@navaramap/core 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2026 Navara contributors
1
+ Copyright (c) 2026 MapLibre contributors
2
2
 
3
3
  This project is dual-licensed under either of
4
4
 
package/dist/index.d.ts CHANGED
@@ -47,6 +47,8 @@ export declare class CachedMeshHandleLike {
47
47
  uvs: number;
48
48
  indices: number;
49
49
  heights?: number | undefined;
50
+ normals?: number | undefined;
51
+ watermask?: number | undefined;
50
52
  constructor(t: CachedMeshHandle);
51
53
  free(): void;
52
54
  }
@@ -197,11 +199,17 @@ export declare class EventHandler<T extends BaseEventMap = BaseEventMap, K exten
197
199
  export declare class EventManager {
198
200
  stacks: EventsStacks;
199
201
  addedEventIds: Map<string, Set<unknown>>;
202
+ private sortedLengths;
200
203
  private transactionManager;
201
204
  needsUpdate(): boolean;
202
205
  pushEvents(events: Events | undefined): void;
203
206
  forEachStack<Key extends JsEventsKey>(key: Key, cb: (value: GetJsEventValue<Key>) => void, max?: number): void;
204
- forEachStackAsync<Key extends JsEventsKey>(key: Key, cb: (value: GetJsEventValue<Key>) => Promise<void>, max?: number, shouldProcess?: (value: GetJsEventValue<Key>) => boolean): Promise<void>;
207
+ /** Order the stack for dispatch. Pushes only append, so only the events
208
+ * added since the last pass are sorted and merged into the already sorted
209
+ * prefix (the prefix wins ties, keeping equal keys FIFO). */
210
+ private sortPending;
211
+ private removeAt;
212
+ forEachStackAsync<Key extends JsEventsKey>(key: Key, cb: (value: GetJsEventValue<Key>) => Promise<void>, max?: number, shouldProcess?: (value: GetJsEventValue<Key>) => boolean, order?: (a: GetJsEventValue<Key>, b: GetJsEventValue<Key>) => number): Promise<void>;
205
213
  removeDuplicatedTransactionEvents<AddKey extends JsEventsKey, RemoveKey extends JsEventsKey, ChangeKey extends JsEventsKey>(options: TransactionProcessOption<AddKey, RemoveKey, ChangeKey>): void;
206
214
  removeStacksByIndices(key: JsEventsKey, removedIndices: Set<number>): void;
207
215
  processTransactionEvents<AddKey extends JsEventsKey, RemoveKey extends JsEventsKey, ChangeKey extends JsEventsKey>(transactionKey: string, options: TransactionProcessOption<AddKey, RemoveKey, ChangeKey>, cb: (ev: TransactionCallbackParams<AddKey, RemoveKey, ChangeKey>) => Promise<void>, handlers?: {
@@ -486,6 +494,10 @@ declare type TransactionProcessOption<AddKey extends JsEventsKey, RemoveKey exte
486
494
  add: {
487
495
  key: AddKey;
488
496
  max?: number;
497
+ /** Dispatch order for the pending stack. Events a `shouldProcess` gate
498
+ * leaves behind are re-sorted against newer ones every pass, so this turns
499
+ * the FIFO stack into a priority queue (stable: equal keys stay FIFO). */
500
+ order?: (a: GetJsEventValue<AddKey>, b: GetJsEventValue<AddKey>) => number;
489
501
  };
490
502
  remove: {
491
503
  key: RemoveKey;
@@ -543,6 +555,12 @@ export declare class TransferablePolylineBatchedFeatureLike implements RemoveFre
543
555
  points_sizes: Uint32Array;
544
556
  batch_ids: Uint32Array;
545
557
  batch_indices: Uint32Array;
558
+ /**
559
+ * Per polyline, whether it is a polygon ring (1) or an open line (0). A
560
+ * ring's repeated first vertex is a seam the geometry joins; an open line
561
+ * keeps its end caps even when its endpoints coincide.
562
+ */
563
+ ring_flags: Uint8Array;
546
564
  crs: CRS;
547
565
  length: number;
548
566
  constructor(t: ReturnedTransferablePolylineBatchedFeature);
@@ -550,10 +568,12 @@ export declare class TransferablePolylineBatchedFeatureLike implements RemoveFre
550
568
  setPointsSizes(_byte_length: number, _f: () => void): void;
551
569
  setBatchIds(_byte_length: number, _f: () => void): void;
552
570
  setBatchIndices(_length: number, _f: () => void): void;
571
+ setRingFlags(_byte_length: number, _f: () => void): void;
553
572
  transferPoints(): Float64Array;
554
573
  transferPointsSizes(): Uint32Array;
555
574
  transferBatchIds(): Uint32Array;
556
575
  transferBatchIndices(): Uint32Array;
576
+ transferRingFlags(): Uint8Array;
557
577
  }
558
578
 
559
579
  export declare class TransferableRasterDEMDataLike implements RemoveFreeRecursively<TransferableRasterDEMData> {
package/dist/index.js CHANGED
@@ -65,6 +65,7 @@ var i = class {
65
65
  data_requester_removed: [],
66
66
  mesh_added: [],
67
67
  mesh_updated: [],
68
+ mesh_geometry_replaced: [],
68
69
  mesh_removed: [],
69
70
  object_transform_updated: [],
70
71
  renderable_feature_added: [],
@@ -73,12 +74,14 @@ var i = class {
73
74
  texture_fragment_removed: [],
74
75
  texture_fragment_requested: [],
75
76
  update_sample_terrain_height: [],
77
+ update_terrain_height_range: [],
76
78
  worker_task_delegated: [],
77
79
  worker_task_removed: [],
78
80
  hillshade_backfilled: [],
79
81
  hillshade_canceled: []
80
82
  };
81
83
  addedEventIds = /* @__PURE__ */ new Map();
84
+ sortedLengths = {};
82
85
  transactionManager = new i();
83
86
  needsUpdate() {
84
87
  return Object.values(this.stacks).some((e) => !!e.length);
@@ -96,26 +99,46 @@ var i = class {
96
99
  t(i), o(i), r++;
97
100
  }
98
101
  this.stacks[e].splice(0, r);
102
+ let i = this.sortedLengths[e];
103
+ i !== void 0 && (this.sortedLengths[e] = Math.max(0, i - r));
104
+ }
105
+ sortPending(e, t) {
106
+ let n = this.stacks[e], r = Math.min(this.sortedLengths[e] ?? 0, n.length);
107
+ if (r < n.length) {
108
+ let i = n.splice(r).sort(t), a = [], o = 0, s = 0;
109
+ for (; o < n.length && s < i.length;) a.push(t(n[o], i[s]) <= 0 ? n[o++] : i[s++]);
110
+ for (; o < n.length; o++) a.push(n[o]);
111
+ for (; s < i.length; s++) a.push(i[s]);
112
+ this.stacks[e] = a;
113
+ }
114
+ this.sortedLengths[e] = this.stacks[e].length;
115
+ }
116
+ removeAt(e, t) {
117
+ this.stacks[e].splice(t, 1);
118
+ let n = this.sortedLengths[e];
119
+ n !== void 0 && t < n && (this.sortedLengths[e] = n - 1);
99
120
  }
100
- async forEachStackAsync(e, t, n = 100, r) {
101
- let i = [], a = 0, s = [];
102
- for (let o of this.stacks[e]) {
103
- if (a === n) break;
104
- let e = o;
121
+ async forEachStackAsync(e, t, n = 100, r, i) {
122
+ let a = [];
123
+ i && this.sortPending(e, i);
124
+ let s = 0, c = [];
125
+ for (let i of this.stacks[e]) {
126
+ if (s === n) break;
127
+ let e = i;
105
128
  if (r && !r(e)) {
106
- a++;
129
+ s++;
107
130
  continue;
108
131
  }
109
- i.push(t(e)), s.push(a), a++;
132
+ a.push(t(e)), c.push(s), s++;
110
133
  }
111
- let c = [], l = 0;
112
- for (let t of s) {
113
- let n = t - l;
114
- c.push(this.stacks[e][n]), this.stacks[e].splice(n, 1), l++;
134
+ let l = [], u = 0;
135
+ for (let t of c) {
136
+ let n = t - u;
137
+ l.push(this.stacks[e][n]), this.removeAt(e, n), u++;
115
138
  }
116
- let u = await Promise.allSettled(i);
117
- for (let t of u) t.status === "rejected" && console.error(`Event handler for "${e}" failed:`, t.reason);
118
- for (let e of c) o(e);
139
+ let d = await Promise.allSettled(a);
140
+ for (let t of d) t.status === "rejected" && console.error(`Event handler for "${e}" failed:`, t.reason);
141
+ for (let e of l) o(e);
119
142
  }
120
143
  removeDuplicatedTransactionEvents(e) {
121
144
  let n = /* @__PURE__ */ new Map(), i = e.change ? /* @__PURE__ */ new Map() : null;
@@ -143,7 +166,7 @@ var i = class {
143
166
  }
144
167
  removeStacksByIndices(e, t) {
145
168
  let n = [...t].sort((e, t) => t - e);
146
- for (let t of n) o(this.stacks[e][t]), this.stacks[e].splice(t, 1);
169
+ for (let t of n) o(this.stacks[e][t]), this.removeAt(e, t);
147
170
  }
148
171
  processTransactionEvents(e, t, n, r) {
149
172
  let { shouldProcess: i, generateEventId: a = s, onAbort: o } = r ?? {};
@@ -159,7 +182,7 @@ var i = class {
159
182
  })), t.add.max, i ? (e) => i({
160
183
  type: "add",
161
184
  event: e
162
- }) : void 0)).then(() => (o && c.clear(), this.forEachStackAsync(t.remove.key, (e) => n({
185
+ }) : void 0, t.add.order)).then(() => (o && c.clear(), this.forEachStackAsync(t.remove.key, (e) => n({
163
186
  type: "remove",
164
187
  event: e
165
188
  }), t.remove.max, i ? (e) => i({
@@ -215,7 +238,10 @@ var p = class {
215
238
  max_height;
216
239
  min_height;
217
240
  constructor(e) {
218
- this.cached_mesh_handle = e.cached_mesh_handle ? new h(e.cached_mesh_handle) : void 0, this.coords = new m(e.coords), this.max_height = e.max_height, this.min_height = e.min_height;
241
+ let t = e.cached_mesh_handle;
242
+ this.cached_mesh_handle = t ? new h(t) : void 0, t?.free();
243
+ let n = e.coords;
244
+ this.coords = new m(n), n.free(), this.max_height = e.max_height, this.min_height = e.min_height;
219
245
  }
220
246
  free() {}
221
247
  }, m = class {
@@ -230,8 +256,10 @@ var p = class {
230
256
  uvs;
231
257
  indices;
232
258
  heights;
259
+ normals;
260
+ watermask;
233
261
  constructor(e) {
234
- this.vertices = e.vertices, this.uvs = e.uvs, this.indices = e.indices, this.heights = e.heights;
262
+ this.vertices = e.vertices, this.uvs = e.uvs, this.indices = e.indices, this.heights = e.heights, this.normals = e.normals, this.watermask = e.watermask;
235
263
  }
236
264
  free() {}
237
265
  }, g = class e {
@@ -451,15 +479,17 @@ var p = class {
451
479
  points_sizes;
452
480
  batch_ids;
453
481
  batch_indices;
482
+ ring_flags;
454
483
  crs;
455
484
  length;
456
485
  constructor(e) {
457
- this.points = e.transferPoints(), this.points_sizes = e.transferPointsSizes(), this.batch_ids = e.transferBatchIds(), this.batch_indices = e.transferBatchIndices(), this.crs = e.crs(), this.length = e.length();
486
+ this.points = e.transferPoints(), this.points_sizes = e.transferPointsSizes(), this.batch_ids = e.transferBatchIds(), this.batch_indices = e.transferBatchIndices(), this.ring_flags = e.transferRingFlags(), this.crs = e.crs(), this.length = e.length();
458
487
  }
459
488
  setPoints(e, t) {}
460
489
  setPointsSizes(e, t) {}
461
490
  setBatchIds(e, t) {}
462
491
  setBatchIndices(e, t) {}
492
+ setRingFlags(e, t) {}
463
493
  transferPoints() {
464
494
  throw Error();
465
495
  }
@@ -472,6 +502,9 @@ var p = class {
472
502
  transferBatchIndices() {
473
503
  throw Error();
474
504
  }
505
+ transferRingFlags() {
506
+ throw Error();
507
+ }
475
508
  }, re = class {
476
509
  clampToGround;
477
510
  tiled;
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@navaramap/engine")):typeof define==`function`&&define.amd?define([`exports`,`@navaramap/engine`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.NavaraCore={},e._navaramap_engine))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(e){return r(e.ind,e.gen)}function r(e,t){return`${e}_${t}`}function i(e){return!!e&&typeof e==`object`&&`ind`in e&&`gen`in e}var a=class{record={};getOrInsert(e){return this.record[e]||(this.record[e]=new o(e)),this.record[e]}},o=class e{id;continuable;currentPending;next;parent;constructor(e,t=!0){this.id=e,this.continuable=t}then(t){if(this.next||(this.next=new e(this.id,!1),this.next.parent=this),!this.currentPending&&this.continuable){this.continuable=!1,this.next.continuable=!1;let e=()=>{this.currentPending=void 0,this.next&&(this.next.continuable=!0)},n=t=>{console.error(`Transaction "${this.id}" callback failed:`,t),e()};try{this.currentPending=t().then(e,n)}catch(e){n(e)}}return this.next}end(){if(!this.continuable)return;let e=this.parent;if(!e){this.continuable=!0;return}for(this.continuable=!1;e.parent;)e=e.parent;e.continuable=!0}},s=e=>{e&&`free`in e&&e.free instanceof Function&&e.free()},c=e=>{let{event:t}=e;if(i(t))return n(t)},l=class{stacks={camera_transform_updated:[],camera_frustum_updated:[],camera_flight_ended:[],data_requested:[],data_requester_removed:[],mesh_added:[],mesh_updated:[],mesh_removed:[],object_transform_updated:[],renderable_feature_added:[],renderable_feature_changed:[],renderable_feature_removed:[],texture_fragment_removed:[],texture_fragment_requested:[],update_sample_terrain_height:[],worker_task_delegated:[],worker_task_removed:[],hillshade_backfilled:[],hillshade_canceled:[]};addedEventIds=new Map;transactionManager=new a;needsUpdate(){return Object.values(this.stacks).some(e=>!!e.length)}pushEvents(e){if(e)for(let t of Object.keys(this.stacks)){let n=e[`take_${t}`].call(e);n&&(Array.isArray(n)?this.stacks[t].push(...n):this.stacks[t].push(n))}}forEachStack(e,t,n=100){let r=0;for(let i of this.stacks[e]){if(r===n)break;t(i),s(i),r++}this.stacks[e].splice(0,r)}async forEachStackAsync(e,t,n=100,r){let i=[],a=0,o=[];for(let s of this.stacks[e]){if(a===n)break;let e=s;if(r&&!r(e)){a++;continue}i.push(t(e)),o.push(a),a++}let c=[],l=0;for(let t of o){let n=t-l;c.push(this.stacks[e][n]),this.stacks[e].splice(n,1),l++}let u=await Promise.allSettled(i);for(let t of u)t.status===`rejected`&&console.error(`Event handler for "${e}" failed:`,t.reason);for(let e of c)s(e)}removeDuplicatedTransactionEvents(e){let t=new Map,r=e.change?new Map:null;this.stacks[e.add.key].forEach((e,r)=>{if(i(e)){let i=n(e);t.set(i,r)}}),r&&e.change&&this.stacks[e.change.key].forEach((e,t)=>{if(i(e)){let i=n(e);r.set(i,t)}});let a=new Set,o=new Set,s=new Set;this.stacks[e.remove.key].forEach((c,l)=>{if(!i(c))return;let u=n(c),d=t.get(u),f=!1;if(d!==void 0&&(a.add(d),f=!0),r&&e.change){let e=r.get(u);e!==void 0&&o.add(e)}f&&s.add(l)}),a.size>0&&this.removeStacksByIndices(e.add.key,a),o.size>0&&e.change&&this.removeStacksByIndices(e.change.key,o),s.size>0&&this.removeStacksByIndices(e.remove.key,s)}removeStacksByIndices(e,t){let n=[...t].sort((e,t)=>t-e);for(let t of n)s(this.stacks[e][t]),this.stacks[e].splice(t,1)}processTransactionEvents(e,t,n,r){let{shouldProcess:i,generateEventId:a=c,onAbort:o}=r??{};this.removeDuplicatedTransactionEvents(t);let s=this.addedEventIds.get(e)??new Set;this.addedEventIds.set(e,s);let l=this.transactionManager.getOrInsert(e).then(()=>this.forEachStackAsync(t.add.key,e=>(o&&s.add(a({type:`add`,event:e})),n({type:`add`,event:e})),t.add.max,i?e=>i({type:`add`,event:e}):void 0)).then(()=>(o&&s.clear(),this.forEachStackAsync(t.remove.key,e=>n({type:`remove`,event:e}),t.remove.max,i?e=>i({type:`remove`,event:e}):void 0)));if(o&&s.size)for(let n of this.stacks[t.remove.key]){if(!n)continue;let t=n,r=a({type:`remove`,event:t});if(r&&s.has(r)){try{Promise.resolve(o(t)).catch(t=>{console.error(`onAbort handler for "${e}" failed:`,t)})}catch(t){console.error(`onAbort handler for "${e}" failed:`,t)}s.delete(r)}}if(t.change){let e=t.change;l.then(()=>this.forEachStackAsync(e.key,e=>n({type:`change`,event:e}),e.max,i?e=>i({type:`change`,event:e}):void 0)).end()}else l.end()}};function u(e){}function d(e){return e!=null}function f(e){return e!==void 0}function p(e){return e!==!1}var m=class{cached_mesh_handle;coords;max_height;min_height;constructor(e){this.cached_mesh_handle=e.cached_mesh_handle?new g(e.cached_mesh_handle):void 0,this.coords=new h(e.coords),this.max_height=e.max_height,this.min_height=e.min_height}free(){}},h=class{x;y;z;constructor(e){this.x=e.x,this.y=e.y,this.z=e.z}},g=class{vertices;uvs;indices;heights;constructor(e){this.vertices=e.vertices,this.uvs=e.uvs,this.indices=e.indices,this.heights=e.heights}free(){}},_=class e{coords;size;constructor(e,t){this.coords=e,this.size=t}transfer_coords(){return this.coords}clone(){return new e(this.coords.slice(),this.size)}},v=class{uvs;indices;heights;normals;watermask;constructor(e,t,n,r,i){this.uvs=e,this.indices=t,this.heights=n,this.normals=r,this.watermask=i}},y=class{decoder;constructor(e){this.decoder=new b(e)}},b=class{b_scaler;boundary;epsilon;g_scaler;max_offset;min_offset;offset;r_scaler;constructor(e){this.b_scaler=e.b_scaler,this.boundary=e.boundary,this.epsilon=e.epsilon,this.g_scaler=e.g_scaler,this.max_offset=e.max_offset,this.min_offset=e.min_offset,this.offset=e.offset,this.r_scaler=e.r_scaler}},ee=class{x;y;z;constructor(e){this.x=e.x,this.y=e.y,this.z=e.z}},te=class{vertices;uvs;indices;heights;max_height;min_height;rtc_translation;normals;skirt_vertices;skirt_uvs;skirt_indices;skirt_normals;watermask;constructor(e){this.vertices=e.transferVertices(),this.uvs=e.transferUvs(),this.indices=e.transferIndices(),this.heights=e.transferHeights(),this.max_height=e.max_height,this.min_height=e.min_height,this.rtc_translation=e.rtc_translation?new ee(e.rtc_translation):void 0,e.hasNormals()&&(this.normals=e.transferNormals()),e.hasSkirt()&&(this.skirt_vertices=e.transferSkirtVertices(),this.skirt_uvs=e.transferSkirtUvs(),this.skirt_indices=e.transferSkirtIndices(),this.skirt_normals=e.transferSkirtNormals()),e.hasWatermask()&&(this.watermask=e.transferWatermask())}transferVertices(){throw Error()}transferUvs(){throw Error()}transferIndices(){throw Error()}transferHeights(){throw Error()}transferNormals(){throw Error()}transferSkirtVertices(){throw Error()}transferSkirtUvs(){throw Error()}transferSkirtIndices(){throw Error()}transferSkirtNormals(){throw Error()}transferWatermask(){throw Error()}hasSkirt(){return this.skirt_vertices!==void 0&&this.skirt_uvs!==void 0&&this.skirt_indices!==void 0}hasNormals(){return this.normals!==void 0}hasWatermask(){return this.watermask!==void 0}},ne=class{batch_ids;batch_indices;crs;expected_winding_orders;holes;holes_boundaries;holes_sizes;holes_total_sizes;length;outer_ring;outer_ring_sizes;constructor(e){this.batch_ids=e.transferBatchIds(),this.batch_indices=e.transferBatchIndices(),this.crs=e.crs(),this.expected_winding_orders=e.transferExpectedWindingOrders(),this.holes=e.transferHoles(),this.holes_boundaries=e.transferHolesBoundaries(),this.holes_sizes=e.transferHolesSizes(),this.holes_total_sizes=e.transferHolesTotalSizes(),this.length=e.length(),this.outer_ring=e.transferOuterRing(),this.outer_ring_sizes=e.transferOuterRingSizes()}setBatchIds(e,t){}setBatchIndices(e,t){}setExpectedWindingOrders(e,t){}setOuterRing(e,t){}setOuterRingSizes(e,t){}setHoles(e,t){}setHolesBoundaries(e,t){}setHolesSizes(e,t){}setHolesTotalSizes(e,t){}transferBatchIds(){throw Error()}transferBatchIndices(){throw Error()}transferExpectedWindingOrders(){throw Error()}transferOuterRing(){throw Error()}transferOuterRingSizes(){throw Error()}transferHoles(){throw Error()}transferHolesBoundaries(){throw Error()}transferHolesSizes(){throw Error()}transferHolesTotalSizes(){throw Error()}},x=class{clampToGround;tiled;castShadow;receiveShadow;color;extrudedHeight;height;show;perPositionHeight;wireframe;outline;__internal__;constructor(e){this.clampToGround=e.clampToGround,this.tiled=e.tiled,this.receiveShadow=e.receiveShadow,this.castShadow=e.castShadow,this.color=e.color,this.extrudedHeight=e.extrudedHeight,this.height=e.height,this.show=e.show,this.perPositionHeight=e.perPositionHeight,this.wireframe=e.wireframe,this.outline=e.outline}free(){}},S=class{east;north;south;west;constructor(e){this.east=e.east,this.north=e.north,this.south=e.south,this.west=e.west}},C=class{extent;position_3d_high;position_3d_high_size;position_3d_low;position_3d_low_size;position;position_size;normal;normal_size;scale_normal_and_cap;scale_normal_and_cap_size;batch_id;batch_id_size;batch_index;batch_index_size;indices;rtc_translation;outline_position;outline_position_size;outline_position_3d_high;outline_position_3d_high_size;outline_position_3d_low;outline_position_3d_low_size;outline_scale_normal_and_cap;outline_scale_normal_and_cap_size;outline_skip_indices;outline_batch_index;outline_batch_index_size;constructor(e){let t=e.extent;this.extent=t?new S(t):void 0,this.position_3d_high=e.position_3d_high()?.slice(),this.position_3d_high_size=e.position_3d_high_size(),this.position_3d_low=e.position_3d_low()?.slice(),this.position_3d_low_size=e.position_3d_low_size(),this.position=e.position()?.slice(),this.position_size=e.position_size(),this.normal=e.normal()?.slice(),this.normal_size=e.normal_size(),this.scale_normal_and_cap=e.scale_normal_and_cap()?.slice(),this.scale_normal_and_cap_size=e.scale_normal_and_cap_size(),this.batch_id=e.batch_id()?.slice(),this.batch_id_size=e.batch_id_size(),this.batch_index=e.batch_index()?.slice(),this.batch_index_size=e.batch_index_size(),this.indices=e.indices().slice(),this.rtc_translation=e.rtc_translation?new ee(e.rtc_translation):void 0;let n=e.outline();n&&(this.outline_position=n.position()?.slice(),this.outline_position_size=n.position_size(),this.outline_position_3d_high=n.position_3d_high()?.slice(),this.outline_position_3d_high_size=n.position_3d_high_size(),this.outline_position_3d_low=n.position_3d_low()?.slice(),this.outline_position_3d_low_size=n.position_3d_low_size(),this.outline_scale_normal_and_cap=n.scale_normal_and_cap()?.slice(),this.outline_scale_normal_and_cap_size=n.scale_normal_and_cap_size(),this.outline_skip_indices=n.skip_indices()?.slice(),this.outline_batch_index=n.batch_index()?.slice(),this.outline_batch_index_size=n.batch_index_size(),n.free())}},re=class{points;points_sizes;batch_ids;batch_indices;crs;length;constructor(e){this.points=e.transferPoints(),this.points_sizes=e.transferPointsSizes(),this.batch_ids=e.transferBatchIds(),this.batch_indices=e.transferBatchIndices(),this.crs=e.crs(),this.length=e.length()}setPoints(e,t){}setPointsSizes(e,t){}setBatchIds(e,t){}setBatchIndices(e,t){}transferPoints(){throw Error()}transferPointsSizes(){throw Error()}transferBatchIds(){throw Error()}transferBatchIndices(){throw Error()}},ie=class{clampToGround;tiled;castShadow;receiveShadow;color;height;width;maxWidth;show;__internal__;constructor(e){this.clampToGround=e.clampToGround,this.tiled=e.tiled,this.receiveShadow=e.receiveShadow,this.castShadow=e.castShadow,this.color=e.color,this.width=e.width,this.maxWidth=e.maxWidth,this.height=e.height,this.show=e.show}free(){}},ae=class{extent;position;position_size;position_high;position_high_size;position_low;position_low_size;start;start_size;start_high;start_high_size;start_low;start_low_size;forward_offset;forward_offset_size;end_high;end_high_size;end_low;end_low_size;start_normals;start_normals_size;end_normal_and_texture_coordinate_normalization_x;end_normal_and_texture_coordinate_normalization_x_size;right_normal_and_texture_coordinate_normalization_y;right_normal_and_texture_coordinate_normalization_y_size;batch_id;batch_id_size;batch_index;batch_index_size;indices;constructor(e){let t=e.extent;this.extent=t?new S(t):void 0,this.position=e.position().slice(),this.position_size=e.position_size(),this.position_high=e.position_high()?.slice(),this.position_high_size=e.position_high_size(),this.position_low=e.position_low()?.slice(),this.position_low_size=e.position_low_size(),this.start=e.start()?.slice(),this.start_size=e.start_size(),this.start_high=e.start_high()?.slice(),this.start_high_size=e.start_high_size(),this.start_low=e.start_low()?.slice(),this.start_low_size=e.start_low_size(),this.forward_offset=e.forward_offset()?.slice(),this.forward_offset_size=e.forward_offset_size(),this.end_high=e.end_high()?.slice(),this.end_high_size=e.end_high_size(),this.end_low=e.end_low()?.slice(),this.end_low_size=e.end_low_size(),this.start_normals=e.start_normals()?.slice(),this.start_normals_size=e.start_normals_size(),this.end_normal_and_texture_coordinate_normalization_x=e.end_normal_and_texture_coordinate_normalization_x()?.slice(),this.end_normal_and_texture_coordinate_normalization_x_size=e.end_normal_and_texture_coordinate_normalization_x_size(),this.right_normal_and_texture_coordinate_normalization_y=e.right_normal_and_texture_coordinate_normalization_y().slice(),this.right_normal_and_texture_coordinate_normalization_y_size=e.right_normal_and_texture_coordinate_normalization_y_size(),this.batch_id=e.batch_id()?.slice(),this.batch_id_size=e.batch_id_size(),this.batch_index=e.batch_index()?.slice(),this.batch_index_size=e.batch_index_size(),this.indices=e.indices().slice()}},oe=[`png`,`webp`],se=class{events={};onceEvents={};on(e,t){this.events[e]||(this.events[e]=new Set),this.events[e].add(t)}off(e,t){this.events[e]?.delete(t),this.onceEvents[e]?.delete(t)}clear(e){this.events[e]?.clear(),this.onceEvents[e]?.clear()}size(e){return this.events[e]?.size||this.onceEvents[e]?.size}once(e,t){this.onceEvents[e]||(this.onceEvents[e]=new Set),this.onceEvents[e].add(t)}emit(e,...t){this.events[e]?.forEach(e=>e(...t)),this.onceEvents[e]?.size&&(this.onceEvents[e]?.forEach(e=>e(...t)),this.onceEvents[e]?.clear())}},ce=(e,t,n)=>{let r=t.length;for(let i=0;i<r;i++){let r=e[t[i]];n[i]=r}},le=class extends Error{constructor(e){super(e??`Unimplemented`)}},ue=class extends Error{constructor(e){super(e??`Unreachable`)}},de=class{list=[];indexMap={};add(e){this.assertUnique(e.name);let t=this.list.length;this.list.push(e),this.indexMap[e.name]=t}insertBefore(e,t){let n=this.findIndex(e);return this.insertAt(n,t)}insertAfter(e,t){let n=this.findIndex(e);return this.insertAt(n+1,t)}insertAt(e,t){if(this.assertUnique(t.name),e<0||e>this.list.length)throw RangeError(`index out of range: ${e}`);this.list.splice(e,0,t);for(let t=e;t<this.list.length;t++)this.indexMap[this.list[t].name]=t;return e}findIndex(e){let t=this.indexMap[e];if(t===void 0)throw Error(`target not found: ${e}`);return t}assertUnique(e){if(this.indexMap[e]!==void 0)throw Error(`duplicate name: ${e}`)}},fe=class extends se{_value;constructor(e){super(),this._value=e}get value(){return this._value}set value(e){this._value=e,this.emit(`changed`,e)}changed(e){let t=n=>{e(n),this.off(`changed`,t)};this.on(`changed`,t)}},pe=class{value;constructor(e,n,r){this.value=new t.Vec3(e,n,r)}copy(e,t,n){this.value.x=e,this.value.y=t,this.value.z=n}};function me(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function he(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ge(e){let t,n,r;e.length===2?(t=e===me||e===he?e:_e,n=e,r=e):(t=me,n=(t,n)=>me(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function _e(){return 0}function ve(e){return e===null?NaN:+e}var ye=ge(me),be=ye.right;ye.left,ge(ve).center;var xe=Math.sqrt(50),Se=Math.sqrt(10),Ce=Math.sqrt(2);function w(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=xe?10:a>=Se?5:a>=Ce?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?w(e,t,n*2):[s,c,l]}function we(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?w(t,e,n):w(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r){if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o}else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function Te(e,t,n){return t=+t,e=+e,n=+n,w(e,t,n)[2]}function Ee(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Te(t,e,n):Te(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}var De={value:()=>{}};function Oe(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new T(n)}function T(e){this._=e}function ke(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}T.prototype=Oe.prototype={constructor:T,on:function(e,t){var n=this._,r=ke(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Ae(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=je(n[i],e.name,t);else if(t==null)for(i in n)n[i]=je(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new T(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Ae(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function je(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=De,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Me={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function E(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),Me.hasOwnProperty(t)?{space:Me[t],local:e}:e}function Ne(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Pe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Fe(e){var t=E(e);return(t.local?Pe:Ne)(t)}function Ie(){}function Le(e){return e==null?Ie:function(){return this.querySelector(e)}}function Re(e){typeof e!=`function`&&(e=Le(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new O(r,this._parents)}function ze(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Be(){return[]}function Ve(e){return e==null?Be:function(){return this.querySelectorAll(e)}}function He(e){return function(){return ze(e.apply(this,arguments))}}function Ue(e){e=typeof e==`function`?He(e):Ve(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new O(r,i)}function We(e){return function(){return this.matches(e)}}function Ge(e){return function(t){return t.matches(e)}}var Ke=Array.prototype.find;function qe(e){return function(){return Ke.call(this.children,e)}}function Je(){return this.firstElementChild}function Ye(e){return this.select(e==null?Je:qe(typeof e==`function`?e:Ge(e)))}var Xe=Array.prototype.filter;function Ze(){return Array.from(this.children)}function Qe(e){return function(){return Xe.call(this.children,e)}}function $e(e){return this.selectAll(e==null?Ze:Qe(typeof e==`function`?e:Ge(e)))}function et(e){typeof e!=`function`&&(e=We(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new O(r,this._parents)}function tt(e){return Array(e.length)}function nt(){return new O(this._enter||this._groups.map(tt),this._parents)}function rt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}rt.prototype={constructor:rt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function it(e){return function(){return e}}function at(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new rt(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function ot(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new rt(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function st(e){return e.__data__}function ct(e,t){if(!arguments.length)return Array.from(this,st);var n=t?ot:at,r=this._parents,i=this._groups;typeof e!=`function`&&(e=it(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=lt(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new O(o,r),o._enter=s,o._exit=c,o}function lt(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function ut(){return new O(this._exit||this._groups.map(tt),this._parents)}function dt(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function ft(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new O(s,this._parents)}function pt(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function mt(e){e||=ht;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new O(i,this._parents).order()}function ht(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function gt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function _t(){return Array.from(this)}function vt(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function yt(){let e=0;for(let t of this)++e;return e}function bt(){return!this.node()}function xt(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function St(e){return function(){this.removeAttribute(e)}}function Ct(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wt(e,t){return function(){this.setAttribute(e,t)}}function Tt(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Et(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Dt(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ot(e,t){var n=E(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Ct:St:typeof t==`function`?n.local?Dt:Et:n.local?Tt:wt)(n,t))}function kt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function At(e){return function(){this.style.removeProperty(e)}}function jt(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Mt(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Nt(e,t,n){return arguments.length>1?this.each((t==null?At:typeof t==`function`?Mt:jt)(e,t,n??``)):D(this.node(),e)}function D(e,t){return e.style.getPropertyValue(t)||kt(e).getComputedStyle(e,null).getPropertyValue(t)}function Pt(e){return function(){delete this[e]}}function Ft(e,t){return function(){this[e]=t}}function It(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Lt(e,t){return arguments.length>1?this.each((t==null?Pt:typeof t==`function`?It:Ft)(e,t)):this.node()[e]}function Rt(e){return e.trim().split(/^|\s+/)}function zt(e){return e.classList||new Bt(e)}function Bt(e){this._node=e,this._names=Rt(e.getAttribute(`class`)||``)}Bt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Vt(e,t){for(var n=zt(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Ht(e,t){for(var n=zt(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Ut(e){return function(){Vt(this,e)}}function Wt(e){return function(){Ht(this,e)}}function Gt(e,t){return function(){(t.apply(this,arguments)?Vt:Ht)(this,e)}}function Kt(e,t){var n=Rt(e+``);if(arguments.length<2){for(var r=zt(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?Gt:t?Ut:Wt)(n,t))}function qt(){this.textContent=``}function Jt(e){return function(){this.textContent=e}}function Yt(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function Xt(e){return arguments.length?this.each(e==null?qt:(typeof e==`function`?Yt:Jt)(e)):this.node().textContent}function Zt(){this.innerHTML=``}function Qt(e){return function(){this.innerHTML=e}}function $t(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function en(e){return arguments.length?this.each(e==null?Zt:(typeof e==`function`?$t:Qt)(e)):this.node().innerHTML}function tn(){this.nextSibling&&this.parentNode.appendChild(this)}function nn(){return this.each(tn)}function rn(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function an(){return this.each(rn)}function on(e){var t=typeof e==`function`?e:Fe(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function sn(){return null}function cn(e,t){var n=typeof e==`function`?e:Fe(e),r=t==null?sn:typeof t==`function`?t:Le(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function ln(){var e=this.parentNode;e&&e.removeChild(this)}function un(){return this.each(ln)}function dn(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fn(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function pn(e){return this.select(e?fn:dn)}function mn(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function hn(e){return function(t){e.call(this,t,this.__data__)}}function gn(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function _n(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function vn(e,t,n){return function(){var r=this.__on,i,a=hn(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function yn(e,t,n){var r=gn(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?vn:_n,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function bn(e,t,n){var r=kt(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function xn(e,t){return function(){return bn(this,e,t)}}function Sn(e,t){return function(){return bn(this,e,t.apply(this,arguments))}}function Cn(e,t){return this.each((typeof t==`function`?Sn:xn)(e,t))}function*wn(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Tn=[null];function O(e,t){this._groups=e,this._parents=t}function k(){return new O([[document.documentElement]],Tn)}function En(){return this}O.prototype=k.prototype={constructor:O,select:Re,selectAll:Ue,selectChild:Ye,selectChildren:$e,filter:et,data:ct,enter:nt,exit:ut,join:dt,merge:ft,selection:En,order:pt,sort:mt,call:gt,nodes:_t,node:vt,size:yt,empty:bt,each:xt,attr:Ot,style:Nt,property:Lt,classed:Kt,text:Xt,html:en,raise:nn,lower:an,append:on,insert:cn,remove:un,clone:pn,datum:mn,on:yn,dispatch:Cn,[Symbol.iterator]:wn};function Dn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function On(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function A(){}var j=.7,kn=1/j,M=`\\s*([+-]?\\d+)\\s*`,N=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,P=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,An=/^#([0-9a-f]{3,8})$/,jn=RegExp(`^rgb\\(${M},${M},${M}\\)$`),Mn=RegExp(`^rgb\\(${P},${P},${P}\\)$`),Nn=RegExp(`^rgba\\(${M},${M},${M},${N}\\)$`),Pn=RegExp(`^rgba\\(${P},${P},${P},${N}\\)$`),Fn=RegExp(`^hsl\\(${N},${P},${P}\\)$`),In=RegExp(`^hsla\\(${N},${P},${P},${N}\\)$`),Ln={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Dn(A,F,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Rn,formatHex:Rn,formatHex8:zn,formatHsl:Bn,formatRgb:Vn,toString:Vn});function Rn(){return this.rgb().formatHex()}function zn(){return this.rgb().formatHex8()}function Bn(){return Xn(this).formatHsl()}function Vn(){return this.rgb().formatRgb()}function F(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=An.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Hn(t):n===3?new L(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Un(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Un(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=jn.exec(e))?new L(t[1],t[2],t[3],1):(t=Mn.exec(e))?new L(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Nn.exec(e))?Un(t[1],t[2],t[3],t[4]):(t=Pn.exec(e))?Un(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Fn.exec(e))?Yn(t[1],t[2]/100,t[3]/100,1):(t=In.exec(e))?Yn(t[1],t[2]/100,t[3]/100,t[4]):Ln.hasOwnProperty(e)?Hn(Ln[e]):e===`transparent`?new L(NaN,NaN,NaN,0):null}function Hn(e){return new L(e>>16&255,e>>8&255,e&255,1)}function Un(e,t,n,r){return r<=0&&(e=t=n=NaN),new L(e,t,n,r)}function Wn(e){return e instanceof A||(e=F(e)),e?(e=e.rgb(),new L(e.r,e.g,e.b,e.opacity)):new L}function I(e,t,n,r){return arguments.length===1?Wn(e):new L(e,t,n,r??1)}function L(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Dn(L,I,On(A,{brighter(e){return e=e==null?kn:kn**+e,new L(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?j:j**+e,new L(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new L(R(this.r),R(this.g),R(this.b),Jn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Gn,formatHex:Gn,formatHex8:Kn,formatRgb:qn,toString:qn}));function Gn(){return`#${z(this.r)}${z(this.g)}${z(this.b)}`}function Kn(){return`#${z(this.r)}${z(this.g)}${z(this.b)}${z((isNaN(this.opacity)?1:this.opacity)*255)}`}function qn(){let e=Jn(this.opacity);return`${e===1?`rgb(`:`rgba(`}${R(this.r)}, ${R(this.g)}, ${R(this.b)}${e===1?`)`:`, ${e})`}`}function Jn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function R(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function z(e){return e=R(e),(e<16?`0`:``)+e.toString(16)}function Yn(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new B(e,t,n,r)}function Xn(e){if(e instanceof B)return new B(e.h,e.s,e.l,e.opacity);if(e instanceof A||(e=F(e)),!e)return new B;if(e instanceof B)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new B(o,s,c,e.opacity)}function Zn(e,t,n,r){return arguments.length===1?Xn(e):new B(e,t,n,r??1)}function B(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Dn(B,Zn,On(A,{brighter(e){return e=e==null?kn:kn**+e,new B(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?j:j**+e,new B(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new L(er(e>=240?e-240:e+120,i,r),er(e,i,r),er(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new B(Qn(this.h),$n(this.s),$n(this.l),Jn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Jn(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Qn(this.h)}, ${$n(this.s)*100}%, ${$n(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Qn(e){return e=(e||0)%360,e<0?e+360:e}function $n(e){return Math.max(0,Math.min(1,e||0))}function er(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var tr=e=>()=>e;function nr(e,t){return function(n){return e+n*t}}function rr(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function ir(e){return(e=+e)==1?ar:function(t,n){return n-t?rr(t,n,e):tr(isNaN(t)?n:t)}}function ar(e,t){var n=t-e;return n?nr(e,n):tr(isNaN(e)?t:e)}var or=(function e(t){var n=ir(t);function r(e,t){var r=n((e=I(e)).r,(t=I(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=ar(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function sr(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function cr(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function lr(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=_r(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function ur(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function V(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function dr(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=_r(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var fr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pr=new RegExp(fr.source,`g`);function mr(e){return function(){return e}}function hr(e){return function(t){return e(t)+``}}function gr(e,t){var n=fr.lastIndex=pr.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=fr.exec(e))&&(i=pr.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:V(r,i)})),n=pr.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?hr(c[0].x):mr(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function _r(e,t){var n=typeof t,r;return t==null||n===`boolean`?tr(t):(n===`number`?V:n===`string`?(r=F(t))?(t=r,or):gr:t instanceof F?or:t instanceof Date?ur:cr(t)?sr:Array.isArray(t)?lr:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?dr:V)(e,t)}function vr(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var yr=180/Math.PI,br={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xr(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*yr,skewX:Math.atan(c)*yr,scaleX:o,scaleY:s}}var Sr;function Cr(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?br:xr(t.a,t.b,t.c,t.d,t.e,t.f)}function wr(e){return e==null||(Sr||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),Sr.setAttribute(`transform`,e),!(e=Sr.transform.baseVal.consolidate()))?br:(e=e.matrix,xr(e.a,e.b,e.c,e.d,e.e,e.f))}function Tr(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:V(e,i)},{i:c-2,x:V(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:V(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:V(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:V(e,n)},{i:s-2,x:V(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var Er=Tr(Cr,`px, `,`px)`,`deg)`),Dr=Tr(wr,`, `,`)`,`)`);function Or(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e(r/(t-1));return n}var H=0,kr=0,Ar=0,jr=1e3,Mr,U,Nr=0,W=0,Pr=0,G=typeof performance==`object`&&performance.now?performance:Date,Fr=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ir(){return W||=(Fr(Lr),G.now()+Pr)}function Lr(){W=0}function Rr(){this._call=this._time=this._next=null}Rr.prototype=zr.prototype={constructor:Rr,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Ir():+n)+(t==null?0:+t),!this._next&&U!==this&&(U?U._next=this:Mr=this,U=this),this._call=e,this._time=n,Wr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wr())}};function zr(e,t,n){var r=new Rr;return r.restart(e,t,n),r}function Br(){Ir(),++H;for(var e=Mr,t;e;)(t=W-e._time)>=0&&e._call.call(void 0,t),e=e._next;--H}function Vr(){W=(Nr=G.now())+Pr,H=kr=0;try{Br()}finally{H=0,Ur(),W=0}}function Hr(){var e=G.now(),t=e-Nr;t>jr&&(Pr-=t,Nr=e)}function Ur(){for(var e,t=Mr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Mr=n);U=e,Wr(r)}function Wr(e){H||(kr&&=clearTimeout(kr),e-W>24?(e<1/0&&(kr=setTimeout(Vr,e-G.now()-Pr)),Ar&&=clearInterval(Ar)):(Ar||=(Nr=G.now(),setInterval(Hr,jr)),H=1,Fr(Vr)))}function Gr(e,t,n){var r=new Rr;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Kr=Oe(`start`,`end`,`cancel`,`interrupt`),qr=[];function Jr(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Xr(e,n,{name:t,index:r,group:i,on:Kr,tween:qr,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Yr(e,t){var n=q(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function K(e,t){var n=q(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function q(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Xr(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=zr(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Gr(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(Gr(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function Zr(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Qr(e){return this.each(function(){Zr(this,e)})}function $r(e,t){var n,r;return function(){var i=K(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function ei(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=K(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function ti(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=q(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?$r:ei)(n,e,t))}function ni(e,t,n){var r=e._id;return e.each(function(){var e=K(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return q(e,r).value[t]}}function ri(e,t){var n;return(typeof t==`number`?V:t instanceof F?or:(n=F(t))?(t=n,or):gr)(e,t)}function ii(e){return function(){this.removeAttribute(e)}}function ai(e){return function(){this.removeAttributeNS(e.space,e.local)}}function oi(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function si(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function ci(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function li(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function ui(e,t){var n=E(e),r=n===`transform`?Dr:ri;return this.attrTween(e,typeof t==`function`?(n.local?li:ci)(n,r,ni(this,`attr.`+e,t)):t==null?(n.local?ai:ii)(n):(n.local?si:oi)(n,r,t))}function di(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function fi(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function pi(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&fi(e,i)),n}return i._value=t,i}function mi(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&di(e,i)),n}return i._value=t,i}function hi(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=E(e);return this.tween(n,(r.local?pi:mi)(r,t))}function gi(e,t){return function(){Yr(this,e).delay=+t.apply(this,arguments)}}function _i(e,t){return t=+t,function(){Yr(this,e).delay=t}}function vi(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?gi:_i)(t,e)):q(this.node(),t).delay}function yi(e,t){return function(){K(this,e).duration=+t.apply(this,arguments)}}function bi(e,t){return t=+t,function(){K(this,e).duration=t}}function xi(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?yi:bi)(t,e)):q(this.node(),t).duration}function Si(e,t){if(typeof t!=`function`)throw Error();return function(){K(this,e).ease=t}}function Ci(e){var t=this._id;return arguments.length?this.each(Si(t,e)):q(this.node(),t).ease}function wi(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();K(this,e).ease=n}}function Ti(e){if(typeof e!=`function`)throw Error();return this.each(wi(this._id,e))}function Ei(e){typeof e!=`function`&&(e=We(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new J(r,this._parents,this._name,this._id)}function Di(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new J(o,this._parents,this._name,this._id)}function Oi(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function ki(e,t,n){var r,i,a=Oi(t)?Yr:K;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Ai(e,t){var n=this._id;return arguments.length<2?q(this.node(),n).on.on(e):this.each(ki(n,e,t))}function ji(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Mi(){return this.on(`end.remove`,ji(this._id))}function Ni(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Le(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,Jr(l[f],t,n,f,l,q(u,n)));return new J(a,this._parents,t,n)}function Pi(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ve(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=q(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&Jr(p,t,n,h,f,m);a.push(f),o.push(u)}return new J(a,o,t,n)}var Fi=k.prototype.constructor;function Ii(){return new Fi(this._groups,this._parents)}function Li(e,t){var n,r,i;return function(){var a=D(this,e),o=(this.style.removeProperty(e),D(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Ri(e){return function(){this.style.removeProperty(e)}}function zi(e,t,n){var r,i=n+``,a;return function(){var o=D(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Bi(e,t,n){var r,i,a;return function(){var o=D(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),D(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Vi(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=K(this,e),l=c.on,u=c.value[a]==null?s||=Ri(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Hi(e,t,n){var r=(e+=``)==`transform`?Er:ri;return t==null?this.styleTween(e,Li(e,r)).on(`end.style.`+e,Ri(e)):typeof t==`function`?this.styleTween(e,Bi(e,r,ni(this,`style.`+e,t))).each(Vi(this._id,e)):this.styleTween(e,zi(e,r,t),n).on(`end.style.`+e,null)}function Ui(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Wi(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Ui(e,a,n)),r}return a._value=t,a}function Gi(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Wi(e,t,n??``))}function Ki(e){return function(){this.textContent=e}}function qi(e){return function(){var t=e(this);this.textContent=t??``}}function Ji(e){return this.tween(`text`,typeof e==`function`?qi(ni(this,`text`,e)):Ki(e==null?``:e+``))}function Yi(e){return function(t){this.textContent=e.call(this,t)}}function Xi(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Yi(r)),t}return r._value=e,r}function Zi(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,Xi(e))}function Qi(){for(var e=this._name,t=this._id,n=ta(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=q(c,t);Jr(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new J(r,this._parents,e,n)}function $i(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=K(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var ea=0;function J(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ta(){return++ea}var Y=k.prototype;J.prototype={constructor:J,select:Ni,selectAll:Pi,selectChild:Y.selectChild,selectChildren:Y.selectChildren,filter:Ei,merge:Di,selection:Ii,transition:Qi,call:Y.call,nodes:Y.nodes,node:Y.node,size:Y.size,empty:Y.empty,each:Y.each,on:Ai,attr:ui,attrTween:hi,style:Hi,styleTween:Gi,text:Ji,textTween:Zi,remove:Mi,tween:ti,delay:vi,duration:xi,ease:Ci,easeVarying:Ti,end:$i,[Symbol.iterator]:Y[Symbol.iterator]};function na(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ra={time:null,delay:0,duration:250,ease:na};function ia(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function aa(e){var t,n;e instanceof J?(t=e._id,e=e._name):(t=ta(),(n=ra).time=Ir(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Jr(c,e,t,l,o,n||ia(c,t));return new J(r,this._parents,e,t)}k.prototype.interrupt=Qr,k.prototype.transition=aa;var{abs:oa,max:sa,min:ca}=Math;[`w`,`e`].map(la),[`n`,`s`].map(la),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(la);function la(e){return{type:e}}function ua(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function da(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function X(e){return e=da(Math.abs(e)),e?e[1]:NaN}function fa(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function pa(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var ma=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ha(e){if(!(t=ma.exec(e)))throw Error(`invalid format: `+e);var t;return new ga({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}ha.prototype=ga.prototype;function ga(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}ga.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function _a(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var va;function ya(e,t){var n=da(e,t);if(!n)return va=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(va=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+da(e,Math.max(0,t+a-1))[0]}function ba(e,t){var n=da(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var xa={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:ua,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>ba(e*100,t),r:ba,s:ya,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Sa(e){return e}var Ca=Array.prototype.map,wa=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function Ta(e){var t=e.grouping===void 0||e.thousands===void 0?Sa:fa(Ca.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?Sa:pa(Ca.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=ha(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):xa[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),ee=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),te=xa[y],ne=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function x(e){var n=b,r=ee,o,l,p;if(y===`c`)r=te(e)+r,e=``;else{e=+e;var x=e<0||1/e<0;if(e=isNaN(e)?c:te(Math.abs(e),_),v&&(e=_a(e)),x&&+e==0&&f!==`+`&&(x=!1),n=(x?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&va!==void 0?wa[8+va/3]:``)+r+(x&&f===`(`?`)`:``),ne){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var S=n.length+e.length+r.length,C=S<h?Array(h-S+1).join(u):``;switch(g&&m&&(e=t(C+e,C.length?h-r.length:1/0),C=``),d){case`<`:e=n+e+r+C;break;case`=`:e=n+C+e+r;break;case`^`:e=C.slice(0,S=C.length>>1)+n+e+r+C.slice(S);break;default:e=C+n+e+r}return a(e)}return x.toString=function(){return e+``},x}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(X(t)/3)))*3,r=10**-n,i=l((e=ha(e),e.type=`f`,e),{suffix:wa[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var Ea,Da,Oa;ka({thousands:`,`,grouping:[3],currency:[`$`,``]});function ka(e){return Ea=Ta(e),Da=Ea.format,Oa=Ea.formatPrefix,Ea}function Aa(e){return Math.max(0,-X(Math.abs(e)))}function ja(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(X(t)/3)))*3-X(Math.abs(e)))}function Ma(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,X(t)-X(e))+1}function Na(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}function Pa(e){return function(){return e}}function Fa(e){return+e}var Ia=[0,1];function Z(e){return e}function La(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Pa(isNaN(t)?NaN:.5)}function Ra(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function za(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=La(i,r),a=n(o,a)):(r=La(r,i),a=n(a,o)),function(e){return a(r(e))}}function Ba(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=La(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=be(e,t,1,r)-1;return a[n](i[n](t))}}function Va(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Ha(){var e=Ia,t=Ia,n=_r,r,i,a,o=Z,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==Z&&(o=Ra(e[0],e[n-1])),s=n>2?Ba:za,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),V))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,Fa),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=vr,u()},d.clamp=function(e){return arguments.length?(o=e?!0:Z,u()):o!==Z},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function Ua(){return Ha()(Z,Z)}function Wa(e,t,n,r){var i=Ee(e,t,n),a;switch(r=ha(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=ja(i,o))&&(r.precision=a),Oa(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=Ma(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=Aa(i))&&(r.precision=a-(r.type===`%`)*2)}return Da(r)}function Ga(e){var t=e.domain;return e.ticks=function(e){var n=t();return we(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Wa(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-->0;){if(l=Te(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Ka(){var e=Ua();return e.copy=function(){return Va(e,Ka())},Na.apply(e,arguments),Ga(e)}function Q(e,t,n){this.k=e,this.x=t,this.y=n}Q.prototype={constructor:Q,scale:function(e){return e===1?this:new Q(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Q(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var qa=new Q(1,0,0);Ja.prototype=Q.prototype;function Ja(e){for(;!e.__zoom;)if(!(e=e.parentNode))return qa;return e.__zoom}var Ya=`Invariant failed`;function $(e,t){if(!e)throw Error(Ya)}var Xa=class{type;name;lut;constructor(e,t,n){this.type=e,this.name=t,$(n.length>1),this.lut=n.map(e=>Array.isArray(e)?e:e.srgb().toArray())}#e;linear(e){this.buildLinear(),$(this.#e);let t=this.#e(e);return $(t!=null),t}buildLinear(){this.#e??=Ka().domain(Or(_r(0,1),this.lut.length)).range(this.lut).clamp(!0)}get count(){return this.lut.length}ticks(e,t){return Ka().domain(e).ticks(t)}quantize(e){return $(e>1),[...Array(e)].map((t,n)=>this.linear(n/(e-1)))}createImage(){let e=document.createElement(`canvas`);e.width=this.lut.length,e.height=1;let t=e.getContext(`2d`);return $(t!=null),this.lut.forEach(([e,n,r],i)=>{t.fillStyle=I(e*255,n*255,r*255).toString(),t.fillRect(i,0,1,1)}),e}flatten(){let e=new Float32Array(this.lut.length*3);for(let t=0;t<this.lut.length;t++)e[t*3]=this.lut[t][0],e[t*3+1]=this.lut[t][1],e[t*3+2]=this.lut[t][2];return e}},Za=class{},Qa=class{handler;_elevationColormap;constructor(e,t){this.handler=e,this.setOptions(t)}setOptions(e){e?.maxSse!=null&&(this.maxSse=e.maxSse),e?.segments!=null&&(this.segments=e.segments),e?.color!=null&&(this.color=e.color),e?.hideUnderground!=null&&(this.hideUnderground=e.hideUnderground),e?.useNormal!=null&&(this.useNormal=e.useNormal),e?.transparent!=null&&(this.transparent=e.transparent),e?.opacity!=null&&(this.opacity=e.opacity),e?.wireframe!=null&&(this.wireframe=e.wireframe),e?.elevationColormap!=null&&(this.elevationColormap=e.elevationColormap)}get maxSse(){return this.handler.getMaxSse()??2}set maxSse(e){this.handler.setMaxSse(e)}get segments(){return this.handler.getSegments()??64}set segments(e){this.handler.setSegments(e)}get color(){return this.handler.getColor()}set color(e){this.handler.setColor(e)}get hideUnderground(){return this.handler.getHideUnderground()??!0}set hideUnderground(e){this.handler.setHideUnderground(e)}get useNormal(){return this.handler.getUseNormal()??!1}set useNormal(e){this.handler.setUseNormal(e)}get transparent(){return this.handler.getTransparent()??!1}set transparent(e){this.handler.setTransparent(e)}get opacity(){return this.handler.getOpacity()??1}set opacity(e){this.handler.setOpacity(e)}get wireframe(){return this.handler.getWireframe()??!1}set wireframe(e){this.handler.setWireframe(e)}get elevationColormap(){return this._elevationColormap}set elevationColormap(e){this._elevationColormap=e,this.handler.setElevationColormap(e)}},$a=class{};e.BaseAbstractedVec3=pe,e.CachedMeshHandleLike=g,e.Color=Za,e.ColorMap=Xa,e.ConstructedPolygonGeometryLike=C,e.ConstructedPolylineGeometryLike=ae,e.ElevationDecoderLike=b,e.EventHandler=se,e.EventManager=l,e.ExtentRadianF32Like=S,e.Globe=Qa,e.IMAGE_EXTENSIONS=oe,e.NamedIndexMap=de,e.Observed=fe,e.Plugin=$a,e.PolygonMaterialLike=x,e.PolylineMaterialLike=ie,e.ReturnedConstructedTerrainMeshLike=te,e.TileXYZLike=h,e.Transaction=o,e.TransactionManager=a,e.TransferableMartiniLike=_,e.TransferablePolygonBatchedFeatureLike=ne,e.TransferablePolylineBatchedFeatureLike=re,e.TransferableRasterDEMDataLike=y,e.TransferableTileLike=m,e.Unimplemented=le,e.Unreachable=ue,e.UpsamplableTerrainGeometryLike=v,e.Vec3Like=ee,e.assertType=u,e.generate_id_from_entity=n,e.generate_id_from_ind_gen=r,e.isEntityEvent=i,e.isNotFalse=p,e.isNotNullish=d,e.isNotUndefined=f,e.setBatchedValuesToBatchedAttribute=ce});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@navaramap/engine")):typeof define==`function`&&define.amd?define([`exports`,`@navaramap/engine`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.NavaraCore={},e._navaramap_engine))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(e){return r(e.ind,e.gen)}function r(e,t){return`${e}_${t}`}function i(e){return!!e&&typeof e==`object`&&`ind`in e&&`gen`in e}var a=class{record={};getOrInsert(e){return this.record[e]||(this.record[e]=new o(e)),this.record[e]}},o=class e{id;continuable;currentPending;next;parent;constructor(e,t=!0){this.id=e,this.continuable=t}then(t){if(this.next||(this.next=new e(this.id,!1),this.next.parent=this),!this.currentPending&&this.continuable){this.continuable=!1,this.next.continuable=!1;let e=()=>{this.currentPending=void 0,this.next&&(this.next.continuable=!0)},n=t=>{console.error(`Transaction "${this.id}" callback failed:`,t),e()};try{this.currentPending=t().then(e,n)}catch(e){n(e)}}return this.next}end(){if(!this.continuable)return;let e=this.parent;if(!e){this.continuable=!0;return}for(this.continuable=!1;e.parent;)e=e.parent;e.continuable=!0}},s=e=>{e&&`free`in e&&e.free instanceof Function&&e.free()},c=e=>{let{event:t}=e;if(i(t))return n(t)},l=class{stacks={camera_transform_updated:[],camera_frustum_updated:[],camera_flight_ended:[],data_requested:[],data_requester_removed:[],mesh_added:[],mesh_updated:[],mesh_geometry_replaced:[],mesh_removed:[],object_transform_updated:[],renderable_feature_added:[],renderable_feature_changed:[],renderable_feature_removed:[],texture_fragment_removed:[],texture_fragment_requested:[],update_sample_terrain_height:[],update_terrain_height_range:[],worker_task_delegated:[],worker_task_removed:[],hillshade_backfilled:[],hillshade_canceled:[]};addedEventIds=new Map;sortedLengths={};transactionManager=new a;needsUpdate(){return Object.values(this.stacks).some(e=>!!e.length)}pushEvents(e){if(e)for(let t of Object.keys(this.stacks)){let n=e[`take_${t}`].call(e);n&&(Array.isArray(n)?this.stacks[t].push(...n):this.stacks[t].push(n))}}forEachStack(e,t,n=100){let r=0;for(let i of this.stacks[e]){if(r===n)break;t(i),s(i),r++}this.stacks[e].splice(0,r);let i=this.sortedLengths[e];i!==void 0&&(this.sortedLengths[e]=Math.max(0,i-r))}sortPending(e,t){let n=this.stacks[e],r=Math.min(this.sortedLengths[e]??0,n.length);if(r<n.length){let i=n.splice(r).sort(t),a=[],o=0,s=0;for(;o<n.length&&s<i.length;)a.push(t(n[o],i[s])<=0?n[o++]:i[s++]);for(;o<n.length;o++)a.push(n[o]);for(;s<i.length;s++)a.push(i[s]);this.stacks[e]=a}this.sortedLengths[e]=this.stacks[e].length}removeAt(e,t){this.stacks[e].splice(t,1);let n=this.sortedLengths[e];n!==void 0&&t<n&&(this.sortedLengths[e]=n-1)}async forEachStackAsync(e,t,n=100,r,i){let a=[];i&&this.sortPending(e,i);let o=0,c=[];for(let i of this.stacks[e]){if(o===n)break;let e=i;if(r&&!r(e)){o++;continue}a.push(t(e)),c.push(o),o++}let l=[],u=0;for(let t of c){let n=t-u;l.push(this.stacks[e][n]),this.removeAt(e,n),u++}let d=await Promise.allSettled(a);for(let t of d)t.status===`rejected`&&console.error(`Event handler for "${e}" failed:`,t.reason);for(let e of l)s(e)}removeDuplicatedTransactionEvents(e){let t=new Map,r=e.change?new Map:null;this.stacks[e.add.key].forEach((e,r)=>{if(i(e)){let i=n(e);t.set(i,r)}}),r&&e.change&&this.stacks[e.change.key].forEach((e,t)=>{if(i(e)){let i=n(e);r.set(i,t)}});let a=new Set,o=new Set,s=new Set;this.stacks[e.remove.key].forEach((c,l)=>{if(!i(c))return;let u=n(c),d=t.get(u),f=!1;if(d!==void 0&&(a.add(d),f=!0),r&&e.change){let e=r.get(u);e!==void 0&&o.add(e)}f&&s.add(l)}),a.size>0&&this.removeStacksByIndices(e.add.key,a),o.size>0&&e.change&&this.removeStacksByIndices(e.change.key,o),s.size>0&&this.removeStacksByIndices(e.remove.key,s)}removeStacksByIndices(e,t){let n=[...t].sort((e,t)=>t-e);for(let t of n)s(this.stacks[e][t]),this.removeAt(e,t)}processTransactionEvents(e,t,n,r){let{shouldProcess:i,generateEventId:a=c,onAbort:o}=r??{};this.removeDuplicatedTransactionEvents(t);let s=this.addedEventIds.get(e)??new Set;this.addedEventIds.set(e,s);let l=this.transactionManager.getOrInsert(e).then(()=>this.forEachStackAsync(t.add.key,e=>(o&&s.add(a({type:`add`,event:e})),n({type:`add`,event:e})),t.add.max,i?e=>i({type:`add`,event:e}):void 0,t.add.order)).then(()=>(o&&s.clear(),this.forEachStackAsync(t.remove.key,e=>n({type:`remove`,event:e}),t.remove.max,i?e=>i({type:`remove`,event:e}):void 0)));if(o&&s.size)for(let n of this.stacks[t.remove.key]){if(!n)continue;let t=n,r=a({type:`remove`,event:t});if(r&&s.has(r)){try{Promise.resolve(o(t)).catch(t=>{console.error(`onAbort handler for "${e}" failed:`,t)})}catch(t){console.error(`onAbort handler for "${e}" failed:`,t)}s.delete(r)}}if(t.change){let e=t.change;l.then(()=>this.forEachStackAsync(e.key,e=>n({type:`change`,event:e}),e.max,i?e=>i({type:`change`,event:e}):void 0)).end()}else l.end()}};function u(e){}function d(e){return e!=null}function f(e){return e!==void 0}function p(e){return e!==!1}var m=class{cached_mesh_handle;coords;max_height;min_height;constructor(e){let t=e.cached_mesh_handle;this.cached_mesh_handle=t?new g(t):void 0,t?.free();let n=e.coords;this.coords=new h(n),n.free(),this.max_height=e.max_height,this.min_height=e.min_height}free(){}},h=class{x;y;z;constructor(e){this.x=e.x,this.y=e.y,this.z=e.z}},g=class{vertices;uvs;indices;heights;normals;watermask;constructor(e){this.vertices=e.vertices,this.uvs=e.uvs,this.indices=e.indices,this.heights=e.heights,this.normals=e.normals,this.watermask=e.watermask}free(){}},_=class e{coords;size;constructor(e,t){this.coords=e,this.size=t}transfer_coords(){return this.coords}clone(){return new e(this.coords.slice(),this.size)}},v=class{uvs;indices;heights;normals;watermask;constructor(e,t,n,r,i){this.uvs=e,this.indices=t,this.heights=n,this.normals=r,this.watermask=i}},y=class{decoder;constructor(e){this.decoder=new b(e)}},b=class{b_scaler;boundary;epsilon;g_scaler;max_offset;min_offset;offset;r_scaler;constructor(e){this.b_scaler=e.b_scaler,this.boundary=e.boundary,this.epsilon=e.epsilon,this.g_scaler=e.g_scaler,this.max_offset=e.max_offset,this.min_offset=e.min_offset,this.offset=e.offset,this.r_scaler=e.r_scaler}},ee=class{x;y;z;constructor(e){this.x=e.x,this.y=e.y,this.z=e.z}},te=class{vertices;uvs;indices;heights;max_height;min_height;rtc_translation;normals;skirt_vertices;skirt_uvs;skirt_indices;skirt_normals;watermask;constructor(e){this.vertices=e.transferVertices(),this.uvs=e.transferUvs(),this.indices=e.transferIndices(),this.heights=e.transferHeights(),this.max_height=e.max_height,this.min_height=e.min_height,this.rtc_translation=e.rtc_translation?new ee(e.rtc_translation):void 0,e.hasNormals()&&(this.normals=e.transferNormals()),e.hasSkirt()&&(this.skirt_vertices=e.transferSkirtVertices(),this.skirt_uvs=e.transferSkirtUvs(),this.skirt_indices=e.transferSkirtIndices(),this.skirt_normals=e.transferSkirtNormals()),e.hasWatermask()&&(this.watermask=e.transferWatermask())}transferVertices(){throw Error()}transferUvs(){throw Error()}transferIndices(){throw Error()}transferHeights(){throw Error()}transferNormals(){throw Error()}transferSkirtVertices(){throw Error()}transferSkirtUvs(){throw Error()}transferSkirtIndices(){throw Error()}transferSkirtNormals(){throw Error()}transferWatermask(){throw Error()}hasSkirt(){return this.skirt_vertices!==void 0&&this.skirt_uvs!==void 0&&this.skirt_indices!==void 0}hasNormals(){return this.normals!==void 0}hasWatermask(){return this.watermask!==void 0}},ne=class{batch_ids;batch_indices;crs;expected_winding_orders;holes;holes_boundaries;holes_sizes;holes_total_sizes;length;outer_ring;outer_ring_sizes;constructor(e){this.batch_ids=e.transferBatchIds(),this.batch_indices=e.transferBatchIndices(),this.crs=e.crs(),this.expected_winding_orders=e.transferExpectedWindingOrders(),this.holes=e.transferHoles(),this.holes_boundaries=e.transferHolesBoundaries(),this.holes_sizes=e.transferHolesSizes(),this.holes_total_sizes=e.transferHolesTotalSizes(),this.length=e.length(),this.outer_ring=e.transferOuterRing(),this.outer_ring_sizes=e.transferOuterRingSizes()}setBatchIds(e,t){}setBatchIndices(e,t){}setExpectedWindingOrders(e,t){}setOuterRing(e,t){}setOuterRingSizes(e,t){}setHoles(e,t){}setHolesBoundaries(e,t){}setHolesSizes(e,t){}setHolesTotalSizes(e,t){}transferBatchIds(){throw Error()}transferBatchIndices(){throw Error()}transferExpectedWindingOrders(){throw Error()}transferOuterRing(){throw Error()}transferOuterRingSizes(){throw Error()}transferHoles(){throw Error()}transferHolesBoundaries(){throw Error()}transferHolesSizes(){throw Error()}transferHolesTotalSizes(){throw Error()}},x=class{clampToGround;tiled;castShadow;receiveShadow;color;extrudedHeight;height;show;perPositionHeight;wireframe;outline;__internal__;constructor(e){this.clampToGround=e.clampToGround,this.tiled=e.tiled,this.receiveShadow=e.receiveShadow,this.castShadow=e.castShadow,this.color=e.color,this.extrudedHeight=e.extrudedHeight,this.height=e.height,this.show=e.show,this.perPositionHeight=e.perPositionHeight,this.wireframe=e.wireframe,this.outline=e.outline}free(){}},S=class{east;north;south;west;constructor(e){this.east=e.east,this.north=e.north,this.south=e.south,this.west=e.west}},C=class{extent;position_3d_high;position_3d_high_size;position_3d_low;position_3d_low_size;position;position_size;normal;normal_size;scale_normal_and_cap;scale_normal_and_cap_size;batch_id;batch_id_size;batch_index;batch_index_size;indices;rtc_translation;outline_position;outline_position_size;outline_position_3d_high;outline_position_3d_high_size;outline_position_3d_low;outline_position_3d_low_size;outline_scale_normal_and_cap;outline_scale_normal_and_cap_size;outline_skip_indices;outline_batch_index;outline_batch_index_size;constructor(e){let t=e.extent;this.extent=t?new S(t):void 0,this.position_3d_high=e.position_3d_high()?.slice(),this.position_3d_high_size=e.position_3d_high_size(),this.position_3d_low=e.position_3d_low()?.slice(),this.position_3d_low_size=e.position_3d_low_size(),this.position=e.position()?.slice(),this.position_size=e.position_size(),this.normal=e.normal()?.slice(),this.normal_size=e.normal_size(),this.scale_normal_and_cap=e.scale_normal_and_cap()?.slice(),this.scale_normal_and_cap_size=e.scale_normal_and_cap_size(),this.batch_id=e.batch_id()?.slice(),this.batch_id_size=e.batch_id_size(),this.batch_index=e.batch_index()?.slice(),this.batch_index_size=e.batch_index_size(),this.indices=e.indices().slice(),this.rtc_translation=e.rtc_translation?new ee(e.rtc_translation):void 0;let n=e.outline();n&&(this.outline_position=n.position()?.slice(),this.outline_position_size=n.position_size(),this.outline_position_3d_high=n.position_3d_high()?.slice(),this.outline_position_3d_high_size=n.position_3d_high_size(),this.outline_position_3d_low=n.position_3d_low()?.slice(),this.outline_position_3d_low_size=n.position_3d_low_size(),this.outline_scale_normal_and_cap=n.scale_normal_and_cap()?.slice(),this.outline_scale_normal_and_cap_size=n.scale_normal_and_cap_size(),this.outline_skip_indices=n.skip_indices()?.slice(),this.outline_batch_index=n.batch_index()?.slice(),this.outline_batch_index_size=n.batch_index_size(),n.free())}},re=class{points;points_sizes;batch_ids;batch_indices;ring_flags;crs;length;constructor(e){this.points=e.transferPoints(),this.points_sizes=e.transferPointsSizes(),this.batch_ids=e.transferBatchIds(),this.batch_indices=e.transferBatchIndices(),this.ring_flags=e.transferRingFlags(),this.crs=e.crs(),this.length=e.length()}setPoints(e,t){}setPointsSizes(e,t){}setBatchIds(e,t){}setBatchIndices(e,t){}setRingFlags(e,t){}transferPoints(){throw Error()}transferPointsSizes(){throw Error()}transferBatchIds(){throw Error()}transferBatchIndices(){throw Error()}transferRingFlags(){throw Error()}},ie=class{clampToGround;tiled;castShadow;receiveShadow;color;height;width;maxWidth;show;__internal__;constructor(e){this.clampToGround=e.clampToGround,this.tiled=e.tiled,this.receiveShadow=e.receiveShadow,this.castShadow=e.castShadow,this.color=e.color,this.width=e.width,this.maxWidth=e.maxWidth,this.height=e.height,this.show=e.show}free(){}},ae=class{extent;position;position_size;position_high;position_high_size;position_low;position_low_size;start;start_size;start_high;start_high_size;start_low;start_low_size;forward_offset;forward_offset_size;end_high;end_high_size;end_low;end_low_size;start_normals;start_normals_size;end_normal_and_texture_coordinate_normalization_x;end_normal_and_texture_coordinate_normalization_x_size;right_normal_and_texture_coordinate_normalization_y;right_normal_and_texture_coordinate_normalization_y_size;batch_id;batch_id_size;batch_index;batch_index_size;indices;constructor(e){let t=e.extent;this.extent=t?new S(t):void 0,this.position=e.position().slice(),this.position_size=e.position_size(),this.position_high=e.position_high()?.slice(),this.position_high_size=e.position_high_size(),this.position_low=e.position_low()?.slice(),this.position_low_size=e.position_low_size(),this.start=e.start()?.slice(),this.start_size=e.start_size(),this.start_high=e.start_high()?.slice(),this.start_high_size=e.start_high_size(),this.start_low=e.start_low()?.slice(),this.start_low_size=e.start_low_size(),this.forward_offset=e.forward_offset()?.slice(),this.forward_offset_size=e.forward_offset_size(),this.end_high=e.end_high()?.slice(),this.end_high_size=e.end_high_size(),this.end_low=e.end_low()?.slice(),this.end_low_size=e.end_low_size(),this.start_normals=e.start_normals()?.slice(),this.start_normals_size=e.start_normals_size(),this.end_normal_and_texture_coordinate_normalization_x=e.end_normal_and_texture_coordinate_normalization_x()?.slice(),this.end_normal_and_texture_coordinate_normalization_x_size=e.end_normal_and_texture_coordinate_normalization_x_size(),this.right_normal_and_texture_coordinate_normalization_y=e.right_normal_and_texture_coordinate_normalization_y().slice(),this.right_normal_and_texture_coordinate_normalization_y_size=e.right_normal_and_texture_coordinate_normalization_y_size(),this.batch_id=e.batch_id()?.slice(),this.batch_id_size=e.batch_id_size(),this.batch_index=e.batch_index()?.slice(),this.batch_index_size=e.batch_index_size(),this.indices=e.indices().slice()}},oe=[`png`,`webp`],se=class{events={};onceEvents={};on(e,t){this.events[e]||(this.events[e]=new Set),this.events[e].add(t)}off(e,t){this.events[e]?.delete(t),this.onceEvents[e]?.delete(t)}clear(e){this.events[e]?.clear(),this.onceEvents[e]?.clear()}size(e){return this.events[e]?.size||this.onceEvents[e]?.size}once(e,t){this.onceEvents[e]||(this.onceEvents[e]=new Set),this.onceEvents[e].add(t)}emit(e,...t){this.events[e]?.forEach(e=>e(...t)),this.onceEvents[e]?.size&&(this.onceEvents[e]?.forEach(e=>e(...t)),this.onceEvents[e]?.clear())}},ce=(e,t,n)=>{let r=t.length;for(let i=0;i<r;i++){let r=e[t[i]];n[i]=r}},le=class extends Error{constructor(e){super(e??`Unimplemented`)}},ue=class extends Error{constructor(e){super(e??`Unreachable`)}},de=class{list=[];indexMap={};add(e){this.assertUnique(e.name);let t=this.list.length;this.list.push(e),this.indexMap[e.name]=t}insertBefore(e,t){let n=this.findIndex(e);return this.insertAt(n,t)}insertAfter(e,t){let n=this.findIndex(e);return this.insertAt(n+1,t)}insertAt(e,t){if(this.assertUnique(t.name),e<0||e>this.list.length)throw RangeError(`index out of range: ${e}`);this.list.splice(e,0,t);for(let t=e;t<this.list.length;t++)this.indexMap[this.list[t].name]=t;return e}findIndex(e){let t=this.indexMap[e];if(t===void 0)throw Error(`target not found: ${e}`);return t}assertUnique(e){if(this.indexMap[e]!==void 0)throw Error(`duplicate name: ${e}`)}},fe=class extends se{_value;constructor(e){super(),this._value=e}get value(){return this._value}set value(e){this._value=e,this.emit(`changed`,e)}changed(e){let t=n=>{e(n),this.off(`changed`,t)};this.on(`changed`,t)}},pe=class{value;constructor(e,n,r){this.value=new t.Vec3(e,n,r)}copy(e,t,n){this.value.x=e,this.value.y=t,this.value.z=n}};function me(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function he(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ge(e){let t,n,r;e.length===2?(t=e===me||e===he?e:_e,n=e,r=e):(t=me,n=(t,n)=>me(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function _e(){return 0}function ve(e){return e===null?NaN:+e}var ye=ge(me),be=ye.right;ye.left,ge(ve).center;var xe=Math.sqrt(50),Se=Math.sqrt(10),Ce=Math.sqrt(2);function w(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=xe?10:a>=Se?5:a>=Ce?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?w(e,t,n*2):[s,c,l]}function we(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?w(t,e,n):w(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r){if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o}else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function Te(e,t,n){return t=+t,e=+e,n=+n,w(e,t,n)[2]}function Ee(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Te(t,e,n):Te(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}var De={value:()=>{}};function Oe(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new T(n)}function T(e){this._=e}function ke(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}T.prototype=Oe.prototype={constructor:T,on:function(e,t){var n=this._,r=ke(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Ae(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=je(n[i],e.name,t);else if(t==null)for(i in n)n[i]=je(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new T(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Ae(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function je(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=De,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Me={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function E(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),Me.hasOwnProperty(t)?{space:Me[t],local:e}:e}function Ne(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Pe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Fe(e){var t=E(e);return(t.local?Pe:Ne)(t)}function Ie(){}function Le(e){return e==null?Ie:function(){return this.querySelector(e)}}function Re(e){typeof e!=`function`&&(e=Le(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new O(r,this._parents)}function ze(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Be(){return[]}function Ve(e){return e==null?Be:function(){return this.querySelectorAll(e)}}function He(e){return function(){return ze(e.apply(this,arguments))}}function Ue(e){e=typeof e==`function`?He(e):Ve(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new O(r,i)}function We(e){return function(){return this.matches(e)}}function Ge(e){return function(t){return t.matches(e)}}var Ke=Array.prototype.find;function qe(e){return function(){return Ke.call(this.children,e)}}function Je(){return this.firstElementChild}function Ye(e){return this.select(e==null?Je:qe(typeof e==`function`?e:Ge(e)))}var Xe=Array.prototype.filter;function Ze(){return Array.from(this.children)}function Qe(e){return function(){return Xe.call(this.children,e)}}function $e(e){return this.selectAll(e==null?Ze:Qe(typeof e==`function`?e:Ge(e)))}function et(e){typeof e!=`function`&&(e=We(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new O(r,this._parents)}function tt(e){return Array(e.length)}function nt(){return new O(this._enter||this._groups.map(tt),this._parents)}function rt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}rt.prototype={constructor:rt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function it(e){return function(){return e}}function at(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new rt(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function ot(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new rt(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function st(e){return e.__data__}function ct(e,t){if(!arguments.length)return Array.from(this,st);var n=t?ot:at,r=this._parents,i=this._groups;typeof e!=`function`&&(e=it(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=lt(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new O(o,r),o._enter=s,o._exit=c,o}function lt(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function ut(){return new O(this._exit||this._groups.map(tt),this._parents)}function dt(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function ft(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new O(s,this._parents)}function pt(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function mt(e){e||=ht;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new O(i,this._parents).order()}function ht(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function gt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function _t(){return Array.from(this)}function vt(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function yt(){let e=0;for(let t of this)++e;return e}function bt(){return!this.node()}function xt(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function St(e){return function(){this.removeAttribute(e)}}function Ct(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wt(e,t){return function(){this.setAttribute(e,t)}}function Tt(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Et(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Dt(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ot(e,t){var n=E(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Ct:St:typeof t==`function`?n.local?Dt:Et:n.local?Tt:wt)(n,t))}function kt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function At(e){return function(){this.style.removeProperty(e)}}function jt(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Mt(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Nt(e,t,n){return arguments.length>1?this.each((t==null?At:typeof t==`function`?Mt:jt)(e,t,n??``)):D(this.node(),e)}function D(e,t){return e.style.getPropertyValue(t)||kt(e).getComputedStyle(e,null).getPropertyValue(t)}function Pt(e){return function(){delete this[e]}}function Ft(e,t){return function(){this[e]=t}}function It(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Lt(e,t){return arguments.length>1?this.each((t==null?Pt:typeof t==`function`?It:Ft)(e,t)):this.node()[e]}function Rt(e){return e.trim().split(/^|\s+/)}function zt(e){return e.classList||new Bt(e)}function Bt(e){this._node=e,this._names=Rt(e.getAttribute(`class`)||``)}Bt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Vt(e,t){for(var n=zt(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Ht(e,t){for(var n=zt(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Ut(e){return function(){Vt(this,e)}}function Wt(e){return function(){Ht(this,e)}}function Gt(e,t){return function(){(t.apply(this,arguments)?Vt:Ht)(this,e)}}function Kt(e,t){var n=Rt(e+``);if(arguments.length<2){for(var r=zt(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?Gt:t?Ut:Wt)(n,t))}function qt(){this.textContent=``}function Jt(e){return function(){this.textContent=e}}function Yt(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function Xt(e){return arguments.length?this.each(e==null?qt:(typeof e==`function`?Yt:Jt)(e)):this.node().textContent}function Zt(){this.innerHTML=``}function Qt(e){return function(){this.innerHTML=e}}function $t(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function en(e){return arguments.length?this.each(e==null?Zt:(typeof e==`function`?$t:Qt)(e)):this.node().innerHTML}function tn(){this.nextSibling&&this.parentNode.appendChild(this)}function nn(){return this.each(tn)}function rn(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function an(){return this.each(rn)}function on(e){var t=typeof e==`function`?e:Fe(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function sn(){return null}function cn(e,t){var n=typeof e==`function`?e:Fe(e),r=t==null?sn:typeof t==`function`?t:Le(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function ln(){var e=this.parentNode;e&&e.removeChild(this)}function un(){return this.each(ln)}function dn(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fn(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function pn(e){return this.select(e?fn:dn)}function mn(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function hn(e){return function(t){e.call(this,t,this.__data__)}}function gn(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function _n(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function vn(e,t,n){return function(){var r=this.__on,i,a=hn(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function yn(e,t,n){var r=gn(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?vn:_n,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function bn(e,t,n){var r=kt(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function xn(e,t){return function(){return bn(this,e,t)}}function Sn(e,t){return function(){return bn(this,e,t.apply(this,arguments))}}function Cn(e,t){return this.each((typeof t==`function`?Sn:xn)(e,t))}function*wn(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Tn=[null];function O(e,t){this._groups=e,this._parents=t}function k(){return new O([[document.documentElement]],Tn)}function En(){return this}O.prototype=k.prototype={constructor:O,select:Re,selectAll:Ue,selectChild:Ye,selectChildren:$e,filter:et,data:ct,enter:nt,exit:ut,join:dt,merge:ft,selection:En,order:pt,sort:mt,call:gt,nodes:_t,node:vt,size:yt,empty:bt,each:xt,attr:Ot,style:Nt,property:Lt,classed:Kt,text:Xt,html:en,raise:nn,lower:an,append:on,insert:cn,remove:un,clone:pn,datum:mn,on:yn,dispatch:Cn,[Symbol.iterator]:wn};function Dn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function On(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function A(){}var j=.7,kn=1/j,M=`\\s*([+-]?\\d+)\\s*`,N=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,P=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,An=/^#([0-9a-f]{3,8})$/,jn=RegExp(`^rgb\\(${M},${M},${M}\\)$`),Mn=RegExp(`^rgb\\(${P},${P},${P}\\)$`),Nn=RegExp(`^rgba\\(${M},${M},${M},${N}\\)$`),Pn=RegExp(`^rgba\\(${P},${P},${P},${N}\\)$`),Fn=RegExp(`^hsl\\(${N},${P},${P}\\)$`),In=RegExp(`^hsla\\(${N},${P},${P},${N}\\)$`),Ln={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Dn(A,F,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Rn,formatHex:Rn,formatHex8:zn,formatHsl:Bn,formatRgb:Vn,toString:Vn});function Rn(){return this.rgb().formatHex()}function zn(){return this.rgb().formatHex8()}function Bn(){return Xn(this).formatHsl()}function Vn(){return this.rgb().formatRgb()}function F(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=An.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Hn(t):n===3?new L(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Un(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Un(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=jn.exec(e))?new L(t[1],t[2],t[3],1):(t=Mn.exec(e))?new L(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Nn.exec(e))?Un(t[1],t[2],t[3],t[4]):(t=Pn.exec(e))?Un(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Fn.exec(e))?Yn(t[1],t[2]/100,t[3]/100,1):(t=In.exec(e))?Yn(t[1],t[2]/100,t[3]/100,t[4]):Ln.hasOwnProperty(e)?Hn(Ln[e]):e===`transparent`?new L(NaN,NaN,NaN,0):null}function Hn(e){return new L(e>>16&255,e>>8&255,e&255,1)}function Un(e,t,n,r){return r<=0&&(e=t=n=NaN),new L(e,t,n,r)}function Wn(e){return e instanceof A||(e=F(e)),e?(e=e.rgb(),new L(e.r,e.g,e.b,e.opacity)):new L}function I(e,t,n,r){return arguments.length===1?Wn(e):new L(e,t,n,r??1)}function L(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Dn(L,I,On(A,{brighter(e){return e=e==null?kn:kn**+e,new L(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?j:j**+e,new L(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new L(R(this.r),R(this.g),R(this.b),Jn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Gn,formatHex:Gn,formatHex8:Kn,formatRgb:qn,toString:qn}));function Gn(){return`#${z(this.r)}${z(this.g)}${z(this.b)}`}function Kn(){return`#${z(this.r)}${z(this.g)}${z(this.b)}${z((isNaN(this.opacity)?1:this.opacity)*255)}`}function qn(){let e=Jn(this.opacity);return`${e===1?`rgb(`:`rgba(`}${R(this.r)}, ${R(this.g)}, ${R(this.b)}${e===1?`)`:`, ${e})`}`}function Jn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function R(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function z(e){return e=R(e),(e<16?`0`:``)+e.toString(16)}function Yn(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new B(e,t,n,r)}function Xn(e){if(e instanceof B)return new B(e.h,e.s,e.l,e.opacity);if(e instanceof A||(e=F(e)),!e)return new B;if(e instanceof B)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new B(o,s,c,e.opacity)}function Zn(e,t,n,r){return arguments.length===1?Xn(e):new B(e,t,n,r??1)}function B(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Dn(B,Zn,On(A,{brighter(e){return e=e==null?kn:kn**+e,new B(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?j:j**+e,new B(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new L(er(e>=240?e-240:e+120,i,r),er(e,i,r),er(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new B(Qn(this.h),$n(this.s),$n(this.l),Jn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Jn(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Qn(this.h)}, ${$n(this.s)*100}%, ${$n(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Qn(e){return e=(e||0)%360,e<0?e+360:e}function $n(e){return Math.max(0,Math.min(1,e||0))}function er(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var tr=e=>()=>e;function nr(e,t){return function(n){return e+n*t}}function rr(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function ir(e){return(e=+e)==1?ar:function(t,n){return n-t?rr(t,n,e):tr(isNaN(t)?n:t)}}function ar(e,t){var n=t-e;return n?nr(e,n):tr(isNaN(e)?t:e)}var or=(function e(t){var n=ir(t);function r(e,t){var r=n((e=I(e)).r,(t=I(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=ar(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function sr(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function cr(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function lr(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=_r(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function ur(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function V(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function dr(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=_r(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var fr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pr=new RegExp(fr.source,`g`);function mr(e){return function(){return e}}function hr(e){return function(t){return e(t)+``}}function gr(e,t){var n=fr.lastIndex=pr.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=fr.exec(e))&&(i=pr.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:V(r,i)})),n=pr.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?hr(c[0].x):mr(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function _r(e,t){var n=typeof t,r;return t==null||n===`boolean`?tr(t):(n===`number`?V:n===`string`?(r=F(t))?(t=r,or):gr:t instanceof F?or:t instanceof Date?ur:cr(t)?sr:Array.isArray(t)?lr:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?dr:V)(e,t)}function vr(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var yr=180/Math.PI,br={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xr(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*yr,skewX:Math.atan(c)*yr,scaleX:o,scaleY:s}}var Sr;function Cr(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?br:xr(t.a,t.b,t.c,t.d,t.e,t.f)}function wr(e){return e==null||(Sr||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),Sr.setAttribute(`transform`,e),!(e=Sr.transform.baseVal.consolidate()))?br:(e=e.matrix,xr(e.a,e.b,e.c,e.d,e.e,e.f))}function Tr(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:V(e,i)},{i:c-2,x:V(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:V(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:V(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:V(e,n)},{i:s-2,x:V(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var Er=Tr(Cr,`px, `,`px)`,`deg)`),Dr=Tr(wr,`, `,`)`,`)`);function Or(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e(r/(t-1));return n}var H=0,kr=0,Ar=0,jr=1e3,Mr,U,Nr=0,W=0,Pr=0,G=typeof performance==`object`&&performance.now?performance:Date,Fr=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ir(){return W||=(Fr(Lr),G.now()+Pr)}function Lr(){W=0}function Rr(){this._call=this._time=this._next=null}Rr.prototype=zr.prototype={constructor:Rr,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Ir():+n)+(t==null?0:+t),!this._next&&U!==this&&(U?U._next=this:Mr=this,U=this),this._call=e,this._time=n,Wr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wr())}};function zr(e,t,n){var r=new Rr;return r.restart(e,t,n),r}function Br(){Ir(),++H;for(var e=Mr,t;e;)(t=W-e._time)>=0&&e._call.call(void 0,t),e=e._next;--H}function Vr(){W=(Nr=G.now())+Pr,H=kr=0;try{Br()}finally{H=0,Ur(),W=0}}function Hr(){var e=G.now(),t=e-Nr;t>jr&&(Pr-=t,Nr=e)}function Ur(){for(var e,t=Mr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Mr=n);U=e,Wr(r)}function Wr(e){H||(kr&&=clearTimeout(kr),e-W>24?(e<1/0&&(kr=setTimeout(Vr,e-G.now()-Pr)),Ar&&=clearInterval(Ar)):(Ar||=(Nr=G.now(),setInterval(Hr,jr)),H=1,Fr(Vr)))}function Gr(e,t,n){var r=new Rr;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Kr=Oe(`start`,`end`,`cancel`,`interrupt`),qr=[];function Jr(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Xr(e,n,{name:t,index:r,group:i,on:Kr,tween:qr,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Yr(e,t){var n=q(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function K(e,t){var n=q(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function q(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Xr(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=zr(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Gr(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(Gr(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function Zr(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Qr(e){return this.each(function(){Zr(this,e)})}function $r(e,t){var n,r;return function(){var i=K(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function ei(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=K(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function ti(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=q(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?$r:ei)(n,e,t))}function ni(e,t,n){var r=e._id;return e.each(function(){var e=K(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return q(e,r).value[t]}}function ri(e,t){var n;return(typeof t==`number`?V:t instanceof F?or:(n=F(t))?(t=n,or):gr)(e,t)}function ii(e){return function(){this.removeAttribute(e)}}function ai(e){return function(){this.removeAttributeNS(e.space,e.local)}}function oi(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function si(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function ci(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function li(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function ui(e,t){var n=E(e),r=n===`transform`?Dr:ri;return this.attrTween(e,typeof t==`function`?(n.local?li:ci)(n,r,ni(this,`attr.`+e,t)):t==null?(n.local?ai:ii)(n):(n.local?si:oi)(n,r,t))}function di(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function fi(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function pi(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&fi(e,i)),n}return i._value=t,i}function mi(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&di(e,i)),n}return i._value=t,i}function hi(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=E(e);return this.tween(n,(r.local?pi:mi)(r,t))}function gi(e,t){return function(){Yr(this,e).delay=+t.apply(this,arguments)}}function _i(e,t){return t=+t,function(){Yr(this,e).delay=t}}function vi(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?gi:_i)(t,e)):q(this.node(),t).delay}function yi(e,t){return function(){K(this,e).duration=+t.apply(this,arguments)}}function bi(e,t){return t=+t,function(){K(this,e).duration=t}}function xi(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?yi:bi)(t,e)):q(this.node(),t).duration}function Si(e,t){if(typeof t!=`function`)throw Error();return function(){K(this,e).ease=t}}function Ci(e){var t=this._id;return arguments.length?this.each(Si(t,e)):q(this.node(),t).ease}function wi(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();K(this,e).ease=n}}function Ti(e){if(typeof e!=`function`)throw Error();return this.each(wi(this._id,e))}function Ei(e){typeof e!=`function`&&(e=We(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new J(r,this._parents,this._name,this._id)}function Di(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new J(o,this._parents,this._name,this._id)}function Oi(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function ki(e,t,n){var r,i,a=Oi(t)?Yr:K;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Ai(e,t){var n=this._id;return arguments.length<2?q(this.node(),n).on.on(e):this.each(ki(n,e,t))}function ji(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Mi(){return this.on(`end.remove`,ji(this._id))}function Ni(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Le(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,Jr(l[f],t,n,f,l,q(u,n)));return new J(a,this._parents,t,n)}function Pi(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ve(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=q(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&Jr(p,t,n,h,f,m);a.push(f),o.push(u)}return new J(a,o,t,n)}var Fi=k.prototype.constructor;function Ii(){return new Fi(this._groups,this._parents)}function Li(e,t){var n,r,i;return function(){var a=D(this,e),o=(this.style.removeProperty(e),D(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Ri(e){return function(){this.style.removeProperty(e)}}function zi(e,t,n){var r,i=n+``,a;return function(){var o=D(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Bi(e,t,n){var r,i,a;return function(){var o=D(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),D(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Vi(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=K(this,e),l=c.on,u=c.value[a]==null?s||=Ri(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Hi(e,t,n){var r=(e+=``)==`transform`?Er:ri;return t==null?this.styleTween(e,Li(e,r)).on(`end.style.`+e,Ri(e)):typeof t==`function`?this.styleTween(e,Bi(e,r,ni(this,`style.`+e,t))).each(Vi(this._id,e)):this.styleTween(e,zi(e,r,t),n).on(`end.style.`+e,null)}function Ui(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Wi(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Ui(e,a,n)),r}return a._value=t,a}function Gi(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Wi(e,t,n??``))}function Ki(e){return function(){this.textContent=e}}function qi(e){return function(){var t=e(this);this.textContent=t??``}}function Ji(e){return this.tween(`text`,typeof e==`function`?qi(ni(this,`text`,e)):Ki(e==null?``:e+``))}function Yi(e){return function(t){this.textContent=e.call(this,t)}}function Xi(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Yi(r)),t}return r._value=e,r}function Zi(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,Xi(e))}function Qi(){for(var e=this._name,t=this._id,n=ta(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=q(c,t);Jr(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new J(r,this._parents,e,n)}function $i(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=K(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var ea=0;function J(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ta(){return++ea}var Y=k.prototype;J.prototype={constructor:J,select:Ni,selectAll:Pi,selectChild:Y.selectChild,selectChildren:Y.selectChildren,filter:Ei,merge:Di,selection:Ii,transition:Qi,call:Y.call,nodes:Y.nodes,node:Y.node,size:Y.size,empty:Y.empty,each:Y.each,on:Ai,attr:ui,attrTween:hi,style:Hi,styleTween:Gi,text:Ji,textTween:Zi,remove:Mi,tween:ti,delay:vi,duration:xi,ease:Ci,easeVarying:Ti,end:$i,[Symbol.iterator]:Y[Symbol.iterator]};function na(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ra={time:null,delay:0,duration:250,ease:na};function ia(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function aa(e){var t,n;e instanceof J?(t=e._id,e=e._name):(t=ta(),(n=ra).time=Ir(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Jr(c,e,t,l,o,n||ia(c,t));return new J(r,this._parents,e,t)}k.prototype.interrupt=Qr,k.prototype.transition=aa;var{abs:oa,max:sa,min:ca}=Math;[`w`,`e`].map(la),[`n`,`s`].map(la),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(la);function la(e){return{type:e}}function ua(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function da(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function X(e){return e=da(Math.abs(e)),e?e[1]:NaN}function fa(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function pa(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var ma=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ha(e){if(!(t=ma.exec(e)))throw Error(`invalid format: `+e);var t;return new ga({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}ha.prototype=ga.prototype;function ga(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}ga.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function _a(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var va;function ya(e,t){var n=da(e,t);if(!n)return va=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(va=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+da(e,Math.max(0,t+a-1))[0]}function ba(e,t){var n=da(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var xa={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:ua,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>ba(e*100,t),r:ba,s:ya,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Sa(e){return e}var Ca=Array.prototype.map,wa=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function Ta(e){var t=e.grouping===void 0||e.thousands===void 0?Sa:fa(Ca.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?Sa:pa(Ca.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=ha(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):xa[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),ee=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),te=xa[y],ne=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function x(e){var n=b,r=ee,o,l,p;if(y===`c`)r=te(e)+r,e=``;else{e=+e;var x=e<0||1/e<0;if(e=isNaN(e)?c:te(Math.abs(e),_),v&&(e=_a(e)),x&&+e==0&&f!==`+`&&(x=!1),n=(x?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&va!==void 0?wa[8+va/3]:``)+r+(x&&f===`(`?`)`:``),ne){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var S=n.length+e.length+r.length,C=S<h?Array(h-S+1).join(u):``;switch(g&&m&&(e=t(C+e,C.length?h-r.length:1/0),C=``),d){case`<`:e=n+e+r+C;break;case`=`:e=n+C+e+r;break;case`^`:e=C.slice(0,S=C.length>>1)+n+e+r+C.slice(S);break;default:e=C+n+e+r}return a(e)}return x.toString=function(){return e+``},x}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(X(t)/3)))*3,r=10**-n,i=l((e=ha(e),e.type=`f`,e),{suffix:wa[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var Ea,Da,Oa;ka({thousands:`,`,grouping:[3],currency:[`$`,``]});function ka(e){return Ea=Ta(e),Da=Ea.format,Oa=Ea.formatPrefix,Ea}function Aa(e){return Math.max(0,-X(Math.abs(e)))}function ja(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(X(t)/3)))*3-X(Math.abs(e)))}function Ma(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,X(t)-X(e))+1}function Na(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}function Pa(e){return function(){return e}}function Fa(e){return+e}var Ia=[0,1];function Z(e){return e}function La(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Pa(isNaN(t)?NaN:.5)}function Ra(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function za(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=La(i,r),a=n(o,a)):(r=La(r,i),a=n(a,o)),function(e){return a(r(e))}}function Ba(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=La(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=be(e,t,1,r)-1;return a[n](i[n](t))}}function Va(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Ha(){var e=Ia,t=Ia,n=_r,r,i,a,o=Z,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==Z&&(o=Ra(e[0],e[n-1])),s=n>2?Ba:za,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),V))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,Fa),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=vr,u()},d.clamp=function(e){return arguments.length?(o=e?!0:Z,u()):o!==Z},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function Ua(){return Ha()(Z,Z)}function Wa(e,t,n,r){var i=Ee(e,t,n),a;switch(r=ha(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=ja(i,o))&&(r.precision=a),Oa(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=Ma(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=Aa(i))&&(r.precision=a-(r.type===`%`)*2)}return Da(r)}function Ga(e){var t=e.domain;return e.ticks=function(e){var n=t();return we(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Wa(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-->0;){if(l=Te(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Ka(){var e=Ua();return e.copy=function(){return Va(e,Ka())},Na.apply(e,arguments),Ga(e)}function Q(e,t,n){this.k=e,this.x=t,this.y=n}Q.prototype={constructor:Q,scale:function(e){return e===1?this:new Q(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Q(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var qa=new Q(1,0,0);Ja.prototype=Q.prototype;function Ja(e){for(;!e.__zoom;)if(!(e=e.parentNode))return qa;return e.__zoom}var Ya=`Invariant failed`;function $(e,t){if(!e)throw Error(Ya)}var Xa=class{type;name;lut;constructor(e,t,n){this.type=e,this.name=t,$(n.length>1),this.lut=n.map(e=>Array.isArray(e)?e:e.srgb().toArray())}#e;linear(e){this.buildLinear(),$(this.#e);let t=this.#e(e);return $(t!=null),t}buildLinear(){this.#e??=Ka().domain(Or(_r(0,1),this.lut.length)).range(this.lut).clamp(!0)}get count(){return this.lut.length}ticks(e,t){return Ka().domain(e).ticks(t)}quantize(e){return $(e>1),[...Array(e)].map((t,n)=>this.linear(n/(e-1)))}createImage(){let e=document.createElement(`canvas`);e.width=this.lut.length,e.height=1;let t=e.getContext(`2d`);return $(t!=null),this.lut.forEach(([e,n,r],i)=>{t.fillStyle=I(e*255,n*255,r*255).toString(),t.fillRect(i,0,1,1)}),e}flatten(){let e=new Float32Array(this.lut.length*3);for(let t=0;t<this.lut.length;t++)e[t*3]=this.lut[t][0],e[t*3+1]=this.lut[t][1],e[t*3+2]=this.lut[t][2];return e}},Za=class{},Qa=class{handler;_elevationColormap;constructor(e,t){this.handler=e,this.setOptions(t)}setOptions(e){e?.maxSse!=null&&(this.maxSse=e.maxSse),e?.segments!=null&&(this.segments=e.segments),e?.color!=null&&(this.color=e.color),e?.hideUnderground!=null&&(this.hideUnderground=e.hideUnderground),e?.useNormal!=null&&(this.useNormal=e.useNormal),e?.transparent!=null&&(this.transparent=e.transparent),e?.opacity!=null&&(this.opacity=e.opacity),e?.wireframe!=null&&(this.wireframe=e.wireframe),e?.elevationColormap!=null&&(this.elevationColormap=e.elevationColormap)}get maxSse(){return this.handler.getMaxSse()??2}set maxSse(e){this.handler.setMaxSse(e)}get segments(){return this.handler.getSegments()??64}set segments(e){this.handler.setSegments(e)}get color(){return this.handler.getColor()}set color(e){this.handler.setColor(e)}get hideUnderground(){return this.handler.getHideUnderground()??!0}set hideUnderground(e){this.handler.setHideUnderground(e)}get useNormal(){return this.handler.getUseNormal()??!1}set useNormal(e){this.handler.setUseNormal(e)}get transparent(){return this.handler.getTransparent()??!1}set transparent(e){this.handler.setTransparent(e)}get opacity(){return this.handler.getOpacity()??1}set opacity(e){this.handler.setOpacity(e)}get wireframe(){return this.handler.getWireframe()??!1}set wireframe(e){this.handler.setWireframe(e)}get elevationColormap(){return this._elevationColormap}set elevationColormap(e){this._elevationColormap=e,this.handler.setElevationColormap(e)}},$a=class{};e.BaseAbstractedVec3=pe,e.CachedMeshHandleLike=g,e.Color=Za,e.ColorMap=Xa,e.ConstructedPolygonGeometryLike=C,e.ConstructedPolylineGeometryLike=ae,e.ElevationDecoderLike=b,e.EventHandler=se,e.EventManager=l,e.ExtentRadianF32Like=S,e.Globe=Qa,e.IMAGE_EXTENSIONS=oe,e.NamedIndexMap=de,e.Observed=fe,e.Plugin=$a,e.PolygonMaterialLike=x,e.PolylineMaterialLike=ie,e.ReturnedConstructedTerrainMeshLike=te,e.TileXYZLike=h,e.Transaction=o,e.TransactionManager=a,e.TransferableMartiniLike=_,e.TransferablePolygonBatchedFeatureLike=ne,e.TransferablePolylineBatchedFeatureLike=re,e.TransferableRasterDEMDataLike=y,e.TransferableTileLike=m,e.Unimplemented=le,e.Unreachable=ue,e.UpsamplableTerrainGeometryLike=v,e.Vec3Like=ee,e.assertType=u,e.generate_id_from_entity=n,e.generate_id_from_ind_gen=r,e.isEntityEvent=i,e.isNotFalse=p,e.isNotNullish=d,e.isNotUndefined=f,e.setBatchedValuesToBatchedAttribute=ce});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@navaramap/core",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "main": "dist/index.umd.cjs",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "license": "MIT OR Apache-2.0",
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "git+https://github.com/reearth/navara.git",
15
+ "url": "git+https://github.com/maplibre/navara.git",
16
16
  "directory": "web/navara_core"
17
17
  },
18
18
  "publishConfig": {
@@ -537,3 +537,99 @@ it("should keep in-flight add tracking isolated between transaction keys", async
537
537
  expect(aborted).toEqual([1]);
538
538
  releaseAdds();
539
539
  });
540
+
541
+ it("should dispatch the pending stack in the given order across passes", async () => {
542
+ const eventManager = new EventManager();
543
+ const processedIds: number[] = [];
544
+
545
+ // gen doubles as the urgency rank here: lower is more urgent.
546
+ eventManager.pushEvents(
547
+ makeEvent({
548
+ renderable_feature_added: [
549
+ makeRenderableFeatures(1, 3),
550
+ makeRenderableFeatures(1, 2),
551
+ ],
552
+ renderable_feature_removed: [],
553
+ renderable_feature_changed: [],
554
+ }),
555
+ );
556
+ const byUrgency = (
557
+ a: RenderableFeatureAddedEvent,
558
+ b: RenderableFeatureAddedEvent,
559
+ ) => a.gen - b.gen;
560
+
561
+ // Only one slot free: the more urgent of the two goes first even though it
562
+ // was pushed second.
563
+ let slots = 1;
564
+ await eventManager.forEachStackAsync(
565
+ "renderable_feature_added",
566
+ async (event) => {
567
+ processedIds.push(event.gen);
568
+ },
569
+ 10,
570
+ () => slots-- > 0,
571
+ byUrgency,
572
+ );
573
+ expect(processedIds).toEqual([2]);
574
+
575
+ // A more urgent event arriving later overtakes the one left behind.
576
+ eventManager.pushEvents(
577
+ makeEvent({
578
+ renderable_feature_added: [makeRenderableFeatures(1, 1)],
579
+ renderable_feature_removed: [],
580
+ renderable_feature_changed: [],
581
+ }),
582
+ );
583
+ slots = 1;
584
+ await eventManager.forEachStackAsync(
585
+ "renderable_feature_added",
586
+ async (event) => {
587
+ processedIds.push(event.gen);
588
+ },
589
+ 10,
590
+ () => slots-- > 0,
591
+ byUrgency,
592
+ );
593
+ expect(processedIds).toEqual([2, 1]);
594
+ expect(eventManager.stacks.renderable_feature_added).toHaveLength(1);
595
+ });
596
+
597
+ it("should merge newly pushed events into the already ordered stack", async () => {
598
+ const eventManager = new EventManager();
599
+ const processed: number[] = [];
600
+ const byUrgency = (
601
+ a: RenderableFeatureAddedEvent,
602
+ b: RenderableFeatureAddedEvent,
603
+ ) => a.gen - b.gen;
604
+ const push = (...gens: number[]) =>
605
+ eventManager.pushEvents(
606
+ makeEvent({
607
+ renderable_feature_added: gens.map((g) => makeRenderableFeatures(1, g)),
608
+ renderable_feature_removed: [],
609
+ renderable_feature_changed: [],
610
+ }),
611
+ );
612
+ const pass = async (slots: number) => {
613
+ let left = slots;
614
+ await eventManager.forEachStackAsync(
615
+ "renderable_feature_added",
616
+ async (event) => {
617
+ processed.push(event.gen);
618
+ },
619
+ 10,
620
+ () => left-- > 0,
621
+ byUrgency,
622
+ );
623
+ };
624
+
625
+ // Each pass leaves a sorted prefix behind; removals from it and later
626
+ // pushes after it must keep the dispatch order correct across passes.
627
+ push(5, 3, 8);
628
+ await pass(1);
629
+ push(4, 1);
630
+ await pass(2);
631
+ push(6, 2);
632
+ await pass(10);
633
+ expect(processed).toEqual([3, 1, 4, 2, 5, 6, 8]);
634
+ expect(eventManager.stacks.renderable_feature_added).toHaveLength(0);
635
+ });
@@ -32,6 +32,10 @@ type TransactionProcessOption<
32
32
  add: {
33
33
  key: AddKey;
34
34
  max?: number;
35
+ /** Dispatch order for the pending stack. Events a `shouldProcess` gate
36
+ * leaves behind are re-sorted against newer ones every pass, so this turns
37
+ * the FIFO stack into a priority queue (stable: equal keys stay FIFO). */
38
+ order?: (a: GetJsEventValue<AddKey>, b: GetJsEventValue<AddKey>) => number;
35
39
  };
36
40
  remove: {
37
41
  key: RemoveKey;
@@ -83,6 +87,7 @@ export class EventManager {
83
87
  data_requester_removed: [],
84
88
  mesh_added: [],
85
89
  mesh_updated: [],
90
+ mesh_geometry_replaced: [],
86
91
  mesh_removed: [],
87
92
  object_transform_updated: [],
88
93
  renderable_feature_added: [],
@@ -91,6 +96,7 @@ export class EventManager {
91
96
  texture_fragment_removed: [],
92
97
  texture_fragment_requested: [],
93
98
  update_sample_terrain_height: [],
99
+ update_terrain_height_range: [],
94
100
  worker_task_delegated: [],
95
101
  worker_task_removed: [],
96
102
  hillshade_backfilled: [],
@@ -100,6 +106,8 @@ export class EventManager {
100
106
  // matching remove arrives while they are still pending. Keyed by transaction
101
107
  // so one transaction's remove phase cannot wipe another's tracking.
102
108
  addedEventIds = new Map<string, Set<unknown>>();
109
+ // Length of each stack's already-sorted prefix (see `sortPending`).
110
+ private sortedLengths: Partial<Record<JsEventsKey, number>> = {};
103
111
  private transactionManager = new TransactionManager();
104
112
 
105
113
  needsUpdate() {
@@ -143,6 +151,42 @@ export class EventManager {
143
151
 
144
152
  // Remove processed events
145
153
  this.stacks[key].splice(0, idx);
154
+ const sorted = this.sortedLengths[key];
155
+ if (sorted !== undefined) {
156
+ this.sortedLengths[key] = Math.max(0, sorted - idx);
157
+ }
158
+ }
159
+
160
+ /** Order the stack for dispatch. Pushes only append, so only the events
161
+ * added since the last pass are sorted and merged into the already sorted
162
+ * prefix (the prefix wins ties, keeping equal keys FIFO). */
163
+ private sortPending<Key extends JsEventsKey>(
164
+ key: Key,
165
+ order: (a: GetJsEventValue<Key>, b: GetJsEventValue<Key>) => number,
166
+ ) {
167
+ const stack = this.stacks[key] as GetJsEventValue<Key>[];
168
+ const sortedLength = Math.min(this.sortedLengths[key] ?? 0, stack.length);
169
+ if (sortedLength < stack.length) {
170
+ const added = stack.splice(sortedLength).sort(order);
171
+ const merged: GetJsEventValue<Key>[] = [];
172
+ let i = 0;
173
+ let j = 0;
174
+ while (i < stack.length && j < added.length) {
175
+ merged.push(order(stack[i], added[j]) <= 0 ? stack[i++] : added[j++]);
176
+ }
177
+ for (; i < stack.length; i++) merged.push(stack[i]);
178
+ for (; j < added.length; j++) merged.push(added[j]);
179
+ this.stacks[key] = merged as EventsStacks[Key];
180
+ }
181
+ this.sortedLengths[key] = this.stacks[key].length;
182
+ }
183
+
184
+ private removeAt(key: JsEventsKey, index: number) {
185
+ this.stacks[key].splice(index, 1);
186
+ const sorted = this.sortedLengths[key];
187
+ if (sorted !== undefined && index < sorted) {
188
+ this.sortedLengths[key] = sorted - 1;
189
+ }
146
190
  }
147
191
 
148
192
  async forEachStackAsync<Key extends JsEventsKey>(
@@ -150,9 +194,14 @@ export class EventManager {
150
194
  cb: (value: GetJsEventValue<Key>) => Promise<void>,
151
195
  max = 100,
152
196
  shouldProcess?: (value: GetJsEventValue<Key>) => boolean,
197
+ order?: (a: GetJsEventValue<Key>, b: GetJsEventValue<Key>) => number,
153
198
  ) {
154
199
  const promises = [];
155
200
 
201
+ if (order) {
202
+ this.sortPending(key, order);
203
+ }
204
+
156
205
  let idx = 0;
157
206
  const removedIndices = [];
158
207
  for (const value of this.stacks[key]) {
@@ -181,7 +230,7 @@ export class EventManager {
181
230
  // Remove processed events
182
231
  const i = idx - offset;
183
232
  removedEvs.push(this.stacks[key][i]);
184
- this.stacks[key].splice(i, 1);
233
+ this.removeAt(key, i);
185
234
  offset++;
186
235
  }
187
236
 
@@ -273,7 +322,7 @@ export class EventManager {
273
322
  const sortedIndices = [...removedIndices].sort((a, b) => b - a);
274
323
  for (const idx of sortedIndices) {
275
324
  maybeFree(this.stacks[key][idx]);
276
- this.stacks[key].splice(idx, 1);
325
+ this.removeAt(key, idx);
277
326
  }
278
327
  }
279
328
 
@@ -323,6 +372,7 @@ export class EventManager {
323
372
  shouldProcess
324
373
  ? (event) => shouldProcess({ type: "add", event })
325
374
  : undefined,
375
+ options.add.order,
326
376
  ),
327
377
  )
328
378
  .then(() => {
@@ -13,10 +13,15 @@ export class TransferableTileLike {
13
13
  min_height: number;
14
14
 
15
15
  constructor(t: TransferableTile) {
16
- this.cached_mesh_handle = t.cached_mesh_handle
17
- ? new CachedMeshHandleLike(t.cached_mesh_handle)
16
+ // Both getters hand out owned wasm objects: read each once, copy, free.
17
+ const cachedMeshHandle = t.cached_mesh_handle;
18
+ this.cached_mesh_handle = cachedMeshHandle
19
+ ? new CachedMeshHandleLike(cachedMeshHandle)
18
20
  : undefined;
19
- this.coords = new TileXYZLike(t.coords);
21
+ cachedMeshHandle?.free();
22
+ const coords = t.coords;
23
+ this.coords = new TileXYZLike(coords);
24
+ coords.free();
20
25
  this.max_height = t.max_height;
21
26
  this.min_height = t.min_height;
22
27
  }
@@ -41,12 +46,16 @@ export class CachedMeshHandleLike {
41
46
  uvs: number;
42
47
  indices: number;
43
48
  heights?: number | undefined;
49
+ normals?: number | undefined;
50
+ watermask?: number | undefined;
44
51
 
45
52
  constructor(t: CachedMeshHandle) {
46
53
  this.vertices = t.vertices;
47
54
  this.uvs = t.uvs;
48
55
  this.indices = t.indices;
49
56
  this.heights = t.heights;
57
+ this.normals = t.normals;
58
+ this.watermask = t.watermask;
50
59
  }
51
60
 
52
61
  free(): void {}
@@ -11,6 +11,12 @@ export class TransferablePolylineBatchedFeatureLike implements RemoveFreeRecursi
11
11
  points_sizes: Uint32Array;
12
12
  batch_ids: Uint32Array;
13
13
  batch_indices: Uint32Array;
14
+ /**
15
+ * Per polyline, whether it is a polygon ring (1) or an open line (0). A
16
+ * ring's repeated first vertex is a seam the geometry joins; an open line
17
+ * keeps its end caps even when its endpoints coincide.
18
+ */
19
+ ring_flags: Uint8Array;
14
20
  crs: CRS;
15
21
  length: number;
16
22
 
@@ -19,6 +25,7 @@ export class TransferablePolylineBatchedFeatureLike implements RemoveFreeRecursi
19
25
  this.points_sizes = t.transferPointsSizes();
20
26
  this.batch_ids = t.transferBatchIds();
21
27
  this.batch_indices = t.transferBatchIndices();
28
+ this.ring_flags = t.transferRingFlags();
22
29
  this.crs = t.crs();
23
30
  this.length = t.length();
24
31
  }
@@ -27,6 +34,7 @@ export class TransferablePolylineBatchedFeatureLike implements RemoveFreeRecursi
27
34
  setPointsSizes(_byte_length: number, _f: () => void): void {}
28
35
  setBatchIds(_byte_length: number, _f: () => void): void {}
29
36
  setBatchIndices(_length: number, _f: () => void) {}
37
+ setRingFlags(_byte_length: number, _f: () => void): void {}
30
38
 
31
39
  transferPoints(): Float64Array {
32
40
  throw new Error();
@@ -40,4 +48,7 @@ export class TransferablePolylineBatchedFeatureLike implements RemoveFreeRecursi
40
48
  transferBatchIndices(): Uint32Array {
41
49
  throw new Error();
42
50
  }
51
+ transferRingFlags(): Uint8Array {
52
+ throw new Error();
53
+ }
43
54
  }