glassbrain 0.2.0-alpha.7 → 0.2.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +6 -7
  2. package/dist/chunks/{chunk-GZSWZSSE.js → chunk-3CNHFYHG.js} +1317 -1650
  3. package/dist/chunks/chunk-7PWRJEZT.js +35 -0
  4. package/dist/chunks/chunk-CHOCJIOD.js +1340 -0
  5. package/dist/chunks/chunk-DHYIMBHU.js +960 -0
  6. package/dist/chunks/{chunk-FNTYI7VP.js → chunk-NDUF3CBQ.js} +340 -996
  7. package/dist/cli/glassbrain.js +338 -142
  8. package/dist/cli/viewer.js +218 -213
  9. package/dist/core.d.ts +1 -0
  10. package/dist/core.js +50 -30
  11. package/dist/diff.d.ts +9 -1
  12. package/dist/edit.d.ts +10 -0
  13. package/dist/index.js +57 -37
  14. package/dist/internal.d.ts +1 -0
  15. package/dist/internal.js +98 -76
  16. package/dist/layers.d.ts +3 -1
  17. package/dist/lint-report.d.ts +70 -0
  18. package/dist/profile.d.ts +10 -2
  19. package/dist/react/DetailPanel.d.ts +31 -1
  20. package/dist/react/DetailPanel.js +8 -4
  21. package/dist/react/EdgeMark.d.ts +22 -0
  22. package/dist/react/EditPanel.d.ts +6 -6
  23. package/dist/react/GraphCanvas.d.ts +17 -6
  24. package/dist/react/GraphCanvas.js +4 -4
  25. package/dist/react/Inspector.d.ts +72 -0
  26. package/dist/react/ObjectRef.d.ts +12 -0
  27. package/dist/react/Toolbar.d.ts +10 -3
  28. package/dist/react/ZoomBoundary.d.ts +4 -0
  29. package/dist/react/camera.d.ts +7 -0
  30. package/dist/react/i18n.d.ts +2 -2
  31. package/dist/react/icons.d.ts +7 -3
  32. package/dist/react/input.d.ts +5 -3
  33. package/dist/react/useSubgraph.d.ts +15 -0
  34. package/dist/shell.d.ts +1 -0
  35. package/dist/strings.d.ts +23 -2
  36. package/dist/style.d.ts +2 -0
  37. package/dist/subgraph.d.ts +13 -0
  38. package/dist/tree.d.ts +1 -0
  39. package/dist/view.d.ts +3 -1
  40. package/package.json +1 -1
  41. package/dist/chunks/chunk-3KUNYSJE.js +0 -246
  42. package/dist/chunks/chunk-LK77SYCN.js +0 -100
  43. package/dist/chunks/chunk-Q35ZKWKF.js +0 -99
  44. package/dist/react/GlassPlanes.d.ts +0 -11
@@ -1,7 +1,7 @@
1
1
  // src/tree.ts
2
2
  var object = (x) => !!x && typeof x === "object" && !Array.isArray(x);
3
3
  var ref = (x) => typeof x === "string" || typeof x === "number" ? String(x) : void 0;
4
- var stable = (x) => JSON.stringify(x, function(_key, value) {
4
+ var stableJson = (x) => JSON.stringify(x, function(_key, value) {
5
5
  return object(value) ? Object.fromEntries(Object.keys(value).sort().map((k) => [k, value[k]])) : value;
6
6
  });
7
7
  function treeDeclarations(raw, origin) {
@@ -67,12 +67,12 @@ function composeTrees(input) {
67
67
  if (!r.origins.includes(slice.origin)) r.origins.push(slice.origin);
68
68
  for (const [field, value] of [...Object.entries(d.fields), ...d.children === void 0 ? [] : [["children", d.children]]]) {
69
69
  const previous = field === "children" ? r.children : r.fields[field];
70
- if (r.locations.has(field) && stable(previous) !== stable(value)) {
70
+ if (r.locations.has(field) && stableJson(previous) !== stableJson(value)) {
71
71
  errors.push({
72
72
  origin: slice.origin,
73
73
  node: d.id,
74
74
  code: field === "children" ? "children-conflict" : "field-conflict",
75
- message: `"${d.id}".${field}: ${r.locations.get(field)} = ${stable(previous)} conflicts with ${d.path} = ${stable(value)}; provide one consistent value (lists are not combined).`
75
+ message: `"${d.id}".${field}: ${r.locations.get(field)} = ${stableJson(previous)} conflicts with ${d.path} = ${stableJson(value)}.`
76
76
  });
77
77
  } else if (!r.locations.has(field)) {
78
78
  if (field === "children") r.children = value;
@@ -264,128 +264,10 @@ function indexModel(model) {
264
264
  function originsOf(model) {
265
265
  const seen = /* @__PURE__ */ new Set();
266
266
  for (const n of model.nodes) for (const o of originsOfNode(n)) seen.add(o);
267
+ for (const e of model.edges) if (e.origin) seen.add(e.origin);
267
268
  return [...seen].sort();
268
269
  }
269
270
 
270
- // src/profile.ts
271
- function parsePhysical(origin, text) {
272
- let raw;
273
- try {
274
- raw = JSON.parse(text);
275
- } catch (e) {
276
- return { origin, title: origin, nodes: [], edges: [], error: e instanceof Error ? e.message : String(e) };
277
- }
278
- if (!raw || typeof raw !== "object" || !("nodes" in raw) && !("edges" in raw)) return null;
279
- const edges = (Array.isArray(raw.edges) ? raw.edges : []).filter((e) => e && typeof e === "object").map((e) => ({
280
- source: String(e.source ?? e.from),
281
- target: String(e.target ?? e.to),
282
- kind: typeof e.kind === "string" ? e.kind : void 0,
283
- label: typeof e.label === "string" ? e.label : void 0,
284
- weight: typeof e.weight === "number" ? e.weight : void 0,
285
- // The whole record, like nodes' `data`: fields the library does not know survive a round trip (convert, toPhysical).
286
- data: e
287
- }));
288
- const parsed = treeDeclarations(raw.nodes, origin);
289
- return { origin, title: String(raw.name ?? raw.title ?? origin), nodes: treeNodes(parsed.declarations), edges, ...parsed };
290
- }
291
- function toPhysical(model) {
292
- return serializeTree(model);
293
- }
294
- function toBundle(model, profile = null) {
295
- const palette = Object.assign(/* @__PURE__ */ Object.create(null), profile?.nodePalette ?? {});
296
- const wheel = ["#6366f1", "#f59e0b", "#10b981", "#ef4444", "#8b5cf6", "#06b6d4", "#ec4899", "#84cc16"];
297
- const kinds = [...new Set(model.nodes.map((n) => n.kind).filter((k) => !!k))];
298
- for (const [i, kind] of kinds.entries()) if (!Object.hasOwn(palette, kind)) palette[kind] = wheel[i % wheel.length];
299
- return { profile: { ...profile, nodePalette: palette }, ...toPhysical(model) };
300
- }
301
- var DEFAULT_LAYER = { id: "default", label: "Graph", z: 0, structural: true };
302
- function validateStructure(model) {
303
- const out = model.errors.map((e) => ({ kind: e.code ?? "schema", group: "Invalid graph", level: "error", nodeId: e.node, message: `${e.origin}: ${e.message}` }));
304
- const seen = /* @__PURE__ */ new Set();
305
- const dup = /* @__PURE__ */ new Set();
306
- for (const n of model.nodes) {
307
- if (seen.has(n.id)) dup.add(n.id);
308
- else seen.add(n.id);
309
- }
310
- for (const id of model.duplicateIds ?? []) dup.add(id);
311
- for (const id of dup) out.push({ kind: "duplicate", group: "Duplicate id", level: "warn", nodeId: id, message: `Duplicate node id: ${id} (defined more than once; the first one is kept)` });
312
- const seenEdge = /* @__PURE__ */ new Set();
313
- const dupEdge = /* @__PURE__ */ new Map();
314
- for (const e of model.edges) {
315
- const key = `${e.source}\0${e.target}\0${e.kind ?? ""}`;
316
- if (seenEdge.has(key)) dupEdge.set(key, e);
317
- else seenEdge.add(key);
318
- }
319
- for (const e of dupEdge.values()) {
320
- out.push({
321
- kind: "duplicate-edge",
322
- group: "Duplicate edge",
323
- level: "warn",
324
- edge: { source: e.source, target: e.target },
325
- message: `Duplicate edge: ${e.source} \u2192 ${e.target}${e.kind ? ` (${e.kind})` : ""} is defined more than once`
326
- });
327
- }
328
- for (const e of model.edges) {
329
- const miss = [!seen.has(e.source) && e.source, !seen.has(e.target) && e.target].filter(Boolean).join(" / ");
330
- if (miss) out.push({ kind: "dangling", group: "Dangling edge", level: "warn", edge: { source: e.source, target: e.target }, message: `Dangling edge: points to missing node ${miss}` });
331
- }
332
- return out;
333
- }
334
- function kindTable(...entries) {
335
- return Object.assign(/* @__PURE__ */ Object.create(null), ...entries);
336
- }
337
- function defineProfile(input) {
338
- const layers = input.layers?.length ? input.layers : [DEFAULT_LAYER];
339
- const fallbackLayer = layers[0].id;
340
- return {
341
- id: input.id,
342
- parse: input.parse ?? parsePhysical,
343
- merge: input.merge ?? mergeSlices,
344
- layers,
345
- layerOf: input.layerOf ?? ((n) => n.layer ?? fallbackLayer),
346
- nodePalette: kindTable(input.nodePalette),
347
- edgePalette: kindTable(input.edgePalette),
348
- nodeSize: kindTable(input.nodeSize),
349
- edgeWidth: kindTable(input.edgeWidth),
350
- placeholderFlags: input.placeholderFlags ?? [],
351
- style: input.style ?? [],
352
- nodeClass: input.nodeClass ?? (() => ""),
353
- edgeClass: input.edgeClass ?? ((e) => e.kind ?? ""),
354
- kindLabels: kindTable(input.kindLabels),
355
- detail: input.detail ?? {},
356
- validate: input.validate ?? (() => []),
357
- layoutEdge: input.layoutEdge ?? (() => false),
358
- singleRoot: input.singleRoot ?? true,
359
- rootLabel: input.rootLabel ?? "Overview"
360
- };
361
- }
362
- var defaultProfile = defineProfile({ id: "default" });
363
- function parseSources(sources, profile = defaultProfile) {
364
- const slices = [];
365
- for (const { origin, text } of sources) {
366
- const s = profile.parse(origin, text);
367
- if (!s) continue;
368
- slices.push({
369
- ...s,
370
- origin,
371
- nodes: s.nodes.map((n) => ({
372
- ...n,
373
- origin: n.origin ?? origin,
374
- origins: n.origins ?? [origin],
375
- layer: n.layer ?? profile.layerOf(n)
376
- })),
377
- edges: s.edges.map((e) => ({ ...e, origin: e.origin ?? origin }))
378
- });
379
- }
380
- const model = profile.merge(slices);
381
- const nodes = model.nodes.map((n) => n.layer ? n : { ...n, layer: profile.layerOf(n) });
382
- const out = buildModel(nodes, model.edges, model.errors);
383
- return model.duplicateIds ? { ...out, duplicateIds: model.duplicateIds } : out;
384
- }
385
- function validateModel(model, profile) {
386
- return [...validateStructure(model), ...profile.validate(model)];
387
- }
388
-
389
271
  // src/diff.ts
390
272
  var DIFF_FLAG = {
391
273
  added: "gb-added",
@@ -395,7 +277,7 @@ var DIFF_FLAG = {
395
277
  merged: "gb-merged"
396
278
  };
397
279
  var KEPT_FLAG = "gb-kept";
398
- var stable2 = (v, ignore) => {
280
+ var stable = (v, ignore) => {
399
281
  const walk = (x) => {
400
282
  if (Array.isArray(x)) return x.map(walk);
401
283
  if (x && typeof x === "object") {
@@ -413,7 +295,7 @@ function changedFields(a, b, ignore) {
413
295
  const ob = b ?? {};
414
296
  const keys = new Set([...Object.keys(oa), ...Object.keys(ob)].filter((k) => !ignore.has(k)));
415
297
  const out = [];
416
- for (const k of keys) if (stable2(oa[k], ignore) !== stable2(ob[k], ignore)) out.push(k);
298
+ for (const k of keys) if (stable(oa[k], ignore) !== stable(ob[k], ignore)) out.push(k);
417
299
  return out.sort();
418
300
  }
419
301
  var EDIT_CAP = 512;
@@ -448,10 +330,17 @@ function editDistance(a, b) {
448
330
  return prev[m] + over;
449
331
  }
450
332
  function changeAmount(a, b, fields, ignore) {
451
- const pick = (n) => fields.map((k) => stable2((n.data ?? {})[k], ignore)).join("\0");
333
+ const pick = (n) => fields.map((k) => stable((n.data ?? {})[k], ignore)).join("\0");
452
334
  return editDistance(pick(a), pick(b)) + editDistance(a.label ?? "", b.label ?? "");
453
335
  }
454
- var edgeKey = (e) => `${e.source} ${e.target} ${e.kind ?? ""}`;
336
+ var edgeKey = (e) => JSON.stringify([e.source, e.target, e.kind ?? ""]);
337
+ function edgeContent(edge) {
338
+ const { source, target, from, to, kind, ...data } = edge.data ?? {};
339
+ return { ...data, label: edge.label ?? data.label, weight: edge.weight ?? data.weight };
340
+ }
341
+ function edgeContentChanged(before, after, ignore) {
342
+ return stable(edgeContent(before), ignore) !== stable(edgeContent(after), ignore);
343
+ }
455
344
  var withFlag = (x, flag) => ({ ...x, flags: [...x.flags ?? [], flag] });
456
345
  function diffModels(before, after, opts = {}) {
457
346
  const ignore = new Set(opts.ignore ?? []);
@@ -565,7 +454,9 @@ function diffModels(before, after, opts = {}) {
565
454
  );
566
455
  const edges = [];
567
456
  for (const [k, e] of afterEdges) {
568
- edges.push(withFlag(e, beforeEdges.has(k) ? KEPT_FLAG : DIFF_FLAG.added));
457
+ const previous = beforeEdges.get(k);
458
+ const flag = !previous ? DIFF_FLAG.added : edgeContentChanged(previous, e, ignore) ? DIFF_FLAG.changed : KEPT_FLAG;
459
+ edges.push(withFlag(e, flag));
569
460
  }
570
461
  for (const [k, e] of beforeEdges) {
571
462
  if (afterEdges.has(k)) continue;
@@ -588,7 +479,9 @@ function diffModels(before, after, opts = {}) {
588
479
  prevData,
589
480
  labels,
590
481
  before,
591
- after
482
+ after,
483
+ ignore: opts.ignore,
484
+ options: opts
592
485
  };
593
486
  }
594
487
  function unionSides(d) {
@@ -673,19 +566,27 @@ function stepUnion(before, after, key = (n) => n.id) {
673
566
  after
674
567
  };
675
568
  }
569
+ function changedEdge(e) {
570
+ return !!e.flags?.some((f) => f === DIFF_FLAG.added || f === DIFF_FLAG.removed || f === DIFF_FLAG.changed);
571
+ }
676
572
  function hasChanges(d) {
677
- return d.changes.length > 0;
573
+ return d.changes.length > 0 || d.model.edges.some(changedEdge);
678
574
  }
679
575
  function changedSubset(d) {
680
576
  const keep = /* @__PURE__ */ new Set();
681
- for (const c of d.changes) {
682
- keep.add(c.id);
683
- if (c.pairId) keep.add(c.pairId);
684
- let p = d.model.index.get(c.id)?.parent;
685
- while (p && !keep.has(p)) {
686
- keep.add(p);
687
- p = d.model.index.get(p)?.parent;
577
+ const include = (id) => {
578
+ while (id && !keep.has(id)) {
579
+ keep.add(id);
580
+ id = d.model.index.get(id)?.parent;
688
581
  }
582
+ };
583
+ for (const c of d.changes) {
584
+ include(c.id);
585
+ include(c.pairId);
586
+ }
587
+ for (const edge of d.model.edges) if (changedEdge(edge)) {
588
+ include(edge.source);
589
+ include(edge.target);
689
590
  }
690
591
  return keep;
691
592
  }
@@ -873,130 +774,6 @@ function countByKind(model) {
873
774
  return out;
874
775
  }
875
776
 
876
- // src/view.ts
877
- var FULL_VIEW = {};
878
- function planeView(v, layers) {
879
- if (layers.length < 2) return v.planes || v.layers ? { ...v, planes: false, layers: null } : v;
880
- const stacked = v.planes !== false;
881
- const picked = layers.map((l) => l.id).filter((id) => v.layers?.includes(id));
882
- const want = stacked ? picked.length && picked.length < layers.length ? picked : null : v.layers && picked.length === 1 ? picked : null;
883
- const same = v.planes === stacked && (want === null ? v.layers === null : !!v.layers && want.length === v.layers.length && want.every((id, i) => id === v.layers[i]));
884
- return same ? v : { ...v, planes: stacked, layers: want };
885
- }
886
- function isFiltering(v) {
887
- return !!(v.origins && v.origins.length || v.layers && v.layers.length);
888
- }
889
- function isNarrowing(v) {
890
- return !!(v.origins && v.origins.length);
891
- }
892
- function originView(v, available) {
893
- if (!v.origins?.length) return v;
894
- const have = new Set(available);
895
- const kept = v.origins.filter((o) => have.has(o));
896
- if (kept.length === v.origins.length) return v;
897
- return { ...v, origins: kept.length ? kept : null };
898
- }
899
- var textOf = (data) => {
900
- if (typeof data === "string") return data;
901
- if (Array.isArray(data)) return data.map(textOf).join(" ");
902
- if (data && typeof data === "object") return Object.values(data).map(textOf).join(" ");
903
- return "";
904
- };
905
- function resolveView(model, elements, view) {
906
- const present = /* @__PURE__ */ new Set();
907
- for (const el of elements) if (!el.data.source) present.add(el.data.id);
908
- const hitsIn = (scope) => new Set(searchNodes(model, view.query ?? "", scope));
909
- if (!isFiltering(view)) {
910
- return { visible: present, hits: hitsIn(present) };
911
- }
912
- const idx = indexModel(model);
913
- const layers = view.layers?.length ? new Set(view.layers) : null;
914
- const origins = view.origins?.length ? new Set(view.origins) : null;
915
- const base = /* @__PURE__ */ new Set();
916
- for (const n of model.nodes) {
917
- if (!present.has(n.id)) continue;
918
- if (layers && !layers.has(n.layer ?? "")) continue;
919
- if (origins && !originsOfNode(n).some((o) => origins.has(o))) continue;
920
- base.add(n.id);
921
- }
922
- const visible = new Set(base);
923
- for (const id of base) for (const a of idx.ancestorsOf(id)) if (present.has(a)) visible.add(a);
924
- if (present.has(VIRTUAL_ROOT)) {
925
- let isCompoundRoot = false;
926
- let topVisible = 0;
927
- for (const el of elements) {
928
- if (el.data.source) {
929
- if (el.data.kind === "contains" && el.data.source === VIRTUAL_ROOT && visible.has(el.data.target)) topVisible++;
930
- } else if (el.data.parent === VIRTUAL_ROOT) {
931
- isCompoundRoot = true;
932
- if (visible.has(el.data.id)) topVisible++;
933
- }
934
- }
935
- if (isCompoundRoot || topVisible > 1) visible.add(VIRTUAL_ROOT);
936
- }
937
- return { visible, hits: hitsIn(base) };
938
- }
939
- function parseQuery(query) {
940
- const raw = query.trim();
941
- const m = /^\/(.+)\/$/.exec(raw);
942
- if (m) {
943
- try {
944
- return { re: new RegExp(m[1], "i"), phrase: "", words: [] };
945
- } catch {
946
- }
947
- }
948
- const phrase = raw.toLowerCase();
949
- return { re: null, phrase, words: phrase ? [...new Set(phrase.split(/\s+/))] : [] };
950
- }
951
- function queryMarker(query) {
952
- const { re, phrase, words } = parseQuery(query);
953
- if (re) return new RegExp(re.source, "gi");
954
- if (!phrase) return null;
955
- const esc = (w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
956
- const alts = [phrase, ...words.filter((w) => w !== phrase)].sort((a, b) => b.length - a.length);
957
- return new RegExp(alts.map(esc).join("|"), "gi");
958
- }
959
- function searchNodes(model, query, scope) {
960
- const { re, phrase: q, words } = parseQuery(query);
961
- if (!re && !q) return [];
962
- const ids = scope ? scope : model.nodes.map((n) => n.id);
963
- const ranked = [];
964
- let best = 0;
965
- for (const id of ids) {
966
- if (id === VIRTUAL_ROOT) continue;
967
- const n = model.index.get(id);
968
- if (!n) continue;
969
- let tier = -1;
970
- let k = 1;
971
- if (re) {
972
- const m = re.exec(n.label);
973
- tier = m ? m.index > 0 ? 2 : m[0].length === n.label.length ? 0 : 1 : re.test(n.id) ? 3 : re.test(textOf(n.data)) ? 4 : -1;
974
- } else {
975
- const label = n.label.toLowerCase();
976
- tier = label === q ? 0 : label.startsWith(q) ? 1 : label.includes(q) ? 2 : n.id.toLowerCase().includes(q) ? 3 : -1;
977
- let text = null;
978
- const rest = () => text ?? (text = `${n.id} ${textOf(n.data)}`.toLowerCase());
979
- if (tier < 0 && rest().includes(q)) tier = 4;
980
- if (tier >= 0) k = words.length;
981
- else if (words.length > 1) {
982
- let inLabel = 0;
983
- k = 0;
984
- for (const w of words) {
985
- if (label.includes(w)) {
986
- k++;
987
- inLabel++;
988
- } else if (rest().includes(w)) k++;
989
- }
990
- if (k) tier = inLabel === k ? 5 : 6;
991
- }
992
- }
993
- if (tier < 0) continue;
994
- if (k > best) best = k;
995
- ranked.push([k, tier, n.label.length, id]);
996
- }
997
- return ranked.filter((r) => r[0] === best).sort((a, b) => a[1] - b[1] || a[2] - b[2] || (a[3] < b[3] ? -1 : a[3] > b[3] ? 1 : 0)).map((r) => r[3]);
998
- }
999
-
1000
777
  // src/style.ts
1001
778
  var PLANE_HUES = ["#64748b", "#6366f1", "#14b8a6", "#ef4444"];
1002
779
  var plateColors = (theme, hue) => ({
@@ -1298,6 +1075,8 @@ function chromeStyle(theme) {
1298
1075
  border: "#1e293b",
1299
1076
  panel: `${theme.canvas}e6`,
1300
1077
  panel2: theme.canvas,
1078
+ surface: `color-mix(in srgb, ${theme.canvas} 94%, white)`,
1079
+ rim: "rgba(226,232,240,.16)",
1301
1080
  tint: "#1e293b",
1302
1081
  active: "#1e3a5f",
1303
1082
  accent: "#38bdf8",
@@ -1316,8 +1095,11 @@ function chromeStyle(theme) {
1316
1095
  ...Object.fromEntries(Object.entries(colors).map(([key, value]) => [`--gb-default-${key}`, dark ? value : "initial"]))
1317
1096
  };
1318
1097
  }
1098
+ var HOVER_FADE_MS = 160;
1319
1099
  var GK_CSS = `
1320
- .gb-root { display:flex; height:100%; min-height:0; font-family: var(--gb-font, ui-sans-serif, system-ui, sans-serif);
1100
+ /* Apply at scroll containers too: browsers resolve touch-action at gesture start. */
1101
+ :where([data-gb-zoom-boundary], [data-gb-zoom-boundary] *) { touch-action:pan-x pan-y; }
1102
+ .gb-root { --gb-ease:cubic-bezier(.2,.8,.3,1); --gb-ease-out:cubic-bezier(.4,0,.6,1); display:flex; height:100%; min-height:0; font-family: var(--gb-font, ui-sans-serif, system-ui, sans-serif);
1321
1103
  color: var(--gb-text, var(--gb-default-text,#1f2937)); position:relative; container-type:inline-size; container-name:gk; }
1322
1104
  .gb-stage { flex:1; min-width:0; position:relative; container-type:inline-size; container-name:gks; }
1323
1105
  .gb-scene, .gb-canvas { position:absolute; inset:0; }
@@ -1335,8 +1117,7 @@ var GK_CSS = `
1335
1117
  * the seam is the only place empty in both columns, and left-then-right reads as "before \u2192 now". */
1336
1118
  .gb-pane-tag { position:absolute; bottom:12px; right:12px; z-index:6; pointer-events:none;
1337
1119
  font-size:11px; font-weight:600; letter-spacing:.02em; color: var(--gb-muted,var(--gb-default-muted,#64748b));
1338
- background: var(--gb-panel,var(--gb-default-panel,rgba(255,255,255,.88))); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0));
1339
- border-radius:var(--gb-r-face,10px); padding:3px 8px; }
1120
+ padding:3px 8px; }
1340
1121
  .gb-pane-now { color: var(--gb-text,var(--gb-default-text,#1f2937)); right:auto; left:12px; }
1341
1122
  /* The direction of time. **Purely indicative**: takes no events, no width (absolutely positioned, centered on the seam). A big hollow
1342
1123
  * block arrow stamped on the seam, not a round button: nothing about it should invite a click. Filled with the canvas color
@@ -1347,11 +1128,11 @@ var GK_CSS = `
1347
1128
  stroke-linejoin:round; vector-effect:non-scaling-stroke; }
1348
1129
  /* The in-column truncation notice sits one line above the column name. */
1349
1130
  .gb-pane .gb-diff-trunc { top:auto; left:auto; bottom:44px; right:12px; }
1350
- .gb-glass-plane { position:absolute; pointer-events:none; }
1351
- .gb-glass-surface { position:absolute; inset:0; backdrop-filter:blur(18px) saturate(160%); -webkit-backdrop-filter:blur(18px) saturate(160%); }
1352
- .gb-glass-rim { position:absolute; inset:0; overflow:visible; }
1353
- .gb-glass-planes, .gb-plane-labels { position:absolute; inset:0; width:100%; height:100%;
1131
+ .gb-planes, .gb-plane-labels { position:absolute; inset:0; width:100%; height:100%;
1354
1132
  pointer-events:none; overflow:hidden; }
1133
+ /* The B\xE9zier has linear x and smoothstep y, matching the canvas painter. */
1134
+ .gb-planes polygon { transition-property:fill-opacity,stroke-width,opacity;
1135
+ transition-duration:${HOVER_FADE_MS}ms; transition-timing-function:cubic-bezier(.333333,0,.666667,1); }
1355
1136
  /* svg is a replaced element: inset:0 alone falls back to its intrinsic 300x150, so it needs an explicit 100%. */
1356
1137
  /* Plates are drawn **under** the graph (cytoscape's canvases are z-index 1\u20133); layer names **above**,
1357
1138
  or nodes at the same spot would cover them. */
@@ -1366,23 +1147,24 @@ var GK_CSS = `
1366
1147
  .gb-bar.has-layers { flex-wrap:nowrap; }
1367
1148
  .gb-bar > * { pointer-events:auto; }
1368
1149
  .gb-ico { display:block; flex:none; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
1369
- /* Only four radius levels, which the host can override as a set:
1370
- * --gb-r-face faces floating on the canvas (search box, zoom group, caption, column labels)
1371
- * --gb-r-pop layers that pop out (dropdowns, panels, cards on overlays)
1372
- * --gb-r-in-face / --gb-r-in-pop controls inside a face: outer radius minus padding (concentric), 10\u22123, 12\u22126
1373
- * --gb-r-chip small inline tags (keycaps, kind tags, focus tags) */
1374
- .gb-field, .gb-segm, .gb-icon-btn, .gb-group, .gb-note, .gb-chip, .gb-legend {
1375
- background: var(--gb-panel, var(--gb-default-panel,rgba(255,255,255,.86))); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0));
1376
- box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 6px 18px -6px rgba(15,23,42,.12);
1377
- -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-radius:var(--gb-r-face,10px); }
1150
+ /* Material, elevation and rounding compose independently. Only the outer face blurs. */
1151
+ .gb-glass { background:color-mix(in srgb, var(--gb-surface-fill,var(--gb-panel,var(--gb-default-panel,rgba(255,255,255,.86)))),
1152
+ transparent var(--gb-glass-transparency,25%));
1153
+ border:1px solid var(--gb-border,var(--gb-default-rim,#e2e8f0));
1154
+ -webkit-backdrop-filter:blur(var(--gb-blur,10px)); backdrop-filter:blur(var(--gb-blur,10px)); }
1155
+ .gb-raised { box-shadow:var(--gb-shadow,0 1px 2px rgba(15,23,42,.05), 0 6px 18px -6px rgba(15,23,42,.12)); }
1156
+ .gb-round { border-radius:var(--gb-radius,var(--gb-r-face,10px)); }
1157
+ .gb-drop,.gb-panel,.gb-lg-pop,.gb-pick-list,.gb-loading,.gb-drawer {
1158
+ --gb-surface-fill:color-mix(in srgb,var(--gb-panel2,var(--gb-default-surface,#fff)) 93%,transparent);
1159
+ --gb-radius:var(--gb-r-pop,12px);
1160
+ --gb-shadow:0 2px 6px rgba(0,0,0,.08),0 18px 40px -12px rgba(0,0,0,.24); }
1378
1161
  .gb-bar button, .gb-dock button { font-family:inherit; cursor:pointer; }
1379
1162
  .gb-bar button:focus-visible, .gb-dock button:focus-visible { outline:2px solid var(--gb-accent,var(--gb-default-accent,#0284c7)); outline-offset:1px; }
1380
1163
 
1381
- /* Search: fixed width (it does not widen on focus: widening would push the layer toggle away, jumping sideways on every focus and blur),
1382
- * a bit wider with a focus tag; the dropdown is a solid card (text must be readable, the graph must not show through), wider than the box. */
1383
- .gb-search { position:relative; width:260px; flex:0 1 260px; min-width:180px; max-width:100%; transition: width .22s cubic-bezier(.3,.7,.2,1); }
1164
+ /* Keep the search width stable on focus. */
1165
+ .gb-search { position:relative; width:260px; flex:0 1 260px; min-width:180px; max-width:100%; transition: width .22s var(--gb-ease); }
1384
1166
  .gb-field { display:flex; align-items:center; gap:7px; height:36px; padding:0 8px 0 11px;
1385
- color: var(--gb-muted,var(--gb-default-muted,#64748b)); transition: border-color .15s, box-shadow .15s; }
1167
+ color: var(--gb-muted,var(--gb-default-muted,#64748b)); transition: border-color .15s var(--gb-ease), box-shadow .15s var(--gb-ease); }
1386
1168
  .gb-search.is-focus .gb-field { border-color: var(--gb-accent,var(--gb-default-accent,#0284c7));
1387
1169
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 16%, transparent), 0 6px 18px -6px rgba(15,23,42,.14); }
1388
1170
  .gb-field input { flex:1; min-width:0; height:100%; border:0; background:transparent; outline:none; padding:0;
@@ -1402,20 +1184,18 @@ var GK_CSS = `
1402
1184
  .gb-token button:hover { background: rgba(127,127,127,.18); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1403
1185
 
1404
1186
  .gb-drop, .gb-panel { position:absolute; top:calc(100% + 6px); left:0; z-index:12;
1405
- background: var(--gb-panel2,var(--gb-default-panel2,#fff)); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); border-radius:var(--gb-r-pop,12px);
1406
- box-shadow: 0 2px 6px rgba(15,23,42,.06), 0 18px 40px -12px rgba(15,23,42,.24);
1407
- padding:6px; transform-origin: top left; animation: gb-pop .14s cubic-bezier(.2,.8,.3,1); }
1187
+ padding:6px; transform-origin: top left; animation: gb-pop .14s var(--gb-ease); }
1408
1188
  .gb-drop { width:max(100%, 360px); max-width:calc(100vw - 24px); }
1409
1189
  .gb-drop ul { list-style:none; margin:0; padding:0; }
1410
1190
  .gb-drop li { display:flex; align-items:center; gap:10px; padding:7px 9px; border-radius:var(--gb-r-in-pop,6px); cursor:pointer; }
1411
1191
  .gb-drop li.on { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
1412
1192
  .gb-dot { width:9px; height:9px; border-radius:50%; flex:none; background: var(--gb-muted2,var(--gb-default-muted2,#94a3b8));
1413
1193
  box-shadow: 0 0 0 2px var(--gb-panel2,var(--gb-default-panel2,#fff)), 0 0 0 3px var(--gb-border,var(--gb-default-border,#e2e8f0)); }
1414
- .gb-r-main { flex:1; min-width:0; display:flex; flex-direction:column; gap:1px; }
1415
- .gb-r-label { font-size:13px; color: var(--gb-text,var(--gb-default-text,#1f2937)); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
1416
- .gb-r-label mark { background:none; color:inherit; font-weight:650;
1194
+ .gb-drop .gb-ref { flex:1; gap:10px; }
1195
+ .gb-drop .gb-ref-main { gap:1px; }
1196
+ .gb-drop .gb-ref-label { font-size:13px; }
1197
+ .gb-drop mark { background:none; color:inherit; font-weight:650;
1417
1198
  text-decoration: underline 2px color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 45%, transparent); text-underline-offset:3px; }
1418
- .gb-r-path { font-size:11px; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
1419
1199
  .gb-r-kind { flex:none; font-size:10.5px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0));
1420
1200
  border-radius:var(--gb-r-chip,5px); padding:1px 6px; }
1421
1201
  .gb-drop-empty { padding:10px 9px; font-size:12.5px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
@@ -1428,14 +1208,11 @@ var GK_CSS = `
1428
1208
  .gb-drop-keys kbd { padding:1px 4px; }
1429
1209
  .gb-drop-keys kbd + kbd { margin-left:-1px; }
1430
1210
 
1431
- /* Filtering by source: a tag you can \xD7 away, the same height as the toolbar. */
1432
- .gb-chip { display:inline-flex; align-items:center; gap:6px; height:36px; box-sizing:border-box; padding:0 6px 0 11px;
1433
- min-width:0; flex:0 1 auto; max-width:220px; font-size:12.5px; color: var(--gb-text,var(--gb-default-text,#1f2937)); background: var(--gb-active,var(--gb-default-active,#e0f2fe)); }
1434
- .gb-chip > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
1435
- .gb-chip .gb-ico { color: var(--gb-accent,var(--gb-default-accent,#0284c7)); }
1436
- .gb-chip button { display:grid; place-items:center; width:22px; height:22px; border:0; padding:0; border-radius:var(--gb-r-chip,5px);
1437
- background:transparent; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
1438
- .gb-chip button:hover { background: rgba(127,127,127,.18); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1211
+ .gb-field .gb-token { max-width:min(48%,140px); }
1212
+ .gb-token .gb-ico, .gb-token button { flex:none; }
1213
+ .gb-absent { position:absolute; inset:20% 8%; display:grid; place-content:center; text-align:center;
1214
+ pointer-events:none; color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
1215
+
1439
1216
 
1440
1217
  /* Segmented: a backing slides to the current item. The layer names live in a horizontal
1441
1218
  * scroll track so a long list never pushes the toolbar wider than the canvas; the stack
@@ -1444,7 +1221,7 @@ var GK_CSS = `
1444
1221
  min-width:0; max-width:100%; flex:0 1 auto; }
1445
1222
  .gb-layer-track { position:relative; display:flex; flex:1 1 auto; min-width:0; height:28px;
1446
1223
  overflow-x:auto; overflow-y:hidden; overscroll-behavior-x:contain; touch-action:pan-x;
1447
- scrollbar-width:none; max-width:1000px; transition:max-width .26s ease, opacity .18s ease; }
1224
+ scrollbar-width:none; max-width:1000px; transition:max-width .26s var(--gb-ease), opacity .18s var(--gb-ease); }
1448
1225
  /* Floors off: the list folds away; the switch beside it does not move (same element, same place, as the legend). */
1449
1226
  .gb-layers.is-collapsed .gb-layer-track { max-width:0; opacity:0; pointer-events:none; }
1450
1227
  .gb-layers.is-collapsed .gb-sep { opacity:0; margin:0; }
@@ -1456,15 +1233,15 @@ var GK_CSS = `
1456
1233
  mask-image:linear-gradient(to right, transparent, #000 18px, #000 calc(100% - 18px), transparent); }
1457
1234
  .gb-segm > button, .gb-layer-track > button { position:relative; z-index:1; height:28px; padding:0 12px; border:0; border-radius:var(--gb-r-in-face,7px);
1458
1235
  background:transparent; font-size:12.5px; font-weight:500; color: var(--gb-muted,var(--gb-default-muted,#64748b)); white-space:nowrap;
1459
- transition: color .2s, background-color .2s; flex:none; }
1236
+ transition: color .2s var(--gb-ease), background-color .2s var(--gb-ease); flex:none; }
1460
1237
  .gb-segm > button:hover:not(.on):not(:disabled), .gb-layer-track > button:hover:not(.on):not(:disabled) { color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1461
1238
  .gb-segm > button.on, .gb-layer-track > button.on { color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1462
1239
  .gb-segm > button:disabled, .gb-layer-track > button:disabled { cursor:default; opacity:.5; }
1463
1240
  .gb-thumb { position:absolute; top:0; left:0; z-index:0; height:28px; border-radius:var(--gb-r-in-face,7px); background: var(--gb-active,var(--gb-default-active,#e0f2fe));
1464
- box-shadow: 0 1px 2px rgba(15,23,42,.08); transition: transform .3s cubic-bezier(.3,.7,.2,1), width .3s cubic-bezier(.3,.7,.2,1); }
1241
+ box-shadow: 0 1px 2px rgba(15,23,42,.08); transition: transform .3s var(--gb-ease), width .3s var(--gb-ease); }
1465
1242
  /* Stacked layers on: layer names are multi-select, each lit on its own; no slider. */
1466
1243
  .gb-layers.is-multi .gb-layer-track > button[data-v].on { background: var(--gb-active,var(--gb-default-active,#e0f2fe)); box-shadow: 0 1px 2px rgba(15,23,42,.08); }
1467
- .gb-sep { align-self:center; width:1px; height:18px; margin:0 3px; background: var(--gb-border,var(--gb-default-border,#e2e8f0)); flex:none; transition:opacity .18s ease, margin .26s ease; }
1244
+ .gb-sep { align-self:center; width:1px; height:18px; margin:0 3px; background: var(--gb-border,var(--gb-default-border,#e2e8f0)); flex:none; transition:opacity .18s var(--gb-ease), margin .26s var(--gb-ease); }
1468
1245
  .gb-layer-track > button:focus-visible { outline-offset:-2px; }
1469
1246
  .gb-segm > button.gb-stack { display:grid; place-items:center; width:30px; padding:0; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
1470
1247
  .gb-segm > button.gb-stack:hover:not(:disabled) { color: var(--gb-text,var(--gb-default-text,#1f2937)); background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
@@ -1472,7 +1249,7 @@ var GK_CSS = `
1472
1249
 
1473
1250
  .gb-menu { position:relative; }
1474
1251
  .gb-icon-btn { display:grid; place-items:center; width:36px; height:36px; padding:0; color: var(--gb-muted,var(--gb-default-muted,#64748b));
1475
- transition: color .15s, background-color .15s; }
1252
+ transition: color .15s var(--gb-ease), background-color .15s var(--gb-ease); }
1476
1253
  .gb-icon-btn:hover, .gb-icon-btn.on { color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1477
1254
  .gb-icon-btn.on { background: var(--gb-active,var(--gb-default-active,#e0f2fe)); }
1478
1255
  .gb-panel { min-width:228px; }
@@ -1495,36 +1272,27 @@ var GK_CSS = `
1495
1272
  .gb-dock > * { pointer-events:auto; }
1496
1273
  .gb-group { display:inline-flex; overflow:hidden; }
1497
1274
  .gb-group > button { display:grid; place-items:center; width:34px; height:34px; padding:0; border:0; background:transparent;
1498
- color: var(--gb-muted,var(--gb-default-muted,#64748b)); transition: color .15s, background-color .15s; }
1275
+ color: var(--gb-muted,var(--gb-default-muted,#64748b)); transition: color .15s var(--gb-ease), background-color .15s var(--gb-ease); }
1499
1276
  .gb-group > button:hover { color: var(--gb-text,var(--gb-default-text,#1f2937)); background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
1500
1277
  .gb-group > button:active { background: var(--gb-active,var(--gb-default-active,#e0f2fe)); }
1501
1278
  .gb-group > button + button { border-left:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
1502
- .gb-issues { width:min(440px, calc(100vw - 24px)); max-height:min(520px, 70vh); overflow:auto; padding-bottom:6px; }
1503
- .gb-issues details { border-top:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
1504
- .gb-issues summary { display:flex; align-items:center; gap:8px; padding:7px 12px; cursor:pointer; font-size:12.5px;
1505
- color: var(--gb-text,var(--gb-default-text,#1f2937)); list-style:none; }
1506
- .gb-issues summary::-webkit-details-marker { display:none; }
1507
- .gb-issues summary::before { content:''; width:5px; height:5px; border:solid var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); border-width:0 1.5px 1.5px 0;
1508
- transform: rotate(-45deg); transition: transform .15s; flex:none; }
1509
- .gb-issues details[open] > summary::before { transform: rotate(45deg); }
1510
- .gb-issues summary:hover { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
1511
- .gb-issues summary span { flex:1; }
1512
- .gb-issues summary b { font-weight:500; font-variant-numeric: tabular-nums; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
1513
- .gb-issues ul { margin:0; padding:0 0 6px; list-style:none; font-size:11.5px; line-height:1.5; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
1514
- .gb-issues li { overflow-wrap:break-word; padding:3px 12px 3px 25px; }
1515
- .gb-check-button { position:relative; }
1516
- .gb-check-button .gb-ico { transform:translate(-2px,2px); }
1517
- .gb-check-badge { position:absolute; top:1px; right:1px; padding:0 2px; border-radius:4px;
1518
- background:var(--gb-panel2,var(--gb-default-panel2,#fff));
1519
- font-size:10px; font-weight:700; line-height:12px; font-variant-numeric:tabular-nums; }
1520
- .gb-check-error { color:var(--gb-err, #dc2626); }
1521
- .gb-check-warn { color:var(--gb-warn, #b45309); }
1522
- .gb-check-info { color:var(--gb-muted, #64748b); }
1523
- .gb-issue-target { display:block; border:0; background:none; color:inherit; padding:0; font:inherit; text-align:left; cursor:pointer; }
1524
- .gb-issue-target:hover { text-decoration:underline; }
1525
- .gb-issue-where { display:block; opacity:.75; margin-top:3px; }
1526
- .gb-issue-fix { white-space:pre-wrap; border-left:2px solid var(--gb-border, #e2e8f0); padding-left:8px; margin:6px 0 10px; }
1527
-
1279
+ .gb-issues { padding:0; width:min(700px, calc(100vw - 24px)); max-height:min(600px, 70vh); overflow:auto; }
1280
+ .gb-issues .gb-md { padding:10px 11px; font-size:13px; line-height:1.5; text-align:left; user-select:text; overflow-wrap:anywhere; }
1281
+ .gb-issues .gb-md-h { margin:14px 0 4px; }
1282
+ .gb-issues .gb-md-h:first-child { margin-top:0; }
1283
+ .gb-issues .gb-md > ul > li + li { margin-top:12px; }
1284
+ .gb-issues .gb-md li > ul, .gb-issues .gb-md li > pre { margin-top:4px; }
1285
+ .gb-issues .gb-md pre { white-space:pre-wrap; }
1286
+ .gb-check-button[aria-expanded="true"] { color:var(--gb-text,var(--gb-default-text,#1f2937)); background:var(--gb-active,var(--gb-default-active,#e0f2fe)); }
1287
+ .gb-issues .gb-md-h1 { font-size:15px; }
1288
+ .gb-issues .gb-md-h1:not(:first-child) { margin-top:16px; padding-top:12px; border-top:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
1289
+ .gb-issues .gb-md-h2 { color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
1290
+ .gb-issues .gb-md > .gb-md-h2, .gb-issues .gb-md > ul { margin-inline-start:8px; }
1291
+ .gb-check-stack { position:relative; display:block; }
1292
+ .gb-check-badge { position:absolute; top:-1px; right:-7px; min-width:12px; text-align:left;
1293
+ font:700 9px/9px ui-monospace, SFMono-Regular, Consolas, monospace;
1294
+ background:var(--gb-panel2,var(--gb-default-panel2,#fff)); border-radius:2px; }
1295
+ .gb-check-button[aria-expanded="true"] .gb-check-badge { background:var(--gb-active,var(--gb-default-active,#e0f2fe)); }
1528
1296
  .gb-err { color: var(--gb-err,var(--gb-default-err,#dc2626)); border-color: var(--gb-err-border,var(--gb-default-err-border,#fca5a5)); background: var(--gb-err-bg,var(--gb-default-err-bg,#fef2f2)); }
1529
1297
  .gb-hint { color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
1530
1298
  .gb-hint .gb-ico { color: var(--gb-warn,var(--gb-default-warn,#b45309)); }
@@ -1540,8 +1308,7 @@ var GK_CSS = `
1540
1308
  .gb-note { font-size:11px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); padding:4px 8px; display:flex; gap:8px; align-items:center; }
1541
1309
  .gb-warn { color: var(--gb-warn,var(--gb-default-warn,#b45309)); border-color: var(--gb-warn-border,var(--gb-default-warn-border,#fcd34d)); background: var(--gb-warn-bg,var(--gb-default-warn-bg,#fffbeb)); }
1542
1310
  .gb-mask { position:absolute; inset:0; z-index:20; display:grid; place-items:center; background: var(--gb-mask,var(--gb-default-mask,rgba(248,250,252,.6))); }
1543
- .gb-mask > div { display:flex; align-items:center; gap:10px; border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0));
1544
- border-radius:var(--gb-r-pop,12px); box-shadow: 0 2px 6px rgba(15,23,42,.06), 0 18px 40px -12px rgba(15,23,42,.24); background: var(--gb-panel,var(--gb-default-panel,#fff)); padding:10px 16px; font-size:12.5px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
1311
+ .gb-loading { display:flex; align-items:center; gap:10px; padding:10px 16px; font-size:12.5px; color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
1545
1312
  .gb-spin { width:14px; height:14px; border-radius:50%; border:2px solid var(--gb-accent,var(--gb-default-accent,#0284c7));
1546
1313
  border-top-color:transparent; animation: gb-spin 0.8s linear infinite; }
1547
1314
  @keyframes gb-spin { to { transform: rotate(360deg); } }
@@ -1563,7 +1330,7 @@ var GK_CSS = `
1563
1330
  .gb-lg-row { display:flex; flex-wrap:wrap; align-items:center; gap:1px 4px; }
1564
1331
  .gb-lg-item { position:relative; display:inline-flex; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
1565
1332
  .gb-lg-hit { display:inline-flex; align-items:center; gap:5px; height:24px; padding:0 6px; border:0; border-radius:var(--gb-r-in-pop,6px);
1566
- background:none; font:inherit; color:inherit; cursor:pointer; transition: background-color .12s, color .12s; }
1333
+ background:none; font:inherit; color:inherit; cursor:pointer; transition: background-color .12s var(--gb-ease), color .12s var(--gb-ease); }
1567
1334
  .gb-lg-hit:hover, .gb-lg-item.is-open .gb-lg-hit { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1568
1335
  .gb-lg-item b { font-weight:600; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); font-variant-numeric: tabular-nums; }
1569
1336
  .gb-lg-item.off { color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
@@ -1574,9 +1341,7 @@ var GK_CSS = `
1574
1341
  outline:2px solid var(--gb-accent,var(--gb-default-accent,#0284c7)); outline-offset:1px; }
1575
1342
  .gb-lg-pop { position:absolute; left:-6px; bottom:calc(100% + 6px); z-index:30;
1576
1343
  display:flex; align-items:center; gap:4px; padding:6px; white-space:nowrap;
1577
- background: var(--gb-panel2,var(--gb-default-panel2,#fff)); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); border-radius:var(--gb-r-pop,12px);
1578
- box-shadow: 0 2px 6px rgba(15,23,42,.06), 0 18px 40px -12px rgba(15,23,42,.24);
1579
- animation: gb-pop-up .14s cubic-bezier(.2,.8,.3,1); }
1344
+ animation: gb-pop-up .14s var(--gb-ease); }
1580
1345
  /* The gap between panel and entry counts as panel: moving the mouse up from the entry is not leaving. */
1581
1346
  .gb-lg-pop::after { content:''; position:absolute; left:0; right:0; top:100%; height:8px; }
1582
1347
  /* Portaled panel: opens above by default, flips below when the stage is too short. */
@@ -1618,43 +1383,75 @@ var GK_CSS = `
1618
1383
  * inputs look like the search box, the node picker dropdown like the search dropdown, nodes carry their color on the graph. */
1619
1384
  /* Drawer: opening and closing animate width, the canvas changes with it instead of jumping. Hosts use --gb-inspector-bg to match their own
1620
1385
  * sidebar (symmetric on both sides, with the canvas in between). */
1621
- .gb-drawer { flex:none; width:320px; overflow:hidden; display:flex; animation: gb-drawer-in .2s cubic-bezier(.2,.8,.3,1); }
1622
- .gb-drawer.is-closing { animation: gb-drawer-out .2s cubic-bezier(.4,0,.6,1) forwards; pointer-events:none; }
1386
+ .gb-drawer { --gb-surface-fill:var(--gb-inspector-bg,var(--gb-panel2,var(--gb-default-surface,#fff)));
1387
+ --gb-radius:0; --gb-shadow:none; border-color:var(--gb-inspector-border,var(--gb-border,var(--gb-default-rim,#e2e8f0))); border-width:0 0 0 1px; flex:none; width:320px; overflow:hidden; display:flex; animation: gb-drawer-in .2s var(--gb-ease); }
1388
+ .gb-drawer.is-closing { animation: gb-drawer-out .2s var(--gb-ease-out) forwards; pointer-events:none; }
1623
1389
  @keyframes gb-drawer-in { from { width:0; } }
1624
1390
  @keyframes gb-drawer-out { to { width:0; } }
1625
- .gb-detail { width:320px; flex-shrink:0; display:flex; flex-direction:column; min-height:0;
1626
- border-left:1px solid var(--gb-inspector-border, var(--gb-border,var(--gb-default-border,#e2e8f0)));
1627
- background: var(--gb-inspector-bg, var(--gb-panel2,var(--gb-default-panel2,#fff))); }
1628
- .gb-dh { flex:none; display:flex; align-items:center; justify-content:space-between; gap:8px;
1629
- height:52px; padding:0 10px 0 16px; border-bottom:1px solid var(--gb-inspector-border, var(--gb-border,var(--gb-default-border,#e2e8f0))); }
1630
- .gb-dh-title { display:inline-flex; align-items:center; gap:8px; min-width:0; font-size:12.5px; font-weight:600;
1631
- color: var(--gb-text,var(--gb-default-text,#1f2937)); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
1632
- .gb-kind { font-weight:500; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
1633
- .gb-dh-act { display:inline-flex; align-items:center; gap:2px; flex:none; }
1391
+ .gb-detail { container:gb-inspector / inline-size; width:320px; flex-shrink:0; display:flex; flex-direction:column; min-height:0; }
1392
+ /* DetailPanel can also be mounted directly by a host. */
1393
+ :where(:not(.gb-drawer)) > .gb-detail { background:var(--gb-inspector-bg,var(--gb-panel2,var(--gb-default-panel2,#fff))); }
1394
+ .gb-dh { position:relative; flex:none; display:flex; align-items:flex-start; gap:6px;
1395
+ min-height:48px; box-sizing:border-box; padding:8px 44px 8px 16px; border-bottom:1px solid var(--gb-inspector-border, var(--gb-border,var(--gb-default-border,#e2e8f0))); }
1396
+ .gb-dh-title { flex:1; min-width:0; max-height:8rem; overflow:auto; overflow-wrap:anywhere; }
1397
+ .gb-dh-meta { display:flex; align-items:flex-start; flex-wrap:wrap; gap:2px 8px; font-size:11px; line-height:16px;
1398
+ color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
1399
+ .gb-identity-field { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:start; column-gap:4px; min-width:0; }
1400
+ .gb-identity-mark, .gb-ref-mark { display:grid; place-items:center; height:1lh; flex:none; }
1401
+ .gb-identity-mark { min-width:16px; }
1402
+ .gb-dh-controls { flex:none; display:flex; align-items:center; min-height:38px; gap:6px; }
1403
+ .gb-dh .gb-dh-close { position:absolute; top:3px; right:3px; width:36px; height:36px; }
1634
1404
  .gb-ibtn { display:inline-flex; align-items:center; justify-content:center; gap:5px; min-width:28px; height:28px; padding:0 6px;
1635
1405
  border:0; border-radius:var(--gb-r-in-face,7px); background:transparent; color: var(--gb-muted,var(--gb-default-muted,#64748b));
1636
- font:inherit; font-size:12.5px; cursor:pointer; transition: color .15s, background-color .15s; }
1406
+ font:inherit; font-size:12.5px; cursor:pointer; transition: color .15s var(--gb-ease), background-color .15s var(--gb-ease); }
1637
1407
  .gb-ibtn:hover { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1638
- .gb-ibtn:focus-visible, .gb-btn:focus-visible, .gb-add:focus-visible, .gb-pick-cur:focus-visible {
1408
+ .gb-ibtn:focus-visible, .gb-btn:focus-visible, .gb-link:focus-visible, .gb-ref-link:focus-visible, .gb-pick-cur:focus-visible {
1639
1409
  outline:2px solid var(--gb-accent,var(--gb-default-accent,#0284c7)); outline-offset:1px; }
1640
1410
  .gb-ibtn-text { padding:0 10px 0 8px; color: var(--gb-text,var(--gb-default-text,#1f2937)); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
1641
- .gb-db { flex:1; min-height:0; overflow:auto; padding:16px; font-size:12.5px; line-height:1.55; }
1642
- .gb-dt { font-size:15px; font-weight:600; line-height:1.35; margin-bottom:12px; overflow-wrap:anywhere; color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1643
- .gb-flag { font-size:11.5px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); background: var(--gb-tint,var(--gb-default-tint,#f8fafc));
1644
- border-radius:var(--gb-r-in-pop,6px); padding:7px 10px; margin-bottom:12px; }
1411
+ @container gb-inspector (max-width:400px) {
1412
+ .gb-dh-controls .gb-ibtn-text { position:relative; width:28px; padding:0; }
1413
+ .gb-dh-controls .gb-ibtn-text::after { content:''; position:absolute; inset:-4px -3px; }
1414
+ .gb-dh-controls .gb-ibtn-text span { display:none; }
1415
+ }
1416
+ .gb-db { overscroll-behavior:contain; flex:1; min-height:0; overflow:auto; padding:16px; font-size:12.5px; line-height:1.55; }
1417
+ .gb-dt { font-size:15px; font-weight:600; line-height:1.35; margin:2px 0 0; overflow-wrap:anywhere; color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1645
1418
  .gb-dempty { color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
1646
- .gb-line { display:grid; grid-template-columns: minmax(64px, 30%) 1fr; gap:10px; padding:5px 0; overflow-wrap:anywhere; }
1647
- .gb-k { font-size:10.5px; font-weight:600; letter-spacing:.05em; text-transform:uppercase; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
1419
+ .gb-line { display:grid; grid-template-columns:minmax(64px,30%) minmax(0,1fr); gap:10px; padding:5px 0; overflow-wrap:anywhere; }
1420
+ .gb-k { font-size:10.5px; font-weight:600; letter-spacing:.05em; text-transform:uppercase; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
1648
1421
  .gb-line .gb-k { padding-top:2px; }
1649
- .gb-desc { color: var(--gb-muted,var(--gb-default-muted,#475569)); margin:6px 0 14px; }
1650
- .gb-sect { margin:12px 0; }
1651
- .gb-sect .gb-k { display:block; margin-bottom:6px; }
1652
- .gb-sect ul { margin:0; padding-left:16px; }
1653
- .gb-sect li { margin-bottom:3px; overflow-wrap:anywhere; }
1654
- .gb-extras { margin-top:14px; padding-top:10px; border-top:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
1422
+ .gb-db:not(.gb-form) > .gb-core-field { margin:12px 0; }
1423
+ .gb-core-field .gb-value ul, .gb-core-field .gb-value-diff ul { margin:0; padding-left:16px; }
1424
+ .gb-core-field .gb-value li, .gb-core-field .gb-value-diff li { margin-bottom:3px; overflow-wrap:anywhere; }
1425
+ .gb-field-pair, .gb-children, .gb-edge-row, .gb-rel:not(.gb-children) > li { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); column-gap:12px; }
1426
+ .gb-field-pair { margin:8px 0 12px; }
1427
+ .gb-field-pair:first-child { margin-top:0; }
1428
+ .gb-core-field { min-width:0; display:grid; grid-template-columns:minmax(0,1fr); align-content:start; gap:3px; }
1429
+ .gb-rel-section { padding:8px 0; border-top:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
1430
+ .gb-list-head { display:flex; align-items:center; gap:6px; min-height:22px; font-size:11px; font-variant-numeric:tabular-nums; color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
1431
+ .gb-list-add { margin-inline-start:auto; }
1432
+ .gb-rel { list-style:none; margin:0; padding:0; }
1433
+ .gb-rel li { min-width:0; align-items:start; padding:2px 0; overflow-wrap:anywhere; }
1434
+ .gb-children > li, .gb-peer, .gb-ref { display:flex; align-items:flex-start; gap:6px; min-width:0; }
1435
+ .gb-peer { justify-content:space-between; }
1436
+ .gb-ref { align-items:center; max-width:100%; }
1437
+ .gb-ref-link { border:0; background:none; padding:2px 0; font:inherit; cursor:pointer; text-align:start; }
1438
+ .gb-ref-link:hover .gb-ref-label { text-decoration:underline; }
1439
+ :is(.gb-rel,.gb-value,.gb-value-diff) .gb-ref { align-items:flex-start; font-size:12.5px; line-height:1.4; }
1440
+ :is(.gb-rel,.gb-value,.gb-value-diff) .gb-ref-label { white-space:normal; overflow-wrap:anywhere; }
1441
+ .gb-rel .gb-ref { padding:2px 0; }
1442
+
1443
+ .gb-rel-section .gb-more { font-size:11.5px; padding:4px 0; }
1444
+ .gb-value { min-width:0; white-space:pre-wrap; overflow-wrap:anywhere; }
1445
+ .gb-value:has(.gb-md), .gb-value:has(ul) { white-space:normal; }
1446
+ .gb-value-diff { display:flex; flex-wrap:wrap; align-items:baseline; gap:3px 7px; min-width:0; overflow-wrap:anywhere; }
1447
+ .gb-value-diff.is-block { display:grid; }
1448
+ .gb-change { color:var(--gb-muted,var(--gb-default-muted,#64748b)); font-size:11px; }
1449
+ .gb-was, .gb-was .gb-ref-label { text-decoration:line-through; color:var(--gb-err,var(--gb-default-err,#b91c1c)); }
1450
+ .gb-now, .gb-now .gb-ref-label { text-decoration:underline; text-underline-offset:.15em; color:var(--gb-accent,var(--gb-default-accent,#0369a1)); }
1451
+ .gb-change { font-weight:600; padding-inline:5px; border-inline-start:1px solid currentColor; }
1655
1452
  .gb-df { flex:none; display:flex; align-items:center; justify-content:space-between; gap:8px;
1656
1453
  padding:10px 12px 10px 16px; border-top:1px solid var(--gb-inspector-border, var(--gb-border,var(--gb-default-border,#e2e8f0)));
1657
- background: var(--gb-inspector-bg, var(--gb-panel2,var(--gb-default-panel2,#fff))); }
1454
+ }
1658
1455
 
1659
1456
  /* markdown (long text in details): body font size, images span the column, code on a faint background. */
1660
1457
  .gb-md > * + * { margin-top:8px; }
@@ -1679,13 +1476,15 @@ var GK_CSS = `
1679
1476
  * opening the 320px inspector narrows the chrome too. */
1680
1477
  @container gk (max-width: 640px) {
1681
1478
  .gb-drawer { position:absolute; left:0; right:0; bottom:0; z-index:25; width:auto; max-height:62%;
1682
- border-radius:16px 16px 0 0; box-shadow: 0 -12px 40px -12px rgba(15,23,42,.3);
1683
- animation: gb-sheet-in .24s cubic-bezier(.2,.8,.3,1); }
1684
- .gb-drawer.is-closing { animation: gb-sheet-out .2s cubic-bezier(.4,0,.6,1) forwards; }
1479
+ --gb-radius:var(--gb-r-sheet,16px) var(--gb-r-sheet,16px) 0 0;
1480
+ --gb-surface-fill:color-mix(in srgb,var(--gb-inspector-bg,var(--gb-default-surface,#fff)) 93%,transparent);
1481
+ --gb-shadow:0 -10px 32px -12px rgba(0,0,0,.32); border-width:1px 0 0;
1482
+ animation: gb-sheet-in .24s var(--gb-ease); }
1483
+ .gb-drawer.is-closing { animation: gb-sheet-out .2s var(--gb-ease-out) forwards; }
1685
1484
  .gb-drawer > .gb-detail { width:100%; border-left:0; }
1686
1485
  .gb-dh::before { content:''; position:absolute; left:50%; top:6px; width:36px; height:4px; margin-left:-18px;
1687
- border-radius:2px; background: var(--gb-border,var(--gb-default-border,#e2e8f0)); }
1688
- .gb-dh { position:relative; }
1486
+ border-radius:2px; background:var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); opacity:.4; }
1487
+ .gb-dh { padding-top:14px; }
1689
1488
  }
1690
1489
  @container gks (max-width: 640px) {
1691
1490
  .gb-bar { right:12px; }
@@ -1705,7 +1504,8 @@ var GK_CSS = `
1705
1504
  @keyframes gb-sheet-in { from { transform: translateY(100%); } }
1706
1505
  @keyframes gb-sheet-out { to { transform: translateY(100%); } }
1707
1506
  @media (prefers-reduced-motion: reduce) {
1708
- .gb-drawer, .gb-drawer.is-closing { animation-duration:.01s; }
1507
+ .gb-root :is(.gb-drawer,.gb-glass,.gb-layer-track,.gb-sep,.gb-thumb,.gb-search) {
1508
+ animation-duration:.01ms; transition-duration:.01ms; }
1709
1509
  }
1710
1510
 
1711
1511
  /* What a node looks like: its color on the graph (.gb-dot, as in the search dropdown) + name (+ a grey line). */
@@ -1721,64 +1521,52 @@ var GK_CSS = `
1721
1521
  .gb-menu-item:disabled { opacity:.5; cursor:default; }
1722
1522
  .gb-link { border:0; background:none; padding:0; font:inherit; font-size:12.5px; color: var(--gb-accent,var(--gb-default-accent,#0284c7)); cursor:pointer; }
1723
1523
  .gb-link:hover { text-decoration:underline; }
1724
- .gb-form { display:flex; flex-direction:column; gap:18px; }
1725
- .gb-fld { display:flex; flex-direction:column; gap:7px; }
1726
- .gb-fld .gb-k em { font-style:normal; font-weight:500; letter-spacing:0; text-transform:none; margin-left:4px; opacity:.8; }
1727
- .gb-fld small { font-size:11px; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
1728
- .gb-fld small.is-bad { color: var(--gb-err,var(--gb-default-err,#dc2626)); }
1524
+ .gb-form > :is(.gb-core-field,.gb-rel-section) + .gb-core-field { margin-top:10px; }
1525
+ .gb-form > .gb-core-field { gap:7px; }
1526
+ .gb-core-field .gb-k em { font-style:normal; font-weight:500; letter-spacing:0; text-transform:none; margin-left:4px; opacity:.8; }
1527
+ .gb-core-field small { font-size:11px; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
1528
+ .gb-core-field small.is-bad { color: var(--gb-err,var(--gb-default-err,#dc2626)); }
1729
1529
  /* Inputs: look like the search box: white background, thin border, a glow on focus. */
1730
1530
  .gb-input { width:100%; box-sizing:border-box; height:36px; padding:0 11px; border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0));
1731
1531
  border-radius:var(--gb-r-in-face,8px); background: var(--gb-panel2,var(--gb-default-panel2,#fff)); color: var(--gb-text,var(--gb-default-text,#1f2937));
1732
1532
  font: inherit; font-size:13px; outline:none; box-shadow: 0 1px 2px rgba(15,23,42,.04);
1733
- transition: border-color .15s, box-shadow .15s; }
1533
+ transition: border-color .15s var(--gb-ease), box-shadow .15s var(--gb-ease); }
1734
1534
  .gb-input:focus, .gb-input:focus-within { border-color: var(--gb-accent,var(--gb-default-accent,#0284c7));
1735
1535
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 16%, transparent); }
1536
+ .gb-input.gb-edge-row { grid-column:1 / -1; align-items:start; height:auto; min-height:36px; padding:6px 8px; text-align:start; cursor:pointer; }
1736
1537
  .gb-input.is-bad { border-color: var(--gb-err,var(--gb-default-err,#dc2626)); }
1737
1538
  .gb-input::placeholder, .gb-input input::placeholder { color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
1738
- .gb-json { height:auto; min-height:168px; padding:10px 11px; resize:vertical; tab-size:2; white-space:pre;
1539
+ .gb-json { height:auto; min-height:96px; padding:10px 11px; resize:vertical; tab-size:2; white-space:pre;
1739
1540
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--gb-tint,var(--gb-default-tint,#f8fafc)); }
1740
1541
  .gb-json:focus { background: var(--gb-panel2,var(--gb-default-panel2,#fff)); }
1741
- .gb-id { display:block; padding:8px 11px; border-radius:var(--gb-r-in-face,8px); background: var(--gb-tint,var(--gb-default-tint,#f8fafc));
1742
- font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--gb-muted,var(--gb-default-muted,#64748b)); overflow-wrap:anywhere; }
1743
1542
  /* Node picker: unselected it is a search box with a magnifier and a dropdown like search's; selected it is a colored tag. */
1744
1543
  .gb-pick { position:relative; }
1745
1544
  .gb-pick-field { display:flex; align-items:center; gap:8px; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
1746
1545
  .gb-pick-field input { flex:1; min-width:0; height:100%; border:0; outline:none; background:transparent; padding:0;
1747
1546
  font:inherit; font-size:13px; color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1748
- .gb-pick-cur { display:flex; align-items:center; gap:10px; width:100%; height:44px; padding:0 8px 0 12px; text-align:left;
1749
- border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); border-radius:var(--gb-r-in-face,8px); background: var(--gb-panel2,var(--gb-default-panel2,#fff));
1750
- font:inherit; cursor:pointer; transition: border-color .15s; }
1751
- .gb-pick-cur:hover { border-color: color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 45%, var(--gb-border,var(--gb-default-border,#e2e8f0))); }
1547
+ .gb-pick-selected { display:flex; align-items:center; gap:2px; padding:0 3px 0 8px; }
1548
+ .gb-pick-cur { flex:1; min-width:0; height:100%; display:flex; align-items:center; padding:0; border:0;
1549
+ text-align:start; color:inherit; background:transparent; font:inherit; cursor:pointer; }
1550
+ .gb-pick-selected:hover, .gb-edge-row:hover { border-color: color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 45%, var(--gb-border,var(--gb-default-border,#e2e8f0))); }
1551
+ .gb-pick-cur > .gb-ref-static { flex:1; }
1752
1552
  .gb-pick-x { display:grid; place-items:center; width:24px; height:24px; flex:none; border-radius:var(--gb-r-chip,5px);
1753
1553
  color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
1754
1554
  .gb-pick-x:hover { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
1755
1555
  .gb-pick-list { position:absolute; left:0; right:0; top:calc(100% + 6px); z-index:5; margin:0; padding:6px; list-style:none;
1756
- background: var(--gb-panel2,var(--gb-default-panel2,#fff)); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); border-radius:var(--gb-r-pop,12px);
1757
- box-shadow: 0 2px 6px rgba(15,23,42,.06), 0 18px 40px -12px rgba(15,23,42,.24);
1758
- animation: gb-pop .14s cubic-bezier(.2,.8,.3,1); }
1556
+ animation: gb-pop .14s var(--gb-ease); }
1759
1557
  .gb-pick-list li { display:flex; align-items:center; gap:10px; padding:7px 9px; border-radius:var(--gb-r-in-pop,6px); cursor:pointer; }
1760
1558
  .gb-pick-list li.on { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
1761
- /* Edge list: direction \xB7 other end \xB7 kind \xB7 \xD7. */
1762
- .gb-rel { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; }
1763
- .gb-rel li { display:flex; align-items:center; gap:9px; min-height:34px; padding:0 2px 0 6px; border-radius:var(--gb-r-in-pop,6px); }
1764
- .gb-rel li:hover { background: var(--gb-tint,var(--gb-default-tint,#f8fafc)); }
1765
- .gb-rel-dir { width:12px; flex:none; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); font-size:12px; }
1766
- .gb-rel .gb-ibtn { min-width:24px; height:24px; padding:0; opacity:0; }
1767
- .gb-rel li:hover .gb-ibtn, .gb-rel .gb-ibtn:focus-visible { opacity:1; }
1768
- .gb-add { align-self:flex-start; display:inline-flex; align-items:center; gap:6px; height:30px; padding:0 10px 0 8px;
1769
- border:1px dashed var(--gb-border,var(--gb-default-border,#e2e8f0)); border-radius:var(--gb-r-in-face,7px); background:none;
1770
- font:inherit; font-size:12px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); cursor:pointer; }
1771
- .gb-add:hover { color: var(--gb-accent,var(--gb-default-accent,#0284c7)); border-color: var(--gb-accent,var(--gb-default-accent,#0284c7)); }
1772
1559
  /* Buttons: same height and radius as the canvas overlays. */
1773
- .gb-form-act { display:flex; align-items:center; gap:8px; }
1560
+ .gb-form-act { margin-inline-start:auto; display:flex; align-items:center; gap:8px; }
1774
1561
  .gb-btn { height:32px; padding:0 14px; border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); border-radius:var(--gb-r-in-face,7px);
1775
1562
  background: var(--gb-panel2,var(--gb-default-panel2,#fff)); color: var(--gb-text,var(--gb-default-text,#1f2937)); font:inherit; font-size:12.5px; font-weight:500; cursor:pointer;
1776
- transition: background-color .15s, border-color .15s, opacity .15s; }
1563
+ transition: background-color .15s var(--gb-ease), border-color .15s var(--gb-ease), opacity .15s var(--gb-ease); }
1777
1564
  .gb-btn:hover:not(:disabled) { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
1778
1565
  .gb-btn:disabled { opacity:.45; cursor:default; }
1779
1566
  .gb-primary { border-color:transparent; background: var(--gb-accent,var(--gb-default-accent,#0284c7)); color: var(--gb-on-accent,var(--gb-default-on-accent,#fff));
1780
1567
  box-shadow: 0 1px 2px rgba(15,23,42,.12); }
1781
1568
  .gb-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 88%, #000); }
1569
+ .gb-df :is(.gb-danger,.gb-danger-text) { display:inline-flex; align-items:center; gap:5px; }
1782
1570
  .gb-danger { border-color:transparent; background: var(--gb-err,var(--gb-default-err,#dc2626)); color:#fff; }
1783
1571
  .gb-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--gb-err,var(--gb-default-err,#dc2626)) 88%, #000); }
1784
1572
  .gb-danger-text { border-color:transparent; background:none; color: var(--gb-err,var(--gb-default-err,#dc2626)); padding:0 8px; }
@@ -1813,8 +1601,7 @@ var GK_CSS = `
1813
1601
  .gb-pastwire { fill:none; stroke: var(--gb-diff-past, ${DIFF_INK.past}); stroke-linecap:round; }
1814
1602
  .gb-diff-trunc { position:absolute; top:8px; left:8px; z-index:6; pointer-events:none;
1815
1603
  font-size:11px; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8));
1816
- background: var(--gb-panel,var(--gb-default-panel,rgba(255,255,255,.85))); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0));
1817
- border-radius:var(--gb-r-face,10px); padding:3px 7px; }
1604
+ padding:3px 7px; }
1818
1605
  `;
1819
1606
 
1820
1607
  // src/edit.ts
@@ -1854,11 +1641,15 @@ function checkEdit(model, op) {
1854
1641
  case "removeNode":
1855
1642
  if (!has(op.id)) return "no-node";
1856
1643
  return model.nodes.some((n) => n.parent === op.id) ? "has-children" : null;
1857
- case "addEdge": {
1858
- const { source, target } = op.edge;
1859
- if (!source || !target || !has(source) || !has(target)) return "no-endpoint";
1860
- if (source === target) return "self-loop";
1861
- return model.edges.some((e) => sameEdge(e, op.edge)) ? "edge-exists" : null;
1644
+ case "addEdge":
1645
+ case "updateEdge": {
1646
+ const updating = op.op === "updateEdge";
1647
+ if (updating && !model.edges.some((e) => sameEdge(e, op.edge))) return "no-edge";
1648
+ const next = updating ? { ...op.edge, ...op.set } : op.edge;
1649
+ if (!has(next.source) || !has(next.target) || !next.source || !next.target) return "no-endpoint";
1650
+ if (next.source === next.target) return "self-loop";
1651
+ if (updating && sameEdge(next, op.edge)) return null;
1652
+ return model.edges.some((e) => sameEdge(e, next)) ? "edge-exists" : null;
1862
1653
  }
1863
1654
  case "removeEdge":
1864
1655
  return model.edges.some((e) => sameEdge(e, op.edge)) ? null : "no-edge";
@@ -1924,7 +1715,7 @@ function apply(model, op, profile) {
1924
1715
  );
1925
1716
  case "addEdge": {
1926
1717
  const { kind, label, weight, source, target } = op.edge;
1927
- const origin = model.index.get(source)?.origin;
1718
+ const origin = op.origin ?? model.index.get(source)?.origin;
1928
1719
  const edge = {
1929
1720
  source,
1930
1721
  target,
@@ -1935,6 +1726,23 @@ function apply(model, op, profile) {
1935
1726
  };
1936
1727
  return buildModel(model.nodes, [...model.edges, edge], model.errors);
1937
1728
  }
1729
+ case "updateEdge":
1730
+ return buildModel(model.nodes, model.edges.map((e) => {
1731
+ if (!sameEdge(e, op.edge)) return e;
1732
+ const next = { ...e, ...op.set };
1733
+ if (!next.kind) delete next.kind;
1734
+ if (!next.label) delete next.label;
1735
+ if (e.data) {
1736
+ next.data = { ...e.data, source: next.source, target: next.target };
1737
+ if ("from" in next.data) next.data.from = next.source;
1738
+ if ("to" in next.data) next.data.to = next.target;
1739
+ for (const key of ["kind", "label"]) {
1740
+ if (next[key] !== void 0) next.data[key] = next[key];
1741
+ else delete next.data[key];
1742
+ }
1743
+ }
1744
+ return next;
1745
+ }), model.errors);
1938
1746
  case "removeEdge":
1939
1747
  return buildModel(model.nodes, model.edges.filter((e) => !sameEdge(e, op.edge)), model.errors);
1940
1748
  }
@@ -1951,558 +1759,133 @@ function applyEdits(model, ops, profile) {
1951
1759
  }
1952
1760
  var checkNativeEdit = checkEdit;
1953
1761
 
1954
- // src/animate.ts
1955
- var easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
1956
- var easeInOutCubic = (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
1957
- var easeOutBack = (s) => (t) => {
1958
- const u = t - 1;
1959
- return 1 + (s + 1) * u * u * u + s * u * u;
1960
- };
1961
- var easeDrift = (t) => 0.2 * (1 - Math.pow(1 - t, 3)) + 0.8 * t;
1962
- var DEFAULT_ANIMATE = {
1963
- duration: 1800,
1964
- easing: easeInOutCubic,
1965
- drift: 0.08,
1966
- bounce: 0.6,
1967
- maxNodes: 3e3
1968
- };
1969
- function resolveSpec(a) {
1970
- if (a === false) return null;
1971
- if (a === true || a === void 0) return DEFAULT_ANIMATE;
1972
- return { ...DEFAULT_ANIMATE, ...a };
1973
- }
1974
- var BEATS = {
1975
- cut: [0, 0.1],
1976
- snap: [0.07, 0.2],
1977
- leaf: [0.18, 0.95],
1978
- move: [0.22, 0.74],
1979
- present: [0.64, 0.94],
1980
- sprout: [0.68, 1],
1981
- graft: [0.86, 1],
1982
- open: [0, 0.3],
1983
- close: [0.58, 1]
1984
- };
1985
- var TRACK_NAMES = Object.keys(BEATS);
1986
- var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
1987
- var trackLin = (tr, t) => {
1988
- const span = tr.to - tr.from;
1989
- return span > 0 ? clamp01((t - tr.from) / span) : 0;
1990
- };
1991
- var trackAt = (tr, t) => {
1992
- const p = trackLin(tr, t);
1993
- return p <= 0 ? 0 : p >= 1 ? 1 : tr.ease(p);
1994
- };
1995
- var SNAP_DIM = 0.4;
1996
- var FADE_NAMES = ["cut", "out", "in", "graft"];
1997
- var ENVELOPES = {
1998
- /** Edges across the cut: **break at once**, faster than anything. */
1999
- cut: { base: 1, legs: [{ track: "cut", d: -1 }] },
2000
- /** The leaving piece: dims a notch when it springs off, then fades the whole way while drifting. */
2001
- out: { base: 1, legs: [{ track: "snap", d: -SNAP_DIM }, { track: "leaf", d: -(1 - SNAP_DIM) }] },
2002
- /** Entering nodes and the edges growing with them. */
2003
- in: { base: 0, legs: [{ track: "present", d: 1 }] },
2004
- /** New edges into the existing structure: **connected last**. */
2005
- graft: { base: 0, legs: [{ track: "graft", d: 1 }] }
2006
- };
2007
- function edgeFade(from, to, flag) {
2008
- if (flag === "removed" || from === "gone" || to === "gone") {
2009
- return from === "gone" && to === "gone" ? "out" : "cut";
1762
+ // src/strings.ts
1763
+ var EN = {
1764
+ empty: "No data yet",
1765
+ viewSubtree: "Scope",
1766
+ viewSubtreeTip: "View subtree",
1767
+ restructureFull: "Re-structure full graph",
1768
+ exitScopeLabel: "Exit scope",
1769
+ exitScope: "Return to full graph",
1770
+ absentNode: "This node is absent in this pass.",
1771
+ absentSource: "No graph content from this file in this pass.",
1772
+ enteredScope: "Moved into view",
1773
+ leftScope: "Moved out of view",
1774
+ noLocalFloors: "No layers in this subgraph.",
1775
+ stats: (n, e) => `${n} nodes \xB7 ${e} edges`,
1776
+ layingOut: (d, t) => `Laying out ${d}/${t}`,
1777
+ preparing: "Preparing layout\u2026",
1778
+ parseErrors: (c, names) => `\u26A0 ${c} source${c > 1 ? "s" : ""} could not be parsed: ${names}`,
1779
+ past: "past",
1780
+ now: "now",
1781
+ diffTruncated: (n) => `${n} more changes not marked (over the limit)`,
1782
+ change: { added: "Added", removed: "Removed", changed: "Changed", moved: "Moved", merged: "Merged" },
1783
+ search: "Search nodes",
1784
+ searchTip: "Several words: as many as possible; /\u2026/ is a regex",
1785
+ clearSearch: "Clear search",
1786
+ noMatch: (q, elsewhere) => `No \u201C${q}\u201D${elsewhere ? " in this layer" : ""}`,
1787
+ moreResults: (n) => `${n} more \u2014 keep typing to narrow down`,
1788
+ inLayer: (l, n) => `${n} in \u201C${l}\u201D`,
1789
+ keysBrowse: "browse",
1790
+ keysPick: "select",
1791
+ keysClear: "clear",
1792
+ viewLayer: (l) => `View \u201C${l}\u201D`,
1793
+ stackLayer: (l, on) => `${on ? "Hide" : "Stack"} \u201C${l}\u201D`,
1794
+ stack: "Stack layers",
1795
+ stackTip: (on) => on ? "Stacked (turn off to view one layer at a time)" : "Stack layers (2.5D)",
1796
+ layersOff: "Layers are off",
1797
+ forceLayers: "Open the floors anyway",
1798
+ ok: "OK",
1799
+ more: "More",
1800
+ origins: "Source",
1801
+ allOrigins: "All sources",
1802
+ issuesBySource: (review, lint) => {
1803
+ const count = (n) => `${n} ${n === 1 ? "category" : "categories"}`;
1804
+ return `Data review \xB7 ${count(review)} / Graph lint \xB7 ${count(lint)}`;
1805
+ },
1806
+ issuesTip: (e, w, i) => [e && `${e} error${e > 1 ? "s" : ""}`, w && `${w} warning${w > 1 ? "s" : ""}`, i && `${i} info`].filter(Boolean).join(" \xB7 "),
1807
+ issuesTitle: (e, w, i, groups) => {
1808
+ const count = groups ?? e + w + (i ?? 0);
1809
+ return count ? `Graph checks \xB7 ${count} ${count === 1 ? "category" : "categories"}` : "Graph checks \xB7 No findings";
1810
+ },
1811
+ moreItems: (n) => `${n} more`,
1812
+ cameraTip: "Scroll / two fingers to pan \xB7 \u2318 + scroll or pinch to zoom",
1813
+ zoomIn: "Zoom in (+)",
1814
+ zoomOut: "Zoom out (-)",
1815
+ fit: "Fit (0)",
1816
+ legend: "Legend",
1817
+ legendPlainName: "Default",
1818
+ noColor: "no colour set",
1819
+ legendPlain: "Nodes without a color of their own: containers and placeholders, shaded by how much hangs under them",
1820
+ legendContainsName: "Contains",
1821
+ legendHint: "Hover an item: color, hide, size",
1822
+ legendContains: "Containment: one shade from light to dark, trunk thick, leaves thin",
1823
+ legendShow: "Show",
1824
+ legendHide: "Hide",
1825
+ legendHideTip: "Hide in the overview \u2014 still shown on hover, selection and search",
1826
+ legendColor: "Color",
1827
+ legendSize: "Size",
1828
+ legendReset: "Reset",
1829
+ node: "Node",
1830
+ edge: "Edge",
1831
+ back: "Back",
1832
+ showLess: "Show less",
1833
+ position: "Position",
1834
+ beforeSibling: "Before",
1835
+ lastSibling: "Last",
1836
+ inEdges: "In-edges",
1837
+ outEdges: "Out-edges",
1838
+ noDetails: "No details yet",
1839
+ close: "Close",
1840
+ addNode: "Add node\u2026",
1841
+ addEdge: "Add edge\u2026",
1842
+ relayout: "Re-layout",
1843
+ restructure: "Re-structure",
1844
+ edit: "Edit",
1845
+ editNode: "Edit node",
1846
+ newNode: "New node",
1847
+ newEdge: "New edge",
1848
+ editEdge: "Edit edge",
1849
+ clearField: "Clear",
1850
+ id: "id",
1851
+ idHint: "Unique, cannot be changed later",
1852
+ parent: "Inside",
1853
+ noParent: "Top level",
1854
+ source: "From",
1855
+ target: "To",
1856
+ kind: "Kind",
1857
+ edgeLabel: "Label",
1858
+ content: "Content",
1859
+ contentHint: "JSON",
1860
+ badJson: "Not valid JSON (an object is expected)",
1861
+ relations: "Edges",
1862
+ removeEdge: "Remove this edge",
1863
+ pick: "Search a node\u2026",
1864
+ cancel: "Cancel",
1865
+ save: "Save",
1866
+ create: "Create",
1867
+ remove: "Delete",
1868
+ confirmRemove: (n) => n ? `Delete, with its ${n} edge${n > 1 ? "s" : ""}?` : "Delete?",
1869
+ error: {
1870
+ "id-empty": "id is required",
1871
+ "id-taken": "This id is already used",
1872
+ "no-node": "Node not found",
1873
+ "no-parent": "Parent not found",
1874
+ cycle: "Cannot be placed inside itself",
1875
+ "invalid-position": "Choose a different node in the same children list",
1876
+ "order-invalid": "Order must be positive and unique among siblings (blank = unordered)",
1877
+ "has-children": "Has children \u2014 delete or move them first",
1878
+ "no-endpoint": "Pick both ends",
1879
+ "self-loop": "Both ends are the same node",
1880
+ "edge-exists": "This edge already exists",
1881
+ "no-edge": "Edge not found"
2010
1882
  }
2011
- if (flag === "added" || from === "new" || to === "new") {
2012
- return from === "new" || to === "new" ? "in" : "graft";
2013
- }
2014
- return null;
2015
- }
2016
- var FADE_BASE = {
2017
- cut: ENVELOPES.cut.base,
2018
- out: ENVELOPES.out.base,
2019
- in: ENVELOPES.in.base,
2020
- graft: ENVELOPES.graft.base
2021
- };
2022
- var fadeAt = (name, sc, t) => {
2023
- const e = ENVELOPES[name];
2024
- let v = e.base;
2025
- for (const l of e.legs) v += l.d * trackLin(sc[l.track], t);
2026
- return v;
2027
1883
  };
2028
- function makeScore(spec, active = {}) {
2029
- const on = [];
2030
- if (active.leaf) on.push("cut", "snap", "leaf");
2031
- if (active.move) on.push("move");
2032
- if (active.present) on.push("present", "sprout", "graft");
2033
- const lead = on.length ? Math.min(...on.map((n) => BEATS[n][0])) : 0;
2034
- const span = Math.max(1e-6, 1 - lead);
2035
- const cut = (v) => clamp01((v - lead) / span);
2036
- const ease = {
2037
- cut: (t) => t,
2038
- // a cut is an instant, not a stretch
2039
- snap: easeOutCubic,
2040
- // spring off: fastest at first, stops on arrival
2041
- leaf: easeDrift,
2042
- // then drift steadily to the end
2043
- move: spec.easing,
2044
- // sigmoid
2045
- present: (t) => t,
2046
- // envelopes take no curve
2047
- sprout: easeOutBack(spec.bounce),
2048
- graft: (t) => t,
2049
- open: easeInOutCubic,
2050
- close: easeInOutCubic
2051
- };
2052
- const out = { span };
2053
- for (const n of TRACK_NAMES) {
2054
- out[n] = { from: cut(BEATS[n][0]), to: cut(BEATS[n][1]), ease: ease[n] };
2055
- }
2056
- return out;
2057
- }
2058
- function edgeTraffic(delta) {
2059
- let i = 0, o = 0;
2060
- for (const e of delta.model.edges) {
2061
- const f = e.flags;
2062
- if (!f) continue;
2063
- if (f.includes(DIFF_FLAG.added) || f.includes(STEP_FLAG.added)) i++;
2064
- else if (f.includes(DIFF_FLAG.removed) || f.includes(STEP_FLAG.removed)) o++;
2065
- }
2066
- return { in: i, out: o };
2067
- }
2068
- var NOT_OURS = /^(display|visibility|opacity|z-|transition-|events|text-events|min-zoomed)/;
2069
- var GEOMETRY = /^(padding|shape|font-|text-|label|source-arrow-shape|target-arrow-shape)/;
2070
- var SKIN_SIZE_PROPS = ["width", "height"];
2071
- var RGB = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,/\s]+([\d.]+))?\s*\)$/;
2072
- function asColor(v) {
2073
- const m = RGB.exec(String(v));
2074
- return m ? [+m[1], +m[2], +m[3], m[4] === void 0 ? 1 : +m[4]] : null;
2075
- }
2076
- function asNumber(v) {
2077
- if (typeof v === "number") return Number.isFinite(v) ? v : null;
2078
- const m = /^(-?[\d.]+)(px)?$/.exec(String(v).trim());
2079
- if (!m) return null;
2080
- const n = Number(m[1]);
2081
- return Number.isFinite(n) ? n : null;
2082
- }
2083
- function diffSkinStyle(past, now) {
2084
- const tween = [];
2085
- const steps = {};
2086
- for (const prop of Object.keys(now)) {
2087
- if (/[A-Z]/.test(prop) || NOT_OURS.test(prop) || GEOMETRY.test(prop)) continue;
2088
- const a = past[prop], b = now[prop];
2089
- if (a === void 0 || a === b || String(a) === String(b)) continue;
2090
- const [ca, cb] = [asColor(a), asColor(b)];
2091
- if (ca && cb) {
2092
- tween.push({ prop, from: ca, to: cb, color: true });
2093
- continue;
2094
- }
2095
- const [na, nb] = [asNumber(a), asNumber(b)];
2096
- if (na !== null && nb !== null) {
2097
- tween.push({ prop, from: [na], to: [nb], color: false });
2098
- continue;
2099
- }
2100
- steps[prop] = a;
2101
- }
2102
- return { tween, steps };
2103
- }
2104
- function sampleSkinStyle(tween, p) {
2105
- const out = {};
2106
- for (const t of tween) {
2107
- const v = t.from.map((f, i) => f + (t.to[i] - f) * p);
2108
- out[t.prop] = t.color ? `rgba(${Math.round(v[0])},${Math.round(v[1])},${Math.round(v[2])},${v[3]})` : v[0];
2109
- }
2110
- return out;
2111
- }
2112
- var MOVED_EPS = 1.5;
2113
- var SNAP_KICK = 0.3;
2114
- function anchorOf(id, seen, parentOf) {
2115
- const walked = /* @__PURE__ */ new Set([id]);
2116
- let cur = parentOf(id);
2117
- while (cur && !walked.has(cur)) {
2118
- if (seen(cur)) return cur;
2119
- walked.add(cur);
2120
- cur = parentOf(cur);
2121
- }
2122
- return void 0;
2123
- }
2124
- function planTransition(delta, from, union, opts = {}) {
2125
- const skins = opts.skins ?? [];
2126
- const spec = opts.spec ?? DEFAULT_ANIMATE;
2127
- const drift = spec.drift;
2128
- const items = [];
2129
- const leaving = /* @__PURE__ */ new Set();
2130
- const report = {
2131
- total: 0,
2132
- moved: 0,
2133
- movedMedian: 0,
2134
- entering: 0,
2135
- leaving: 0,
2136
- relocated: 0,
2137
- converging: 0,
2138
- restyled: skins.length,
2139
- pieces: 0,
2140
- edgesIn: 0,
2141
- edgesOut: 0
2142
- };
2143
- const dists = [];
2144
- if (delta) ({ in: report.edgesIn, out: report.edgesOut } = edgeTraffic(delta));
2145
- const at = (id) => from[id] ?? union[id];
2146
- const ids = Object.keys(union);
2147
- const kindOf = (id) => {
2148
- const k = delta?.byId.get(id)?.kind;
2149
- if (k) return k;
2150
- const p = opts.presence?.get(id);
2151
- return p === "gone" ? "removed" : p === "new" ? "added" : void 0;
2152
- };
2153
- const parentOf = opts.parentOf ?? (() => {
2154
- const model = /* @__PURE__ */ new Map();
2155
- for (const n of delta?.model.nodes ?? []) if (n.parent) model.set(n.id, n.parent);
2156
- const root = union[VIRTUAL_ROOT] ? VIRTUAL_ROOT : void 0;
2157
- return (id) => model.get(id) ?? (id === root ? void 0 : root);
2158
- })();
2159
- const hub = { x: 0, y: 0 };
2160
- for (const id of ids) {
2161
- hub.x += union[id].x / ids.length;
2162
- hub.y += union[id].y / ids.length;
2163
- }
2164
- const jitter = (seed) => {
2165
- let h = 2166136261;
2166
- for (let i = 0; i < seed.length; i++) {
2167
- h ^= seed.charCodeAt(i);
2168
- h = Math.imul(h, 16777619);
2169
- }
2170
- return (h >>> 0) % 2048 / 2048;
2171
- };
2172
- const bb = { x1: Infinity, y1: Infinity, x2: -Infinity, y2: -Infinity };
2173
- for (const id of ids) {
2174
- const q = union[id];
2175
- bb.x1 = Math.min(bb.x1, q.x);
2176
- bb.x2 = Math.max(bb.x2, q.x);
2177
- bb.y1 = Math.min(bb.y1, q.y);
2178
- bb.y2 = Math.max(bb.y2, q.y);
2179
- }
2180
- const span = Math.max(bb.x2 - bb.x1, bb.y2 - bb.y1) || 0;
2181
- const cutIds = /* @__PURE__ */ new Set();
2182
- for (const id of ids) if (kindOf(id) === "removed") cutIds.add(id);
2183
- const topOf = /* @__PURE__ */ new Map();
2184
- const climb = (id) => {
2185
- const path = [];
2186
- let cur = id;
2187
- for (; ; ) {
2188
- const hit = topOf.get(cur);
2189
- if (hit) {
2190
- for (const q of path) topOf.set(q, hit);
2191
- return hit;
2192
- }
2193
- const pa = parentOf(cur);
2194
- if (!pa || !cutIds.has(pa) || path.includes(cur)) break;
2195
- path.push(cur);
2196
- cur = pa;
2197
- }
2198
- for (const q of path) topOf.set(q, cur);
2199
- topOf.set(cur, cur);
2200
- return cur;
2201
- };
2202
- const crew = /* @__PURE__ */ new Map();
2203
- for (const id of cutIds) {
2204
- const top = climb(id);
2205
- const list = crew.get(top);
2206
- if (list) list.push(id);
2207
- else crew.set(top, [id]);
2208
- }
2209
- const piece = /* @__PURE__ */ new Map();
2210
- for (const [top, mates] of crew) {
2211
- const pa = parentOf(top);
2212
- const anchor = pa && union[pa] ? at(pa) : hub;
2213
- const legs = [];
2214
- let cx = 0, cy = 0;
2215
- for (const m of mates) {
2216
- cx += at(m).x / mates.length;
2217
- cy += at(m).y / mates.length;
2218
- }
2219
- const r = Math.hypot(cx - anchor.x, cy - anchor.y);
2220
- const ang = jitter(`${top}@`) * Math.PI * 2;
2221
- const ux = r > 1e-6 ? (cx - anchor.x) / r : Math.cos(ang);
2222
- const uy = r > 1e-6 ? (cy - anchor.y) / r : Math.sin(ang);
2223
- const len = drift * span * (0.7 + 0.6 * jitter(top));
2224
- const side = 0.32 * (jitter(`${top}~`) * 2 - 1);
2225
- const [dx, dy] = [(ux - uy * side) * len, (uy + ux * side) * len];
2226
- if (len > 0) {
2227
- legs.push({ track: "snap", dx: dx * SNAP_KICK, dy: dy * SNAP_KICK });
2228
- legs.push({ track: "leaf", dx: dx * (1 - SNAP_KICK), dy: dy * (1 - SNAP_KICK) });
2229
- }
2230
- piece.set(top, legs);
2231
- }
2232
- report.pieces = crew.size;
2233
- for (const id of ids) {
2234
- const to = union[id];
2235
- const c = delta?.byId.get(id);
2236
- const kind = kindOf(id);
2237
- report.total++;
2238
- if (kind === "removed" || kind === "merged") {
2239
- leaving.add(id);
2240
- report.leaving++;
2241
- const base = at(id);
2242
- const pair = kind === "merged" && c.pairId ? c.pairId : void 0;
2243
- if (pair && union[pair]) {
2244
- report.converging++;
2245
- const pf = at(pair);
2246
- items.push({
2247
- id,
2248
- x: base.x,
2249
- y: base.y,
2250
- legs: [
2251
- { track: "move", dx: union[pair].x - pf.x, dy: union[pair].y - pf.y },
2252
- { track: "leaf", dx: pf.x - base.x, dy: pf.y - base.y }
2253
- ]
2254
- });
2255
- continue;
2256
- }
2257
- items.push({ id, x: base.x, y: base.y, legs: piece.get(topOf.get(id) ?? id) ?? [] });
2258
- continue;
2259
- }
2260
- if (kind === "added") {
2261
- report.entering++;
2262
- const anc = anchorOf(id, (q) => !!from[q], parentOf);
2263
- if (anc && union[anc]) {
2264
- const pf = from[anc];
2265
- items.push({
2266
- id,
2267
- x: pf.x,
2268
- y: pf.y,
2269
- legs: [
2270
- { track: "move", dx: union[anc].x - pf.x, dy: union[anc].y - pf.y },
2271
- { track: "sprout", dx: to.x - union[anc].x, dy: to.y - union[anc].y }
2272
- ]
2273
- });
2274
- } else {
2275
- items.push({ id, x: to.x, y: to.y, legs: [] });
2276
- }
2277
- continue;
2278
- }
2279
- if (kind === "moved") {
2280
- report.relocated++;
2281
- const a0 = at(id);
2282
- items.push({ id, x: a0.x, y: a0.y, legs: [{ track: "move", dx: to.x - a0.x, dy: to.y - a0.y }] });
2283
- continue;
2284
- }
2285
- const a = at(id);
2286
- const d = Math.hypot(a.x - to.x, a.y - to.y);
2287
- if (d > MOVED_EPS) {
2288
- report.moved++;
2289
- dists.push(d);
2290
- }
2291
- items.push({ id, x: a.x, y: a.y, legs: [{ track: "move", dx: to.x - a.x, dy: to.y - a.y }] });
2292
- }
2293
- if (dists.length) {
2294
- dists.sort((x, y) => x - y);
2295
- report.movedMedian = Math.round(dists[dists.length >> 1]);
2296
- }
2297
- const worth = report.moved + report.entering + report.leaving + report.relocated + report.restyled + report.edgesIn + report.edgesOut > 0;
2298
- const score = makeScore(spec, {
2299
- // A branch move counts on both sides: it is **one containment edge gone + one containment edge come**, so both cut and graft
2300
- // have content. Counting only node additions and removals would judge the step "motion only", then empty-beat trimming
2301
- // squeezes cut to zero width, and the old link would not "break" but "vanish within a frame".
2302
- leaf: report.leaving + report.edgesOut + report.relocated > 0,
2303
- move: report.moved + report.relocated > 0,
2304
- present: report.entering + report.edgesIn + report.restyled + report.relocated > 0
2305
- });
2306
- return { items, skins, score, leaving, worth, report };
2307
- }
2308
- function planSkins(delta, prev, next, profile) {
2309
- if (!delta || !prev) return [];
2310
- const kids = (m) => {
2311
- const s = /* @__PURE__ */ new Set();
2312
- for (const n of m.nodes) if (n.parent) s.add(n.parent);
2313
- return s;
2314
- };
2315
- const [pKids, nKids] = [kids(prev), kids(next)];
2316
- const skin = (n) => n.flags?.some((f) => f.startsWith("gb-")) ? { ...n, flags: n.flags.filter((f) => !f.startsWith("gb-")) } : n;
2317
- const out = [];
2318
- for (const [oldId, unionId] of delta.resolved) {
2319
- const a = prev.index.get(oldId), b = next.index.get(unionId);
2320
- if (!a || !b) continue;
2321
- const past = nodeClasses(skin(a), profile, { container: pKids.has(oldId) });
2322
- const now = nodeClasses(skin(b), profile, { container: nKids.has(unionId) });
2323
- if (past !== now) out.push({ id: unionId, past, now });
2324
- }
2325
- return out;
2326
- }
2327
- function leavingOf(delta) {
2328
- const out = /* @__PURE__ */ new Set();
2329
- for (const c of delta?.changes ?? []) if (c.kind === "removed" || c.kind === "merged") out.add(c.id);
2330
- return out;
2331
- }
2332
- function sampleTransition(t, time) {
2333
- const sc = t.score;
2334
- const s = {};
2335
- for (const n of TRACK_NAMES) s[n] = trackAt(sc[n], time);
2336
- const pos = {};
2337
- for (const it of t.items) {
2338
- let { x, y } = it;
2339
- for (const l of it.legs) {
2340
- const k = s[l.track];
2341
- x += l.dx * k;
2342
- y += l.dy * k;
2343
- }
2344
- pos[it.id] = { x, y };
2345
- }
2346
- const fade = {};
2347
- for (const n of FADE_NAMES) fade[n] = fadeAt(n, sc, time);
2348
- return { pos, fade, open: s.open, close: s.close };
2349
- }
2350
-
2351
- // src/layout/diff-layout.ts
2352
- function repOf(model, pos) {
2353
- const idx = indexModel(model);
2354
- const memo = /* @__PURE__ */ new Map();
2355
- const walk = (id) => {
2356
- const hit = memo.get(id);
2357
- if (hit !== void 0) return hit;
2358
- memo.set(id, null);
2359
- const own = pos[id];
2360
- let out = own ? { x: own.x, y: own.y } : null;
2361
- if (!out) {
2362
- let sx = 0, sy = 0, n = 0;
2363
- for (const c of idx.childrenOf.get(id) ?? []) {
2364
- const p = walk(c);
2365
- if (p) {
2366
- sx += p.x;
2367
- sy += p.y;
2368
- n++;
2369
- }
2370
- }
2371
- out = n ? { x: sx / n, y: sy / n } : null;
2372
- }
2373
- memo.set(id, out);
2374
- return out;
2375
- };
2376
- return walk;
2377
- }
2378
- function adjacency(m) {
2379
- const adj = /* @__PURE__ */ new Map();
2380
- const link = (a, b) => {
2381
- let s = adj.get(a);
2382
- if (!s) adj.set(a, s = /* @__PURE__ */ new Set());
2383
- s.add(b);
2384
- };
2385
- for (const n of m.nodes) if (n.parent) {
2386
- link(n.id, n.parent);
2387
- link(n.parent, n.id);
2388
- }
2389
- for (const e of m.edges) {
2390
- link(e.source, e.target);
2391
- link(e.target, e.source);
2392
- }
2393
- return adj;
2394
- }
2395
- function bboxOf(ids, pos) {
2396
- let x1 = Infinity, y1 = Infinity, x2 = -Infinity, y2 = -Infinity, n = 0;
2397
- for (const id of ids) {
2398
- const p = pos[id];
2399
- if (!p) continue;
2400
- n++;
2401
- x1 = Math.min(x1, p.x);
2402
- y1 = Math.min(y1, p.y);
2403
- x2 = Math.max(x2, p.x);
2404
- y2 = Math.max(y2, p.y);
2405
- }
2406
- return n ? { x1, y1, x2, y2, w: x2 - x1, h: y2 - y1 } : null;
2407
- }
2408
- function diffPositions(sides, posBefore, posAfter) {
2409
- const out = { ...posAfter };
2410
- const alive = sides.after.index;
2411
- const ghostSet = /* @__PURE__ */ new Set();
2412
- for (const n of sides.before.nodes) if (!alive.has(n.id)) ghostSet.add(n.id);
2413
- if (!ghostSet.size) return out;
2414
- const adj = adjacency(sides.before);
2415
- const repB = repOf(sides.before, posBefore);
2416
- const repA = repOf(sides.after, posAfter);
2417
- const seen = /* @__PURE__ */ new Set();
2418
- const parked = [];
2419
- for (const n of sides.before.nodes) {
2420
- const start = n.id;
2421
- if (!ghostSet.has(start) || seen.has(start)) continue;
2422
- const comp = [];
2423
- const anchors = /* @__PURE__ */ new Set();
2424
- const stack = [start];
2425
- seen.add(start);
2426
- while (stack.length) {
2427
- const id = stack.pop();
2428
- comp.push(id);
2429
- for (const nb of adj.get(id) ?? []) {
2430
- if (ghostSet.has(nb)) {
2431
- if (!seen.has(nb)) {
2432
- seen.add(nb);
2433
- stack.push(nb);
2434
- }
2435
- } else if (alive.has(nb)) anchors.add(nb);
2436
- }
2437
- }
2438
- let dx = 0, dy = 0, k = 0;
2439
- for (const a of anchors) {
2440
- const b = repB(a), f = repA(a);
2441
- if (b && f) {
2442
- dx += f.x - b.x;
2443
- dy += f.y - b.y;
2444
- k++;
2445
- }
2446
- }
2447
- if (!k) {
2448
- parked.push(comp);
2449
- continue;
2450
- }
2451
- dx /= k;
2452
- dy /= k;
2453
- for (const g of comp) {
2454
- const p = posBefore[g];
2455
- if (p) out[g] = { x: p.x + dx, y: p.y + dy };
2456
- }
2457
- }
2458
- if (parked.length) {
2459
- const main = bboxOf(Object.keys(posAfter), posAfter);
2460
- const ids = parked.flat();
2461
- const block = bboxOf(ids, posBefore);
2462
- const dx = block && main ? (main.x1 + main.x2) / 2 - (block.x1 + block.x2) / 2 : 0;
2463
- const dy = block && main ? (main.y1 + main.y2) / 2 - (block.y1 + block.y2) / 2 : 0;
2464
- for (const id of ids) {
2465
- const p = posBefore[id];
2466
- if (p) out[id] = { x: p.x + dx, y: p.y + dy };
2467
- }
2468
- }
2469
- return out;
2470
- }
2471
- var DEFAULT_DIFF_LAYOUT = { rounds: 1, iterations: 12, snap: true };
2472
- var EMPTY = /* @__PURE__ */ new Set();
2473
- function split(pos, shared) {
2474
- const a = {}, b = {};
2475
- for (const [id, p] of Object.entries(pos)) (shared.has(id) ? a : b)[id] = p;
2476
- return { shared: a, own: b };
2477
- }
2478
- async function solveDiffLayout(sides, base, solve, spec = {}) {
2479
- const rounds = Math.max(0, Math.floor(spec.rounds ?? DEFAULT_DIFF_LAYOUT.rounds));
2480
- const snap = spec.snap !== false;
2481
- const shared = /* @__PURE__ */ new Set();
2482
- for (const n of sides.before.nodes) if (sides.after.index.has(n.id)) shared.add(n.id);
2483
- const seeded = diffPositions(sides, base.before, base.after);
2484
- let x = split(seeded, shared).shared;
2485
- let ownA = split(seeded, shared).own;
2486
- let ownB = split(base.after, shared).own;
2487
- for (const id of Object.keys(ownA)) if (sides.after.index.has(id)) delete ownA[id];
2488
- for (const id of Object.keys(ownB)) if (sides.before.index.has(id)) delete ownB[id];
2489
- const steps = [];
2490
- let iter = Math.max(0, Math.floor(spec.iterations ?? DEFAULT_DIFF_LAYOUT.iterations));
2491
- for (let k = 0; k < rounds && iter > 0; k++) {
2492
- const side = k % 2 === 0 ? "before" : "after";
2493
- const seed = { ...x, ...side === "before" ? ownA : ownB };
2494
- const got = await solve(side, seed, iter, snap ? shared : EMPTY);
2495
- const parts = split(got, shared);
2496
- if (side === "before") ownA = parts.own;
2497
- else ownB = parts.own;
2498
- if (!snap) x = parts.shared;
2499
- steps.push({ side, iterations: iter });
2500
- iter = Math.floor(iter / 2);
2501
- }
2502
- return { past: { ...x, ...ownA }, now: { ...x, ...ownB }, steps };
2503
- }
2504
1884
 
2505
1885
  export {
1886
+ treeDeclarations,
1887
+ treeNodes,
1888
+ serializeTree,
2506
1889
  EMPTY_MODEL,
2507
1890
  buildModel,
2508
1891
  mergeSlices,
@@ -2510,17 +1893,12 @@ export {
2510
1893
  originsOfNode,
2511
1894
  indexModel,
2512
1895
  originsOf,
2513
- parsePhysical,
2514
- toPhysical,
2515
- toBundle,
2516
- validateStructure,
2517
- kindTable,
2518
- defineProfile,
2519
- defaultProfile,
2520
- parseSources,
2521
- validateModel,
2522
1896
  DIFF_FLAG,
2523
1897
  KEPT_FLAG,
1898
+ stable,
1899
+ edgeKey,
1900
+ edgeContent,
1901
+ edgeContentChanged,
2524
1902
  diffModels,
2525
1903
  unionSides,
2526
1904
  STEP_FLAG,
@@ -2536,15 +1914,6 @@ export {
2536
1914
  buildElements,
2537
1915
  isNodeEl,
2538
1916
  countByKind,
2539
- FULL_VIEW,
2540
- planeView,
2541
- isFiltering,
2542
- isNarrowing,
2543
- originView,
2544
- resolveView,
2545
- parseQuery,
2546
- queryMarker,
2547
- searchNodes,
2548
1917
  PLANE_HUES,
2549
1918
  plateColors,
2550
1919
  LIGHT_THEME,
@@ -2569,38 +1938,13 @@ export {
2569
1938
  DIFF_COLORS,
2570
1939
  diffStyle,
2571
1940
  chromeStyle,
1941
+ HOVER_FADE_MS,
2572
1942
  GK_CSS,
1943
+ sameEdge,
2573
1944
  checkEdit,
2574
1945
  edgesOf,
2575
1946
  applyEdit,
2576
1947
  applyEdits,
2577
1948
  checkNativeEdit,
2578
- easeOutCubic,
2579
- easeInOutCubic,
2580
- easeOutBack,
2581
- easeDrift,
2582
- DEFAULT_ANIMATE,
2583
- resolveSpec,
2584
- TRACK_NAMES,
2585
- trackLin,
2586
- trackAt,
2587
- SNAP_DIM,
2588
- FADE_NAMES,
2589
- ENVELOPES,
2590
- edgeFade,
2591
- FADE_BASE,
2592
- fadeAt,
2593
- makeScore,
2594
- edgeTraffic,
2595
- SKIN_SIZE_PROPS,
2596
- diffSkinStyle,
2597
- sampleSkinStyle,
2598
- anchorOf,
2599
- planTransition,
2600
- planSkins,
2601
- leavingOf,
2602
- sampleTransition,
2603
- diffPositions,
2604
- DEFAULT_DIFF_LAYOUT,
2605
- solveDiffLayout
1949
+ EN
2606
1950
  };