@ai-ecoverse/slicc-spectrum 1.86.1 → 1.86.3

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.
Binary file
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SliccTerminal,
3
3
  define
4
- } from "./chunk-ZGJM5WUN.js";
4
+ } from "./chunk-SQG7U2FN.js";
5
5
  import {
6
6
  kernelBackend
7
7
  } from "./chunk-XYPGNJAO.js";
package/dist/slicc-ui.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  } from "./chunk-EN3XGF2M.js";
25
25
  import {
26
26
  define
27
- } from "./chunk-ZGJM5WUN.js";
27
+ } from "./chunk-SQG7U2FN.js";
28
28
  import {
29
29
  isVaultFailure,
30
30
  nameProblem,
@@ -10052,6 +10052,87 @@ function search(options) {
10052
10052
  ></sp-search>`;
10053
10053
  }
10054
10054
 
10055
+ // src/app/view-state.ts
10056
+ var stores = /* @__PURE__ */ new WeakMap();
10057
+ var loose = {};
10058
+ function slotOf(model, key2, initial) {
10059
+ const owner = model ?? loose;
10060
+ const slots = stores.get(owner) ?? /* @__PURE__ */ new Map();
10061
+ stores.set(owner, slots);
10062
+ const found = slots.get(key2);
10063
+ if (found) return found;
10064
+ const slot = { value: initial(), listeners: /* @__PURE__ */ new Set() };
10065
+ slots.set(key2, slot);
10066
+ return slot;
10067
+ }
10068
+ var ViewState = class {
10069
+ #host;
10070
+ #key;
10071
+ #initial;
10072
+ #watched = null;
10073
+ #connected = false;
10074
+ #listener = () => this.#host.requestUpdate();
10075
+ constructor(host4, key2, initial) {
10076
+ this.#host = host4;
10077
+ this.#key = key2;
10078
+ this.#initial = initial;
10079
+ host4.addController(this);
10080
+ }
10081
+ #slot() {
10082
+ const model = this.#host.model;
10083
+ return slotOf(model, this.#key, () => this.#initial(model));
10084
+ }
10085
+ get value() {
10086
+ return this.#slot().value;
10087
+ }
10088
+ set value(value) {
10089
+ const slot = this.#slot();
10090
+ if (Object.is(slot.value, value)) return;
10091
+ slot.value = value;
10092
+ for (const listener of [...slot.listeners]) listener();
10093
+ }
10094
+ #watch() {
10095
+ const slot = this.#slot();
10096
+ if (slot === this.#watched) return;
10097
+ this.#unwatch();
10098
+ slot.listeners.add(this.#listener);
10099
+ this.#watched = slot;
10100
+ }
10101
+ #unwatch() {
10102
+ this.#watched?.listeners.delete(this.#listener);
10103
+ this.#watched = null;
10104
+ }
10105
+ hostConnected() {
10106
+ this.#connected = true;
10107
+ this.#watch();
10108
+ }
10109
+ hostUpdate() {
10110
+ if (this.#connected) this.#watch();
10111
+ }
10112
+ hostDisconnected() {
10113
+ this.#connected = false;
10114
+ this.#unwatch();
10115
+ }
10116
+ };
10117
+ var ViewSet = class extends ViewState {
10118
+ constructor(host4, key2, initial = () => []) {
10119
+ super(host4, key2, (model) => new Set(initial(model)));
10120
+ }
10121
+ has(id) {
10122
+ return this.value.has(id);
10123
+ }
10124
+ toggle(id, open = !this.has(id)) {
10125
+ if (open === this.has(id)) return;
10126
+ const next = new Set(this.value);
10127
+ if (open) next.add(id);
10128
+ else next.delete(id);
10129
+ this.value = next;
10130
+ }
10131
+ details(id) {
10132
+ return (event2) => this.toggle(id, event2.currentTarget.open);
10133
+ }
10134
+ };
10135
+
10055
10136
  // src/app/files.ts
10056
10137
  function relative(path) {
10057
10138
  return path.replace(/^\//, "");
@@ -10203,6 +10284,8 @@ var SliccFiles = class extends ModelElement {
10203
10284
  #entries = [];
10204
10285
  #pending = false;
10205
10286
  #reveal = null;
10287
+ #folders = new ViewState(this, "files", () => null);
10288
+ #applied = null;
10206
10289
  constructor() {
10207
10290
  super();
10208
10291
  this.count = 0;
@@ -10358,7 +10441,8 @@ var SliccFiles = class extends ModelElement {
10358
10441
  const tree = this.#tree();
10359
10442
  const changes2 = this.model ? changesOf(this.model).changes() : [];
10360
10443
  if (!tree) return;
10361
- if (tree.paths.length === 0) tree.expanded = ancestors(changes2.map((change) => change.path));
10444
+ if (tree.paths.length === 0)
10445
+ tree.expanded = this.#folders.value ?? ancestors(changes2.map((change) => change.path));
10362
10446
  tree.paths = treePaths(this.#entries);
10363
10447
  tree.gitStatus = treeStatus(changes2);
10364
10448
  this.#show();
@@ -10528,8 +10612,20 @@ var SliccFiles = class extends ModelElement {
10528
10612
  @tree-search=${this.#seed}
10529
10613
  @tree-matches=${this.#matches}
10530
10614
  @tree-search-close=${this.#closed}
10615
+ @tree-expand=${this.#expand}
10531
10616
  ></slicc-file-tree>`;
10532
10617
  }
10618
+ #expand(event2) {
10619
+ this.#applied = event2.detail.expanded;
10620
+ this.#folders.value = event2.detail.expanded;
10621
+ }
10622
+ updated() {
10623
+ const folders = this.#folders.value;
10624
+ const tree = this.#tree();
10625
+ if (!folders || folders === this.#applied || !tree?.paths.length) return;
10626
+ this.#applied = folders;
10627
+ tree.expanded = folders;
10628
+ }
10533
10629
  };
10534
10630
  var SliccFileView = class extends ThemedElement {
10535
10631
  static properties = {
@@ -10995,14 +11091,19 @@ function attention(section) {
10995
11091
  var SliccMonitor = class extends ModelElement {
10996
11092
  static properties = {
10997
11093
  ...ModelElement.properties,
10998
- expanded: { state: true },
10999
11094
  copied: { state: true }
11000
11095
  };
11096
+ #sections = new ViewState(this, "monitor", () => ({}));
11001
11097
  constructor() {
11002
11098
  super();
11003
- this.expanded = {};
11004
11099
  this.copied = null;
11005
11100
  }
11101
+ get expanded() {
11102
+ return this.#sections.value;
11103
+ }
11104
+ set expanded(value) {
11105
+ this.#sections.value = value;
11106
+ }
11006
11107
  static styles = [
11007
11108
  shared,
11008
11109
  panelCss,
@@ -11460,7 +11561,8 @@ function fillShown(fill2) {
11460
11561
  }
11461
11562
  var SliccAgents = class extends ModelElement {
11462
11563
  static properties = { ...ModelElement.properties, errors: { state: true } };
11463
- #expanded = /* @__PURE__ */ new Set();
11564
+ #expanded = new ViewSet(this, "agents");
11565
+ #revealed = new ViewState(this, "agents:revealed", () => "");
11464
11566
  #pointer = false;
11465
11567
  #modality = (event2) => {
11466
11568
  this.#pointer = event2.type === "pointerdown";
@@ -11731,16 +11833,16 @@ var SliccAgents = class extends ModelElement {
11731
11833
  #reveal(model) {
11732
11834
  const focused2 = model.agent.list().find((agent) => agent.id === model.agent.active());
11733
11835
  const cone = focused2?.kind === "cone" ? focused2.id : focused2?.parentId;
11734
- if (cone) this.#expanded.add(cone);
11836
+ if (!cone || focused2?.id === this.#revealed.value) return;
11837
+ this.#revealed.value = focused2?.id;
11838
+ this.#expanded.toggle(cone, true);
11735
11839
  }
11736
11840
  #select(agent) {
11737
11841
  this.model?.agent.select(agent.id);
11738
11842
  if (agent.kind === "cone") this.#toggle(agent, true);
11739
11843
  }
11740
11844
  #toggle(agent, open = !this.#expanded.has(agent.id)) {
11741
- if (open) this.#expanded.add(agent.id);
11742
- else this.#expanded.delete(agent.id);
11743
- this.requestUpdate();
11845
+ this.#expanded.toggle(agent.id, open);
11744
11846
  }
11745
11847
  focus() {
11746
11848
  this.focusOn('li[tabindex="0"]');
@@ -13783,6 +13885,7 @@ var SliccNetwork = class extends ModelElement {
13783
13885
  guestError: { state: true },
13784
13886
  guestsOff: { state: true }
13785
13887
  };
13888
+ #open = new ViewSet(this, "network");
13786
13889
  #leaderId = "";
13787
13890
  #guestId = "";
13788
13891
  constructor() {
@@ -14500,7 +14603,7 @@ var SliccNetwork = class extends ModelElement {
14500
14603
  </div>
14501
14604
  ${this.#permission(port, links)}
14502
14605
  ${links.devices.length ? b`<ul aria-labelledby="links">${links.devices.map((device) => this.#device(port, status2, device))}</ul>
14503
- <details><summary>Link another device</summary><div>${this.#join(port, links)}</div></details>` : this.#join(port, links)}
14606
+ <details ?open=${this.#open.has("link")} @toggle=${this.#open.details("link")}><summary>Link another device</summary><div>${this.#join(port, links)}</div></details>` : this.#join(port, links)}
14504
14607
  ${this.linksError ? b`<div class="error" role="alert" data-error="links"><swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle><span>${this.linksError}</span></div>` : A}
14505
14608
  </section>`;
14506
14609
  }
@@ -14699,7 +14802,7 @@ var SliccNetwork = class extends ModelElement {
14699
14802
  }
14700
14803
  #whole(status2) {
14701
14804
  if (wholeWeb.has(routeOf(status2))) {
14702
- return b`<details><summary>Other ways to reach the whole web</summary><div>${this.#ways(status2)}</div></details>`;
14805
+ return b`<details ?open=${this.#open.has("whole")} @toggle=${this.#open.details("whole")}><summary>Other ways to reach the whole web</summary><div>${this.#ways(status2)}</div></details>`;
14703
14806
  }
14704
14807
  return b`<section aria-labelledby="whole">
14705
14808
  <h2 id="whole">Get the whole web</h2>
@@ -31832,7 +31935,7 @@ function lick(message, handlers, stamp = true, pile = flatPile) {
31832
31935
  b`<div class="lick-frame"><div class="lick" data-id=${message.id} data-channel=${message.channel} data-severity=${message.severity ?? A}><div class="lick-head">${head2}</div></div>${reaction}</div>`
31833
31936
  );
31834
31937
  }
31835
- const details = b`<details class="lick" data-id=${message.id} data-channel=${message.channel} data-severity=${message.severity ?? A}>
31938
+ const details = b`<details class="lick" data-id=${message.id} data-channel=${message.channel} data-severity=${message.severity ?? A} ?open=${handlers.licks?.has(message.id) ?? false} @toggle=${handlers.licks?.details(message.id) ?? A}>
31836
31939
  <summary class="lick-head">${head2}<swc-icon-chevron-right class="chevron" size="s" aria-hidden="true"></swc-icon-chevron-right></summary>
31837
31940
  <pre class="output">${message.body}</pre>
31838
31941
  </details>`;
@@ -32865,6 +32968,7 @@ var SliccUpdates = class extends ModelElement {
32865
32968
  busy: { state: true },
32866
32969
  problems: { state: true }
32867
32970
  };
32971
+ #logs = new ViewSet(this, "updates");
32868
32972
  constructor() {
32869
32973
  super();
32870
32974
  this.pending = /* @__PURE__ */ new Set();
@@ -33244,7 +33348,7 @@ var SliccUpdates = class extends ModelElement {
33244
33348
  <span>${error}</span>
33245
33349
  </div>` : A}
33246
33350
  ${this.#actions(item2)}
33247
- ${item2.log ? b`<details><summary>Install log</summary><pre>${item2.log}</pre></details>` : A}
33351
+ ${item2.log ? b`<details ?open=${this.#logs.has(`item:${item2.id}`)} @toggle=${this.#logs.details(`item:${item2.id}`)}><summary>Install log</summary><pre>${item2.log}</pre></details>` : A}
33248
33352
  </article>`;
33249
33353
  }
33250
33354
  #packageMeta(item2, all2) {
@@ -33318,7 +33422,7 @@ var SliccUpdates = class extends ModelElement {
33318
33422
  <swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle>
33319
33423
  <span>${error}</span>
33320
33424
  </div>` : A}
33321
- ${item2.log ? b`<details><summary>Install log</summary><pre><span class="package">${item2.package}</span>\n${item2.log}</pre></details>` : A}
33425
+ ${item2.log ? b`<details ?open=${this.#logs.has(`package:${item2.id}`)} @toggle=${this.#logs.details(`package:${item2.id}`)}><summary>Install log</summary><pre><span class="package">${item2.package}</span>\n${item2.log}</pre></details>` : A}
33322
33426
  </li>`;
33323
33427
  }
33324
33428
  #list(items, all2, port) {
@@ -35271,7 +35375,9 @@ var SliccBrowser = class extends ModelElement {
35271
35375
  #last = null;
35272
35376
  #shown = actionPage;
35273
35377
  #anchor = null;
35274
- #expanded = /* @__PURE__ */ new Set();
35378
+ #expanded = new ViewSet(this, "browser");
35379
+ #recent = new ViewState(this, "browser:recent", () => false);
35380
+ #chosen = new ViewState(this, "browser:tab", () => void 0);
35275
35381
  constructor() {
35276
35382
  super();
35277
35383
  this.address = "";
@@ -35742,7 +35848,6 @@ var SliccBrowser = class extends ModelElement {
35742
35848
  this.#shots.clear();
35743
35849
  this.#frames.clear();
35744
35850
  this.#pulse.clear();
35745
- this.#expanded.clear();
35746
35851
  this.#shown = actionPage;
35747
35852
  const tabs = model.browser.list();
35748
35853
  this.#driven = new Set(tabs.filter((tab) => tab.controlled).map((tab) => tab.id));
@@ -35805,7 +35910,10 @@ var SliccBrowser = class extends ModelElement {
35805
35910
  this.#driven = driven;
35806
35911
  const ids = new Set(tabs.map((tab) => tab.id));
35807
35912
  for (const id of this.#frames.keys()) if (!ids.has(id)) this.#frames.delete(id);
35808
- if (this.#focus && !ids.has(this.#focus)) this.#show(null);
35913
+ if (this.#focus && !ids.has(this.#focus)) {
35914
+ this.#show(null);
35915
+ this.#chosen.value = void 0;
35916
+ }
35809
35917
  this.#stale();
35810
35918
  this.requestUpdate();
35811
35919
  }
@@ -35859,11 +35967,22 @@ var SliccBrowser = class extends ModelElement {
35859
35967
  return shot ?? null;
35860
35968
  }
35861
35969
  #show(id) {
35970
+ this.#chosen.value = id;
35971
+ this.#visit(id);
35972
+ this.requestUpdate();
35973
+ }
35974
+ #visit(id) {
35862
35975
  this.#focus = id;
35863
35976
  this.#copied = null;
35864
35977
  this.#shown = actionPage;
35865
35978
  if (id) this.#pulse.delete(id);
35866
- this.requestUpdate();
35979
+ }
35980
+ willUpdate(changed) {
35981
+ super.willUpdate(changed);
35982
+ const chosen = this.#chosen.value;
35983
+ if (chosen === void 0 || chosen === this.#focus) return;
35984
+ if (chosen === null || this.model?.browser.list().some((tab) => tab.id === chosen))
35985
+ this.#visit(chosen);
35867
35986
  }
35868
35987
  #focused() {
35869
35988
  return this.model?.browser.list().find((tab) => tab.id === this.#focus);
@@ -36021,8 +36140,7 @@ var SliccBrowser = class extends ModelElement {
36021
36140
  this.requestUpdate();
36022
36141
  }
36023
36142
  #toggle(id) {
36024
- if (!this.#expanded.delete(id)) this.#expanded.add(id);
36025
- this.requestUpdate();
36143
+ this.#expanded.toggle(id);
36026
36144
  }
36027
36145
  #what(action) {
36028
36146
  const url = linked.has(action.kind) ? action.value : void 0;
@@ -36052,7 +36170,7 @@ var SliccBrowser = class extends ModelElement {
36052
36170
  if (this.#width >= narrowWidth)
36053
36171
  return b`<h3>Recent actions</h3>${more}<ol class="actions" aria-label="Recent actions" tabindex="0">${actions2.map((action) => this.#row(action))}</ol>`;
36054
36172
  const last = actions2.at(-1);
36055
- return b`<details>
36173
+ return b`<details ?open=${this.#recent.value} @toggle=${(event2) => this.#recent.value = event2.currentTarget.open}>
36056
36174
  <summary><swc-icon-chevron-right class="chevron" size="s" aria-hidden="true"></swc-icon-chevron-right>Recent actions (${all2.length})</summary>
36057
36175
  ${more}
36058
36176
  <ol class="actions" aria-label="Earlier actions" tabindex="0">${actions2.slice(0, -1).map((action) => this.#row(action))}</ol>
@@ -37192,7 +37310,9 @@ var SliccChat = class extends ThemedElement {
37192
37310
  }
37193
37311
  `
37194
37312
  ];
37313
+ #licks = new ViewSet(this, "chat:licks");
37195
37314
  #handlers = {
37315
+ licks: this.#licks,
37196
37316
  color: "light",
37197
37317
  model: null,
37198
37318
  readOnly: false,
@@ -40051,17 +40171,22 @@ var SliccMemory = class extends ModelElement {
40051
40171
  query: { state: true },
40052
40172
  tag: { state: true },
40053
40173
  scope: { state: true },
40054
- open: { state: true },
40055
40174
  editing: { state: true }
40056
40175
  };
40176
+ #open = new ViewState(this, "memory", () => null);
40057
40177
  constructor() {
40058
40178
  super();
40059
40179
  this.query = "";
40060
40180
  this.tag = "all";
40061
40181
  this.scope = everyone;
40062
- this.open = null;
40063
40182
  this.editing = null;
40064
40183
  }
40184
+ get open() {
40185
+ return this.#open.value;
40186
+ }
40187
+ set open(value) {
40188
+ this.#open.value = value;
40189
+ }
40065
40190
  static styles = [
40066
40191
  shared,
40067
40192
  panelCss,
@@ -40708,6 +40833,7 @@ var SliccSecrets = class extends ThemedElement {
40708
40833
  picked: { state: true },
40709
40834
  again: { state: true }
40710
40835
  };
40836
+ #removed = new ViewState(this, "settings:removed", () => false);
40711
40837
  #tick;
40712
40838
  #offline = false;
40713
40839
  constructor() {
@@ -41516,7 +41642,7 @@ var SliccSecrets = class extends ThemedElement {
41516
41642
  const live = sorted.filter((secret) => secret.state !== "removed");
41517
41643
  const removed = sorted.filter((secret) => secret.state === "removed");
41518
41644
  return b`${live.length ? b`<ul class="secrets" aria-labelledby="secrets">${live.map(row)}</ul>` : A}
41519
- ${removed.length ? b`<details class="removed" data-removed>
41645
+ ${removed.length ? b`<details class="removed" data-removed ?open=${this.#removed.value} @toggle=${(event2) => this.#removed.value = event2.currentTarget.open}>
41520
41646
  <summary>Removed (${removed.length})</summary>
41521
41647
  <ul class="secrets">${removed.map(row)}</ul>
41522
41648
  </details>` : A}`;
@@ -42758,7 +42884,6 @@ ${data.html}`;
42758
42884
  };
42759
42885
 
42760
42886
  // src/app/tool-runs.ts
42761
- var opened = /* @__PURE__ */ new Map();
42762
42887
  var caches = /* @__PURE__ */ new WeakMap();
42763
42888
  function cache(port) {
42764
42889
  const found = caches.get(port);
@@ -42775,6 +42900,7 @@ var SliccToolRuns = class extends i2 {
42775
42900
  model: { attribute: false },
42776
42901
  owners: { attribute: false }
42777
42902
  };
42903
+ #opened = new ViewState(this, "chat:runs", () => /* @__PURE__ */ new Map());
42778
42904
  #icons = null;
42779
42905
  #count = 0;
42780
42906
  #resize = new ResizeObserver(() => this.#end());
@@ -42804,12 +42930,13 @@ var SliccToolRuns = class extends i2 {
42804
42930
  return this.calls.map((call) => call.id).join(" ");
42805
42931
  }
42806
42932
  get #open() {
42807
- return opened.get(this.#anchor) ?? "";
42933
+ return this.#opened.value.get(this.#anchor) ?? "";
42808
42934
  }
42809
42935
  #set(value) {
42810
- if (value) opened.set(this.#anchor, value);
42811
- else opened.delete(this.#anchor);
42812
- this.requestUpdate();
42936
+ const next = new Map(this.#opened.value);
42937
+ if (value) next.set(this.#anchor, value);
42938
+ else next.delete(this.#anchor);
42939
+ this.#opened.value = next;
42813
42940
  }
42814
42941
  #toggled(call, event2) {
42815
42942
  const open = event2.currentTarget.open;
@@ -85330,11 +85457,13 @@ var SliccFileTree = class extends HTMLElement {
85330
85457
  #expanded = [];
85331
85458
  #mount = null;
85332
85459
  #query = "";
85460
+ #chosen = [];
85461
+ #applying = false;
85333
85462
  get paths() {
85334
85463
  return this.#paths;
85335
85464
  }
85336
85465
  set paths(value) {
85337
- const expanded = this.#paths.length > 0 ? this.#expandedNow() : this.#expanded;
85466
+ const expanded = this.#paths.length > 0 ? this.#held() : this.#expanded;
85338
85467
  this.#paths = value;
85339
85468
  this.#tree?.resetPaths(value, { initialExpandedPaths: expanded });
85340
85469
  this.#research();
@@ -85352,10 +85481,15 @@ var SliccFileTree = class extends HTMLElement {
85352
85481
  return this.#query;
85353
85482
  }
85354
85483
  set query(value) {
85484
+ const was = this.#query;
85355
85485
  this.#query = value;
85356
85486
  this.#tree?.setSearch(value || null);
85487
+ if (was && !value) this.expanded = this.#chosen;
85357
85488
  this.#matched();
85358
85489
  }
85490
+ #held() {
85491
+ return this.#query ? this.#chosen : this.#expandedNow();
85492
+ }
85359
85493
  get empty() {
85360
85494
  return this.hasAttribute("data-empty");
85361
85495
  }
@@ -85375,10 +85509,12 @@ var SliccFileTree = class extends HTMLElement {
85375
85509
  }
85376
85510
  #expandedNow() {
85377
85511
  const tree = this.#tree;
85378
- return this.#paths.filter((path) => {
85379
- const item2 = path.endsWith("/") ? tree?.getItem(path) : null;
85380
- return !!item2 && "isExpanded" in item2 && item2.isExpanded();
85381
- }).map((path) => path.slice(0, -1));
85512
+ const open = (path) => {
85513
+ const item2 = tree?.getItem(path);
85514
+ return item2 && "isExpanded" in item2 ? item2.isExpanded() : null;
85515
+ };
85516
+ const shown4 = (path) => path.split("/").slice(0, -2).every((_9, i26, parts2) => open(`${parts2.slice(0, i26 + 1).join("/")}/`) !== false);
85517
+ return this.#paths.filter((path) => path.endsWith("/") && open(path) === true && shown4(path)).map((path) => path.slice(0, -1));
85382
85518
  }
85383
85519
  get gitStatus() {
85384
85520
  return this.#status;
@@ -85392,6 +85528,36 @@ var SliccFileTree = class extends HTMLElement {
85392
85528
  }
85393
85529
  set expanded(value) {
85394
85530
  this.#expanded = value;
85531
+ this.#apply();
85532
+ }
85533
+ #apply() {
85534
+ const tree = this.#tree;
85535
+ if (!tree || this.#paths.length === 0) return;
85536
+ if (this.#query) {
85537
+ this.#chosen = this.#expanded;
85538
+ return;
85539
+ }
85540
+ const wanted = new Set(this.#expanded);
85541
+ this.#applying = true;
85542
+ for (const path of this.#paths) {
85543
+ const item2 = path.endsWith("/") ? tree.getItem(path) : null;
85544
+ if (!item2 || !("isExpanded" in item2)) continue;
85545
+ const open = wanted.has(path.slice(0, -1));
85546
+ if (item2.isExpanded() === open) continue;
85547
+ if (open) item2.expand();
85548
+ else item2.collapse();
85549
+ }
85550
+ this.#applying = false;
85551
+ this.#chosen = this.#expandedNow();
85552
+ }
85553
+ #changed() {
85554
+ if (this.#applying || !this.#tree || this.#query) return;
85555
+ const expanded = this.#expandedNow();
85556
+ if (expanded.join("\n") === this.#chosen.join("\n")) return;
85557
+ this.#chosen = expanded;
85558
+ this.dispatchEvent(
85559
+ new CustomEvent("tree-expand", { detail: { expanded }, bubbles: true, composed: true })
85560
+ );
85395
85561
  }
85396
85562
  get tree() {
85397
85563
  return this.#tree;
@@ -85418,9 +85584,12 @@ var SliccFileTree = class extends HTMLElement {
85418
85584
  onSearchChange: (value) => this.#searched(value)
85419
85585
  });
85420
85586
  this.#tree.render({ containerWrapper: this.#mount });
85587
+ this.#chosen = this.#query ? this.#expanded : this.#expandedNow();
85588
+ this.#tree.subscribe(() => this.#changed());
85421
85589
  this.#matched();
85422
85590
  }
85423
85591
  disconnectedCallback() {
85592
+ if (this.#paths.length > 0) this.#expanded = this.#held();
85424
85593
  this.#tree?.cleanUp();
85425
85594
  this.#tree = null;
85426
85595
  this.#mount?.replaceChildren();