bruce-cesium 7.8.1 → 7.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import * as Cesium from 'cesium';
2
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, Cartesian3, Model, ClassificationType, Matrix4, JulianDate, Quaternion, ArcType, CornerType, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, Cartesian2, Cartesian4, SceneMode, Ellipsoid, IntersectionTests, Ray, SceneTransforms, ShaderSource, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Intersect, WebGLConstants, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, CesiumInspector, ClockRange, ShadowMode, DynamicEnvironmentMapManager, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, Event, GeometryInstance, CustomDataSource, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
- import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, EntityLod, UrlUtils, Geometry as Geometry$1, Api, Bounds, ClientFileValueMap, Color as Color$1, ProjectView, ProjectViewBookmark, ZoomControl, Assembly, EntityCoords, BruceApi, EntityRelation, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, ProjectViewBookmarkGroup, EntityAttachment, EntityAttribute, MathUtils } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, Cartesian3, ClassificationType, ShaderSource, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, ArcType, CornerType, ColorBlendMode, HeadingPitchRoll, Model, JulianDate, Quaternion, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, Cesium3DTileset, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, WebGLConstants, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, ShadowMode, CustomDataSource, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, GeometryInstance, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, Event, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
+ import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, Api, Geometry as Geometry$1, EntityLod, UrlUtils, Bounds, ClientFileValueMap, Color as Color$1, Assembly, EntityCoords, ZoomControl, ProjectView, ProjectViewBookmark, EntityRelation, BruceApi, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, EntityAttachment, EntityAttribute, MathUtils, ProjectViewBookmarkGroup } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -6690,6 +6690,17 @@ function GetClusterIconPriority(options) {
6690
6690
  * Groups eligible neighbours around stable representatives without coupling membership to its renderer.
6691
6691
  */
6692
6692
  function ClusterItems(params) {
6693
+ const steps = ClusterItemsInSteps(params, Infinity);
6694
+ let next = steps.next();
6695
+ while (!next.done) {
6696
+ next = steps.next();
6697
+ }
6698
+ return next.value;
6699
+ }
6700
+ /*
6701
+ * ClusterItems as steps, pausing after every so many representatives tried, so a caller can spread one run over frames.
6702
+ */
6703
+ function* ClusterItemsInSteps(params, every = 32) {
6693
6704
  const eligible = new Map();
6694
6705
  for (const item of params.items) {
6695
6706
  if (!params.eligible || params.eligible(item)) {
@@ -6699,12 +6710,21 @@ function ClusterItems(params) {
6699
6710
  const assigned = new Set();
6700
6711
  const result = [];
6701
6712
  const minimum = Math.max(2, params.minSize || 2);
6713
+ const free = (other) => {
6714
+ const key = params.id(other);
6715
+ return eligible.has(key) && !assigned.has(key);
6716
+ };
6717
+ let tried = 0;
6702
6718
  for (const [id, item] of eligible) {
6703
6719
  if (assigned.has(id)) {
6704
6720
  continue;
6705
6721
  }
6722
+ if (++tried > every) {
6723
+ tried = 1;
6724
+ yield;
6725
+ }
6706
6726
  const members = new Map([[id, item]]);
6707
- for (const neighbour of params.neighbours(item)) {
6727
+ for (const neighbour of params.neighbours(item, free)) {
6708
6728
  const key = params.id(neighbour);
6709
6729
  if (eligible.has(key) && !assigned.has(key)) {
6710
6730
  members.set(key, eligible.get(key));
@@ -7237,6 +7257,10 @@ var EntityLabel;
7237
7257
  const ICON_STACK_SCALE = 0.6;
7238
7258
  // How far an angled leader runs sideways before the label starts.
7239
7259
  const ANGLED_LEADER_RUN = 28;
7260
+ // While labels move on screen, clusters are worked out afresh at most this often, and again once they settle.
7261
+ const CLUSTER_MOVING_INTERVAL = 400;
7262
+ // Milliseconds of each frame a fresh clustering may take; the rest of it runs on the next frames.
7263
+ const CLUSTER_STEP_BUDGET = 4;
7240
7264
  // How far a pin's white body reaches past the icon it wraps, before its tip.
7241
7265
  const PIN_RIM = 7;
7242
7266
  // A pin is drawn in one fixed look for now: a white body with a faint edge and a soft shadow.
@@ -7559,6 +7583,8 @@ var EntityLabel;
7559
7583
  */
7560
7584
  class PlacementMemory {
7561
7585
  constructor() {
7586
+ // The last clusters worked out from scratch, by label id, for frames that may reuse them.
7587
+ this.clusters = null;
7562
7588
  this.previous = new Map();
7563
7589
  this.nextOrder = 0;
7564
7590
  }
@@ -7680,6 +7706,16 @@ var EntityLabel;
7680
7706
  function pinLook(look) {
7681
7707
  return look.iconBackground ? look : { ...look, iconBackground: PIN_COLOR };
7682
7708
  }
7709
+ /*
7710
+ * Whether a label draws a pin: it needs an icon to wrap, and a photo keeps its own shape.
7711
+ */
7712
+ function HasPin(options) {
7713
+ return ((options === null || options === void 0 ? void 0 : options.leaderStyle) === "pin" &&
7714
+ options.leader !== false &&
7715
+ (options.presentation || "text") !== "text" &&
7716
+ !options.iconPhoto);
7717
+ }
7718
+ EntityLabel.HasPin = HasPin;
7683
7719
  function iconLook(options) {
7684
7720
  return {
7685
7721
  icon: options.icon || undefined,
@@ -7702,20 +7738,80 @@ var EntityLabel;
7702
7738
  presentation === "text" ? null : iconLook(options)
7703
7739
  ]);
7704
7740
  }
7741
+ function summariseCluster(cluster) {
7742
+ var _a, _b, _c;
7743
+ let chosen = cluster.representative;
7744
+ const iconic = (chosen.options.presentation || "text") !== "text";
7745
+ // Members in the order they would win representation; the seed is the nearest.
7746
+ let ordered = [chosen, ...cluster.members.filter(member => member !== chosen)];
7747
+ if (iconic && chosen.options.cluster.representative !== "nearest") {
7748
+ ordered = ordered.map((member, i) => ({ member, i, priority: EntityLabel.IconPriority(member.options) }))
7749
+ .sort((a, b) => b.priority - a.priority || a.i - b.i).map(entry => entry.member);
7750
+ chosen = ordered[0];
7751
+ }
7752
+ const summary = {
7753
+ chosen: chosen.id,
7754
+ members: cluster.members.map(frame => frame.id),
7755
+ entityIds: Array.from(new Set(cluster.members.map(frame => frame.entityId).filter(Boolean)))
7756
+ };
7757
+ if (iconic && chosen.options.iconScale !== 0) {
7758
+ const seen = new Set();
7759
+ const icons = [];
7760
+ for (const member of ordered) {
7761
+ const look = iconLook(member.options);
7762
+ const key = JSON.stringify(look);
7763
+ if (seen.has(key)) {
7764
+ continue;
7765
+ }
7766
+ seen.add(key);
7767
+ if (member !== ordered[0])
7768
+ icons.push(look);
7769
+ if (seen.size >= ICON_STACK_LIMIT) {
7770
+ break;
7771
+ }
7772
+ }
7773
+ if (icons.length)
7774
+ summary.icons = icons;
7775
+ }
7776
+ if (chosen.options.presentation !== "icon") {
7777
+ const values = new Set();
7778
+ const stableMembers = [...cluster.members].sort((a, b) => (a.entityKey || a.entityId || a.id).localeCompare(b.entityKey || b.entityId || b.id));
7779
+ for (const member of stableMembers) {
7780
+ const value = ((_c = (_a = member.text) !== null && _a !== void 0 ? _a : (_b = member.options) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : "").replace(/\s+/g, " ").trim();
7781
+ if (value) {
7782
+ values.add(value);
7783
+ }
7784
+ }
7785
+ if (values.size > 1) {
7786
+ // A value long enough to wrap fills the box on its own, so only one is listed.
7787
+ const wrapped = stableMembers.some(member => { var _a, _b; return member.textWrapped && ((_b = (member.text || ((_a = member.options) === null || _a === void 0 ? void 0 : _a.text))) === null || _b === void 0 ? void 0 : _b.trim()); });
7788
+ const limit = wrapped ? 1 : 2;
7789
+ const rows = Array.from(values).slice(0, limit);
7790
+ if (values.size > limit)
7791
+ rows.push(`+${values.size - limit} more…`);
7792
+ summary.text = rows.join("\n");
7793
+ }
7794
+ }
7795
+ return summary;
7796
+ }
7705
7797
  /*
7706
- * Resolves clustering and stable text placement before depth fading; highlighted labels receive priority.
7798
+ * Frames in the order they win: priority first, then nearest, with every coordinate known.
7707
7799
  */
7708
- function Layout(input, memory = new PlacementMemory()) {
7709
- var _a, _b, _c, _d, _e, _f, _g;
7710
- const frames = input.filter(frame => [frame.x, frame.y, frame.width, frame.height, frame.depth].every(Number.isFinite))
7800
+ function sortFrames(input) {
7801
+ return input.filter(frame => [frame.x, frame.y, frame.width, frame.height, frame.depth].every(Number.isFinite))
7711
7802
  .sort((a, b) => (b.priority || 0) - (a.priority || 0) || a.depth - b.depth || a.id.localeCompare(b.id));
7712
- const result = new Map();
7803
+ }
7804
+ /*
7805
+ * The frames clustering considers, by presentation, and the ones hidden as another label of the same entity.
7806
+ */
7807
+ function clusterGroups(frames) {
7808
+ var _a, _b;
7713
7809
  const entityKeys = new Set();
7714
7810
  const groups = new Map();
7811
+ const duplicates = new Set();
7715
7812
  for (const frame of frames) {
7716
- const duplicate = frame.entityKey && entityKeys.has(frame.entityKey);
7717
- result.set(frame.id, { frame, visible: !duplicate, opacity: frame.opacity, zIndex: 0, members: [], entityIds: frame.entityId ? [frame.entityId] : [] });
7718
- if (duplicate) {
7813
+ if (frame.entityKey && entityKeys.has(frame.entityKey)) {
7814
+ duplicates.add(frame.id);
7719
7815
  continue;
7720
7816
  }
7721
7817
  if (frame.entityKey)
@@ -7730,6 +7826,13 @@ var EntityLabel;
7730
7826
  }
7731
7827
  groups.get(key).push(frame);
7732
7828
  }
7829
+ return { groups, duplicates };
7830
+ }
7831
+ /*
7832
+ * Works clusters out from scratch, as steps a caller can spread over frames or run straight through.
7833
+ */
7834
+ function* clusterInSteps(groups, every = 32) {
7835
+ const clustered = [];
7733
7836
  for (const group of groups.values()) {
7734
7837
  // Summary and badge dimensions are output, never the next frame's membership input.
7735
7838
  const candidates = group.map(frame => frame.extendedGeometry && frame.canFlip &&
@@ -7743,70 +7846,76 @@ var EntityLabel;
7743
7846
  rank.set(frame.id, i);
7744
7847
  looks.set(frame.id, clusterLook(frame.options));
7745
7848
  });
7746
- const clusters = ClusterItems({
7849
+ const clusters = yield* ClusterItemsInSteps({
7747
7850
  items: candidates,
7748
7851
  id: frame => frame.id,
7749
7852
  minSize: group[0].options.cluster.minSize,
7750
- neighbours: frame => {
7853
+ neighbours: (frame, free) => {
7751
7854
  var _a;
7752
- const nearby = index.Query(frame, (_a = frame.options.cluster.pixelRange) !== null && _a !== void 0 ? _a : (frame.options.presentation === "icon" ? 24 : 8)).sort((a, b) => rank.get(a.id) - rank.get(b.id));
7753
- return compatibleMembers(frame, nearby, other => other.group || "", other => looks.get(other.id));
7855
+ // Labels an earlier cluster took cannot join, so they are dropped before the pairwise checks.
7856
+ const nearby = index.Query(frame, (_a = frame.options.cluster.pixelRange) !== null && _a !== void 0 ? _a : (frame.options.presentation === "icon" ? 24 : 8))
7857
+ .filter(other => other === frame || free(other))
7858
+ .sort((a, b) => rank.get(a.id) - rank.get(b.id));
7859
+ // A pin stands for one thing, so it clusters only with pins that look the same.
7860
+ const group = (other) => HasPin(other.options) ? `look:${looks.get(other.id)}` : other.group || "";
7861
+ return compatibleMembers(frame, nearby, group, other => looks.get(other.id));
7754
7862
  }
7755
- });
7756
- for (const cluster of clusters) {
7757
- let chosen = cluster.representative;
7758
- const iconic = (chosen.options.presentation || "text") !== "text";
7759
- // Members in the order they would win representation; the seed is the nearest.
7760
- let ordered = [chosen, ...cluster.members.filter(member => member !== chosen)];
7761
- if (iconic && chosen.options.cluster.representative !== "nearest") {
7762
- ordered = ordered.map((member, i) => ({ member, i, priority: EntityLabel.IconPriority(member.options) }))
7763
- .sort((a, b) => b.priority - a.priority || a.i - b.i).map(entry => entry.member);
7764
- chosen = ordered[0];
7765
- }
7766
- const representative = result.get(chosen.id);
7767
- representative.members = cluster.members.map(frame => frame.id);
7768
- if (iconic && chosen.options.iconScale !== 0) {
7769
- const seen = new Set();
7770
- const icons = [];
7771
- for (const member of ordered) {
7772
- const look = iconLook(member.options);
7773
- const key = JSON.stringify(look);
7774
- if (seen.has(key)) {
7775
- continue;
7776
- }
7777
- seen.add(key);
7778
- if (member !== ordered[0])
7779
- icons.push(look);
7780
- if (seen.size >= ICON_STACK_LIMIT) {
7781
- break;
7782
- }
7783
- }
7784
- if (icons.length)
7785
- representative.icons = icons;
7786
- }
7787
- representative.entityIds = Array.from(new Set(cluster.members.map(frame => frame.entityId).filter(Boolean)));
7788
- if (chosen.options.presentation !== "icon") {
7789
- const values = new Set();
7790
- const stableMembers = [...cluster.members].sort((a, b) => (a.entityKey || a.entityId || a.id).localeCompare(b.entityKey || b.entityId || b.id));
7791
- for (const member of stableMembers) {
7792
- const value = ((_e = (_c = member.text) !== null && _c !== void 0 ? _c : (_d = member.options) === null || _d === void 0 ? void 0 : _d.text) !== null && _e !== void 0 ? _e : "").replace(/\s+/g, " ").trim();
7793
- if (value) {
7794
- values.add(value);
7795
- }
7796
- }
7797
- if (values.size > 1) {
7798
- // A value long enough to wrap fills the box on its own, so only one is listed.
7799
- const wrapped = stableMembers.some(member => { var _a, _b; return member.textWrapped && ((_b = (member.text || ((_a = member.options) === null || _a === void 0 ? void 0 : _a.text))) === null || _b === void 0 ? void 0 : _b.trim()); });
7800
- const limit = wrapped ? 1 : 2;
7801
- const rows = Array.from(values).slice(0, limit);
7802
- if (values.size > limit)
7803
- rows.push(`+${values.size - limit} more…`);
7804
- representative.text = rows.join("\n");
7805
- }
7863
+ }, every);
7864
+ clusters.forEach(cluster => clustered.push({ representative: cluster.representative.id, members: cluster.members.map(member => member.id) }));
7865
+ }
7866
+ return clustered;
7867
+ }
7868
+ /*
7869
+ * Runs a clustering job to the end at once.
7870
+ */
7871
+ function finishClustering(steps) {
7872
+ let next = steps.next();
7873
+ while (!next.done) {
7874
+ next = steps.next();
7875
+ }
7876
+ return next.value;
7877
+ }
7878
+ function Layout(input, memory = new PlacementMemory(), reuseClusters = false) {
7879
+ var _a, _b, _c;
7880
+ const frames = sortFrames(input);
7881
+ const { groups, duplicates } = clusterGroups(frames);
7882
+ const result = new Map();
7883
+ for (const frame of frames) {
7884
+ result.set(frame.id, { frame, visible: !duplicates.has(frame.id), opacity: frame.opacity, zIndex: 0, members: [], entityIds: frame.entityId ? [frame.entityId] : [] });
7885
+ }
7886
+ if (!reuseClusters || !memory.clusters) {
7887
+ memory.clusters = finishClustering(clusterInSteps(groups, Infinity));
7888
+ }
7889
+ for (const group of groups.values()) {
7890
+ // The kept membership, less anything gone, hovered or moved out of the group since.
7891
+ const byId = new Map(group.map(frame => [frame.id, frame]));
7892
+ const minSize = Math.max(2, (_a = group[0].options.cluster.minSize) !== null && _a !== void 0 ? _a : 2);
7893
+ const clusters = memory.clusters.map(entry => {
7894
+ var _a;
7895
+ const members = entry.members.map(id => byId.get(id)).filter(Boolean);
7896
+ if (members.length < minSize) {
7897
+ return null;
7806
7898
  }
7807
- for (const frame of cluster.members) {
7808
- if (frame !== chosen)
7809
- result.get(frame.id).visible = false;
7899
+ return { entry, whole: members.length === entry.members.length, representative: (_a = byId.get(entry.representative)) !== null && _a !== void 0 ? _a : members[0], members };
7900
+ }).filter(Boolean);
7901
+ for (const cluster of clusters) {
7902
+ // A cluster that kept every member keeps its summary, worked out once, sparing a pass over its members.
7903
+ let summary = cluster.whole ? cluster.entry.summary : undefined;
7904
+ if (!summary) {
7905
+ summary = summariseCluster(cluster);
7906
+ if (cluster.whole)
7907
+ cluster.entry.summary = summary;
7908
+ }
7909
+ const representative = result.get(summary.chosen);
7910
+ representative.members = summary.members;
7911
+ if (summary.icons)
7912
+ representative.icons = summary.icons;
7913
+ representative.entityIds = summary.entityIds;
7914
+ if (summary.text != null)
7915
+ representative.text = summary.text;
7916
+ for (const id of summary.members) {
7917
+ if (id !== summary.chosen)
7918
+ result.get(id).visible = false;
7810
7919
  }
7811
7920
  }
7812
7921
  }
@@ -7825,7 +7934,7 @@ var EntityLabel;
7825
7934
  const box = { ...frame, x: frame.x + .01, y: frame.y + .01, width: Math.max(0, frame.width - .02), height: Math.max(0, frame.height - .02) };
7826
7935
  const overlap = foreground.HasOverlap(box) || foregroundLeaders.HasOverlap(box) || Boolean(stem && foreground.HasOverlap(stem));
7827
7936
  if (overlap) {
7828
- placement.opacity *= Math.max(0, Math.min(1, (_g = (_f = frame.options) === null || _f === void 0 ? void 0 : _f.overlapOpacity) !== null && _g !== void 0 ? _g : 0.25));
7937
+ placement.opacity *= Math.max(0, Math.min(1, (_c = (_b = frame.options) === null || _b === void 0 ? void 0 : _b.overlapOpacity) !== null && _c !== void 0 ? _c : 0.25));
7829
7938
  }
7830
7939
  placement.zIndex = zIndex--;
7831
7940
  foreground.Add(frame);
@@ -7845,21 +7954,23 @@ var EntityLabel;
7845
7954
  const accepted = [seed];
7846
7955
  const byGroup = new Map([[group(seed), 1]]);
7847
7956
  const byLook = new Map([[look(seed), 1]]);
7848
- const byBoth = new Map([[JSON.stringify([group(seed), look(seed)]), 1]]);
7957
+ // Joined with a character no group id or look holds, not serialised, since this runs per neighbour.
7958
+ const both = (itemGroup, itemLook) => `${itemGroup}\u0000${itemLook}`;
7959
+ const byBoth = new Map([[both(group(seed), look(seed)), 1]]);
7849
7960
  for (const item of nearby) {
7850
7961
  if (item === seed) {
7851
7962
  continue;
7852
7963
  }
7853
- const itemGroup = group(item), itemLook = look(item), both = JSON.stringify([itemGroup, itemLook]);
7964
+ const itemGroup = group(item), itemLook = look(item), key = both(itemGroup, itemLook);
7854
7965
  // Accepted members in another group with another look are the ones this item may not sit beside.
7855
- const conflicting = accepted.length - (byGroup.get(itemGroup) || 0) - (byLook.get(itemLook) || 0) + (byBoth.get(both) || 0);
7966
+ const conflicting = accepted.length - (byGroup.get(itemGroup) || 0) - (byLook.get(itemLook) || 0) + (byBoth.get(key) || 0);
7856
7967
  if (conflicting > 0) {
7857
7968
  continue;
7858
7969
  }
7859
7970
  accepted.push(item);
7860
7971
  byGroup.set(itemGroup, (byGroup.get(itemGroup) || 0) + 1);
7861
7972
  byLook.set(itemLook, (byLook.get(itemLook) || 0) + 1);
7862
- byBoth.set(both, (byBoth.get(both) || 0) + 1);
7973
+ byBoth.set(key, (byBoth.get(key) || 0) + 1);
7863
7974
  }
7864
7975
  return accepted;
7865
7976
  }
@@ -7890,10 +8001,20 @@ var EntityLabel;
7890
8001
  this.viewer = viewer;
7891
8002
  this.element = document.createElement("div");
7892
8003
  this.coordinates = { x: 0, y: 0, scaleX: 1, scaleY: 1 };
8004
+ // The canvas size, read once a frame: reading the canvas after placing a label lays the page out again.
8005
+ this.viewport = { width: 0, height: 0 };
7893
8006
  this.participants = new Set();
7894
8007
  // Participants whose failure has been logged, so a label that throws every frame logs once.
7895
8008
  this.failed = new WeakSet();
7896
8009
  this.placementMemory = new PlacementMemory();
8010
+ // What the clusters were last worked out from: the labels taking part and where they sat, and when.
8011
+ this.clustered = null;
8012
+ // Labels added or removed, which can change any cluster's look or membership.
8013
+ this.clustersDirty = true;
8014
+ // A fresh clustering spread over frames, while the last one stays on show.
8015
+ this.clusterJob = null;
8016
+ // Labels hidden in a cluster last frame, with the frame they were laid out from, for reused clusters to skip.
8017
+ this.sleeping = new Map();
7897
8018
  this.modelBoxes = new ModelBoxes();
7898
8019
  this.forwardingWheel = false;
7899
8020
  this.pendingDrag = null;
@@ -8070,9 +8191,12 @@ var EntityLabel;
8070
8191
  }
8071
8192
  Add(participant) {
8072
8193
  this.participants.add(participant);
8194
+ this.clustersDirty = true;
8073
8195
  this.viewer.scene.requestRender();
8074
8196
  return () => {
8075
8197
  this.participants.delete(participant);
8198
+ this.sleeping.delete(participant);
8199
+ this.clustersDirty = true;
8076
8200
  if (!this.participants.size) {
8077
8201
  this.remove();
8078
8202
  this.element.removeEventListener("wheel", this.ForwardWheel);
@@ -8123,8 +8247,9 @@ var EntityLabel;
8123
8247
  }
8124
8248
  }
8125
8249
  Update() {
8126
- var _a, _b;
8250
+ var _a, _b, _c;
8127
8251
  this.coordinates = this.MeasureCoordinates();
8252
+ this.viewport = { width: this.viewer.canvas.clientWidth, height: this.viewer.canvas.clientHeight };
8128
8253
  this.UpdateHorizon();
8129
8254
  const rect = (_b = (_a = this.viewer.canvas).getBoundingClientRect) === null || _b === void 0 ? void 0 : _b.call(_a);
8130
8255
  const pointer = this.pointerClient;
@@ -8140,21 +8265,77 @@ var EntityLabel;
8140
8265
  console.error("EntityLabel: model boxes failed to resolve.", e);
8141
8266
  }
8142
8267
  // This runs inside Cesium's frame, where one throwing label would stop rendering for the whole scene.
8268
+ const project = (participant) => {
8269
+ try {
8270
+ return participant.project();
8271
+ }
8272
+ catch (e) {
8273
+ this.logFailure(participant, e);
8274
+ return null;
8275
+ }
8276
+ };
8277
+ // A label hidden in a cluster needs no position while its cluster is reused, which is most frames.
8278
+ const mayReuse = Boolean(this.clustered) && !this.clustersDirty && Date.now() - this.clustered.at < CLUSTER_MOVING_INTERVAL;
8143
8279
  const projected = new Map();
8144
8280
  for (const participant of this.participants) {
8145
- let frame = null;
8281
+ const asleep = mayReuse && !((_c = participant.wake) === null || _c === void 0 ? void 0 : _c.call(participant)) ? this.sleeping.get(participant) : undefined;
8282
+ projected.set(participant, asleep !== null && asleep !== void 0 ? asleep : project(participant));
8283
+ }
8284
+ let frames = Array.from(projected.values()).filter(Boolean);
8285
+ const decision = this.DecideClusters(frames);
8286
+ if (decision !== "reuse" && mayReuse) {
8287
+ // Clusters are worked out from where every label is now, sleepers included.
8288
+ for (const participant of this.participants) {
8289
+ if (this.sleeping.has(participant))
8290
+ projected.set(participant, project(participant));
8291
+ }
8292
+ frames = Array.from(projected.values()).filter(Boolean);
8293
+ }
8294
+ if (decision === "refresh") {
8295
+ this.clusterJob = clusterInSteps(clusterGroups(sortFrames(frames)).groups);
8296
+ }
8297
+ this.StepClusters();
8298
+ const layout = Layout(frames, this.placementMemory, decision !== "now");
8299
+ const placements = new Map(layout.map(item => [item.frame.id, item]));
8300
+ const participantsById = new Map();
8301
+ for (const [participant, frame] of projected) {
8302
+ if (frame)
8303
+ participantsById.set(frame.id, participant);
8304
+ }
8305
+ this.sleeping = new Map();
8306
+ for (const placement of layout) {
8307
+ for (const id of placement.members) {
8308
+ const participant = id !== placement.frame.id ? participantsById.get(id) : undefined;
8309
+ if (participant)
8310
+ this.sleeping.set(participant, projected.get(participant));
8311
+ }
8312
+ }
8313
+ // Writes, then reads, then writes, each across all labels; interleaved, each read lays them out again.
8314
+ const measures = [];
8315
+ for (const [participant, frame] of projected) {
8146
8316
  try {
8147
- frame = participant.project();
8317
+ const measure = participant.apply(frame ? placements.get(frame.id) : undefined);
8318
+ if (measure)
8319
+ measures.push([participant, measure]);
8148
8320
  }
8149
8321
  catch (e) {
8150
8322
  this.logFailure(participant, e);
8151
8323
  }
8152
- projected.set(participant, frame);
8153
8324
  }
8154
- const placements = new Map(Layout(Array.from(projected.values()).filter(Boolean), this.placementMemory).map(item => [item.frame.id, item]));
8155
- for (const [participant, frame] of projected) {
8325
+ const places = [];
8326
+ for (const [participant, measure] of measures) {
8156
8327
  try {
8157
- participant.apply(frame ? placements.get(frame.id) : undefined);
8328
+ const place = measure();
8329
+ if (place)
8330
+ places.push([participant, place]);
8331
+ }
8332
+ catch (e) {
8333
+ this.logFailure(participant, e);
8334
+ }
8335
+ }
8336
+ for (const [participant, place] of places) {
8337
+ try {
8338
+ place();
8158
8339
  }
8159
8340
  catch (e) {
8160
8341
  this.logFailure(participant, e);
@@ -8167,6 +8348,55 @@ var EntityLabel;
8167
8348
  console.error("EntityLabel: model boxes failed to draw.", e);
8168
8349
  }
8169
8350
  }
8351
+ /*
8352
+ * How this frame gets its clusters: kept from last time, refreshed by a job over frames, or worked out now.
8353
+ * They are kept while no clustering label has moved, and while labels move (camera or entities) until a moment
8354
+ * old or while a refresh is under way. Labels coming or going, or none clustered yet, work them out now.
8355
+ */
8356
+ DecideClusters(frames) {
8357
+ // Where each clustering label sits, to a few pixels, so drawing alone never counts as movement.
8358
+ const signature = frames
8359
+ .filter(frame => { var _a, _b; return ((_b = (_a = frame.options) === null || _a === void 0 ? void 0 : _a.cluster) === null || _b === void 0 ? void 0 : _b.enabled) && !(frame.priority > 0); })
8360
+ .map(frame => `${frame.id}@${Math.round(frame.x / 4)},${Math.round(frame.y / 4)}`)
8361
+ .join("|");
8362
+ const now = Date.now();
8363
+ if (!this.clustered || this.clustersDirty) {
8364
+ this.clusterJob = null;
8365
+ this.clustered = { signature, at: now };
8366
+ this.clustersDirty = false;
8367
+ return "now";
8368
+ }
8369
+ if (this.clustered.signature === signature) {
8370
+ return "reuse";
8371
+ }
8372
+ if (this.clusterJob || now - this.clustered.at < CLUSTER_MOVING_INTERVAL) {
8373
+ // Another frame is due either way, so the scene gets its fresh clusters once it settles.
8374
+ this.viewer.scene.requestRender();
8375
+ return "reuse";
8376
+ }
8377
+ this.clustered = { signature, at: now };
8378
+ return "refresh";
8379
+ }
8380
+ /*
8381
+ * Advances a spread clustering for this frame's share of time, handing its result over once it finishes.
8382
+ */
8383
+ StepClusters() {
8384
+ if (!this.clusterJob) {
8385
+ return;
8386
+ }
8387
+ const deadline = performance.now() + CLUSTER_STEP_BUDGET;
8388
+ let next = this.clusterJob.next();
8389
+ while (!next.done && performance.now() < deadline) {
8390
+ next = this.clusterJob.next();
8391
+ }
8392
+ if (next.done) {
8393
+ this.placementMemory.clusters = next.value;
8394
+ this.clusterJob = null;
8395
+ }
8396
+ else {
8397
+ this.viewer.scene.requestRender();
8398
+ }
8399
+ }
8170
8400
  logFailure(participant, error) {
8171
8401
  if (this.failed.has(participant)) {
8172
8402
  return;
@@ -9471,8 +9701,7 @@ var EntityLabel;
9471
9701
  target.addEventListener(type, event => event.stopPropagation());
9472
9702
  }
9473
9703
  };
9474
- // A pin needs an icon to wrap; a photo keeps its own shape, and plain text keeps a straight stem.
9475
- const pin = this.options.leaderStyle === "pin" && look.leader !== false && presentation !== "text" && !look.iconPhoto;
9704
+ const pin = HasPin(look);
9476
9705
  const normalLeader = (_m = look.leader) !== null && _m !== void 0 ? _m : (presentation === "text" || pin);
9477
9706
  const angled = this.options.leaderStyle === "angled";
9478
9707
  let leader = normalLeader;
@@ -9533,11 +9762,9 @@ var EntityLabel;
9533
9762
  makeClickable(iconStack);
9534
9763
  iconContainer.append(iconStack, icon);
9535
9764
  if (pin) {
9536
- // The shadow sits on an unturned holder so it falls the same way whichever way the tip points.
9537
9765
  pinHolder = document.createElement("span");
9538
9766
  pinHolder.className = "entity-label-pin";
9539
- pinHolder.style.cssText = "position:absolute;left:50%;top:50%;z-index:-1;pointer-events:none;" +
9540
- "filter:drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.35));";
9767
+ pinHolder.style.cssText = "position:absolute;left:50%;top:50%;z-index:-1;pointer-events:none;";
9541
9768
  pinBody = document.createElement("span");
9542
9769
  pinBody.style.cssText = `position:absolute;inset:0;background:${PIN_COLOR};border:1px solid rgba(0, 0, 0, 0.14);` +
9543
9770
  "box-sizing:border-box;border-radius:50% 50% 0 50%;";
@@ -9619,7 +9846,10 @@ var EntityLabel;
9619
9846
  border-radius: 9px;
9620
9847
  color: #ffffff;
9621
9848
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
9849
+ will-change: transform;
9622
9850
  `);
9851
+ // Each label, leader and ring gets its own compositor layer: in one shared layer, moving any of them
9852
+ // repainted all of them, shadows included, on every camera move.
9623
9853
  this.label = ele;
9624
9854
  ele.style.width = "max-content";
9625
9855
  layer.element.appendChild(ele);
@@ -9638,6 +9868,7 @@ var EntityLabel;
9638
9868
  width: 2px;
9639
9869
  background: rgba(255, 255, 255, 0.8);
9640
9870
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
9871
+ will-change: transform;
9641
9872
  `);
9642
9873
  this.line = lineEle;
9643
9874
  lineEle.className = "entity-label-leader";
@@ -9655,6 +9886,7 @@ var EntityLabel;
9655
9886
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
9656
9887
  top: -2px;
9657
9888
  left: -2px;
9889
+ will-change: transform;
9658
9890
  `);
9659
9891
  lineEleNode.className = "entity-label-anchor";
9660
9892
  // SVG preserves fractional strokes in scaled containers where CSS borders round to pixels.
@@ -9687,13 +9919,13 @@ var EntityLabel;
9687
9919
  }
9688
9920
  const fitLeader = (anchorX, anchorY, desired, width, height, radius = 0) => {
9689
9921
  const above = Math.max(0, anchorY - height);
9690
- const below = Math.max(0, this.viewer.canvas.clientHeight - anchorY - height);
9922
+ const below = Math.max(0, layer.viewport.height - anchorY - height);
9691
9923
  // Keep a short visible stem before switching sides; never aim it at the cursor or a box corner.
9692
9924
  const upwards = above >= Math.max(radius ? radius + 4 : 0, Math.min(8, desired)) || above >= below;
9693
9925
  const length = Math.min(desired, upwards ? above : below);
9694
9926
  const endY = anchorY + (upwards ? -length : length);
9695
9927
  return {
9696
- x: Math.max(0, Math.min(anchorX, this.viewer.canvas.clientWidth - width)),
9928
+ x: Math.max(0, Math.min(anchorX, layer.viewport.width - width)),
9697
9929
  y: upwards ? endY - height : endY, endY
9698
9930
  };
9699
9931
  };
@@ -9702,17 +9934,17 @@ var EntityLabel;
9702
9934
  * so the stem rises to the label's middle and then runs out to whichever side has the room.
9703
9935
  */
9704
9936
  const fitAngledLeader = (anchorX, anchorY, desired, width, height, radius = 0) => {
9705
- const canvas = this.viewer.canvas;
9937
+ const canvas = layer.viewport;
9706
9938
  const above = Math.max(0, anchorY - height / 2);
9707
- const below = Math.max(0, canvas.clientHeight - anchorY - height / 2);
9939
+ const below = Math.max(0, canvas.height - anchorY - height / 2);
9708
9940
  const upwards = above >= Math.max(radius ? radius + 4 : 0, Math.min(8, desired)) || above >= below;
9709
9941
  const length = Math.min(desired, upwards ? above : below);
9710
9942
  const endY = anchorY + (upwards ? -length : length);
9711
9943
  const run = Math.max(ANGLED_LEADER_RUN, radius + 4);
9712
- const rightwards = anchorX + run + width <= canvas.clientWidth || anchorX - run - width < 0;
9944
+ const rightwards = anchorX + run + width <= canvas.width || anchorX - run - width < 0;
9713
9945
  return {
9714
- x: Math.max(0, Math.min(rightwards ? anchorX + run : anchorX - run - width, canvas.clientWidth - width)),
9715
- y: Math.max(0, Math.min(endY - height / 2, canvas.clientHeight - height)), endY,
9946
+ x: Math.max(0, Math.min(rightwards ? anchorX + run : anchorX - run - width, canvas.width - width)),
9947
+ y: Math.max(0, Math.min(endY - height / 2, canvas.height - height)), endY,
9716
9948
  run, side: (rightwards ? "right" : "left")
9717
9949
  };
9718
9950
  };
@@ -9736,13 +9968,13 @@ var EntityLabel;
9736
9968
  * Off to the side it is only clamped back on screen, and its tip turns to keep pointing at the anchor.
9737
9969
  */
9738
9970
  const fitPin = (anchorX, anchorY, stem, width, height, shape) => {
9739
- const canvas = this.viewer.canvas;
9971
+ const canvas = layer.viewport;
9740
9972
  const reach = stem + shape.tip;
9741
9973
  const above = anchorY - reach - shape.y;
9742
9974
  const below = anchorY + reach - shape.y;
9743
- const upwards = above >= 0 || (below + height > canvas.clientHeight && anchorY >= canvas.clientHeight - anchorY);
9975
+ const upwards = above >= 0 || (below + height > canvas.height && anchorY >= canvas.height - anchorY);
9744
9976
  return {
9745
- x: Math.max(0, Math.min(anchorX - shape.x, canvas.clientWidth - width)),
9977
+ x: Math.max(0, Math.min(anchorX - shape.x, canvas.width - width)),
9746
9978
  y: upwards ? above : below
9747
9979
  };
9748
9980
  };
@@ -9860,6 +10092,43 @@ var EntityLabel;
9860
10092
  this.viewer.scene.requestRender();
9861
10093
  }).finally(settle);
9862
10094
  }
10095
+ /*
10096
+ * The label's size when last laid out. A label hidden in a cluster leaves layout altogether, so a
10097
+ * frame reads its size from here; a shown one refreshes it when it changes, a new one on its first frame.
10098
+ */
10099
+ let size = null;
10100
+ const measureSize = () => {
10101
+ size = {
10102
+ width: ele.offsetWidth,
10103
+ height: ele.offsetHeight,
10104
+ textWidth: (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetWidth) || 0,
10105
+ textHeight: (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetHeight) || 0,
10106
+ iconWidth: (iconElement === null || iconElement === void 0 ? void 0 : iconElement.offsetWidth) || 0,
10107
+ iconHeight: (iconElement === null || iconElement === void 0 ? void 0 : iconElement.offsetHeight) || 0,
10108
+ naturalTextWidth: (sourceNaturalText === null || sourceNaturalText === void 0 ? void 0 : sourceNaturalText.offsetWidth) || 0,
10109
+ pin: pin ? measurePin() : undefined
10110
+ };
10111
+ };
10112
+ // Whether the label was out of layout last frame, so staying hidden writes nothing.
10113
+ let hiddenLast = false;
10114
+ // Set by this frame's writes that change the label's size, so it is measured before it is placed.
10115
+ let sizeStale = true;
10116
+ // Set when the size changed on its own; a shown label reads it at the start of the next frame, while layout
10117
+ // is still clean, rather than forcing a layout mid-frame.
10118
+ let resizedSince = false;
10119
+ // The cluster badge's own size beside its icon, read with the label's.
10120
+ let badge = null;
10121
+ // Images, fonts and photo transitions change the size outside any write here. Without an observer the size
10122
+ // is read every frame instead.
10123
+ const resized = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => {
10124
+ if (this.disposed || this.counter !== counter) {
10125
+ resized.disconnect();
10126
+ return;
10127
+ }
10128
+ resizedSince = true;
10129
+ this.viewer.scene.requestRender();
10130
+ });
10131
+ resized === null || resized === void 0 ? void 0 : resized.observe(ele);
9863
10132
  let cursorMotion = this.cursorMotion;
9864
10133
  const project = () => {
9865
10134
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
@@ -9871,6 +10140,11 @@ var EntityLabel;
9871
10140
  (this.hoverFade.from === 0 || Date.now() - this.hoverFade.start >= 120)) {
9872
10141
  return null;
9873
10142
  }
10143
+ // A new label is still in layout, so its first frame reads its size, as does a shown one that resized.
10144
+ if (!size || (resizedSince && !hiddenLast)) {
10145
+ measureSize();
10146
+ resizedSince = false;
10147
+ }
9874
10148
  // Moving point/model positions must be sampled at the current clock time.
9875
10149
  if (!this.prePositioned && visual instanceof Entity && visual.position) {
9876
10150
  const position = getValue(this.viewer, visual.position);
@@ -9918,8 +10192,8 @@ var EntityLabel;
9918
10192
  y: ringPoint.y + (boxTarget.y - ringPoint.y) * boxBlend
9919
10193
  } : undefined;
9920
10194
  const start = boxAnchor || anchor;
9921
- const onScreen = anchor.x >= 0 && anchor.y >= 0 && anchor.x < this.viewer.canvas.clientWidth && anchor.y < this.viewer.canvas.clientHeight;
9922
- if (leader && (start.x < 0 || start.y < 0 || start.x >= this.viewer.canvas.clientWidth || start.y >= this.viewer.canvas.clientHeight))
10195
+ const onScreen = anchor.x >= 0 && anchor.y >= 0 && anchor.x < layer.viewport.width && anchor.y < layer.viewport.height;
10196
+ if (leader && (start.x < 0 || start.y < 0 || start.x >= layer.viewport.width || start.y >= layer.viewport.height))
9923
10197
  return null;
9924
10198
  if (onScreen && !this.imageAsked && this.groupId && !HasIcon(this.options) && !this.options.photo) {
9925
10199
  this.imageAsked = true;
@@ -9963,8 +10237,8 @@ var EntityLabel;
9963
10237
  if (cursorAmount > 0 && !pinned) {
9964
10238
  // A leader-less label starts centred on its anchor; preserve that box as it lifts away.
9965
10239
  if (!normalLeader) {
9966
- x -= ele.offsetWidth / layer.coordinates.scaleX / 2;
9967
- y += ele.offsetHeight / layer.coordinates.scaleY / 2;
10240
+ x -= size.width / layer.coordinates.scaleX / 2;
10241
+ y += size.height / layer.coordinates.scaleY / 2;
9968
10242
  }
9969
10243
  x += (cursorMotion.position.x + pixelOffset.x - x) * cursorAmount;
9970
10244
  y += (cursorMotion.position.y + pixelOffset.y - y) * cursorAmount;
@@ -10014,17 +10288,16 @@ var EntityLabel;
10014
10288
  x = hover.x + pixelOffset.x;
10015
10289
  y = hover.y + pixelOffset.y - 24;
10016
10290
  }
10017
- // Hidden participants remain measurable; visibility never removes their layout boxes.
10018
10291
  const coordinates = layer.coordinates;
10019
- const width = ele.offsetWidth / coordinates.scaleX;
10020
- const height = ele.offsetHeight / coordinates.scaleY;
10292
+ const width = size.width / coordinates.scaleX;
10293
+ const height = size.height / coordinates.scaleY;
10021
10294
  let clusterBounds;
10022
10295
  if ((_u = this.options.cluster) === null || _u === void 0 ? void 0 : _u.enabled) {
10023
- const textWidth = (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetWidth) || 0;
10024
- const textHeight = (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetHeight) || 0;
10296
+ const textWidth = size.textWidth;
10297
+ const textHeight = size.textHeight;
10025
10298
  // A photo is never part of the footprint, so its arrival cannot change which cluster a label joins.
10026
- const iconWidth = look.iconPhoto ? 0 : (iconElement === null || iconElement === void 0 ? void 0 : iconElement.offsetWidth) || 0;
10027
- const iconHeight = look.iconPhoto ? 0 : (iconElement === null || iconElement === void 0 ? void 0 : iconElement.offsetHeight) || 0;
10299
+ const iconWidth = look.iconPhoto ? 0 : size.iconWidth;
10300
+ const iconHeight = look.iconPhoto ? 0 : size.iconHeight;
10028
10301
  const gap = sourceText && iconWidth ? 6 : 0;
10029
10302
  const above = presentation === "icon-text-above";
10030
10303
  // Match the fixed content gap and label padding, excluding the count badge.
@@ -10043,7 +10316,7 @@ var EntityLabel;
10043
10316
  let leaderRun;
10044
10317
  let leaderSide;
10045
10318
  if (leader && pin)
10046
- ({ x, y } = fitPin(anchorX, anchorY, leaderLength, width, height, measurePin()));
10319
+ ({ x, y } = fitPin(anchorX, anchorY, leaderLength, width, height, size.pin));
10047
10320
  else if (leader && angled) {
10048
10321
  const fit = fitAngledLeader(anchorX, anchorY, leaderLength, width, height);
10049
10322
  ({ x, y } = fit);
@@ -10052,17 +10325,17 @@ var EntityLabel;
10052
10325
  else if (leader)
10053
10326
  ({ x, y } = fitLeader(anchorX, anchorY, leaderLength, width, height));
10054
10327
  const bounds = clusterBounds || { x, y, width, height };
10055
- if (!leader && (bounds.x + bounds.width < 0 || bounds.y + bounds.height < 0 || bounds.x > this.viewer.canvas.clientWidth || bounds.y > this.viewer.canvas.clientHeight)) {
10328
+ if (!leader && (bounds.x + bounds.width < 0 || bounds.y + bounds.height < 0 || bounds.x > layer.viewport.width || bounds.y > layer.viewport.height)) {
10056
10329
  return null;
10057
10330
  }
10058
10331
  const state = (_v = this.visualRegister) === null || _v === void 0 ? void 0 : _v.GetState({ entityId: (_w = this.rego) === null || _w === void 0 ? void 0 : _w.entityId, menuItemId: (_x = this.rego) === null || _x === void 0 ? void 0 : _x.menuItemId });
10059
10332
  const opacity = this.prePositioned || hoverOnly || MAX_DISTANCE === Infinity ? 1 : 1 - distance / MAX_DISTANCE;
10060
10333
  return {
10061
10334
  canFlip: leader && presentation !== "icon" && !pin, hasLeader: leader,
10062
- textWrapped: ((sourceNaturalText === null || sourceNaturalText === void 0 ? void 0 : sourceNaturalText.offsetWidth) || 0) > TEXT_MAX_WIDTH,
10335
+ textWrapped: size.naturalTextWidth > TEXT_MAX_WIDTH,
10063
10336
  transient: this.Transient || Boolean(hover) || cursorAmount > 0,
10064
10337
  extendedGeometry: visual instanceof Entity && Boolean(visual.polygon || visual.polyline || visual.corridor),
10065
- viewportWidth: this.viewer.canvas.clientWidth,
10338
+ viewportWidth: layer.viewport.width,
10066
10339
  id: this.id, entityKey: ((_y = this.rego) === null || _y === void 0 ? void 0 : _y.entityId) ? JSON.stringify([this.rego.entityId, this.rego.menuItemId || "", this.Transient && !this.Persistent ? "hover" : ""]) : undefined,
10067
10340
  entityId: (_z = this.rego) === null || _z === void 0 ? void 0 : _z.entityId, group: this.groupId, x, y, width, height, anchorX, anchorY, depth, leaderLength, leaderRun, leaderSide, distance,
10068
10341
  iconRadius: icon === null || icon === void 0 ? void 0 : icon.radius, modelBox: boxed || undefined, boxBlend, follows: !pinned && Boolean(transientPivot || cursorMotion.target),
@@ -10073,10 +10346,19 @@ var EntityLabel;
10073
10346
  let displacement = { x: 0, y: 0 };
10074
10347
  let nudge = { x: 0, y: 0, fromX: 0, fromY: 0, targetX: 0, targetY: 0, start: 0 };
10075
10348
  const apply = (placement) => {
10076
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
10349
+ var _a, _b, _c, _d, _e;
10077
10350
  const show = (placement === null || placement === void 0 ? void 0 : placement.visible) && placement.opacity > 0;
10351
+ if (!show && hiddenLast) {
10352
+ return;
10353
+ }
10354
+ if (show && hiddenLast) {
10355
+ sizeStale = true;
10356
+ }
10357
+ hiddenLast = !show;
10078
10358
  shownOnce = shownOnce || Boolean(show);
10079
10359
  clickEntityIds = show ? placement.entityIds : [];
10360
+ // Out of layout while hidden, so thousands of clustered labels cost the browser nothing to lay out.
10361
+ ele.style.display = show ? "flex" : "none";
10080
10362
  ele.style.visibility = show ? "visible" : "hidden";
10081
10363
  lineEle.style.display = show && leader ? "block" : "none";
10082
10364
  if (runEle)
@@ -10115,6 +10397,7 @@ var EntityLabel;
10115
10397
  const displayText = (_c = placement.text) !== null && _c !== void 0 ? _c : originalText;
10116
10398
  if (textElement && textElement.textContent !== displayText) {
10117
10399
  textElement.textContent = displayText;
10400
+ sizeStale = true;
10118
10401
  // Measure the summary's footprint next frame without replacing each member's source text.
10119
10402
  this.viewer.scene.requestRender();
10120
10403
  }
@@ -10129,10 +10412,10 @@ var EntityLabel;
10129
10412
  const count = placement.members.length ? String(placement.members.length) : "";
10130
10413
  if (countElement.textContent !== count) {
10131
10414
  countElement.textContent = count;
10415
+ sizeStale = true;
10132
10416
  // The badge participates in layout, so its new width needs another measurement.
10133
10417
  this.viewer.scene.requestRender();
10134
10418
  }
10135
- fitIconBackground === null || fitIconBackground === void 0 ? void 0 : fitIconBackground();
10136
10419
  const stack = JSON.stringify(placement.icons || []);
10137
10420
  if (iconStack && stack !== displayedStack) {
10138
10421
  displayedStack = stack;
@@ -10148,6 +10431,7 @@ var EntityLabel;
10148
10431
  built[0].icon.style.gridColumn = "1 / span 2";
10149
10432
  }
10150
10433
  iconStack.replaceChildren(...built.map(({ icon }) => icon));
10434
+ sizeStale = true;
10151
10435
  iconStack.style.display = built.length ? "inline-grid" : "none";
10152
10436
  // The glyph stays measurable, since cluster membership is taken from its footprint.
10153
10437
  iconElement.style.visibility = built.length ? "hidden" : "";
@@ -10156,255 +10440,301 @@ var EntityLabel;
10156
10440
  // The stack widens the label, which the next frame has to measure.
10157
10441
  this.viewer.scene.requestRender();
10158
10442
  }
10159
- for (const fit of stackedFits)
10160
- fit();
10161
- if (badgeOnIcon) {
10162
- const badgeWidth = countElement.offsetWidth;
10163
- const iconWidth = iconElement.offsetWidth;
10164
- const narrow = iconWidth < iconElement.offsetHeight * 0.6;
10165
- const clearance = badgeWidth ? (narrow ? badgeWidth / 2 + 2 : Math.max(0, badgeWidth / 2 - iconWidth / 4)) : 0;
10166
- countElement.style.left = `calc(100% + ${clearance}px)`;
10167
- // Reserve the badge overhang so adjacent text and viewport edges remain clear.
10168
- const overhang = countElement.offsetHeight / 2;
10169
- iconContainer.style.marginTop = badgeBelow ? "0px" : `${overhang}px`;
10170
- iconContainer.style.marginBottom = badgeBelow ? `${overhang}px` : "0px";
10171
- iconContainer.style.marginRight = `${badgeWidth / 2 + clearance}px`;
10172
- }
10173
- // Summary and badge changes must fit on their first visible frame, including after resize.
10174
- const ring = this.options.anchorRing;
10175
- const pointer = (layer.pointer || (cursorMotion.target ? cursorMotion.position : undefined) || (this.Transient && !this.Persistent ?
10176
- (this.hoverFade.to === 0 ? this.retainedHoverPosition : (_f = this.visualRegister) === null || _f === void 0 ? void 0 : _f.GetLabelHoverPosition((_g = this.rego) === null || _g === void 0 ? void 0 : _g.entityId, (_h = this.rego) === null || _h === void 0 ? void 0 : _h.menuItemId)) : undefined));
10177
- const iconRing = frame.iconRadius ? Math.max(ICON_RING_MIN, frame.iconRadius + ICON_RING_PADDING) : 0;
10178
- const boxed = leader ? frame.modelBox : undefined;
10179
- const hovered = pointer && (boxed ? hullContains(boxed.hull, pointer) :
10180
- Math.hypot(pointer.x - frame.anchorX, pointer.y - frame.anchorY) <= Math.max((_j = ring === null || ring === void 0 ? void 0 : ring.hoverDistance) !== null && _j !== void 0 ? _j : 24, iconRing));
10181
- if (look.iconPhoto && growPhoto) {
10182
- // A rectangle leans on the leader's side of the label.
10183
- if (photoShape === "rect") {
10184
- const align = !leader ? "center" : placement.textSide === "left" ? "flex-end" : "flex-start";
10185
- if (content.style.alignItems !== align) {
10186
- content.style.alignItems = align;
10187
- }
10188
- }
10189
- // Grown in layout rather than scaled, so the border keeps its width, and the label, whose bottom
10190
- // sits on the leader, grows up and sideways without changing the leader's length.
10191
- growPhoto(Boolean(hovered) && !((_k = placement.members) === null || _k === void 0 ? void 0 : _k.length));
10192
- }
10193
- const normalRadius = (!leader || (ring === null || ring === void 0 ? void 0 : ring.enabled) === false ? 0 : Math.max(frame.distance <= ((_l = ring === null || ring === void 0 ? void 0 : ring.nearDistance) !== null && _l !== void 0 ? _l : 100) ? ((_m = ring === null || ring === void 0 ? void 0 : ring.nearRadius) !== null && _m !== void 0 ? _m : 10) : 0, hovered ? ((_o = ring === null || ring === void 0 ? void 0 : ring.hoverRadius) !== null && _o !== void 0 ? _o : (this.Transient && !this.Persistent ? 15.4 : 22)) : 0));
10194
- const targetRadius = normalRadius + (15.4 - normalRadius) * cursorMotion.amount;
10195
- // Around a glyph the ring keeps the glyph's size and only fades its stroke in, so it never covers the icon.
10196
- // A ring around the cursor marks nothing, so a riding label keeps only its leader.
10197
- const targetOuter = frame.follows ? 0 : iconRing || targetRadius || 2.5;
10198
- const targetInner = frame.follows ? 0 : iconRing ? (targetRadius > 0 ? iconRing - 2 : iconRing) : Math.max(0, targetRadius - 2);
10199
- const now = Date.now();
10200
- const duration = (_p = ring === null || ring === void 0 ? void 0 : ring.transitionDuration) !== null && _p !== void 0 ? _p : 200;
10201
- const sharedRing = this.Transient && !this.Persistent && this.hoverFade.to === 1 ? this.hoverRingState : undefined;
10202
- let ringAnimation = sharedRing ? sharedRing.animation : this.ringAnimation;
10203
- if (!ringAnimation) {
10204
- const outer = frame.follows ? 0 : iconRing || 2.5;
10205
- const inner = frame.follows ? 0 : iconRing;
10206
- ringAnimation = { target: outer, targetInner: inner, start: now, outer, inner, fromOuter: outer, fromInner: inner };
10207
- }
10208
- const animateRing = () => {
10209
- const progress = duration > 0 ? Math.min(1, Math.max(0, (now - ringAnimation.start) / duration)) : 1;
10210
- const eased = progress * progress * (3 - 2 * progress);
10211
- ringAnimation.outer = ringAnimation.fromOuter + (ringAnimation.target - ringAnimation.fromOuter) * eased;
10212
- ringAnimation.inner = ringAnimation.fromInner + (ringAnimation.targetInner - ringAnimation.fromInner) * eased;
10213
- return progress;
10214
- };
10215
- animateRing();
10216
- if (ringAnimation.target !== targetOuter || ringAnimation.targetInner !== targetInner) {
10217
- ringAnimation = {
10218
- ...ringAnimation,
10219
- target: targetOuter,
10220
- targetInner,
10221
- start: now,
10222
- fromOuter: ringAnimation.outer,
10223
- fromInner: ringAnimation.inner
10443
+ /*
10444
+ * Everything above writes the label's content. The layer runs what follows in two passes over all
10445
+ * its labels, measuring every one before placing any, so no label reads layout another just changed.
10446
+ */
10447
+ return () => {
10448
+ if (sizeStale || !resized) {
10449
+ fitIconBackground === null || fitIconBackground === void 0 ? void 0 : fitIconBackground();
10450
+ for (const fit of stackedFits)
10451
+ fit();
10452
+ badge = badgeOnIcon ? {
10453
+ width: countElement.offsetWidth,
10454
+ height: countElement.offsetHeight,
10455
+ iconWidth: iconElement.offsetWidth,
10456
+ iconHeight: iconElement.offsetHeight
10457
+ } : null;
10458
+ measureSize();
10459
+ sizeStale = false;
10460
+ }
10461
+ const pinShape = leader && pin ? size.pin : undefined;
10462
+ const measuredWidth = size.width / coordinates.scaleX;
10463
+ const measuredHeight = size.height / coordinates.scaleY;
10464
+ return () => {
10465
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
10466
+ if (badge) {
10467
+ const narrow = badge.iconWidth < badge.iconHeight * 0.6;
10468
+ const clearance = badge.width ? (narrow ? badge.width / 2 + 2 : Math.max(0, badge.width / 2 - badge.iconWidth / 4)) : 0;
10469
+ // Reserve the badge overhang so adjacent text and viewport edges remain clear.
10470
+ const overhang = badge.height / 2;
10471
+ const margins = [
10472
+ badgeBelow ? "0px" : `${overhang}px`, badgeBelow ? `${overhang}px` : "0px", `${badge.width / 2 + clearance}px`
10473
+ ];
10474
+ countElement.style.left = `calc(100% + ${clearance}px)`;
10475
+ if (iconContainer.style.marginTop !== margins[0] ||
10476
+ iconContainer.style.marginBottom !== margins[1] ||
10477
+ iconContainer.style.marginRight !== margins[2]) {
10478
+ [iconContainer.style.marginTop, iconContainer.style.marginBottom, iconContainer.style.marginRight] = margins;
10479
+ sizeStale = true;
10480
+ // The margins change the label's size, which the next frame measures.
10481
+ this.viewer.scene.requestRender();
10482
+ }
10483
+ }
10484
+ const ring = this.options.anchorRing;
10485
+ const pointer = (layer.pointer || (cursorMotion.target ? cursorMotion.position : undefined) || (this.Transient && !this.Persistent ?
10486
+ (this.hoverFade.to === 0 ? this.retainedHoverPosition : (_a = this.visualRegister) === null || _a === void 0 ? void 0 : _a.GetLabelHoverPosition((_b = this.rego) === null || _b === void 0 ? void 0 : _b.entityId, (_c = this.rego) === null || _c === void 0 ? void 0 : _c.menuItemId)) : undefined));
10487
+ const iconRing = frame.iconRadius ? Math.max(ICON_RING_MIN, frame.iconRadius + ICON_RING_PADDING) : 0;
10488
+ const boxed = leader ? frame.modelBox : undefined;
10489
+ const hovered = pointer && (boxed ? hullContains(boxed.hull, pointer) :
10490
+ Math.hypot(pointer.x - frame.anchorX, pointer.y - frame.anchorY) <= Math.max((_d = ring === null || ring === void 0 ? void 0 : ring.hoverDistance) !== null && _d !== void 0 ? _d : 24, iconRing));
10491
+ if (look.iconPhoto && growPhoto) {
10492
+ // A rectangle leans on the leader's side of the label.
10493
+ if (photoShape === "rect") {
10494
+ const align = !leader ? "center" : placement.textSide === "left" ? "flex-end" : "flex-start";
10495
+ if (content.style.alignItems !== align) {
10496
+ content.style.alignItems = align;
10497
+ }
10498
+ }
10499
+ // Grown in layout rather than scaled, so the border keeps its width, and the label,
10500
+ // whose bottom sits on the leader, grows up and sideways without changing its length.
10501
+ growPhoto(Boolean(hovered) && !((_e = placement.members) === null || _e === void 0 ? void 0 : _e.length));
10502
+ sizeStale = true;
10503
+ }
10504
+ const normalRadius = (!leader || (ring === null || ring === void 0 ? void 0 : ring.enabled) === false ? 0 : Math.max(frame.distance <= ((_f = ring === null || ring === void 0 ? void 0 : ring.nearDistance) !== null && _f !== void 0 ? _f : 100) ? ((_g = ring === null || ring === void 0 ? void 0 : ring.nearRadius) !== null && _g !== void 0 ? _g : 10) : 0, hovered ? ((_h = ring === null || ring === void 0 ? void 0 : ring.hoverRadius) !== null && _h !== void 0 ? _h : (this.Transient && !this.Persistent ? 15.4 : 22)) : 0));
10505
+ const targetRadius = normalRadius + (15.4 - normalRadius) * cursorMotion.amount;
10506
+ // Around a glyph the ring keeps its size and only fades its stroke in, never covering it.
10507
+ // A ring around the cursor marks nothing, so a riding label keeps only its leader.
10508
+ const targetOuter = frame.follows ? 0 : iconRing || targetRadius || 2.5;
10509
+ const targetInner = frame.follows ? 0 : iconRing ? (targetRadius > 0 ? iconRing - 2 : iconRing) : Math.max(0, targetRadius - 2);
10510
+ const now = Date.now();
10511
+ const duration = (_j = ring === null || ring === void 0 ? void 0 : ring.transitionDuration) !== null && _j !== void 0 ? _j : 200;
10512
+ const sharedRing = this.Transient && !this.Persistent && this.hoverFade.to === 1 ? this.hoverRingState : undefined;
10513
+ let ringAnimation = sharedRing ? sharedRing.animation : this.ringAnimation;
10514
+ if (!ringAnimation) {
10515
+ const outer = frame.follows ? 0 : iconRing || 2.5;
10516
+ const inner = frame.follows ? 0 : iconRing;
10517
+ ringAnimation = { target: outer, targetInner: inner, start: now, outer, inner, fromOuter: outer, fromInner: inner };
10518
+ }
10519
+ const animateRing = () => {
10520
+ const progress = duration > 0 ? Math.min(1, Math.max(0, (now - ringAnimation.start) / duration)) : 1;
10521
+ const eased = progress * progress * (3 - 2 * progress);
10522
+ ringAnimation.outer = ringAnimation.fromOuter + (ringAnimation.target - ringAnimation.fromOuter) * eased;
10523
+ ringAnimation.inner = ringAnimation.fromInner + (ringAnimation.targetInner - ringAnimation.fromInner) * eased;
10524
+ return progress;
10525
+ };
10526
+ animateRing();
10527
+ if (ringAnimation.target !== targetOuter || ringAnimation.targetInner !== targetInner) {
10528
+ ringAnimation = {
10529
+ ...ringAnimation,
10530
+ target: targetOuter,
10531
+ targetInner,
10532
+ start: now,
10533
+ fromOuter: ringAnimation.outer,
10534
+ fromInner: ringAnimation.inner
10535
+ };
10536
+ }
10537
+ // Animate the hole and stem together; no CSS transition may lag behind a moving world anchor.
10538
+ if (animateRing() < 1 && (ringAnimation.fromOuter !== targetOuter || ringAnimation.fromInner !== targetInner)) {
10539
+ this.viewer.scene.requestRender();
10540
+ }
10541
+ this.ringAnimation = ringAnimation;
10542
+ if (sharedRing) {
10543
+ sharedRing.animation = ringAnimation;
10544
+ }
10545
+ const ringShare = 1 - (frame.boxBlend || 0);
10546
+ const radius = ringShare > 0 && ringAnimation.inner > 0 ? ringAnimation.outer * ringShare : 0;
10547
+ const stem = (pinShape ? fitPin(frame.anchorX, frame.anchorY, frame.leaderLength, measuredWidth, measuredHeight, pinShape) :
10548
+ leader ? (angled ? fitAngledLeader : fitLeader)(frame.anchorX, frame.anchorY, Math.max(frame.leaderLength, radius ? radius + 4 : 0), measuredWidth, measuredHeight, radius) : undefined);
10549
+ const position = { x: (stem || frame).x, y: (stem || frame).y };
10550
+ const width = measuredWidth;
10551
+ const height = measuredHeight;
10552
+ if (leader && angled) {
10553
+ // The declutter owns the side; the fit only says which one had the room to begin with.
10554
+ const run = Math.max(ANGLED_LEADER_RUN, radius + 4);
10555
+ const side = (_l = (_k = placement.textSide) !== null && _k !== void 0 ? _k : frame.leaderSide) !== null && _l !== void 0 ? _l : "right";
10556
+ const beside = side === "left" ? frame.anchorX - run - width : frame.anchorX + run;
10557
+ position.x = Math.max(0, Math.min(beside, layer.viewport.width - width));
10558
+ }
10559
+ else if (leader && !pin && placement.textSide === "left") {
10560
+ position.x = Math.max(0, Math.min(frame.anchorX - width, layer.viewport.width - width));
10561
+ }
10562
+ const gap = (_o = (_m = this.options.pointerAvoidance) === null || _m === void 0 ? void 0 : _m.gap) !== null && _o !== void 0 ? _o : 12;
10563
+ const containsPointer = (x, y, margin) => {
10564
+ return pointer && pointer.x >= x - margin && pointer.x <= x + width + margin && pointer.y >= y - margin && pointer.y <= y + height + margin;
10565
+ };
10566
+ const passive = !selectOnClick || !this.visualRegister;
10567
+ if (passive && ((_p = this.options.pointerAvoidance) === null || _p === void 0 ? void 0 : _p.enabled) !== false && pointer &&
10568
+ (containsPointer(position.x, position.y, gap) || containsPointer(position.x + displacement.x, position.y + displacement.y, gap))) {
10569
+ if (containsPointer(position.x + displacement.x, position.y + displacement.y, 0)) {
10570
+ // Choose against the original box; keep the offset until the pointer leaves both.
10571
+ const candidates = [
10572
+ { x: 0, y: pointer.y - gap - height - position.y },
10573
+ { x: 0, y: pointer.y + gap - position.y },
10574
+ { x: pointer.x - gap - width - position.x, y: 0 },
10575
+ { x: pointer.x + gap - position.x, y: 0 }
10576
+ ].filter(offset => position.x + offset.x >= 0 && position.y + offset.y >= 0 &&
10577
+ position.x + offset.x + width <= layer.viewport.width && position.y + offset.y + height <= layer.viewport.height)
10578
+ .sort((a, b) => Math.hypot(a.x, a.y) - Math.hypot(b.x, b.y));
10579
+ displacement = candidates[0] || { x: 0, y: 0 };
10580
+ }
10581
+ }
10582
+ else {
10583
+ displacement = { x: 0, y: 0 };
10584
+ }
10585
+ const nudgeDuration = (_r = (_q = this.options.pointerAvoidance) === null || _q === void 0 ? void 0 : _q.transitionDuration) !== null && _r !== void 0 ? _r : 200;
10586
+ const animateNudge = () => {
10587
+ const progress = now < nudge.start ? 0 : nudgeDuration > 0 ? Math.min(1, (now - nudge.start) / nudgeDuration) : 1;
10588
+ const eased = progress * progress * (3 - 2 * progress);
10589
+ nudge.x = nudge.fromX + (nudge.targetX - nudge.fromX) * eased;
10590
+ nudge.y = nudge.fromY + (nudge.targetY - nudge.fromY) * eased;
10591
+ return progress;
10592
+ };
10593
+ animateNudge();
10594
+ if (nudge.targetX !== displacement.x || nudge.targetY !== displacement.y) {
10595
+ nudge = {
10596
+ ...nudge,
10597
+ fromX: nudge.x,
10598
+ fromY: nudge.y,
10599
+ targetX: displacement.x,
10600
+ targetY: displacement.y,
10601
+ start: now + ((_t = (_s = this.options.pointerAvoidance) === null || _s === void 0 ? void 0 : _s.delay) !== null && _t !== void 0 ? _t : 180)
10602
+ };
10603
+ }
10604
+ if (animateNudge() < 1 && (nudge.fromX !== nudge.targetX || nudge.fromY !== nudge.targetY)) {
10605
+ this.viewer.scene.requestRender();
10606
+ }
10607
+ position.x += nudge.x;
10608
+ position.y += nudge.y;
10609
+ ele.style.left = `${coordinates.x + position.x * coordinates.scaleX}px`;
10610
+ ele.style.top = `${coordinates.y + position.y * coordinates.scaleY}px`;
10611
+ for (const clickTarget of Array.from(content.querySelectorAll('[role="button"]'))) {
10612
+ clickTarget.setAttribute("aria-label", placement.members.length ? `Select ${placement.entityIds.length} entities` : `Select ${(_v = (_u = this.options.text) !== null && _u !== void 0 ? _u : text) !== null && _v !== void 0 ? _v : (_w = this.rego) === null || _w === void 0 ? void 0 : _w.entityId}`);
10613
+ }
10614
+ if (leader) {
10615
+ const nodeRadius = ringAnimation.outer * (1 - (frame.boxBlend || 0));
10616
+ const anchor = this.anchor;
10617
+ anchor.style.left = `${coordinates.x + (frame.anchorX - nodeRadius) * coordinates.scaleX}px`;
10618
+ anchor.style.top = `${coordinates.y + (frame.anchorY - nodeRadius) * coordinates.scaleY}px`;
10619
+ anchor.style.width = `${nodeRadius * 2 * coordinates.scaleX}px`;
10620
+ anchor.style.height = `${nodeRadius * 2 * coordinates.scaleY}px`;
10621
+ anchor.style.boxSizing = "border-box";
10622
+ anchor.style.background = "transparent";
10623
+ const svg = anchor.firstElementChild;
10624
+ svg.setAttribute("viewBox", `0 0 ${nodeRadius * 2} ${nodeRadius * 2}`);
10625
+ const circle = svg.firstElementChild;
10626
+ circle.setAttribute("cx", String(nodeRadius));
10627
+ circle.setAttribute("cy", String(nodeRadius));
10628
+ const innerRadius = ringAnimation.inner * (1 - (frame.boxBlend || 0));
10629
+ circle.setAttribute("r", String((nodeRadius + innerRadius) / 2));
10630
+ circle.setAttribute("stroke", this.options.leaderColor || "rgba(255, 255, 255, 0.8)");
10631
+ circle.setAttribute("stroke-width", String(nodeRadius - innerRadius));
10632
+ anchor.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
10633
+ anchor.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount) * (1 - (frame.boxBlend || 0)));
10634
+ anchor.style.zIndex = String(placement.zIndex);
10635
+ // The stem starts at the rim, never across the clear centre, even after displacement.
10636
+ const straightX = Math.max(position.x, Math.min(frame.anchorX, position.x + width));
10637
+ const straightY = frame.anchorY < position.y ? position.y : frame.anchorY > position.y + height ? position.y + height : frame.anchorY;
10638
+ const beside = angled && (frame.anchorX < position.x || frame.anchorX > position.x + width);
10639
+ const elbowY = position.y + height / 2;
10640
+ let endX = beside ? frame.anchorX : straightX;
10641
+ let endY = beside ? elbowY : straightY;
10642
+ if (pinShape) {
10643
+ // Aimed from wherever clamping or a nudge left it; a stem, if any, meets the tip.
10644
+ const centreX = position.x + pinShape.x, centreY = position.y + pinShape.y;
10645
+ const aim = Math.atan2(frame.anchorY - centreY, frame.anchorX - centreX);
10646
+ const reach = Math.min(pinShape.tip, Math.hypot(frame.anchorX - centreX, frame.anchorY - centreY));
10647
+ endX = centreX + Math.cos(aim) * reach;
10648
+ endY = centreY + Math.sin(aim) * reach;
10649
+ const size = `${pinShape.radius * 2 * coordinates.scaleX}px`;
10650
+ if (pinHolder.style.width !== size) {
10651
+ pinHolder.style.width = pinHolder.style.height = size;
10652
+ pinHolder.style.margin = `-${pinShape.radius * coordinates.scaleX}px`;
10653
+ }
10654
+ // The body's square corner starts lower right, a quarter turn short of down.
10655
+ const turn = Math.round((aim - Math.PI / 4) * 200) / 200;
10656
+ const rotation = `rotate(${turn}rad)`;
10657
+ if (pinBody.style.transform !== rotation) {
10658
+ pinBody.style.transform = rotation;
10659
+ // A box shadow turns with the body, so its offset is turned back to fall down
10660
+ // and right; a drop-shadow filter would not turn, but repaints every moving pin.
10661
+ const offsetX = Math.round((Math.cos(turn) + 2 * Math.sin(turn)) * 4) / 4;
10662
+ const offsetY = Math.round((2 * Math.cos(turn) - Math.sin(turn)) * 4) / 4;
10663
+ pinBody.style.boxShadow = `${offsetX}px ${offsetY}px 3px rgba(0, 0, 0, 0.35)`;
10664
+ }
10665
+ }
10666
+ const runToX = frame.anchorX < position.x ? position.x : position.x + width;
10667
+ const dx = endX - frame.anchorX, dy = endY - frame.anchorY;
10668
+ const length = Math.hypot(dx, dy);
10669
+ const leaderAngle = Math.atan2(dy, dx);
10670
+ const pointerDx = pointer ? pointer.x - frame.anchorX : 0;
10671
+ const pointerDy = pointer ? pointer.y - frame.anchorY : 0;
10672
+ const desiredAngle = Math.hypot(pointerDx, pointerDy) > 0.5 ? Math.atan2(pointerDy, pointerDx) + Math.PI - leaderAngle : 0;
10673
+ const wrappedAngle = Math.atan2(Math.sin(desiredAngle), Math.cos(desiredAngle));
10674
+ // Keep the stem inside the 126-degree arc, away from antialiased endpoints.
10675
+ const arcFraction = 0.35;
10676
+ const rotationLimit = Math.PI * arcFraction - Math.PI / 30;
10677
+ const targetOffset = hovered ? Math.max(-rotationLimit, Math.min(rotationLimit, wrappedAngle)) : ((_x = ringAnimation.arcOffset) !== null && _x !== void 0 ? _x : 0);
10678
+ const targetOpen = cursorMotion.target || (hovered && (ring === null || ring === void 0 ? void 0 : ring.enabled) !== false && targetRadius > 0) ? 1 : 0;
10679
+ const elapsed = Math.min(32, Math.max(0, now - ((_y = ringAnimation.arcTime) !== null && _y !== void 0 ? _y : now)));
10680
+ const blend = duration > 0 ? 1 - Math.exp(-elapsed / (duration / 3)) : 1;
10681
+ const approach = (value, target) => Math.abs(value - target) < 0.001 ? target : value + (target - value) * blend;
10682
+ ringAnimation.arcOffset = approach((_z = ringAnimation.arcOffset) !== null && _z !== void 0 ? _z : 0, targetOffset);
10683
+ ringAnimation.arcOpen = approach((_0 = ringAnimation.arcOpen) !== null && _0 !== void 0 ? _0 : 0, targetOpen);
10684
+ ringAnimation.arcTime = now;
10685
+ if (ringAnimation.arcOffset !== targetOffset || ringAnimation.arcOpen !== targetOpen) {
10686
+ this.viewer.scene.requestRender();
10687
+ }
10688
+ const circumference = Math.PI * (nodeRadius + ringAnimation.inner);
10689
+ const filledFraction = 1 - ringAnimation.arcOpen * (1 - arcFraction);
10690
+ circle.setAttribute("stroke-dasharray", `${circumference * filledFraction} ${circumference * (1 - filledFraction)}`);
10691
+ circle.setAttribute("transform", `rotate(${(leaderAngle + ringAnimation.arcOffset - Math.PI * filledFraction) * 180 / Math.PI} ${nodeRadius} ${nodeRadius})`);
10692
+ const cut = Math.min(radius, length);
10693
+ const startX = frame.anchorX + (length ? dx / length * cut : 0);
10694
+ const startY = frame.anchorY + (length ? dy / length * cut : 0);
10695
+ const draw = (element, fromX, fromY, toX, toY) => {
10696
+ const screenDx = (toX - fromX) * coordinates.scaleX;
10697
+ const screenDy = (toY - fromY) * coordinates.scaleY;
10698
+ element.style.width = `${2 * coordinates.scaleX}px`;
10699
+ element.style.left = `${coordinates.x + (fromX - 1) * coordinates.scaleX}px`;
10700
+ element.style.top = `${coordinates.y + fromY * coordinates.scaleY}px`;
10701
+ element.style.height = `${Math.hypot(screenDx, screenDy)}px`;
10702
+ element.style.transform = `rotate(${Math.atan2(screenDy, screenDx) - Math.PI / 2}rad)`;
10703
+ element.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
10704
+ element.style.transformOrigin = "top center";
10705
+ element.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount));
10706
+ element.style.zIndex = String(placement.zIndex);
10707
+ };
10708
+ draw(lineEle, startX, startY, endX, endY);
10709
+ if (layer.modelBoxes.Hull(this.id)) {
10710
+ layer.modelBoxes.Request(this.id, {
10711
+ whole: Boolean(cursorMotion.target), from: { x: frame.anchorX, y: frame.anchorY },
10712
+ opacity, zIndex: placement.zIndex, color: this.options.leaderColor || "rgba(255, 255, 255, 0.8)", duration
10713
+ });
10714
+ }
10715
+ if (runEle) {
10716
+ // Overlap the corner by the stem's own width so the elbow has no notch in it.
10717
+ const overlap = frame.anchorX < runToX ? -1 : 1;
10718
+ runEle.style.display = beside ? "block" : "none";
10719
+ if (beside)
10720
+ draw(runEle, endX + overlap, endY, runToX, endY);
10721
+ }
10722
+ }
10224
10723
  };
10225
- }
10226
- // Animate the hole and stem together; no CSS transition may lag behind a moving world anchor.
10227
- if (animateRing() < 1 && (ringAnimation.fromOuter !== targetOuter || ringAnimation.fromInner !== targetInner)) {
10228
- this.viewer.scene.requestRender();
10229
- }
10230
- this.ringAnimation = ringAnimation;
10231
- if (sharedRing) {
10232
- sharedRing.animation = ringAnimation;
10233
- }
10234
- const ringShare = 1 - (frame.boxBlend || 0);
10235
- const radius = ringShare > 0 && ringAnimation.inner > 0 ? ringAnimation.outer * ringShare : 0;
10236
- const pinShape = leader && pin ? measurePin() : undefined;
10237
- const stem = (pinShape ? fitPin(frame.anchorX, frame.anchorY, frame.leaderLength, ele.offsetWidth / coordinates.scaleX, ele.offsetHeight / coordinates.scaleY, pinShape) :
10238
- leader ? (angled ? fitAngledLeader : fitLeader)(frame.anchorX, frame.anchorY, Math.max(frame.leaderLength, radius ? radius + 4 : 0), ele.offsetWidth / coordinates.scaleX, ele.offsetHeight / coordinates.scaleY, radius) : undefined);
10239
- const position = { x: (stem || frame).x, y: (stem || frame).y };
10240
- const width = ele.offsetWidth / coordinates.scaleX;
10241
- const height = ele.offsetHeight / coordinates.scaleY;
10242
- if (leader && angled) {
10243
- // The declutter owns the side; the fit only says which one had the room to begin with.
10244
- const run = Math.max(ANGLED_LEADER_RUN, radius + 4);
10245
- const side = (_r = (_q = placement.textSide) !== null && _q !== void 0 ? _q : frame.leaderSide) !== null && _r !== void 0 ? _r : "right";
10246
- const beside = side === "left" ? frame.anchorX - run - width : frame.anchorX + run;
10247
- position.x = Math.max(0, Math.min(beside, this.viewer.canvas.clientWidth - width));
10248
- }
10249
- else if (leader && !pin && placement.textSide === "left") {
10250
- position.x = Math.max(0, Math.min(frame.anchorX - width, this.viewer.canvas.clientWidth - width));
10251
- }
10252
- const gap = (_t = (_s = this.options.pointerAvoidance) === null || _s === void 0 ? void 0 : _s.gap) !== null && _t !== void 0 ? _t : 12;
10253
- const containsPointer = (x, y, margin) => {
10254
- return pointer && pointer.x >= x - margin && pointer.x <= x + width + margin && pointer.y >= y - margin && pointer.y <= y + height + margin;
10255
- };
10256
- const passive = !selectOnClick || !this.visualRegister;
10257
- if (passive && ((_u = this.options.pointerAvoidance) === null || _u === void 0 ? void 0 : _u.enabled) !== false && pointer &&
10258
- (containsPointer(position.x, position.y, gap) || containsPointer(position.x + displacement.x, position.y + displacement.y, gap))) {
10259
- if (containsPointer(position.x + displacement.x, position.y + displacement.y, 0)) {
10260
- // Choose against the original box and retain the offset until the pointer leaves both boxes.
10261
- const candidates = [
10262
- { x: 0, y: pointer.y - gap - height - position.y },
10263
- { x: 0, y: pointer.y + gap - position.y },
10264
- { x: pointer.x - gap - width - position.x, y: 0 },
10265
- { x: pointer.x + gap - position.x, y: 0 }
10266
- ].filter(offset => position.x + offset.x >= 0 && position.y + offset.y >= 0 &&
10267
- position.x + offset.x + width <= this.viewer.canvas.clientWidth && position.y + offset.y + height <= this.viewer.canvas.clientHeight)
10268
- .sort((a, b) => Math.hypot(a.x, a.y) - Math.hypot(b.x, b.y));
10269
- displacement = candidates[0] || { x: 0, y: 0 };
10270
- }
10271
- }
10272
- else {
10273
- displacement = { x: 0, y: 0 };
10274
- }
10275
- const nudgeDuration = (_w = (_v = this.options.pointerAvoidance) === null || _v === void 0 ? void 0 : _v.transitionDuration) !== null && _w !== void 0 ? _w : 200;
10276
- const animateNudge = () => {
10277
- const progress = now < nudge.start ? 0 : nudgeDuration > 0 ? Math.min(1, (now - nudge.start) / nudgeDuration) : 1;
10278
- const eased = progress * progress * (3 - 2 * progress);
10279
- nudge.x = nudge.fromX + (nudge.targetX - nudge.fromX) * eased;
10280
- nudge.y = nudge.fromY + (nudge.targetY - nudge.fromY) * eased;
10281
- return progress;
10282
10724
  };
10283
- animateNudge();
10284
- if (nudge.targetX !== displacement.x || nudge.targetY !== displacement.y) {
10285
- nudge = {
10286
- ...nudge,
10287
- fromX: nudge.x,
10288
- fromY: nudge.y,
10289
- targetX: displacement.x,
10290
- targetY: displacement.y,
10291
- start: now + ((_y = (_x = this.options.pointerAvoidance) === null || _x === void 0 ? void 0 : _x.delay) !== null && _y !== void 0 ? _y : 180)
10292
- };
10293
- }
10294
- if (animateNudge() < 1 && (nudge.fromX !== nudge.targetX || nudge.fromY !== nudge.targetY)) {
10295
- this.viewer.scene.requestRender();
10296
- }
10297
- position.x += nudge.x;
10298
- position.y += nudge.y;
10299
- ele.style.left = `${coordinates.x + position.x * coordinates.scaleX}px`;
10300
- ele.style.top = `${coordinates.y + position.y * coordinates.scaleY}px`;
10301
- for (const clickTarget of Array.from(content.querySelectorAll('[role="button"]'))) {
10302
- clickTarget.setAttribute("aria-label", placement.members.length ? `Select ${placement.entityIds.length} entities` : `Select ${(_0 = (_z = this.options.text) !== null && _z !== void 0 ? _z : text) !== null && _0 !== void 0 ? _0 : (_1 = this.rego) === null || _1 === void 0 ? void 0 : _1.entityId}`);
10303
- }
10304
- if (leader) {
10305
- const nodeRadius = ringAnimation.outer * (1 - (frame.boxBlend || 0));
10306
- const anchor = this.anchor;
10307
- anchor.style.left = `${coordinates.x + (frame.anchorX - nodeRadius) * coordinates.scaleX}px`;
10308
- anchor.style.top = `${coordinates.y + (frame.anchorY - nodeRadius) * coordinates.scaleY}px`;
10309
- anchor.style.width = `${nodeRadius * 2 * coordinates.scaleX}px`;
10310
- anchor.style.height = `${nodeRadius * 2 * coordinates.scaleY}px`;
10311
- anchor.style.boxSizing = "border-box";
10312
- anchor.style.background = "transparent";
10313
- const svg = anchor.firstElementChild;
10314
- svg.setAttribute("viewBox", `0 0 ${nodeRadius * 2} ${nodeRadius * 2}`);
10315
- const circle = svg.firstElementChild;
10316
- circle.setAttribute("cx", String(nodeRadius));
10317
- circle.setAttribute("cy", String(nodeRadius));
10318
- const innerRadius = ringAnimation.inner * (1 - (frame.boxBlend || 0));
10319
- circle.setAttribute("r", String((nodeRadius + innerRadius) / 2));
10320
- circle.setAttribute("stroke", this.options.leaderColor || "rgba(255, 255, 255, 0.8)");
10321
- circle.setAttribute("stroke-width", String(nodeRadius - innerRadius));
10322
- anchor.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
10323
- anchor.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount) * (1 - (frame.boxBlend || 0)));
10324
- anchor.style.zIndex = String(placement.zIndex);
10325
- // The stem starts at the rim, never across the transparent centre, even after passive displacement.
10326
- const straightX = Math.max(position.x, Math.min(frame.anchorX, position.x + width));
10327
- const straightY = frame.anchorY < position.y ? position.y : frame.anchorY > position.y + height ? position.y + height : frame.anchorY;
10328
- const beside = angled && (frame.anchorX < position.x || frame.anchorX > position.x + width);
10329
- const elbowY = position.y + height / 2;
10330
- let endX = beside ? frame.anchorX : straightX;
10331
- let endY = beside ? elbowY : straightY;
10332
- if (pinShape) {
10333
- // Aimed from wherever clamping or a nudge left it; a stem, if any, meets the tip.
10334
- const centreX = position.x + pinShape.x, centreY = position.y + pinShape.y;
10335
- const aim = Math.atan2(frame.anchorY - centreY, frame.anchorX - centreX);
10336
- const reach = Math.min(pinShape.tip, Math.hypot(frame.anchorX - centreX, frame.anchorY - centreY));
10337
- endX = centreX + Math.cos(aim) * reach;
10338
- endY = centreY + Math.sin(aim) * reach;
10339
- const size = `${pinShape.radius * 2 * coordinates.scaleX}px`;
10340
- if (pinHolder.style.width !== size) {
10341
- pinHolder.style.width = pinHolder.style.height = size;
10342
- pinHolder.style.margin = `-${pinShape.radius * coordinates.scaleX}px`;
10343
- }
10344
- // The body's square corner starts at the lower right, a quarter turn short of pointing down.
10345
- pinBody.style.transform = `rotate(${aim - Math.PI / 4}rad)`;
10346
- }
10347
- const runToX = frame.anchorX < position.x ? position.x : position.x + width;
10348
- const dx = endX - frame.anchorX, dy = endY - frame.anchorY;
10349
- const length = Math.hypot(dx, dy);
10350
- const leaderAngle = Math.atan2(dy, dx);
10351
- const pointerDx = pointer ? pointer.x - frame.anchorX : 0;
10352
- const pointerDy = pointer ? pointer.y - frame.anchorY : 0;
10353
- const desiredAngle = Math.hypot(pointerDx, pointerDy) > 0.5 ? Math.atan2(pointerDy, pointerDx) + Math.PI - leaderAngle : 0;
10354
- const wrappedAngle = Math.atan2(Math.sin(desiredAngle), Math.cos(desiredAngle));
10355
- // Keep the stem inside the 126-degree arc, away from antialiased endpoints.
10356
- const arcFraction = 0.35;
10357
- const rotationLimit = Math.PI * arcFraction - Math.PI / 30;
10358
- const targetOffset = hovered ? Math.max(-rotationLimit, Math.min(rotationLimit, wrappedAngle)) : ((_2 = ringAnimation.arcOffset) !== null && _2 !== void 0 ? _2 : 0);
10359
- const targetOpen = cursorMotion.target || (hovered && (ring === null || ring === void 0 ? void 0 : ring.enabled) !== false && targetRadius > 0) ? 1 : 0;
10360
- const elapsed = Math.min(32, Math.max(0, now - ((_3 = ringAnimation.arcTime) !== null && _3 !== void 0 ? _3 : now)));
10361
- const blend = duration > 0 ? 1 - Math.exp(-elapsed / (duration / 3)) : 1;
10362
- const approach = (value, target) => Math.abs(value - target) < 0.001 ? target : value + (target - value) * blend;
10363
- ringAnimation.arcOffset = approach((_4 = ringAnimation.arcOffset) !== null && _4 !== void 0 ? _4 : 0, targetOffset);
10364
- ringAnimation.arcOpen = approach((_5 = ringAnimation.arcOpen) !== null && _5 !== void 0 ? _5 : 0, targetOpen);
10365
- ringAnimation.arcTime = now;
10366
- if (ringAnimation.arcOffset !== targetOffset || ringAnimation.arcOpen !== targetOpen) {
10367
- this.viewer.scene.requestRender();
10368
- }
10369
- const circumference = Math.PI * (nodeRadius + ringAnimation.inner);
10370
- const filledFraction = 1 - ringAnimation.arcOpen * (1 - arcFraction);
10371
- circle.setAttribute("stroke-dasharray", `${circumference * filledFraction} ${circumference * (1 - filledFraction)}`);
10372
- circle.setAttribute("transform", `rotate(${(leaderAngle + ringAnimation.arcOffset - Math.PI * filledFraction) * 180 / Math.PI} ${nodeRadius} ${nodeRadius})`);
10373
- const cut = Math.min(radius, length);
10374
- const startX = frame.anchorX + (length ? dx / length * cut : 0);
10375
- const startY = frame.anchorY + (length ? dy / length * cut : 0);
10376
- const draw = (element, fromX, fromY, toX, toY) => {
10377
- const screenDx = (toX - fromX) * coordinates.scaleX;
10378
- const screenDy = (toY - fromY) * coordinates.scaleY;
10379
- element.style.width = `${2 * coordinates.scaleX}px`;
10380
- element.style.left = `${coordinates.x + (fromX - 1) * coordinates.scaleX}px`;
10381
- element.style.top = `${coordinates.y + fromY * coordinates.scaleY}px`;
10382
- element.style.height = `${Math.hypot(screenDx, screenDy)}px`;
10383
- element.style.transform = `rotate(${Math.atan2(screenDy, screenDx) - Math.PI / 2}rad)`;
10384
- element.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
10385
- element.style.transformOrigin = "top center";
10386
- element.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount));
10387
- element.style.zIndex = String(placement.zIndex);
10388
- };
10389
- draw(lineEle, startX, startY, endX, endY);
10390
- if (layer.modelBoxes.Hull(this.id)) {
10391
- layer.modelBoxes.Request(this.id, {
10392
- whole: Boolean(cursorMotion.target), from: { x: frame.anchorX, y: frame.anchorY },
10393
- opacity, zIndex: placement.zIndex, color: this.options.leaderColor || "rgba(255, 255, 255, 0.8)", duration
10394
- });
10395
- }
10396
- if (runEle) {
10397
- // Overlap the corner by the stem's own width so the elbow has no notch in it.
10398
- const overlap = frame.anchorX < runToX ? -1 : 1;
10399
- runEle.style.display = beside ? "block" : "none";
10400
- if (beside)
10401
- draw(runEle, endX + overlap, endY, runToX, endY);
10402
- }
10403
- }
10404
10725
  };
10405
10726
  ele.style.display = "flex";
10406
10727
  ele.style.visibility = "hidden";
10407
- this.renderRemoval = layer.Add({ project, apply });
10728
+ // Hovering, riding the cursor or a highlight lift a label out of its cluster, which a stale frame misses.
10729
+ const wake = () => {
10730
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
10731
+ return Boolean(this.Transient ||
10732
+ ((_a = this.cursorMotion) === null || _a === void 0 ? void 0 : _a.target) ||
10733
+ ((_b = this.cursorMotion) === null || _b === void 0 ? void 0 : _b.amount) > 0 ||
10734
+ ((_c = this.visualRegister) === null || _c === void 0 ? void 0 : _c.GetLabelHoverPosition((_d = this.rego) === null || _d === void 0 ? void 0 : _d.entityId, (_e = this.rego) === null || _e === void 0 ? void 0 : _e.menuItemId)) ||
10735
+ ((_j = (_f = this.visualRegister) === null || _f === void 0 ? void 0 : _f.GetState({ entityId: (_g = this.rego) === null || _g === void 0 ? void 0 : _g.entityId, menuItemId: (_h = this.rego) === null || _h === void 0 ? void 0 : _h.menuItemId })) === null || _j === void 0 ? void 0 : _j.highlighted));
10736
+ };
10737
+ this.renderRemoval = layer.Add({ project, apply, wake });
10408
10738
  leaveLayer === null || leaveLayer === void 0 ? void 0 : leaveLayer();
10409
10739
  // If terrain changes then we'll re-call createLabel as the position may have changed.
10410
10740
  let terrTimeout = null;
@@ -60449,7 +60779,7 @@ var StyleUtils;
60449
60779
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
60450
60780
  })(StyleUtils || (StyleUtils = {}));
60451
60781
 
60452
- const VERSION = "7.8.1";
60782
+ const VERSION = "7.8.2";
60453
60783
  /**
60454
60784
  * Updates the environment instance used by bruce-cesium to one specified.
60455
60785
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.