@navaramap/core 0.0.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 +8 -0
- package/README.md +3 -0
- package/dist/index.d.ts +605 -0
- package/dist/index.js +3042 -0
- package/dist/index.umd.cjs +1 -0
- package/package.json +38 -0
- package/src/abstracts/index.ts +1 -0
- package/src/abstracts/vec3.ts +15 -0
- package/src/assertions.ts +15 -0
- package/src/batch/attribute.test.ts +20 -0
- package/src/batch/attribute.ts +14 -0
- package/src/batch/index.ts +1 -0
- package/src/color/Color.ts +10 -0
- package/src/color/ColorMap.ts +86 -0
- package/src/color/index.ts +3 -0
- package/src/color/types.ts +4 -0
- package/src/constants/image.ts +1 -0
- package/src/constants/index.ts +1 -0
- package/src/error.ts +11 -0
- package/src/event/EventManager.test.ts +539 -0
- package/src/event/EventManager.ts +387 -0
- package/src/event/TransactionManager.test.ts +126 -0
- package/src/event/TransactionManager.ts +78 -0
- package/src/event/index.ts +2 -0
- package/src/event/mock.ts +36 -0
- package/src/eventHandler.ts +52 -0
- package/src/globe/Globe.ts +156 -0
- package/src/globe/index.ts +1 -0
- package/src/id.ts +9 -0
- package/src/index.ts +15 -0
- package/src/namedIndexMap.test.ts +268 -0
- package/src/namedIndexMap.ts +50 -0
- package/src/observed.ts +30 -0
- package/src/plugin.ts +15 -0
- package/src/time.ts +3 -0
- package/src/types/buffer.ts +4 -0
- package/src/types/camera.ts +16 -0
- package/src/types/cameraFrustum.ts +5 -0
- package/src/types/feature.ts +1 -0
- package/src/types/index.ts +13 -0
- package/src/types/layer.ts +1 -0
- package/src/types/plane.ts +5 -0
- package/src/types/ray.ts +5 -0
- package/src/types/tile.ts +1 -0
- package/src/types/transform.ts +5 -0
- package/src/types/unit.ts +7 -0
- package/src/types/utils.ts +20 -0
- package/src/types/vec.ts +9 -0
- package/src/types/window.ts +5 -0
- package/src/utils/ExtentRadianF32Like.ts +17 -0
- package/src/utils/FloatAttributeLike.ts +17 -0
- package/src/utils/ReturnedConstructedTerrainMeshLike.ts +92 -0
- package/src/utils/TransferableMartiniLike.ts +21 -0
- package/src/utils/TransferableRasterDEMDataLike.ts +36 -0
- package/src/utils/TransferableTileLike.ts +53 -0
- package/src/utils/UpsamplableTerrainGeometryLike.ts +26 -0
- package/src/utils/Vec3Like.ts +15 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/polygon/ConstructedPolygonGeometryLike.ts +70 -0
- package/src/utils/polygon/PolygonMaterialLike.ts +37 -0
- package/src/utils/polygon/TransferablePolygonBatchedFeatureLike.ts +73 -0
- package/src/utils/polygon/index.ts +3 -0
- package/src/utils/polyline/ConstructedPolylineGeometryLike.ts +77 -0
- package/src/utils/polyline/PolylineMaterialLike.ts +31 -0
- package/src/utils/polyline/TransferablePolylineBatchedFeatureLike.ts +43 -0
- package/src/utils/polyline/index.ts +3 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +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`${e.ind}_${e.gen}`}function r(e){return!!e&&typeof e==`object`&&`ind`in e&&`gen`in e}var i=class{record={};getOrInsert(e){return this.record[e]||(this.record[e]=new a(e)),this.record[e]}},a=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}},o=e=>{e&&`free`in e&&e.free instanceof Function&&e.free()},s=e=>{let{event:t}=e;if(r(t))return n(t)},c=class{stacks={camera_transform_updated:[],camera_frustum_updated:[],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 i;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),o(i),r++}this.stacks[e].splice(0,r)}async forEachStackAsync(e,t,n=100,r){let i=[],a=0,s=[];for(let o of this.stacks[e]){if(a===n)break;let e=o;if(r&&!r(e)){a++;continue}i.push(t(e)),s.push(a),a++}let c=[],l=0;for(let t of s){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)o(e)}removeDuplicatedTransactionEvents(e){let t=new Map,i=e.change?new Map:null;this.stacks[e.add.key].forEach((e,i)=>{if(r(e)){let r=n(e);t.set(r,i)}}),i&&e.change&&this.stacks[e.change.key].forEach((e,t)=>{if(r(e)){let r=n(e);i.set(r,t)}});let a=new Set,o=new Set,s=new Set;this.stacks[e.remove.key].forEach((c,l)=>{if(!r(c))return;let u=n(c),d=t.get(u),f=!1;if(d!==void 0&&(a.add(d),f=!0),i&&e.change){let e=i.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)o(this.stacks[e][t]),this.stacks[e].splice(t,1)}processTransactionEvents(e,t,n,r){let{shouldProcess:i,generateEventId:a=s,onAbort:o}=r??{};this.removeDuplicatedTransactionEvents(t);let c=this.addedEventIds.get(e)??new Set;this.addedEventIds.set(e,c);let l=this.transactionManager.getOrInsert(e).then(()=>this.forEachStackAsync(t.add.key,e=>(o&&c.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&&c.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&&c.size)for(let n of this.stacks[t.remove.key]){if(!n)continue;let t=n,r=a({type:`remove`,event:t});if(r&&c.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)}c.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 l(e){}function u(e){return e!=null}function d(e){return e!==void 0}function f(e){return e!==!1}var p=class{cached_mesh_handle;coords;max_height;min_height;constructor(e){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}free(){}},m=class{x;y;z;constructor(e){this.x=e.x,this.y=e.y,this.z=e.z}},h=class{vertices;uvs;indices;heights;constructor(e){this.vertices=e.vertices,this.uvs=e.uvs,this.indices=e.indices,this.heights=e.heights}free(){}},g=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)}},_=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}},v=class{decoder;constructor(e){this.decoder=new y(e)}},y=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}},b=class{x;y;z;constructor(e){this.x=e.x,this.y=e.y,this.z=e.z}},ee=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 b(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}},te=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_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 b(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_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())}},w=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()}},ne=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(){}},re=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()}},ie=[`png`,`webp`],ae=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())}},oe=(e,t,n)=>{let r=t.length;for(let i=0;i<r;i++)n[i]=e[t[i]]},se=class extends Error{constructor(e){super(e??`Unimplemented`)}},ce=class extends Error{constructor(e){super(e??`Unreachable`)}},le=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}`)}},ue=class extends ae{_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)}},de=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 fe(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function pe(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function me(e){let t,n,r;e.length===2?(t=e===fe||e===pe?e:he,n=e,r=e):(t=fe,n=(t,n)=>fe(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 he(){return 0}function ge(e){return e===null?NaN:+e}var _e=me(fe),ve=_e.right;_e.left,me(ge).center;var ye=Math.sqrt(50),be=Math.sqrt(10),xe=Math.sqrt(2);function T(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=ye?10:a>=be?5:a>=xe?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?T(e,t,n*2):[s,c,l]}function Se(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?T(t,e,n):T(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 Ce(e,t,n){return t=+t,e=+e,n=+n,T(e,t,n)[2]}function we(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Ce(t,e,n):Ce(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}var Te={value:()=>{}};function Ee(){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 De(n)}function De(e){this._=e}function Oe(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}})}De.prototype=Ee.prototype={constructor:De,on:function(e,t){var n=this._,r=Oe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=ke(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]=Ae(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Ae(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 De(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 ke(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Ae(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Te,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var je={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 Me(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),je.hasOwnProperty(t)?{space:je[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=Me(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 D(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 D(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 D(r,this._parents)}function tt(e){return Array(e.length)}function nt(){return new D(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 D(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 D(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 D(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 D(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=Me(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??``)):E(this.node(),e)}function E(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(){this.textContent=e.apply(this,arguments)??``}}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(){this.innerHTML=e.apply(this,arguments)??``}}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 D(e,t){this._groups=e,this._parents=t}function O(){return new D([[document.documentElement]],Tn)}function En(){return this}D.prototype=O.prototype={constructor:D,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 k(){}var A=.7,kn=1/A,j=`\\s*([+-]?\\d+)\\s*`,M=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,N=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,An=/^#([0-9a-f]{3,8})$/,jn=RegExp(`^rgb\\(${j},${j},${j}\\)$`),Mn=RegExp(`^rgb\\(${N},${N},${N}\\)$`),Nn=RegExp(`^rgba\\(${j},${j},${j},${M}\\)$`),Pn=RegExp(`^rgba\\(${N},${N},${N},${M}\\)$`),Fn=RegExp(`^hsl\\(${M},${N},${N}\\)$`),In=RegExp(`^hsla\\(${M},${N},${N},${M}\\)$`),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(k,P,{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 Zn(this).formatHsl()}function Vn(){return this.rgb().formatRgb()}function P(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 F(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 F(t[1],t[2],t[3],1):(t=Mn.exec(e))?new F(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))?Xn(t[1],t[2]/100,t[3]/100,1):(t=In.exec(e))?Xn(t[1],t[2]/100,t[3]/100,t[4]):Ln.hasOwnProperty(e)?Hn(Ln[e]):e===`transparent`?new F(NaN,NaN,NaN,0):null}function Hn(e){return new F(e>>16&255,e>>8&255,e&255,1)}function Un(e,t,n,r){return r<=0&&(e=t=n=NaN),new F(e,t,n,r)}function Wn(e){return e instanceof k||(e=P(e)),e?(e=e.rgb(),new F(e.r,e.g,e.b,e.opacity)):new F}function Gn(e,t,n,r){return arguments.length===1?Wn(e):new F(e,t,n,r??1)}function F(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Dn(F,Gn,On(k,{brighter(e){return e=e==null?kn:kn**+e,new F(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?A:A**+e,new F(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new F(I(this.r),I(this.g),I(this.b),Yn(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:Kn,formatHex:Kn,formatHex8:qn,formatRgb:Jn,toString:Jn}));function Kn(){return`#${L(this.r)}${L(this.g)}${L(this.b)}`}function qn(){return`#${L(this.r)}${L(this.g)}${L(this.b)}${L((isNaN(this.opacity)?1:this.opacity)*255)}`}function Jn(){let e=Yn(this.opacity);return`${e===1?`rgb(`:`rgba(`}${I(this.r)}, ${I(this.g)}, ${I(this.b)}${e===1?`)`:`, ${e})`}`}function Yn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function I(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function L(e){return e=I(e),(e<16?`0`:``)+e.toString(16)}function Xn(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new R(e,t,n,r)}function Zn(e){if(e instanceof R)return new R(e.h,e.s,e.l,e.opacity);if(e instanceof k||(e=P(e)),!e)return new R;if(e instanceof R)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 R(o,s,c,e.opacity)}function Qn(e,t,n,r){return arguments.length===1?Zn(e):new R(e,t,n,r??1)}function R(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Dn(R,Qn,On(k,{brighter(e){return e=e==null?kn:kn**+e,new R(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?A:A**+e,new R(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 F(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 R($n(this.h),z(this.s),z(this.l),Yn(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=Yn(this.opacity);return`${e===1?`hsl(`:`hsla(`}${$n(this.h)}, ${z(this.s)*100}%, ${z(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function $n(e){return e=(e||0)%360,e<0?e+360:e}function z(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 B=(function e(t){var n=ir(t);function r(e,t){var r=n((e=Gn(e)).r,(t=Gn(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 or(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 sr(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cr(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]=gr(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 lr(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 ur(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]=gr(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var dr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,fr=new RegExp(dr.source,`g`);function pr(e){return function(){return e}}function mr(e){return function(t){return e(t)+``}}function hr(e,t){var n=dr.lastIndex=fr.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=dr.exec(e))&&(i=fr.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=fr.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?mr(c[0].x):pr(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 gr(e,t){var n=typeof t,r;return t==null||n===`boolean`?tr(t):(n===`number`?V:n===`string`?(r=P(t))?(t=r,B):hr:t instanceof P?B:t instanceof Date?lr:sr(t)?or:Array.isArray(t)?cr:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?ur:V)(e,t)}function _r(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var vr=180/Math.PI,yr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function br(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)*vr,skewX:Math.atan(c)*vr,scaleX:o,scaleY:s}}var xr;function Sr(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?yr:br(t.a,t.b,t.c,t.d,t.e,t.f)}function Cr(e){return e==null||(xr||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),xr.setAttribute(`transform`,e),!(e=xr.transform.baseVal.consolidate()))?yr:(e=e.matrix,br(e.a,e.b,e.c,e.d,e.e,e.f))}function wr(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 Tr=wr(Sr,`px, `,`px)`,`deg)`),Er=wr(Cr,`, `,`)`,`)`);function Dr(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e(r/(t-1));return n}var H=0,Or=0,kr=0,Ar=1e3,jr,U,Mr=0,W=0,Nr=0,G=typeof performance==`object`&&performance.now?performance:Date,Pr=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Fr(){return W||=(Pr(Ir),G.now()+Nr)}function Ir(){W=0}function Lr(){this._call=this._time=this._next=null}Lr.prototype=Rr.prototype={constructor:Lr,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Fr():+n)+(t==null?0:+t),!this._next&&U!==this&&(U?U._next=this:jr=this,U=this),this._call=e,this._time=n,Ur()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ur())}};function Rr(e,t,n){var r=new Lr;return r.restart(e,t,n),r}function zr(){Fr(),++H;for(var e=jr,t;e;)(t=W-e._time)>=0&&e._call.call(void 0,t),e=e._next;--H}function Br(){W=(Mr=G.now())+Nr,H=Or=0;try{zr()}finally{H=0,Hr(),W=0}}function Vr(){var e=G.now(),t=e-Mr;t>Ar&&(Nr-=t,Mr=e)}function Hr(){for(var e,t=jr,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:jr=n);U=e,Ur(r)}function Ur(e){H||(Or&&=clearTimeout(Or),e-W>24?(e<1/0&&(Or=setTimeout(Br,e-G.now()-Nr)),kr&&=clearInterval(kr)):(kr||=(Mr=G.now(),setInterval(Vr,Ar)),H=1,Pr(Br)))}function Wr(e,t,n){var r=new Lr;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Gr=Ee(`start`,`end`,`cancel`,`interrupt`),Kr=[];function qr(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Yr(e,n,{name:t,index:r,group:i,on:Gr,tween:Kr,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Jr(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 Yr(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Rr(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 Wr(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(Wr(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 Xr(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 Zr(e){return this.each(function(){Xr(this,e)})}function Qr(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 $r(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 ei(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?Qr:$r)(n,e,t))}function ti(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 ni(e,t){var n;return(typeof t==`number`?V:t instanceof P?B:(n=P(t))?(t=n,B):hr)(e,t)}function ri(e){return function(){this.removeAttribute(e)}}function ii(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ai(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 oi(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 si(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 ci(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 li(e,t){var n=Me(e),r=n===`transform`?Er:ni;return this.attrTween(e,typeof t==`function`?(n.local?ci:si)(n,r,ti(this,`attr.`+e,t)):t==null?(n.local?ii:ri)(n):(n.local?oi:ai)(n,r,t))}function ui(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function di(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function fi(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 pi(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&ui(e,i)),n}return i._value=t,i}function mi(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=Me(e);return this.tween(n,(r.local?fi:pi)(r,t))}function hi(e,t){return function(){Jr(this,e).delay=+t.apply(this,arguments)}}function gi(e,t){return t=+t,function(){Jr(this,e).delay=t}}function _i(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?hi:gi)(t,e)):q(this.node(),t).delay}function vi(e,t){return function(){K(this,e).duration=+t.apply(this,arguments)}}function yi(e,t){return t=+t,function(){K(this,e).duration=t}}function bi(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?vi:yi)(t,e)):q(this.node(),t).duration}function xi(e,t){if(typeof t!=`function`)throw Error();return function(){K(this,e).ease=t}}function Si(e){var t=this._id;return arguments.length?this.each(xi(t,e)):q(this.node(),t).ease}function Ci(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();K(this,e).ease=n}}function wi(e){if(typeof e!=`function`)throw Error();return this.each(Ci(this._id,e))}function Ti(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 Ei(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 Di(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 Oi(e,t,n){var r,i,a=Di(t)?Jr:K;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function ki(e,t){var n=this._id;return arguments.length<2?q(this.node(),n).on.on(e):this.each(Oi(n,e,t))}function Ai(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function ji(){return this.on(`end.remove`,Ai(this._id))}function Mi(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,qr(l[f],t,n,f,l,q(u,n)));return new J(a,this._parents,t,n)}function Ni(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])&&qr(p,t,n,h,f,m);a.push(f),o.push(u)}return new J(a,o,t,n)}var Pi=O.prototype.constructor;function Fi(){return new Pi(this._groups,this._parents)}function Ii(e,t){var n,r,i;return function(){var a=E(this,e),o=(this.style.removeProperty(e),E(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Li(e){return function(){this.style.removeProperty(e)}}function Ri(e,t,n){var r,i=n+``,a;return function(){var o=E(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function zi(e,t,n){var r,i,a;return function(){var o=E(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),E(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Bi(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||=Li(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Vi(e,t,n){var r=(e+=``)==`transform`?Tr:ni;return t==null?this.styleTween(e,Ii(e,r)).on(`end.style.`+e,Li(e)):typeof t==`function`?this.styleTween(e,zi(e,r,ti(this,`style.`+e,t))).each(Bi(this._id,e)):this.styleTween(e,Ri(e,r,t),n).on(`end.style.`+e,null)}function Hi(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Ui(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Hi(e,a,n)),r}return a._value=t,a}function Wi(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,Ui(e,t,n??``))}function Gi(e){return function(){this.textContent=e}}function Ki(e){return function(){this.textContent=e(this)??``}}function qi(e){return this.tween(`text`,typeof e==`function`?Ki(ti(this,`text`,e)):Gi(e==null?``:e+``))}function Ji(e){return function(t){this.textContent=e.call(this,t)}}function Yi(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Ji(r)),t}return r._value=e,r}function Xi(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,Yi(e))}function Zi(){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);qr(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 Qi(){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 $i=0;function J(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ea(e){return O().transition(e)}function ta(){return++$i}var Y=O.prototype;J.prototype=ea.prototype={constructor:J,select:Mi,selectAll:Ni,selectChild:Y.selectChild,selectChildren:Y.selectChildren,filter:Ti,merge:Ei,selection:Fi,transition:Zi,call:Y.call,nodes:Y.nodes,node:Y.node,size:Y.size,empty:Y.empty,each:Y.each,on:ki,attr:li,attrTween:mi,style:Vi,styleTween:Wi,text:qi,textTween:Xi,remove:ji,tween:ei,delay:_i,duration:bi,ease:Si,easeVarying:wi,end:Qi,[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=Fr(),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])&&qr(c,e,t,l,o,n||ia(c,t));return new J(r,this._parents,e,t)}O.prototype.interrupt=Zr,O.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((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`))<0)return null;var n,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);break}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 e+``;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){e=ha(e);var l=e.fill,u=e.align,d=e.sign,f=e.symbol,p=e.zero,m=e.width,h=e.comma,g=e.precision,_=e.trim,v=e.type;v===`n`?(h=!0,v=`g`):xa[v]||(g===void 0&&(g=12),_=!0,v=`g`),(p||l===`0`&&u===`=`)&&(p=!0,l=`0`,u=`=`);var y=f===`$`?n:f===`#`&&/[boxX]/.test(v)?`0`+v.toLowerCase():``,b=f===`$`?r:/[%p]/.test(v)?o:``,ee=xa[v],te=/[defgprs%]/.test(v);g=g===void 0?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g));function x(e){var n=y,r=b,o,f,x;if(v===`c`)r=ee(e)+r,e=``;else{e=+e;var S=e<0||1/e<0;if(e=isNaN(e)?c:ee(Math.abs(e),g),_&&(e=_a(e)),S&&+e==0&&d!==`+`&&(S=!1),n=(S?d===`(`?d:s:d===`-`||d===`(`?``:d)+n,r=(v===`s`?wa[8+va/3]:``)+r+(S&&d===`(`?`)`:``),te){for(o=-1,f=e.length;++o<f;)if(x=e.charCodeAt(o),48>x||x>57){r=(x===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}h&&!p&&(e=t(e,1/0));var C=n.length+e.length+r.length,w=C<m?Array(m-C+1).join(l):``;switch(h&&p&&(e=t(w+e,w.length?m-r.length:1/0),w=``),u){case`<`:e=n+e+r+w;break;case`=`:e=n+w+e+r;break;case`^`:e=w.slice(0,C=w.length>>1)+n+e+r+w.slice(C);break;default:e=w+n+e+r;break}return a(e)}return x.toString=function(){return e+``},x}function u(e,t){var n=l((e=ha(e),e.type=`f`,e)),r=Math.max(-8,Math.min(8,Math.floor(X(t)/3)))*3,i=10**-r,a=wa[8+r/3];return function(e){return n(i*e)+a}}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);break}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=ve(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=gr,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=_r,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=we(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);break}return Da(r)}function Ga(e){var t=e.domain;return e.ticks=function(e){var n=t();return Se(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=Ce(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=!0,Xa=`Invariant failed`;function $(e,t){if(!e){if(Ya)throw Error(Xa);var n=typeof t==`function`?t():t,r=n?`${Xa}: ${n}`:Xa;throw Error(r)}}var Za=class{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(Dr(gr(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=Gn(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}},Qa=class{},$a=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)}},eo=class{};e.BaseAbstractedVec3=de,e.CachedMeshHandleLike=h,e.Color=Qa,e.ColorMap=Za,e.ConstructedPolygonGeometryLike=C,e.ConstructedPolylineGeometryLike=re,e.ElevationDecoderLike=y,e.EventHandler=ae,e.EventManager=c,e.ExtentRadianF32Like=S,e.Globe=$a,e.IMAGE_EXTENSIONS=ie,e.NamedIndexMap=le,e.Observed=ue,e.Plugin=eo,e.PolygonMaterialLike=x,e.PolylineMaterialLike=ne,e.ReturnedConstructedTerrainMeshLike=ee,e.TileXYZLike=m,e.Transaction=a,e.TransactionManager=i,e.TransferableMartiniLike=g,e.TransferablePolygonBatchedFeatureLike=te,e.TransferablePolylineBatchedFeatureLike=w,e.TransferableRasterDEMDataLike=v,e.TransferableTileLike=p,e.Unimplemented=se,e.Unreachable=ce,e.UpsamplableTerrainGeometryLike=_,e.Vec3Like=b,e.assertType=l,e.generate_id_from_entity=n,e.isEntityEvent=r,e.isNotFalse=f,e.isNotNullish=u,e.isNotUndefined=d,e.setBatchedValuesToBatchedAttribute=oe});
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@navaramap/core",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"main": "dist/index.umd.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"src",
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT OR Apache-2.0",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/eukarya-inc/navara.git",
|
|
16
|
+
"directory": "web/navara_core"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"d3": "7.9.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/d3": "7.4.3"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"type-check": "tsc && tsc -p tsconfig.node.json",
|
|
29
|
+
"build": "pnpm type-check && vite build --watch=false",
|
|
30
|
+
"build:dev": "vite build --mode development",
|
|
31
|
+
"build:dev:watch": "pnpm build:dev --watch",
|
|
32
|
+
"test": "vitest --passWithNoTests --watch=false",
|
|
33
|
+
"lint": "eslint . --fix",
|
|
34
|
+
"lint:check": "eslint .",
|
|
35
|
+
"format": "prettier --write --ignore-path ../../.gitignore --ignore-path ../../.prettierignore .",
|
|
36
|
+
"format:check": "prettier --check --ignore-path ../../.gitignore --ignore-path ../../.prettierignore ."
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./vec3";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Vec3 } from "@navaramap/engine";
|
|
2
|
+
|
|
3
|
+
export abstract class BaseAbstractedVec3 {
|
|
4
|
+
value: Vec3;
|
|
5
|
+
|
|
6
|
+
constructor(x: number, y: number, z: number) {
|
|
7
|
+
this.value = new Vec3(x, y, z);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
copy(x: number, y: number, z: number) {
|
|
11
|
+
this.value.x = x;
|
|
12
|
+
this.value.y = y;
|
|
13
|
+
this.value.z = z;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Ref: https://github.com/takram-design-engineering/geovanni/blob/ee91f675ba2558ee3099f635dfa30bbe3adfe103/libs/core/src/assertions.ts
|
|
2
|
+
|
|
3
|
+
export function assertType<T>(_value: unknown): asserts _value is T {}
|
|
4
|
+
|
|
5
|
+
export function isNotNullish<T>(value: T | null | undefined): value is T {
|
|
6
|
+
return value != null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function isNotUndefined<T>(value: T | undefined): value is T {
|
|
10
|
+
return value !== undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isNotFalse<T>(value: T | false): value is T {
|
|
14
|
+
return value !== false;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { setBatchedValuesToBatchedAttribute } from "./attribute";
|
|
4
|
+
|
|
5
|
+
it("should set values to attribute by batch id", () => {
|
|
6
|
+
let batchIds = new Uint32Array([0, 1, 2, 3, 4]);
|
|
7
|
+
let colors = new Float32Array([0, 1, 2, 3, 4]);
|
|
8
|
+
const values = new Float32Array([5, 6, 7, 8, 9]);
|
|
9
|
+
|
|
10
|
+
setBatchedValuesToBatchedAttribute(values, batchIds, colors);
|
|
11
|
+
|
|
12
|
+
expect(colors).toEqual(values);
|
|
13
|
+
|
|
14
|
+
batchIds = batchIds.reverse();
|
|
15
|
+
colors = new Float32Array([0, 1, 2, 3, 4]);
|
|
16
|
+
|
|
17
|
+
setBatchedValuesToBatchedAttribute(values, batchIds, colors);
|
|
18
|
+
|
|
19
|
+
expect(colors).toEqual(values.reverse());
|
|
20
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TypedArrayLike } from "../types";
|
|
2
|
+
|
|
3
|
+
export const setBatchedValuesToBatchedAttribute = (
|
|
4
|
+
values: TypedArrayLike,
|
|
5
|
+
batchIds: TypedArrayLike,
|
|
6
|
+
attr: TypedArrayLike,
|
|
7
|
+
) => {
|
|
8
|
+
const len = batchIds.length;
|
|
9
|
+
for (let i = 0; i < len; i++) {
|
|
10
|
+
const batchId = batchIds[i];
|
|
11
|
+
const value = values[batchId];
|
|
12
|
+
attr[i] = value;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./attribute";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export abstract class Color {
|
|
2
|
+
abstract setRGB(r: number, g: number, b: number): this;
|
|
3
|
+
abstract setHex(hex: number): this;
|
|
4
|
+
abstract setStyle(style: string): this;
|
|
5
|
+
abstract copy(color: this): this;
|
|
6
|
+
abstract clone(): this;
|
|
7
|
+
abstract srgb(): this;
|
|
8
|
+
abstract toArray(): [r: number, g: number, b: number];
|
|
9
|
+
abstract toHex(): number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { interpolate, quantize, rgb, scaleLinear, type ScaleLinear } from "d3";
|
|
2
|
+
import invariant from "tiny-invariant";
|
|
3
|
+
|
|
4
|
+
import { type ColorTuple, type LUT } from "./types";
|
|
5
|
+
|
|
6
|
+
export type ColorMapType = "sequential" | "diverging";
|
|
7
|
+
|
|
8
|
+
// TODO: Handle the color calculation in Rust by https://github.com/Ogeon/palette.
|
|
9
|
+
// Ref: https://github.com/eukarya-inc/PLATEAU-VIEW/blob/26c98fa36e6cfe5776c04d1d2cbf77cc69eb264d/extension/src/prototypes/color-maps/ColorMap.ts
|
|
10
|
+
export class ColorMap<T extends ColorMapType = ColorMapType> {
|
|
11
|
+
lut: ColorTuple[];
|
|
12
|
+
constructor(
|
|
13
|
+
readonly type: T,
|
|
14
|
+
readonly name: string,
|
|
15
|
+
lut: LUT,
|
|
16
|
+
) {
|
|
17
|
+
invariant(lut.length > 1);
|
|
18
|
+
this.lut = lut.map(
|
|
19
|
+
// Color might be converted to linear color space, so make sure SRGB is used.
|
|
20
|
+
(color) => (Array.isArray(color) ? color : color.srgb().toArray()),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#linear?: ScaleLinear<ColorTuple, ColorTuple> | undefined;
|
|
25
|
+
linear(value: number): ColorTuple {
|
|
26
|
+
this.buildLinear();
|
|
27
|
+
invariant(this.#linear);
|
|
28
|
+
|
|
29
|
+
const result = this.#linear(value);
|
|
30
|
+
invariant(result != null);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
buildLinear() {
|
|
35
|
+
if (this.#linear != null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.#linear = scaleLinear<ColorTuple>()
|
|
39
|
+
.domain(quantize(interpolate(0, 1), this.lut.length))
|
|
40
|
+
.range(this.lut)
|
|
41
|
+
.clamp(true);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get count(): number {
|
|
45
|
+
return this.lut.length;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ticks(range: [min: number, max: number], count: number) {
|
|
49
|
+
return scaleLinear<ColorTuple>().domain(range).ticks(count);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
quantize(count: number): ColorTuple[] {
|
|
53
|
+
invariant(count > 1);
|
|
54
|
+
return [...Array(count)].map((_, index) => {
|
|
55
|
+
return this.linear(index / (count - 1));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
createImage(): HTMLCanvasElement {
|
|
60
|
+
const canvas = document.createElement("canvas");
|
|
61
|
+
canvas.width = this.lut.length;
|
|
62
|
+
canvas.height = 1;
|
|
63
|
+
const context = canvas.getContext("2d");
|
|
64
|
+
invariant(context != null);
|
|
65
|
+
this.lut.forEach(([r, g, b], index) => {
|
|
66
|
+
context.fillStyle = rgb(r * 255, g * 255, b * 255).toString();
|
|
67
|
+
context.fillRect(index, 0, 1, 1);
|
|
68
|
+
});
|
|
69
|
+
return canvas;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Flatten the color map LUT into a Float32Array for WASM/GPU usage.
|
|
74
|
+
* Each color tuple [r, g, b] is flattened into consecutive array elements.
|
|
75
|
+
* @returns A Float32Array with length = lut.length * 3
|
|
76
|
+
*/
|
|
77
|
+
flatten(): Float32Array {
|
|
78
|
+
const flatArray = new Float32Array(this.lut.length * 3);
|
|
79
|
+
for (let i = 0; i < this.lut.length; i++) {
|
|
80
|
+
flatArray[i * 3] = this.lut[i][0];
|
|
81
|
+
flatArray[i * 3 + 1] = this.lut[i][1];
|
|
82
|
+
flatArray[i * 3 + 2] = this.lut[i][2];
|
|
83
|
+
}
|
|
84
|
+
return flatArray;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const IMAGE_EXTENSIONS = ["png", "webp"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./image";
|
package/src/error.ts
ADDED