@ai-ecoverse/slicc-spectrum 1.58.2 → 1.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/slicc-ui.js CHANGED
@@ -8702,6 +8702,51 @@ function resolveColor(scheme, prefersDark) {
8702
8702
  if (scheme === "system") return prefersDark ? "dark" : "light";
8703
8703
  return scheme;
8704
8704
  }
8705
+ var paints = /* @__PURE__ */ new WeakMap();
8706
+ function schemeOf(media2) {
8707
+ const query = media2.replace(/\s/g, "").toLowerCase();
8708
+ const scheme = query.match(/prefers-color-scheme:(light|dark)/)?.[1];
8709
+ if (!scheme) return null;
8710
+ if (!query.startsWith("not")) return scheme;
8711
+ return scheme === "dark" ? "light" : "dark";
8712
+ }
8713
+ function apply(doc, paint, color) {
8714
+ doc.documentElement.style.colorScheme = color;
8715
+ const metas = [...doc.head.querySelectorAll('meta[name="theme-color"]')];
8716
+ for (const meta of metas) if (!paint.tones.has(meta)) paint.tones.set(meta, meta.content);
8717
+ const own4 = metas.find((meta) => schemeOf(meta.media ?? "") === color);
8718
+ if (!own4) return;
8719
+ const tone = paint.tones.get(own4);
8720
+ for (const meta of metas) meta.content = tone;
8721
+ }
8722
+ function holdDocument(doc) {
8723
+ const paint = paints.get(doc) ?? {
8724
+ scheme: doc.documentElement.style.colorScheme,
8725
+ priority: doc.documentElement.style.getPropertyPriority("color-scheme"),
8726
+ tones: /* @__PURE__ */ new Map(),
8727
+ holds: /* @__PURE__ */ new Map()
8728
+ };
8729
+ paints.set(doc, paint);
8730
+ const key2 = {};
8731
+ paint.holds.set(key2, null);
8732
+ return {
8733
+ paint(color) {
8734
+ if (!paint.holds.has(key2)) return;
8735
+ paint.holds.delete(key2);
8736
+ paint.holds.set(key2, color);
8737
+ apply(doc, paint, color);
8738
+ },
8739
+ release() {
8740
+ if (!paint.holds.delete(key2)) return;
8741
+ const left = [...paint.holds.values()].filter((color) => color !== null);
8742
+ if (left.length) return apply(doc, paint, left[left.length - 1]);
8743
+ if (paint.holds.size) return;
8744
+ paints.delete(doc);
8745
+ doc.documentElement.style.setProperty("color-scheme", paint.scheme, paint.priority);
8746
+ for (const [meta, tone] of paint.tones) meta.content = tone;
8747
+ }
8748
+ };
8749
+ }
8705
8750
  var ThemedElement = class extends ModelElement {
8706
8751
  #media = globalThis.matchMedia?.("(prefers-color-scheme: dark)") ?? null;
8707
8752
  #change = () => this.requestUpdate();
@@ -10126,7 +10171,7 @@ function coneLabel(model, agent) {
10126
10171
  }
10127
10172
  function watchTitles(model, update) {
10128
10173
  const seen = /* @__PURE__ */ new Map();
10129
- const check2 = (id) => {
10174
+ const check3 = (id) => {
10130
10175
  const agent = model.agent.list().find((candidate) => candidate.id === id);
10131
10176
  if (agent?.kind !== "cone") return;
10132
10177
  const title = agentTitle(model, agent);
@@ -10135,8 +10180,8 @@ function watchTitles(model, update) {
10135
10180
  update();
10136
10181
  };
10137
10182
  const stops = [
10138
- model.agent.on("messages", check2),
10139
- model.agent.on("message", ({ agentId }) => check2(agentId))
10183
+ model.agent.on("messages", check3),
10184
+ model.agent.on("message", ({ agentId }) => check3(agentId))
10140
10185
  ];
10141
10186
  return () => {
10142
10187
  for (const stop of stops) stop();
@@ -10152,15 +10197,15 @@ function ago(at, now = Date.now()) {
10152
10197
  return `${Math.floor(days / 7)} weeks ago`;
10153
10198
  }
10154
10199
  async function deleteCone(model, agent, trigger2) {
10155
- const ok = await confirm({
10200
+ const ok2 = await confirm({
10156
10201
  title: `Delete cone ${coneLabel(model, agent)}?`,
10157
10202
  body: "It stops, with its scoops. Its conversation stays in the Freezer, where you can thaw it.",
10158
10203
  action: "Delete cone",
10159
10204
  variant: "confirmation",
10160
10205
  trigger: trigger2
10161
10206
  });
10162
- if (ok) model.agent.freeze?.(agent.id);
10163
- return ok;
10207
+ if (ok2) model.agent.freeze?.(agent.id);
10208
+ return ok2;
10164
10209
  }
10165
10210
  var frozenKinds = {
10166
10211
  cone: ["indigo", "Cone"],
@@ -10232,14 +10277,14 @@ var SliccFreezer = class extends ModelElement {
10232
10277
  this.focusOn("swc-action-button");
10233
10278
  }
10234
10279
  async #remove(cone, trigger2) {
10235
- const ok = await confirm({
10280
+ const ok2 = await confirm({
10236
10281
  title: `Remove ${this.#named(cone)} from the Freezer?`,
10237
10282
  body: "Its working folders are deleted. The conversation stays in the session database. You can\u2019t undo this.",
10238
10283
  action: "Remove",
10239
10284
  variant: "destructive",
10240
10285
  trigger: trigger2
10241
10286
  });
10242
- if (ok) this.model?.agent.discard(cone.id);
10287
+ if (ok2) this.model?.agent.discard(cone.id);
10243
10288
  }
10244
10289
  #named(cone) {
10245
10290
  const rows = this.model?.agent.frozen() ?? [];
@@ -10458,14 +10503,14 @@ var SliccAgents = class extends ModelElement {
10458
10503
  async #drop(agent, trigger2) {
10459
10504
  const port = this.model?.agent;
10460
10505
  if (!port?.drop) return;
10461
- const ok = await confirm({
10506
+ const ok2 = await confirm({
10462
10507
  title: `Drop scoop ${agent.name}?`,
10463
10508
  body: "It stops, and its working folder is deleted. Its conversation and reports are kept. You can\u2019t undo this.",
10464
10509
  action: "Drop",
10465
10510
  variant: "destructive",
10466
10511
  trigger: trigger2
10467
10512
  });
10468
- if (!ok) return;
10513
+ if (!ok2) return;
10469
10514
  const { [agent.id]: _9, ...rest } = this.errors;
10470
10515
  this.errors = rest;
10471
10516
  try {
@@ -10813,33 +10858,33 @@ var lights = {
10813
10858
  unlinked: ["negative", (owner) => `Unlinked from ${owner}`],
10814
10859
  failed: ["negative", (owner) => `Can\u2019t reach ${owner}`]
10815
10860
  };
10816
- function followLight(state2) {
10817
- const [variant, text2] = lights[state2.link];
10818
- return { variant, text: text2(state2.owner) };
10861
+ function followLight(state3) {
10862
+ const [variant, text2] = lights[state3.link];
10863
+ return { variant, text: text2(state3.owner) };
10819
10864
  }
10820
- function followPage(state2) {
10821
- if (!state2) return null;
10822
- const { owner } = state2;
10823
- if (state2.link === "connecting")
10865
+ function followPage(state3) {
10866
+ if (!state3) return null;
10867
+ const { owner } = state3;
10868
+ if (state3.link === "connecting")
10824
10869
  return {
10825
10870
  kind: "connecting",
10826
10871
  title: `Connecting to ${owner}\u2026`,
10827
10872
  body: `This device follows ${owner}. Its agent shows here once it\u2019s connected.`
10828
10873
  };
10829
- if (state2.link === "unlinked")
10874
+ if (state3.link === "unlinked")
10830
10875
  return {
10831
10876
  kind: "unlinked",
10832
10877
  title: `${owner} unlinked this device`,
10833
10878
  body: `To follow it again, open a new link from ${owner}.`
10834
10879
  };
10835
- if (state2.link === "failed")
10880
+ if (state3.link === "failed")
10836
10881
  return {
10837
10882
  kind: "failed",
10838
10883
  title: `Can\u2019t follow ${owner}`,
10839
- body: state2.error ?? `The link to ${owner} failed.`
10884
+ body: state3.error ?? `The link to ${owner} failed.`
10840
10885
  };
10841
- if (state2.access.view) return null;
10842
- const where2 = state2.name ? `next to ${state2.name}` : "for this device";
10886
+ if (state3.access.view) return null;
10887
+ const where2 = state3.name ? `next to ${state3.name}` : "for this device";
10843
10888
  return {
10844
10889
  kind: "waiting",
10845
10890
  title: `Waiting for ${owner} to allow this device`,
@@ -10850,26 +10895,26 @@ function list(items, last) {
10850
10895
  if (items.length < 2) return items.join("");
10851
10896
  return `${items.slice(0, -1).join(", ")} ${last} ${items.at(-1)}`;
10852
10897
  }
10853
- function followCan(state2) {
10898
+ function followCan(state3) {
10854
10899
  const allowed = ["watch the agent"];
10855
10900
  const missing = [];
10856
- (state2.access.control ? allowed : missing).push("send prompts");
10857
- (state2.access.terminal ? allowed : missing).push("open terminals");
10901
+ (state3.access.control ? allowed : missing).push("send prompts");
10902
+ (state3.access.terminal ? allowed : missing).push("open terminals");
10858
10903
  const can = `This device can ${list(allowed, "and")}.`;
10859
- return missing.length ? `${can} To ${list(missing, "or")}, allow it on ${state2.owner}.` : can;
10904
+ return missing.length ? `${can} To ${list(missing, "or")}, allow it on ${state3.owner}.` : can;
10860
10905
  }
10861
10906
  function following(model) {
10862
- const state2 = model?.follow?.state();
10863
- return state2 && !followPage(state2) ? state2 : null;
10907
+ const state3 = model?.follow?.state();
10908
+ return state3 && !followPage(state3) ? state3 : null;
10864
10909
  }
10865
10910
  function watchOnly(model) {
10866
- const state2 = following(model);
10867
- if (!state2 || state2.access.control) return "";
10868
- return `${state2.owner} lets this device watch only. To send prompts, allow Control for it on ${state2.owner}.`;
10911
+ const state3 = following(model);
10912
+ if (!state3 || state3.access.control) return "";
10913
+ return `${state3.owner} lets this device watch only. To send prompts, allow Control for it on ${state3.owner}.`;
10869
10914
  }
10870
10915
  function terminalsAllowed(model) {
10871
- const state2 = model?.follow?.state();
10872
- return !state2 || !!state2.access.terminal;
10916
+ const state3 = model?.follow?.state();
10917
+ return !state3 || !!state3.access.terminal;
10873
10918
  }
10874
10919
  var SliccFollow = class extends ModelElement {
10875
10920
  static properties = {
@@ -10965,15 +11010,15 @@ var SliccFollow = class extends ModelElement {
10965
11010
  async leave() {
10966
11011
  const port = this.model?.follow;
10967
11012
  if (!port || this.busy) return;
10968
- const state2 = port.state();
10969
- if (state2.link !== "unlinked") {
10970
- const ok = await confirm({
10971
- title: `Stop following ${state2.owner}?`,
10972
- body: `This device forgets the link. To follow ${state2.owner} again, open a new link from it.`,
11013
+ const state3 = port.state();
11014
+ if (state3.link !== "unlinked") {
11015
+ const ok2 = await confirm({
11016
+ title: `Stop following ${state3.owner}?`,
11017
+ body: `This device forgets the link. To follow ${state3.owner} again, open a new link from it.`,
10973
11018
  action: "Leave",
10974
11019
  variant: "confirmation"
10975
11020
  });
10976
- if (!ok) return;
11021
+ if (!ok2) return;
10977
11022
  }
10978
11023
  await this.#run("leave", () => port.leave());
10979
11024
  }
@@ -11012,12 +11057,12 @@ var SliccFollow = class extends ModelElement {
11012
11057
  </div>`;
11013
11058
  }
11014
11059
  render() {
11015
- const state2 = this.model?.follow?.state();
11016
- if (!state2) return A;
11017
- const page = followPage(state2);
11060
+ const state3 = this.model?.follow?.state();
11061
+ if (!state3) return A;
11062
+ const page = followPage(state3);
11018
11063
  if (this.page) return page ? this.#page(page) : A;
11019
- const light = followLight(state2);
11020
- return b`<swc-action-button id="chip" class="chip" size="s" quiet data-follow=${state2.link} accessible-label=${light.text}>
11064
+ const light = followLight(state3);
11065
+ return b`<swc-action-button id="chip" class="chip" size="s" quiet data-follow=${state3.link} accessible-label=${light.text}>
11021
11066
  ${this.compact ? b`<swc-icon-user-following slot="icon" size="s" aria-hidden="true"></swc-icon-user-following>` : A}
11022
11067
  <swc-status-light size="s" variant=${light.variant}><span class="text">${light.text}</span></swc-status-light>
11023
11068
  </swc-action-button>
@@ -11025,8 +11070,8 @@ var SliccFollow = class extends ModelElement {
11025
11070
  <swc-popover for="chip" placement="bottom-end" accessible-label=${light.text}>
11026
11071
  <div class="panel">
11027
11072
  <h2>${light.text}</h2>
11028
- ${state2.link === "reconnecting" ? b`<p class="muted" data-reconnecting>The link to ${state2.owner} dropped. The conversation may be out of date until it’s back${state2.access.control ? ", and sending waits until then" : ""}.</p>` : A}
11029
- <p data-can>${followCan(state2)}</p>
11073
+ ${state3.link === "reconnecting" ? b`<p class="muted" data-reconnecting>The link to ${state3.owner} dropped. The conversation may be out of date until it’s back${state3.access.control ? ", and sending waits until then" : ""}.</p>` : A}
11074
+ <p data-can>${followCan(state3)}</p>
11030
11075
  ${this.#error()}
11031
11076
  <div class="actions">${this.#leaveButton()}</div>
11032
11077
  </div>
@@ -12741,9 +12786,9 @@ var SliccNetwork = class extends ModelElement {
12741
12786
  }
12742
12787
  }
12743
12788
  async copy() {
12744
- const done = await copyText(command);
12745
- this.copied = done;
12746
- this.uncopied = !done;
12789
+ const done2 = await copyText(command);
12790
+ this.copied = done2;
12791
+ this.uncopied = !done2;
12747
12792
  }
12748
12793
  async #act(action, run2, area) {
12749
12794
  if (this.busy) return;
@@ -12790,13 +12835,13 @@ var SliccNetwork = class extends ModelElement {
12790
12835
  if (event2.key === "Enter") this.#sendKey(event2);
12791
12836
  }
12792
12837
  async #signOut(port) {
12793
- const ok = await confirm({
12838
+ const ok2 = await confirm({
12794
12839
  title: "Sign out of Tailscale?",
12795
12840
  body: "This browser leaves your tailnet until you sign in again.",
12796
12841
  action: "Sign out",
12797
12842
  variant: "confirmation"
12798
12843
  });
12799
- if (ok) await this.#tailnet("sign-out", () => port.logoutTailnet?.());
12844
+ if (ok2) await this.#tailnet("sign-out", () => port.logoutTailnet?.());
12800
12845
  }
12801
12846
  #copyButton(key2, what, label, value, area, hidden = false) {
12802
12847
  const copied = this.tailnetCopied === key2;
@@ -12904,13 +12949,13 @@ var SliccNetwork = class extends ModelElement {
12904
12949
  async #setControl(port, device, toggle) {
12905
12950
  const allowed = toggle.checked;
12906
12951
  if (allowed) {
12907
- const ok = await confirm({
12952
+ const ok2 = await confirm({
12908
12953
  title: `Allow remote control from ${device.name}?`,
12909
12954
  body: "It can send prompts to the agent, watch its replies and stop it. Unlinking it, or a new certificate on it, turns this off again.",
12910
12955
  action: "Allow",
12911
12956
  variant: "confirmation"
12912
12957
  });
12913
- if (!ok) {
12958
+ if (!ok2) {
12914
12959
  toggle.checked = false;
12915
12960
  return;
12916
12961
  }
@@ -12923,22 +12968,22 @@ var SliccNetwork = class extends ModelElement {
12923
12968
  }
12924
12969
  async #unlink(port, status2, device) {
12925
12970
  const isExit = status2.exit?.kind === "link" && status2.exit.id === device.id;
12926
- const ok = await confirm({
12971
+ const ok2 = await confirm({
12927
12972
  title: `Unlink ${device.name}?`,
12928
12973
  body: unlinkBody(device, isExit),
12929
12974
  action: "Unlink",
12930
12975
  variant: "confirmation"
12931
12976
  });
12932
- if (ok) await this.#act(`unlink:${device.id}`, () => port.unlink?.(device.id), "linksError");
12977
+ if (ok2) await this.#act(`unlink:${device.id}`, () => port.unlink?.(device.id), "linksError");
12933
12978
  }
12934
12979
  async #rotate(port, follow) {
12935
- const ok = await confirm({
12980
+ const ok2 = await confirm({
12936
12981
  title: "Make a new join URL?",
12937
12982
  body: `Linked devices stay linked. Anyone with the old ${follow ? "join URL, follow link or QR code" : "URL"} can\u2019t link anymore.`,
12938
12983
  action: "New URL",
12939
12984
  variant: "confirmation"
12940
12985
  });
12941
- if (ok) await this.#act("rotate", () => port.rotateJoinUrl?.(), "linksError");
12986
+ if (ok2) await this.#act("rotate", () => port.rotateJoinUrl?.(), "linksError");
12942
12987
  }
12943
12988
  #access(port, device) {
12944
12989
  const access = device.access;
@@ -13117,14 +13162,14 @@ var SliccNetwork = class extends ModelElement {
13117
13162
  </section>`;
13118
13163
  }
13119
13164
  async #disconnect(tray, name, trigger2) {
13120
- const ok = await confirm({
13165
+ const ok2 = await confirm({
13121
13166
  title: `Disconnect from ${name}?`,
13122
13167
  body: "This SLICC stops syncing with the tray until you reconnect.",
13123
13168
  action: "Disconnect",
13124
13169
  variant: "confirmation",
13125
13170
  trigger: trigger2
13126
13171
  });
13127
- if (ok) tray.disconnect();
13172
+ if (ok2) tray.disconnect();
13128
13173
  }
13129
13174
  #sync(tray) {
13130
13175
  const status2 = tray.status();
@@ -13321,8 +13366,9 @@ function create(tag3, model, params = {}) {
13321
13366
  function sideOf(id) {
13322
13367
  return surface(terminalOf(id) === null ? id : "terminal")?.side ?? "center";
13323
13368
  }
13324
- function first(dock, side) {
13325
- return dock.api.panels.find((panel) => sideOf(panel.id) === side)?.id;
13369
+ var home = (panel) => sideOf(panel.id);
13370
+ function first(dock, side, sider, except) {
13371
+ return dock.api.panels.find((panel) => panel.id !== except && sider(panel) === side)?.id;
13326
13372
  }
13327
13373
  var neighbours = {
13328
13374
  left: [
@@ -13338,26 +13384,47 @@ var neighbours = {
13338
13384
  ["left", "right"]
13339
13385
  ]
13340
13386
  };
13341
- function placement(dock, side, screen) {
13387
+ function place(dock, side, screen, sider, except) {
13342
13388
  const anchor = (id, direction) => id ? { position: { referencePanel: id, direction } } : null;
13343
13389
  if (screen === "phone") return anchor(dock.api.panels[0]?.id, "within") ?? {};
13344
- const same = anchor(first(dock, side), "within");
13390
+ const same = anchor(first(dock, side, sider, except), "within");
13345
13391
  if (same) return same;
13346
13392
  for (const [other, direction] of neighbours[side]) {
13347
- const found = anchor(first(dock, other), direction);
13393
+ const found = anchor(first(dock, other, sider, except), direction);
13348
13394
  if (found) return found;
13349
13395
  }
13350
13396
  return {};
13351
13397
  }
13352
- function openSurface(dock, item2, screen) {
13398
+ function placement(dock, side, screen) {
13399
+ return place(dock, side, screen, home);
13400
+ }
13401
+ function views(node) {
13402
+ return node.type === "leaf" ? node.data.views : node.data.flatMap(views);
13403
+ }
13404
+ function destination(dock, id, side, screen) {
13405
+ const { grid } = dock.api.toJSON();
13406
+ const root2 = grid.root;
13407
+ const columns = String(grid.orientation) === "HORIZONTAL" && root2.type === "branch" ? root2.data.map(views) : [views(root2)];
13408
+ const holds = (test) => columns.findIndex((ids) => ids.some((other) => other !== id && test(other)));
13409
+ const chat = holds((other) => chatAgent(other) !== null);
13410
+ const middle = chat < 0 ? holds((other) => sideOf(other) === "center") : chat;
13411
+ const current = (panel) => {
13412
+ if (middle < 0) return home(panel);
13413
+ const at = columns.findIndex((ids) => ids.includes(panel.id));
13414
+ return at < middle ? "left" : at > middle ? "right" : "center";
13415
+ };
13416
+ return place(dock, side, screen, current, id);
13417
+ }
13418
+ function openSurface(dock, item2, screen, focus = true) {
13353
13419
  if (dock.has(item2.id)) return;
13354
- const place2 = placement(dock, item2.side, screen);
13355
- const fresh2 = place2.position?.direction !== "within";
13420
+ const place3 = placement(dock, item2.side, screen);
13421
+ const fresh2 = place3.position?.direction !== "within";
13356
13422
  dock.open({
13357
13423
  id: item2.id,
13358
13424
  component: item2.id,
13359
13425
  title: item2.title,
13360
- ...place2,
13426
+ inactive: !focus,
13427
+ ...place3,
13361
13428
  ...fresh2 && item2.width && screen !== "phone" ? { initialWidth: item2.width } : {}
13362
13429
  });
13363
13430
  }
@@ -13374,35 +13441,37 @@ function openChat(dock, agent, screen, focus = true, reveal = true) {
13374
13441
  const id = chatId(agent.id);
13375
13442
  if (!dock.has(id)) {
13376
13443
  const sibling = chats(dock)[0];
13377
- const place2 = sibling ? { position: { referencePanel: sibling, direction: "within" } } : placement(dock, "center", screen);
13444
+ const place3 = sibling ? { position: { referencePanel: sibling, direction: "within" } } : placement(dock, "center", screen);
13378
13445
  dock.open({
13379
13446
  id,
13380
13447
  component: "chat",
13381
13448
  title: agent.name,
13382
13449
  params: { agent: agent.id },
13383
13450
  inactive: !focus,
13384
- ...place2
13451
+ ...place3
13385
13452
  });
13386
13453
  }
13387
13454
  if (focus) dock.focusPanel(id);
13388
13455
  else if (reveal) dock.reveal(id);
13389
13456
  return id;
13390
13457
  }
13391
- function openDocument(dock, kind, path, screen) {
13458
+ function openDocument(dock, kind, path, screen, focus = true) {
13392
13459
  const id = `${kind}:${path}`;
13393
13460
  if (!dock.has(id)) {
13394
13461
  const sibling = dock.api.panels.find((panel) => /^(file|diff):/.test(panel.id));
13395
13462
  const chat = chats(dock)[0];
13396
- const place2 = sibling ? { position: { referencePanel: sibling.id, direction: "within" } } : chat && screen !== "phone" ? { position: { referencePanel: chat, direction: "right" } } : placement(dock, "center", screen);
13463
+ const place3 = sibling ? { position: { referencePanel: sibling.id, direction: "within" } } : chat && screen !== "phone" ? { position: { referencePanel: chat, direction: "right" } } : placement(dock, "center", screen);
13397
13464
  dock.open({
13398
13465
  id,
13399
13466
  component: kind,
13400
13467
  title: documents[kind].title(path),
13401
13468
  params: { path },
13402
- ...place2
13469
+ inactive: !focus,
13470
+ ...place3
13403
13471
  });
13404
13472
  }
13405
- dock.focusPanel(id);
13473
+ if (focus) dock.focusPanel(id);
13474
+ else dock.reveal(id);
13406
13475
  return id;
13407
13476
  }
13408
13477
  function terminalPanel(terminal) {
@@ -13471,7 +13540,7 @@ var directions = {
13471
13540
  function dropPlacement(panel, position) {
13472
13541
  return panel ? { position: { referencePanel: panel, direction: directions[position] ?? "within" } } : null;
13473
13542
  }
13474
- function openSprinkle(dock, sprinkle, screen, place2 = null) {
13543
+ function openSprinkle(dock, sprinkle, screen, place3 = null, focus = true) {
13475
13544
  const id = `sprinkle:${sprinkle.id}`;
13476
13545
  if (!dock.has(id)) {
13477
13546
  dock.open({
@@ -13479,13 +13548,364 @@ function openSprinkle(dock, sprinkle, screen, place2 = null) {
13479
13548
  component: "sprinkle",
13480
13549
  title: sprinkle.title,
13481
13550
  params: { sprinkle: sprinkle.id },
13482
- ...place2 ?? placement(dock, "right", screen)
13551
+ inactive: !focus,
13552
+ ...place3 ?? placement(dock, "right", screen)
13483
13553
  });
13484
13554
  }
13485
- dock.focusPanel(id);
13555
+ if (focus) dock.focusPanel(id);
13556
+ else dock.reveal(id);
13486
13557
  return id;
13487
13558
  }
13488
13559
 
13560
+ // src/app/panel-command.ts
13561
+ var userCloseWindow = 6e4;
13562
+ var positions = {
13563
+ left: "left",
13564
+ right: "right",
13565
+ above: "top",
13566
+ below: "bottom",
13567
+ within: "center"
13568
+ };
13569
+ var ok = (message) => ({ code: 0, message });
13570
+ var refused = (message) => ({ code: 5, message });
13571
+ var unknown = (id) => ({
13572
+ code: 1,
13573
+ message: `no panel called ${id}; panel list shows the ids you can use`
13574
+ });
13575
+ var Panels = class {
13576
+ #host;
13577
+ #quiet = 0;
13578
+ #closed = /* @__PURE__ */ new Map();
13579
+ constructor(host4) {
13580
+ this.#host = host4;
13581
+ }
13582
+ quietly(run2) {
13583
+ this.#quiet++;
13584
+ try {
13585
+ return run2();
13586
+ } finally {
13587
+ this.#quiet--;
13588
+ }
13589
+ }
13590
+ closed(id) {
13591
+ if (this.#quiet === 0) this.#closed.set(id, Date.now());
13592
+ }
13593
+ closedAgo(id) {
13594
+ const at = this.#closed.get(id);
13595
+ if (at === void 0) return null;
13596
+ const ago2 = Date.now() - at;
13597
+ return ago2 < userCloseWindow ? ago2 : null;
13598
+ }
13599
+ recentClose() {
13600
+ const dock = this.#host.dock();
13601
+ for (const id of this.#closed.keys()) {
13602
+ const ago2 = this.closedAgo(id);
13603
+ if (ago2 !== null && !dock.has(id)) return { id, ago: ago2 };
13604
+ }
13605
+ return null;
13606
+ }
13607
+ typing() {
13608
+ return this.#host.typing();
13609
+ }
13610
+ agents() {
13611
+ return this.#host.model()?.agent.list() ?? [];
13612
+ }
13613
+ active() {
13614
+ return this.#host.model()?.agent.active() ?? null;
13615
+ }
13616
+ list() {
13617
+ const host4 = this.#host;
13618
+ const surfaces3 = host4.surfaces();
13619
+ const offers = (id) => surfaces3.some((item2) => item2.id === id);
13620
+ const rows = [
13621
+ ...surfaces3.filter((item2) => item2.id !== "chat" && item2.id !== "terminal").map((item2) => ({
13622
+ id: item2.id,
13623
+ title: item2.title,
13624
+ kind: "surface",
13625
+ side: item2.side,
13626
+ agent: null
13627
+ })),
13628
+ ...(offers("chat") ? this.agents() : []).map((agent) => ({
13629
+ id: `chat:${agent.id}`,
13630
+ title: agent.name,
13631
+ kind: "chat",
13632
+ side: "center",
13633
+ agent: agent.id
13634
+ })),
13635
+ ...(offers("terminal") ? host4.model()?.terminals.list() ?? [] : []).map((info) => ({
13636
+ id: terminalPanel(info.id),
13637
+ title: terminalTitle(info),
13638
+ kind: "terminal",
13639
+ side: "right",
13640
+ agent: null
13641
+ })),
13642
+ ...host4.sprinkles().map((sprinkle) => ({
13643
+ id: `sprinkle:${sprinkle.id}`,
13644
+ title: sprinkle.title,
13645
+ kind: "sprinkle",
13646
+ side: "right",
13647
+ agent: sprinkle.id.includes("/") ? sprinkle.agentId : null
13648
+ })),
13649
+ ...host4.dock().api.panels.filter((panel) => /^(file|diff):/.test(panel.id)).map((panel) => ({
13650
+ id: panel.id,
13651
+ title: panel.title ?? panel.id,
13652
+ kind: panel.id.slice(0, panel.id.indexOf(":")),
13653
+ side: "center",
13654
+ agent: null
13655
+ }))
13656
+ ];
13657
+ return rows.map((row) => this.#state(row));
13658
+ }
13659
+ #state(row) {
13660
+ const dock = this.#host.dock();
13661
+ const panel = dock.api.getPanel(row.id);
13662
+ const content = dock.content(row.id);
13663
+ return {
13664
+ ...row,
13665
+ open: panel !== void 0,
13666
+ visible: panel?.api.isVisible === true,
13667
+ active: panel !== void 0 && dock.api.activePanel?.id === row.id,
13668
+ busy: content?.busyReason ?? null
13669
+ };
13670
+ }
13671
+ find(id) {
13672
+ const listed = this.list().find((info) => info.id === id);
13673
+ if (listed) return listed;
13674
+ const document2 = id.match(/^(file|diff):(.+)$/);
13675
+ if (!document2) return void 0;
13676
+ return this.#state({
13677
+ id,
13678
+ title: id,
13679
+ kind: document2[1],
13680
+ side: "center",
13681
+ agent: null
13682
+ });
13683
+ }
13684
+ open(id, options = {}) {
13685
+ return this.#show(id, false, options);
13686
+ }
13687
+ focus(id, options = {}) {
13688
+ return this.#show(id, true, options);
13689
+ }
13690
+ #show(id, focus, { place: place3, section }) {
13691
+ const info = this.find(id);
13692
+ if (!info) return unknown(id);
13693
+ const bad = this.#reference(id, place3);
13694
+ if (bad) return bad;
13695
+ this.quietly(() => this.#host.open(id, focus, section));
13696
+ if (place3) {
13697
+ const moved = this.move(id, place3);
13698
+ if (moved.code !== 0) return moved;
13699
+ }
13700
+ return ok(`${focus ? "focused" : info.open ? "showed" : "opened"} ${id}`);
13701
+ }
13702
+ close(id) {
13703
+ const info = this.find(id);
13704
+ if (!info) return unknown(id);
13705
+ if (!info.open) return ok(`${id} was already closed`);
13706
+ if (info.kind === "terminal")
13707
+ return refused(`closing ${id} stops its shell; ask the user to close it`);
13708
+ if (info.kind === "chat" && chats(this.#host.dock()).length === 1)
13709
+ return refused(`${id} is the last chat, so it stays open`);
13710
+ if (info.busy) return refused(`${id} is busy: ${info.busy}`);
13711
+ this.quietly(() => this.#host.dock().close(id));
13712
+ return ok(`closed ${id}`);
13713
+ }
13714
+ move(id, place3) {
13715
+ const info = this.find(id);
13716
+ if (!info) return unknown(id);
13717
+ const bad = this.#reference(id, place3);
13718
+ if (bad) return bad;
13719
+ const dock = this.#host.dock();
13720
+ if (!info.open) this.quietly(() => this.#host.open(id, false));
13721
+ if (!dock.has(id)) return unknown(id);
13722
+ if (this.#host.screen() === "phone")
13723
+ return ok(`phones show one panel at a time, so ${id} stays where it is`);
13724
+ const busy = info.open ? info.busy : this.find(id)?.busy ?? null;
13725
+ if (busy) return refused(`${id} is busy: ${busy}`);
13726
+ const target = typeof place3 === "string" ? destination(dock, id, place3, this.#host.screen()) : { position: { referencePanel: place3.ref, direction: place3.direction } };
13727
+ const reference2 = target.position && dock.api.getPanel(target.position.referencePanel);
13728
+ if (!reference2 || !target.position) return ok(`${id} is the only panel, so it stays`);
13729
+ const position = positions[target.position.direction];
13730
+ const panel = dock.api.getPanel(id);
13731
+ this.quietly(() => panel?.api.moveTo({ group: reference2.group, position }));
13732
+ return ok(`moved ${id}`);
13733
+ }
13734
+ #reference(id, place3) {
13735
+ if (typeof place3 !== "object") return null;
13736
+ if (place3.ref === id) return { code: 2, message: `can't place ${id} beside itself` };
13737
+ if (!this.#host.dock().has(place3.ref)) return { code: 1, message: `${place3.ref} isn't open` };
13738
+ return null;
13739
+ }
13740
+ reset() {
13741
+ const busy = this.list().find((info) => info.open && info.busy);
13742
+ if (busy) return refused(`${busy.id} is busy: ${busy.busy}`);
13743
+ this.quietly(() => this.#host.reset());
13744
+ return ok("restored the default layout");
13745
+ }
13746
+ };
13747
+ var help = `usage: panel <command>
13748
+
13749
+ list [--json] the panels you can reach, and their state
13750
+ open <id> [place] show a panel; keyboard focus stays where it is
13751
+ focus <id> [place] show a panel and give it keyboard focus
13752
+ close <id> close a panel
13753
+ move <id> <place> move an open panel
13754
+ reset restore the default layout
13755
+
13756
+ place: left | center | right, or --left | --right | --above | --below | --within <id>
13757
+ open and focus also take --section <name>, e.g. panel open settings --section accounts
13758
+
13759
+ ids: the ones panel list shows, e.g. files, changes, terminal, monitor, settings,
13760
+ chat (your cone's chat), chat:<agent>, terminal:<n>, sprinkle:<name>,
13761
+ file:<path>, diff:<path>
13762
+ `;
13763
+ var verbs = /* @__PURE__ */ new Set(["list", "open", "focus", "close", "move", "reset"]);
13764
+ var sides = /* @__PURE__ */ new Set(["left", "center", "right"]);
13765
+ var directions2 = /* @__PURE__ */ new Set(["left", "right", "above", "below", "within"]);
13766
+ function scan(parsed, rest, positional) {
13767
+ for (let index = 0; index < rest.length; index++) {
13768
+ const arg = rest[index];
13769
+ const flag = arg.startsWith("--") ? arg.slice(2) : null;
13770
+ if (flag === "json") parsed.json = true;
13771
+ else if (flag === "section" || flag !== null && directions2.has(flag)) {
13772
+ const value = rest[++index];
13773
+ if (value === void 0) return `--${flag} needs a value`;
13774
+ if (flag === "section") parsed.section = value;
13775
+ else if (parsed.place) return "give one place";
13776
+ else parsed.place = { direction: flag, ref: value };
13777
+ } else if (arg.startsWith("-")) return `unknown option ${arg}`;
13778
+ else positional.push(arg);
13779
+ }
13780
+ const [id, side, ...extra] = positional;
13781
+ if (extra.length > 0) return `unexpected ${extra[0]}`;
13782
+ parsed.id = id;
13783
+ if (side === void 0) return null;
13784
+ if (!sides.has(side)) return `${side} isn't a place; use left, center or right`;
13785
+ if (parsed.place) return "give one place";
13786
+ parsed.place = side;
13787
+ return null;
13788
+ }
13789
+ function check({ verb, id, json, section, place: place3 }) {
13790
+ const ids = verb === "list" || verb === "reset" ? 0 : 1;
13791
+ if ((id === void 0 ? 0 : 1) !== ids)
13792
+ return ids ? `${verb} needs an id` : `${verb} takes no id`;
13793
+ if (json && verb !== "list") return "--json is for list";
13794
+ if (section !== void 0 && verb !== "open" && verb !== "focus")
13795
+ return "--section is for open and focus";
13796
+ if (place3 && verb !== "open" && verb !== "focus" && verb !== "move")
13797
+ return `${verb} takes no place`;
13798
+ if (verb === "move" && !place3) return "move needs a place";
13799
+ return null;
13800
+ }
13801
+ function parse(args2) {
13802
+ const [verb, ...rest] = args2;
13803
+ if (!verbs.has(verb)) return `unknown command ${verb}`;
13804
+ const parsed = { verb, json: false };
13805
+ return scan(parsed, rest, []) ?? check(parsed) ?? parsed;
13806
+ }
13807
+ function coneOf(agents, id) {
13808
+ let agent = agents.find((candidate) => candidate.id === id);
13809
+ const seen = /* @__PURE__ */ new Set();
13810
+ while (agent && agent.kind !== "cone" && !seen.has(agent)) {
13811
+ seen.add(agent);
13812
+ agent = agents.find((candidate) => candidate.id === agent?.parentId);
13813
+ }
13814
+ return agent?.kind === "cone" ? agent.id : null;
13815
+ }
13816
+ function resolve(panels, raw2, reachable, cone) {
13817
+ if (/^(file|diff):./.test(raw2)) return raw2;
13818
+ if (raw2 === "chat") {
13819
+ const agent = cone === void 0 ? panels.active() : cone;
13820
+ return reachable.some((info) => info.id === `chat:${agent}`) ? `chat:${agent}` : null;
13821
+ }
13822
+ if (raw2 === "terminal") {
13823
+ const terminals = reachable.filter((info) => info.kind === "terminal");
13824
+ const picked = terminals.find((info) => info.active) ?? terminals.filter((info) => info.open).at(-1) ?? terminals.at(-1);
13825
+ return picked?.id ?? null;
13826
+ }
13827
+ if (reachable.some((info) => info.id === raw2)) return raw2;
13828
+ const name = raw2.startsWith("sprinkle:") ? raw2.slice(9) : raw2;
13829
+ const sprinkles = reachable.filter((info) => info.kind === "sprinkle");
13830
+ const found = sprinkles.find((info) => info.id === `sprinkle:${name}`) ?? sprinkles.find((info) => cone && info.id === `sprinkle:${cone}/${name}`) ?? sprinkles.find((info) => info.id.split("/").at(-1) === name);
13831
+ return found?.id ?? null;
13832
+ }
13833
+ function state(info) {
13834
+ const shown2 = info.active ? "active" : info.visible ? "shown" : info.open ? "open" : "closed";
13835
+ return info.busy ? `${shown2} \xB7 busy: ${info.busy}` : shown2;
13836
+ }
13837
+ function table(rows) {
13838
+ const lines = [["ID", "TITLE", "STATE"], ...rows.map((row) => [row.id, row.title, state(row)])];
13839
+ const widths = [0, 1].map((column) => Math.max(...lines.map((line) => line[column].length)));
13840
+ return lines.map(([id, title, shown2]) => `${id.padEnd(widths[0])} ${title.padEnd(widths[1])} ${shown2}`).join("\n");
13841
+ }
13842
+ var done = (result, note = "") => result.code === 0 ? { stdout: `${result.message}${note}
13843
+ `, stderr: "", code: 0 } : { stdout: "", stderr: `panel: ${result.message}
13844
+ `, code: result.code };
13845
+ function act(scope, parsed) {
13846
+ const { panels, reachable, cone } = scope;
13847
+ if (parsed.verb === "reset") {
13848
+ const recent = scope.agent ? panels.recentClose() : null;
13849
+ if (recent)
13850
+ return refusedOutput(
13851
+ `the user closed ${recent.id} ${Math.round(recent.ago / 1e3)} s ago; ask before resetting the layout`
13852
+ );
13853
+ return done(panels.reset());
13854
+ }
13855
+ const raw2 = parsed.id;
13856
+ const id = resolve(panels, raw2, reachable, cone);
13857
+ if (!id) return done(unknown(raw2));
13858
+ let place3 = parsed.place;
13859
+ if (typeof place3 === "object") {
13860
+ const ref = resolve(panels, place3.ref, reachable, cone);
13861
+ if (!ref) return done(unknown(place3.ref));
13862
+ place3 = { ...place3, ref };
13863
+ }
13864
+ if (parsed.verb === "close") return done(panels.close(id));
13865
+ const ago2 = scope.agent && !panels.find(id)?.open ? panels.closedAgo(id) : null;
13866
+ if (ago2 !== null)
13867
+ return refusedOutput(
13868
+ `the user closed ${id} ${Math.round(ago2 / 1e3)} s ago; ask before opening it again`
13869
+ );
13870
+ if (parsed.verb === "move") return done(panels.move(id, place3));
13871
+ const options = { place: place3, section: parsed.section };
13872
+ if (parsed.verb === "open") return done(panels.open(id, options));
13873
+ if (scope.agent && panels.typing())
13874
+ return done(
13875
+ panels.open(id, options),
13876
+ "; the user is typing, so it was shown without taking focus"
13877
+ );
13878
+ return done(panels.focus(id, options));
13879
+ }
13880
+ function panelCommand(app, argv, caller) {
13881
+ const panels = app.panels;
13882
+ const args2 = argv[0] === "panel" ? argv.slice(1) : argv;
13883
+ if (args2.length === 0 || args2[0] === "--help" || args2[0] === "-h" || args2[0] === "help")
13884
+ return { stdout: help, stderr: "", code: 0 };
13885
+ if (caller.readOnly && args2[0] !== "list")
13886
+ return refusedOutput("this page only follows SLICC; panel list is all it allows");
13887
+ const parsed = parse(args2);
13888
+ if (typeof parsed === "string")
13889
+ return { stdout: "", stderr: `panel: ${parsed}
13890
+
13891
+ ${help}`, code: 2 };
13892
+ const agents = panels.agents();
13893
+ const scoped2 = caller.agentId !== null || !!caller.cone;
13894
+ const cone = scoped2 ? caller.cone ?? coneOf(agents, caller.agentId) : void 0;
13895
+ const reachable = panels.list().filter(
13896
+ (info) => !scoped2 || info.agent === null || !!cone && coneOf(agents, info.agent) === cone
13897
+ );
13898
+ if (parsed.verb !== "list")
13899
+ return act({ panels, agent: caller.agentId !== null, cone, reachable }, parsed);
13900
+ const body4 = parsed.json ? JSON.stringify(reachable, null, 2) : table(reachable);
13901
+ return { stdout: `${body4}
13902
+ `, stderr: "", code: 0 };
13903
+ }
13904
+ function refusedOutput(message) {
13905
+ return { stdout: "", stderr: `panel: ${message}
13906
+ `, code: 5 };
13907
+ }
13908
+
13489
13909
  // node_modules/@adobe/spectrum-wc/dist/swc.css
13490
13910
  var swc_default = `/**
13491
13911
  * Copyright 2026 Adobe. All rights reserved.
@@ -13617,23 +14037,23 @@ function installProperties(document2, text2 = swc_default) {
13617
14037
  var following2 = "SLICC runs in another tab. This tab shows it and sends your actions there.";
13618
14038
  var connecting = "Connecting to the tab running SLICC\u2026";
13619
14039
  var alone = "SLICC is open in another tab.";
13620
- function tabsBanner(state2) {
13621
- if (!state2 || state2.role === "alone") return null;
13622
- if (state2.skew === "newer")
14040
+ function tabsBanner(state3) {
14041
+ if (!state3 || state3.role === "alone") return null;
14042
+ if (state3.skew === "newer")
13623
14043
  return {
13624
14044
  kind: "skew",
13625
14045
  skew: "newer",
13626
14046
  text: "Another tab runs a newer SLICC. Reload this tab.",
13627
14047
  reload: true
13628
14048
  };
13629
- if (state2.skew === "older")
14049
+ if (state3.skew === "older")
13630
14050
  return {
13631
14051
  kind: "skew",
13632
14052
  skew: "older",
13633
14053
  text: "Another tab runs an older SLICC. Reload the other SLICC tab.",
13634
14054
  reload: false
13635
14055
  };
13636
- if (state2.stalled)
14056
+ if (state3.stalled)
13637
14057
  return {
13638
14058
  kind: "stalled",
13639
14059
  skew: null,
@@ -13642,11 +14062,11 @@ function tabsBanner(state2) {
13642
14062
  };
13643
14063
  return null;
13644
14064
  }
13645
- function tabsLight(state2) {
13646
- if (!state2 || state2.role === "owner" || state2.role === "alone") return null;
13647
- const banner = tabsBanner(state2);
14065
+ function tabsLight(state3) {
14066
+ if (!state3 || state3.role === "owner" || state3.role === "alone") return null;
14067
+ const banner = tabsBanner(state3);
13648
14068
  if (banner) return { variant: "notice", text: "Another tab", tooltip: banner.text };
13649
- if (state2.role === "connecting")
14069
+ if (state3.role === "connecting")
13650
14070
  return { variant: "info", text: "Connecting", tooltip: connecting };
13651
14071
  return { variant: "neutral", text: "Another tab", tooltip: following2 };
13652
14072
  }
@@ -13887,11 +14307,11 @@ var SliccTerminalPanel = class extends ThemedElement {
13887
14307
  const host4 = this.getRootNode().host;
13888
14308
  const panel = host4?.localName === "slicc-dock" ? host4.api.getPanel(terminalPanel(id)) : void 0;
13889
14309
  if (!panel || laid(panel.api)) return Promise.resolve();
13890
- return new Promise((resolve) => {
14310
+ return new Promise((resolve2) => {
13891
14311
  const watch = panel.api.onDidDimensionsChange((size4) => {
13892
14312
  if (!laid(size4)) return;
13893
14313
  watch.dispose();
13894
- resolve();
14314
+ resolve2();
13895
14315
  });
13896
14316
  });
13897
14317
  }
@@ -19845,7 +20265,7 @@ function block(lines, i25) {
19845
20265
  const end = run(lines, i25, (l24) => l24.trim() !== "" && !starts.test(l24) && !itemPattern.test(l24));
19846
20266
  return [{ type: "paragraph", text: lines.slice(i25, end).join(" ") }, end];
19847
20267
  }
19848
- function parse(text2) {
20268
+ function parse2(text2) {
19849
20269
  const lines = text2.split("\n");
19850
20270
  const blocks = [];
19851
20271
  let i25 = 0;
@@ -19886,7 +20306,7 @@ function render(entry) {
19886
20306
  }
19887
20307
  }
19888
20308
  function markdown(text2) {
19889
- return b`${parse(text2).map(render)}`;
20309
+ return b`${parse2(text2).map(render)}`;
19890
20310
  }
19891
20311
 
19892
20312
  // src/app/messages.ts
@@ -20012,7 +20432,7 @@ function toolSummary(calls) {
20012
20432
  }
20013
20433
  return [...counts].sort((a22, b13) => b13[1] - a22[1]).map(([kind, count]) => `${count} ${count === 1 ? kind.one : kind.many}`).join(", ");
20014
20434
  }
20015
- function state(status2, label = toolStates[status2][0]) {
20435
+ function state2(status2, label = toolStates[status2][0]) {
20016
20436
  return b`<span class="state" data-state=${status2}>${toolStates[status2][1]}<span>${label}</span></span>`;
20017
20437
  }
20018
20438
  var actionLabels = {
@@ -20069,7 +20489,7 @@ function tool(call, color = "light") {
20069
20489
  <span class="title">${call.title}</span>
20070
20490
  <span class="name">${call.name}</span>
20071
20491
  ${call.meta ? b`<span class="tool-meta">${call.meta}</span>` : A}
20072
- ${state(call.status)}
20492
+ ${state2(call.status)}
20073
20493
  </span>
20074
20494
  ${call.image ? b`<span class="thumb"><img src=${call.image} alt="" /></span>` : A}
20075
20495
  </summary>
@@ -20094,7 +20514,7 @@ function cluster(calls, open, color) {
20094
20514
  <swc-icon-chevron-right class="chevron" size="s" aria-hidden="true"></swc-icon-chevron-right>
20095
20515
  <span class="title">${calls.length} tools</span>
20096
20516
  <span class="names"><span aria-hidden="true">· </span>${toolSummary(calls)}</span>
20097
- ${state(overall, label || void 0)}
20517
+ ${state2(overall, label || void 0)}
20098
20518
  </summary>
20099
20519
  <div class="calls">${calls.map((call) => tool(call, color))}</div>
20100
20520
  </details>`;
@@ -20129,7 +20549,7 @@ function card(item2) {
20129
20549
  }
20130
20550
  return b`<div class="card light" data-tone=${item2.tone}><strong>${item2.title}</strong><span>${item2.detail}</span></div>`;
20131
20551
  }
20132
- function check(items) {
20552
+ function check2(items) {
20133
20553
  return b`<ul class="check">
20134
20554
  ${items.map((entry) => b`<li data-tone=${entry.tone ?? "positive"}><span class="mark" aria-hidden="true">✓</span>${entry.text}</li>`)}
20135
20555
  </ul>`;
@@ -20199,7 +20619,7 @@ function part(entry, handlers, showThinking) {
20199
20619
  case "plan":
20200
20620
  return b`<div class="plan"><div class="label">Plan</div><ol>${entry.items.map((step) => b`<li>${step}</li>`)}</ol></div>`;
20201
20621
  case "check":
20202
- return check(entry.items);
20622
+ return check2(entry.items);
20203
20623
  case "diff":
20204
20624
  return b`<div class="inline-diff">
20205
20625
  <button class="diff-head" @click=${() => handlers.open(entry.path)}>${entry.path}</button>
@@ -21110,7 +21530,7 @@ function requiresText(item2, all2) {
21110
21530
  ].filter(Boolean);
21111
21531
  return parts2.length ? parts2.join("; ") : null;
21112
21532
  }
21113
- var snapshot = (items) => new Map(items.map(({ id, state: state2, error }) => [id, { state: state2, error }]));
21533
+ var snapshot = (items) => new Map(items.map(({ id, state: state3, error }) => [id, { state: state3, error }]));
21114
21534
  function settled(failures, before, after) {
21115
21535
  return new Map(
21116
21536
  [...failures].filter(([id]) => {
@@ -21173,6 +21593,11 @@ var SliccUpdates = class extends ModelElement {
21173
21593
  this.busy = /* @__PURE__ */ new Map();
21174
21594
  this.problems = /* @__PURE__ */ new Map();
21175
21595
  }
21596
+ get busyReason() {
21597
+ const packages = this.model?.updates?.packages?.() ?? [];
21598
+ const running2 = this.busy.size > 0 || packages.some((item2) => packageRunning.has(item2.state));
21599
+ return running2 ? "a package is installing" : null;
21600
+ }
21176
21601
  static styles = [
21177
21602
  i`
21178
21603
  :host {
@@ -21521,8 +21946,8 @@ var SliccUpdates = class extends ModelElement {
21521
21946
  return b`<span>Checked <time datetime=${date.toISOString()}>${shown2}</time></span>`;
21522
21947
  }
21523
21948
  #item(item2) {
21524
- const [variant, state2] = states[item2.state];
21525
- const label = item2.state === "failed" && item2.from !== null ? "Update failed" : state2;
21949
+ const [variant, state3] = states[item2.state];
21950
+ const label = item2.state === "failed" && item2.from !== null ? "Update failed" : state3;
21526
21951
  const error = this.failures.get(item2.id) ?? item2.error;
21527
21952
  return b`<swc-divider size="s"></swc-divider>
21528
21953
  <article data-id=${item2.id} data-state=${item2.state} aria-label=${item2.label}>
@@ -21580,10 +22005,10 @@ var SliccUpdates = class extends ModelElement {
21580
22005
  accessible-label=${`${item2.label}: ${packageLight(item2)?.[1].toLowerCase()}`}
21581
22006
  ></swc-progress-bar>`;
21582
22007
  }
21583
- #package(item2, all2, act) {
22008
+ #package(item2, all2, act2) {
21584
22009
  const light = packageLight(item2);
21585
22010
  const busy = this.busy.get(item2.id);
21586
- const shown2 = busy ? [busy] : act ? item2.actions : [];
22011
+ const shown2 = busy ? [busy] : act2 ? item2.actions : [];
21587
22012
  const error = this.problems.get(item2.id) ?? item2.error;
21588
22013
  return b`<li data-id=${item2.id} data-state=${item2.state}>
21589
22014
  <div class="name">
@@ -21714,6 +22139,9 @@ function finishTransitions(root2) {
21714
22139
  for (const element2 of root2.querySelectorAll("*"))
21715
22140
  if (element2.shadowRoot) finishTransitions(element2.shadowRoot);
21716
22141
  }
22142
+ function editable(node) {
22143
+ return node instanceof HTMLElement && (node.isContentEditable || node.tagName === "TEXTAREA" || node.tagName === "INPUT");
22144
+ }
21717
22145
  var SliccApp = class extends ThemedElement {
21718
22146
  static properties = {
21719
22147
  ...ThemedElement.properties,
@@ -21724,6 +22152,17 @@ var SliccApp = class extends ThemedElement {
21724
22152
  layoutKey = "slicc-ui.layout.v2";
21725
22153
  dips = new Dips();
21726
22154
  terminalPanels = new TerminalPanels();
22155
+ panels = new Panels({
22156
+ dock: () => this.dock,
22157
+ screen: () => this.screen,
22158
+ model: () => this.model,
22159
+ surfaces: () => this.#available(),
22160
+ sprinkles: () => this.#sprinkles(),
22161
+ open: (id, focus, section) => this.#open(id, focus, section),
22162
+ reset: () => this.resetLayout(),
22163
+ typing: () => this.#typing()
22164
+ });
22165
+ #typedAt = Number.NEGATIVE_INFINITY;
21727
22166
  #fontBase = defaultFontBase;
21728
22167
  #variableFont = defaultVariableFont;
21729
22168
  #resize = null;
@@ -21733,6 +22172,7 @@ var SliccApp = class extends ThemedElement {
21733
22172
  #saving = false;
21734
22173
  #updatesPort;
21735
22174
  #unlock;
22175
+ #hold;
21736
22176
  #updatesVisibility = null;
21737
22177
  constructor() {
21738
22178
  super();
@@ -22005,6 +22445,9 @@ var SliccApp = class extends ThemedElement {
22005
22445
  this.#fonts();
22006
22446
  installProperties(this.ownerDocument);
22007
22447
  this.#unlock = lockOverscroll(this.ownerDocument);
22448
+ this.#hold = holdDocument(this.ownerDocument);
22449
+ this.#painted = "";
22450
+ this.requestUpdate();
22008
22451
  this.#resize = new ResizeObserver(() => this.#measure());
22009
22452
  this.#resize.observe(this);
22010
22453
  }
@@ -22012,6 +22455,7 @@ var SliccApp = class extends ThemedElement {
22012
22455
  super.disconnectedCallback();
22013
22456
  this.ownerDocument.removeEventListener("keydown", this.#keydown, true);
22014
22457
  this.#unlock();
22458
+ this.#hold.release();
22015
22459
  this.#resize?.disconnect();
22016
22460
  }
22017
22461
  get fontBase() {
@@ -22059,13 +22503,17 @@ var SliccApp = class extends ThemedElement {
22059
22503
  finishTransitions(root2);
22060
22504
  requestAnimationFrame(() => finishTransitions(root2));
22061
22505
  }
22506
+ if (this.#painted !== color) this.#hold.paint(color);
22062
22507
  this.#painted = color;
22063
- if (!this.model) return;
22064
- const layout = this.#started !== this.screen;
22065
- if (layout) this.#start(this.model);
22066
- else if (changed.has("model")) this.#rebind(this.model);
22067
- this.#updates(layout);
22068
- this.#retitle();
22508
+ const model = this.model;
22509
+ if (!model) return;
22510
+ this.panels.quietly(() => {
22511
+ const layout = this.#started !== this.screen;
22512
+ if (layout) this.#start(model);
22513
+ else if (changed.has("model")) this.#rebind(model);
22514
+ this.#updates(layout);
22515
+ this.#retitle();
22516
+ });
22069
22517
  }
22070
22518
  #retitle() {
22071
22519
  for (const sprinkle of this.#sprinkles()) {
@@ -22129,7 +22577,10 @@ var SliccApp = class extends ThemedElement {
22129
22577
  if (!this.#started) return;
22130
22578
  const dock = this.dock;
22131
22579
  dock.factories = this.#factories(model);
22132
- if (!terminalsAllowed(model)) for (const id of terminalPanels(dock)) dock.close(id);
22580
+ if (!terminalsAllowed(model))
22581
+ this.panels.quietly(() => {
22582
+ for (const id of terminalPanels(dock)) dock.close(id);
22583
+ });
22133
22584
  }
22134
22585
  #start(model) {
22135
22586
  const dock = this.dock;
@@ -22179,11 +22630,13 @@ var SliccApp = class extends ThemedElement {
22179
22630
  const dock = this.renderRoot.querySelector("slicc-dock");
22180
22631
  if (!dock || !this.#started) return;
22181
22632
  const known = new Set(this.model?.agent.list().map((agent) => agent.id));
22182
- for (const id of chats(dock)) {
22183
- if (!known.has(chatAgent(id))) dock.close(id);
22184
- }
22185
- if (this.model && this.#offers("terminal"))
22186
- this.terminalPanels.sync(dock, this.model.terminals, this.screen);
22633
+ this.panels.quietly(() => {
22634
+ for (const id of chats(dock)) {
22635
+ if (!known.has(chatAgent(id))) dock.close(id);
22636
+ }
22637
+ if (this.model && this.#offers("terminal"))
22638
+ this.terminalPanels.sync(dock, this.model.terminals, this.screen);
22639
+ });
22187
22640
  }
22188
22641
  #activated(event2) {
22189
22642
  const { id } = event2.detail;
@@ -22194,7 +22647,9 @@ var SliccApp = class extends ThemedElement {
22194
22647
  }
22195
22648
  resetLayout() {
22196
22649
  const terminals = this.model?.terminals.list();
22197
- defaultLayout(this.dock, this.screen, this.#active(), this.#available(), terminals);
22650
+ this.panels.quietly(
22651
+ () => defaultLayout(this.dock, this.screen, this.#active(), this.#available(), terminals)
22652
+ );
22198
22653
  this.#save();
22199
22654
  }
22200
22655
  #showSurface(event2) {
@@ -22202,14 +22657,28 @@ var SliccApp = class extends ThemedElement {
22202
22657
  this.show(id, section);
22203
22658
  }
22204
22659
  show(id, section) {
22205
- const agent = this.#active();
22206
- if (id === "chat" && agent && this.#offers("chat")) {
22207
- openChat(this.dock, agent, this.screen);
22660
+ this.#open(id, true, section);
22661
+ }
22662
+ #open(id, focus, section) {
22663
+ const agent = id === "chat" ? this.#active() : this.model?.agent.list().find((candidate) => `chat:${candidate.id}` === id);
22664
+ if (agent && this.#offers("chat")) {
22665
+ openChat(this.dock, agent, this.screen, focus);
22208
22666
  return;
22209
22667
  }
22210
22668
  const sprinkle = this.#sprinkles().find((candidate) => `sprinkle:${candidate.id}` === id);
22211
22669
  if (sprinkle) {
22212
- openSprinkle(this.dock, sprinkle, this.screen);
22670
+ this.dips.detach(sprinkle.id);
22671
+ openSprinkle(this.dock, sprinkle, this.screen, null, focus);
22672
+ return;
22673
+ }
22674
+ const terminal = this.model?.terminals.list().find((info) => info.id === terminalOf(id));
22675
+ if (terminal && this.#offers("terminal")) {
22676
+ this.#reveal(openTerminal(this.dock, terminal, this.screen), focus);
22677
+ return;
22678
+ }
22679
+ const document2 = id.match(/^(file|diff):(.+)$/);
22680
+ if (document2) {
22681
+ openDocument(this.dock, document2[1], document2[2], this.screen, focus);
22213
22682
  return;
22214
22683
  }
22215
22684
  const item2 = surface(id, this.#available());
@@ -22218,12 +22687,24 @@ var SliccApp = class extends ThemedElement {
22218
22687
  if (this.model) this.terminalPanels.show(this.dock, this.model.terminals, this.screen);
22219
22688
  return;
22220
22689
  }
22221
- openSurface(this.dock, item2, this.screen);
22690
+ openSurface(this.dock, item2, this.screen, focus);
22222
22691
  if (id === "updates") this.dock.api.getPanel(id)?.api.updateParameters({ boot: false });
22223
- this.dock.focusPanel(id);
22692
+ this.#reveal(id, focus);
22224
22693
  if (section)
22225
22694
  this.dock.content(id)?.reveal?.(section);
22226
22695
  }
22696
+ #reveal(id, focus) {
22697
+ if (focus) this.dock.focusPanel(id);
22698
+ else this.dock.reveal(id);
22699
+ }
22700
+ #typing() {
22701
+ if (Date.now() - this.#typedAt < 3e3) return true;
22702
+ let active = this.ownerDocument.activeElement;
22703
+ while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
22704
+ if (!editable(active)) return false;
22705
+ const value = "value" in active ? String(active.value) : active.textContent;
22706
+ return (value ?? "").trim() !== "";
22707
+ }
22227
22708
  #sprinkle(id) {
22228
22709
  return this.#sprinkles().find((candidate) => candidate.id === id);
22229
22710
  }
@@ -22239,11 +22720,11 @@ var SliccApp = class extends ThemedElement {
22239
22720
  return cone ? { ...sprinkle, title: `${cone.name} / ${sprinkle.title}` } : sprinkle;
22240
22721
  }).sort((a22, b13) => order.indexOf(a22.agentId) - order.indexOf(b13.agentId));
22241
22722
  }
22242
- #detach(id, place2, open) {
22723
+ #detach(id, place3, open) {
22243
22724
  const sprinkle = this.#sprinkle(id);
22244
22725
  if (!sprinkle) return;
22245
22726
  this.dips.detach(id);
22246
- if (open) openSprinkle(this.dock, sprinkle, this.screen, place2);
22727
+ if (open) openSprinkle(this.dock, sprinkle, this.screen, place3);
22247
22728
  }
22248
22729
  #dropped(event2) {
22249
22730
  const { type, data, panel, position } = event2.detail;
@@ -22322,6 +22803,7 @@ var SliccApp = class extends ThemedElement {
22322
22803
  this.model?.settings.update({ color: this.color === "dark" ? "light" : "dark" });
22323
22804
  }
22324
22805
  #keydown = (event2) => {
22806
+ if (editable(event2.composedPath()[0])) this.#typedAt = Date.now();
22325
22807
  if (!event2.altKey || event2.ctrlKey || event2.metaKey) return;
22326
22808
  const digit = event2.code.match(/^Digit([1-9])$/)?.[1] ?? event2.key.match(/^[1-9]$/)?.[0];
22327
22809
  const surface2 = digit ? this.#available()[Number(digit) - 1] : void 0;
@@ -22418,10 +22900,10 @@ var SliccApp = class extends ThemedElement {
22418
22900
  <swc-tooltip for="updates" placement="bottom">${text2}</swc-tooltip>`;
22419
22901
  }
22420
22902
  #tabsIndicator() {
22421
- const state2 = this.model?.tabs?.state();
22422
- const light = tabsLight(state2);
22423
- if (!state2 || !light) return A;
22424
- return b`<span id="tabs" class="tabs" tabindex="0" role="img" data-tabs data-role=${state2.role} ?data-stalled=${state2.stalled} data-skew=${state2.skew ?? A} aria-label=${`${light.text}. ${light.tooltip}`}>
22903
+ const state3 = this.model?.tabs?.state();
22904
+ const light = tabsLight(state3);
22905
+ if (!state3 || !light) return A;
22906
+ return b`<span id="tabs" class="tabs" tabindex="0" role="img" data-tabs data-role=${state3.role} ?data-stalled=${state3.stalled} data-skew=${state3.skew ?? A} aria-label=${`${light.text}. ${light.tooltip}`}>
22425
22907
  <swc-status-light size="s" variant=${light.variant}>${this.screen === "phone" ? A : light.text}</swc-status-light>
22426
22908
  </span>
22427
22909
  <swc-tooltip for="tabs" placement="bottom">${light.tooltip}</swc-tooltip>`;
@@ -22440,9 +22922,9 @@ var SliccApp = class extends ThemedElement {
22440
22922
  const port = this.model?.network;
22441
22923
  if (!port || !this.#offers("network")) return A;
22442
22924
  const status2 = networkStatus(port);
22443
- const [variant, state2] = networkHealth[status2.health];
22925
+ const [variant, state3] = networkHealth[status2.health];
22444
22926
  const label = networkLabel(status2);
22445
- const content = this.screen === "phone" ? networkIcon[status2.health] : b`<swc-status-light size="s" variant=${variant}>Network${status2.health === "ok" ? A : b`<span class="state"> ${state2.toLowerCase()}</span>`}</swc-status-light>`;
22927
+ const content = this.screen === "phone" ? networkIcon[status2.health] : b`<swc-status-light size="s" variant=${variant}>Network${status2.health === "ok" ? A : b`<span class="state"> ${state3.toLowerCase()}</span>`}</swc-status-light>`;
22446
22928
  return b`<swc-action-button id="network" quiet size="s" data-network data-health=${status2.health} accessible-label=${label} @click=${() => this.show("network")}>${content}</swc-action-button>
22447
22929
  <swc-tooltip for="network" placement="bottom">${status2.detail ?? label}${status2.tailnet?.state === "running" ? " Tailscale is connected." : ""}</swc-tooltip>`;
22448
22930
  }
@@ -22504,6 +22986,7 @@ var SliccApp = class extends ThemedElement {
22504
22986
  <main>
22505
22987
  ${rails.left}
22506
22988
  <slicc-dock empty-text="All panels are closed. Open one from a rail or View." @layout-change=${this.#save}
22989
+ @panel-close=${(event2) => this.panels.closed(event2.detail.id)}
22507
22990
  @active-panel-change=${this.#activated}
22508
22991
  @external-drop=${this.#dropped}
22509
22992
  @detach-sprinkle=${(event2) => this.#detach(event2.detail.id, null, true)}
@@ -22528,8 +23011,8 @@ function countdown(ms) {
22528
23011
  }
22529
23012
  function asking(approval) {
22530
23013
  const { kind, name, where: where2 } = approval.requester;
22531
- const place2 = where2 ? ` in ${where2}` : "";
22532
- return kind === "user" ? `You ran this with sudo${place2} (as ${name})` : `${name} wants to run this with sudo${place2}`;
23014
+ const place3 = where2 ? ` in ${where2}` : "";
23015
+ return kind === "user" ? `You ran this with sudo${place3} (as ${name})` : `${name} wants to run this with sudo${place3}`;
22533
23016
  }
22534
23017
  function sudo(approval) {
22535
23018
  const as = approval.target && approval.target !== "root" ? `-u ${approval.target} ` : "";
@@ -23081,7 +23564,7 @@ function host3(url) {
23081
23564
  return url;
23082
23565
  }
23083
23566
  }
23084
- function place(url) {
23567
+ function place2(url) {
23085
23568
  try {
23086
23569
  const { host: host4, pathname } = new URL(url);
23087
23570
  return host4 ? `${host4}${pathname === "/" ? "" : pathname}` : url;
@@ -23108,9 +23591,9 @@ function typed(action) {
23108
23591
  const count = action.length === void 0 ? "" : ` ${action.length} ${action.length === 1 ? "character" : "characters"}`;
23109
23592
  return `Typed${count}${action.target ? ` into ${action.target}` : ""}`;
23110
23593
  }
23111
- var verbs = {
23112
- open: (action) => `Opened ${place(action.value ?? "")}`.trim(),
23113
- goto: (action) => `Went to ${place(action.value ?? "")}`.trim(),
23594
+ var verbs2 = {
23595
+ open: (action) => `Opened ${place2(action.value ?? "")}`.trim(),
23596
+ goto: (action) => `Went to ${place2(action.value ?? "")}`.trim(),
23114
23597
  back: () => "Went back",
23115
23598
  reload: () => "Reloaded",
23116
23599
  close: () => "Closed tab",
@@ -23126,7 +23609,7 @@ var verbs = {
23126
23609
  request: (action) => called(action.value)
23127
23610
  };
23128
23611
  function describe(action) {
23129
- return verbs[action.kind](action);
23612
+ return verbs2[action.kind](action);
23130
23613
  }
23131
23614
  var icons = {
23132
23615
  open: b`<swc-icon-open-in size="s"></swc-icon-open-in>`,
@@ -23857,7 +24340,7 @@ var SliccBrowser = class extends ModelElement {
23857
24340
  ${wide ? A : this.#picker(tabs, tab)}
23858
24341
  </div>
23859
24342
  <div class="address">
23860
- <span class="url" title=${tab.url}>${narrow ? place(tab.url) : tab.url}</span>
24343
+ <span class="url" title=${tab.url}>${narrow ? place2(tab.url) : tab.url}</span>
23861
24344
  <swc-action-button size="s" quiet data-action="copy-url" accessible-label=${copy === "Copy" ? "Copy URL" : copy} @click=${() => this.#copy(tab.url)}><swc-icon-copy slot="icon"></swc-icon-copy>${narrow ? A : copy}</swc-action-button>
23862
24345
  <swc-action-button size="s" quiet data-action="open-tab" accessible-label="Show in the browser" @click=${() => this.model?.browser.activate(tab.id)}><swc-icon-open-in slot="icon"></swc-icon-open-in>${narrow ? A : "Open"}</swc-action-button>
23863
24346
  </div>
@@ -24683,7 +25166,7 @@ var SliccChat = class extends ThemedElement {
24683
25166
  model: null,
24684
25167
  readOnly: false,
24685
25168
  answer: (questionId, answer) => this.model?.agent.answer(this.#id(), questionId, answer),
24686
- resolve: (messageId, state2) => this.model?.agent.resolveLick(this.#id(), messageId, state2),
25169
+ resolve: (messageId, state3) => this.model?.agent.resolveLick(this.#id(), messageId, state3),
24687
25170
  action: (action, messageId) => this.#action(action, messageId),
24688
25171
  dropping: (messageId) => failedTurns(this.model.agent.messages(this.#id()), messageId).length,
24689
25172
  open: (path) => this.dispatchEvent(
@@ -24772,6 +25255,14 @@ var SliccChat = class extends ThemedElement {
24772
25255
  #id() {
24773
25256
  return this.agent || (this.model?.agent.active() ?? "");
24774
25257
  }
25258
+ get busyReason() {
25259
+ const open = (this.model?.agent.messages(this.#id()) ?? []).some(
25260
+ (message) => ("parts" in message ? message.parts : []).some(
25261
+ (part2) => part2.type === "question" && part2.question.state === "open"
25262
+ )
25263
+ );
25264
+ return open ? "a question waits for an answer" : null;
25265
+ }
24775
25266
  #agent() {
24776
25267
  const id = this.#id();
24777
25268
  return this.model?.agent.list().find((agent) => agent.id === id);
@@ -25823,9 +26314,9 @@ var commands2 = [
25823
26314
  }
25824
26315
  ];
25825
26316
  function readFile(file) {
25826
- return new Promise((resolve, reject) => {
26317
+ return new Promise((resolve2, reject) => {
25827
26318
  const reader = new FileReader();
25828
- reader.onload = () => resolve(String(reader.result));
26319
+ reader.onload = () => resolve2(String(reader.result));
25829
26320
  reader.onerror = () => reject(reader.error);
25830
26321
  if (file.type.startsWith("image/")) reader.readAsDataURL(file);
25831
26322
  else reader.readAsText(file);
@@ -26114,8 +26605,8 @@ var SliccComposer = class extends ModelElement {
26114
26605
  ];
26115
26606
  }
26116
26607
  #held() {
26117
- const state2 = this.model?.follow?.state();
26118
- return state2?.link === "reconnecting" ? state2.owner : null;
26608
+ const state3 = this.model?.follow?.state();
26609
+ return state3?.link === "reconnecting" ? state3.owner : null;
26119
26610
  }
26120
26611
  #switch(id) {
26121
26612
  if (this.#agent)
@@ -27065,7 +27556,7 @@ var SliccMonitor = class extends ModelElement {
27065
27556
  .toggle {
27066
27557
  all: unset;
27067
27558
  box-sizing: border-box;
27068
- flex: 1;
27559
+ flex: 1 1 auto;
27069
27560
  min-width: 0;
27070
27561
  display: flex;
27071
27562
  align-items: center;
@@ -27091,7 +27582,7 @@ var SliccMonitor = class extends ModelElement {
27091
27582
  transform: scaleX(-1);
27092
27583
  }
27093
27584
  .line .name {
27094
- flex: 1;
27585
+ flex: 1 1 auto;
27095
27586
  min-width: 0;
27096
27587
  }
27097
27588
  .line .num {
@@ -27648,6 +28139,11 @@ var SliccSettings = class extends ModelElement {
27648
28139
  this.#cancelled.add(account.id);
27649
28140
  this.model?.settings.cancel?.(account.id);
27650
28141
  }
28142
+ get busyReason() {
28143
+ const accounts = this.model?.settings.accounts() ?? [];
28144
+ if (accounts.some((account) => this.#signingIn(account))) return "signing in";
28145
+ return this.entering === null ? null : "a key is being entered";
28146
+ }
27651
28147
  #signingIn(account) {
27652
28148
  return account.status === "signing-in" || account.auth !== "api-key" && account.status !== "connected" && this.pending.has(account.id);
27653
28149
  }
@@ -27891,9 +28387,9 @@ function literal(value) {
27891
28387
  return "null";
27892
28388
  }
27893
28389
  }
27894
- function store(state2) {
28390
+ function store(state3) {
27895
28391
  return `(() => {
27896
- let state = ${literal(state2)};
28392
+ let state = ${literal(state3)};
27897
28393
  const tag = Math.random().toString(36).slice(2);
27898
28394
  const pending = new Map();
27899
28395
  let next = 0;
@@ -27931,11 +28427,11 @@ function store(state2) {
27931
28427
  });
27932
28428
  })();`;
27933
28429
  }
27934
- function frameDocument(source, color, name, state2) {
28430
+ function frameDocument(source, color, name, state3) {
27935
28431
  const scheme = `<style>${sprinkleTokens}${sprinkle_theme_default}</style>`;
27936
28432
  const light = `<script>document.documentElement.classList.toggle('theme-light', ${color === "light"});<\/script>`;
27937
28433
  const script = `<script data-name="${name.replace(/"/g, "&quot;")}">${bridge}<\/script>`;
27938
- const injection = light + scheme + script + (state2 ? `<script>${store(state2.value)}<\/script>` : "");
28434
+ const injection = light + scheme + script + (state3 ? `<script>${store(state3.value)}<\/script>` : "");
27939
28435
  const head2 = source.match(/<head\b[^>]*>/i);
27940
28436
  if (!head2 || head2.index === void 0) return injection + source;
27941
28437
  const at = head2.index + head2[0].length;
@@ -28146,12 +28642,12 @@ var SliccSprinkle = class extends ThemedElement {
28146
28642
  return this.model?.sprinkles.list().find((candidate) => candidate.id === this.sprinkle);
28147
28643
  }
28148
28644
  #frame = { key: "", doc: "" };
28149
- #document(data, state2) {
28150
- const key2 = `${!!state2}
28645
+ #document(data, state3) {
28646
+ const key2 = `${!!state3}
28151
28647
  ${data.name}
28152
28648
  ${data.html}`;
28153
28649
  if (this.#frame.key !== key2)
28154
- this.#frame = { key: key2, doc: frameDocument(data.html, this.color, data.name, state2) };
28650
+ this.#frame = { key: key2, doc: frameDocument(data.html, this.color, data.name, state3) };
28155
28651
  return this.#frame.doc;
28156
28652
  }
28157
28653
  updated(changed) {
@@ -28175,11 +28671,11 @@ ${data.html}`;
28175
28671
  }
28176
28672
  const bridged = !!this.model?.sprinkles.call;
28177
28673
  if (bridged && !this.#held.ready) return b``;
28178
- const state2 = bridged ? this.#held : void 0;
28674
+ const state3 = bridged ? this.#held : void 0;
28179
28675
  const style = `color-scheme:${this.color};${this.inline ? `height:${this.height}px;` : ""}`;
28180
28676
  const frame = b`${i17(
28181
28677
  this.#mounts,
28182
- b`<iframe title=${data.title} sandbox="allow-scripts" style=${style} .srcdoc=${this.#document(data, state2)}></iframe>`
28678
+ b`<iframe title=${data.title} sandbox="allow-scripts" style=${style} .srcdoc=${this.#document(data, state3)}></iframe>`
28183
28679
  )}`;
28184
28680
  if (!this.inline) return frame;
28185
28681
  return b`<div class="handle" draggable="true" title="Drag into the dock or a rail to open as a panel" @dragstart=${this.#drag}>
@@ -34087,8 +34583,8 @@ async function createShikiPrimitiveAsync(options) {
34087
34583
  });
34088
34584
  }
34089
34585
  var _grammarStateMap = /* @__PURE__ */ new WeakMap();
34090
- function setLastGrammarStateToMap(keys, state2) {
34091
- _grammarStateMap.set(keys, state2);
34586
+ function setLastGrammarStateToMap(keys, state3) {
34587
+ _grammarStateMap.set(keys, state3);
34092
34588
  }
34093
34589
  function getLastGrammarStateFromMap(keys) {
34094
34590
  return _grammarStateMap.get(keys);
@@ -34157,9 +34653,9 @@ function getScopes(stack) {
34157
34653
  pushScope(stack);
34158
34654
  return scopes;
34159
34655
  }
34160
- function getGrammarStack(state2, theme3) {
34161
- if (!(state2 instanceof GrammarState)) throw new ShikiError2("Invalid grammar state");
34162
- return state2.getInternalStack(theme3);
34656
+ function getGrammarStack(state3, theme3) {
34657
+ if (!(state3 instanceof GrammarState)) throw new ShikiError2("Invalid grammar state");
34658
+ return state3.getInternalStack(theme3);
34163
34659
  }
34164
34660
  var RE_COMMA = /,/;
34165
34661
  var RE_SPACE = / /;
@@ -34532,8 +35028,8 @@ var DefinedInfo = class extends Info {
34532
35028
  mark(this, "space", space);
34533
35029
  if (typeof mask === "number") {
34534
35030
  while (++index < checks.length) {
34535
- const check2 = checks[index];
34536
- mark(this, checks[index], (mask & types_exports[check2]) === types_exports[check2]);
35031
+ const check3 = checks[index];
35032
+ mark(this, checks[index], (mask & types_exports[check3]) === types_exports[check3]);
34537
35033
  }
34538
35034
  }
34539
35035
  }
@@ -36162,17 +36658,17 @@ function stringifyEntities(value, options) {
36162
36658
  var htmlCommentRegex = /^>|^->|<!--|-->|--!>|<!-$/g;
36163
36659
  var bogusCommentEntitySubset = [">"];
36164
36660
  var commentEntitySubset = ["<", ">"];
36165
- function comment(node, _1, _22, state2) {
36166
- return state2.settings.bogusComments ? "<?" + stringifyEntities(
36661
+ function comment(node, _1, _22, state3) {
36662
+ return state3.settings.bogusComments ? "<?" + stringifyEntities(
36167
36663
  node.value,
36168
- Object.assign({}, state2.settings.characterReferences, {
36664
+ Object.assign({}, state3.settings.characterReferences, {
36169
36665
  subset: bogusCommentEntitySubset
36170
36666
  })
36171
36667
  ) + ">" : "<!--" + node.value.replace(htmlCommentRegex, encode2) + "-->";
36172
36668
  function encode2($0) {
36173
36669
  return stringifyEntities(
36174
36670
  $0,
36175
- Object.assign({}, state2.settings.characterReferences, {
36671
+ Object.assign({}, state3.settings.characterReferences, {
36176
36672
  subset: commentEntitySubset
36177
36673
  })
36178
36674
  );
@@ -36180,8 +36676,8 @@ function comment(node, _1, _22, state2) {
36180
36676
  }
36181
36677
 
36182
36678
  // node_modules/hast-util-to-html/lib/handle/doctype.js
36183
- function doctype(_1, _22, _32, state2) {
36184
- return "<!" + (state2.settings.upperDoctype ? "DOCTYPE" : "doctype") + (state2.settings.tightDoctype ? "" : " ") + "html>";
36679
+ function doctype(_1, _22, _32, state3) {
36680
+ return "<!" + (state3.settings.upperDoctype ? "DOCTYPE" : "doctype") + (state3.settings.tightDoctype ? "" : " ") + "html>";
36185
36681
  }
36186
36682
 
36187
36683
  // node_modules/ccount/index.js
@@ -36406,26 +36902,26 @@ var constants = {
36406
36902
  ['\0"&'.split(""), "\0\"&'`".split("")]
36407
36903
  ]
36408
36904
  };
36409
- function element(node, index, parent, state2) {
36410
- const schema = state2.schema;
36411
- const omit = schema.space === "svg" ? false : state2.settings.omitOptionalTags;
36412
- let selfClosing = schema.space === "svg" ? state2.settings.closeEmptyElements : state2.settings.voids.includes(node.tagName.toLowerCase());
36905
+ function element(node, index, parent, state3) {
36906
+ const schema = state3.schema;
36907
+ const omit = schema.space === "svg" ? false : state3.settings.omitOptionalTags;
36908
+ let selfClosing = schema.space === "svg" ? state3.settings.closeEmptyElements : state3.settings.voids.includes(node.tagName.toLowerCase());
36413
36909
  const parts2 = [];
36414
36910
  let last;
36415
36911
  if (schema.space === "html" && node.tagName === "svg") {
36416
- state2.schema = svg3;
36912
+ state3.schema = svg3;
36417
36913
  }
36418
- const attributes = serializeAttributes(state2, node.properties);
36419
- const content = state2.all(
36914
+ const attributes = serializeAttributes(state3, node.properties);
36915
+ const content = state3.all(
36420
36916
  schema.space === "html" && node.tagName === "template" ? node.content : node
36421
36917
  );
36422
- state2.schema = schema;
36918
+ state3.schema = schema;
36423
36919
  if (content) selfClosing = false;
36424
36920
  if (attributes || !omit || !opening(node, index, parent)) {
36425
36921
  parts2.push("<", node.tagName, attributes ? " " + attributes : "");
36426
- if (selfClosing && (schema.space === "svg" || state2.settings.closeSelfClosing)) {
36922
+ if (selfClosing && (schema.space === "svg" || state3.settings.closeSelfClosing)) {
36427
36923
  last = attributes.charAt(attributes.length - 1);
36428
- if (!state2.settings.tightSelfClosing || last === "/" || last && last !== '"' && last !== "'") {
36924
+ if (!state3.settings.tightSelfClosing || last === "/" || last && last !== '"' && last !== "'") {
36429
36925
  parts2.push(" ");
36430
36926
  }
36431
36927
  parts2.push("/");
@@ -36438,31 +36934,31 @@ function element(node, index, parent, state2) {
36438
36934
  }
36439
36935
  return parts2.join("");
36440
36936
  }
36441
- function serializeAttributes(state2, properties) {
36937
+ function serializeAttributes(state3, properties) {
36442
36938
  const values = [];
36443
36939
  let index = -1;
36444
36940
  let key2;
36445
36941
  if (properties) {
36446
36942
  for (key2 in properties) {
36447
36943
  if (properties[key2] !== null && properties[key2] !== void 0) {
36448
- const value = serializeAttribute(state2, key2, properties[key2]);
36944
+ const value = serializeAttribute(state3, key2, properties[key2]);
36449
36945
  if (value) values.push(value);
36450
36946
  }
36451
36947
  }
36452
36948
  }
36453
36949
  while (++index < values.length) {
36454
- const last = state2.settings.tightAttributes ? values[index].charAt(values[index].length - 1) : void 0;
36950
+ const last = state3.settings.tightAttributes ? values[index].charAt(values[index].length - 1) : void 0;
36455
36951
  if (index !== values.length - 1 && last !== '"' && last !== "'") {
36456
36952
  values[index] += " ";
36457
36953
  }
36458
36954
  }
36459
36955
  return values.join("");
36460
36956
  }
36461
- function serializeAttribute(state2, key2, value) {
36462
- const info = find(state2.schema, key2);
36463
- const x7 = state2.settings.allowParseErrors && state2.schema.space === "html" ? 0 : 1;
36464
- const y10 = state2.settings.allowDangerousCharacters ? 0 : 1;
36465
- let quote = state2.quote;
36957
+ function serializeAttribute(state3, key2, value) {
36958
+ const info = find(state3.schema, key2);
36959
+ const x7 = state3.settings.allowParseErrors && state3.schema.space === "html" ? 0 : 1;
36960
+ const y10 = state3.settings.allowDangerousCharacters ? 0 : 1;
36961
+ let quote = state3.quote;
36466
36962
  let result;
36467
36963
  if (info.overloadedBoolean && (value === info.attribute || value === "")) {
36468
36964
  value = true;
@@ -36474,32 +36970,32 @@ function serializeAttribute(state2, key2, value) {
36474
36970
  }
36475
36971
  const name = stringifyEntities(
36476
36972
  info.attribute,
36477
- Object.assign({}, state2.settings.characterReferences, {
36973
+ Object.assign({}, state3.settings.characterReferences, {
36478
36974
  // Always encode without parse errors in non-HTML.
36479
36975
  subset: constants.name[x7][y10]
36480
36976
  })
36481
36977
  );
36482
36978
  if (value === true) return name;
36483
36979
  value = Array.isArray(value) ? (info.commaSeparated ? stringify : stringify2)(value, {
36484
- padLeft: !state2.settings.tightCommaSeparatedLists
36980
+ padLeft: !state3.settings.tightCommaSeparatedLists
36485
36981
  }) : String(value);
36486
- if (state2.settings.collapseEmptyAttributes && !value) return name;
36487
- if (state2.settings.preferUnquoted) {
36982
+ if (state3.settings.collapseEmptyAttributes && !value) return name;
36983
+ if (state3.settings.preferUnquoted) {
36488
36984
  result = stringifyEntities(
36489
36985
  value,
36490
- Object.assign({}, state2.settings.characterReferences, {
36986
+ Object.assign({}, state3.settings.characterReferences, {
36491
36987
  attribute: true,
36492
36988
  subset: constants.unquoted[x7][y10]
36493
36989
  })
36494
36990
  );
36495
36991
  }
36496
36992
  if (result !== value) {
36497
- if (state2.settings.quoteSmart && ccount(value, quote) > ccount(value, state2.alternative)) {
36498
- quote = state2.alternative;
36993
+ if (state3.settings.quoteSmart && ccount(value, quote) > ccount(value, state3.alternative)) {
36994
+ quote = state3.alternative;
36499
36995
  }
36500
36996
  result = quote + stringifyEntities(
36501
36997
  value,
36502
- Object.assign({}, state2.settings.characterReferences, {
36998
+ Object.assign({}, state3.settings.characterReferences, {
36503
36999
  // Always encode without parse errors in non-HTML.
36504
37000
  subset: (quote === "'" ? constants.single : constants.double)[x7][y10],
36505
37001
  attribute: true
@@ -36511,35 +37007,35 @@ function serializeAttribute(state2, key2, value) {
36511
37007
 
36512
37008
  // node_modules/hast-util-to-html/lib/handle/text.js
36513
37009
  var textEntitySubset = ["<", "&"];
36514
- function text(node, _9, parent, state2) {
37010
+ function text(node, _9, parent, state3) {
36515
37011
  return parent && parent.type === "element" && (parent.tagName === "script" || parent.tagName === "style") ? node.value : stringifyEntities(
36516
37012
  node.value,
36517
- Object.assign({}, state2.settings.characterReferences, {
37013
+ Object.assign({}, state3.settings.characterReferences, {
36518
37014
  subset: textEntitySubset
36519
37015
  })
36520
37016
  );
36521
37017
  }
36522
37018
 
36523
37019
  // node_modules/hast-util-to-html/lib/handle/raw.js
36524
- function raw(node, index, parent, state2) {
36525
- return state2.settings.allowDangerousHtml ? node.value : text(node, index, parent, state2);
37020
+ function raw(node, index, parent, state3) {
37021
+ return state3.settings.allowDangerousHtml ? node.value : text(node, index, parent, state3);
36526
37022
  }
36527
37023
 
36528
37024
  // node_modules/hast-util-to-html/lib/handle/root.js
36529
- function root(node, _1, _22, state2) {
36530
- return state2.all(node);
37025
+ function root(node, _1, _22, state3) {
37026
+ return state3.all(node);
36531
37027
  }
36532
37028
 
36533
37029
  // node_modules/hast-util-to-html/lib/handle/index.js
36534
37030
  var handle = zwitch("type", {
36535
37031
  invalid,
36536
- unknown,
37032
+ unknown: unknown2,
36537
37033
  handlers: { comment, doctype, element, raw, root, text }
36538
37034
  });
36539
37035
  function invalid(node) {
36540
37036
  throw new Error("Expected node, not `" + node + "`");
36541
37037
  }
36542
- function unknown(node_) {
37038
+ function unknown2(node_) {
36543
37039
  const node = (
36544
37040
  /** @type {Nodes} */
36545
37041
  node_
@@ -36558,7 +37054,7 @@ function toHtml(tree, options) {
36558
37054
  if (quote !== '"' && quote !== "'") {
36559
37055
  throw new Error("Invalid quote `" + quote + "`, expected `'` or `\"`");
36560
37056
  }
36561
- const state2 = {
37057
+ const state3 = {
36562
37058
  one,
36563
37059
  all,
36564
37060
  settings: {
@@ -36584,7 +37080,7 @@ function toHtml(tree, options) {
36584
37080
  quote,
36585
37081
  alternative
36586
37082
  };
36587
- return state2.one(
37083
+ return state3.one(
36588
37084
  Array.isArray(tree) ? { type: "root", children: tree } : tree,
36589
37085
  void 0,
36590
37086
  void 0
@@ -39485,9 +39981,9 @@ var FirstPassVisitor = {
39485
39981
  }
39486
39982
  }
39487
39983
  },
39488
- Assertion({ node, parent, key: key2, container, root: root2, remove: remove2, replaceWith }, state2) {
39984
+ Assertion({ node, parent, key: key2, container, root: root2, remove: remove2, replaceWith }, state3) {
39489
39985
  const { kind, negate } = node;
39490
- const { asciiWordBoundaries, avoidSubclass, supportedGNodes, wordIsAscii } = state2;
39986
+ const { asciiWordBoundaries, avoidSubclass, supportedGNodes, wordIsAscii } = state3;
39491
39987
  if (kind === "text_segment_boundary") {
39492
39988
  throw new Error(`Unsupported text segment boundary "\\${negate ? "Y" : "y"}"`);
39493
39989
  } else if (kind === "line_end") {
@@ -39510,7 +40006,7 @@ var FirstPassVisitor = {
39510
40006
  throw new Error(r36`Uses "\G" in a way that requires a subclass`);
39511
40007
  } else {
39512
40008
  replaceWith(setParent(F3("string_start"), parent));
39513
- state2.strategy = "clip_search";
40009
+ state3.strategy = "clip_search";
39514
40010
  }
39515
40011
  }
39516
40012
  } else if (kind === "string_end" || kind === "string_start") {
@@ -39703,10 +40199,10 @@ var FirstPassVisitor = {
39703
40199
  disable && !Object.keys(disable).length && delete node.flags.disable;
39704
40200
  !node.flags.enable && !node.flags.disable && delete node.flags;
39705
40201
  },
39706
- LookaroundAssertion({ node }, state2) {
40202
+ LookaroundAssertion({ node }, state3) {
39707
40203
  const { kind } = node;
39708
40204
  if (kind === "lookbehind") {
39709
- state2.passedLookbehind = true;
40205
+ state3.passedLookbehind = true;
39710
40206
  }
39711
40207
  },
39712
40208
  NamedCallout({ node, parent, replaceWith }) {
@@ -39833,17 +40329,17 @@ var SecondPassVisitor = {
39833
40329
  }
39834
40330
  },
39835
40331
  Group: {
39836
- enter({ node }, state2) {
39837
- state2.prevFlags = state2.currentFlags;
40332
+ enter({ node }, state3) {
40333
+ state3.prevFlags = state3.currentFlags;
39838
40334
  if (node.flags) {
39839
- state2.currentFlags = getNewCurrentFlags(state2.currentFlags, node.flags);
40335
+ state3.currentFlags = getNewCurrentFlags(state3.currentFlags, node.flags);
39840
40336
  }
39841
40337
  },
39842
- exit(_9, state2) {
39843
- state2.currentFlags = state2.prevFlags;
40338
+ exit(_9, state3) {
40339
+ state3.currentFlags = state3.prevFlags;
39844
40340
  }
39845
40341
  },
39846
- Subroutine({ node, parent, replaceWith }, state2) {
40342
+ Subroutine({ node, parent, replaceWith }, state3) {
39847
40343
  const { isRecursive, ref } = node;
39848
40344
  if (isRecursive) {
39849
40345
  let reffed = parent;
@@ -39852,14 +40348,14 @@ var SecondPassVisitor = {
39852
40348
  break;
39853
40349
  }
39854
40350
  }
39855
- state2.reffedNodesByReferencer.set(node, reffed);
40351
+ state3.reffedNodesByReferencer.set(node, reffed);
39856
40352
  return;
39857
40353
  }
39858
- const reffedGroupNode = state2.subroutineRefMap.get(ref);
40354
+ const reffedGroupNode = state3.subroutineRefMap.get(ref);
39859
40355
  const isGlobalRecursion = ref === 0;
39860
40356
  const expandedSubroutine = isGlobalRecursion ? createRecursion(0) : (
39861
40357
  // The reffed group might itself contain subroutines, which are expanded during sub-traversal
39862
- cloneCapturingGroup(reffedGroupNode, state2.groupOriginByCopy, null)
40358
+ cloneCapturingGroup(reffedGroupNode, state3.groupOriginByCopy, null)
39863
40359
  );
39864
40360
  let replacement = expandedSubroutine;
39865
40361
  if (!isGlobalRecursion) {
@@ -39867,8 +40363,8 @@ var SecondPassVisitor = {
39867
40363
  reffedGroupNode,
39868
40364
  (p17) => p17.type === "Group" && !!p17.flags
39869
40365
  ));
39870
- const reffedGroupFlags = reffedGroupFlagMods ? getNewCurrentFlags(state2.globalFlags, reffedGroupFlagMods) : state2.globalFlags;
39871
- if (!areFlagsEqual(reffedGroupFlags, state2.currentFlags)) {
40366
+ const reffedGroupFlags = reffedGroupFlagMods ? getNewCurrentFlags(state3.globalFlags, reffedGroupFlagMods) : state3.globalFlags;
40367
+ if (!areFlagsEqual(reffedGroupFlags, state3.currentFlags)) {
39872
40368
  replacement = A6({
39873
40369
  flags: getFlagModsFromFlags(reffedGroupFlags)
39874
40370
  });
@@ -39879,12 +40375,12 @@ var SecondPassVisitor = {
39879
40375
  }
39880
40376
  };
39881
40377
  var ThirdPassVisitor = {
39882
- Backreference({ node, parent, replaceWith }, state2) {
40378
+ Backreference({ node, parent, replaceWith }, state3) {
39883
40379
  if (node.orphan) {
39884
- state2.highestOrphanBackref = Math.max(state2.highestOrphanBackref, node.ref);
40380
+ state3.highestOrphanBackref = Math.max(state3.highestOrphanBackref, node.ref);
39885
40381
  return;
39886
40382
  }
39887
- const reffedNodes = state2.reffedNodesByReferencer.get(node);
40383
+ const reffedNodes = state3.reffedNodesByReferencer.get(node);
39888
40384
  const participants = reffedNodes.filter((reffed) => canParticipateWithNode(reffed, node));
39889
40385
  if (!participants.length) {
39890
40386
  replaceWith(setParentDeep(K2({ negate: true }), parent));
@@ -39900,28 +40396,28 @@ var ThirdPassVisitor = {
39900
40396
  node.ref = participants[0].number;
39901
40397
  }
39902
40398
  },
39903
- CapturingGroup({ node }, state2) {
39904
- node.number = ++state2.numCapturesToLeft;
40399
+ CapturingGroup({ node }, state3) {
40400
+ node.number = ++state3.numCapturesToLeft;
39905
40401
  if (node.name) {
39906
- if (state2.groupsByName.get(node.name).get(node).hasDuplicateNameToRemove) {
40402
+ if (state3.groupsByName.get(node.name).get(node).hasDuplicateNameToRemove) {
39907
40403
  delete node.name;
39908
40404
  }
39909
40405
  }
39910
40406
  },
39911
40407
  Regex: {
39912
- exit({ node }, state2) {
39913
- const numCapsNeeded = Math.max(state2.highestOrphanBackref - state2.numCapturesToLeft, 0);
40408
+ exit({ node }, state3) {
40409
+ const numCapsNeeded = Math.max(state3.highestOrphanBackref - state3.numCapturesToLeft, 0);
39914
40410
  for (let i25 = 0; i25 < numCapsNeeded; i25++) {
39915
40411
  const emptyCapture = P3();
39916
40412
  node.body.at(-1).body.push(emptyCapture);
39917
40413
  }
39918
40414
  }
39919
40415
  },
39920
- Subroutine({ node }, state2) {
40416
+ Subroutine({ node }, state3) {
39921
40417
  if (!node.isRecursive || node.ref === 0) {
39922
40418
  return;
39923
40419
  }
39924
- node.ref = state2.reffedNodesByReferencer.get(node).number;
40420
+ node.ref = state3.reffedNodesByReferencer.get(node).number;
39925
40421
  }
39926
40422
  };
39927
40423
  function addParentProperties(root2) {
@@ -40163,7 +40659,7 @@ function generate(ast, options) {
40163
40659
  ignoreCase: !!((ast.flags.ignoreCase || hasCaseInsensitiveNode) && !hasCaseSensitiveNode)
40164
40660
  };
40165
40661
  let lastNode = ast;
40166
- const state2 = {
40662
+ const state3 = {
40167
40663
  accuracy: opts.accuracy,
40168
40664
  appliedGlobalFlags,
40169
40665
  captureMap: /* @__PURE__ */ new Map(),
@@ -40181,10 +40677,10 @@ function generate(ast, options) {
40181
40677
  verbose: opts.verbose
40182
40678
  };
40183
40679
  function gen(node) {
40184
- state2.lastNode = lastNode;
40680
+ state3.lastNode = lastNode;
40185
40681
  lastNode = node;
40186
40682
  const fn = throwIfNullish(generator[node.type], `Unexpected node type "${node.type}"`);
40187
- return fn(node, state2, gen);
40683
+ return fn(node, state3, gen);
40188
40684
  }
40189
40685
  const result = {
40190
40686
  pattern: ast.body.map(gen).join("|"),
@@ -40199,7 +40695,7 @@ function generate(ast, options) {
40199
40695
  }
40200
40696
  result._captureTransfers = /* @__PURE__ */ new Map();
40201
40697
  result._hiddenCaptures = [];
40202
- state2.captureMap.forEach((value, key2) => {
40698
+ state3.captureMap.forEach((value, key2) => {
40203
40699
  if (value.hidden) {
40204
40700
  result._hiddenCaptures.push(key2);
40205
40701
  }
@@ -40211,37 +40707,37 @@ function generate(ast, options) {
40211
40707
  }
40212
40708
  var FlagModifierVisitor = {
40213
40709
  "*": {
40214
- enter({ node }, state2) {
40710
+ enter({ node }, state3) {
40215
40711
  if (isAnyGroup(node)) {
40216
- const currentModI = state2.getCurrentModI();
40217
- state2.pushModI(
40712
+ const currentModI = state3.getCurrentModI();
40713
+ state3.pushModI(
40218
40714
  node.flags ? getNewCurrentFlags({ ignoreCase: currentModI }, node.flags).ignoreCase : currentModI
40219
40715
  );
40220
40716
  }
40221
40717
  },
40222
- exit({ node }, state2) {
40718
+ exit({ node }, state3) {
40223
40719
  if (isAnyGroup(node)) {
40224
- state2.popModI();
40720
+ state3.popModI();
40225
40721
  }
40226
40722
  }
40227
40723
  },
40228
- Backreference(_9, state2) {
40229
- state2.setHasCasedChar();
40724
+ Backreference(_9, state3) {
40725
+ state3.setHasCasedChar();
40230
40726
  },
40231
- Character({ node }, state2) {
40727
+ Character({ node }, state3) {
40232
40728
  if (charHasCase(cp(node.value))) {
40233
- state2.setHasCasedChar();
40729
+ state3.setHasCasedChar();
40234
40730
  }
40235
40731
  },
40236
- CharacterClassRange({ node, skip }, state2) {
40732
+ CharacterClassRange({ node, skip }, state3) {
40237
40733
  skip();
40238
40734
  if (getCasesOutsideCharClassRange(node, { firstOnly: true }).length) {
40239
- state2.setHasCasedChar();
40735
+ state3.setHasCasedChar();
40240
40736
  }
40241
40737
  },
40242
- CharacterSet({ node }, state2) {
40738
+ CharacterSet({ node }, state3) {
40243
40739
  if (node.kind === "property" && UnicodePropertiesWithSpecificCase.has(node.value)) {
40244
- state2.setHasCasedChar();
40740
+ state3.setHasCasedChar();
40245
40741
  }
40246
40742
  }
40247
40743
  };
@@ -40270,11 +40766,11 @@ var generator = {
40270
40766
  /**
40271
40767
  @param {BackreferenceNode} node
40272
40768
  */
40273
- Backreference({ ref }, state2) {
40769
+ Backreference({ ref }, state3) {
40274
40770
  if (typeof ref !== "number") {
40275
40771
  throw new Error("Unexpected named backref in transformed AST");
40276
40772
  }
40277
- if (!state2.useFlagMods && state2.accuracy === "strict" && state2.currentFlags.ignoreCase && !state2.captureMap.get(ref).ignoreCase) {
40773
+ if (!state3.useFlagMods && state3.accuracy === "strict" && state3.currentFlags.ignoreCase && !state3.captureMap.get(ref).ignoreCase) {
40278
40774
  throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");
40279
40775
  }
40280
40776
  return "\\" + ref;
@@ -40282,55 +40778,55 @@ var generator = {
40282
40778
  /**
40283
40779
  @param {CapturingGroupNode} node
40284
40780
  */
40285
- CapturingGroup(node, state2, gen) {
40781
+ CapturingGroup(node, state3, gen) {
40286
40782
  const { body: body4, name, number: number2 } = node;
40287
- const data = { ignoreCase: state2.currentFlags.ignoreCase };
40288
- const origin = state2.originMap.get(node);
40783
+ const data = { ignoreCase: state3.currentFlags.ignoreCase };
40784
+ const origin = state3.originMap.get(node);
40289
40785
  if (origin) {
40290
40786
  data.hidden = true;
40291
40787
  if (number2 > origin.number) {
40292
40788
  data.transferTo = origin.number;
40293
40789
  }
40294
40790
  }
40295
- state2.captureMap.set(number2, data);
40791
+ state3.captureMap.set(number2, data);
40296
40792
  return `(${name ? `?<${name}>` : ""}${body4.map(gen).join("|")})`;
40297
40793
  },
40298
40794
  /**
40299
40795
  @param {CharacterNode} node
40300
40796
  */
40301
- Character({ value }, state2) {
40797
+ Character({ value }, state3) {
40302
40798
  const char = cp(value);
40303
40799
  const escaped = getCharEscape(value, {
40304
- escDigit: state2.lastNode.type === "Backreference",
40305
- inCharClass: state2.inCharClass,
40306
- useFlagV: state2.useFlagV
40800
+ escDigit: state3.lastNode.type === "Backreference",
40801
+ inCharClass: state3.inCharClass,
40802
+ useFlagV: state3.useFlagV
40307
40803
  });
40308
40804
  if (escaped !== char) {
40309
40805
  return escaped;
40310
40806
  }
40311
- if (state2.useAppliedIgnoreCase && state2.currentFlags.ignoreCase && charHasCase(char)) {
40807
+ if (state3.useAppliedIgnoreCase && state3.currentFlags.ignoreCase && charHasCase(char)) {
40312
40808
  const cases = getIgnoreCaseMatchChars(char);
40313
- return state2.inCharClass ? cases.join("") : cases.length > 1 ? `[${cases.join("")}]` : cases[0];
40809
+ return state3.inCharClass ? cases.join("") : cases.length > 1 ? `[${cases.join("")}]` : cases[0];
40314
40810
  }
40315
40811
  return char;
40316
40812
  },
40317
40813
  /**
40318
40814
  @param {CharacterClassNode} node
40319
40815
  */
40320
- CharacterClass(node, state2, gen) {
40816
+ CharacterClass(node, state3, gen) {
40321
40817
  const { kind, negate, parent } = node;
40322
40818
  let { body: body4 } = node;
40323
- if (kind === "intersection" && !state2.useFlagV) {
40819
+ if (kind === "intersection" && !state3.useFlagV) {
40324
40820
  throw new Error("Use of character class intersection requires min target ES2024");
40325
40821
  }
40326
- if (envFlags.bugFlagVLiteralHyphenIsRange && state2.useFlagV && body4.some(isLiteralHyphen)) {
40822
+ if (envFlags.bugFlagVLiteralHyphenIsRange && state3.useFlagV && body4.some(isLiteralHyphen)) {
40327
40823
  body4 = [m12(45), ...body4.filter((kid) => !isLiteralHyphen(kid))];
40328
40824
  }
40329
40825
  const genClass = () => `[${negate ? "^" : ""}${body4.map(gen).join(kind === "intersection" ? "&&" : "")}]`;
40330
- if (!state2.inCharClass) {
40826
+ if (!state3.inCharClass) {
40331
40827
  if (
40332
40828
  // Already established `kind !== 'intersection'` if `!state.useFlagV`; don't check again
40333
- (!state2.useFlagV || envFlags.bugNestedClassIgnoresNegation) && !negate
40829
+ (!state3.useFlagV || envFlags.bugNestedClassIgnoresNegation) && !negate
40334
40830
  ) {
40335
40831
  const negatedChildClasses = body4.filter(
40336
40832
  (kid) => kid.type === "CharacterClass" && kid.kind === "union" && kid.negate
@@ -40357,21 +40853,21 @@ var generator = {
40357
40853
  return gen(group);
40358
40854
  }
40359
40855
  }
40360
- state2.inCharClass = true;
40856
+ state3.inCharClass = true;
40361
40857
  const result = genClass();
40362
- state2.inCharClass = false;
40858
+ state3.inCharClass = false;
40363
40859
  return result;
40364
40860
  }
40365
40861
  const firstEl = body4[0];
40366
40862
  if (
40367
40863
  // Already established that the parent is a char class via `inCharClass`; don't check again
40368
40864
  kind === "union" && !negate && firstEl && // Allows many nested classes to work with `target` ES2018 which doesn't support nesting
40369
- ((!state2.useFlagV || !state2.verbose) && parent.kind === "union" && !(envFlags.bugFlagVLiteralHyphenIsRange && state2.useFlagV) || !state2.verbose && parent.kind === "intersection" && // JS doesn't allow intersection with union or ranges
40865
+ ((!state3.useFlagV || !state3.verbose) && parent.kind === "union" && !(envFlags.bugFlagVLiteralHyphenIsRange && state3.useFlagV) || !state3.verbose && parent.kind === "intersection" && // JS doesn't allow intersection with union or ranges
40370
40866
  body4.length === 1 && firstEl.type !== "CharacterClassRange")
40371
40867
  ) {
40372
40868
  return body4.map(gen).join("");
40373
40869
  }
40374
- if (!state2.useFlagV && parent.type === "CharacterClass") {
40870
+ if (!state3.useFlagV && parent.type === "CharacterClass") {
40375
40871
  throw new Error("Uses nested character class in a way that requires min target ES2024");
40376
40872
  }
40377
40873
  return genClass();
@@ -40379,18 +40875,18 @@ var generator = {
40379
40875
  /**
40380
40876
  @param {CharacterClassRangeNode} node
40381
40877
  */
40382
- CharacterClassRange(node, state2) {
40878
+ CharacterClassRange(node, state3) {
40383
40879
  const min2 = node.min.value;
40384
40880
  const max2 = node.max.value;
40385
40881
  const escOpts = {
40386
40882
  escDigit: false,
40387
40883
  inCharClass: true,
40388
- useFlagV: state2.useFlagV
40884
+ useFlagV: state3.useFlagV
40389
40885
  };
40390
40886
  const minStr = getCharEscape(min2, escOpts);
40391
40887
  const maxStr = getCharEscape(max2, escOpts);
40392
40888
  const extraChars = /* @__PURE__ */ new Set();
40393
- if (state2.useAppliedIgnoreCase && state2.currentFlags.ignoreCase) {
40889
+ if (state3.useAppliedIgnoreCase && state3.currentFlags.ignoreCase) {
40394
40890
  const charsOutsideRange = getCasesOutsideCharClassRange(node);
40395
40891
  const ranges = getCodePointRangesFromChars(charsOutsideRange);
40396
40892
  ranges.forEach((value) => {
@@ -40404,9 +40900,9 @@ var generator = {
40404
40900
  /**
40405
40901
  @param {CharacterSetNode} node
40406
40902
  */
40407
- CharacterSet({ kind, negate, value, key: key2 }, state2) {
40903
+ CharacterSet({ kind, negate, value, key: key2 }, state3) {
40408
40904
  if (kind === "dot") {
40409
- return state2.currentFlags.dotAll ? state2.appliedGlobalFlags.dotAll || state2.useFlagMods ? "." : "[^]" : (
40905
+ return state3.currentFlags.dotAll ? state3.appliedGlobalFlags.dotAll || state3.useFlagMods ? "." : "[^]" : (
40410
40906
  // Onig's only line break char is line feed, unlike JS
40411
40907
  r36`[^\n]`
40412
40908
  );
@@ -40415,7 +40911,7 @@ var generator = {
40415
40911
  return negate ? r36`\D` : r36`\d`;
40416
40912
  }
40417
40913
  if (kind === "property") {
40418
- if (state2.useAppliedIgnoreCase && state2.currentFlags.ignoreCase && UnicodePropertiesWithSpecificCase.has(value)) {
40914
+ if (state3.useAppliedIgnoreCase && state3.currentFlags.ignoreCase && UnicodePropertiesWithSpecificCase.has(value)) {
40419
40915
  throw new Error(`Unicode property "${value}" can't be case-insensitive when other chars have specific case`);
40420
40916
  }
40421
40917
  return `${negate ? r36`\P` : r36`\p`}{${key2 ? `${key2}=` : ""}${value}}`;
@@ -40428,28 +40924,28 @@ var generator = {
40428
40924
  /**
40429
40925
  @param {FlagsNode} node
40430
40926
  */
40431
- Flags(node, state2) {
40927
+ Flags(node, state3) {
40432
40928
  return (
40433
40929
  // The transformer should never turn on the properties for flags d, g, m since Onig doesn't
40434
40930
  // have equivs. Flag m is never used since Onig uses different line break chars than JS
40435
40931
  // (node.hasIndices ? 'd' : '') +
40436
40932
  // (node.global ? 'g' : '') +
40437
40933
  // (node.multiline ? 'm' : '') +
40438
- (state2.appliedGlobalFlags.ignoreCase ? "i" : "") + (node.dotAll ? "s" : "") + (node.sticky ? "y" : "")
40934
+ (state3.appliedGlobalFlags.ignoreCase ? "i" : "") + (node.dotAll ? "s" : "") + (node.sticky ? "y" : "")
40439
40935
  );
40440
40936
  },
40441
40937
  /**
40442
40938
  @param {GroupNode} node
40443
40939
  */
40444
- Group({ atomic: atomic2, body: body4, flags, parent }, state2, gen) {
40445
- const currentFlags = state2.currentFlags;
40940
+ Group({ atomic: atomic2, body: body4, flags, parent }, state3, gen) {
40941
+ const currentFlags = state3.currentFlags;
40446
40942
  if (flags) {
40447
- state2.currentFlags = getNewCurrentFlags(currentFlags, flags);
40943
+ state3.currentFlags = getNewCurrentFlags(currentFlags, flags);
40448
40944
  }
40449
40945
  const contents = body4.map(gen).join("|");
40450
- const result = !state2.verbose && body4.length === 1 && // Single alt
40451
- parent.type !== "Quantifier" && !atomic2 && (!state2.useFlagMods || !flags) ? contents : `(?${getGroupPrefix(atomic2, flags, state2.useFlagMods)}${contents})`;
40452
- state2.currentFlags = currentFlags;
40946
+ const result = !state3.verbose && body4.length === 1 && // Single alt
40947
+ parent.type !== "Quantifier" && !atomic2 && (!state3.useFlagMods || !flags) ? contents : `(?${getGroupPrefix(atomic2, flags, state3.useFlagMods)}${contents})`;
40948
+ state3.currentFlags = currentFlags;
40453
40949
  return result;
40454
40950
  },
40455
40951
  /**
@@ -40468,11 +40964,11 @@ var generator = {
40468
40964
  /**
40469
40965
  @param {SubroutineNode & {isRecursive: true}} node
40470
40966
  */
40471
- Subroutine({ isRecursive, ref }, state2) {
40967
+ Subroutine({ isRecursive, ref }, state3) {
40472
40968
  if (!isRecursive) {
40473
40969
  throw new Error("Unexpected non-recursive subroutine in transformed AST");
40474
40970
  }
40475
- const limit2 = state2.recursionLimit;
40971
+ const limit2 = state3.recursionLimit;
40476
40972
  return ref === 0 ? `(?R=${limit2})` : r36`\g<${ref}&R=${limit2}>`;
40477
40973
  }
40478
40974
  };
@@ -42438,13 +42934,13 @@ var InteractionManager = class {
42438
42934
  }
42439
42935
  };
42440
42936
  }
42441
- resolveLineRenderRange(state2, split, source) {
42442
- if (state2.range == null) return;
42443
- const rowRange = this.getIndexesFromSelection(state2.range, split);
42937
+ resolveLineRenderRange(state3, split, source) {
42938
+ if (state3.range == null) return;
42939
+ const rowRange = this.getIndexesFromSelection(state3.range, split);
42444
42940
  if (rowRange == null) {
42445
42941
  console.error({
42446
42942
  rowRange,
42447
- range: state2.range
42943
+ range: state3.range
42448
42944
  });
42449
42945
  throw new Error(`InteractionManager.renderSelection: No valid ${source} rowRange`);
42450
42946
  }
@@ -43708,14 +44204,14 @@ function isDefaultRenderRange(renderRange) {
43708
44204
  }
43709
44205
 
43710
44206
  // node_modules/@pierre/diffs/dist/utils/processLine.js
43711
- function processLine(node, line, state2) {
43712
- const lineInfo = typeof state2.lineInfo === "function" ? state2.lineInfo(line) : state2.lineInfo[line - 1];
44207
+ function processLine(node, line, state3) {
44208
+ const lineInfo = typeof state3.lineInfo === "function" ? state3.lineInfo(line) : state3.lineInfo[line - 1];
43713
44209
  if (lineInfo == null) {
43714
44210
  const errorMessage = `processLine: line ${line}, contains no state.lineInfo`;
43715
44211
  console.error(errorMessage, {
43716
44212
  node,
43717
44213
  line,
43718
- state: state2
44214
+ state: state3
43719
44215
  });
43720
44216
  throw new Error(errorMessage);
43721
44217
  }
@@ -43867,7 +44363,7 @@ function cyrb53(str, seed = 0) {
43867
44363
 
43868
44364
  // node_modules/@pierre/diffs/dist/utils/createTransformerWithState.js
43869
44365
  function createTransformerWithState(useTokenTransformer = false, useCSSClasses = false) {
43870
- const state2 = { lineInfo: [] };
44366
+ const state3 = { lineInfo: [] };
43871
44367
  const transformers = [{
43872
44368
  line(node) {
43873
44369
  delete node.properties.class;
@@ -43881,7 +44377,7 @@ function createTransformerWithState(useTokenTransformer = false, useCSSClasses =
43881
44377
  for (const node of code2.children) {
43882
44378
  if (node.type !== "element") continue;
43883
44379
  if (useTokenTransformer) wrapTokenFragments(node);
43884
- children.push(processLine(node, index, state2));
44380
+ children.push(processLine(node, index, state3));
43885
44381
  index++;
43886
44382
  }
43887
44383
  code2.children = children;
@@ -43923,7 +44419,7 @@ function createTransformerWithState(useTokenTransformer = false, useCSSClasses =
43923
44419
  return node;
43924
44420
  } });
43925
44421
  return {
43926
- state: state2,
44422
+ state: state3,
43927
44423
  transformers,
43928
44424
  toClass
43929
44425
  };
@@ -44176,14 +44672,14 @@ function renderFileWithHighlighter(file, highlighter2, { theme: theme3, tokenize
44176
44672
  totalLines = Infinity;
44177
44673
  }
44178
44674
  const isWindowedHighlight = startingLine > 0 || totalLines < Infinity;
44179
- const { state: state2, transformers } = createTransformerWithState(useTokenTransformer);
44675
+ const { state: state3, transformers } = createTransformerWithState(useTokenTransformer);
44180
44676
  const lang = forcePlainText ? "text" : file.lang ?? getFiletypeFromFileName(file.name);
44181
44677
  const baseThemeType = typeof theme3 === "string" ? highlighter2.getTheme(theme3).type : void 0;
44182
44678
  const themeStyles = getHighlighterThemeStyles({
44183
44679
  theme: theme3,
44184
44680
  highlighter: highlighter2
44185
44681
  });
44186
- state2.lineInfo = (shikiLineNumber) => ({
44682
+ state3.lineInfo = (shikiLineNumber) => ({
44187
44683
  type: "context",
44188
44684
  lineIndex: shikiLineNumber - 1 + startingLine,
44189
44685
  lineNumber: shikiLineNumber + startingLine
@@ -47182,7 +47678,7 @@ var Diff = class {
47182
47678
  }
47183
47679
  diffWithOptionsObj(oldTokens, newTokens, options, callback) {
47184
47680
  var _a;
47185
- const done = (value) => {
47681
+ const done2 = (value) => {
47186
47682
  value = this.postProcess(value, options);
47187
47683
  if (callback) {
47188
47684
  setTimeout(function() {
@@ -47204,7 +47700,7 @@ var Diff = class {
47204
47700
  const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
47205
47701
  let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
47206
47702
  if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
47207
- return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
47703
+ return done2(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
47208
47704
  }
47209
47705
  let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
47210
47706
  const execEditLength = () => {
@@ -47231,7 +47727,7 @@ var Diff = class {
47231
47727
  }
47232
47728
  newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
47233
47729
  if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
47234
- return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
47730
+ return done2(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
47235
47731
  } else {
47236
47732
  bestPath[diagonalPath] = basePath;
47237
47733
  if (basePath.oldPos + 1 >= oldLen) {
@@ -48358,7 +48854,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48358
48854
  expandedHunks,
48359
48855
  collapsedContextThreshold
48360
48856
  });
48361
- const state2 = {
48857
+ const state3 = {
48362
48858
  viewportStart: startingLine,
48363
48859
  viewportEnd: startingLine + totalLines,
48364
48860
  isWindowedHighlight: startingLine > 0 || totalLines < Infinity,
@@ -48366,44 +48862,44 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48366
48862
  unifiedCount: iterationStart.unifiedCount,
48367
48863
  finalHunkIndex: diff.hunks.length - 1,
48368
48864
  shouldBreak() {
48369
- if (!state2.isWindowedHighlight) return false;
48370
- const breakUnified = state2.unifiedCount >= startingLine + totalLines;
48371
- const breakSplit = state2.splitCount >= startingLine + totalLines;
48865
+ if (!state3.isWindowedHighlight) return false;
48866
+ const breakUnified = state3.unifiedCount >= startingLine + totalLines;
48867
+ const breakSplit = state3.splitCount >= startingLine + totalLines;
48372
48868
  if (diffStyle === "unified") return breakUnified;
48373
48869
  else if (diffStyle === "split") return breakSplit;
48374
48870
  else return breakUnified && breakSplit;
48375
48871
  },
48376
48872
  shouldSkip(unifiedCount, splitCount) {
48377
- if (!state2.isWindowedHighlight) return false;
48378
- const skipUnified = unifiedCount > 0 && state2.unifiedCount + unifiedCount <= startingLine;
48379
- const skipSplit = splitCount > 0 && state2.splitCount + splitCount <= startingLine;
48873
+ if (!state3.isWindowedHighlight) return false;
48874
+ const skipUnified = unifiedCount > 0 && state3.unifiedCount + unifiedCount <= startingLine;
48875
+ const skipSplit = splitCount > 0 && state3.splitCount + splitCount <= startingLine;
48380
48876
  if (diffStyle === "unified") return skipUnified;
48381
48877
  else if (diffStyle === "split") return skipSplit;
48382
48878
  else return skipUnified && skipSplit;
48383
48879
  },
48384
48880
  incrementCounts(unifiedValue, splitValue) {
48385
- if (diffStyle === "unified" || diffStyle === "both") state2.unifiedCount += unifiedValue;
48386
- if (diffStyle === "split" || diffStyle === "both") state2.splitCount += splitValue;
48881
+ if (diffStyle === "unified" || diffStyle === "both") state3.unifiedCount += unifiedValue;
48882
+ if (diffStyle === "split" || diffStyle === "both") state3.splitCount += splitValue;
48387
48883
  },
48388
48884
  isInWindow(unifiedHeight, splitHeight) {
48389
- if (!state2.isWindowedHighlight) return true;
48390
- const unifiedInWindow = state2.isInUnifiedWindow(unifiedHeight);
48391
- const splitInWindow = state2.isInSplitWindow(splitHeight);
48885
+ if (!state3.isWindowedHighlight) return true;
48886
+ const unifiedInWindow = state3.isInUnifiedWindow(unifiedHeight);
48887
+ const splitInWindow = state3.isInSplitWindow(splitHeight);
48392
48888
  if (diffStyle === "unified") return unifiedInWindow;
48393
48889
  else if (diffStyle === "split") return splitInWindow;
48394
48890
  else return unifiedInWindow || splitInWindow;
48395
48891
  },
48396
48892
  isInUnifiedWindow(unifiedHeight) {
48397
- return !state2.isWindowedHighlight || state2.unifiedCount >= startingLine - unifiedHeight && state2.unifiedCount < startingLine + totalLines;
48893
+ return !state3.isWindowedHighlight || state3.unifiedCount >= startingLine - unifiedHeight && state3.unifiedCount < startingLine + totalLines;
48398
48894
  },
48399
48895
  isInSplitWindow(splitHeight) {
48400
- return !state2.isWindowedHighlight || state2.splitCount >= startingLine - splitHeight && state2.splitCount < startingLine + totalLines;
48896
+ return !state3.isWindowedHighlight || state3.splitCount >= startingLine - splitHeight && state3.splitCount < startingLine + totalLines;
48401
48897
  },
48402
48898
  emit(props, silent = false) {
48403
48899
  if (!silent) {
48404
- if (diffStyle === "unified") state2.incrementCounts(1, 0);
48405
- else if (diffStyle === "split") state2.incrementCounts(0, 1);
48406
- else state2.incrementCounts(1, 1);
48900
+ if (diffStyle === "unified") state3.incrementCounts(1, 0);
48901
+ else if (diffStyle === "split") state3.incrementCounts(0, 1);
48902
+ else state3.incrementCounts(1, 1);
48407
48903
  }
48408
48904
  return callback(props) ?? false;
48409
48905
  }
@@ -48420,7 +48916,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48420
48916
  };
48421
48917
  const hunk = diff.hunks[hunkIndex];
48422
48918
  if (hunk == null) throw new Error("iterateOverDiff: invalid hunk index");
48423
- if (state2.shouldBreak()) break;
48919
+ if (state3.shouldBreak()) break;
48424
48920
  const deletionBoundary = getHunkSideStartBoundary(hunk.deletionStart, hunk.deletionCount);
48425
48921
  const additionBoundary = getHunkSideStartBoundary(hunk.additionStart, hunk.additionCount);
48426
48922
  const deletionStartIndex = !diff.isPartial && hunk.deletionCount === 0 ? deletionBoundary : hunk.deletionLineIndex;
@@ -48432,7 +48928,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48432
48928
  hunkIndex,
48433
48929
  collapsedContextThreshold
48434
48930
  });
48435
- const trailingRegion = hunkIndex === state2.finalHunkIndex ? getTrailingExpandedRegion({
48931
+ const trailingRegion = hunkIndex === state3.finalHunkIndex ? getTrailingExpandedRegion({
48436
48932
  fileDiff: diff,
48437
48933
  hunkIndex,
48438
48934
  expandedHunks,
@@ -48441,15 +48937,15 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48441
48937
  }) : void 0;
48442
48938
  const expandedLineCount = leadingRegion.fromStart + leadingRegion.fromEnd;
48443
48939
  let consumedCollapsed = leadingRegion.collapsedLines === 0;
48444
- if (!state2.shouldSkip(expandedLineCount, expandedLineCount)) {
48940
+ if (!state3.shouldSkip(expandedLineCount, expandedLineCount)) {
48445
48941
  let unifiedLineIndex2 = hunk.unifiedLineStart - leadingRegion.rangeSize;
48446
48942
  let splitLineIndex2 = hunk.splitLineStart - leadingRegion.rangeSize;
48447
48943
  let deletionLineIndex2 = deletionStartIndex - leadingRegion.rangeSize;
48448
48944
  let additionLineIndex2 = additionStartIndex - leadingRegion.rangeSize;
48449
48945
  let deletionLineNumber2 = deletionBoundary + 1 - leadingRegion.rangeSize;
48450
48946
  let additionLineNumber2 = additionBoundary + 1 - leadingRegion.rangeSize;
48451
- if (walkContextLines(state2, leadingRegion.fromStart, diffStyle, (index) => {
48452
- return state2.emit({
48947
+ if (walkContextLines(state3, leadingRegion.fromStart, diffStyle, (index) => {
48948
+ return state3.emit({
48453
48949
  hunkIndex,
48454
48950
  hunk,
48455
48951
  collapsedBefore: 0,
@@ -48477,8 +48973,8 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48477
48973
  additionLineIndex2 = additionStartIndex - leadingRegion.fromEnd;
48478
48974
  deletionLineNumber2 = deletionBoundary + 1 - leadingRegion.fromEnd;
48479
48975
  additionLineNumber2 = additionBoundary + 1 - leadingRegion.fromEnd;
48480
- if (walkContextLines(state2, leadingRegion.fromEnd, diffStyle, (index) => {
48481
- return state2.emit({
48976
+ if (walkContextLines(state3, leadingRegion.fromEnd, diffStyle, (index) => {
48977
+ return state3.emit({
48482
48978
  hunkIndex,
48483
48979
  hunk,
48484
48980
  collapsedBefore: consumePendingCollapsed(),
@@ -48503,7 +48999,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48503
48999
  consumePendingCollapsed();
48504
49000
  })) break hunkIterator;
48505
49001
  } else {
48506
- state2.incrementCounts(expandedLineCount, expandedLineCount);
49002
+ state3.incrementCounts(expandedLineCount, expandedLineCount);
48507
49003
  consumePendingCollapsed();
48508
49004
  }
48509
49005
  let unifiedLineIndex = hunk.unifiedLineStart;
@@ -48514,15 +49010,15 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48514
49010
  let additionLineNumber = additionBoundary + 1;
48515
49011
  const lastContent = hunk.hunkContent.at(-1);
48516
49012
  for (const content of hunk.hunkContent) {
48517
- if (state2.shouldBreak()) break hunkIterator;
49013
+ if (state3.shouldBreak()) break hunkIterator;
48518
49014
  const isLastContent = content === lastContent;
48519
49015
  if (content.type === "context") {
48520
- if (!state2.shouldSkip(content.lines, content.lines)) {
48521
- if (walkContextLines(state2, content.lines, diffStyle, (index) => {
49016
+ if (!state3.shouldSkip(content.lines, content.lines)) {
49017
+ if (walkContextLines(state3, content.lines, diffStyle, (index) => {
48522
49018
  const isLastLine = isLastContent && index === content.lines - 1;
48523
49019
  const unifiedRowIndex = unifiedLineIndex + index;
48524
49020
  const splitRowIndex = splitLineIndex + index;
48525
- return state2.emit({
49021
+ return state3.emit({
48526
49022
  hunkIndex,
48527
49023
  hunk,
48528
49024
  collapsedBefore: consumePendingCollapsed(),
@@ -48547,7 +49043,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48547
49043
  consumePendingCollapsed();
48548
49044
  })) break hunkIterator;
48549
49045
  } else {
48550
- state2.incrementCounts(content.lines, content.lines);
49046
+ state3.incrementCounts(content.lines, content.lines);
48551
49047
  consumePendingCollapsed();
48552
49048
  }
48553
49049
  unifiedLineIndex += content.lines;
@@ -48559,12 +49055,12 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48559
49055
  } else {
48560
49056
  const splitCount = Math.max(content.deletions, content.additions);
48561
49057
  const unifiedCount = content.deletions + content.additions;
48562
- if (!state2.shouldSkip(unifiedCount, splitCount)) {
48563
- const iterationRanges = getChangeIterationRanges(state2, content, diffStyle);
49058
+ if (!state3.shouldSkip(unifiedCount, splitCount)) {
49059
+ const iterationRanges = getChangeIterationRanges(state3, content, diffStyle);
48564
49060
  if ((iterationRanges[0]?.[0] ?? 0) > 0) consumePendingCollapsed();
48565
49061
  for (const [rangeStart, rangeEnd] of iterationRanges) for (let index = rangeStart; index < rangeEnd; index++) {
48566
49062
  const collapsedAfter = getTrailingCollapsedAfter(unifiedLineIndex + index, diffStyle === "unified" ? splitLineIndex + (index < content.deletions ? index : index - content.deletions) : splitLineIndex + index);
48567
- if (state2.emit(getChangeLineData({
49063
+ if (state3.emit(getChangeLineData({
48568
49064
  hunkIndex,
48569
49065
  hunk,
48570
49066
  collapsedBefore: consumePendingCollapsed(),
@@ -48585,7 +49081,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48585
49081
  }
48586
49082
  }
48587
49083
  consumePendingCollapsed();
48588
- state2.incrementCounts(unifiedCount, splitCount);
49084
+ state3.incrementCounts(unifiedCount, splitCount);
48589
49085
  unifiedLineIndex += unifiedCount;
48590
49086
  splitLineIndex += splitCount;
48591
49087
  deletionLineIndex += content.deletions;
@@ -48597,9 +49093,9 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48597
49093
  if (trailingRegion != null) {
48598
49094
  const { collapsedLines, fromStart, fromEnd } = trailingRegion;
48599
49095
  const len = fromStart + fromEnd;
48600
- if (walkContextLines(state2, len, diffStyle, (index) => {
49096
+ if (walkContextLines(state3, len, diffStyle, (index) => {
48601
49097
  const isLastLine = index === len - 1;
48602
- return state2.emit({
49098
+ return state3.emit({
48603
49099
  hunkIndex: diff.hunks.length,
48604
49100
  hunk: void 0,
48605
49101
  collapsedBefore: 0,
@@ -48620,7 +49116,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48620
49116
  noEOFCR: false
48621
49117
  }
48622
49118
  });
48623
- }, void 0, () => state2.shouldBreak())) break hunkIterator;
49119
+ }, void 0, () => state3.shouldBreak())) break hunkIterator;
48624
49120
  }
48625
49121
  }
48626
49122
  }
@@ -48704,16 +49200,16 @@ function getHunkPrefixCounts({ diff, expandedHunks, collapsedContextThreshold })
48704
49200
  }
48705
49201
  return prefixCounts;
48706
49202
  }
48707
- function getContextLineIterationBounds(state2, count, diffStyle) {
48708
- if (!state2.isWindowedHighlight || count <= 0) return [0, count];
49203
+ function getContextLineIterationBounds(state3, count, diffStyle) {
49204
+ if (!state3.isWindowedHighlight || count <= 0) return [0, count];
48709
49205
  const ranges = [];
48710
49206
  function pushRange(currentCount) {
48711
- const start2 = Math.max(0, state2.viewportStart - currentCount);
48712
- const end2 = Math.min(count, state2.viewportEnd - currentCount);
49207
+ const start2 = Math.max(0, state3.viewportStart - currentCount);
49208
+ const end2 = Math.min(count, state3.viewportEnd - currentCount);
48713
49209
  if (end2 > start2) ranges.push([start2, end2]);
48714
49210
  }
48715
- if (diffStyle !== "split") pushRange(state2.unifiedCount);
48716
- if (diffStyle !== "unified") pushRange(state2.splitCount);
49211
+ if (diffStyle !== "split") pushRange(state3.unifiedCount);
49212
+ if (diffStyle !== "unified") pushRange(state3.splitCount);
48717
49213
  if (ranges.length === 0) return [0, 0];
48718
49214
  let start = ranges[0][0];
48719
49215
  let end = ranges[0][1];
@@ -48724,36 +49220,36 @@ function getContextLineIterationBounds(state2, count, diffStyle) {
48724
49220
  }
48725
49221
  return [start, end];
48726
49222
  }
48727
- function walkContextLines(state2, count, diffStyle, callback, onSkippedStart, shouldBreak) {
48728
- const [startIndex, endIndex] = getContextLineIterationBounds(state2, count, diffStyle);
49223
+ function walkContextLines(state3, count, diffStyle, callback, onSkippedStart, shouldBreak) {
49224
+ const [startIndex, endIndex] = getContextLineIterationBounds(state3, count, diffStyle);
48729
49225
  if (startIndex > 0) {
48730
- state2.incrementCounts(startIndex, startIndex);
49226
+ state3.incrementCounts(startIndex, startIndex);
48731
49227
  onSkippedStart?.();
48732
49228
  }
48733
49229
  let index = startIndex;
48734
49230
  while (index < count) {
48735
49231
  if (shouldBreak?.() === true) return true;
48736
49232
  if (index >= endIndex) {
48737
- state2.incrementCounts(count - index, count - index);
49233
+ state3.incrementCounts(count - index, count - index);
48738
49234
  break;
48739
49235
  }
48740
- if (state2.isInWindow(0, 0)) {
49236
+ if (state3.isInWindow(0, 0)) {
48741
49237
  if (callback(index) === true) return true;
48742
- } else state2.incrementCounts(1, 1);
49238
+ } else state3.incrementCounts(1, 1);
48743
49239
  index++;
48744
49240
  }
48745
49241
  return false;
48746
49242
  }
48747
- function getChangeIterationRanges(state2, content, diffStyle) {
48748
- if (!state2.isWindowedHighlight) return [[0, diffStyle === "unified" ? content.deletions + content.additions : Math.max(content.deletions, content.additions)]];
49243
+ function getChangeIterationRanges(state3, content, diffStyle) {
49244
+ if (!state3.isWindowedHighlight) return [[0, diffStyle === "unified" ? content.deletions + content.additions : Math.max(content.deletions, content.additions)]];
48749
49245
  const useUnified = diffStyle !== "split";
48750
49246
  const useSplit = diffStyle !== "unified";
48751
49247
  const iterationSpace = diffStyle === "unified" ? "unified" : "split";
48752
49248
  const iterationRanges = [];
48753
49249
  function getVisibleRange(start, count) {
48754
- if (start + count <= state2.viewportStart || start >= state2.viewportEnd) return;
48755
- const visibleStart = Math.max(0, state2.viewportStart - start);
48756
- const visibleEnd = Math.min(count, state2.viewportEnd - start);
49250
+ if (start + count <= state3.viewportStart || start >= state3.viewportEnd) return;
49251
+ const visibleStart = Math.max(0, state3.viewportStart - start);
49252
+ const visibleEnd = Math.min(count, state3.viewportEnd - start);
48757
49253
  return visibleEnd > visibleStart ? [visibleStart, visibleEnd] : void 0;
48758
49254
  }
48759
49255
  function mapRangeToIteration(range3, kind) {
@@ -48766,12 +49262,12 @@ function getChangeIterationRanges(state2, content, diffStyle) {
48766
49262
  if (end > start) iterationRanges.push([start, end]);
48767
49263
  }
48768
49264
  if (useUnified) {
48769
- pushRange(getVisibleRange(state2.unifiedCount, content.deletions), "deletions");
48770
- pushRange(getVisibleRange(state2.unifiedCount + content.deletions, content.additions), "additions");
49265
+ pushRange(getVisibleRange(state3.unifiedCount, content.deletions), "deletions");
49266
+ pushRange(getVisibleRange(state3.unifiedCount + content.deletions, content.additions), "additions");
48771
49267
  }
48772
49268
  if (useSplit) {
48773
- pushRange(getVisibleRange(state2.splitCount, content.deletions), "deletions");
48774
- pushRange(getVisibleRange(state2.splitCount, content.additions), "additions");
49269
+ pushRange(getVisibleRange(state3.splitCount, content.deletions), "deletions");
49270
+ pushRange(getVisibleRange(state3.splitCount, content.additions), "additions");
48775
49271
  }
48776
49272
  if (iterationRanges.length === 0) return iterationRanges;
48777
49273
  iterationRanges.sort((a22, b13) => a22[0] - b13[0]);
@@ -49087,7 +49583,7 @@ function createBucket() {
49087
49583
  function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo, highlighter: highlighter2, deletionDecorations, additionDecorations, languageOverride, options: { theme: themeOrThemes, ...options } }) {
49088
49584
  const deletionLang = languageOverride ?? getFiletypeFromFileName(deletionFile.name);
49089
49585
  const additionLang = languageOverride ?? getFiletypeFromFileName(additionFile.name);
49090
- const { state: state2, transformers } = createTransformerWithState(options.useTokenTransformer);
49586
+ const { state: state3, transformers } = createTransformerWithState(options.useTokenTransformer);
49091
49587
  const hastConfig = (() => {
49092
49588
  return typeof themeOrThemes === "string" ? {
49093
49589
  ...options,
@@ -49113,7 +49609,7 @@ function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo
49113
49609
  deletionLines: (() => {
49114
49610
  if (deletionFile.contents === "") return [];
49115
49611
  hastConfig.lang = deletionLang;
49116
- state2.lineInfo = deletionInfo;
49612
+ state3.lineInfo = deletionInfo;
49117
49613
  hastConfig.decorations = deletionDecorations;
49118
49614
  return getLineNodes(highlighter2.codeToHast(cleanLastNewline(deletionFile.contents), hastConfig));
49119
49615
  })(),
@@ -49121,7 +49617,7 @@ function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo
49121
49617
  if (additionFile.contents === "") return [];
49122
49618
  hastConfig.lang = additionLang;
49123
49619
  hastConfig.decorations = additionDecorations;
49124
- state2.lineInfo = additionInfo;
49620
+ state3.lineInfo = additionInfo;
49125
49621
  return getLineNodes(highlighter2.codeToHast(cleanLastNewline(additionFile.contents), hastConfig));
49126
49622
  })()
49127
49623
  };
@@ -51041,8 +51537,8 @@ function areHunkDataEqual(hunkA, hunkB) {
51041
51537
  async function awaitWithTimeout(callback, timeout = 300) {
51042
51538
  let timeoutId;
51043
51539
  try {
51044
- await Promise.race([callback(), new Promise((resolve) => {
51045
- timeoutId = setTimeout(resolve, timeout);
51540
+ await Promise.race([callback(), new Promise((resolve2) => {
51541
+ timeoutId = setTimeout(resolve2, timeout);
51046
51542
  })]);
51047
51543
  } finally {
51048
51544
  if (timeoutId != null) clearTimeout(timeoutId);
@@ -53969,14 +54465,14 @@ var PopoutWindow = class extends CompositeDisposable {
53969
54465
  id: _this.target,
53970
54466
  window: externalWindow
53971
54467
  });
53972
- return new Promise((resolve) => {
54468
+ return new Promise((resolve2) => {
53973
54469
  const abandon = (err) => {
53974
54470
  _this._failure = {
53975
54471
  reason: "unscriptable",
53976
54472
  error: err instanceof Error ? err : new Error(String(err))
53977
54473
  };
53978
54474
  _this.close();
53979
- resolve(null);
54475
+ resolve2(null);
53980
54476
  };
53981
54477
  try {
53982
54478
  externalWindow.addEventListener("unload", () => {
@@ -53988,7 +54484,7 @@ var PopoutWindow = class extends CompositeDisposable {
53988
54484
  disposable.addDisposables(_this.onWillClose(() => {
53989
54485
  var _this$_failure;
53990
54486
  (_this$_failure = _this._failure) !== null && _this$_failure !== void 0 || (_this._failure = { reason: "closed" });
53991
- resolve(null);
54487
+ resolve2(null);
53992
54488
  }));
53993
54489
  externalWindow.addEventListener("load", () => {
53994
54490
  try {
@@ -54006,7 +54502,7 @@ var PopoutWindow = class extends CompositeDisposable {
54006
54502
  addDisposableListener(externalWindow, "beforeunload", () => {
54007
54503
  _this.close();
54008
54504
  });
54009
- resolve(container);
54505
+ resolve2(container);
54010
54506
  } catch (err) {
54011
54507
  abandon(err);
54012
54508
  }
@@ -54720,11 +55216,11 @@ var Splitview = class {
54720
55216
  else this.updateSash(sash, 3);
54721
55217
  }
54722
55218
  }
54723
- updateSash(sash, state2) {
54724
- toggleClass(sash.container, "dv-disabled", state2 === 2);
54725
- toggleClass(sash.container, "dv-enabled", state2 === 3);
54726
- toggleClass(sash.container, "dv-maximum", state2 === 0);
54727
- toggleClass(sash.container, "dv-minimum", state2 === 1);
55219
+ updateSash(sash, state3) {
55220
+ toggleClass(sash.container, "dv-disabled", state3 === 2);
55221
+ toggleClass(sash.container, "dv-enabled", state3 === 3);
55222
+ toggleClass(sash.container, "dv-maximum", state3 === 0);
55223
+ toggleClass(sash.container, "dv-minimum", state3 === 1);
54728
55224
  }
54729
55225
  createViewContainer() {
54730
55226
  const element2 = document.createElement("div");
@@ -56923,14 +57419,14 @@ var Droptarget = class Droptarget2 extends CompositeDisposable {
56923
57419
  onDrop: (e119) => {
56924
57420
  var _this$options$getOver7, _this$options6;
56925
57421
  e119.preventDefault();
56926
- const state2 = this._state;
57422
+ const state3 = this._state;
56927
57423
  const edge = this._edge;
56928
57424
  this.removeDropTarget();
56929
57425
  (_this$options$getOver7 = (_this$options6 = this.options).getOverrideTarget) === null || _this$options$getOver7 === void 0 || (_this$options$getOver7 = _this$options$getOver7.call(_this$options6)) === null || _this$options$getOver7 === void 0 || _this$options$getOver7.clear();
56930
- if (state2) {
57426
+ if (state3) {
56931
57427
  e119.stopPropagation();
56932
57428
  this._onDrop.fire({
56933
- position: state2,
57429
+ position: state3,
56934
57430
  nativeEvent: e119,
56935
57431
  edge
56936
57432
  });
@@ -57404,13 +57900,13 @@ var PointerDropTarget = class extends CompositeDisposable {
57404
57900
  }
57405
57901
  _onDropEvent(event2) {
57406
57902
  var _this$options$getOver5, _this$options4;
57407
- const state2 = this._state;
57903
+ const state3 = this._state;
57408
57904
  const edge = this._edge;
57409
57905
  const overrideTarget = (_this$options$getOver5 = (_this$options4 = this.options).getOverrideTarget) === null || _this$options$getOver5 === void 0 ? void 0 : _this$options$getOver5.call(_this$options4);
57410
57906
  this._removeOverlay();
57411
57907
  overrideTarget === null || overrideTarget === void 0 || overrideTarget.clear();
57412
- if (state2) this._onDrop.fire({
57413
- position: state2,
57908
+ if (state3) this._onDrop.fire({
57909
+ position: state3,
57414
57910
  nativeEvent: event2.pointerEvent,
57415
57911
  edge
57416
57912
  });
@@ -60117,9 +60613,9 @@ var TabReorderController = class extends CompositeDisposable {
60117
60613
  else this._animState.currentInsertionIndex = null;
60118
60614
  }
60119
60615
  snapshotTabPositions() {
60120
- const positions = /* @__PURE__ */ new Map();
60121
- for (const tab of this._tabs) positions.set(tab.value.panel.id, tab.value.element.getBoundingClientRect());
60122
- return positions;
60616
+ const positions2 = /* @__PURE__ */ new Map();
60617
+ for (const tab of this._tabs) positions2.set(tab.value.panel.id, tab.value.element.getBoundingClientRect());
60618
+ return positions2;
60123
60619
  }
60124
60620
  /** Main-axis extent of a rect for this header's orientation. */
60125
60621
  _mainAxisSize(rect) {
@@ -63438,10 +63934,10 @@ var GridviewPanel = class extends BasePanelView {
63438
63934
  });
63439
63935
  }
63440
63936
  toJSON() {
63441
- const state2 = super.toJSON();
63937
+ const state3 = super.toJSON();
63442
63938
  const maximum = (value) => value === Number.MAX_SAFE_INTEGER ? void 0 : value;
63443
63939
  const minimum = (value) => value <= 0 ? void 0 : value;
63444
- return _objectSpread2(_objectSpread2({}, state2), {}, {
63940
+ return _objectSpread2(_objectSpread2({}, state3), {}, {
63445
63941
  minimumHeight: minimum(this.minimumHeight),
63446
63942
  maximumHeight: maximum(this.maximumHeight),
63447
63943
  minimumWidth: minimum(this.minimumWidth),
@@ -63933,17 +64429,17 @@ var DockviewPanel = class extends CompositeDisposable {
63933
64429
  for (const key2 of Object.keys(event2.params)) if (event2.params[key2] === void 0) delete this._params[key2];
63934
64430
  this.view.update({ params: this._params });
63935
64431
  }
63936
- updateFromStateModel(state2) {
64432
+ updateFromStateModel(state3) {
63937
64433
  var _state$params, _state$title, _state$renderer, _state$pinned, _this$accessor$option;
63938
- this._maximumHeight = state2.maximumHeight;
63939
- this._minimumHeight = state2.minimumHeight;
63940
- this._maximumWidth = state2.maximumWidth;
63941
- this._minimumWidth = state2.minimumWidth;
63942
- this._params = (_state$params = state2.params) !== null && _state$params !== void 0 ? _state$params : {};
64434
+ this._maximumHeight = state3.maximumHeight;
64435
+ this._minimumHeight = state3.minimumHeight;
64436
+ this._maximumWidth = state3.maximumWidth;
64437
+ this._minimumWidth = state3.minimumWidth;
64438
+ this._params = (_state$params = state3.params) !== null && _state$params !== void 0 ? _state$params : {};
63943
64439
  this.view.update({ params: this._params });
63944
- this.setTitle((_state$title = state2.title) !== null && _state$title !== void 0 ? _state$title : this.id);
63945
- this.setRenderer((_state$renderer = state2.renderer) !== null && _state$renderer !== void 0 ? _state$renderer : this.accessor.renderer);
63946
- this.setPinned(((_state$pinned = state2.pinned) !== null && _state$pinned !== void 0 ? _state$pinned : false) && !!((_this$accessor$option = this.accessor.options.pinnedTabs) === null || _this$accessor$option === void 0 ? void 0 : _this$accessor$option.enabled));
64440
+ this.setTitle((_state$title = state3.title) !== null && _state$title !== void 0 ? _state$title : this.id);
64441
+ this.setRenderer((_state$renderer = state3.renderer) !== null && _state$renderer !== void 0 ? _state$renderer : this.accessor.renderer);
64442
+ this.setPinned(((_state$pinned = state3.pinned) !== null && _state$pinned !== void 0 ? _state$pinned : false) && !!((_this$accessor$option = this.accessor.options.pinnedTabs) === null || _this$accessor$option === void 0 ? void 0 : _this$accessor$option.enabled));
63947
64443
  }
63948
64444
  updateParentGroup(group, options) {
63949
64445
  this._group = group;
@@ -64946,20 +65442,20 @@ var PopoutWindowService = class {
64946
65442
  * only for the timer that starts it.
64947
65443
  */
64948
65444
  scheduleRestoration(delayMs, work, onCancel) {
64949
- return new Promise((resolve) => {
65445
+ return new Promise((resolve2) => {
64950
65446
  const cleanup = () => {
64951
65447
  this._restorationCleanups.delete(cleanup);
64952
65448
  clearTimeout(handle2);
64953
65449
  onCancel === null || onCancel === void 0 || onCancel();
64954
- resolve();
65450
+ resolve2();
64955
65451
  };
64956
65452
  const handle2 = setTimeout(() => {
64957
65453
  this._restorationCleanups.delete(cleanup);
64958
65454
  if (this._host.isDisposed) {
64959
- resolve();
65455
+ resolve2();
64960
65456
  return;
64961
65457
  }
64962
- Promise.resolve(work()).then(() => resolve(), () => resolve());
65458
+ Promise.resolve(work()).then(() => resolve2(), () => resolve2());
64963
65459
  }, delayMs);
64964
65460
  this._restorationCleanups.add(cleanup);
64965
65461
  });
@@ -65221,36 +65717,36 @@ var HeaderActionsService = class {
65221
65717
  }
65222
65718
  refresh(group) {
65223
65719
  if (!(group === null || group === void 0 ? void 0 : group.model)) return;
65224
- const state2 = this._ensureState(group);
65225
- this._refreshSlot("left", group, state2.left);
65226
- this._refreshSlot("right", group, state2.right);
65227
- this._refreshSlot("prefix", group, state2.prefix);
65720
+ const state3 = this._ensureState(group);
65721
+ this._refreshSlot("left", group, state3.left);
65722
+ this._refreshSlot("right", group, state3.right);
65723
+ this._refreshSlot("prefix", group, state3.prefix);
65228
65724
  }
65229
65725
  refreshAll() {
65230
65726
  for (const group of this._host.groups) this.refresh(group);
65231
65727
  }
65232
65728
  disposeGroup(group) {
65233
- const state2 = this._perGroup.get(group);
65234
- if (!state2) return;
65235
- state2.left.dispose();
65236
- state2.right.dispose();
65237
- state2.prefix.dispose();
65729
+ const state3 = this._perGroup.get(group);
65730
+ if (!state3) return;
65731
+ state3.left.dispose();
65732
+ state3.right.dispose();
65733
+ state3.prefix.dispose();
65238
65734
  this._perGroup.delete(group);
65239
65735
  }
65240
65736
  dispose() {
65241
65737
  for (const group of [...this._perGroup.keys()]) this.disposeGroup(group);
65242
65738
  }
65243
65739
  _ensureState(group) {
65244
- let state2 = this._perGroup.get(group);
65245
- if (!state2) {
65246
- state2 = {
65740
+ let state3 = this._perGroup.get(group);
65741
+ if (!state3) {
65742
+ state3 = {
65247
65743
  left: new MutableDisposable(),
65248
65744
  right: new MutableDisposable(),
65249
65745
  prefix: new MutableDisposable()
65250
65746
  };
65251
- this._perGroup.set(group, state2);
65747
+ this._perGroup.set(group, state3);
65252
65748
  }
65253
- return state2;
65749
+ return state3;
65254
65750
  }
65255
65751
  _refreshSlot(slot, group, disposable) {
65256
65752
  const factory = this._host.options[SLOT_OPTION_KEY[slot]];
@@ -66935,16 +67431,16 @@ var ShellManager = class {
66935
67431
  "bottom"
66936
67432
  ]) {
66937
67433
  var _state$collapsed;
66938
- const state2 = data[position];
67434
+ const state3 = data[position];
66939
67435
  const view = this._getView(position);
66940
- if (!state2 || !view) continue;
66941
- view.restoreExpandedSize(state2.size);
66942
- view.setCollapsed((_state$collapsed = state2.collapsed) !== null && _state$collapsed !== void 0 ? _state$collapsed : false);
66943
- if (state2.collapsed) {
67436
+ if (!state3 || !view) continue;
67437
+ view.restoreExpandedSize(state3.size);
67438
+ view.setCollapsed((_state$collapsed = state3.collapsed) !== null && _state$collapsed !== void 0 ? _state$collapsed : false);
67439
+ if (state3.collapsed) {
66944
67440
  this._pendingSizes.delete(position);
66945
67441
  this._resizeView(position, view.collapsedSize);
66946
- } else this.resizeEdgeGroup(position, state2.size);
66947
- this.setEdgeGroupVisible(position, !!state2.visible);
67442
+ } else this.resizeEdgeGroup(position, state3.size);
67443
+ this.setEdgeGroupVisible(position, !!state3.visible);
66948
67444
  }
66949
67445
  }
66950
67446
  dispose() {
@@ -68700,7 +69196,7 @@ var DockviewComponent = class extends BaseGrid {
68700
69196
  const width = this.width;
68701
69197
  const height = this.height;
68702
69198
  const createGroupFromSerializedState = (data2) => {
68703
- const { id, locked, hideHeader, headerPosition, views, activeView } = data2;
69199
+ const { id, locked, hideHeader, headerPosition, views: views2, activeView } = data2;
68704
69200
  if (typeof id !== "string") throw new TypeError("dockview: group id must be of type string");
68705
69201
  const group = this.createGroup({
68706
69202
  id,
@@ -68710,7 +69206,7 @@ var DockviewComponent = class extends BaseGrid {
68710
69206
  });
68711
69207
  this._onDidAddGroup.fire(group);
68712
69208
  const createdPanels = [];
68713
- const presentViews = views.filter((child) => panels[child]);
69209
+ const presentViews = views2.filter((child) => panels[child]);
68714
69210
  for (const child of presentViews) {
68715
69211
  const existingPanel = existingPanels.get(child);
68716
69212
  const temporaryGroup = temporaryGroups.get(child);
@@ -68823,9 +69319,9 @@ var DockviewComponent = class extends BaseGrid {
68823
69319
  const edgeData = edgeGroups[position];
68824
69320
  const groupState = edgeData === null || edgeData === void 0 ? void 0 : edgeData.group;
68825
69321
  if (groupState) {
68826
- const { views, activeView } = groupState;
69322
+ const { views: views2, activeView } = groupState;
68827
69323
  const createdPanels = [];
68828
- for (const panelId of views) {
69324
+ for (const panelId of views2) {
68829
69325
  if (!panels[panelId]) continue;
68830
69326
  const existingPanel = existingPanels.get(panelId);
68831
69327
  const temporaryGroup = temporaryGroups.get(panelId);
@@ -70864,13 +71360,13 @@ function ensureChildIdByNameId(nodes, index) {
70864
71360
  }
70865
71361
  function ensureChildPositions(index) {
70866
71362
  if (index.childPositionById != null) return index.childPositionById;
70867
- const positions = /* @__PURE__ */ new Map();
71363
+ const positions2 = /* @__PURE__ */ new Map();
70868
71364
  for (let i25 = 0; i25 < index.childIds.length; i25++) {
70869
71365
  const childId = index.childIds[i25];
70870
- if (childId != null) positions.set(childId, i25);
71366
+ if (childId != null) positions2.set(childId, i25);
70871
71367
  }
70872
- index.childPositionById = positions;
70873
- return positions;
71368
+ index.childPositionById = positions2;
71369
+ return positions2;
70874
71370
  }
70875
71371
  function appendChildReference(index, childId) {
70876
71372
  if (index.childPositionById != null) index.childPositionById.set(childId, index.childIds.length);
@@ -71833,40 +72329,40 @@ function resolveInitialExpansion(initialExpansion) {
71833
72329
  if (!Number.isInteger(initialExpansion) || initialExpansion < 0) throw new Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(initialExpansion)}`);
71834
72330
  return initialExpansion;
71835
72331
  }
71836
- function isDirectoryExpandedByDefault(state2, node) {
72332
+ function isDirectoryExpandedByDefault(state3, node) {
71837
72333
  if (hasNodeFlag(node, 2)) return true;
71838
- if (state2.defaultExpansion === "open") return true;
71839
- if (state2.defaultExpansion === "closed") return false;
71840
- return getNodeDepth(node) <= state2.defaultExpansion;
72334
+ if (state3.defaultExpansion === "open") return true;
72335
+ if (state3.defaultExpansion === "closed") return false;
72336
+ return getNodeDepth(node) <= state3.defaultExpansion;
71841
72337
  }
71842
- function isDirectoryExpanded(state2, nodeId, node = state2.snapshot.nodes[nodeId]) {
72338
+ function isDirectoryExpanded(state3, nodeId, node = state3.snapshot.nodes[nodeId]) {
71843
72339
  if (node == null || !isDirectoryNode(node)) return false;
71844
- if (state2.directoriesOpenByDefault && !state2.hasCollapsedDirectoryOverrides) return true;
71845
- if (state2.collapsedDirectoryIds.has(nodeId)) return false;
71846
- if (state2.expandedDirectoryIds.has(nodeId)) return true;
71847
- return isDirectoryExpandedByDefault(state2, node);
72340
+ if (state3.directoriesOpenByDefault && !state3.hasCollapsedDirectoryOverrides) return true;
72341
+ if (state3.collapsedDirectoryIds.has(nodeId)) return false;
72342
+ if (state3.expandedDirectoryIds.has(nodeId)) return true;
72343
+ return isDirectoryExpandedByDefault(state3, node);
71848
72344
  }
71849
- function setDirectoryExpanded(state2, nodeId, expanded, node = state2.snapshot.nodes[nodeId]) {
72345
+ function setDirectoryExpanded(state3, nodeId, expanded, node = state3.snapshot.nodes[nodeId]) {
71850
72346
  if (node == null || !isDirectoryNode(node)) return;
71851
- const expandedByDefault = isDirectoryExpandedByDefault(state2, node);
72347
+ const expandedByDefault = isDirectoryExpandedByDefault(state3, node);
71852
72348
  if (expanded) {
71853
72349
  if (expandedByDefault) {
71854
- state2.collapsedDirectoryIds.delete(nodeId);
71855
- state2.hasCollapsedDirectoryOverrides = state2.collapsedDirectoryIds.size > 0;
72350
+ state3.collapsedDirectoryIds.delete(nodeId);
72351
+ state3.hasCollapsedDirectoryOverrides = state3.collapsedDirectoryIds.size > 0;
71856
72352
  return;
71857
72353
  }
71858
- state2.expandedDirectoryIds.add(nodeId);
72354
+ state3.expandedDirectoryIds.add(nodeId);
71859
72355
  return;
71860
72356
  }
71861
72357
  if (expandedByDefault) {
71862
- state2.collapsedDirectoryIds.add(nodeId);
71863
- state2.hasCollapsedDirectoryOverrides = true;
72358
+ state3.collapsedDirectoryIds.add(nodeId);
72359
+ state3.hasCollapsedDirectoryOverrides = true;
71864
72360
  return;
71865
72361
  }
71866
- state2.expandedDirectoryIds.delete(nodeId);
72362
+ state3.expandedDirectoryIds.delete(nodeId);
71867
72363
  }
71868
- function getOrCreateDirectoryLoadInfo(state2, nodeId) {
71869
- const existingInfo = state2.directoryLoadInfoById.get(nodeId);
72364
+ function getOrCreateDirectoryLoadInfo(state3, nodeId) {
72365
+ const existingInfo = state3.directoryLoadInfoById.get(nodeId);
71870
72366
  if (existingInfo != null) return existingInfo;
71871
72367
  const nextInfo = {
71872
72368
  activeAttemptId: null,
@@ -71874,14 +72370,14 @@ function getOrCreateDirectoryLoadInfo(state2, nodeId) {
71874
72370
  nextAttemptId: 1,
71875
72371
  state: "loaded"
71876
72372
  };
71877
- state2.directoryLoadInfoById.set(nodeId, nextInfo);
72373
+ state3.directoryLoadInfoById.set(nodeId, nextInfo);
71878
72374
  return nextInfo;
71879
72375
  }
71880
- function getDirectoryLoadState(state2, nodeId) {
71881
- return state2.directoryLoadInfoById.get(nodeId)?.state ?? "loaded";
72376
+ function getDirectoryLoadState(state3, nodeId) {
72377
+ return state3.directoryLoadInfoById.get(nodeId)?.state ?? "loaded";
71882
72378
  }
71883
- function beginDirectoryLoad(state2, nodeId) {
71884
- const loadInfo = getOrCreateDirectoryLoadInfo(state2, nodeId);
72379
+ function beginDirectoryLoad(state3, nodeId) {
72380
+ const loadInfo = getOrCreateDirectoryLoadInfo(state3, nodeId);
71885
72381
  if (loadInfo.state === "loading" && loadInfo.activeAttemptId != null) return {
71886
72382
  attemptId: loadInfo.activeAttemptId,
71887
72383
  nodeId,
@@ -71898,46 +72394,46 @@ function beginDirectoryLoad(state2, nodeId) {
71898
72394
  reused: false
71899
72395
  };
71900
72396
  }
71901
- function markDirectoryUnloadedState(state2, nodeId) {
71902
- const loadInfo = getOrCreateDirectoryLoadInfo(state2, nodeId);
72397
+ function markDirectoryUnloadedState(state3, nodeId) {
72398
+ const loadInfo = getOrCreateDirectoryLoadInfo(state3, nodeId);
71903
72399
  loadInfo.activeAttemptId = null;
71904
72400
  loadInfo.errorMessage = null;
71905
72401
  loadInfo.state = "unloaded";
71906
72402
  }
71907
- function completeDirectoryLoad(state2, nodeId, attemptId) {
71908
- const loadInfo = state2.directoryLoadInfoById.get(nodeId);
72403
+ function completeDirectoryLoad(state3, nodeId, attemptId) {
72404
+ const loadInfo = state3.directoryLoadInfoById.get(nodeId);
71909
72405
  if (loadInfo == null || loadInfo.activeAttemptId !== attemptId) return false;
71910
72406
  loadInfo.activeAttemptId = null;
71911
72407
  loadInfo.errorMessage = null;
71912
72408
  loadInfo.state = "loaded";
71913
72409
  return true;
71914
72410
  }
71915
- function isDirectoryLoadAttemptCurrent(state2, nodeId, attemptId) {
71916
- return state2.directoryLoadInfoById.get(nodeId)?.activeAttemptId === attemptId;
72411
+ function isDirectoryLoadAttemptCurrent(state3, nodeId, attemptId) {
72412
+ return state3.directoryLoadInfoById.get(nodeId)?.activeAttemptId === attemptId;
71917
72413
  }
71918
- function failDirectoryLoad(state2, nodeId, attemptId, errorMessage) {
71919
- const loadInfo = state2.directoryLoadInfoById.get(nodeId);
72414
+ function failDirectoryLoad(state3, nodeId, attemptId, errorMessage) {
72415
+ const loadInfo = state3.directoryLoadInfoById.get(nodeId);
71920
72416
  if (loadInfo == null || loadInfo.activeAttemptId !== attemptId) return false;
71921
72417
  loadInfo.activeAttemptId = null;
71922
72418
  loadInfo.errorMessage = errorMessage ?? null;
71923
72419
  loadInfo.state = "error";
71924
72420
  return true;
71925
72421
  }
71926
- function clearDirectoryLoadInfo(state2, nodeId) {
71927
- state2.directoryLoadInfoById.delete(nodeId);
72422
+ function clearDirectoryLoadInfo(state3, nodeId) {
72423
+ state3.directoryLoadInfoById.delete(nodeId);
71928
72424
  }
71929
72425
 
71930
72426
  // node_modules/@pierre/trees/dist/path-store/src/events.js
71931
- function subscribe(state2, type, handler) {
72427
+ function subscribe(state3, type, handler) {
71932
72428
  const rawHandler = handler;
71933
- const existingListeners = state2.listeners.get(type);
72429
+ const existingListeners = state3.listeners.get(type);
71934
72430
  if (existingListeners != null) existingListeners.add(rawHandler);
71935
- else state2.listeners.set(type, /* @__PURE__ */ new Set([rawHandler]));
72431
+ else state3.listeners.set(type, /* @__PURE__ */ new Set([rawHandler]));
71936
72432
  return () => {
71937
- const listeners = state2.listeners.get(type);
72433
+ const listeners = state3.listeners.get(type);
71938
72434
  if (listeners == null) return;
71939
72435
  listeners.delete(rawHandler);
71940
- if (listeners.size === 0) state2.listeners.delete(type);
72436
+ if (listeners.size === 0) state3.listeners.delete(type);
71941
72437
  };
71942
72438
  }
71943
72439
  function createAddEvent(args2) {
@@ -72087,58 +72583,58 @@ function createCleanupEvent(args2) {
72087
72583
  visibleCountDelta: null
72088
72584
  };
72089
72585
  }
72090
- function finalizeEvent(state2, previousVisibleCount, event2) {
72586
+ function finalizeEvent(state3, previousVisibleCount, event2) {
72091
72587
  return {
72092
72588
  ...event2,
72093
- visibleCountDelta: getCurrentVisibleCount(state2) - previousVisibleCount
72589
+ visibleCountDelta: getCurrentVisibleCount(state3) - previousVisibleCount
72094
72590
  };
72095
72591
  }
72096
- function batchEvents(state2, run2) {
72097
- const previousVisibleCount = getCurrentVisibleCount(state2);
72592
+ function batchEvents(state3, run2) {
72593
+ const previousVisibleCount = getCurrentVisibleCount(state3);
72098
72594
  const frame = createTransactionFrame();
72099
- state2.transactionStack.push(frame);
72595
+ state3.transactionStack.push(frame);
72100
72596
  try {
72101
72597
  run2();
72102
72598
  } catch (error) {
72103
- finishTransaction(state2, frame, false);
72599
+ finishTransaction(state3, frame, false);
72104
72600
  throw error;
72105
72601
  }
72106
- finishTransaction(state2, frame, true, getCurrentVisibleCount(state2) - previousVisibleCount);
72602
+ finishTransaction(state3, frame, true, getCurrentVisibleCount(state3) - previousVisibleCount);
72107
72603
  }
72108
- function recordEvent(state2, event2) {
72109
- const instrumentation = state2.instrumentation;
72604
+ function recordEvent(state3, event2) {
72605
+ const instrumentation = state3.instrumentation;
72110
72606
  if (instrumentation == null) {
72111
- recordEventNow(state2, event2);
72607
+ recordEventNow(state3, event2);
72112
72608
  return;
72113
72609
  }
72114
- withBenchmarkPhase(instrumentation, "store.events.record", () => recordEventNow(state2, event2));
72610
+ withBenchmarkPhase(instrumentation, "store.events.record", () => recordEventNow(state3, event2));
72115
72611
  }
72116
- function recordEventNow(state2, event2) {
72117
- const currentFrame = state2.transactionStack[state2.transactionStack.length - 1] ?? null;
72612
+ function recordEventNow(state3, event2) {
72613
+ const currentFrame = state3.transactionStack[state3.transactionStack.length - 1] ?? null;
72118
72614
  if (currentFrame == null) {
72119
- emitEvent(state2, event2);
72615
+ emitEvent(state3, event2);
72120
72616
  return;
72121
72617
  }
72122
72618
  currentFrame.events.push(event2);
72123
72619
  mergeEventMetadataIntoFrame(currentFrame, event2);
72124
72620
  }
72125
- function finishTransaction(state2, frame, emit, visibleCountDelta = null) {
72126
- if (state2.transactionStack.pop() !== frame) throw new Error("Transaction stack underflow");
72621
+ function finishTransaction(state3, frame, emit, visibleCountDelta = null) {
72622
+ if (state3.transactionStack.pop() !== frame) throw new Error("Transaction stack underflow");
72127
72623
  if (!emit) return;
72128
- const parentFrame = state2.transactionStack[state2.transactionStack.length - 1] ?? null;
72624
+ const parentFrame = state3.transactionStack[state3.transactionStack.length - 1] ?? null;
72129
72625
  if (parentFrame != null) {
72130
- const instrumentation2 = state2.instrumentation;
72626
+ const instrumentation2 = state3.instrumentation;
72131
72627
  if (instrumentation2 == null) mergeBatchFrameIntoParent(parentFrame, frame);
72132
72628
  else withBenchmarkPhase(instrumentation2, "store.events.batch.merge", () => mergeBatchFrameIntoParent(parentFrame, frame));
72133
72629
  return;
72134
72630
  }
72135
72631
  const batchEvent = createBatchEvent(frame, visibleCountDelta);
72136
- const instrumentation = state2.instrumentation;
72632
+ const instrumentation = state3.instrumentation;
72137
72633
  if (instrumentation == null) {
72138
- emitEvent(state2, batchEvent);
72634
+ emitEvent(state3, batchEvent);
72139
72635
  return;
72140
72636
  }
72141
- withBenchmarkPhase(instrumentation, "store.events.batch.commit", () => emitEvent(state2, batchEvent));
72637
+ withBenchmarkPhase(instrumentation, "store.events.batch.commit", () => emitEvent(state3, batchEvent));
72142
72638
  }
72143
72639
  function createBatchEvent(frame, visibleCountDelta) {
72144
72640
  return {
@@ -72163,48 +72659,48 @@ function mergeEventMetadataIntoFrame(frame, event2) {
72163
72659
  for (const nodeId of event2.affectedNodeIds) frame.affectedNodeIds.add(nodeId);
72164
72660
  for (const nodeId of event2.affectedAncestorIds) frame.affectedAncestorIds.add(nodeId);
72165
72661
  }
72166
- function emitEvent(state2, event2) {
72167
- const instrumentation = state2.instrumentation;
72662
+ function emitEvent(state3, event2) {
72663
+ const instrumentation = state3.instrumentation;
72168
72664
  if (instrumentation == null) {
72169
- emitEventNow(state2, event2);
72665
+ emitEventNow(state3, event2);
72170
72666
  return;
72171
72667
  }
72172
- withBenchmarkPhase(instrumentation, "store.events.emit", () => emitEventNow(state2, event2));
72668
+ withBenchmarkPhase(instrumentation, "store.events.emit", () => emitEventNow(state3, event2));
72173
72669
  }
72174
- function emitEventNow(state2, event2) {
72175
- state2.listeners.get(event2.operation)?.forEach((handler) => handler(event2));
72176
- state2.listeners.get("*")?.forEach((handler) => handler(event2));
72670
+ function emitEventNow(state3, event2) {
72671
+ state3.listeners.get(event2.operation)?.forEach((handler) => handler(event2));
72672
+ state3.listeners.get("*")?.forEach((handler) => handler(event2));
72177
72673
  }
72178
- function getCurrentVisibleCount(state2) {
72179
- return state2.snapshot.nodes[state2.snapshot.rootId]?.visibleSubtreeCount ?? 0;
72674
+ function getCurrentVisibleCount(state3) {
72675
+ return state3.snapshot.nodes[state3.snapshot.rootId]?.visibleSubtreeCount ?? 0;
72180
72676
  }
72181
72677
 
72182
72678
  // node_modules/@pierre/trees/dist/path-store/src/flatten.js
72183
- function getFlattenedChildDirectoryId(state2, directoryNodeId) {
72184
- if (state2.snapshot.options.flattenEmptyDirectories !== true) return null;
72185
- const directoryNode = state2.snapshot.nodes[directoryNodeId];
72679
+ function getFlattenedChildDirectoryId(state3, directoryNodeId) {
72680
+ if (state3.snapshot.options.flattenEmptyDirectories !== true) return null;
72681
+ const directoryNode = state3.snapshot.nodes[directoryNodeId];
72186
72682
  if (directoryNode == null || !isDirectoryNode(directoryNode) || hasNodeFlag(directoryNode, 2)) return null;
72187
- const directoryIndex = state2.snapshot.directories.get(directoryNodeId);
72683
+ const directoryIndex = state3.snapshot.directories.get(directoryNodeId);
72188
72684
  if (directoryIndex == null || directoryIndex.childIds.length !== 1) return null;
72189
72685
  const childId = directoryIndex.childIds[0];
72190
72686
  if (childId == null) return null;
72191
- const childNode = state2.snapshot.nodes[childId];
72687
+ const childNode = state3.snapshot.nodes[childId];
72192
72688
  if (childNode == null || !isDirectoryNode(childNode)) return null;
72193
72689
  return childId;
72194
72690
  }
72195
- function getFlattenedTerminalDirectoryId(state2, directoryNodeId) {
72691
+ function getFlattenedTerminalDirectoryId(state3, directoryNodeId) {
72196
72692
  let currentDirectoryId = directoryNodeId;
72197
72693
  while (true) {
72198
- const nextDirectoryId = getFlattenedChildDirectoryId(state2, currentDirectoryId);
72694
+ const nextDirectoryId = getFlattenedChildDirectoryId(state3, currentDirectoryId);
72199
72695
  if (nextDirectoryId == null) return currentDirectoryId;
72200
72696
  currentDirectoryId = nextDirectoryId;
72201
72697
  }
72202
72698
  }
72203
- function collectFlattenedDirectoryChainIds(state2, directoryNodeId) {
72699
+ function collectFlattenedDirectoryChainIds(state3, directoryNodeId) {
72204
72700
  const chainIds = [directoryNodeId];
72205
72701
  let currentDirectoryId = directoryNodeId;
72206
72702
  while (true) {
72207
- const nextDirectoryId = getFlattenedChildDirectoryId(state2, currentDirectoryId);
72703
+ const nextDirectoryId = getFlattenedChildDirectoryId(state3, currentDirectoryId);
72208
72704
  if (nextDirectoryId == null) return chainIds;
72209
72705
  chainIds.push(nextDirectoryId);
72210
72706
  currentDirectoryId = nextDirectoryId;
@@ -72212,144 +72708,144 @@ function collectFlattenedDirectoryChainIds(state2, directoryNodeId) {
72212
72708
  }
72213
72709
 
72214
72710
  // node_modules/@pierre/trees/dist/path-store/src/canonical.js
72215
- function listPaths(state2, path) {
72216
- const nodeId = path == null ? state2.snapshot.rootId : findNodeId(state2, path);
72711
+ function listPaths(state3, path) {
72712
+ const nodeId = path == null ? state3.snapshot.rootId : findNodeId(state3, path);
72217
72713
  if (nodeId == null) return [];
72218
- return collectCanonicalEntries(state2, nodeId);
72714
+ return collectCanonicalEntries(state3, nodeId);
72219
72715
  }
72220
- function addPath(state2, path) {
72716
+ function addPath(state3, path) {
72221
72717
  const preparedPath = parseInputPath(path);
72222
72718
  const parentSegments = preparedPath.isDirectory ? preparedPath.segments : preparedPath.segments.slice(0, -1);
72223
- const previousProjectionSignature = getCollapsedProjectionSignature(state2, findDeepestExistingDirectoryId(state2, parentSegments));
72224
- const { createdNodeIds, directoryId } = ensureDirectoryChain(state2, parentSegments);
72719
+ const previousProjectionSignature = getCollapsedProjectionSignature(state3, findDeepestExistingDirectoryId(state3, parentSegments));
72720
+ const { createdNodeIds, directoryId } = ensureDirectoryChain(state3, parentSegments);
72225
72721
  const affectedNodeIds = new Set(createdNodeIds);
72226
72722
  let addedNodeId = directoryId;
72227
72723
  if (preparedPath.isDirectory) {
72228
- const directoryNode = requireNode(state2, directoryId);
72724
+ const directoryNode = requireNode(state3, directoryId);
72229
72725
  if (hasNodeFlag(directoryNode, 1)) throw new Error(`Path already exists: "${path}"`);
72230
72726
  addNodeFlag(directoryNode, 1);
72231
- state2.pathCacheByNodeId.set(directoryId, {
72727
+ state3.pathCacheByNodeId.set(directoryId, {
72232
72728
  path,
72233
- version: state2.pathCacheVersion
72729
+ version: state3.pathCacheVersion
72234
72730
  });
72235
72731
  affectedNodeIds.add(directoryId);
72236
72732
  } else {
72237
- addedNodeId = createFileNode(state2, directoryId, preparedPath.basename);
72733
+ addedNodeId = createFileNode(state3, directoryId, preparedPath.basename);
72238
72734
  affectedNodeIds.add(addedNodeId);
72239
72735
  }
72240
- recomputeCountsUpwardFrom(state2, directoryId);
72241
- const nextProjectionSignature = getCollapsedProjectionSignature(state2, directoryId);
72736
+ recomputeCountsUpwardFrom(state3, directoryId);
72737
+ const nextProjectionSignature = getCollapsedProjectionSignature(state3, directoryId);
72242
72738
  return createAddEvent({
72243
- affectedAncestorIds: collectAncestorIds(state2, addedNodeId),
72739
+ affectedAncestorIds: collectAncestorIds(state3, addedNodeId),
72244
72740
  affectedNodeIds: [...affectedNodeIds],
72245
72741
  path,
72246
72742
  projectionChanged: didProjectionChange(previousProjectionSignature, nextProjectionSignature)
72247
72743
  });
72248
72744
  }
72249
- function removePath(state2, path, options) {
72250
- const nodeId = findNodeId(state2, path);
72745
+ function removePath(state3, path, options) {
72746
+ const nodeId = findNodeId(state3, path);
72251
72747
  if (nodeId == null) throw new Error(`Path does not exist: "${path}"`);
72252
- const node = requireNode(state2, nodeId);
72748
+ const node = requireNode(state3, nodeId);
72253
72749
  if (hasNodeFlag(node, 2)) throw new Error("The root node cannot be removed");
72254
- if (isDirectoryNode(node) && getDirectoryIndex(state2, nodeId).childIds.length > 0 && options.recursive !== true) throw new Error(`Cannot remove a non-empty directory without recursive: "${path}"`);
72750
+ if (isDirectoryNode(node) && getDirectoryIndex(state3, nodeId).childIds.length > 0 && options.recursive !== true) throw new Error(`Cannot remove a non-empty directory without recursive: "${path}"`);
72255
72751
  const parentId = node.parentId;
72256
- const previousProjectionSignature = getCollapsedProjectionSignature(state2, parentId);
72257
- const removedNodeIds = removeSubtree(state2, nodeId);
72258
- removeChildReference(state2, parentId, nodeId, node.nameId);
72259
- promoteEmptyAncestorsToExplicit(state2, parentId);
72260
- recomputeCountsUpwardFrom(state2, parentId);
72261
- const nextProjectionSignature = getCollapsedProjectionSignature(state2, parentId);
72752
+ const previousProjectionSignature = getCollapsedProjectionSignature(state3, parentId);
72753
+ const removedNodeIds = removeSubtree(state3, nodeId);
72754
+ removeChildReference(state3, parentId, nodeId, node.nameId);
72755
+ promoteEmptyAncestorsToExplicit(state3, parentId);
72756
+ recomputeCountsUpwardFrom(state3, parentId);
72757
+ const nextProjectionSignature = getCollapsedProjectionSignature(state3, parentId);
72262
72758
  return createRemoveEvent({
72263
- affectedAncestorIds: collectAncestorIds(state2, parentId),
72759
+ affectedAncestorIds: collectAncestorIds(state3, parentId),
72264
72760
  affectedNodeIds: removedNodeIds,
72265
72761
  path,
72266
72762
  projectionChanged: didProjectionChange(previousProjectionSignature, nextProjectionSignature),
72267
72763
  recursive: options.recursive === true
72268
72764
  });
72269
72765
  }
72270
- function movePath(state2, fromPath, toPath, options) {
72271
- const sourceNodeId = findNodeId(state2, fromPath);
72766
+ function movePath(state3, fromPath, toPath, options) {
72767
+ const sourceNodeId = findNodeId(state3, fromPath);
72272
72768
  if (sourceNodeId == null) throw new Error(`Source path does not exist: "${fromPath}"`);
72273
- const sourceNode = requireNode(state2, sourceNodeId);
72769
+ const sourceNode = requireNode(state3, sourceNodeId);
72274
72770
  if (hasNodeFlag(sourceNode, 2)) throw new Error("The root node cannot be moved");
72275
72771
  const collision = options.collision ?? "error";
72276
- const moveTarget = resolveMoveTarget(state2, sourceNodeId, toPath);
72277
- const previousSourceProjectionSignature = getCollapsedProjectionSignature(state2, sourceNode.parentId);
72278
- const previousTargetProjectionSignature = getCollapsedProjectionSignature(state2, moveTarget.parentId);
72279
- const sourceName = getSegmentValue(state2.snapshot.segmentTable, sourceNode.nameId);
72280
- const targetNameId = internSegment(state2.snapshot.segmentTable, moveTarget.basename);
72772
+ const moveTarget = resolveMoveTarget(state3, sourceNodeId, toPath);
72773
+ const previousSourceProjectionSignature = getCollapsedProjectionSignature(state3, sourceNode.parentId);
72774
+ const previousTargetProjectionSignature = getCollapsedProjectionSignature(state3, moveTarget.parentId);
72775
+ const sourceName = getSegmentValue(state3.snapshot.segmentTable, sourceNode.nameId);
72776
+ const targetNameId = internSegment(state3.snapshot.segmentTable, moveTarget.basename);
72281
72777
  if (moveTarget.parentId === sourceNode.parentId && sourceName === moveTarget.basename) return null;
72282
- if (isDirectoryNode(sourceNode) && isAncestor2(state2, sourceNodeId, moveTarget.parentId)) throw new Error("Cannot move a directory into one of its descendants");
72283
- const siblingCollisionId = ensureChildIdByNameId(state2.snapshot.nodes, getDirectoryIndex(state2, moveTarget.parentId)).get(targetNameId);
72778
+ if (isDirectoryNode(sourceNode) && isAncestor2(state3, sourceNodeId, moveTarget.parentId)) throw new Error("Cannot move a directory into one of its descendants");
72779
+ const siblingCollisionId = ensureChildIdByNameId(state3.snapshot.nodes, getDirectoryIndex(state3, moveTarget.parentId)).get(targetNameId);
72284
72780
  const collisionNodeId = moveTarget.existingNodeId ?? siblingCollisionId ?? null;
72285
72781
  if (collisionNodeId != null && collisionNodeId !== sourceNodeId) {
72286
- if (handleMoveCollision(state2, collisionNodeId, collision, getNodeKind(sourceNode)) === "skip") return null;
72782
+ if (handleMoveCollision(state3, collisionNodeId, collision, getNodeKind(sourceNode)) === "skip") return null;
72287
72783
  }
72288
72784
  const previousParentId = sourceNode.parentId;
72289
- removeChildReference(state2, previousParentId, sourceNodeId, sourceNode.nameId);
72785
+ removeChildReference(state3, previousParentId, sourceNodeId, sourceNode.nameId);
72290
72786
  sourceNode.parentId = moveTarget.parentId;
72291
72787
  sourceNode.nameId = targetNameId;
72292
- state2.pathCacheByNodeId.delete(sourceNodeId);
72293
- recomputeDepths(state2, sourceNodeId);
72294
- insertChildReference(state2, moveTarget.parentId, sourceNodeId);
72295
- promoteEmptyAncestorsToExplicit(state2, previousParentId);
72296
- state2.pathCacheVersion++;
72297
- recomputeCountsUpwardFrom(state2, previousParentId);
72298
- if (moveTarget.parentId !== previousParentId) recomputeCountsUpwardFrom(state2, moveTarget.parentId);
72299
- const nextSourceProjectionSignature = getCollapsedProjectionSignature(state2, previousParentId);
72300
- const nextTargetProjectionSignature = getCollapsedProjectionSignature(state2, moveTarget.parentId);
72788
+ state3.pathCacheByNodeId.delete(sourceNodeId);
72789
+ recomputeDepths(state3, sourceNodeId);
72790
+ insertChildReference(state3, moveTarget.parentId, sourceNodeId);
72791
+ promoteEmptyAncestorsToExplicit(state3, previousParentId);
72792
+ state3.pathCacheVersion++;
72793
+ recomputeCountsUpwardFrom(state3, previousParentId);
72794
+ if (moveTarget.parentId !== previousParentId) recomputeCountsUpwardFrom(state3, moveTarget.parentId);
72795
+ const nextSourceProjectionSignature = getCollapsedProjectionSignature(state3, previousParentId);
72796
+ const nextTargetProjectionSignature = getCollapsedProjectionSignature(state3, moveTarget.parentId);
72301
72797
  return createMoveEvent({
72302
- affectedAncestorIds: [.../* @__PURE__ */ new Set([...collectAncestorIds(state2, previousParentId), ...collectAncestorIds(state2, moveTarget.parentId)])],
72798
+ affectedAncestorIds: [.../* @__PURE__ */ new Set([...collectAncestorIds(state3, previousParentId), ...collectAncestorIds(state3, moveTarget.parentId)])],
72303
72799
  affectedNodeIds: [sourceNodeId],
72304
72800
  from: fromPath,
72305
72801
  projectionChanged: didAnyProjectionChange([previousSourceProjectionSignature, previousTargetProjectionSignature], [nextSourceProjectionSignature, nextTargetProjectionSignature]),
72306
- to: materializeNodePath(state2, sourceNodeId)
72802
+ to: materializeNodePath(state3, sourceNodeId)
72307
72803
  });
72308
72804
  }
72309
- function getCachedNodePath(state2, nodeId) {
72310
- const cachedEntry = state2.pathCacheByNodeId.get(nodeId);
72311
- return cachedEntry != null && cachedEntry.version === state2.pathCacheVersion ? cachedEntry.path : null;
72805
+ function getCachedNodePath(state3, nodeId) {
72806
+ const cachedEntry = state3.pathCacheByNodeId.get(nodeId);
72807
+ return cachedEntry != null && cachedEntry.version === state3.pathCacheVersion ? cachedEntry.path : null;
72312
72808
  }
72313
- function setCachedNodePath(state2, nodeId, path) {
72314
- state2.pathCacheByNodeId.set(nodeId, {
72809
+ function setCachedNodePath(state3, nodeId, path) {
72810
+ state3.pathCacheByNodeId.set(nodeId, {
72315
72811
  path,
72316
- version: state2.pathCacheVersion
72812
+ version: state3.pathCacheVersion
72317
72813
  });
72318
72814
  return path;
72319
72815
  }
72320
- function materializeNodePath(state2, nodeId) {
72321
- const node = requireNode(state2, nodeId);
72322
- const cachedPath = getCachedNodePath(state2, nodeId);
72816
+ function materializeNodePath(state3, nodeId) {
72817
+ const node = requireNode(state3, nodeId);
72818
+ const cachedPath = getCachedNodePath(state3, nodeId);
72323
72819
  if (cachedPath != null) return cachedPath;
72324
- if (hasNodeFlag(node, 2)) return setCachedNodePath(state2, nodeId, "");
72325
- const parentPath = materializeNodePath(state2, node.parentId);
72326
- const nodeName = getSegmentValue(state2.snapshot.segmentTable, node.nameId);
72820
+ if (hasNodeFlag(node, 2)) return setCachedNodePath(state3, nodeId, "");
72821
+ const parentPath = materializeNodePath(state3, node.parentId);
72822
+ const nodeName = getSegmentValue(state3.snapshot.segmentTable, node.nameId);
72327
72823
  const path = parentPath.length === 0 ? nodeName : `${parentPath}${nodeName}`;
72328
- return setCachedNodePath(state2, nodeId, isDirectoryNode(node) ? `${path}/` : path);
72824
+ return setCachedNodePath(state3, nodeId, isDirectoryNode(node) ? `${path}/` : path);
72329
72825
  }
72330
- function recomputeCountsUpwardFrom(state2, startNodeId) {
72331
- const instrumentation = state2.instrumentation;
72826
+ function recomputeCountsUpwardFrom(state3, startNodeId) {
72827
+ const instrumentation = state3.instrumentation;
72332
72828
  if (instrumentation == null) {
72333
- recomputeCountsUpwardFromNow(state2, startNodeId);
72829
+ recomputeCountsUpwardFromNow(state3, startNodeId);
72334
72830
  return;
72335
72831
  }
72336
- withBenchmarkPhase(instrumentation, "store.recomputeCountsUpwardFrom", () => recomputeCountsUpwardFromNow(state2, startNodeId));
72832
+ withBenchmarkPhase(instrumentation, "store.recomputeCountsUpwardFrom", () => recomputeCountsUpwardFromNow(state3, startNodeId));
72337
72833
  }
72338
- function recomputeCountsRecursive(state2, nodeId) {
72834
+ function recomputeCountsRecursive(state3, nodeId) {
72339
72835
  const stack = [[nodeId, 0]];
72340
- const { nodes, directories } = state2.snapshot;
72836
+ const { nodes, directories } = state3.snapshot;
72341
72837
  while (stack.length > 0) {
72342
72838
  const frame = stack[stack.length - 1];
72343
72839
  const nid = frame[0];
72344
72840
  const node = nodes[nid];
72345
72841
  if (node == null || !isDirectoryNode(node)) {
72346
- recomputeNodeCounts(state2, nid, node, true);
72842
+ recomputeNodeCounts(state3, nid, node, true);
72347
72843
  stack.pop();
72348
72844
  continue;
72349
72845
  }
72350
72846
  const dirIndex = directories.get(nid);
72351
72847
  if (dirIndex == null || frame[1] >= dirIndex.childIds.length) {
72352
- recomputeNodeCounts(state2, nid, node, true);
72848
+ recomputeNodeCounts(state3, nid, node, true);
72353
72849
  stack.pop();
72354
72850
  continue;
72355
72851
  }
@@ -72357,51 +72853,51 @@ function recomputeCountsRecursive(state2, nodeId) {
72357
72853
  stack.push([childId, 0]);
72358
72854
  }
72359
72855
  }
72360
- function collectAncestorIds(state2, nodeId) {
72856
+ function collectAncestorIds(state3, nodeId) {
72361
72857
  const ancestorIds = [];
72362
72858
  let currentNodeId = nodeId;
72363
72859
  while (currentNodeId != null) {
72364
- const currentNode = requireNode(state2, currentNodeId);
72860
+ const currentNode = requireNode(state3, currentNodeId);
72365
72861
  ancestorIds.push(currentNodeId);
72366
- if (currentNodeId === state2.snapshot.rootId) break;
72862
+ if (currentNodeId === state3.snapshot.rootId) break;
72367
72863
  currentNodeId = currentNode.parentId;
72368
72864
  }
72369
72865
  return ancestorIds;
72370
72866
  }
72371
- function findNodeId(state2, path) {
72372
- if (path.length === 0) return state2.snapshot.rootId;
72867
+ function findNodeId(state3, path) {
72868
+ if (path.length === 0) return state3.snapshot.rootId;
72373
72869
  const lookupPath = parseLookupPath(path);
72374
- return findNodeIdBySegments(state2, lookupPath.segments, lookupPath.requiresDirectory);
72870
+ return findNodeIdBySegments(state3, lookupPath.segments, lookupPath.requiresDirectory);
72375
72871
  }
72376
- function findNodeIdBySegments(state2, segments, requireDirectory) {
72377
- let currentNodeId = state2.snapshot.rootId;
72872
+ function findNodeIdBySegments(state3, segments, requireDirectory) {
72873
+ let currentNodeId = state3.snapshot.rootId;
72378
72874
  for (const segment2 of segments) {
72379
- const segmentId = state2.snapshot.segmentTable.idByValue.get(segment2);
72875
+ const segmentId = state3.snapshot.segmentTable.idByValue.get(segment2);
72380
72876
  if (segmentId === void 0) return null;
72381
- const currentIndex = getDirectoryIndex(state2, currentNodeId);
72382
- const nextNodeId = ensureChildIdByNameId(state2.snapshot.nodes, currentIndex).get(segmentId);
72877
+ const currentIndex = getDirectoryIndex(state3, currentNodeId);
72878
+ const nextNodeId = ensureChildIdByNameId(state3.snapshot.nodes, currentIndex).get(segmentId);
72383
72879
  if (nextNodeId === void 0) return null;
72384
72880
  currentNodeId = nextNodeId;
72385
72881
  }
72386
- const currentNode = requireNode(state2, currentNodeId);
72882
+ const currentNode = requireNode(state3, currentNodeId);
72387
72883
  if (requireDirectory && !isDirectoryNode(currentNode)) return null;
72388
72884
  return currentNodeId;
72389
72885
  }
72390
- function getDirectoryIndex(state2, directoryId) {
72391
- const directoryIndex = state2.snapshot.directories.get(directoryId);
72886
+ function getDirectoryIndex(state3, directoryId) {
72887
+ const directoryIndex = state3.snapshot.directories.get(directoryId);
72392
72888
  if (directoryIndex === void 0) throw new Error(`Unknown directory child index for node ${String(directoryId)}`);
72393
72889
  return directoryIndex;
72394
72890
  }
72395
- function requireNode(state2, nodeId) {
72396
- const node = state2.snapshot.nodes[nodeId];
72891
+ function requireNode(state3, nodeId) {
72892
+ const node = state3.snapshot.nodes[nodeId];
72397
72893
  if (node === void 0 || hasNodeFlag(node, 4)) throw new Error(`Unknown node ID: ${String(nodeId)}`);
72398
72894
  return node;
72399
72895
  }
72400
- function collectCanonicalEntries(state2, nodeId) {
72401
- const rootNode = state2.snapshot.nodes[nodeId];
72896
+ function collectCanonicalEntries(state3, nodeId) {
72897
+ const rootNode = state3.snapshot.nodes[nodeId];
72402
72898
  if (rootNode === void 0 || hasNodeFlag(rootNode, 4)) return [];
72403
- if (!isDirectoryNode(rootNode)) return [materializeNodePath(state2, nodeId)];
72404
- if (getDirectoryIndex(state2, nodeId).childIds.length === 0) return hasNodeFlag(rootNode, 1) && !hasNodeFlag(rootNode, 2) ? [materializeNodePath(state2, nodeId)] : [];
72899
+ if (!isDirectoryNode(rootNode)) return [materializeNodePath(state3, nodeId)];
72900
+ if (getDirectoryIndex(state3, nodeId).childIds.length === 0) return hasNodeFlag(rootNode, 1) && !hasNodeFlag(rootNode, 2) ? [materializeNodePath(state3, nodeId)] : [];
72405
72901
  const entries = [];
72406
72902
  const stack = [{
72407
72903
  childIndex: 0,
@@ -72410,19 +72906,19 @@ function collectCanonicalEntries(state2, nodeId) {
72410
72906
  while (stack.length > 0) {
72411
72907
  const frame = stack[stack.length - 1];
72412
72908
  if (frame == null) break;
72413
- const currentNode = state2.snapshot.nodes[frame.nodeId];
72909
+ const currentNode = state3.snapshot.nodes[frame.nodeId];
72414
72910
  if (currentNode === void 0 || hasNodeFlag(currentNode, 4)) {
72415
72911
  stack.pop();
72416
72912
  continue;
72417
72913
  }
72418
72914
  if (!isDirectoryNode(currentNode)) {
72419
- entries.push(materializeNodePath(state2, frame.nodeId));
72915
+ entries.push(materializeNodePath(state3, frame.nodeId));
72420
72916
  stack.pop();
72421
72917
  continue;
72422
72918
  }
72423
- const currentIndex = getDirectoryIndex(state2, frame.nodeId);
72919
+ const currentIndex = getDirectoryIndex(state3, frame.nodeId);
72424
72920
  if (currentIndex.childIds.length === 0) {
72425
- if (hasNodeFlag(currentNode, 1) && !hasNodeFlag(currentNode, 2)) entries.push(materializeNodePath(state2, frame.nodeId));
72921
+ if (hasNodeFlag(currentNode, 1) && !hasNodeFlag(currentNode, 2)) entries.push(materializeNodePath(state3, frame.nodeId));
72426
72922
  stack.pop();
72427
72923
  continue;
72428
72924
  }
@@ -72439,19 +72935,19 @@ function collectCanonicalEntries(state2, nodeId) {
72439
72935
  }
72440
72936
  return entries;
72441
72937
  }
72442
- function ensureDirectoryChain(state2, directorySegments) {
72938
+ function ensureDirectoryChain(state3, directorySegments) {
72443
72939
  const createdNodeIds = [];
72444
- let currentDirectoryId = state2.snapshot.rootId;
72940
+ let currentDirectoryId = state3.snapshot.rootId;
72445
72941
  for (const segment2 of directorySegments) {
72446
- const segmentId = internSegment(state2.snapshot.segmentTable, segment2);
72447
- const currentIndex = getDirectoryIndex(state2, currentDirectoryId);
72448
- const existingChildId = ensureChildIdByNameId(state2.snapshot.nodes, currentIndex).get(segmentId);
72942
+ const segmentId = internSegment(state3.snapshot.segmentTable, segment2);
72943
+ const currentIndex = getDirectoryIndex(state3, currentDirectoryId);
72944
+ const existingChildId = ensureChildIdByNameId(state3.snapshot.nodes, currentIndex).get(segmentId);
72449
72945
  if (existingChildId !== void 0) {
72450
- if (!isDirectoryNode(requireNode(state2, existingChildId))) throw new Error(`Cannot create a directory that collides with an existing file: "${segment2}"`);
72946
+ if (!isDirectoryNode(requireNode(state3, existingChildId))) throw new Error(`Cannot create a directory that collides with an existing file: "${segment2}"`);
72451
72947
  currentDirectoryId = existingChildId;
72452
72948
  continue;
72453
72949
  }
72454
- currentDirectoryId = createDirectoryNode(state2, currentDirectoryId, segmentId);
72950
+ currentDirectoryId = createDirectoryNode(state3, currentDirectoryId, segmentId);
72455
72951
  createdNodeIds.push(currentDirectoryId);
72456
72952
  }
72457
72953
  return {
@@ -72459,43 +72955,43 @@ function ensureDirectoryChain(state2, directorySegments) {
72459
72955
  directoryId: currentDirectoryId
72460
72956
  };
72461
72957
  }
72462
- function createDirectoryNode(state2, parentId, nameId) {
72463
- const parentNode = requireNode(state2, parentId);
72464
- const nodeId = state2.snapshot.nodes.length;
72465
- state2.snapshot.nodes.push({
72958
+ function createDirectoryNode(state3, parentId, nameId) {
72959
+ const parentNode = requireNode(state3, parentId);
72960
+ const nodeId = state3.snapshot.nodes.length;
72961
+ state3.snapshot.nodes.push({
72466
72962
  depthAndFlags: createNodeDepthAndFlags(getNodeDepth(parentNode) + 1, 0, 1),
72467
72963
  nameId,
72468
72964
  parentId,
72469
72965
  subtreeNodeCount: 1,
72470
72966
  visibleSubtreeCount: 1
72471
72967
  });
72472
- state2.snapshot.directories.set(nodeId, createDirectoryChildIndex());
72473
- insertChildReference(state2, parentId, nodeId);
72474
- if (state2.collapseNewDirectoriesByDefault) {
72475
- state2.collapsedDirectoryIds.add(nodeId);
72476
- state2.hasCollapsedDirectoryOverrides = true;
72968
+ state3.snapshot.directories.set(nodeId, createDirectoryChildIndex());
72969
+ insertChildReference(state3, parentId, nodeId);
72970
+ if (state3.collapseNewDirectoriesByDefault) {
72971
+ state3.collapsedDirectoryIds.add(nodeId);
72972
+ state3.hasCollapsedDirectoryOverrides = true;
72477
72973
  }
72478
- state2.activeNodeCount++;
72974
+ state3.activeNodeCount++;
72479
72975
  return nodeId;
72480
72976
  }
72481
- function createFileNode(state2, parentId, basename3) {
72482
- const nameId = internSegment(state2.snapshot.segmentTable, basename3);
72483
- const parentIndex = getDirectoryIndex(state2, parentId);
72484
- if (ensureChildIdByNameId(state2.snapshot.nodes, parentIndex).has(nameId)) throw new Error(`Path already exists: "${buildPathPreview(state2, parentId, basename3)}"`);
72485
- const parentNode = requireNode(state2, parentId);
72486
- const nodeId = state2.snapshot.nodes.length;
72487
- state2.snapshot.nodes.push({
72977
+ function createFileNode(state3, parentId, basename3) {
72978
+ const nameId = internSegment(state3.snapshot.segmentTable, basename3);
72979
+ const parentIndex = getDirectoryIndex(state3, parentId);
72980
+ if (ensureChildIdByNameId(state3.snapshot.nodes, parentIndex).has(nameId)) throw new Error(`Path already exists: "${buildPathPreview(state3, parentId, basename3)}"`);
72981
+ const parentNode = requireNode(state3, parentId);
72982
+ const nodeId = state3.snapshot.nodes.length;
72983
+ state3.snapshot.nodes.push({
72488
72984
  depthAndFlags: createNodeDepthAndFlags(getNodeDepth(parentNode) + 1, 0),
72489
72985
  nameId,
72490
72986
  parentId,
72491
72987
  subtreeNodeCount: 1,
72492
72988
  visibleSubtreeCount: 1
72493
72989
  });
72494
- insertChildReference(state2, parentId, nodeId);
72495
- state2.activeNodeCount++;
72990
+ insertChildReference(state3, parentId, nodeId);
72991
+ state3.activeNodeCount++;
72496
72992
  return nodeId;
72497
72993
  }
72498
- function findChildInsertIndex(state2, parentIndex, childId) {
72994
+ function findChildInsertIndex(state3, parentIndex, childId) {
72499
72995
  let low = 0;
72500
72996
  let high = parentIndex.childIds.length;
72501
72997
  while (low < high) {
@@ -72505,72 +73001,72 @@ function findChildInsertIndex(state2, parentIndex, childId) {
72505
73001
  high = middle;
72506
73002
  continue;
72507
73003
  }
72508
- if (compareSiblingNodes(state2, childId, existingChildId) < 0) high = middle;
73004
+ if (compareSiblingNodes(state3, childId, existingChildId) < 0) high = middle;
72509
73005
  else low = middle + 1;
72510
73006
  }
72511
73007
  return low;
72512
73008
  }
72513
- function insertChildReference(state2, parentId, childId) {
72514
- const parentIndex = getDirectoryIndex(state2, parentId);
72515
- const childNode = requireNode(state2, childId);
72516
- ensureChildIdByNameId(state2.snapshot.nodes, parentIndex).set(childNode.nameId, childId);
73009
+ function insertChildReference(state3, parentId, childId) {
73010
+ const parentIndex = getDirectoryIndex(state3, parentId);
73011
+ const childNode = requireNode(state3, childId);
73012
+ ensureChildIdByNameId(state3.snapshot.nodes, parentIndex).set(childNode.nameId, childId);
72517
73013
  applyChildAggregateDelta(parentIndex, childId, childNode.subtreeNodeCount, childNode.visibleSubtreeCount);
72518
- const insertIndex = findChildInsertIndex(state2, parentIndex, childId);
73014
+ const insertIndex = findChildInsertIndex(state3, parentIndex, childId);
72519
73015
  parentIndex.childIds.splice(insertIndex, 0, childId);
72520
73016
  updateChildPositionsFrom(parentIndex, insertIndex);
72521
- rebuildVisibleChildChunks(state2.snapshot.nodes, parentIndex);
72522
- }
72523
- function removeChildReference(state2, parentId, childId, childNameId) {
72524
- const parentIndex = getDirectoryIndex(state2, parentId);
72525
- const positions = ensureChildPositions(parentIndex);
72526
- const childIndex = positions.get(childId) ?? -1;
72527
- ensureChildIdByNameId(state2.snapshot.nodes, parentIndex).delete(childNameId);
72528
- positions.delete(childId);
72529
- const childNode = state2.snapshot.nodes[childId];
73017
+ rebuildVisibleChildChunks(state3.snapshot.nodes, parentIndex);
73018
+ }
73019
+ function removeChildReference(state3, parentId, childId, childNameId) {
73020
+ const parentIndex = getDirectoryIndex(state3, parentId);
73021
+ const positions2 = ensureChildPositions(parentIndex);
73022
+ const childIndex = positions2.get(childId) ?? -1;
73023
+ ensureChildIdByNameId(state3.snapshot.nodes, parentIndex).delete(childNameId);
73024
+ positions2.delete(childId);
73025
+ const childNode = state3.snapshot.nodes[childId];
72530
73026
  if (childNode != null) applyChildAggregateDelta(parentIndex, childId, -childNode.subtreeNodeCount, -childNode.visibleSubtreeCount);
72531
73027
  if (childIndex >= 0) {
72532
73028
  parentIndex.childIds.splice(childIndex, 1);
72533
73029
  updateChildPositionsFrom(parentIndex, childIndex);
72534
- rebuildVisibleChildChunks(state2.snapshot.nodes, parentIndex);
73030
+ rebuildVisibleChildChunks(state3.snapshot.nodes, parentIndex);
72535
73031
  }
72536
73032
  }
72537
- function compareSiblingNodes(state2, leftId, rightId) {
72538
- const sortOption = state2.snapshot.options.sort;
72539
- if (sortOption === "default") return compareSiblingNodesDefault(state2, leftId, rightId);
72540
- return sortOption(createCompareEntry2(state2, leftId), createCompareEntry2(state2, rightId));
73033
+ function compareSiblingNodes(state3, leftId, rightId) {
73034
+ const sortOption = state3.snapshot.options.sort;
73035
+ if (sortOption === "default") return compareSiblingNodesDefault(state3, leftId, rightId);
73036
+ return sortOption(createCompareEntry2(state3, leftId), createCompareEntry2(state3, rightId));
72541
73037
  }
72542
- function compareSiblingNodesDefault(state2, leftId, rightId) {
72543
- const leftNode = requireNode(state2, leftId);
72544
- const rightNode = requireNode(state2, rightId);
73038
+ function compareSiblingNodesDefault(state3, leftId, rightId) {
73039
+ const leftNode = requireNode(state3, leftId);
73040
+ const rightNode = requireNode(state3, rightId);
72545
73041
  const leftIsDirectory = isDirectoryNode(leftNode);
72546
73042
  if (leftIsDirectory !== isDirectoryNode(rightNode)) return leftIsDirectory ? -1 : 1;
72547
- const comparison = compareSegmentSortKeys(getSegmentSortKey(state2.snapshot.segmentTable, leftNode.nameId), getSegmentSortKey(state2.snapshot.segmentTable, rightNode.nameId));
73043
+ const comparison = compareSegmentSortKeys(getSegmentSortKey(state3.snapshot.segmentTable, leftNode.nameId), getSegmentSortKey(state3.snapshot.segmentTable, rightNode.nameId));
72548
73044
  if (comparison !== 0) return comparison;
72549
- const leftName = getSegmentValue(state2.snapshot.segmentTable, leftNode.nameId);
72550
- const rightName = getSegmentValue(state2.snapshot.segmentTable, rightNode.nameId);
73045
+ const leftName = getSegmentValue(state3.snapshot.segmentTable, leftNode.nameId);
73046
+ const rightName = getSegmentValue(state3.snapshot.segmentTable, rightNode.nameId);
72551
73047
  if (leftName !== rightName) return leftName < rightName ? -1 : 1;
72552
73048
  return leftId < rightId ? -1 : 1;
72553
73049
  }
72554
- function createCompareEntry2(state2, nodeId) {
72555
- const node = requireNode(state2, nodeId);
72556
- const path = materializeNodePath(state2, nodeId);
73050
+ function createCompareEntry2(state3, nodeId) {
73051
+ const node = requireNode(state3, nodeId);
73052
+ const path = materializeNodePath(state3, nodeId);
72557
73053
  const isDirectory = isDirectoryNode(node);
72558
73054
  const normalizedPath = isDirectory ? path.slice(0, -1) : path;
72559
73055
  return {
72560
- basename: getSegmentValue(state2.snapshot.segmentTable, node.nameId),
73056
+ basename: getSegmentValue(state3.snapshot.segmentTable, node.nameId),
72561
73057
  depth: getNodeDepth(node),
72562
73058
  isDirectory,
72563
73059
  path,
72564
73060
  segments: normalizedPath.length === 0 ? [] : normalizedPath.split("/")
72565
73061
  };
72566
73062
  }
72567
- function resolveMoveTarget(state2, sourceNodeId, toPath) {
72568
- const sourceNode = requireNode(state2, sourceNodeId);
72569
- const existingDestinationId = findNodeId(state2, toPath);
73063
+ function resolveMoveTarget(state3, sourceNodeId, toPath) {
73064
+ const sourceNode = requireNode(state3, sourceNodeId);
73065
+ const existingDestinationId = findNodeId(state3, toPath);
72570
73066
  if (existingDestinationId != null) {
72571
- const existingDestination = requireNode(state2, existingDestinationId);
73067
+ const existingDestination = requireNode(state3, existingDestinationId);
72572
73068
  if (isDirectoryNode(existingDestination)) return {
72573
- basename: getSegmentValue(state2.snapshot.segmentTable, sourceNode.nameId),
73069
+ basename: getSegmentValue(state3.snapshot.segmentTable, sourceNode.nameId),
72574
73070
  existingNodeId: null,
72575
73071
  parentId: existingDestinationId
72576
73072
  };
@@ -72584,7 +73080,7 @@ function resolveMoveTarget(state2, sourceNodeId, toPath) {
72584
73080
  const destinationLookup = parseLookupPath(toPath);
72585
73081
  const basename3 = destinationLookup.segments[destinationLookup.segments.length - 1] ?? "";
72586
73082
  const parentSegments = destinationLookup.segments.slice(0, -1);
72587
- const parentId = parentSegments.length === 0 ? state2.snapshot.rootId : findNodeIdBySegments(state2, parentSegments, true);
73083
+ const parentId = parentSegments.length === 0 ? state3.snapshot.rootId : findNodeIdBySegments(state3, parentSegments, true);
72588
73084
  if (parentId == null) throw new Error(`Destination parent does not exist: "${toPath}"`);
72589
73085
  return {
72590
73086
  basename: basename3,
@@ -72592,21 +73088,21 @@ function resolveMoveTarget(state2, sourceNodeId, toPath) {
72592
73088
  parentId
72593
73089
  };
72594
73090
  }
72595
- function handleMoveCollision(state2, collisionNodeId, strategy, sourceKind) {
73091
+ function handleMoveCollision(state3, collisionNodeId, strategy, sourceKind) {
72596
73092
  if (strategy === "skip") return "skip";
72597
- if (strategy === "error") throw new Error(`Destination already exists: "${materializeNodePath(state2, collisionNodeId)}"`);
72598
- const collisionNode = requireNode(state2, collisionNodeId);
73093
+ if (strategy === "error") throw new Error(`Destination already exists: "${materializeNodePath(state3, collisionNodeId)}"`);
73094
+ const collisionNode = requireNode(state3, collisionNodeId);
72599
73095
  if (getNodeKind(collisionNode) !== sourceKind) throw new Error("replace collision requires the same source and destination kinds");
72600
- if (isDirectoryNode(collisionNode) && getDirectoryIndex(state2, collisionNodeId).childIds.length > 0) throw new Error("replace collision does not support non-empty directories");
73096
+ if (isDirectoryNode(collisionNode) && getDirectoryIndex(state3, collisionNodeId).childIds.length > 0) throw new Error("replace collision does not support non-empty directories");
72601
73097
  const collisionParentId = collisionNode.parentId;
72602
73098
  const collisionNameId = collisionNode.nameId;
72603
- removeSubtree(state2, collisionNodeId);
72604
- removeChildReference(state2, collisionParentId, collisionNodeId, collisionNameId);
72605
- promoteEmptyAncestorsToExplicit(state2, collisionParentId);
72606
- recomputeCountsUpwardFrom(state2, collisionParentId);
73099
+ removeSubtree(state3, collisionNodeId);
73100
+ removeChildReference(state3, collisionParentId, collisionNodeId, collisionNameId);
73101
+ promoteEmptyAncestorsToExplicit(state3, collisionParentId);
73102
+ recomputeCountsUpwardFrom(state3, collisionParentId);
72607
73103
  return "handled";
72608
73104
  }
72609
- function removeSubtree(state2, nodeId) {
73105
+ function removeSubtree(state3, nodeId) {
72610
73106
  const removedNodeIds = [];
72611
73107
  const stack = [{
72612
73108
  nodeId,
@@ -72615,15 +73111,15 @@ function removeSubtree(state2, nodeId) {
72615
73111
  while (stack.length > 0) {
72616
73112
  const frame = stack.pop();
72617
73113
  if (frame == null) break;
72618
- const node = requireNode(state2, frame.nodeId);
73114
+ const node = requireNode(state3, frame.nodeId);
72619
73115
  if (frame.visitedChildren || !isDirectoryNode(node)) {
72620
- if (isDirectoryNode(node)) state2.snapshot.directories.delete(frame.nodeId);
73116
+ if (isDirectoryNode(node)) state3.snapshot.directories.delete(frame.nodeId);
72621
73117
  addNodeFlag(node, 4);
72622
- state2.pathCacheByNodeId.delete(frame.nodeId);
72623
- if (state2.collapsedDirectoryIds.delete(frame.nodeId)) state2.hasCollapsedDirectoryOverrides = state2.collapsedDirectoryIds.size > 0;
72624
- state2.expandedDirectoryIds.delete(frame.nodeId);
72625
- clearDirectoryLoadInfo(state2, frame.nodeId);
72626
- state2.activeNodeCount--;
73118
+ state3.pathCacheByNodeId.delete(frame.nodeId);
73119
+ if (state3.collapsedDirectoryIds.delete(frame.nodeId)) state3.hasCollapsedDirectoryOverrides = state3.collapsedDirectoryIds.size > 0;
73120
+ state3.expandedDirectoryIds.delete(frame.nodeId);
73121
+ clearDirectoryLoadInfo(state3, frame.nodeId);
73122
+ state3.activeNodeCount--;
72627
73123
  removedNodeIds.push(frame.nodeId);
72628
73124
  continue;
72629
73125
  }
@@ -72631,7 +73127,7 @@ function removeSubtree(state2, nodeId) {
72631
73127
  nodeId: frame.nodeId,
72632
73128
  visitedChildren: true
72633
73129
  });
72634
- const directoryIndex = getDirectoryIndex(state2, frame.nodeId);
73130
+ const directoryIndex = getDirectoryIndex(state3, frame.nodeId);
72635
73131
  for (let childIndex = directoryIndex.childIds.length - 1; childIndex >= 0; childIndex--) {
72636
73132
  const childId = directoryIndex.childIds[childIndex];
72637
73133
  if (childId != null) stack.push({
@@ -72642,38 +73138,38 @@ function removeSubtree(state2, nodeId) {
72642
73138
  }
72643
73139
  return removedNodeIds;
72644
73140
  }
72645
- function promoteEmptyAncestorsToExplicit(state2, startDirectoryId) {
73141
+ function promoteEmptyAncestorsToExplicit(state3, startDirectoryId) {
72646
73142
  let currentDirectoryId = startDirectoryId;
72647
73143
  while (currentDirectoryId != null) {
72648
- const currentNode = requireNode(state2, currentDirectoryId);
73144
+ const currentNode = requireNode(state3, currentDirectoryId);
72649
73145
  if (!isDirectoryNode(currentNode) || hasNodeFlag(currentNode, 2)) return;
72650
- if (getDirectoryIndex(state2, currentDirectoryId).childIds.length > 0) return;
73146
+ if (getDirectoryIndex(state3, currentDirectoryId).childIds.length > 0) return;
72651
73147
  addNodeFlag(currentNode, 1);
72652
73148
  currentDirectoryId = currentNode.parentId === currentDirectoryId ? null : currentNode.parentId;
72653
73149
  }
72654
73150
  }
72655
- function findDeepestExistingDirectoryId(state2, segments) {
72656
- let currentDirectoryId = state2.snapshot.rootId;
73151
+ function findDeepestExistingDirectoryId(state3, segments) {
73152
+ let currentDirectoryId = state3.snapshot.rootId;
72657
73153
  for (const segment2 of segments) {
72658
- const segmentId = state2.snapshot.segmentTable.idByValue.get(segment2);
73154
+ const segmentId = state3.snapshot.segmentTable.idByValue.get(segment2);
72659
73155
  if (segmentId == null) break;
72660
- const nextNodeId = ensureChildIdByNameId(state2.snapshot.nodes, getDirectoryIndex(state2, currentDirectoryId)).get(segmentId);
73156
+ const nextNodeId = ensureChildIdByNameId(state3.snapshot.nodes, getDirectoryIndex(state3, currentDirectoryId)).get(segmentId);
72661
73157
  if (nextNodeId == null) break;
72662
- if (!isDirectoryNode(requireNode(state2, nextNodeId))) break;
73158
+ if (!isDirectoryNode(requireNode(state3, nextNodeId))) break;
72663
73159
  currentDirectoryId = nextNodeId;
72664
73160
  }
72665
73161
  return currentDirectoryId;
72666
73162
  }
72667
- function getCollapsedProjectionSignature(state2, startDirectoryId) {
72668
- const collapsedAncestorId = findNearestCollapsedAncestor(state2, startDirectoryId);
73163
+ function getCollapsedProjectionSignature(state3, startDirectoryId) {
73164
+ const collapsedAncestorId = findNearestCollapsedAncestor(state3, startDirectoryId);
72669
73165
  if (collapsedAncestorId == null) return null;
72670
- const terminalDirectoryId = getFlattenedTerminalDirectoryId(state2, collapsedAncestorId);
72671
- const terminalNode = requireNode(state2, terminalDirectoryId);
72672
- const flattenedSegmentPaths = collapsedAncestorId === terminalDirectoryId ? null : collectFlattenedDirectoryChainIds(state2, collapsedAncestorId).map((nodeId) => materializeNodePath(state2, nodeId));
73166
+ const terminalDirectoryId = getFlattenedTerminalDirectoryId(state3, collapsedAncestorId);
73167
+ const terminalNode = requireNode(state3, terminalDirectoryId);
73168
+ const flattenedSegmentPaths = collapsedAncestorId === terminalDirectoryId ? null : collectFlattenedDirectoryChainIds(state3, collapsedAncestorId).map((nodeId) => materializeNodePath(state3, nodeId));
72673
73169
  return JSON.stringify({
72674
73170
  flattenedSegmentPaths,
72675
- hasChildren: getDirectoryIndex(state2, terminalDirectoryId).childIds.length > 0,
72676
- path: materializeNodePath(state2, terminalDirectoryId),
73171
+ hasChildren: getDirectoryIndex(state3, terminalDirectoryId).childIds.length > 0,
73172
+ path: materializeNodePath(state3, terminalDirectoryId),
72677
73173
  terminalKind: getNodeKind(terminalNode)
72678
73174
  });
72679
73175
  }
@@ -72688,67 +73184,67 @@ function didAnyProjectionChange(previousProjectionSignatures, nextProjectionSign
72688
73184
  }
72689
73185
  return false;
72690
73186
  }
72691
- function findNearestCollapsedAncestor(state2, startDirectoryId) {
73187
+ function findNearestCollapsedAncestor(state3, startDirectoryId) {
72692
73188
  let currentDirectoryId = startDirectoryId;
72693
73189
  while (currentDirectoryId != null) {
72694
- const currentNode = requireNode(state2, currentDirectoryId);
73190
+ const currentNode = requireNode(state3, currentDirectoryId);
72695
73191
  if (!isDirectoryNode(currentNode) || hasNodeFlag(currentNode, 2)) return null;
72696
- if (!isDirectoryExpanded(state2, currentDirectoryId, currentNode)) return currentDirectoryId;
73192
+ if (!isDirectoryExpanded(state3, currentDirectoryId, currentNode)) return currentDirectoryId;
72697
73193
  currentDirectoryId = currentNode.parentId;
72698
73194
  }
72699
73195
  return null;
72700
73196
  }
72701
- function recomputeDepths(state2, nodeId) {
72702
- const node = requireNode(state2, nodeId);
72703
- setNodeDepth(node, (nodeId === state2.snapshot.rootId ? -1 : getNodeDepth(requireNode(state2, node.parentId))) + 1);
73197
+ function recomputeDepths(state3, nodeId) {
73198
+ const node = requireNode(state3, nodeId);
73199
+ setNodeDepth(node, (nodeId === state3.snapshot.rootId ? -1 : getNodeDepth(requireNode(state3, node.parentId))) + 1);
72704
73200
  if (!isDirectoryNode(node)) return;
72705
- const directoryIndex = getDirectoryIndex(state2, nodeId);
72706
- for (const childId of directoryIndex.childIds) recomputeDepths(state2, childId);
73201
+ const directoryIndex = getDirectoryIndex(state3, nodeId);
73202
+ for (const childId of directoryIndex.childIds) recomputeDepths(state3, childId);
72707
73203
  }
72708
- function isAncestor2(state2, ancestorNodeId, nodeId) {
73204
+ function isAncestor2(state3, ancestorNodeId, nodeId) {
72709
73205
  let currentNodeId = nodeId;
72710
73206
  while (currentNodeId != null) {
72711
73207
  if (currentNodeId === ancestorNodeId) return true;
72712
- const currentNode = requireNode(state2, currentNodeId);
72713
- if (currentNodeId === state2.snapshot.rootId) return false;
73208
+ const currentNode = requireNode(state3, currentNodeId);
73209
+ if (currentNodeId === state3.snapshot.rootId) return false;
72714
73210
  currentNodeId = currentNode.parentId;
72715
73211
  }
72716
73212
  return false;
72717
73213
  }
72718
- function recomputeNodeCounts(state2, nodeId, currentNode = requireNode(state2, nodeId), rebuildChildAggregates = false) {
72719
- const instrumentation = state2.instrumentation;
73214
+ function recomputeNodeCounts(state3, nodeId, currentNode = requireNode(state3, nodeId), rebuildChildAggregates = false) {
73215
+ const instrumentation = state3.instrumentation;
72720
73216
  if (instrumentation == null) {
72721
- recomputeNodeCountsNow(state2, nodeId, currentNode, rebuildChildAggregates);
73217
+ recomputeNodeCountsNow(state3, nodeId, currentNode, rebuildChildAggregates);
72722
73218
  return;
72723
73219
  }
72724
- withBenchmarkPhase(instrumentation, "store.recomputeNodeCounts", () => recomputeNodeCountsNow(state2, nodeId, currentNode, rebuildChildAggregates));
73220
+ withBenchmarkPhase(instrumentation, "store.recomputeNodeCounts", () => recomputeNodeCountsNow(state3, nodeId, currentNode, rebuildChildAggregates));
72725
73221
  }
72726
- function recomputeCountsUpwardFromNow(state2, startNodeId) {
73222
+ function recomputeCountsUpwardFromNow(state3, startNodeId) {
72727
73223
  let currentNodeId = startNodeId;
72728
73224
  while (currentNodeId != null) {
72729
- const currentNode = requireNode(state2, currentNodeId);
73225
+ const currentNode = requireNode(state3, currentNodeId);
72730
73226
  const previousSubtreeNodeCount = currentNode.subtreeNodeCount;
72731
73227
  const previousVisibleSubtreeCount = currentNode.visibleSubtreeCount;
72732
- recomputeNodeCounts(state2, currentNodeId, currentNode);
72733
- if (currentNodeId === state2.snapshot.rootId) return;
73228
+ recomputeNodeCounts(state3, currentNodeId, currentNode);
73229
+ if (currentNodeId === state3.snapshot.rootId) return;
72734
73230
  const subtreeNodeDelta = currentNode.subtreeNodeCount - previousSubtreeNodeCount;
72735
73231
  const visibleSubtreeDelta = currentNode.visibleSubtreeCount - previousVisibleSubtreeCount;
72736
73232
  const parentId = currentNode.parentId;
72737
- if (subtreeNodeDelta !== 0 || visibleSubtreeDelta !== 0) applyChildAggregateDelta(getDirectoryIndex(state2, parentId), currentNodeId, subtreeNodeDelta, visibleSubtreeDelta);
73233
+ if (subtreeNodeDelta !== 0 || visibleSubtreeDelta !== 0) applyChildAggregateDelta(getDirectoryIndex(state3, parentId), currentNodeId, subtreeNodeDelta, visibleSubtreeDelta);
72738
73234
  currentNodeId = parentId;
72739
73235
  }
72740
73236
  }
72741
- function recomputeNodeCountsNow(state2, nodeId, currentNode, rebuildChildAggregates) {
73237
+ function recomputeNodeCountsNow(state3, nodeId, currentNode, rebuildChildAggregates) {
72742
73238
  if (!isDirectoryNode(currentNode)) {
72743
73239
  currentNode.subtreeNodeCount = 1;
72744
73240
  currentNode.visibleSubtreeCount = 1;
72745
73241
  return;
72746
73242
  }
72747
- const currentIndex = getDirectoryIndex(state2, nodeId);
73243
+ const currentIndex = getDirectoryIndex(state3, nodeId);
72748
73244
  if (rebuildChildAggregates) {
72749
- const instrumentation = state2.instrumentation;
72750
- if (instrumentation == null) rebuildDirectoryChildAggregates(state2.snapshot.nodes, currentIndex);
72751
- else withBenchmarkPhase(instrumentation, "store.recomputeNodeCounts.rebuildChildAggregates", () => rebuildDirectoryChildAggregates(state2.snapshot.nodes, currentIndex));
73245
+ const instrumentation = state3.instrumentation;
73246
+ if (instrumentation == null) rebuildDirectoryChildAggregates(state3.snapshot.nodes, currentIndex);
73247
+ else withBenchmarkPhase(instrumentation, "store.recomputeNodeCounts.rebuildChildAggregates", () => rebuildDirectoryChildAggregates(state3.snapshot.nodes, currentIndex));
72752
73248
  }
72753
73249
  const subtreeNodeCount = 1 + currentIndex.totalChildSubtreeNodeCount;
72754
73250
  const visibleChildCount = currentIndex.totalChildVisibleSubtreeCount;
@@ -72757,10 +73253,10 @@ function recomputeNodeCountsNow(state2, nodeId, currentNode, rebuildChildAggrega
72757
73253
  currentNode.visibleSubtreeCount = visibleChildCount;
72758
73254
  return;
72759
73255
  }
72760
- currentNode.visibleSubtreeCount = getFlattenedChildDirectoryId(state2, nodeId) != null ? visibleChildCount : isDirectoryExpanded(state2, nodeId, currentNode) ? 1 + visibleChildCount : 1;
73256
+ currentNode.visibleSubtreeCount = getFlattenedChildDirectoryId(state3, nodeId) != null ? visibleChildCount : isDirectoryExpanded(state3, nodeId, currentNode) ? 1 + visibleChildCount : 1;
72761
73257
  }
72762
- function buildPathPreview(state2, parentId, basename3) {
72763
- const parentPath = materializeNodePath(state2, parentId);
73258
+ function buildPathPreview(state3, parentId, basename3) {
73259
+ const parentPath = materializeNodePath(state3, parentId);
72764
73260
  return parentPath.length === 0 ? basename3 : `${parentPath}${basename3}`;
72765
73261
  }
72766
73262
 
@@ -72768,16 +73264,16 @@ function buildPathPreview(state2, parentId, basename3) {
72768
73264
  function isLiveNode(node) {
72769
73265
  return node != null && !hasNodeFlag(node, 4);
72770
73266
  }
72771
- function isLiveDirectoryNode(state2, nodeId) {
72772
- const node = state2.snapshot.nodes[nodeId];
73267
+ function isLiveDirectoryNode(state3, nodeId) {
73268
+ const node = state3.snapshot.nodes[nodeId];
72773
73269
  if (!isLiveNode(node) || !isDirectoryNode(node) || hasNodeFlag(node, 2)) return null;
72774
73270
  return node;
72775
73271
  }
72776
- function countCachedPathEntries(state2) {
73272
+ function countCachedPathEntries(state3) {
72777
73273
  let cachedPathEntryCount = 0;
72778
- for (const [nodeId, cachedEntry] of state2.pathCacheByNodeId) {
72779
- if (cachedEntry.version !== state2.pathCacheVersion) continue;
72780
- if (!isLiveNode(state2.snapshot.nodes[nodeId])) continue;
73274
+ for (const [nodeId, cachedEntry] of state3.pathCacheByNodeId) {
73275
+ if (cachedEntry.version !== state3.pathCacheVersion) continue;
73276
+ if (!isLiveNode(state3.snapshot.nodes[nodeId])) continue;
72781
73277
  cachedPathEntryCount += 1;
72782
73278
  }
72783
73279
  return cachedPathEntryCount;
@@ -72785,13 +73281,13 @@ function countCachedPathEntries(state2) {
72785
73281
  function countSegmentEntries(segmentTable) {
72786
73282
  return Math.max(0, segmentTable.valueById.length - 1);
72787
73283
  }
72788
- function createCleanupMetricSnapshot(state2) {
73284
+ function createCleanupMetricSnapshot(state3) {
72789
73285
  return {
72790
- activeNodeCount: state2.activeNodeCount,
72791
- cachedPathEntryCount: countCachedPathEntries(state2),
72792
- loadInfoEntryCount: state2.directoryLoadInfoById.size,
72793
- segmentCount: countSegmentEntries(state2.snapshot.segmentTable),
72794
- totalNodeSlotCount: Math.max(0, state2.snapshot.nodes.length - 1)
73286
+ activeNodeCount: state3.activeNodeCount,
73287
+ cachedPathEntryCount: countCachedPathEntries(state3),
73288
+ loadInfoEntryCount: state3.directoryLoadInfoById.size,
73289
+ segmentCount: countSegmentEntries(state3.snapshot.segmentTable),
73290
+ totalNodeSlotCount: Math.max(0, state3.snapshot.nodes.length - 1)
72795
73291
  };
72796
73292
  }
72797
73293
  function createCleanupResult(mode, idsPreserved, before, after) {
@@ -72814,20 +73310,20 @@ function createCleanupResult(mode, idsPreserved, before, after) {
72814
73310
  totalNodeSlotCountBefore: before.totalNodeSlotCount
72815
73311
  };
72816
73312
  }
72817
- function collectExpansionOverridePaths(state2) {
73313
+ function collectExpansionOverridePaths(state3) {
72818
73314
  const collapsedPaths = [];
72819
73315
  const expandedPaths = [];
72820
- for (const nodeId of state2.collapsedDirectoryIds) if (isLiveDirectoryNode(state2, nodeId) != null) collapsedPaths.push(materializeNodePath(state2, nodeId));
72821
- for (const nodeId of state2.expandedDirectoryIds) if (isLiveDirectoryNode(state2, nodeId) != null) expandedPaths.push(materializeNodePath(state2, nodeId));
73316
+ for (const nodeId of state3.collapsedDirectoryIds) if (isLiveDirectoryNode(state3, nodeId) != null) collapsedPaths.push(materializeNodePath(state3, nodeId));
73317
+ for (const nodeId of state3.expandedDirectoryIds) if (isLiveDirectoryNode(state3, nodeId) != null) expandedPaths.push(materializeNodePath(state3, nodeId));
72822
73318
  return {
72823
73319
  collapsedPaths,
72824
73320
  expandedPaths
72825
73321
  };
72826
73322
  }
72827
- function collectDirectoryLoadInfos(state2) {
73323
+ function collectDirectoryLoadInfos(state3) {
72828
73324
  const retainedInfos = [];
72829
- for (const [nodeId, info] of state2.directoryLoadInfoById) {
72830
- if (isLiveDirectoryNode(state2, nodeId) == null || getDirectoryLoadState(state2, nodeId) === "loaded") continue;
73325
+ for (const [nodeId, info] of state3.directoryLoadInfoById) {
73326
+ if (isLiveDirectoryNode(state3, nodeId) == null || getDirectoryLoadState(state3, nodeId) === "loaded") continue;
72831
73327
  retainedInfos.push({
72832
73328
  info: {
72833
73329
  activeAttemptId: null,
@@ -72835,33 +73331,33 @@ function collectDirectoryLoadInfos(state2) {
72835
73331
  nextAttemptId: info.nextAttemptId,
72836
73332
  state: info.state
72837
73333
  },
72838
- path: materializeNodePath(state2, nodeId)
73334
+ path: materializeNodePath(state3, nodeId)
72839
73335
  });
72840
73336
  }
72841
73337
  return retainedInfos;
72842
73338
  }
72843
- function restoreExpansionOverridePaths(state2, persistedExpansionState) {
72844
- state2.collapsedDirectoryIds.clear();
72845
- state2.hasCollapsedDirectoryOverrides = false;
72846
- state2.expandedDirectoryIds.clear();
73339
+ function restoreExpansionOverridePaths(state3, persistedExpansionState) {
73340
+ state3.collapsedDirectoryIds.clear();
73341
+ state3.hasCollapsedDirectoryOverrides = false;
73342
+ state3.expandedDirectoryIds.clear();
72847
73343
  for (const path of persistedExpansionState.expandedPaths) {
72848
- const nodeId = findNodeId(state2, path);
73344
+ const nodeId = findNodeId(state3, path);
72849
73345
  if (nodeId == null) continue;
72850
- setDirectoryExpanded(state2, nodeId, true, requireNode(state2, nodeId));
73346
+ setDirectoryExpanded(state3, nodeId, true, requireNode(state3, nodeId));
72851
73347
  }
72852
73348
  for (const path of persistedExpansionState.collapsedPaths) {
72853
- const nodeId = findNodeId(state2, path);
73349
+ const nodeId = findNodeId(state3, path);
72854
73350
  if (nodeId == null) continue;
72855
- setDirectoryExpanded(state2, nodeId, false, requireNode(state2, nodeId));
73351
+ setDirectoryExpanded(state3, nodeId, false, requireNode(state3, nodeId));
72856
73352
  }
72857
73353
  }
72858
- function restoreDirectoryLoadInfos(state2, persistedLoadInfos) {
72859
- state2.directoryLoadInfoById.clear();
73354
+ function restoreDirectoryLoadInfos(state3, persistedLoadInfos) {
73355
+ state3.directoryLoadInfoById.clear();
72860
73356
  for (const retainedInfo of persistedLoadInfos) {
72861
- const nodeId = findNodeId(state2, retainedInfo.path);
73357
+ const nodeId = findNodeId(state3, retainedInfo.path);
72862
73358
  if (nodeId == null) continue;
72863
- if (isLiveDirectoryNode(state2, nodeId) == null) continue;
72864
- state2.directoryLoadInfoById.set(nodeId, {
73359
+ if (isLiveDirectoryNode(state3, nodeId) == null) continue;
73360
+ state3.directoryLoadInfoById.set(nodeId, {
72865
73361
  activeAttemptId: null,
72866
73362
  errorMessage: retainedInfo.info.errorMessage,
72867
73363
  nextAttemptId: retainedInfo.info.nextAttemptId,
@@ -72869,18 +73365,18 @@ function restoreDirectoryLoadInfos(state2, persistedLoadInfos) {
72869
73365
  });
72870
73366
  }
72871
73367
  }
72872
- function clearPathCaches(state2) {
72873
- state2.pathCacheVersion += 1;
72874
- state2.pathCacheByNodeId.clear();
72875
- state2.pathCacheByNodeId.set(state2.snapshot.rootId, {
73368
+ function clearPathCaches(state3) {
73369
+ state3.pathCacheVersion += 1;
73370
+ state3.pathCacheByNodeId.clear();
73371
+ state3.pathCacheByNodeId.set(state3.snapshot.rootId, {
72876
73372
  path: "",
72877
- version: state2.pathCacheVersion
73373
+ version: state3.pathCacheVersion
72878
73374
  });
72879
73375
  }
72880
- function rebuildSegmentTablePreservingNodeIds(state2) {
72881
- const previousSegmentTable = state2.snapshot.segmentTable;
73376
+ function rebuildSegmentTablePreservingNodeIds(state3) {
73377
+ const previousSegmentTable = state3.snapshot.segmentTable;
72882
73378
  const nextSegmentTable = createSegmentTable();
72883
- for (const node of state2.snapshot.nodes) {
73379
+ for (const node of state3.snapshot.nodes) {
72884
73380
  if (!isLiveNode(node)) continue;
72885
73381
  if (hasNodeFlag(node, 2)) {
72886
73382
  node.nameId = 0;
@@ -72888,75 +73384,75 @@ function rebuildSegmentTablePreservingNodeIds(state2) {
72888
73384
  }
72889
73385
  node.nameId = internSegment(nextSegmentTable, getSegmentValue(previousSegmentTable, node.nameId));
72890
73386
  }
72891
- state2.snapshot.segmentTable = nextSegmentTable;
73387
+ state3.snapshot.segmentTable = nextSegmentTable;
72892
73388
  }
72893
- function rebuildDirectoryIndexes(state2) {
72894
- for (const [directoryId, directoryIndex] of state2.snapshot.directories) {
72895
- const directoryNode = state2.snapshot.nodes[directoryId];
73389
+ function rebuildDirectoryIndexes(state3) {
73390
+ for (const [directoryId, directoryIndex] of state3.snapshot.directories) {
73391
+ const directoryNode = state3.snapshot.nodes[directoryId];
72896
73392
  if (!isLiveNode(directoryNode) || !isDirectoryNode(directoryNode)) {
72897
- state2.snapshot.directories.delete(directoryId);
73393
+ state3.snapshot.directories.delete(directoryId);
72898
73394
  continue;
72899
73395
  }
72900
73396
  const liveChildIds = directoryIndex.childIds.filter((childId) => {
72901
- const childNode = state2.snapshot.nodes[childId];
73397
+ const childNode = state3.snapshot.nodes[childId];
72902
73398
  return isLiveNode(childNode) && childNode.parentId === directoryId;
72903
73399
  });
72904
73400
  directoryIndex.childIds = liveChildIds;
72905
- directoryIndex.childIdByNameId = new Map(liveChildIds.map((childId) => [requireNode(state2, childId).nameId, childId]));
73401
+ directoryIndex.childIdByNameId = new Map(liveChildIds.map((childId) => [requireNode(state3, childId).nameId, childId]));
72906
73402
  directoryIndex.childPositionById = new Map(liveChildIds.map((childId, childIndex) => [childId, childIndex]));
72907
- rebuildDirectoryChildAggregates(state2.snapshot.nodes, directoryIndex);
73403
+ rebuildDirectoryChildAggregates(state3.snapshot.nodes, directoryIndex);
72908
73404
  }
72909
73405
  }
72910
- function trimTrailingRemovedNodeSlots(state2) {
72911
- let lastNodeIndex = state2.snapshot.nodes.length - 1;
72912
- while (lastNodeIndex > state2.snapshot.rootId) {
72913
- const node = state2.snapshot.nodes[lastNodeIndex];
73406
+ function trimTrailingRemovedNodeSlots(state3) {
73407
+ let lastNodeIndex = state3.snapshot.nodes.length - 1;
73408
+ while (lastNodeIndex > state3.snapshot.rootId) {
73409
+ const node = state3.snapshot.nodes[lastNodeIndex];
72914
73410
  if (isLiveNode(node)) break;
72915
73411
  lastNodeIndex -= 1;
72916
73412
  }
72917
- state2.snapshot.nodes.length = lastNodeIndex + 1;
72918
- }
72919
- function runStableCleanup(state2) {
72920
- const persistedExpansionState = collectExpansionOverridePaths(state2);
72921
- const persistedLoadInfos = collectDirectoryLoadInfos(state2);
72922
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.clearPathCaches", () => clearPathCaches(state2));
72923
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.rebuildSegmentTable", () => rebuildSegmentTablePreservingNodeIds(state2));
72924
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.rebuildDirectoryIndexes", () => rebuildDirectoryIndexes(state2));
72925
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.trimTrailingRemovedNodeSlots", () => trimTrailingRemovedNodeSlots(state2));
72926
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.restoreExpansionOverrides", () => restoreExpansionOverridePaths(state2, persistedExpansionState));
72927
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.restoreDirectoryLoadInfos", () => restoreDirectoryLoadInfos(state2, persistedLoadInfos));
72928
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.recomputeCounts", () => recomputeCountsRecursive(state2, state2.snapshot.rootId));
72929
- }
72930
- function runAggressiveCleanup(state2) {
72931
- const persistedExpansionState = collectExpansionOverridePaths(state2);
72932
- const persistedLoadInfos = collectDirectoryLoadInfos(state2);
72933
- const canonicalPaths = withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.listPaths", () => listPaths(state2));
72934
- const builderOptions = attachBenchmarkInstrumentation({ ...state2.snapshot.options }, state2.instrumentation);
72935
- const rebuiltSnapshot = withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.rebuildSnapshot", () => {
73413
+ state3.snapshot.nodes.length = lastNodeIndex + 1;
73414
+ }
73415
+ function runStableCleanup(state3) {
73416
+ const persistedExpansionState = collectExpansionOverridePaths(state3);
73417
+ const persistedLoadInfos = collectDirectoryLoadInfos(state3);
73418
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.clearPathCaches", () => clearPathCaches(state3));
73419
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.rebuildSegmentTable", () => rebuildSegmentTablePreservingNodeIds(state3));
73420
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.rebuildDirectoryIndexes", () => rebuildDirectoryIndexes(state3));
73421
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.trimTrailingRemovedNodeSlots", () => trimTrailingRemovedNodeSlots(state3));
73422
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.restoreExpansionOverrides", () => restoreExpansionOverridePaths(state3, persistedExpansionState));
73423
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.restoreDirectoryLoadInfos", () => restoreDirectoryLoadInfos(state3, persistedLoadInfos));
73424
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.recomputeCounts", () => recomputeCountsRecursive(state3, state3.snapshot.rootId));
73425
+ }
73426
+ function runAggressiveCleanup(state3) {
73427
+ const persistedExpansionState = collectExpansionOverridePaths(state3);
73428
+ const persistedLoadInfos = collectDirectoryLoadInfos(state3);
73429
+ const canonicalPaths = withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.listPaths", () => listPaths(state3));
73430
+ const builderOptions = attachBenchmarkInstrumentation({ ...state3.snapshot.options }, state3.instrumentation);
73431
+ const rebuiltSnapshot = withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.rebuildSnapshot", () => {
72936
73432
  const builder = new PathStoreBuilder(builderOptions);
72937
73433
  builder.appendPaths(canonicalPaths);
72938
73434
  return builder.finish();
72939
73435
  });
72940
- state2.snapshot = rebuiltSnapshot;
72941
- state2.activeNodeCount = rebuiltSnapshot.nodes.length - 1;
72942
- state2.pathCacheByNodeId = /* @__PURE__ */ new Map([[rebuiltSnapshot.rootId, {
73436
+ state3.snapshot = rebuiltSnapshot;
73437
+ state3.activeNodeCount = rebuiltSnapshot.nodes.length - 1;
73438
+ state3.pathCacheByNodeId = /* @__PURE__ */ new Map([[rebuiltSnapshot.rootId, {
72943
73439
  path: "",
72944
73440
  version: 0
72945
73441
  }]]);
72946
- state2.pathCacheVersion = 0;
72947
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.restoreExpansionOverrides", () => restoreExpansionOverridePaths(state2, persistedExpansionState));
72948
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.restoreDirectoryLoadInfos", () => restoreDirectoryLoadInfos(state2, persistedLoadInfos));
72949
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.recomputeCounts", () => recomputeCountsRecursive(state2, state2.snapshot.rootId));
73442
+ state3.pathCacheVersion = 0;
73443
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.restoreExpansionOverrides", () => restoreExpansionOverridePaths(state3, persistedExpansionState));
73444
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.restoreDirectoryLoadInfos", () => restoreDirectoryLoadInfos(state3, persistedLoadInfos));
73445
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.recomputeCounts", () => recomputeCountsRecursive(state3, state3.snapshot.rootId));
72950
73446
  }
72951
- function hasActiveCleanupBlockingLoads(state2) {
72952
- for (const loadInfo of state2.directoryLoadInfoById.values()) if (loadInfo.state === "loading" && loadInfo.activeAttemptId != null) return true;
73447
+ function hasActiveCleanupBlockingLoads(state3) {
73448
+ for (const loadInfo of state3.directoryLoadInfoById.values()) if (loadInfo.state === "loading" && loadInfo.activeAttemptId != null) return true;
72953
73449
  return false;
72954
73450
  }
72955
- function cleanupPathStoreState(state2, mode) {
72956
- const before = createCleanupMetricSnapshot(state2);
72957
- if (mode === "stable") withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable", () => runStableCleanup(state2));
72958
- else withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive", () => runAggressiveCleanup(state2));
72959
- const after = createCleanupMetricSnapshot(state2);
73451
+ function cleanupPathStoreState(state3, mode) {
73452
+ const before = createCleanupMetricSnapshot(state3);
73453
+ if (mode === "stable") withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable", () => runStableCleanup(state3));
73454
+ else withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive", () => runAggressiveCleanup(state3));
73455
+ const after = createCleanupMetricSnapshot(state3);
72960
73456
  return createCleanupResult(mode, mode === "stable", before, after);
72961
73457
  }
72962
73458
 
@@ -72972,33 +73468,33 @@ function ensureProjectionDepthCapacity(depthTable, depth) {
72972
73468
  nextDepthTable.set(depthTable);
72973
73469
  return nextDepthTable;
72974
73470
  }
72975
- function getVisibleCount(state2) {
72976
- return requireNode(state2, state2.snapshot.rootId).visibleSubtreeCount;
73471
+ function getVisibleCount(state3) {
73472
+ return requireNode(state3, state3.snapshot.rootId).visibleSubtreeCount;
72977
73473
  }
72978
- function getVisibleRowSubtreeEndIndex(state2, cursor, index, totalVisibleCount) {
72979
- const terminalNode = requireNode(state2, cursor.terminalNodeId);
73474
+ function getVisibleRowSubtreeEndIndex(state3, cursor, index, totalVisibleCount) {
73475
+ const terminalNode = requireNode(state3, cursor.terminalNodeId);
72980
73476
  const subtreeSize = Math.max(1, terminalNode.visibleSubtreeCount);
72981
73477
  return Math.min(totalVisibleCount - 1, index + subtreeSize - 1);
72982
73478
  }
72983
- function materializeVisibleAncestorRow(state2, entry, totalVisibleCount, ancestorPaths) {
73479
+ function materializeVisibleAncestorRow(state3, entry, totalVisibleCount, ancestorPaths) {
72984
73480
  return {
72985
73481
  ancestorPaths,
72986
73482
  index: entry.index,
72987
73483
  posInSet: entry.posInSet,
72988
- row: materializeVisibleRow(state2, entry.cursor),
73484
+ row: materializeVisibleRow(state3, entry.cursor),
72989
73485
  setSize: entry.setSize,
72990
- subtreeEndIndex: getVisibleRowSubtreeEndIndex(state2, entry.cursor, entry.index, totalVisibleCount)
73486
+ subtreeEndIndex: getVisibleRowSubtreeEndIndex(state3, entry.cursor, entry.index, totalVisibleCount)
72991
73487
  };
72992
73488
  }
72993
- function selectVisibleRowContextWithinDirectory(state2, directoryNodeId, index, directoryStartIndex, parentVisibleDepth, ancestors2) {
72994
- const directoryIndex = getDirectoryIndex(state2, directoryNodeId);
72995
- const { childIndex, childVisibleIndex, localVisibleIndex } = selectChildIndexByVisibleIndex(state2.snapshot.nodes, directoryIndex, index);
73489
+ function selectVisibleRowContextWithinDirectory(state3, directoryNodeId, index, directoryStartIndex, parentVisibleDepth, ancestors2) {
73490
+ const directoryIndex = getDirectoryIndex(state3, directoryNodeId);
73491
+ const { childIndex, childVisibleIndex, localVisibleIndex } = selectChildIndexByVisibleIndex(state3.snapshot.nodes, directoryIndex, index);
72996
73492
  const childId = directoryIndex.childIds[childIndex];
72997
73493
  if (childId == null) throw new Error(`Visible index ${String(index)} is out of range`);
72998
- return selectVisibleRowContextWithinSubtree(state2, childId, localVisibleIndex, directoryStartIndex + childVisibleIndex, parentVisibleDepth + 1, childIndex, directoryIndex.childIds.length, ancestors2);
73494
+ return selectVisibleRowContextWithinSubtree(state3, childId, localVisibleIndex, directoryStartIndex + childVisibleIndex, parentVisibleDepth + 1, childIndex, directoryIndex.childIds.length, ancestors2);
72999
73495
  }
73000
- function selectVisibleRowContextWithinSubtree(state2, nodeId, index, rowIndex, visibleDepth, posInSet, setSize, ancestors2) {
73001
- if (!isDirectoryNode(requireNode(state2, nodeId))) {
73496
+ function selectVisibleRowContextWithinSubtree(state3, nodeId, index, rowIndex, visibleDepth, posInSet, setSize, ancestors2) {
73497
+ if (!isDirectoryNode(requireNode(state3, nodeId))) {
73002
73498
  if (index === 0) return {
73003
73499
  ancestors: ancestors2,
73004
73500
  cursor: {
@@ -73012,7 +73508,7 @@ function selectVisibleRowContextWithinSubtree(state2, nodeId, index, rowIndex, v
73012
73508
  };
73013
73509
  throw new Error(`Visible index ${String(index)} is out of range for file`);
73014
73510
  }
73015
- const currentCursor = createVisibleRowCursor(state2, nodeId, visibleDepth);
73511
+ const currentCursor = createVisibleRowCursor(state3, nodeId, visibleDepth);
73016
73512
  if (index === 0) return {
73017
73513
  ancestors: ancestors2,
73018
73514
  cursor: currentCursor,
@@ -73020,20 +73516,20 @@ function selectVisibleRowContextWithinSubtree(state2, nodeId, index, rowIndex, v
73020
73516
  posInSet,
73021
73517
  setSize
73022
73518
  };
73023
- const terminalNode = requireNode(state2, currentCursor.terminalNodeId);
73024
- if (!isDirectoryNode(terminalNode) || !isDirectoryExpanded(state2, currentCursor.terminalNodeId, terminalNode)) throw new Error(`Visible index ${String(index)} is out of range for collapsed directory`);
73025
- return selectVisibleRowContextWithinDirectory(state2, currentCursor.terminalNodeId, index - 1, rowIndex + 1, currentCursor.visibleDepth, [...ancestors2, {
73519
+ const terminalNode = requireNode(state3, currentCursor.terminalNodeId);
73520
+ if (!isDirectoryNode(terminalNode) || !isDirectoryExpanded(state3, currentCursor.terminalNodeId, terminalNode)) throw new Error(`Visible index ${String(index)} is out of range for collapsed directory`);
73521
+ return selectVisibleRowContextWithinDirectory(state3, currentCursor.terminalNodeId, index - 1, rowIndex + 1, currentCursor.visibleDepth, [...ancestors2, {
73026
73522
  cursor: currentCursor,
73027
73523
  index: rowIndex,
73028
73524
  posInSet,
73029
73525
  setSize
73030
73526
  }]);
73031
73527
  }
73032
- function getVisibleRowContext(state2, index) {
73033
- const totalVisibleCount = getVisibleCount(state2);
73528
+ function getVisibleRowContext(state3, index) {
73529
+ const totalVisibleCount = getVisibleCount(state3);
73034
73530
  if (index < 0 || index >= totalVisibleCount) return null;
73035
- const selected = selectVisibleRowContextWithinDirectory(state2, state2.snapshot.rootId, index, 0, -1, []);
73036
- const ancestorPaths = selected.ancestors.map((ancestor) => materializeNodePath(state2, ancestor.cursor.terminalNodeId));
73531
+ const selected = selectVisibleRowContextWithinDirectory(state3, state3.snapshot.rootId, index, 0, -1, []);
73532
+ const ancestorPaths = selected.ancestors.map((ancestor) => materializeNodePath(state3, ancestor.cursor.terminalNodeId));
73037
73533
  let cachedAncestorRows = null;
73038
73534
  return {
73039
73535
  ancestorPaths,
@@ -73042,7 +73538,7 @@ function getVisibleRowContext(state2, index) {
73042
73538
  const ancestorRows = [];
73043
73539
  const rowAncestorPaths = [];
73044
73540
  for (const ancestor of selected.ancestors) {
73045
- const ancestorRow = materializeVisibleAncestorRow(state2, ancestor, totalVisibleCount, [...rowAncestorPaths]);
73541
+ const ancestorRow = materializeVisibleAncestorRow(state3, ancestor, totalVisibleCount, [...rowAncestorPaths]);
73046
73542
  ancestorRows.push(ancestorRow);
73047
73543
  rowAncestorPaths.push(ancestorRow.row.path);
73048
73544
  }
@@ -73051,121 +73547,121 @@ function getVisibleRowContext(state2, index) {
73051
73547
  },
73052
73548
  index: selected.index,
73053
73549
  posInSet: selected.posInSet,
73054
- row: materializeVisibleRow(state2, selected.cursor),
73550
+ row: materializeVisibleRow(state3, selected.cursor),
73055
73551
  setSize: selected.setSize,
73056
- subtreeEndIndex: getVisibleRowSubtreeEndIndex(state2, selected.cursor, selected.index, totalVisibleCount)
73552
+ subtreeEndIndex: getVisibleRowSubtreeEndIndex(state3, selected.cursor, selected.index, totalVisibleCount)
73057
73553
  };
73058
73554
  }
73059
- function getVisibleSlice(state2, start, end) {
73060
- const instrumentation = state2.instrumentation;
73061
- const totalVisibleCount = getVisibleCount(state2);
73555
+ function getVisibleSlice(state3, start, end) {
73556
+ const instrumentation = state3.instrumentation;
73557
+ const totalVisibleCount = getVisibleCount(state3);
73062
73558
  if (totalVisibleCount <= 0 || end < start) return [];
73063
73559
  const normalizedStart = Math.max(0, Math.min(start, totalVisibleCount - 1));
73064
73560
  const normalizedEnd = Math.max(normalizedStart, Math.min(end, totalVisibleCount - 1));
73065
73561
  if (instrumentation == null) {
73066
- if (normalizedStart === 0) return collectVisibleRowsDFS(state2, normalizedEnd + 1);
73562
+ if (normalizedStart === 0) return collectVisibleRowsDFS(state3, normalizedEnd + 1);
73067
73563
  const rows2 = [];
73068
- let currentCursor2 = selectVisibleRow(state2, normalizedStart);
73564
+ let currentCursor2 = selectVisibleRow(state3, normalizedStart);
73069
73565
  for (let visibleIndex = normalizedStart; visibleIndex <= normalizedEnd && currentCursor2 != null; visibleIndex++) {
73070
- const row = materializeVisibleRow(state2, currentCursor2);
73566
+ const row = materializeVisibleRow(state3, currentCursor2);
73071
73567
  rows2.push(row);
73072
- currentCursor2 = getNextVisibleRowCursor(state2, currentCursor2);
73568
+ currentCursor2 = getNextVisibleRowCursor(state3, currentCursor2);
73073
73569
  }
73074
73570
  return rows2;
73075
73571
  }
73076
73572
  const rows = [];
73077
73573
  let flattenedRowCount = 0;
73078
73574
  let flattenedSegmentCount = 0;
73079
- let currentCursor = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.selectFirstRow", () => selectVisibleRow(state2, normalizedStart));
73575
+ let currentCursor = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.selectFirstRow", () => selectVisibleRow(state3, normalizedStart));
73080
73576
  for (let visibleIndex = normalizedStart; visibleIndex <= normalizedEnd && currentCursor != null; visibleIndex++) {
73081
- const row = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.materializeRow", () => materializeVisibleRow(state2, currentCursor));
73577
+ const row = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.materializeRow", () => materializeVisibleRow(state3, currentCursor));
73082
73578
  rows.push(row);
73083
73579
  if (row.isFlattened) {
73084
73580
  flattenedRowCount++;
73085
73581
  flattenedSegmentCount += row.flattenedSegments?.length ?? 0;
73086
73582
  }
73087
- currentCursor = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.advanceCursor", () => getNextVisibleRowCursor(state2, currentCursor));
73583
+ currentCursor = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.advanceCursor", () => getNextVisibleRowCursor(state3, currentCursor));
73088
73584
  }
73089
73585
  setBenchmarkCounter(instrumentation, "workload.visibleRowsRead", rows.length);
73090
73586
  setBenchmarkCounter(instrumentation, "workload.flattenedRowsRead", flattenedRowCount);
73091
73587
  setBenchmarkCounter(instrumentation, "workload.flattenedSegmentsRead", flattenedSegmentCount);
73092
73588
  return rows;
73093
73589
  }
73094
- function getVisibleTreeProjectionData(state2, maxRows = getVisibleCount(state2)) {
73095
- const instrumentation = state2.instrumentation;
73096
- if (instrumentation == null) return buildVisibleTreeProjectionDataDFS(state2, maxRows);
73097
- return withBenchmarkPhase(instrumentation, "store.getVisibleTreeProjection", () => buildVisibleTreeProjectionDataDFS(state2, maxRows));
73590
+ function getVisibleTreeProjectionData(state3, maxRows = getVisibleCount(state3)) {
73591
+ const instrumentation = state3.instrumentation;
73592
+ if (instrumentation == null) return buildVisibleTreeProjectionDataDFS(state3, maxRows);
73593
+ return withBenchmarkPhase(instrumentation, "store.getVisibleTreeProjection", () => buildVisibleTreeProjectionDataDFS(state3, maxRows));
73098
73594
  }
73099
- function getVisibleTreeProjection(state2) {
73100
- return createVisibleTreeProjectionFromData(getVisibleTreeProjectionData(state2));
73595
+ function getVisibleTreeProjection(state3) {
73596
+ return createVisibleTreeProjectionFromData(getVisibleTreeProjectionData(state3));
73101
73597
  }
73102
- function getVisibleIndexByPath(state2, path) {
73103
- const nodeId = findNodeId(state2, path);
73104
- if (nodeId == null || nodeId === state2.snapshot.rootId) return null;
73105
- if (isDirectoryNode(requireNode(state2, nodeId)) && getFlattenedTerminalDirectoryId(state2, nodeId) !== nodeId) return null;
73598
+ function getVisibleIndexByPath(state3, path) {
73599
+ const nodeId = findNodeId(state3, path);
73600
+ if (nodeId == null || nodeId === state3.snapshot.rootId) return null;
73601
+ if (isDirectoryNode(requireNode(state3, nodeId)) && getFlattenedTerminalDirectoryId(state3, nodeId) !== nodeId) return null;
73106
73602
  let visibleIndex = 0;
73107
73603
  let currentNodeId = nodeId;
73108
- const { nodes, rootId } = state2.snapshot;
73604
+ const { nodes, rootId } = state3.snapshot;
73109
73605
  while (currentNodeId !== rootId) {
73110
- const parentId = requireNode(state2, currentNodeId).parentId;
73111
- const parentIndex = getDirectoryIndex(state2, parentId);
73606
+ const parentId = requireNode(state3, currentNodeId).parentId;
73607
+ const parentIndex = getDirectoryIndex(state3, parentId);
73112
73608
  const childPosition = ensureChildPositions(parentIndex).get(currentNodeId);
73113
73609
  if (childPosition == null) throw new Error(`Child ${String(currentNodeId)} was not found in its parent index`);
73114
73610
  visibleIndex += getVisibleChildPrefixCount(nodes, parentIndex, childPosition);
73115
73611
  if (parentId !== rootId) {
73116
- const parentNode = requireNode(state2, parentId);
73117
- const flattenedChildDirectoryId = getFlattenedChildDirectoryId(state2, parentId);
73118
- if (!isDirectoryExpanded(state2, parentId, parentNode) && flattenedChildDirectoryId !== currentNodeId) return null;
73119
- if (getFlattenedTerminalDirectoryId(state2, parentId) === parentId) visibleIndex += 1;
73612
+ const parentNode = requireNode(state3, parentId);
73613
+ const flattenedChildDirectoryId = getFlattenedChildDirectoryId(state3, parentId);
73614
+ if (!isDirectoryExpanded(state3, parentId, parentNode) && flattenedChildDirectoryId !== currentNodeId) return null;
73615
+ if (getFlattenedTerminalDirectoryId(state3, parentId) === parentId) visibleIndex += 1;
73120
73616
  }
73121
73617
  currentNodeId = parentId;
73122
73618
  }
73123
73619
  return visibleIndex;
73124
73620
  }
73125
- function expandPath(state2, path) {
73126
- const directoryNodeId = findNodeId(state2, path);
73621
+ function expandPath(state3, path) {
73622
+ const directoryNodeId = findNodeId(state3, path);
73127
73623
  if (directoryNodeId == null) throw new Error(`Path does not exist: "${path}"`);
73128
- const directoryNode = requireNode(state2, directoryNodeId);
73624
+ const directoryNode = requireNode(state3, directoryNodeId);
73129
73625
  if (!isDirectoryNode(directoryNode)) throw new Error(`Path is not a directory: "${path}"`);
73130
- if (isDirectoryExpanded(state2, directoryNodeId, directoryNode)) return null;
73131
- setDirectoryExpanded(state2, directoryNodeId, true, directoryNode);
73132
- recomputeCountsUpwardFrom(state2, directoryNodeId);
73626
+ if (isDirectoryExpanded(state3, directoryNodeId, directoryNode)) return null;
73627
+ setDirectoryExpanded(state3, directoryNodeId, true, directoryNode);
73628
+ recomputeCountsUpwardFrom(state3, directoryNodeId);
73133
73629
  return createExpandEvent({
73134
- affectedAncestorIds: collectAncestorIds(state2, directoryNodeId),
73630
+ affectedAncestorIds: collectAncestorIds(state3, directoryNodeId),
73135
73631
  affectedNodeIds: [directoryNodeId],
73136
73632
  path,
73137
73633
  projectionChanged: true
73138
73634
  });
73139
73635
  }
73140
- function collapsePath(state2, path) {
73141
- const directoryNodeId = findNodeId(state2, path);
73636
+ function collapsePath(state3, path) {
73637
+ const directoryNodeId = findNodeId(state3, path);
73142
73638
  if (directoryNodeId == null) throw new Error(`Path does not exist: "${path}"`);
73143
- const directoryNode = requireNode(state2, directoryNodeId);
73639
+ const directoryNode = requireNode(state3, directoryNodeId);
73144
73640
  if (!isDirectoryNode(directoryNode)) throw new Error(`Path is not a directory: "${path}"`);
73145
- if (!isDirectoryExpanded(state2, directoryNodeId, directoryNode)) return null;
73146
- setDirectoryExpanded(state2, directoryNodeId, false, directoryNode);
73147
- recomputeCountsUpwardFrom(state2, directoryNodeId);
73641
+ if (!isDirectoryExpanded(state3, directoryNodeId, directoryNode)) return null;
73642
+ setDirectoryExpanded(state3, directoryNodeId, false, directoryNode);
73643
+ recomputeCountsUpwardFrom(state3, directoryNodeId);
73148
73644
  return createCollapseEvent({
73149
- affectedAncestorIds: collectAncestorIds(state2, directoryNodeId),
73645
+ affectedAncestorIds: collectAncestorIds(state3, directoryNodeId),
73150
73646
  affectedNodeIds: [directoryNodeId],
73151
73647
  path,
73152
73648
  projectionChanged: true
73153
73649
  });
73154
73650
  }
73155
- function selectVisibleRow(state2, index) {
73156
- if (index < 0 || index >= getVisibleCount(state2)) return null;
73157
- return selectVisibleRowWithinDirectory(state2, state2.snapshot.rootId, index, -1);
73651
+ function selectVisibleRow(state3, index) {
73652
+ if (index < 0 || index >= getVisibleCount(state3)) return null;
73653
+ return selectVisibleRowWithinDirectory(state3, state3.snapshot.rootId, index, -1);
73158
73654
  }
73159
- function selectVisibleRowWithinDirectory(state2, directoryNodeId, index, parentVisibleDepth) {
73160
- const directoryIndex = getDirectoryIndex(state2, directoryNodeId);
73161
- const instrumentation = state2.instrumentation;
73162
- const { childIndex, localVisibleIndex } = instrumentation == null ? selectChildIndexByVisibleIndex(state2.snapshot.nodes, directoryIndex, index) : withBenchmarkPhase(instrumentation, "store.getVisibleSlice.selectChildIndex", () => selectChildIndexByVisibleIndex(state2.snapshot.nodes, directoryIndex, index));
73655
+ function selectVisibleRowWithinDirectory(state3, directoryNodeId, index, parentVisibleDepth) {
73656
+ const directoryIndex = getDirectoryIndex(state3, directoryNodeId);
73657
+ const instrumentation = state3.instrumentation;
73658
+ const { childIndex, localVisibleIndex } = instrumentation == null ? selectChildIndexByVisibleIndex(state3.snapshot.nodes, directoryIndex, index) : withBenchmarkPhase(instrumentation, "store.getVisibleSlice.selectChildIndex", () => selectChildIndexByVisibleIndex(state3.snapshot.nodes, directoryIndex, index));
73163
73659
  const childId = directoryIndex.childIds[childIndex];
73164
- if (childId != null) return selectVisibleRowWithinSubtree(state2, childId, localVisibleIndex, parentVisibleDepth + 1);
73660
+ if (childId != null) return selectVisibleRowWithinSubtree(state3, childId, localVisibleIndex, parentVisibleDepth + 1);
73165
73661
  throw new Error(`Visible index ${String(index)} is out of range`);
73166
73662
  }
73167
- function selectVisibleRowWithinSubtree(state2, nodeId, index, visibleDepth) {
73168
- if (!isDirectoryNode(requireNode(state2, nodeId))) {
73663
+ function selectVisibleRowWithinSubtree(state3, nodeId, index, visibleDepth) {
73664
+ if (!isDirectoryNode(requireNode(state3, nodeId))) {
73169
73665
  if (index === 0) return {
73170
73666
  headNodeId: nodeId,
73171
73667
  terminalNodeId: nodeId,
@@ -73173,57 +73669,57 @@ function selectVisibleRowWithinSubtree(state2, nodeId, index, visibleDepth) {
73173
73669
  };
73174
73670
  throw new Error(`Visible index ${String(index)} is out of range for file`);
73175
73671
  }
73176
- const currentCursor = createVisibleRowCursor(state2, nodeId, visibleDepth);
73672
+ const currentCursor = createVisibleRowCursor(state3, nodeId, visibleDepth);
73177
73673
  if (index === 0) return currentCursor;
73178
- const terminalNode = requireNode(state2, currentCursor.terminalNodeId);
73179
- if (!isDirectoryNode(terminalNode) || !isDirectoryExpanded(state2, currentCursor.terminalNodeId, terminalNode)) throw new Error(`Visible index ${String(index)} is out of range for collapsed directory`);
73180
- return selectVisibleRowWithinDirectory(state2, currentCursor.terminalNodeId, index - 1, currentCursor.visibleDepth);
73674
+ const terminalNode = requireNode(state3, currentCursor.terminalNodeId);
73675
+ if (!isDirectoryNode(terminalNode) || !isDirectoryExpanded(state3, currentCursor.terminalNodeId, terminalNode)) throw new Error(`Visible index ${String(index)} is out of range for collapsed directory`);
73676
+ return selectVisibleRowWithinDirectory(state3, currentCursor.terminalNodeId, index - 1, currentCursor.visibleDepth);
73181
73677
  }
73182
- function createVisibleRowCursor(state2, nodeId, visibleDepth) {
73183
- if (!isDirectoryNode(requireNode(state2, nodeId))) return {
73678
+ function createVisibleRowCursor(state3, nodeId, visibleDepth) {
73679
+ if (!isDirectoryNode(requireNode(state3, nodeId))) return {
73184
73680
  headNodeId: nodeId,
73185
73681
  terminalNodeId: nodeId,
73186
73682
  visibleDepth
73187
73683
  };
73188
- if (state2.instrumentation == null) return {
73684
+ if (state3.instrumentation == null) return {
73189
73685
  headNodeId: nodeId,
73190
- terminalNodeId: getFlattenedTerminalDirectoryId(state2, nodeId),
73686
+ terminalNodeId: getFlattenedTerminalDirectoryId(state3, nodeId),
73191
73687
  visibleDepth
73192
73688
  };
73193
73689
  return {
73194
73690
  headNodeId: nodeId,
73195
- terminalNodeId: withBenchmarkPhase(state2.instrumentation, "store.getVisibleSlice.flatten.resolveTerminalDirectory", () => getFlattenedTerminalDirectoryId(state2, nodeId)),
73691
+ terminalNodeId: withBenchmarkPhase(state3.instrumentation, "store.getVisibleSlice.flatten.resolveTerminalDirectory", () => getFlattenedTerminalDirectoryId(state3, nodeId)),
73196
73692
  visibleDepth
73197
73693
  };
73198
73694
  }
73199
- function isVisibleRowHeadNode(state2, nodeId) {
73200
- const node = requireNode(state2, nodeId);
73695
+ function isVisibleRowHeadNode(state3, nodeId) {
73696
+ const node = requireNode(state3, nodeId);
73201
73697
  if (!isDirectoryNode(node)) return true;
73202
73698
  const parentId = node.parentId;
73203
- if (parentId === state2.snapshot.rootId) return true;
73204
- return getFlattenedChildDirectoryId(state2, parentId) !== nodeId;
73699
+ if (parentId === state3.snapshot.rootId) return true;
73700
+ return getFlattenedChildDirectoryId(state3, parentId) !== nodeId;
73205
73701
  }
73206
- function getNextVisibleRowCursor(state2, currentCursor) {
73207
- const terminalNode = requireNode(state2, currentCursor.terminalNodeId);
73702
+ function getNextVisibleRowCursor(state3, currentCursor) {
73703
+ const terminalNode = requireNode(state3, currentCursor.terminalNodeId);
73208
73704
  if (isDirectoryNode(terminalNode)) {
73209
- const currentIndex = getDirectoryIndex(state2, currentCursor.terminalNodeId);
73210
- if (isDirectoryExpanded(state2, currentCursor.terminalNodeId, terminalNode) && currentIndex.childIds.length > 0) {
73705
+ const currentIndex = getDirectoryIndex(state3, currentCursor.terminalNodeId);
73706
+ if (isDirectoryExpanded(state3, currentCursor.terminalNodeId, terminalNode) && currentIndex.childIds.length > 0) {
73211
73707
  const firstChildId = currentIndex.childIds[0];
73212
- return firstChildId == null ? null : selectVisibleRowWithinSubtree(state2, firstChildId, 0, currentCursor.visibleDepth + 1);
73708
+ return firstChildId == null ? null : selectVisibleRowWithinSubtree(state3, firstChildId, 0, currentCursor.visibleDepth + 1);
73213
73709
  }
73214
73710
  }
73215
73711
  let currentNodeId = currentCursor.terminalNodeId;
73216
73712
  let currentVisibleDepth = currentCursor.visibleDepth;
73217
73713
  while (true) {
73218
- const currentNode = requireNode(state2, currentNodeId);
73219
- if (currentNodeId === state2.snapshot.rootId) return null;
73714
+ const currentNode = requireNode(state3, currentNodeId);
73715
+ if (currentNodeId === state3.snapshot.rootId) return null;
73220
73716
  const parentId = currentNode.parentId;
73221
- const parentIndex = getDirectoryIndex(state2, parentId);
73717
+ const parentIndex = getDirectoryIndex(state3, parentId);
73222
73718
  const siblingIndex = ensureChildPositions(parentIndex).get(currentNodeId) ?? -1;
73223
73719
  if (siblingIndex < 0) throw new Error(`Child ${String(currentNodeId)} was not found in its parent index`);
73224
73720
  const nextSiblingId = parentIndex.childIds[siblingIndex + 1] ?? null;
73225
- if (nextSiblingId != null) return selectVisibleRowWithinSubtree(state2, nextSiblingId, 0, currentVisibleDepth);
73226
- if (isVisibleRowHeadNode(state2, currentNodeId)) currentVisibleDepth--;
73721
+ if (nextSiblingId != null) return selectVisibleRowWithinSubtree(state3, nextSiblingId, 0, currentVisibleDepth);
73722
+ if (isVisibleRowHeadNode(state3, currentNodeId)) currentVisibleDepth--;
73227
73723
  currentNodeId = parentId;
73228
73724
  }
73229
73725
  }
@@ -73248,7 +73744,7 @@ function createVisibleTreeProjectionFromData(projection) {
73248
73744
  }
73249
73745
  };
73250
73746
  }
73251
- function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73747
+ function buildVisibleTreeProjectionDataDFS(state3, maxRows) {
73252
73748
  const paths = new Array(maxRows);
73253
73749
  const parentRowIndex = new Int32Array(maxRows);
73254
73750
  const posInSetByIndex = new Int32Array(maxRows);
@@ -73256,16 +73752,16 @@ function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73256
73752
  let lastRowAtDepth = new Int32Array(INITIAL_PROJECTION_DEPTH_CAPACITY);
73257
73753
  lastRowAtDepth.fill(-1);
73258
73754
  let rowCount = 0;
73259
- const { nodes, directories, segmentTable } = state2.snapshot;
73755
+ const { nodes, directories, segmentTable } = state3.snapshot;
73260
73756
  const stack = [[
73261
- directories.get(state2.snapshot.rootId),
73757
+ directories.get(state3.snapshot.rootId),
73262
73758
  0,
73263
73759
  -1,
73264
73760
  ""
73265
73761
  ]];
73266
- const flattenEnabled = state2.snapshot.options.flattenEmptyDirectories;
73267
- const pathCacheByNodeId = state2.pathCacheByNodeId;
73268
- const pathCacheVersion = state2.pathCacheVersion;
73762
+ const flattenEnabled = state3.snapshot.options.flattenEmptyDirectories;
73763
+ const pathCacheByNodeId = state3.pathCacheByNodeId;
73764
+ const pathCacheVersion = state3.pathCacheVersion;
73269
73765
  const segmentValues = segmentTable.valueById;
73270
73766
  while (stack.length > 0 && rowCount < maxRows) {
73271
73767
  const frame = stack[stack.length - 1];
@@ -73286,8 +73782,8 @@ function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73286
73782
  const cachedPathEntry = pathCacheByNodeId.get(childId);
73287
73783
  path = cachedPathEntry != null && cachedPathEntry.version === pathCacheVersion ? cachedPathEntry.path : `${parentPath}${segmentValues[childNode.nameId]}`;
73288
73784
  } else {
73289
- terminalNodeId = flattenEnabled ? getFlattenedTerminalDirectoryId(state2, childId) : childId;
73290
- path = terminalNodeId === childId ? `${parentPath}${segmentValues[childNode.nameId]}/` : materializeNodePath(state2, terminalNodeId);
73785
+ terminalNodeId = flattenEnabled ? getFlattenedTerminalDirectoryId(state3, childId) : childId;
73786
+ path = terminalNodeId === childId ? `${parentPath}${segmentValues[childNode.nameId]}/` : materializeNodePath(state3, terminalNodeId);
73291
73787
  }
73292
73788
  parentRowIndex[rowCount] = lastRowAtDepth[visibleDepth];
73293
73789
  paths[rowCount] = path;
@@ -73296,7 +73792,7 @@ function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73296
73792
  lastRowAtDepth[visibleDepth + 1] = rowCount;
73297
73793
  rowCount += 1;
73298
73794
  const terminalNode = nodes[terminalNodeId];
73299
- if (terminalNode != null && isDirectoryNode(terminalNode) && isDirectoryExpanded(state2, terminalNodeId, terminalNode)) stack.push([
73795
+ if (terminalNode != null && isDirectoryNode(terminalNode) && isDirectoryExpanded(state3, terminalNodeId, terminalNode)) stack.push([
73300
73796
  directories.get(terminalNodeId),
73301
73797
  0,
73302
73798
  visibleDepth,
@@ -73324,19 +73820,19 @@ function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73324
73820
  }
73325
73821
  };
73326
73822
  }
73327
- function collectVisibleRowsDFS(state2, maxRows) {
73823
+ function collectVisibleRowsDFS(state3, maxRows) {
73328
73824
  const rows = new Array(maxRows);
73329
73825
  let rowCount = 0;
73330
- const { nodes, directories, segmentTable } = state2.snapshot;
73826
+ const { nodes, directories, segmentTable } = state3.snapshot;
73331
73827
  const stack = [[
73332
- directories.get(state2.snapshot.rootId),
73828
+ directories.get(state3.snapshot.rootId),
73333
73829
  0,
73334
73830
  -1
73335
73831
  ]];
73336
73832
  const segmentValues = segmentTable.valueById;
73337
- const flattenEnabled = state2.snapshot.options.flattenEmptyDirectories;
73338
- const pathCacheByNodeId = state2.pathCacheByNodeId;
73339
- const pathCacheVersion = state2.pathCacheVersion;
73833
+ const flattenEnabled = state3.snapshot.options.flattenEmptyDirectories;
73834
+ const pathCacheByNodeId = state3.pathCacheByNodeId;
73835
+ const pathCacheVersion = state3.pathCacheVersion;
73340
73836
  while (stack.length > 0 && rowCount < maxRows) {
73341
73837
  const frame = stack[stack.length - 1];
73342
73838
  const dirIndex = frame[0];
@@ -73360,19 +73856,19 @@ function collectVisibleRowsDFS(state2, maxRows) {
73360
73856
  kind: "file",
73361
73857
  loadState: void 0,
73362
73858
  name: segmentValues[childNode.nameId],
73363
- path: cachedPathEntry != null && cachedPathEntry.version === pathCacheVersion ? cachedPathEntry.path : materializeNodePath(state2, childId)
73859
+ path: cachedPathEntry != null && cachedPathEntry.version === pathCacheVersion ? cachedPathEntry.path : materializeNodePath(state3, childId)
73364
73860
  };
73365
73861
  continue;
73366
73862
  }
73367
- const terminalNodeId = flattenEnabled ? getFlattenedTerminalDirectoryId(state2, childId) : childId;
73863
+ const terminalNodeId = flattenEnabled ? getFlattenedTerminalDirectoryId(state3, childId) : childId;
73368
73864
  const cursor = {
73369
73865
  headNodeId: childId,
73370
73866
  terminalNodeId,
73371
73867
  visibleDepth
73372
73868
  };
73373
- rows[rowCount++] = materializeVisibleRow(state2, cursor);
73869
+ rows[rowCount++] = materializeVisibleRow(state3, cursor);
73374
73870
  const terminalNode = nodes[terminalNodeId];
73375
- if (terminalNode != null && isDirectoryNode(terminalNode) && isDirectoryExpanded(state2, terminalNodeId, terminalNode)) stack.push([
73871
+ if (terminalNode != null && isDirectoryNode(terminalNode) && isDirectoryExpanded(state3, terminalNodeId, terminalNode)) stack.push([
73376
73872
  directories.get(terminalNodeId),
73377
73873
  0,
73378
73874
  visibleDepth
@@ -73381,29 +73877,29 @@ function collectVisibleRowsDFS(state2, maxRows) {
73381
73877
  if (rowCount < maxRows) rows.length = rowCount;
73382
73878
  return rows;
73383
73879
  }
73384
- function materializeVisibleRow(state2, cursor) {
73385
- const terminalNode = requireNode(state2, cursor.terminalNodeId);
73386
- const loadState = isDirectoryNode(terminalNode) ? getVisibleRowLoadState(state2, cursor) : null;
73387
- const path = materializeNodePath(state2, cursor.terminalNodeId);
73388
- const name = getSegmentValue(state2.snapshot.segmentTable, terminalNode.nameId);
73389
- const hasChildren = isDirectoryNode(terminalNode) && getDirectoryIndex(state2, cursor.terminalNodeId).childIds.length > 0;
73880
+ function materializeVisibleRow(state3, cursor) {
73881
+ const terminalNode = requireNode(state3, cursor.terminalNodeId);
73882
+ const loadState = isDirectoryNode(terminalNode) ? getVisibleRowLoadState(state3, cursor) : null;
73883
+ const path = materializeNodePath(state3, cursor.terminalNodeId);
73884
+ const name = getSegmentValue(state3.snapshot.segmentTable, terminalNode.nameId);
73885
+ const hasChildren = isDirectoryNode(terminalNode) && getDirectoryIndex(state3, cursor.terminalNodeId).childIds.length > 0;
73390
73886
  const isFlattened = cursor.headNodeId !== cursor.terminalNodeId;
73391
- const instrumentation = state2.instrumentation;
73392
- const flattenedSegments = isFlattened ? instrumentation == null ? collectFlattenedDirectoryChainIds(state2, cursor.headNodeId).map((nodeId) => {
73393
- const node = requireNode(state2, nodeId);
73887
+ const instrumentation = state3.instrumentation;
73888
+ const flattenedSegments = isFlattened ? instrumentation == null ? collectFlattenedDirectoryChainIds(state3, cursor.headNodeId).map((nodeId) => {
73889
+ const node = requireNode(state3, nodeId);
73394
73890
  return {
73395
73891
  isTerminal: nodeId === cursor.terminalNodeId,
73396
- name: getSegmentValue(state2.snapshot.segmentTable, node.nameId),
73892
+ name: getSegmentValue(state3.snapshot.segmentTable, node.nameId),
73397
73893
  nodeId,
73398
- path: materializeNodePath(state2, nodeId)
73894
+ path: materializeNodePath(state3, nodeId)
73399
73895
  };
73400
- }) : withBenchmarkPhase(instrumentation, "store.getVisibleSlice.flatten.collectSegments", () => collectFlattenedDirectoryChainIds(state2, cursor.headNodeId).map((nodeId) => {
73401
- const node = requireNode(state2, nodeId);
73896
+ }) : withBenchmarkPhase(instrumentation, "store.getVisibleSlice.flatten.collectSegments", () => collectFlattenedDirectoryChainIds(state3, cursor.headNodeId).map((nodeId) => {
73897
+ const node = requireNode(state3, nodeId);
73402
73898
  return {
73403
73899
  isTerminal: nodeId === cursor.terminalNodeId,
73404
- name: getSegmentValue(state2.snapshot.segmentTable, node.nameId),
73900
+ name: getSegmentValue(state3.snapshot.segmentTable, node.nameId),
73405
73901
  nodeId,
73406
- path: materializeNodePath(state2, nodeId)
73902
+ path: materializeNodePath(state3, nodeId)
73407
73903
  };
73408
73904
  })) : void 0;
73409
73905
  return {
@@ -73411,7 +73907,7 @@ function materializeVisibleRow(state2, cursor) {
73411
73907
  flattenedSegments,
73412
73908
  hasChildren,
73413
73909
  id: cursor.terminalNodeId,
73414
- isExpanded: isDirectoryNode(terminalNode) && isDirectoryExpanded(state2, cursor.terminalNodeId, terminalNode),
73910
+ isExpanded: isDirectoryNode(terminalNode) && isDirectoryExpanded(state3, cursor.terminalNodeId, terminalNode),
73415
73911
  isFlattened,
73416
73912
  isLoading: loadState === "loading",
73417
73913
  kind: isDirectoryNode(terminalNode) ? "directory" : "file",
@@ -73420,13 +73916,13 @@ function materializeVisibleRow(state2, cursor) {
73420
73916
  path
73421
73917
  };
73422
73918
  }
73423
- function getVisibleRowLoadState(state2, cursor) {
73424
- if (cursor.headNodeId === cursor.terminalNodeId) return getDirectoryLoadState(state2, cursor.terminalNodeId);
73425
- const chainNodeIds = collectFlattenedDirectoryChainIds(state2, cursor.headNodeId);
73919
+ function getVisibleRowLoadState(state3, cursor) {
73920
+ if (cursor.headNodeId === cursor.terminalNodeId) return getDirectoryLoadState(state3, cursor.terminalNodeId);
73921
+ const chainNodeIds = collectFlattenedDirectoryChainIds(state3, cursor.headNodeId);
73426
73922
  let hasUnloaded = false;
73427
73923
  let hasError = false;
73428
73924
  for (const nodeId of chainNodeIds) {
73429
- const loadState = getDirectoryLoadState(state2, nodeId);
73925
+ const loadState = getDirectoryLoadState(state3, nodeId);
73430
73926
  if (loadState === "loading") return "loading";
73431
73927
  if (loadState === "error") {
73432
73928
  hasError = true;
@@ -73520,8 +74016,8 @@ function sweepOpenVisibleCountsSoa(store2) {
73520
74016
  }
73521
74017
 
73522
74018
  // node_modules/@pierre/trees/dist/path-store/src/store.js
73523
- function initializeOpenVisibleCounts(state2) {
73524
- const { directories, nodes, options, rootId, presortedDirectoryNodeIds } = state2.snapshot;
74019
+ function initializeOpenVisibleCounts(state3) {
74020
+ const { directories, nodes, options, rootId, presortedDirectoryNodeIds } = state3.snapshot;
73525
74021
  const flattenEmptyDirectories = options.flattenEmptyDirectories === true;
73526
74022
  const walkDirectory = (nodeId) => {
73527
74023
  const currentNode = nodes[nodeId];
@@ -73571,9 +74067,9 @@ function initializeOpenVisibleCounts(state2) {
73571
74067
  rootNode.subtreeNodeCount = 1 + rootTotalChildSubtreeNodeCount;
73572
74068
  rootNode.visibleSubtreeCount = rootTotalChildVisibleSubtreeCount;
73573
74069
  }
73574
- function initializeOpenVisibleCountsViaSoa(state2) {
73575
- const { directories, nodes, rootId } = state2.snapshot;
73576
- const soa = buildSoaNodeStore(state2.snapshot);
74070
+ function initializeOpenVisibleCountsViaSoa(state3) {
74071
+ const { directories, nodes, rootId } = state3.snapshot;
74072
+ const soa = buildSoaNodeStore(state3.snapshot);
73577
74073
  sweepOpenVisibleCountsSoa(soa);
73578
74074
  const subtreeNodeCount = soa.subtreeNodeCount;
73579
74075
  const visibleSubtreeCount = soa.visibleSubtreeCount;
@@ -76697,17 +77193,17 @@ function RenameInput({ ariaLabel, isFlattened = false, ref, value, onBlur, onInp
76697
77193
 
76698
77194
  // node_modules/@pierre/trees/dist/render/rowAttributes.js
76699
77195
  function computeFileTreeRowElementAttributes(input) {
76700
- const { row, mode, targetPath, ariaLabel, domId, isParked, itemHeight, features, state: state2, extraStyle } = input;
77196
+ const { row, mode, targetPath, ariaLabel, domId, isParked, itemHeight, features, state: state3, extraStyle } = input;
76701
77197
  const isSticky = mode === "sticky";
76702
77198
  const parentPath = row.ancestorPaths.at(-1) ?? "";
76703
77199
  const stateAttributes = {};
76704
- if (state2.isFocusRinged) stateAttributes["data-item-focused"] = true;
77200
+ if (state3.isFocusRinged) stateAttributes["data-item-focused"] = true;
76705
77201
  if (row.isSelected) stateAttributes["data-item-selected"] = true;
76706
- if (state2.isContextHovered) stateAttributes["data-item-context-hover"] = "true";
76707
- if (state2.isDragTarget) stateAttributes["data-item-drag-target"] = true;
76708
- if (state2.isDragging) stateAttributes["data-item-dragging"] = true;
76709
- if (state2.effectiveGitStatus != null) stateAttributes["data-item-git-status"] = state2.effectiveGitStatus;
76710
- if (state2.containsGitChange) stateAttributes["data-item-contains-git-change"] = "true";
77202
+ if (state3.isContextHovered) stateAttributes["data-item-context-hover"] = "true";
77203
+ if (state3.isDragTarget) stateAttributes["data-item-drag-target"] = true;
77204
+ if (state3.isDragging) stateAttributes["data-item-dragging"] = true;
77205
+ if (state3.effectiveGitStatus != null) stateAttributes["data-item-git-status"] = state3.effectiveGitStatus;
77206
+ if (state3.containsGitChange) stateAttributes["data-item-contains-git-change"] = "true";
76711
77207
  return {
76712
77208
  "aria-expanded": !isSticky && row.kind === "directory" ? row.isExpanded : void 0,
76713
77209
  "aria-haspopup": features.contextMenuEnabled ? "menu" : void 0,
@@ -79513,6 +80009,7 @@ function define2() {
79513
80009
  define2();
79514
80010
  export {
79515
80011
  Emitter,
80012
+ Panels,
79516
80013
  SliccAgents,
79517
80014
  SliccApp,
79518
80015
  SliccApprovals,
@@ -79536,6 +80033,7 @@ export {
79536
80033
  confirm,
79537
80034
  define2 as define,
79538
80035
  grammarBase,
80036
+ panelCommand,
79539
80037
  prompt,
79540
80038
  resolveColor,
79541
80039
  setGrammarBase,