@equinor/videx-map 1.12.0 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FaultlineModule.d.ts +1 -0
- package/dist/GeoJSONModule/GeoJSONModule.d.ts +5 -1
- package/dist/GeoJSONModule/index.d.ts +1 -15
- package/dist/GeoJSONModule/interfaces.d.ts +15 -0
- package/dist/ModuleInterface.d.ts +1 -0
- package/dist/WellboreModule.d.ts +2 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/utils/wellbores/AsyncLoop.d.ts +3 -2
- package/dist/utils/wellbores/Config.d.ts +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ export default class FaultlineModule extends ModuleInterface {
|
|
|
38
38
|
/** Default config. */
|
|
39
39
|
config: Config;
|
|
40
40
|
constructor(config?: InputConfig);
|
|
41
|
+
destroy(): void;
|
|
41
42
|
/**
|
|
42
43
|
* Set collection of faultlines to display. Clears previous content on execution.
|
|
43
44
|
* @param data Faultlines to draw
|
|
@@ -2,8 +2,12 @@ import * as PIXI from 'pixi.js';
|
|
|
2
2
|
import Vector2 from '@equinor/videx-vector2';
|
|
3
3
|
import { ModuleInterface } from '../ModuleInterface';
|
|
4
4
|
import { EventHandler } from '../EventHandler';
|
|
5
|
-
import {
|
|
5
|
+
import { default as GeoJSONMultiPolygon } from './multipolygon';
|
|
6
|
+
import { default as GeoJSONPolygon } from './polygon';
|
|
7
|
+
import { default as GeoJSONLineString } from './linestring';
|
|
8
|
+
import { default as GeoJSONPoint } from './point';
|
|
6
9
|
import { ResizeConfig, LabelResizeConfig } from '../ResizeConfigInterface';
|
|
10
|
+
import { FeatureProps } from './interfaces';
|
|
7
11
|
/** Interface for config. */
|
|
8
12
|
interface Config {
|
|
9
13
|
customEventHandler?: EventHandler;
|
|
@@ -3,18 +3,4 @@ export { default as GeoJSONPolygon } from './polygon';
|
|
|
3
3
|
export { default as GeoJSONLineString } from './linestring';
|
|
4
4
|
export { default as GeoJSONPoint } from './point';
|
|
5
5
|
export { default as GeoJSONModule } from './GeoJSONModule';
|
|
6
|
-
export
|
|
7
|
-
lineColor: string;
|
|
8
|
-
lineWidth: number;
|
|
9
|
-
fillColor?: string;
|
|
10
|
-
fillColor2?: string;
|
|
11
|
-
fillOpacity?: number;
|
|
12
|
-
hashed?: boolean;
|
|
13
|
-
labelScale?: number;
|
|
14
|
-
}
|
|
15
|
-
export interface FeatureProps {
|
|
16
|
-
id: number;
|
|
17
|
-
label: string;
|
|
18
|
-
style: FeatureStyle;
|
|
19
|
-
additionalData?: any;
|
|
20
|
-
}
|
|
6
|
+
export * from './interfaces';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface FeatureStyle {
|
|
2
|
+
lineColor: string;
|
|
3
|
+
lineWidth: number;
|
|
4
|
+
fillColor?: string;
|
|
5
|
+
fillColor2?: string;
|
|
6
|
+
fillOpacity?: number;
|
|
7
|
+
hashed?: boolean;
|
|
8
|
+
labelScale?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface FeatureProps {
|
|
11
|
+
id: number;
|
|
12
|
+
label: string;
|
|
13
|
+
style: FeatureStyle;
|
|
14
|
+
additionalData?: any;
|
|
15
|
+
}
|
package/dist/WellboreModule.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export default class WellboreModule extends ModuleInterface {
|
|
|
31
31
|
scaling: (zoom: number) => number;
|
|
32
32
|
marker: PIXI.Graphics;
|
|
33
33
|
constructor(inputConfig?: InputConfig);
|
|
34
|
+
destroy(): void;
|
|
34
35
|
registerGroup(key: string, options?: GroupOptions): void;
|
|
35
36
|
private addRoot;
|
|
36
37
|
/**
|
|
@@ -39,7 +40,7 @@ export default class WellboreModule extends ModuleInterface {
|
|
|
39
40
|
* @param data wellbore data
|
|
40
41
|
*/
|
|
41
42
|
addWellbore(data: SourceData, group?: Group): void;
|
|
42
|
-
set(wells: SourceData[], key?: string): Promise<void>;
|
|
43
|
+
set(wells: SourceData[], key?: string, batchSize?: number): Promise<void>;
|
|
43
44
|
private forEachGroup;
|
|
44
45
|
private setActive;
|
|
45
46
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as PIXI from"pixi.js";import Vector2 from"@equinor/videx-vector2";import{flatten,mix}from"@equinor/videx-linear-algebra";import earcut from"earcut";import{inverseLerp,lerp,clamp}from"@equinor/videx-math";import{color}from"d3";import{v4}from"uuid";var ModuleInterface=function(){function ModuleInterface(){this.visibility=!0,this.root=new PIXI.Container,this.root.sortableChildren=!0}return ModuleInterface.prototype.toggle=function(){this.root.visible=!this.root.visible},ModuleInterface.prototype.setVisibility=function(visible){return visible!=this.visibility&&(this.root.visible=visible,this.visibility=visible,!0)},ModuleInterface.prototype.onAdd=function(map){},ModuleInterface.prototype.onRemove=function(map){},ModuleInterface.prototype.resize=function(zoom){},ModuleInterface}(),extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])})(d,b)};
|
|
1
|
+
import*as PIXI from"pixi.js";import Vector2 from"@equinor/videx-vector2";import{flatten,mix}from"@equinor/videx-linear-algebra";import earcut from"earcut";import{inverseLerp,lerp,clamp}from"@equinor/videx-math";import{color}from"d3";import{v4}from"uuid";var ModuleInterface=function(){function ModuleInterface(){this.visibility=!0,this.root=new PIXI.Container,this.root.sortableChildren=!0}return ModuleInterface.prototype.destroy=function(){this.root.destroy({children:!0,texture:!0,baseTexture:!0}),this.root=null},ModuleInterface.prototype.toggle=function(){this.root.visible=!this.root.visible},ModuleInterface.prototype.setVisibility=function(visible){return visible!=this.visibility&&(this.root.visible=visible,this.visibility=visible,!0)},ModuleInterface.prototype.onAdd=function(map){},ModuleInterface.prototype.onRemove=function(map){},ModuleInterface.prototype.resize=function(zoom){},ModuleInterface}(),extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])})(d,b)};
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -12,4 +12,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function __extends(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __spreadArray(to,from){for(var i=0,il=from.length,j=to.length;i<il;i++,j++)to[j]=from[i];return to}function log(text){var date,out="%cVIDEX-MAP%c "+text;console.log(out+" ("+((date=new Date).getHours()+":"+date.getMinutes()+":"+date.getSeconds()+"."+date.getMilliseconds()+")"),"\n background: #555;\n color: #eee;\n padding: 0 6px 0 6px;\n border-radius: 2px;\n ",null)}var FaultlineModule=function(_super){function FaultlineModule(config){var _this=_super.call(this)||this;return _this.spawned=[],_this.pool=[],_this.config={color:7503240,alpha:1,outlineWidth:.125},config?(isNaN(config.color)||(_this.config.color=config.color),isNaN(config.alpha)||(_this.config.alpha=config.alpha),isNaN(config.outlineWidth)||(_this.config.outlineWidth=config.outlineWidth),_this):_this}return __extends(FaultlineModule,_super),FaultlineModule.prototype.set=function(data){var _this=this;this.clear();var project=this.pixiOverlay.utils.latLngToLayerPoint,lineCount=0;data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new PIXI.Graphics,_this.root.addChild(faultline)),_this.spawned.push(faultline),faultline.alpha=_this.config.alpha;var projected=d.coordinates.map((function(p){var coord=project(p);return new PIXI.Point(coord.x,coord.y)})),first=projected[0],last=projected[projected.length-1];if(Vector2.equals([first.x,first.y],[last.x,last.y],1e-6))faultline.beginFill(_this.config.color),faultline.lineStyle(_this.config.outlineWidth,_this.config.color),faultline.drawPolygon(projected),faultline.endFill();else{lineCount++,faultline.lineStyle(_this.config.outlineWidth,_this.config.color).moveTo(first.x,first.y);for(var i=1;i<projected.length;i++)faultline.lineTo(projected[i].x,projected[i].y)}})),lineCount>0&&log("Drawing "+lineCount+" faultline polygons as lines.")},FaultlineModule.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineModule.prototype.resize=function(zoom){},FaultlineModule}(ModuleInterface);function Intersection(p1,d1,p2,d2){var c=[p1[0]-p2[0],p1[1]-p2[1]],len=(c[0]*d2[1]-c[1]*d2[0])/(d1[1]*d2[0]-d1[0]*d2[1]);return c[0]=d1[0]*len+p1[0],c[1]=d1[1]*len+p1[1],c}var Mesh=function(){function Mesh(){}return Mesh.WellboreSegment=function(points,thickness,type){void 0===thickness&&(thickness=1);var vertices=[],triangles=[],vertexData=[],extraData=[],_thickness=.5*thickness,point0=points[0],first=point0.position,from0=Vector2.sub(points[1].position,first).rescale(_thickness);vertices.push(-from0[1]+first[0],from0[0]+first[1],from0[1]+first[0],-from0[0]+first[1]),vertexData.push(point0.distance,1,-point0.direction[1],point0.direction[0],point0.distance,0,point0.direction[1],-point0.direction[0]),extraData.push(type,type);for(var i=1;i<points.length-1;i++){var point=points[i],prev=points[i-1].position,cur=point.position,next=points[i+1].position,to=Vector2.sub(cur,prev),from=Vector2.sub(next,cur),upper=null,inner=null;if(Vector2.angleDeg(to,from)<90){var toU=to.rotate90().mutable.rescale(_thickness).add(prev).immutable,fromU=from.rotate90().mutable.rescale(_thickness).add(next).immutable,toI=to.rotate270().mutable.rescale(_thickness).add(prev).immutable,fromI=from.rotate270().mutable.rescale(_thickness).add(next).immutable;upper=Intersection(toU,to,fromU,from),inner=Intersection(toI,to,fromI,from)}else upper=[-point.direction[1]*_thickness+cur[0],point.direction[0]*_thickness+cur[1]],inner=[point.direction[1]*_thickness+cur[0],-point.direction[0]*_thickness+cur[1]];if(vertices.push(upper[0],upper[1],inner[0],inner[1]),vertexData.push(point.distance,1,-point.direction[1],point.direction[0],point.distance,0,point.direction[1],-point.direction[0]),extraData.push(type,type),0!=i){var n_1=2*i;triangles.push(n_1-1,n_1-2,n_1,n_1-1,n_1,n_1+1)}}var pointN=points[points.length-1],last=pointN.position,toN=Vector2.sub(last,points[points.length-2].position).rescale(_thickness);vertices.push(last[0]-toN[1],last[1]+toN[0],last[0]+toN[1],last[1]-toN[0]),vertexData.push(pointN.distance,1,-pointN.direction[1],pointN.direction[0],pointN.distance,0,pointN.direction[1],-pointN.direction[0]),extraData.push(type,type);var n=2*points.length-2;return triangles.push(n-1,n-2,n,n-1,n,n+1),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},Mesh.from=function(vertices,triangles,vertexShader,fragmentShader,uniforms,normals){var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",vertices,2),normals&&geometry.addAttribute("inputNormals",normals,2),geometry.addIndex(triangles);var shader=PIXI.Shader.from(vertexShader,fragmentShader,uniforms);return new PIXI.Mesh(geometry,shader)},Mesh.SimpleLine=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness;function GetNormal(index){if(0===index)return Vector2.sub(points[1],points[0]).mutable.rotate90().rescale(1);if(index===points.length-1)return Vector2.sub(points[points.length-1],points[points.length-2]).mutable.rotate90().rescale(1);var prev=points[index-1],cur=points[index],next=points[index+1];return Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1)}for(var prevUpperRight,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<points.length-1;i++){var cur=points[i],next=points[i+1],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=GetNormal(i),rightNormal=GetNormal(i+1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh.Polygon=function(points){var vertices=flatten(points);return{vertices:vertices,triangles:earcut(vertices)}},Mesh.PolygonOutline=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness;function GetIndex(index){var r=index%points.length;return r<0&&(r+=points.length),r}for(var prevUpperRight,firstUpperLeft,firstDirN,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<points.length;i++){var prev=points[GetIndex(i-1)],cur=points[GetIndex(i)],next=points[GetIndex(i+1)],next2=points[GetIndex(i+2)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1),rightNormal=Vector2.lerpRot(Vector2.sub(next,cur),Vector2.sub(next2,next),.5).mutable.rotate90().rescale(1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}else firstUpperLeft=upperLeft,firstDirN=dirN;if(i===points.length-1){var toLastUpper=Vector2.sub(upperRight,firstUpperLeft);Vector2.signedAngle(firstDirN,toLastUpper)<0?triangles.push(0,baseTris-2,1):triangles.push(0,baseTris-1,1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh}(),OutlineModule=function(_super){function OutlineModule(config){var _this=_super.call(this)||this;return _this.outlineDict={},_this.spawned=[],_this.config={baseWidth:.1,minZoom:0,maxZoom:18,minExtraWidth:.1,maxExtraWidth:10},_this.state={extraWidth:1},config?(isNaN(config.minZoom)||(_this.config.minZoom=config.minZoom),isNaN(config.maxZoom)||(_this.config.maxZoom=config.maxZoom),isNaN(config.minExtraWidth)||(_this.config.minExtraWidth=config.minExtraWidth),isNaN(config.maxExtraWidth)||(_this.config.maxExtraWidth=config.maxExtraWidth),_this):_this}return __extends(OutlineModule,_super),OutlineModule.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,width:_this.state.extraWidth,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms;for(var coordinates=outlineCollection.coordinates,n=0;n<coordinates.length;n++){for(var polygon=coordinates[n],projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project(p);projected.push([pos.x,pos.y])}var outlineData=void 0;if(Vector2.equals(projected[0],projected[projected.length-1],1e-6)){if(projected.pop(),projected.length<=2){log("Skipping outline (Polygon) with "+projected.length+" points.");continue}outlineData=Mesh.PolygonOutline(projected,_this.config.baseWidth)}else{if(projected.length<=1){log("Skipping outline (Line) with "+projected.length+" points.");continue}outlineData=Mesh.SimpleLine(projected,_this.config.baseWidth)}var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineModule.vertexShader,OutlineModule.fragmentShader,uniforms,outlineData.normals);_this.root.addChild(outline),_this.spawned.push(outline)}}))},OutlineModule.prototype.setVisibleLayers=function(names){var _this=this;Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].visible=!1})),names.forEach((function(name){var uniforms=_this.outlineDict[name];uniforms&&(uniforms.visible=!0)}))},OutlineModule.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineModule.prototype.resize=function(zoom){var _this=this,t=inverseLerp(this.config.minZoom,this.config.maxZoom,zoom),width=lerp(this.config.maxExtraWidth,this.config.minExtraWidth,t);this.state.extraWidth=width,Object.keys(this.outlineDict).forEach((function(key){_this.outlineDict[key].width=width}))},OutlineModule}(ModuleInterface);function toShader(n){return n-Math.floor(n)==0?n.toString()+".0":n.toString()}OutlineModule.vertexShader="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineModule.fragmentShader="\n precision mediump float;\n\n uniform vec3 color;\n uniform bool visible;\n\n void main() {\n if (!visible) discard;\n gl_FragColor = vec4(color, 1.0);\n }\n";var WellboreShader=function(){function WellboreShader(){}return WellboreShader.build=function(maxScale,wellboreDash){WellboreShader.vertexShader="\n attribute vec2 verts;\n attribute vec4 vertCol;\n attribute float typeData;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n uniform float wellboreRadius;\n\n varying vec4 vCol;\n varying float type;\n\n void main() {\n vCol = vertCol;\n type = typeData;\n\n vec2 normal = vertCol.zw;\n\n float extraRadius = wellboreRadius - "+toShader(maxScale)+";\n\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts + normal * extraRadius, 1.0)).xy, 0.0, 1.0);\n }\n ";var dash=toShader(wellboreDash),doubleDash=toShader(2*wellboreDash),quadrupleDash=toShader(4*wellboreDash);WellboreShader.fragmentShader="\n precision mediump float;\n\n varying vec4 vCol;\n varying float type;\n\n uniform vec3 wellboreColor1;\n uniform vec3 wellboreColor2;\n uniform bool completionVisible;\n uniform bool wellboreVisible;\n uniform int status;\n\n const vec3 sunDir = vec3(0.6247, -0.6247, 0.4685);\n\n void main() {\n vec3 col = vec3(0.0);\n float alpha = 1.0;\n\n if (status == 0) {\n if(type == 0.0) {\n if (!wellboreVisible) {\n alpha = 0.03;\n }\n } else if (type == 1.0) {\n if(completionVisible){\n if(mod(vCol.x, "+doubleDash+") > "+dash+") discard;\n } else if(!wellboreVisible){\n alpha = 0.03;\n }\n }\n if (!completionVisible && type == 2.0) discard;\n\n float dist = clamp(vCol.z * vCol.z + vCol.w * vCol.w, 0.0, 1.0);\n\n vec3 dir3D = vec3(vCol.zw, sqrt(1.0 - dist * dist));\n\n float light = 0.4 + dot(dir3D, sunDir) * 0.6;\n light = clamp(light, 0.0, 1.0);\n\n col = mix(wellboreColor2, wellboreColor1, light);\n }\n\n else if (status == 1) {\n if (type == 2.0) discard;\n if(mod(vCol.x + vCol.y * 0.2, "+quadrupleDash+") > "+doubleDash+") discard;\n vec3 c = wellboreColor2 + wellboreColor1 * 0.5;\n vec3 gray = vec3(0.9);\n col = mix(gray, c, 0.3);\n }\n\n else if (status == 2) {\n if (type == 2.0) discard;\n alpha = 0.03;\n }\n\n else discard;\n\n col *= alpha;\n gl_FragColor = vec4(col, alpha);\n }\n "},WellboreShader.vertexShader="",WellboreShader.fragmentShader="",WellboreShader}(),RootShader=function(){function RootShader(){}return RootShader.get=function(){return PIXI.Shader.from(RootShader.vertexShader,RootShader.fragmentShader,{active:!0,circleColor1:[0,0,0],circleColor2:[0,0,0]})},RootShader.build=function(maxScale){RootShader.vertexShader="\n attribute vec2 verts;\n attribute vec2 inputUVs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n uniform float rootRadius;\n\n varying vec2 UVs;\n\n void main() {\n UVs = inputUVs;\n\n vec2 dir = 2.0 * inputUVs - 1.0;\n\n float extraRadius = rootRadius - "+toShader(maxScale)+";\n\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts + dir * extraRadius, 1.0)).xy, 0.0, 1.0);\n }\n "},RootShader.vertexShader="",RootShader.fragmentShader="\n precision mediump float;\n\n varying vec2 UVs;\n\n uniform vec3 circleColor1;\n uniform vec3 circleColor2;\n uniform bool active;\n\n const vec3 sunDir = vec3(0.6247, -0.6247, 0.4685);\n\n void main() {\n if (!active) {\n discard;\n return;\n }\n vec2 dir = 2.0 * UVs - 1.0;\n float dist = dir.x * dir.x + dir.y * dir.y;\n if (dist > 1.0) discard;\n\n vec3 dir3D = vec3(dir, sqrt(1.0 - dist * dist));\n\n float light = dot(dir3D, sunDir);\n light = 0.4 + light * 0.6;\n\n vec3 col = mix(circleColor2, circleColor1, clamp(light, 0.0, 1.0));\n\n gl_FragColor = vec4(col, 1.0);\n }\n ",RootShader}();function generateCircle(center,radius,shader){var geometry=new PIXI.Geometry;return geometry.addAttribute("verts",[center[0]-radius,center[1]-radius,center[0]+radius,center[1]-radius,center[0]-radius,center[1]+radius,center[0]+radius,center[1]+radius],2),geometry.addAttribute("inputUVs",[0,0,1,0,0,1,1,1],2),geometry.addIndex([0,2,3,0,3,1]),new PIXI.Mesh(geometry,shader)}var Label=function(){function Label(label,fontColor,bgColor){this._attachToRoot=!1;var text=new PIXI.Text(label,Label.style);text.resolution=window.devicePixelRatio,text.visible=Label.state.visible,text.tint=fontColor,text.zIndex=1,this.text=text;var metrics=PIXI.TextMetrics.measureText(label,Label.style);this.metrics=metrics;var background=new PIXI.Graphics;background.beginFill(16777215),background.drawRect(.55*-metrics.width,.525*-Label.height,1.1*metrics.width,1.05*Label.height),background.endFill(),background.visible=Label.state.visible,background.alpha=Label.config.backgroundOpacity,background.tint=bgColor,background.zIndex=0,this.background=background}return Label.setStyle=function(fontSize){Label.style=new PIXI.TextStyle({fontFamily:"Arial",fontSize:fontSize,fill:16777215,align:"center"}),Label.height=PIXI.TextMetrics.measureText(" ",Label.style).height},Label.setCommon=function(config){Label.config=config},Object.defineProperty(Label.prototype,"visible",{get:function(){return this.text.visible},set:function(flag){this.text.visible=flag&&Label.state.visible,this.background.visible=flag&&Label.state.visible},enumerable:!1,configurable:!0}),Object.defineProperty(Label.prototype,"attachToRoot",{get:function(){return this._attachToRoot},set:function(val){val!==this._attachToRoot&&(this._attachToRoot=val)},enumerable:!1,configurable:!0}),Label.prototype.getBoundingBox=function(){var _a=this.background,y=_a.y,width=_a.width,height=_a.height,x=this.background.x-width/2;return new PIXI.Rectangle(x,y,width,height)},Label.state={zoom:1,scale:1,visible:!0,rootDisplacement:1},Label}();var RootData=function(){function RootData(position,radius){this.wellbores=[],this.labelIndex=0,this.rootLabelsBBox=null,this.target=null,this.position=position,this.radius=radius;var shader=RootShader.get();this.mesh=generateCircle(position,radius,shader)}return Object.defineProperty(RootData.prototype,"active",{get:function(){return this.target&&this.target.active},enumerable:!1,configurable:!0}),RootData.prototype.updateLabelsBBox=function(label){var bbox=label.getBoundingBox();this.rootLabelsBBox?(this.rootLabelsBBox.height=bbox.y+bbox.height-this.rootLabelsBBox.y,bbox.width>this.rootLabelsBBox.width&&(this.rootLabelsBBox.x=bbox.x,this.rootLabelsBBox.width=bbox.width)):this.rootLabelsBBox=bbox},RootData.prototype.positionLabel=function(wellbore){wellbore.label.attachToRoot?(!function(wellbore,position){wellbore.label.attachToRoot=!0;var _a=wellbore.label,text=_a.text,background=_a.background,_b=Label.state,scale=_b.scale,rootDisplacement=_b.rootDisplacement;text.anchor.set(.5,0),text.rotation=0,background.rotation=0,background.pivot.set(0,.5*-Label.height);var yPos=rootDisplacement+5*scale+position*(Label.height+5)*scale+wellbore.root.position[1];text.position.set(wellbore.root.position[0],yPos),text.scale.set(scale),background.position.set(wellbore.root.position[0],yPos),background.scale.set(scale)}(wellbore,this.labelIndex++),this.updateLabelsBBox(wellbore.label)):function(wellbore){wellbore.label.attachToRoot=!1;var anchorX,anchorY,pivotX,pivotY,angle,pos,_a=wellbore.label,text=_a.text,background=_a.background,metrics=_a.metrics,end=wellbore.interpolator.GetPoint(1).position,width=metrics.width*Label.state.scale,start=wellbore.interpolator.GetPointFromEnd(width),dir=Vector2.sub(end,start.position).mutable;dir.x<0?(anchorX=0,anchorY=0,pivotX=.5*-metrics.width,pivotY=.5*-metrics.height,angle=Vector2.signedAngle(Vector2.left,dir),pos=dir.rotate270().rescale(.5*wellbore.wellboreWidth+.075).add(end)):(anchorX=1,anchorY=0,pivotX=.5*metrics.width,pivotY=.5*-metrics.height,angle=Vector2.signedAngle(Vector2.right,dir),pos=dir.rotate90().rescale(.5*wellbore.wellboreWidth+.075).add(end)),text.position.set(pos[0],pos[1]),text.rotation=angle,text.anchor.set(anchorX,anchorY),text.scale.set(Label.state.scale),background.position.set(pos[0],pos[1]),background.pivot.set(pivotX,pivotY),background.rotation=angle,background.scale.set(Label.state.scale)}(wellbore)},RootData.prototype.append=function(wellbore){this.wellbores.push(wellbore),wellbore.active&&(this.target?wellbore.order<this.target.order&&wellbore.status>this.target.status?this.recalculate(!0):this.positionLabel(wellbore):this.recalculate(!0))},RootData.prototype.recalculate=function(labelUpdate){void 0===labelUpdate&&(labelUpdate=!1),this.updateTarget(),this.updateUniforms(),labelUpdate&&this.updateLabels()},RootData.prototype.updateTarget=function(){for(var target,smallest=Number.MAX_VALUE,i=0;i<this.wellbores.length;i++){var wellbore=this.wellbores[i];if(wellbore.active){if(wellbore.selected){target=wellbore;break}var weighted=wellbore.order-1e6*wellbore.status;weighted<smallest&&(smallest=weighted,target=wellbore)}}this.target=target},RootData.prototype.updateUniforms=function(){var uniform=this.mesh.shader.uniforms;if(uniform.active=this.active,this.target){var color=this.target.color;uniform.circleColor1=color.col1,uniform.circleColor2=color.col2,this.mesh.zIndex=this.target.status}},RootData.prototype.updateLabels=function(){var _this=this;this.labelIndex=0,this.rootLabelsBBox=null,this.wellbores.forEach((function(wellbore){wellbore.active&&_this.positionLabel(wellbore)}))},RootData.prototype.setLabelVisibility=function(visible){visible?this.updateLabels():this.rootLabelsBBox=null,this.wellbores.forEach((function(wellbore){wellbore.active&&(wellbore.label.visible=visible)}))},RootData}();var WellboreStatus,FilterStatus,LineInterpolator=function(){function LineInterpolator(points,radius){this.singlePoint=!0;var initDir,amount=points.length,path=new Array(amount),root=points[0];initDir=points.length>=2?Vector2.sub(points[1],points[0]).normalize():Vector2.right,path[0]={point:root,direction:initDir,distance:0,relative:0};for(var length=0,i=1;i<amount;i++){var point=points[i];length+=Vector2.distance(point,path[i-1].point),path[i]={point:point,direction:this.GetDirection(points,i),distance:length,relative:0},Vector2.distance(point,root)>radius&&(this.singlePoint=!1)}for(i=1;i<amount;i++){var p=path[i];p.relative=0===length?0:p.distance/length}this.amount=amount,this.length=length,this.path=path}return LineInterpolator.prototype.GetPoint=function(relative){if(this.singlePoint)return{position:this.path[0].point,direction:Vector2.up,distance:0};if(relative<0){var first=this.path[0];return{position:first.point,direction:first.direction,distance:0}}if(relative>=1){var last=this.path[this.amount-1];return{position:last.point,direction:last.direction,distance:this.length}}var base=this.GetClosestPointBelow(relative),prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relative-prev.relative)/dist;return{position:mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prev.direction,cur.direction,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac}},LineInterpolator.prototype.GetSection=function(relativeStart,relativeEnd){if(this.singlePoint)return[{position:this.path[0].point,direction:Vector2.up,distance:0},{position:this.path[0].point,direction:Vector2.up,distance:0}];if(relativeStart>=1){var last=this.path[this.path.length-1];return[{position:last.point,direction:last.direction,distance:this.length},{position:last.point,direction:last.direction,distance:this.length}]}var base=this.GetClosestPointBelow(relativeStart),points=[],prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relativeStart-prev.relative)/dist;points.push({position:mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prev.direction,cur.direction,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac});for(var i=base+1;i<this.amount;i++){var cur_1=this.path[i];if(cur_1.relative>=relativeEnd){var cur_2=this.path[i],prev_1=this.path[i-1],dist_1=cur_2.relative-prev_1.relative,frac_1=(relativeEnd-prev_1.relative)/dist_1;points.push({position:mix(prev_1.point,cur_2.point,frac_1,Vector2.zero),direction:Vector2.lerpRot(prev_1.direction,cur_2.direction,frac_1).normalize(),distance:prev_1.distance*(1-frac_1)+cur_2.distance*frac_1});break}points.push({position:cur_1.point,direction:this.path[i].direction,distance:cur_1.distance})}return points},LineInterpolator.prototype.GetClosestPointBelow=function(relative){for(var base=0,range=this.amount,idx=Math.floor(.5*range);range>1;)relative<this.path[idx].relative?(range=Math.floor(.5*range),idx=base+Math.floor(.5*range)):(base+=Math.floor(.5*range),range=Math.ceil(.5*range),idx=base+Math.floor(.5*range));return base},LineInterpolator.prototype.GetPointFromStart=function(distance){var relative=distance/this.length;return clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetPointFromEnd=function(distance){var relative=1-distance/this.length;return clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetRangeFromStart=function(relative,width,resolution){void 0===resolution&&(resolution=10);for(var relativeDisp=(relative+width/this.length-relative)/resolution,points=[],i=0;i<=resolution;i++)points.push(this.GetPoint(relative+relativeDisp*i));return points},LineInterpolator.prototype.GetDirection=function(points,idx){var end=points.length-1;if(0===idx)return Vector2.sub(points[1],points[0]).normalize();if(idx===end)return Vector2.sub(points[end],points[end-1]).normalize();var cur=points[idx],to=Vector2.sub(cur,points[idx-1]),from=Vector2.sub(points[idx+1],cur);return Vector2.lerpRot(to,from,.5).normalize()},LineInterpolator}(),WellboreMesh=function(){function WellboreMesh(interp,thickness,tick){this.interp=interp,this.thickness=thickness,this.baseTris=0,this.tick=tick}return WellboreMesh.prototype.generate=function(intervals){var _this=this;void 0===intervals&&(intervals=[]);var vertices=[],triangles=[],vertexData=[],extraData=[];if(intervals.length<=0){var path=this.interp.GetSection(0,1);this.appendSegment(path,0,vertices,triangles,vertexData,extraData)}else if(intervals.length>0){var p_1=0;intervals.forEach((function(i){var path1=_this.interp.GetSection(p_1,i[0]);_this.appendSegment(path1,0,vertices,triangles,vertexData,extraData);var path2=_this.interp.GetSection(i[0],i[1]);_this.appendSegment(path2,1,vertices,triangles,vertexData,extraData),p_1=i[1]}));var end=intervals[intervals.length-1][1];if(end<1){var lastPath=this.interp.GetSection(end,1);this.appendSegment(lastPath,0,vertices,triangles,vertexData,extraData)}}return intervals.forEach((function(i){var p1=_this.interp.GetPoint(i[0]);if(_this.generateCrossline(p1,vertices,triangles,vertexData,extraData),!(Math.abs(i[0]-i[1])<.001)){var p2=_this.interp.GetPoint(i[1]);_this.generateCrossline(p2,vertices,triangles,vertexData,extraData)}})),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},WellboreMesh.prototype.appendSegment=function(section,type,vertices,triangles,vertexData,extraData){var _this=this,mesh=Mesh.WellboreSegment(section,this.thickness,type);vertices.push.apply(vertices,mesh.vertices),mesh.triangles.forEach((function(d){return triangles.push(d+_this.baseTris)})),vertexData.push.apply(vertexData,mesh.vertexData),extraData.push.apply(extraData,mesh.extraData),this.baseTris+=mesh.vertices.length/2},WellboreMesh.prototype.generateCrossline=function(p,vertices,triangles,vertexData,extraData){var px=p.position[0],py=p.position[1],crosslinesWidth=this.tick.width,dirX=p.direction[0]*crosslinesWidth,dirY=p.direction[1]*crosslinesWidth,crosslinesHeight=this.tick.height,normX=-p.direction[1]*crosslinesHeight,normY=p.direction[0]*crosslinesHeight;vertices.push(px-dirX-normX,py-dirY-normY,px+dirX-normX,py+dirY-normY,px-dirX+normX,py-dirY+normY,px+dirX+normX,py+dirY+normY),triangles.push(this.baseTris,this.baseTris+2,this.baseTris+3,this.baseTris,this.baseTris+3,this.baseTris+1),extraData.push(2,2,2,2);var normalizedNormal=new Vector2(normX,normY).normalized(),nnx=normalizedNormal.x,nny=normalizedNormal.y;vertexData.push(p.distance,0,-nnx,-nny,p.distance,0,-nnx,-nny,p.distance,1,nnx,nny,p.distance,1,nnx,nny),this.baseTris+=4},WellboreMesh}();!function(WellboreStatus){WellboreStatus[WellboreStatus.normal=0]="normal",WellboreStatus[WellboreStatus.highlighted=1]="highlighted",WellboreStatus[WellboreStatus.multiHighlighted=2]="multiHighlighted",WellboreStatus[WellboreStatus.selected=3]="selected"}(WellboreStatus||(WellboreStatus={})),function(FilterStatus){FilterStatus[FilterStatus.none=0]="none",FilterStatus[FilterStatus.soft=1]="soft",FilterStatus[FilterStatus.hard=2]="hard"}(FilterStatus||(FilterStatus={}));var ColorType,WellboreData=function(){function WellboreData(input){if(this._zIndex=0,this.status=WellboreStatus.normal,this.filter=FilterStatus.none,this.data=input.data,this.group=input.group,this.root=input.root,this.wellboreWidth=input.wellboreWidth,this.interpolator=new LineInterpolator(input.coords,input.pointThreshold),this.label=new Label(input.data.labelShort,this.colors.fontColor,this.colors.default.labelBg),this.interpolator.singlePoint)this.label.attachToRoot=!0;else{var intervals=function(intervals){var output=intervals.map((function(i){return[i.l1,i.l2]})).sort((function(a,b){return a[0]<b[0]?-1:a[0]>b[0]?1:0}));return output.length>0&&(output=function(intervals){for(var output=[],prev=intervals[0].slice(0),i=1;i<intervals.length;i++){var cur=intervals[i].slice(0);cur[0]<prev[1]?cur[1]>prev[1]&&(prev[1]=cur[1]):(output.push(prev),prev=cur)}return output.push(prev),output}(output)),output}(input.data.intervals);this.mesh=this.createWellboreMesh(intervals,input.tick)}this.update()}return Object.defineProperty(WellboreData.prototype,"zIndex",{set:function(val){this._zIndex=val,this.mesh&&(this.mesh.zIndex=this._zIndex)},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"colors",{get:function(){return this.group.colors},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"color",{get:function(){var colors=this.group.colors;switch(this.status){case WellboreStatus.normal:return colors.default;case WellboreStatus.highlighted:return colors.highlight;case WellboreStatus.multiHighlighted:return colors.multiHighlight;case WellboreStatus.selected:return colors.selected}},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"active",{get:function(){var activeUniform=this.mesh&&0==this.mesh.shader.uniforms.status;return this.group.active&&(activeUniform||this.filter===FilterStatus.none)},enumerable:!1,configurable:!0}),WellboreData.prototype.setFilter=function(filter){this.filter!==filter&&(this.filter=filter,this.update())},Object.defineProperty(WellboreData.prototype,"selected",{get:function(){return this.status==WellboreStatus.selected},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"highlighted",{get:function(){return this.status==WellboreStatus.highlighted||this.status==WellboreStatus.multiHighlighted},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"order",{get:function(){return this.group.order},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"uniforms",{get:function(){return this.mesh.shader.uniforms},enumerable:!1,configurable:!0}),WellboreData.prototype.createWellboreMesh=function(intervals,tick){var _a=new WellboreMesh(this.interpolator,this.wellboreWidth,tick).generate(intervals),vertices=_a.vertices,triangles=_a.triangles,vertexData=_a.vertexData,extraData=_a.extraData,geometry=new PIXI.Geometry;geometry.addAttribute("verts",vertices,2),geometry.addAttribute("vertCol",vertexData,4),geometry.addAttribute("typeData",extraData,1),geometry.addIndex(triangles);var shader=function(color,completionVisible,wellboreVisible){return PIXI.Shader.from(WellboreShader.vertexShader,WellboreShader.fragmentShader,{wellboreColor1:color.col1,wellboreColor2:color.col2,completionVisible:completionVisible,wellboreVisible:wellboreVisible,status:0})}(this.colors.default,this.group.state.completionVisible,this.group.state.wellboreVisible);return new PIXI.Mesh(geometry,shader)},WellboreData.prototype.setCompletionVisibility=function(visible){this.mesh&&(this.uniforms.completionVisible=visible)},WellboreData.prototype.setWellboreVisibility=function(visible){this.mesh&&(this.uniforms.wellboreVisible=visible)},WellboreData.prototype.setHighlight=function(isHighlighted,multiple){if(void 0===multiple&&(multiple=!1),this.status!==WellboreStatus.selected)if(this.status=isHighlighted?multiple?WellboreStatus.multiHighlighted:WellboreStatus.highlighted:WellboreStatus.normal,isHighlighted){var color=multiple?this.colors.multiHighlight:this.colors.highlight;this.mesh&&(this.mesh.shader.uniforms.wellboreColor1=color.col1,this.mesh.shader.uniforms.wellboreColor2=color.col2,this.mesh.zIndex=this._zIndex+1e5),this.label.background.tint=color.labelBg,this.label.background.alpha=.75,this.label.background.zIndex=2,this.label.text.zIndex=3,this.label.text.tint=this.colors.interactFontColor}else this.mesh&&(this.mesh.shader.uniforms.wellboreColor1=this.colors.default.col1,this.mesh.shader.uniforms.wellboreColor2=this.colors.default.col2,this.mesh.zIndex=this._zIndex),this.label.background.tint=this.colors.default.labelBg,this.label.background.alpha=Label.config.backgroundOpacity,this.label.background.zIndex=0,this.label.text.zIndex=1,this.label.text.tint=this.colors.fontColor},WellboreData.prototype.setSelected=function(isSelected){this.status=isSelected?WellboreStatus.selected:WellboreStatus.normal,isSelected?(this.mesh&&(this.mesh.shader.uniforms.wellboreColor1=this.colors.selected.col1,this.mesh.shader.uniforms.wellboreColor2=this.colors.selected.col2,this.mesh.zIndex=this._zIndex+1e6),this.label.background.tint=this.colors.selected.labelBg,this.label.background.alpha=.75,this.label.background.zIndex=2,this.label.text.zIndex=3):(this.mesh&&(this.mesh.shader.uniforms.wellboreColor1=this.colors.default.col1,this.mesh.shader.uniforms.wellboreColor2=this.colors.default.col2,this.mesh.zIndex=this._zIndex),this.label.background.tint=this.colors.default.labelBg,this.label.background.alpha=Label.config.backgroundOpacity,this.label.background.zIndex=0,this.label.text.zIndex=1),this.label.text.tint=this.colors.fontColor,this.root.recalculate()},WellboreData.prototype.update=function(){var active=this.group.active&&this.filter===FilterStatus.none;if(this.mesh){var status_1=this.filter;this.group.active||(status_1=4),this.mesh.shader.uniforms.status=status_1}this.label.visible=active},WellboreData}();function getDefaultColors(input){var output={fontColor:0,interactFontColor:16777215,default:{col1:[.3,.3,.3],col2:[.05,.05,.05],labelBg:16777215},highlight:{col1:[.8,.2,.9],col2:[.5,.05,.6],labelBg:10685091},multiHighlight:{col1:[.55,.55,.55],col2:[.3,.3,.3],labelBg:6710886},selected:{col1:[1,0,0],col2:[.5,0,0],labelBg:16777215}};if(!input)return output;function transfer(key){isNaN(input[key])||(output[key]=input[key])}function transferColor(color){var inputCol1=input[color+"Color1"],inputCol2=input[color+"Color2"],inputLabelBg=input[color+"LabelBg"],outputColor=output[color];inputCol1&&(outputColor.col1=inputCol1),inputCol2&&(outputColor.col2=inputCol2),inputLabelBg&&(outputColor.labelBg=inputLabelBg)}return transfer("fontColor"),transfer("interactFontColor"),transferColor("default"),transferColor("highlight"),transferColor("multiHighlight"),transferColor("selected"),output}!function(ColorType){ColorType[ColorType.Default=0]="Default",ColorType[ColorType.Highlight=1]="Highlight",ColorType[ColorType.MultiHighlight=2]="MultiHighlight",ColorType[ColorType.Selected=3]="Selected"}(ColorType||(ColorType={}));var Group=function(){function Group(key,options){this.wellbores=[],this.active=!0,this.order=0,this.activeFilter=null,this.state={completionVisible:!0,wellboreVisible:!0},this.key=key,options?(this.colors=getDefaultColors(options.colors),isNaN(options.order)||(this.order=options.order)):this.colors=getDefaultColors()}return Group.prototype.append=function(wellbore){if(wellbore.zIndex=1e4*this.order+this.wellbores.length,this.activeFilter){var targetFilter=this.isHardFilter?FilterStatus.hard:FilterStatus.soft;wellbore.setFilter(this.activeFilter(wellbore.data)?FilterStatus.none:targetFilter),wellbore.root.recalculate(!0)}this.wellbores.push(wellbore)},Group.prototype.forAll=function(wellboreFunc,rootFunc){for(var roots=new Set,wellbores=this.wellbores,i=0;i<wellbores.length;i++){var wellbore=wellbores[i];wellboreFunc(wellbore),roots.add(wellbore.root)}roots.forEach((function(root){return rootFunc(root)}))},Group.prototype.setActive=function(active){this.active!==active&&(this.active=active,this.forAll((function(wellbore){return wellbore.update()}),(function(root){return root.recalculate(!0)})))},Group.prototype.softFilter=function(filter){this.activeFilter=filter,this.isHardFilter=!1,this.forAll((function(wellbore){return wellbore.setFilter(filter(wellbore.data)?FilterStatus.none:FilterStatus.soft)}),(function(root){return root.recalculate(!0)}))},Group.prototype.hardFilter=function(filter){this.activeFilter=filter,this.isHardFilter=!0,this.forAll((function(wellbore){return wellbore.setFilter(filter(wellbore.data)?FilterStatus.none:FilterStatus.hard)}),(function(root){return root.recalculate(!0)}))},Group.prototype.clearFilter=function(){this.activeFilter=null,this.forAll((function(wellbore){return wellbore.setFilter(FilterStatus.none)}),(function(root){return root.recalculate(!0)}))},Group.prototype.setCompletionVisibility=function(visible){this.state.completionVisible=visible,this.wellbores.forEach((function(wellbore){wellbore.mesh&&(wellbore.uniforms.completionVisible=visible)}))},Group.prototype.setWellboreVisibility=function(visible){this.state.wellboreVisible=visible,this.wellbores.forEach((function(wellbore){wellbore.mesh&&(wellbore.uniforms.wellboreVisible=visible)}))},Group}(),WellboreEventData=function(){function WellboreEventData(group,data){this.group=group,this.data=data}return WellboreEventData.from=function(wellbore){return new WellboreEventData(wellbore.group.key,wellbore.data)},WellboreEventData}(),HighlightEvent=function(){function HighlightEvent(eventData,changed,originalEvent){this.eventData=eventData,this.changed=changed,this.originalEvent=originalEvent}return HighlightEvent.from=function(wellbores,changed,originalEvent){return new HighlightEvent(wellbores.map((function(w){return new WellboreEventData(w.group.key,w.data)})),changed,originalEvent)},Object.defineProperty(HighlightEvent.prototype,"count",{get:function(){return this.eventData.length},enumerable:!1,configurable:!0}),HighlightEvent}();function distanceToLine(point,lineStart,lineEnd){var lineDir=Vector2.sub(lineEnd,lineStart),lineAngle=Vector2.angleRight(lineDir),len=lineDir.magnitude,dir=Vector2.sub(point,lineStart).mutable.rotate(-lineAngle);return dir[0]<0?dir.magnitude:dir[0]>len?Vector2.distance(point,lineEnd):Math.abs(dir.y)}var LineDictionary=function(){function LineDictionary(gridsize,testActive){void 0===gridsize&&(gridsize=10),this.tiles=new Map,this.lineValues=new Map,this.gridsize=gridsize,this.lineSeq=0,this.testActiveFunction=testActive}return LineDictionary.prototype.add=function(points,value,id){var lineID=Number.isFinite(id)?id:++this.lineSeq,line={id:lineID,value:value,segments:[]};this.lineValues.set(lineID,line);for(var i=1;i<points.length;i++){var p1=points[i-1],p2=points[i];this.addSegment(p1[0],p1[1],p2[0],p2[1],line)}return line},LineDictionary.prototype.addSegment=function(x1,y1,x2,y2,line){var _this=this,segment={lineID:line.id,geometry:{x1:x1,y1:y1,x2:x2,y2:y2}};line.segments.push(segment),function(x1,x2,y1,y2,gridsize){var downwards,xMin,xMax,yMin,yMax,m,y0,intersections=new Set;if(x1<x2){xMin=Math.floor(x1/gridsize),xMax=Math.floor(x2/gridsize),y0=(y1-x1*(m=(y2-y1)/(x2-x1)))/gridsize,downwards=y2<y1;var key=Math.floor(x1/gridsize)+"."+Math.floor(y1/gridsize);intersections.add(key)}else xMin=Math.floor(x2/gridsize),xMax=Math.floor(x1/gridsize),y0=(y2-x2*(m=(y1-y2)/(x1-x2)))/gridsize,downwards=y1<y2,key=Math.floor(x2/gridsize)+"."+Math.floor(y2/gridsize),intersections.add(key);y1<y2?(yMin=Math.floor(y1/gridsize),yMax=Math.floor(y2/gridsize)):(yMin=Math.floor(y2/gridsize),yMax=Math.floor(y1/gridsize));for(var x=xMin+1;x<=xMax;x++){var y=y0+x*m;intersections.add(x+"."+Math.floor(y))}for(y=yMin+1;y<=yMax;y++)x=(y-y0)/m,intersections.add(Math.floor(x)+"."+Math.floor(downwards?y-1:y));return intersections}(x1,x2,y1,y2,this.gridsize).forEach((function(key){_this.tiles.has(key)?_this.tiles.get(key).push(segment):_this.tiles.set(key,[segment])}))},LineDictionary.prototype.getClosest=function(target,maxDist){void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0!==segments.size){var minDist=1/0,minLineID=-1;if(segments.forEach((function(seg){var dist=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));dist<minDist&&(minDist=dist,minLineID=seg.lineID)})),!(minDist>maxDist*this.gridsize))return this.lineValues.get(minLineID).value}},LineDictionary.prototype.getAllClosest=function(target,epsilon,maxDist,filter){var _a,_this=this;void 0===epsilon&&(epsilon=0),void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0===segments.size)return[];var minDist=1/0,minID=-1,extraLines=[];if(segments.forEach((function(seg){var distance=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));if(distance<minDist+epsilon)if(distance<minDist){var upperLimit_1=distance+epsilon,newLines_1=[];minDist<=upperLimit_1&&newLines_1.push({ID:minID,distance:minDist}),extraLines.forEach((function(d){d.distance<=upperLimit_1&&newLines_1.push(d)})),extraLines=newLines_1,minDist=distance,minID=seg.lineID}else extraLines.push({ID:seg.lineID,distance:distance})})),minDist>maxDist*this.gridsize)return[];var unique=((_a={})[minID]=!0,_a),uniqueLines=[];extraLines.forEach((function(d){unique.hasOwnProperty(d.ID)||(unique[d.ID]=!0,uniqueLines.push(d))}));var minT=this.lineValues.get(minID).value,extraT=uniqueLines.map((function(d){return _this.lineValues.get(d.ID).value}));if(filter){var filtered_1=[];extraT.forEach((function(curT){filter(minT,curT)&&filtered_1.push(curT)})),extraT=filtered_1}return __spreadArray([minT],extraT)},LineDictionary.prototype.isActive=function(line){return!this.testActiveFunction||line&&this.testActiveFunction(line.value)},LineDictionary.prototype.getSegmentsOn3Grid=function(target){for(var _this=this,gridSegments=new Set,keyX=Math.floor(target[0]/this.gridsize),keyY=Math.floor(target[1]/this.gridsize),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);this.tiles.has(key)&&this.tiles.get(key).forEach((function(tileSegment){gridSegments.has(tileSegment)||_this.isActive(_this.lineValues.get(tileSegment.lineID))&&gridSegments.add(tileSegment)}))}return gridSegments},LineDictionary.prototype.clear=function(filter){var _this=this;if(filter){var segmentsToDelete_1=new Set;this.lineValues.forEach((function(line,key){filter(line.value,key)&&(line.segments.forEach(segmentsToDelete_1.add,segmentsToDelete_1),_this.lineValues.delete(key))})),segmentsToDelete_1.size>0&&this.tiles.forEach((function(list,key){var filtered=list.filter((function(s){return!segmentsToDelete_1.has(s)}));filtered.length>0?_this.tiles.set(key,filtered):_this.tiles.delete(key)}))}else this.tiles=new Map,this.lineValues=new Map},LineDictionary}(),PointDictionary=function(){function PointDictionary(distThreshold,gridSize,radius,testActive){if(void 0===gridSize&&(gridSize=2),this.tiles=new Map,this.pointValues=new Map,this.pointSeq=0,gridSize<radius)throw"Gridsize of point dictionary must be greater than scaled radius of root.";this.distThreshold=distThreshold,this.gridSize=gridSize,this.radius=radius,this.testActiveFunction=testActive}return PointDictionary.prototype.add=function(pos,val){var id=++this.pointSeq,point={val:val,pos:pos,id:id};this.pointValues.set(id,point);for(var keys=this.getKeys(pos),i=0;i<keys.length;i++){var key=keys[i];if(this.tiles.has(key))this.tiles.get(key).set(id,point);else{var map=new Map;map.set(id,point),this.tiles.set(key,map)}}return id},PointDictionary.prototype.getKeys=function(pos){var radius=this.radius,gridSize=this.gridSize,keyX=Math.floor(pos[0]/gridSize),keyY=Math.floor(pos[1]/gridSize),keys=[keyX+"."+keyY],localX=pos[0]-keyX*gridSize,localY=pos[1]-keyY*gridSize,local=[localX,localY],addKey=function(deltaX,deltaY){keys.push(keyX+deltaX+"."+(keyY+deltaY))},tryAddDiagKey=function(cornerLocal,deltaX,deltaY){Vector2.distance(local,cornerLocal)<radius&&keys.push(keyX+deltaX+"."+(keyY+deltaY))},l=!1,r=!1,d=!1,u=!1;return localX<radius&&(addKey(-1,0),l=!0),localX>gridSize-radius&&(addKey(1,0),r=!0),localY<radius&&(addKey(0,-1),d=!0),localY>gridSize-radius&&(addKey(0,1),u=!0),l?u?tryAddDiagKey([0,gridSize],-1,1):d&&tryAddDiagKey([0,0],-1,-1):r&&(u?tryAddDiagKey([gridSize,gridSize],1,1):d&&tryAddDiagKey([gridSize,0],1,-1)),keys},PointDictionary.prototype.isActive=function(point){return!this.testActiveFunction||point&&this.testActiveFunction(point.val)},PointDictionary.prototype.getKey=function(position){return Math.floor(position[0]/this.gridSize)+"."+Math.floor(position[1]/this.gridSize)},PointDictionary.prototype.getOverlapping=function(pos){var key=this.getKey(pos);if(!this.tiles.has(key))return null;for(var points=Array.from(this.tiles.get(key).values()),i=0;i<points.length;i++){var point=points[i];if(Vector2.distance(pos,point.pos)<this.distThreshold)return point}return null},PointDictionary.prototype.getClosestUnder=function(pos,radius){var _this=this;void 0===radius&&(radius=this.radius);var key=this.getKey(pos),minDist=1/0,closest=null;return this.tiles.has(key)?(this.tiles.get(key).forEach((function(point){var distance=Vector2.distance(pos,point.pos);_this.isActive(point)&&distance<radius&&distance<minDist&&(minDist=distance,closest=point)})),closest):null},PointDictionary.prototype.clear=function(filter){var _this=this;filter?this.pointValues.forEach((function(point){if(filter(point.val,point.id)){for(var keys=_this.getKeys(point.pos),i=0;i<keys.length;i++){var key=keys[i],tile=_this.tiles.get(key);tile.delete(point.id),0==tile.size&&_this.tiles.delete(key)}_this.pointValues.delete(point.id)}})):(this.tiles=new Map,this.pointValues=new Map)},PointDictionary}(),Projector=function(){function Projector(project){this.project=project}return Projector.prototype.get=function(coord,zoom){return this.project(coord,zoom)},Projector.prototype.getVector2=function(coord,zoom){return new Vector2(this.project(coord,zoom))},Projector.prototype.batch=function(coords,zoom){for(var output=new Array(coords.length),i=0;i<coords.length;i++)output[i]=this.project(coords[i],zoom);return output},Projector.prototype.batchVector2=function(coords,zoom){for(var output=new Array(coords.length),i=0;i<coords.length;i++)output[i]=new Vector2(this.project(coords[i],zoom));return output},Projector}();function forceHighlight(module,wellbore){var highlight=module.highlight,pixiOverlay=module.pixiOverlay,root=wellbore.root,wellbores=[wellbore];highlight&&!highlight.equals(root,wellbores)&&(highlight.set(root,wellbores),pixiOverlay.redraw())}function clearHighlight(module,onHighlightOff){module.highlight.clear(),onHighlightOff&&onHighlightOff(),module.pixiOverlay.redraw()}var Highlight=function(){function Highlight(){this.active=!1}return Object.defineProperty(Highlight.prototype,"single",{get:function(){return 1==this.wellbores.length},enumerable:!1,configurable:!0}),Object.defineProperty(Highlight.prototype,"first",{get:function(){return this.wellbores[0]},enumerable:!1,configurable:!0}),Highlight.prototype.set=function(root,wellbores){if(!this.active)return this.root=root,this.wellbores=wellbores,this.highlightWellbores(),this.highlightRoot(),void(this.active=!0);this.root!==root||this.wellbores.length!==wellbores.length?(this.clear(),this.root=root,this.wellbores=wellbores,this.highlightWellbores(),this.highlightRoot()):(this.clearWellbores(),this.wellbores=wellbores,this.highlightWellbores()),this.active=!0},Highlight.prototype.highlightRoot=function(){this.root.recalculate(!1)},Highlight.prototype.highlightWellbores=function(){for(var multiple=this.wellbores.length>1,i=0;i<this.wellbores.length;i++)this.wellbores[i].setHighlight(!0,multiple)},Highlight.prototype.clear=function(){this.active&&(this.clearWellbores(),this.clearRoot(),this.active=!1)},Highlight.prototype.clearRoot=function(){this.root.recalculate(!1),delete this.root},Highlight.prototype.clearWellbores=function(){for(var i=0;i<this.wellbores.length;i++)this.wellbores[i].setHighlight(!1);delete this.wellbores},Highlight.prototype.equals=function(root,wellbores){if(this.root!=root)return!1;if(this.wellbores.length!=wellbores.length)return!1;for(var i=0;i<this.wellbores.length;i++){var wellbore=this.wellbores[i];if(!wellbores.includes(wellbore))return!1}return!0},Highlight}(),AsyncLoop=function(){function AsyncLoop(){this.intervals={}}return AsyncLoop.prototype.Start=function(key,config){var _this=this;this.Stop(key);var iterations=config.iterations,batchSize=config.batchSize,func=config.func,postFunc=config.postFunc,endFunc=config.endFunc,front=0;this.intervals[key]=setInterval((function(){if(front>=iterations)return clearInterval(_this.intervals[key]),delete _this.intervals[key],void(endFunc&&endFunc());for(var tail=Math.min(front+batchSize,iterations),i=front;i<tail;i++)func(i);postFunc&&postFunc(),front+=batchSize}),3)},AsyncLoop.prototype.Stop=function(key){key in this.intervals&&(clearInterval(this.intervals[key]),delete this.intervals[key])},AsyncLoop.prototype.StopAll=function(){for(var keys=Object.keys(this.intervals),i=0;i<keys.length;i++){var key=keys[i];clearInterval(this.intervals[key]),delete this.intervals[key]}},AsyncLoop}(),DefaultEventHandler=function(){function DefaultEventHandler(){}return DefaultEventHandler.prototype.register=function(map,element,callbacks){this.map=map,this.element=element,this.callbacks=callbacks,element.addEventListener("mousemove",this.callbacks.mousemove),element.addEventListener("mouseout",this.callbacks.mouseout),element.addEventListener("click",this.callbacks.click),element.addEventListener("mousedown",this.callbacks.mousedown),element.addEventListener("mouseup",this.callbacks.mouseup)},DefaultEventHandler.prototype.unregister=function(){var element=this.element;element.removeEventListener("mousemove",this.callbacks.mousemove),element.removeEventListener("mouseout",this.callbacks.mouseout),element.removeEventListener("click",this.callbacks.click),element.removeEventListener("mousedown",this.callbacks.mousedown),element.removeEventListener("mouseup",this.callbacks.mouseup),this.map=null,this.element=null},DefaultEventHandler}(),RealtimeWellbore=function(){function RealtimeWellbore(mapInput,wellbore){if(this.prevCoords=[Number.MIN_VALUE,Number.MIN_VALUE],mapInput.utils&&"getMap"in mapInput.utils){var pixiOverlay=mapInput;this.map=pixiOverlay.utils.getMap()}else this.map=mapInput;this.root=wellbore.data.path[0]}return Object.defineProperty(RealtimeWellbore.prototype,"pixelCoordinates",{get:function(){var map=this.map,containerPoint=map.latLngToContainerPoint(this.root),rect=map.getContainer().getBoundingClientRect(),coords=[rect.x+containerPoint.x,rect.y+containerPoint.y];return this.prevCoords=coords,coords},enumerable:!1,configurable:!0}),RealtimeWellbore.prototype.getPixelCoordinates=function(){var prevCoords=this.prevCoords,coords=this.pixelCoordinates;return{coords:coords,changed:!this.coordinatesEqual(coords,prevCoords,1e-5)}},RealtimeWellbore.prototype.coordinatesEqual=function(c1,c2,delta){return!(Math.abs(c1[0]-c2[0])>delta)&&!(Math.abs(c1[1]-c2[1])>delta)},RealtimeWellbore}(),WellboreModule=function(_super){function WellboreModule(inputConfig){var _this=_super.call(this)||this;_this.groups={},_this.roots=[],_this.asyncLoop=new AsyncLoop,_this.highlight=new Highlight,_this.currentZoom=20;var _a=function(input){var outputConfig={scale:1,batchSize:15,zoomOrigin:0,gridSize:2,wellboreResize:{min:{zoom:10,scale:.01},max:{zoom:18,scale:.001}},rootResize:{min:{zoom:0,scale:1e3},max:{zoom:18,scale:.2}},tick:{width:.02,height:.2}},outputExtra={labelBgOpacity:.5,labelScale:.011,fontSize:18,scaling:void 0,wellboreDash:.01};if(!input)return[outputConfig,outputExtra];function transfer(key,target){isNaN(input[key])||(target[key]=input[key])}function transferFunction(key,target){"function"==typeof input[key]&&(target[key]=input[key])}function transferObj(key,target){input[key]&&(target[key]=input[key])}return transfer("rootRadius",outputConfig),transfer("batchSize",outputConfig),transfer("zoomOrigin",outputConfig),transfer("gridSize",outputConfig),transfer("labelBgOpacity",outputExtra),transfer("labelScale",outputExtra),transfer("fontSize",outputExtra),transfer("wellboreDash",outputExtra),transferFunction("scaling",outputExtra),transferFunction("onWellboreClick",outputConfig),transferFunction("onHighlightOn",outputConfig),transferFunction("onHighlightOff",outputConfig),transferObj("wellboreResize",outputConfig),transferObj("rootResize",outputConfig),transferObj("tick",outputConfig),[outputConfig,outputExtra]}(inputConfig),config=_a[0],extra=_a[1];_this.config=config,_this.scaling=extra.scaling,_this.lineDict=new LineDictionary(config.gridSize,(function(value){return value.active})),_this.pointDict=new PointDictionary(.25,10*config.gridSize,_this.getRootRadius(20),(function(value){return value.active})),_this.registerGroup("default");var createContainer=function(){var container=new PIXI.Container;return container.sortableChildren=!0,_this.root.addChild(container),container};return _this.containers={wellbores:createContainer(),roots:createContainer(),labels:createContainer()},Label.setStyle(extra.fontSize),Label.setCommon({backgroundOpacity:extra.labelBgOpacity}),_this._eventHandler=inputConfig&&inputConfig.customEventHandler||new DefaultEventHandler,RootShader.build(config.rootResize.max.scale),WellboreShader.build(config.wellboreResize.max.scale,extra.wellboreDash),_this}return __extends(WellboreModule,_super),WellboreModule.prototype.registerGroup=function(key,options){if(this.groups[key])throw Error("Group ["+key+"] already registered!");this.groups[key]=new Group(key,options)},WellboreModule.prototype.addRoot=function(position){var overlapping=this.pointDict.getOverlapping(position);if(overlapping)return overlapping.val;var wellboreRoot=new RootData(position,this.config.rootResize.max.scale);return this.containers.roots.addChild(wellboreRoot.mesh),this.pointDict.add(position,wellboreRoot),this.roots.push(wellboreRoot),wellboreRoot},WellboreModule.prototype.addWellbore=function(data,group){if(void 0===group&&(group=this.groups.default),0===data.path.length)throw Error("Empty wellbore path!");var projectedPath=this.projector.batchVector2(data.path),root=this.addRoot(projectedPath[0]),_a=this.config,rootResize=_a.rootResize,wellboreResize=_a.wellboreResize,tick=_a.tick,wellbore=new WellboreData({data:data,group:group,root:root,coords:projectedPath,pointThreshold:1.5*rootResize.max.scale,wellboreWidth:wellboreResize.max.scale,tick:tick});wellbore.mesh&&this.containers.wellbores.addChild(wellbore.mesh),this.containers.labels.addChild(wellbore.label.text),this.containers.labels.addChild(wellbore.label.background),group.append(wellbore),wellbore.interpolator.singlePoint||this.lineDict.add(projectedPath,wellbore),root.append(wellbore),this._deferredSelector&&this._deferredSelector(wellbore.data)&&(this._deferredSelector=void 0,wellbore.setSelected(!0))},WellboreModule.prototype.set=function(wells,key){var _this=this;return void 0===key&&(key="default"),new Promise((function(resolve,reject){var group=_this.groups[key];if(group)try{_this.groups[key].wellbores.length>0&&_this.clear(key),_this.asyncLoop.Start(key,{iterations:wells.length,batchSize:20,func:function(i){return _this.addWellbore(wells[i],group)},postFunc:function(){return _this.pixiOverlay.redraw()},endFunc:function(){_this.pixiOverlay.redraw(),resolve()}})}catch(err){reject(err)}else reject(Error("Group ["+key+"] not registered!"))}))},WellboreModule.prototype.forEachGroup=function(keys,func){var _this=this,registeredKeys=Object.keys(this.groups);(keys=0==keys.length?registeredKeys:keys.filter((function(key){return registeredKeys.includes(key)}))).forEach((function(key){return func(_this.groups[key],key)})),this.pixiOverlay.redraw()},WellboreModule.prototype.setActive=function(active,keys){this.forEachGroup(keys,(function(group){return group.setActive(active)}))},WellboreModule.prototype.handleMouseMove=function(event){var latLng=this.pixiOverlay.utils.getMap().mouseEventToLatLng(event);return function(module,pos,onHighlightOn,onHighlightOff,originalEvent){var wellbores;!(wellbores=function(pos,radius,pointDict){var root=pointDict.getClosestUnder(pos,radius);return root?root.val.wellbores.filter((function(d){return d.active})):null}(pos,module.getRootRadius(),module.pointDict))&&module.containers.labels.visible&&(wellbores=function(pos,roots){for(var candidates=roots.filter((function(root){return root.active&&root.rootLabelsBBox&&root.rootLabelsBBox.contains(pos.x,pos.y)})),i=0;i<candidates.length;i++)for(var j=0;j<candidates[i].wellbores.length;j++){var wellbore=candidates[i].wellbores[j];if(wellbore.active&&wellbore.label.attachToRoot){var bbox=wellbore.label.getBoundingBox();if(bbox.y>pos.y)break;if(bbox.contains(pos.x,pos.y))return[wellbore]}}return null}(pos,module.roots)),wellbores||(wellbores=function(pos,lineDict,distanceThreshold){void 0===distanceThreshold&&(distanceThreshold=.5);var hit=lineDict.getClosest(pos,distanceThreshold);return hit?[hit]:null}(pos,module.lineDict,.5));var highlight=module.highlight,pixiOverlay=module.pixiOverlay;if(wellbores){var root=wellbores[0].root,changed=!1;highlight&&!highlight.equals(root,wellbores)&&(changed=!0,highlight.set(root,wellbores),pixiOverlay.redraw()),onHighlightOn&&onHighlightOn(HighlightEvent.from(wellbores,changed,originalEvent))}else highlight&&clearHighlight(module,onHighlightOff)}(this,this.projector.getVector2(latLng),this.config.onHighlightOn,this.config.onHighlightOff,event),this.highlight.active},WellboreModule.prototype.handleMouseOut=function(){return this.clearHighlight(this.config.onHighlightOff)},WellboreModule.prototype.handleMouseClick=function(){if(this.config.onWellboreClick&&this.highlight.active&&this.highlight.single){var wellbore=this.highlight.first;return this.config.onWellboreClick({group:wellbore.group.key,data:wellbore.data}),!0}return!1},WellboreModule.prototype.enable=function(){for(var keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];this.setActive(!0,keys)},WellboreModule.prototype.disable=function(){for(var keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];this.setActive(!1,keys)},WellboreModule.prototype.setLabelVisibility=function(visible){Label.state.visible=visible,this.roots.forEach((function(root){return root.setLabelVisibility(visible)})),this.pixiOverlay.redraw()},WellboreModule.prototype.setCompletionVisibility=function(visible){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];this.forEachGroup(keys,(function(group){return group.setCompletionVisibility(visible)}))},WellboreModule.prototype.setWellboresVisibility=function(visible){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];this.forEachGroup(keys,(function(group){return group.setWellboreVisibility(visible)}))},WellboreModule.prototype.softFilter=function(filterFunction){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];this.forEachGroup(keys,(function(group){return group.softFilter(filterFunction)}))},WellboreModule.prototype.hardFilter=function(filterFunction){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];this.forEachGroup(keys,(function(group){return group.hardFilter(filterFunction)}))},WellboreModule.prototype.clearFilter=function(){for(var keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];this.forEachGroup(keys,(function(group){return group.clearFilter()}))},WellboreModule.prototype.setSelected=function(selectFunction){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];var nSelected=0;this.forEachGroup(keys,(function(group){group&&group.wellbores.forEach((function(wellbore){selectFunction(wellbore.data)?(wellbore.setSelected(!0),nSelected++):wellbore.selected&&wellbore.setSelected(!1)}))})),0===nSelected&&(this._deferredSelector=selectFunction)},WellboreModule.prototype.clearSelected=function(){for(var keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];this.forEachGroup(keys,(function(group){group&&group.wellbores.forEach((function(wellbore){wellbore.selected&&wellbore.setSelected(!1)}))}))},WellboreModule.prototype.setHighlight=function(label){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];var registeredKeys=Object.keys(this.groups);keys=0==keys.length?registeredKeys:keys.filter((function(key){return registeredKeys.includes(key)}));for(var n=0;n<keys.length;n++){var group=this.groups[keys[n]];if(group)for(var wellbores=group.wellbores,i=0;i<wellbores.length;i++){var wellbore=wellbores[i];if(wellbore.data.label===label)return forceHighlight(this,wellbore),new RealtimeWellbore(this.pixiOverlay,wellbore)}}return null},WellboreModule.prototype.clearHighlight=function(onHighlightOff){return!!this.highlight.active&&(clearHighlight(this,onHighlightOff),!0)},WellboreModule.prototype.clearAll=function(){this.highlight.clear(),this.asyncLoop.StopAll(),this.lineDict.clear(),this.pointDict.clear(),Object.values(this.groups).forEach((function(g){g.wellbores=[]})),this.roots=[],this.containers.wellbores.removeChildren(),this.containers.labels.removeChildren(),this.containers.roots.removeChildren(),this.pixiOverlay.redraw()},WellboreModule.prototype.clear=function(){for(var _this=this,keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];if(0===keys.length)return this.clearAll();this.highlight.clear();var roots=new Set;this.forEachGroup(keys,(function(group,key){_this.asyncLoop.Stop(key),_this.lineDict.clear((function(d){return group.wellbores.includes(d)})),group.wellbores.forEach((function(w){roots.add(w.root);var wellboreIdx=w.root.wellbores.indexOf(w);-1!==wellboreIdx&&w.root.wellbores.splice(wellboreIdx,1),_this.containers.wellbores.removeChild(w.mesh),_this.containers.labels.removeChild(w.label.text),_this.containers.labels.removeChild(w.label.background)})),group.wellbores=[]})),roots.forEach((function(root){if(root.wellbores.length>0)root.recalculate(!0);else{var rootIdx=_this.roots.indexOf(root);-1!==rootIdx&&_this.roots.splice(rootIdx,1),_this.pointDict.clear((function(d){return d===root})),_this.containers.roots.removeChild(root.mesh)}})),this.pixiOverlay.redraw()},WellboreModule.prototype.resize=function(zoom){this.currentZoom=zoom;var wellboreRadius=this.getWellboreRadius(zoom),rootRadius=this.getRootRadius(zoom);if(this.pixiOverlay._renderer.globalUniforms.uniforms.wellboreRadius=wellboreRadius,this.pixiOverlay._renderer.globalUniforms.uniforms.rootRadius=rootRadius,this.scaling){var scale=this.scaling(zoom-this.config.zoomOrigin);Number.isFinite(scale)||(scale=1),Label.state.zoom=zoom,Label.state.scale=scale,Label.state.rootDisplacement=rootRadius;var labelVisible=zoom>10;this.containers.labels.visible=labelVisible,labelVisible&&Label.state.visible&&this.roots.forEach((function(root){return root.updateLabels()}))}},WellboreModule.prototype.onAdd=function(map){var element=this.pixiOverlay.utils.getRenderer().view.parentNode,callbacks={mousemove:this.handleMouseMove.bind(this),mouseout:this.handleMouseOut.bind(this),click:this.handleMouseClick.bind(this),mousedown:function(){return!0},mouseup:function(){return!0}};this._eventHandler.register(map,element,callbacks)},WellboreModule.prototype.onRemove=function(map){this._eventHandler.unregister()},Object.defineProperty(WellboreModule.prototype,"projector",{get:function(){return this._projector||(this._projector=new Projector(this.pixiOverlay.utils.latLngToLayerPoint)),this._projector},enumerable:!1,configurable:!0}),WellboreModule.prototype.getRootRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),this.getRadius(zoom,this.config.rootResize)},WellboreModule.prototype.getWellboreRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),this.getRadius(zoom,this.config.wellboreResize)},WellboreModule.prototype.getRadius=function(zoom,_a){var min=_a.min,max=_a.max,zoomClamped=clamp(zoom,min.zoom,max.zoom)-min.zoom,t=Math.pow(2,-zoomClamped);return lerp(max.scale,min.scale,t)},WellboreModule}(ModuleInterface);function centerOfMass(vertices,triangles){for(var comX=0,comY=0,totalMass=0,i=0;i<triangles.length;i+=3){var a=vertices[triangles[i]],b=vertices[triangles[i+1]],c=vertices[triangles[i+2]],ab=Vector2.sub(b,a),ac=Vector2.sub(c,a),mass=.5*Vector2.cross(ab,ac);comX+=mass*(a.x+b.x+c.x)/3,comY+=mass*(a.y+b.y+c.y)/3,totalMass+=mass}return[new Vector2(comX/totalMass,comY/totalMass),totalMass]}var Hightlighter=function(){function Hightlighter(fillColor1,fillColor2,outlineColor){this.fields=[],this.cached=[],this.fillColor1=fillColor1,this.fillColor2=fillColor2,this.outlineColor=outlineColor}return Hightlighter.prototype.add=function(group){this.fields.push(group)},Hightlighter.prototype.highlight=function(index){var target=this.fields[index];this.cached&&this.revert(),this.cached=new Array(target.length);for(var i=0;i<target.length;i++){var field=target[i];this.cached[i]={fillCol1:field.fill.uniform.col1,fillCol2:field.fill.uniform.col2,outlineCol:field.outline.uniform.color,baseZIndex:field.fill.mesh.zIndex,field:field},field.fill.uniform.col1=this.fillColor1,field.fill.uniform.col2=this.fillColor2,field.fill.mesh.zIndex+=1e4,field.outline.uniform.color=this.outlineColor,field.outline.mesh.zIndex+=1e4}},Hightlighter.prototype.revert=function(){return!!this.cached&&(this.cached.forEach((function(d){d.field.fill.uniform.col1=d.fillCol1,d.field.fill.uniform.col2=d.fillCol2,d.field.fill.mesh.zIndex=d.baseZIndex,d.field.outline.uniform.color=d.outlineCol,d.field.outline.mesh.zIndex=d.baseZIndex+1})),this.cached=void 0,!0)},Hightlighter}();function recalculatePosition(labels,selfIndex,targetIndiced){var self=labels[selfIndex],comX=self.mass*self.position[0],comY=self.mass*self.position[1],totalMass=self.mass;return targetIndiced.forEach((function(idx){var target=labels[idx];comX+=target.mass*target.position[0],comY+=target.mass*target.position[1],totalMass+=target.mass})),[comX/totalMass,comY/totalMass]}var LabelManager=function(){function LabelManager(textStyle,baseScale){this.fields=[],this.multiFields=[],this.prevScale=1,this.visible=!0,this.textStyle=textStyle,this.baseScale=baseScale}return LabelManager.prototype.addField=function(name,entries){if(entries.length<=1)this.fields.push({name:name,position:entries[0].position,instance:null});else{var textMetrics=PIXI.TextMetrics.measureText(name,this.textStyle),width=textMetrics.width*this.baseScale,height=textMetrics.height*this.baseScale,labels=entries.map((function(entry){return{position:entry.position,mass:entry.mass,instance:null,active:!0,consumed:[],consumer:-1}}));this.multiFields.push({name:name,labels:labels,width:width,height:height})}},LabelManager.prototype.draw=function(root){var _this=this,drawLabel=function(name,position){var instance=new PIXI.Text(name,_this.textStyle);return instance.resolution=2,instance.position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor.set(.5),instance.zIndex=1e5,root.addChild(instance),instance};this.fields.forEach((function(field){field.instance=drawLabel(field.name,field.position)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance=drawLabel(field.name,label.position)}))}))},LabelManager.prototype.resize=function(scale){var _this=this;this.fields.forEach((function(field){field.instance.scale.set(scale*_this.baseScale)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.scale.set(scale*_this.baseScale)}));for(var centers=function(field,scale){for(var labels=field.labels,groups=[],i=0;i<labels.length;i++)groups.push({index:i,consumed:[],consumer:-1});for(i=0;i<labels.length;i++)if(!((group=groups[i]).consumer>=0))for(var label=labels[i],_loop_1=function(j){var _a;if(i===j)return"continue";var a,b,dist,compLabel=labels[j];if(a=label,b=compLabel,dist=Vector2.sub(a.position,b.position),Math.abs(dist[0])<field.width*scale&&Math.abs(dist[1])<field.height*scale){var compIndex_1=j,compGroup=groups[j];if(compGroup.consumer>=0){if((compIndex_1=compGroup.consumer)===i)return"continue";compGroup=groups[compGroup.consumer]}return(_a=compGroup.consumed).push.apply(_a,__spreadArray(__spreadArray([],group.consumed),[i])),group.consumed.forEach((function(d){return groups[d].consumer=compIndex_1})),group.consumed=[],group.consumer=compIndex_1,"break"}},j=0;j<labels.length&&"break"!==_loop_1(j);j++);var output=[];for(i=0;i<groups.length;i++){var group;(group=groups[i]).consumer>=0||output.push(recalculatePosition(labels,group.index,group.consumed))}return output}(field,scale),i=0;i<centers.length;i++){var label=field.labels[i],pos=centers[i];label.instance.visible=!0,label.instance.position.set(pos[0],pos[1])}for(i=centers.length;i<field.labels.length;i++){(label=field.labels[i]).instance.visible=!1}})),this.prevScale=scale},LabelManager.prototype.hideLabels=function(){this.fields.forEach((function(field){field.instance.visible=!1})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.visible=!1}))})),this.visible=!1},LabelManager.prototype.showLabels=function(){this.fields.forEach((function(field){field.instance.visible=!0})),this.visible=!0},LabelManager}();var TriangleDictionary=function(){function TriangleDictionary(decimals){void 0===decimals&&(decimals=0),this.tiles=new Map,this.triangles=[],this.polygonValues=[],this.resolution=Math.pow(10,decimals)}return TriangleDictionary.prototype.add=function(vertices,triangles,value){var v1,v2,v3,polygonID=this.polygonValues.length;this.polygonValues.push(value);for(var i=0;i<triangles.length;i+=3){var triangleID=this.triangles.length;v1=vertices[triangles[i]],v2=vertices[triangles[i+1]],v3=vertices[triangles[i+2]],this.triangles.push({v1:v1,v2:v2,v3:v3,polygonID:polygonID});for(var minX=Math.min(v1[0],v2[0],v3[0]),maxX=Math.max(v1[0],v2[0],v3[0]),minY=Math.min(v1[1],v2[1],v3[1]),maxY=Math.max(v1[1],v2[1],v3[1]),tileMinX=Math.floor(minX*this.resolution),tileMaxX=Math.floor(maxX*this.resolution),tileMinY=Math.floor(minY*this.resolution),tileMaxY=Math.floor(maxY*this.resolution),x=tileMinX;x<=tileMaxX;x++)for(var y=tileMinY;y<=tileMaxY;y++){var key=x+"."+y;this.tiles.has(key)?this.tiles.get(key).push(triangleID):this.tiles.set(key,[triangleID])}}},TriangleDictionary.prototype.getPolygonAt=function(target){var key=Math.floor(target[0]*this.resolution)+"."+Math.floor(target[1]*this.resolution);if(!this.tiles.has(key))return null;for(var p,v1,v2,v3,k1,k2,k3,triangles=this.tiles.get(key),i=0;i<triangles.length;i++){var triangle=this.triangles[triangles[i]];if(p=target,v1=triangle.v1,v2=triangle.v2,v3=triangle.v3,k1=void 0,k2=void 0,k3=void 0,k1=(p[0]-v1[0])*(v2[1]-v1[1])-(p[1]-v1[1])*(v2[0]-v1[0]),k2=(p[0]-v2[0])*(v3[1]-v2[1])-(p[1]-v2[1])*(v3[0]-v2[0]),k3=(p[0]-v3[0])*(v1[1]-v3[1])-(p[1]-v3[1])*(v1[0]-v3[0]),k1<0?k2<0&&k3<0:k2>=0&&k3>=0)return this.polygonValues[triangle.polygonID]}return null},TriangleDictionary}(),red=[.8,0,0],green=[.133,.6,.133],pink=[1,.753,.796],gray=[.6,.6,.6],outlineRed=[.6,0,0],outlineGray=[.5,.5,.5],FieldModule=function(_super){function FieldModule(config){var _this=_super.call(this)||this;return _this.fields=[],_this.config={initialHash:1,minHash:0,maxHash:1/0},_this.dict=new TriangleDictionary(1.2),_this.prevField=-1,config?(config.initialHash&&"number"==typeof config.initialHash&&(_this.config.initialHash=config.initialHash),config.minHash&&"number"==typeof config.minHash&&(_this.config.minHash=config.minHash),config.maxHash&&"number"==typeof config.maxHash&&(_this.config.maxHash=config.maxHash),_this):_this}return __extends(FieldModule,_super),FieldModule.prototype.set=function(data){var _this=this;this.config.initialHash=clamp(this.config.initialHash),this.fields=[];var textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:64,fontWeight:"600",fill:4539717,align:"center"});this.labelManager=new LabelManager(textStyle,.029),this.highlighter=new Hightlighter([.5,0,.5],[.25,0,.25],[.35,0,.35]);var preprocessedData=function(data){var unique={};return data.forEach((function(field){var fieldName=field.properties.label,coordinates=[],geometry=field.geometry;if("Polygon"===geometry.type)coordinates=geometry.coordinates;else for(var multipolygons=geometry.coordinates,i=0;i<multipolygons.length;i++)coordinates.push.apply(coordinates,multipolygons[i]);function appendIndex(index){unique[fieldName].geometry.push({coordinates:coordinates[index],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}})}if(unique.hasOwnProperty(fieldName))for(i=0;i<coordinates.length;i++)appendIndex(i);else if(unique[fieldName]={type:field.type,geometry:[{coordinates:coordinates[0],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}}],properties:{group:field.properties.group,guid:field.properties.guid,label:field.properties.label,lat:field.properties.lat,long:field.properties.long}},coordinates.length>1)for(i=1;i<coordinates.length;i++)appendIndex(i)})),Object.values(unique)}(data),fieldID=0,baseZIndex=0;preprocessedData.forEach((function(field){var _a,name=field.properties.label;if("Troll"!==name){var guid=field.properties.guid,entries=[],meshes=[];field.geometry.forEach((function(polygon){var fieldStyle=_this.getFieldStyle(guid,polygon.properties.hctype),projected=_this.projectPolygons(polygon.coordinates);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(polygon.coordinates,meshData.triangles,fieldID);var outlineData=Mesh.PolygonOutline(projected,.15),_a=centerOfMass(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(meshData,outlineData,fieldStyle,baseZIndex)),baseZIndex+=2,entries.push({position:position,mass:mass})})),fieldID++,_this.labelManager.addField(name,entries),(_a=_this.fields).push.apply(_a,meshes),_this.highlighter.add(meshes)}})),this.labelManager.draw(this.root)},FieldModule.prototype.drawPolygons=function(meshData,outlineData,fieldStyle,zIndex){var fillUniform={col1:fieldStyle.fillColor1,col2:fieldStyle.fillColor2,opacity:fieldStyle.fillOpacity,hashed:fieldStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},outlineUniform={color:fieldStyle.outlineColor,width:0},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,FieldModule.vertexShaderFill,FieldModule.fragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,this.root.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,FieldModule.vertexShaderOutline,FieldModule.fragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,this.root.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},FieldModule.prototype.getFieldStyle=function(guid,hctype){if(!guid)return{fillColor1:gray,fillColor2:gray,outlineColor:outlineGray,fillOpacity:.15,hashed:!1};var fill={fillColor1:green,fillColor2:green,outlineColor:green,fillOpacity:.6,hashed:!1};switch(hctype){case"GAS":fill.fillColor1=red,fill.fillColor2=red,fill.outlineColor=outlineRed;break;case"GAS/CONDENSATE":fill.fillColor1=pink,fill.fillColor2=red,fill.outlineColor=outlineRed,fill.hashed=!0;break;case"OIL/GAS":fill.fillColor1=red,fill.hashed=!0}return fill},FieldModule.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},FieldModule.prototype.resize=function(zoom){},FieldModule.prototype.highlight=function(lat,long){var field=this.dict.getPolygonAt([long,lat]);return field?(this.prevField===field||(this.highlighter.highlight(field),this.pixiOverlay.redraw(),this.prevField=field),!0):(this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1,!1)},FieldModule.prototype.tryUnselect=function(){this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1},FieldModule}(ModuleInterface);FieldModule.vertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2, 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1, 1.0) * opacity;\n }\n }\n",FieldModule.vertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color, 1.0);\n }\n";var GeoJSONLabels=function(){function GeoJSONLabels(root,textStyle,baseScale,fontName){this.labels=[],this.visible=!0,this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.textStyle=textStyle,this.baseScale=baseScale,this.fontName=fontName||v4(),this.font=PIXI.BitmapFont.from(this.fontName,this.textStyle,{resolution:window.devicePixelRatio,chars:PIXI.BitmapFont.ASCII})}return GeoJSONLabels.prototype.addLabel=function(name,data){this.labels.push({name:name,position:data.position,instance:null})},GeoJSONLabels.prototype.draw=function(){var _this=this;this.labels.forEach((function(label){var name,position,instance;label.instance=(name=label.name,position=label.position,(instance=new PIXI.BitmapText(name,{fontName:_this.fontName})).position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor=new PIXI.Point(.5,.5),instance.zIndex=1e3,_this.container.addChild(instance),instance)}))},GeoJSONLabels.prototype.hideLabels=function(){this.container.visible=!1,this.visible=!1},GeoJSONLabels.prototype.showLabels=function(){this.container.visible=!0,this.visible=!0},GeoJSONLabels.prototype.resize=function(scale){this.labels.forEach((function(lbl){return lbl.instance.scale.set(scale)}))},GeoJSONLabels}(),GeoJSONVertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n ",GeoJSONFragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2 / 255., 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1 / 255., 1.0) * opacity;\n }\n }\n ",GeoJSONVertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float outlineWidth;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * outlineWidth;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n ",GeoJSONFragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color / 255., 1.0);\n }\n ";function getRadius(zoom,_a){var min=_a.min,max=_a.max,zoomClamped=clamp(zoom,min.zoom,max.zoom)-min.zoom,t=Math.pow(2,-zoomClamped);return lerp(max.scale,min.scale,t)}var Defaults=function(){function Defaults(){}return Defaults.DEFAULT_Z_INDEX=1e3,Defaults.DEFAULT_LINE_WIDTH=.15,Defaults.INITIAL_ZOOM=20,Defaults.DEFAULT_FONT_FAMILY="Arial",Defaults.DEFAULT_FONT_SIZE=64,Defaults.DEFAULT_FONT_WEIGHT="600",Defaults.DEFAULT_LABEL_COLOR=4539717,Defaults.DEFAULT_LABEL_ALIGN="center",Defaults.INITIAL_HASH=1,Defaults.DEFAULT_MIN_HASH=0,Defaults.DEFAULT_BASE_SCALE=.1,Defaults}(),GeoJSONMultiPolygon=function(){function GeoJSONMultiPolygon(root,labelRoot,pixiOverlay,config){var _a;this.features=[],this.config={initialHash:Defaults.INITIAL_HASH,minHash:Defaults.DEFAULT_MIN_HASH,maxHash:1/0},this.dict=new TriangleDictionary(1.2),this.currentZoom=Defaults.INITIAL_ZOOM,(null==config?void 0:config.initialHash)&&"number"==typeof config.initialHash&&(this.config.initialHash=config.initialHash),(null==config?void 0:config.minHash)&&"number"==typeof config.minHash&&(this.config.minHash=config.minHash),(null==config?void 0:config.maxHash)&&"number"==typeof config.maxHash&&(this.config.maxHash=config.maxHash),this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.pixiOverlay=pixiOverlay,this.features=[],this.config=config,this.config.initialHash=clamp(this.config.initialHash),this.textStyle=new PIXI.TextStyle({fontFamily:(null==config?void 0:config.labelFontFamily)||Defaults.DEFAULT_FONT_FAMILY,fontSize:(null==config?void 0:config.labelFontSize)||Defaults.DEFAULT_FONT_SIZE,fontWeight:(null==config?void 0:config.labelFontWeight)||Defaults.DEFAULT_FONT_WEIGHT,fill:(null==config?void 0:config.labelColor)||Defaults.DEFAULT_LABEL_COLOR,align:(null==config?void 0:config.labelAlign)||Defaults.DEFAULT_LABEL_ALIGN}),this.labels=new GeoJSONLabels(labelRoot||this.container,this.textStyle,(null===(_a=this.config.labelResize)||void 0===_a?void 0:_a.baseScale)||Defaults.DEFAULT_BASE_SCALE)}return GeoJSONMultiPolygon.prototype.add=function(feature,props){var _a,_this=this,geom=feature.geometry,properties=props(feature);properties.style.labelScale&&(this.labels.baseScale=properties.style.labelScale);var meshes=[],coordinateGroup=geom.coordinates;(null==coordinateGroup?void 0:coordinateGroup.length)>0&&(coordinateGroup.forEach((function(coordinates){var projected=_this.projectPolygons(coordinates[0]);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(coordinates[0],meshData.triangles,feature.properties);var outlineData=Mesh.PolygonOutline(projected,Defaults.DEFAULT_LINE_WIDTH),_a=centerOfMass(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(_this.container,meshData,outlineData,properties.style,Defaults.DEFAULT_Z_INDEX)),properties.label&&_this.labels.addLabel(properties.label,{position:position,mass:mass})})),(_a=this.features).push.apply(_a,meshes))},GeoJSONMultiPolygon.prototype.drawPolygons=function(container,meshData,outlineData,featureStyle,zIndex){var fillColor=featureStyle.fillColor?color(featureStyle.fillColor).rgb():void 0,fillColor2=featureStyle.fillColor2?color(featureStyle.fillColor2).rgb():void 0,fillUniform={col1:fillColor?[fillColor.r,fillColor.g,fillColor.b]:[0,0,0],col2:fillColor2?[fillColor2.r,fillColor2.g,fillColor2.b]:[0,0,0],opacity:featureStyle.fillOpacity,hashed:featureStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},lineColor=color(featureStyle.lineColor).rgb(),outlineUniform={color:[lineColor.r,lineColor.g,lineColor.b],outlineWidth:featureStyle.lineWidth},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,GeoJSONVertexShaderFill,GeoJSONFragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,container.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,GeoJSONVertexShaderOutline,GeoJSONFragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,container.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},GeoJSONMultiPolygon.prototype.drawLabels=function(){this.labels.draw()},GeoJSONMultiPolygon.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},GeoJSONMultiPolygon.prototype.resize=function(zoom){if(this.config.outlineResize){var outlineRadius=this.getOutlineRadius(zoom);if(this.config.labelResize){var labelSize=this.getLabelSize(zoom);zoom<=this.config.labelResize.threshold?this.labels.hideLabels():(this.labels.showLabels(),this.labels.resize(labelSize))}this.container.children.map((function(child){child.shader.uniformGroup.uniforms.outlineWidth&&(child.shader.uniformGroup.uniforms.outlineWidth=outlineRadius)})),this.currentZoom=zoom}},GeoJSONMultiPolygon.prototype.testPosition=function(pos){return this.dict.getPolygonAt([pos.x,pos.y])},GeoJSONMultiPolygon.prototype.getOutlineRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.outlineResize)},GeoJSONMultiPolygon.prototype.getLabelSize=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.labelResize)},GeoJSONMultiPolygon}(),GeoJSONPolygon=function(){function GeoJSONPolygon(root,labelRoot,pixiOverlay,config){var _a;this.features=[],this.config={initialHash:Defaults.INITIAL_HASH,minHash:Defaults.DEFAULT_MIN_HASH,maxHash:1/0},this.dict=new TriangleDictionary(1.2),this.currentZoom=Defaults.INITIAL_ZOOM,this.outlineThickness=Defaults.DEFAULT_LINE_WIDTH,this.zIndex=Defaults.DEFAULT_Z_INDEX,(null==config?void 0:config.initialHash)&&"number"==typeof config.initialHash&&(this.config.initialHash=config.initialHash),(null==config?void 0:config.minHash)&&"number"==typeof config.minHash&&(this.config.minHash=config.minHash),(null==config?void 0:config.maxHash)&&"number"==typeof config.maxHash&&(this.config.maxHash=config.maxHash),this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.pixiOverlay=pixiOverlay,this.features=[],this.config=config,this.config.initialHash=clamp(this.config.initialHash),this.textStyle=new PIXI.TextStyle({fontFamily:(null==config?void 0:config.labelFontFamily)||Defaults.DEFAULT_FONT_FAMILY,fontSize:(null==config?void 0:config.labelFontSize)||Defaults.DEFAULT_FONT_SIZE,fontWeight:(null==config?void 0:config.labelFontWeight)||Defaults.DEFAULT_FONT_WEIGHT,fill:(null==config?void 0:config.labelColor)||Defaults.DEFAULT_LABEL_COLOR,align:(null==config?void 0:config.labelAlign)||Defaults.DEFAULT_LABEL_ALIGN}),this.labels=new GeoJSONLabels(labelRoot||this.container,this.textStyle,(null===(_a=this.config.labelResize)||void 0===_a?void 0:_a.baseScale)||Defaults.DEFAULT_BASE_SCALE)}return GeoJSONPolygon.prototype.add=function(feature,props){var _a,geom=feature.geometry,properties=props(feature);properties.style.labelScale&&(this.labels.baseScale=properties.style.labelScale);var meshes=[],coordinates=geom.coordinates;if((null==coordinates?void 0:coordinates.length)>0){var projected=this.projectPolygons(coordinates[0]);projected.pop();var meshData=Mesh.Polygon(projected);this.dict.add(coordinates[0],meshData.triangles,feature.properties);var outlineData=Mesh.PolygonOutline(projected,this.outlineThickness),_b=centerOfMass(projected,meshData.triangles),position=_b[0],mass=_b[1];meshes.push(this.drawPolygons(this.container,meshData,outlineData,properties.style,this.zIndex)),properties.label&&this.labels.addLabel(properties.label,{position:position,mass:mass}),(_a=this.features).push.apply(_a,meshes)}},GeoJSONPolygon.prototype.drawPolygons=function(container,meshData,outlineData,featureStyle,zIndex){var fillColor=featureStyle.fillColor?color(featureStyle.fillColor).rgb():void 0,fillColor2=featureStyle.fillColor2?color(featureStyle.fillColor2).rgb():void 0,fillUniform={col1:fillColor?[fillColor.r,fillColor.g,fillColor.b]:[0,0,0],col2:fillColor2?[fillColor2.r,fillColor2.g,fillColor2.b]:[0,0,0],opacity:featureStyle.fillOpacity,hashed:featureStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},lineColor=color(featureStyle.lineColor).rgb(),outlineUniform={color:[lineColor.r,lineColor.g,lineColor.b],outlineWidth:featureStyle.lineWidth},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,GeoJSONVertexShaderFill,GeoJSONFragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,container.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,GeoJSONVertexShaderOutline,GeoJSONFragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,container.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},GeoJSONPolygon.prototype.drawLabels=function(){this.labels.draw()},GeoJSONPolygon.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},GeoJSONPolygon.prototype.resize=function(zoom){if(this.config.outlineResize){var outlineRadius=this.getOutlineRadius(zoom);if(this.config.labelResize){var labelSize=this.getLabelSize(zoom);zoom<=this.config.labelResize.threshold?this.labels.hideLabels():(this.labels.showLabels(),this.labels.resize(labelSize))}this.container.children.map((function(child){child.shader.uniformGroup.uniforms.outlineWidth&&(child.shader.uniformGroup.uniforms.outlineWidth=outlineRadius)})),this.currentZoom=zoom}},GeoJSONPolygon.prototype.testPosition=function(pos){return this.dict.getPolygonAt([pos.x,pos.y])},GeoJSONPolygon.prototype.getOutlineRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.outlineResize)},GeoJSONPolygon.prototype.getLabelSize=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.labelResize)},GeoJSONPolygon}(),GeoJSONLineString=function(){function GeoJSONLineString(root,pixiOverlay,config){this.features=[],this.config={},this.dict=new LineDictionary(1.2),this.currentZoom=Defaults.INITIAL_ZOOM,this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.pixiOverlay=pixiOverlay,this.features=[],this.config=config}return GeoJSONLineString.prototype.add=function(feature,props){var _a,geom=feature.geometry,properties=props(feature),meshes=[],coordinates=geom.coordinates;if((null==coordinates?void 0:coordinates.length)>0){var projected=this.projectPolygons(coordinates);projected.pop(),this.dict.add(projected,feature.properties);var outlineData=Mesh.SimpleLine(projected,Defaults.DEFAULT_LINE_WIDTH);meshes.push(this.drawPolygons(this.container,outlineData,properties.style,Defaults.DEFAULT_Z_INDEX)),(_a=this.features).push.apply(_a,meshes)}},GeoJSONLineString.prototype.drawPolygons=function(container,outlineData,featureStyle,zIndex){var lineColor=color(featureStyle.lineColor).rgb(),outlineUniform={color:[lineColor.r,lineColor.g,lineColor.b],width:featureStyle.lineWidth},polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,GeoJSONVertexShaderOutline,GeoJSONFragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex,container.addChild(polygonOutlineMesh),{outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},GeoJSONLineString.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},GeoJSONLineString.prototype.resize=function(zoom){if(this.config.outlineResize){var outlineRadius=this.getOutlineRadius(zoom);this.container.children.map((function(child){child.shader.uniformGroup.uniforms.outlineWidth&&(child.shader.uniformGroup.uniforms.outlineWidth=outlineRadius)})),this.currentZoom=zoom}},GeoJSONLineString.prototype.testPosition=function(pos){return this.dict.getClosest(pos)},GeoJSONLineString.prototype.getOutlineRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.outlineResize)},GeoJSONLineString}(),GeoJSONPoint=function(){function GeoJSONPoint(root,pixiOverlay){this.spawned=[],this.pool=[],this.dict=new PointDictionary(.25,20,4),this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.pixiOverlay=pixiOverlay}return GeoJSONPoint.prototype.add=function(feature,props){var geom=feature.geometry,properties=props(feature),coordinates=geom.coordinates;if((null==coordinates?void 0:coordinates.length)>0){var projected=this.projectPoint(coordinates);this.dict.add(projected,feature.properties);var point=void 0;this.pool.length>0?point=this.pool.pop():(point=new PIXI.Graphics,this.container.addChild(point));var fillColor=properties.style.fillColor?PIXI.utils.string2hex(color(properties.style.fillColor).hex()):0,lineColor=properties.style.lineColor?PIXI.utils.string2hex(color(properties.style.lineColor).hex()):0,opacity=properties.style.fillOpacity||0;point.lineStyle(properties.style.lineWidth,lineColor),point.beginFill(fillColor,opacity),point.drawRect(projected[0]-4,projected[1]-4,8,8),point.endFill(),this.spawned.push(point)}},GeoJSONPoint.prototype.projectPoint=function(point){var coord=(0,this.pixiOverlay.utils.latLngToLayerPoint)([point[1],point[0]]);return new Vector2(coord.x,coord.y)},GeoJSONPoint.prototype.resize=function(zoom){},GeoJSONPoint.prototype.testPosition=function(pos){return this.dict.getClosestUnder(pos)},GeoJSONPoint}(),GeoJSONModule=function(_super){function GeoJSONModule(config){var _this=_super.call(this)||this;return _this.mapmoving=!1,_this._eventHandler=(null==config?void 0:config.customEventHandler)||new DefaultEventHandler,_this.onFeatureHover=null==config?void 0:config.onFeatureHover,_this.config=config,_this}return __extends(GeoJSONModule,_super),GeoJSONModule.prototype.set=function(data,props){var _this=this;this.labelRoot=new PIXI.Container,data.features.forEach((function(feature){"Point"===feature.geometry.type?(void 0===_this.points&&(_this.points=new GeoJSONPoint(_this.root,_this.pixiOverlay)),_this.points.add(feature,props)):"LineString"===feature.geometry.type?(void 0===_this.linestrings&&(_this.linestrings=new GeoJSONLineString(_this.root,_this.pixiOverlay,_this.config)),_this.linestrings.add(feature,props)):"Polygon"===feature.geometry.type?(void 0===_this.polygons&&(_this.polygons=new GeoJSONPolygon(_this.root,_this.labelRoot,_this.pixiOverlay,_this.config)),_this.polygons.add(feature,props)):"MultiPolygon"===feature.geometry.type&&(void 0===_this.multipolygons&&(_this.multipolygons=new GeoJSONMultiPolygon(_this.root,_this.labelRoot,_this.pixiOverlay,_this.config)),_this.multipolygons.add(feature,props))})),this.root.addChild(this.labelRoot),this.polygons&&this.polygons.drawLabels(),this.multipolygons&&this.multipolygons.drawLabels()},GeoJSONModule.prototype.testPosition=function(pos){var result=[];return this.polygons&&result.push(this.polygons.testPosition(pos)),this.multipolygons&&result.push(this.multipolygons.testPosition(pos)),this.linestrings&&result.push(this.linestrings.testPosition(pos)),this.points&&result.push(this.points.testPosition(pos)),result=result.filter((function(v){return v}))},GeoJSONModule.prototype.onAdd=function(map){var element=this.pixiOverlay.utils.getRenderer().view.parentNode,callbacks={mousemove:this.handleMouseMove.bind(this),mouseout:this.handleMouseOut.bind(this),click:this.handleMouseClick.bind(this),mousedown:this.handleMouseDown.bind(this),mouseup:this.handleMouseUp.bind(this)};this._eventHandler.register(map,element,callbacks)},GeoJSONModule.prototype.onRemove=function(map){this._eventHandler.unregister()},GeoJSONModule.prototype.resize=function(zoom){this.points&&this.points.resize(zoom),this.linestrings&&this.linestrings.resize(zoom),this.polygons&&this.polygons.resize(zoom),this.multipolygons&&this.multipolygons.resize(zoom)},GeoJSONModule.prototype.handleMouseMove=function(event){if(this.mapmoving)return!1;var latLng=this.pixiOverlay.utils.getMap().mouseEventToLatLng(event),layerCoords=new Vector2([latLng.lng,latLng.lat]),hits=this.testPosition(layerCoords);return this.onFeatureHover&&this.onFeatureHover(event,hits),!0},GeoJSONModule.prototype.handleMouseOut=function(event){return this.onFeatureHover&&this.onFeatureHover(event,[]),!0},GeoJSONModule.prototype.handleMouseClick=function(){return!0},GeoJSONModule.prototype.handleMouseDown=function(){return this.mapmoving=!0,!0},GeoJSONModule.prototype.handleMouseUp=function(){return this.mapmoving=!1,!0},GeoJSONModule}(ModuleInterface),ExplorationLayer=function(_super){function ExplorationLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.pointDict=new PointDictionary(.25,-2,-1),_this}return __extends(ExplorationLayer,_super),ExplorationLayer.prototype.appendExploration=function(scale){void 0===scale&&(scale=1);var project=this.pixiOverlay.utils.latLngToLayerPoint,targetScale=this.clampScale(scale);this.prevScale=targetScale;for(var i=0;i<null.length;i++){var projected=project([null[i].latitude,null[i].longitude]),pos=new Vector2(projected.x,projected.y),well=generateCircle(pos,.3,void 0);this.root.addChild(well),this.pointDict.add(pos,{mesh:well,uniforms:void 0})}},ExplorationLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.05*scale;return targetScale>1&&(targetScale=1),targetScale},ExplorationLayer.prototype.highlight=function(lat,long){var project=this.pixiOverlay.utils.latLngToLayerPoint;this.selection&&((point=this.selection.point).uniforms.circleColor1=[.3,.3,.3],point.mesh.zIndex=this.selection.zIndex,this.selection=null);var _a=project([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y),circleUnder=this.pointDict.getClosestUnder(worldSpace);if(circleUnder){var point=circleUnder.val;return this.selection={point:point,zIndex:point.mesh.zIndex},point.uniforms.circleColor1=[.2,.6,.7],point.mesh.zIndex=1/0,!0}return!1},ExplorationLayer}(ModuleInterface);export{DefaultEventHandler,ExplorationLayer,FaultlineModule,FieldModule,GeoJSONModule,ModuleInterface,OutlineModule,WellboreModule};
|
|
15
|
+
***************************************************************************** */function __extends(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __spreadArray(to,from){for(var i=0,il=from.length,j=to.length;i<il;i++,j++)to[j]=from[i];return to}function log(text){var date,out="%cVIDEX-MAP%c "+text;console.log(out+" ("+((date=new Date).getHours()+":"+date.getMinutes()+":"+date.getSeconds()+"."+date.getMilliseconds()+")"),"\n background: #555;\n color: #eee;\n padding: 0 6px 0 6px;\n border-radius: 2px;\n ",null)}var FaultlineModule=function(_super){function FaultlineModule(config){var _this=_super.call(this)||this;return _this.spawned=[],_this.pool=[],_this.config={color:7503240,alpha:1,outlineWidth:.125},config?(isNaN(config.color)||(_this.config.color=config.color),isNaN(config.alpha)||(_this.config.alpha=config.alpha),isNaN(config.outlineWidth)||(_this.config.outlineWidth=config.outlineWidth),_this):_this}return __extends(FaultlineModule,_super),FaultlineModule.prototype.destroy=function(){_super.prototype.destroy.call(this),this.pool.forEach((function(g){return g.destroy({children:!0,texture:!0,baseTexture:!0})})),this.pool=null,this.spawned=null},FaultlineModule.prototype.set=function(data){var _this=this;this.clear();var project=this.pixiOverlay.utils.latLngToLayerPoint,lineCount=0;data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new PIXI.Graphics,_this.root.addChild(faultline)),_this.spawned.push(faultline),faultline.alpha=_this.config.alpha;var projected=d.coordinates.map((function(p){var coord=project(p);return new PIXI.Point(coord.x,coord.y)})),first=projected[0],last=projected[projected.length-1];if(Vector2.equals([first.x,first.y],[last.x,last.y],1e-6))faultline.beginFill(_this.config.color),faultline.lineStyle(_this.config.outlineWidth,_this.config.color),faultline.drawPolygon(projected),faultline.endFill();else{lineCount++,faultline.lineStyle(_this.config.outlineWidth,_this.config.color).moveTo(first.x,first.y);for(var i=1;i<projected.length;i++)faultline.lineTo(projected[i].x,projected[i].y)}})),lineCount>0&&log("Drawing "+lineCount+" faultline polygons as lines.")},FaultlineModule.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineModule.prototype.resize=function(zoom){},FaultlineModule}(ModuleInterface);function Intersection(p1,d1,p2,d2){var c=[p1[0]-p2[0],p1[1]-p2[1]],len=(c[0]*d2[1]-c[1]*d2[0])/(d1[1]*d2[0]-d1[0]*d2[1]);return c[0]=d1[0]*len+p1[0],c[1]=d1[1]*len+p1[1],c}var Mesh=function(){function Mesh(){}return Mesh.WellboreSegment=function(points,thickness,type){void 0===thickness&&(thickness=1);var vertices=[],triangles=[],vertexData=[],extraData=[],_thickness=.5*thickness,point0=points[0],first=point0.position,from0=Vector2.sub(points[1].position,first).rescale(_thickness);vertices.push(-from0[1]+first[0],from0[0]+first[1],from0[1]+first[0],-from0[0]+first[1]),vertexData.push(point0.distance,1,-point0.direction[1],point0.direction[0],point0.distance,0,point0.direction[1],-point0.direction[0]),extraData.push(type,type);for(var i=1;i<points.length-1;i++){var point=points[i],prev=points[i-1].position,cur=point.position,next=points[i+1].position,to=Vector2.sub(cur,prev),from=Vector2.sub(next,cur),upper=null,inner=null;if(Vector2.angleDeg(to,from)<90){var toU=to.rotate90().mutable.rescale(_thickness).add(prev).immutable,fromU=from.rotate90().mutable.rescale(_thickness).add(next).immutable,toI=to.rotate270().mutable.rescale(_thickness).add(prev).immutable,fromI=from.rotate270().mutable.rescale(_thickness).add(next).immutable;upper=Intersection(toU,to,fromU,from),inner=Intersection(toI,to,fromI,from)}else upper=[-point.direction[1]*_thickness+cur[0],point.direction[0]*_thickness+cur[1]],inner=[point.direction[1]*_thickness+cur[0],-point.direction[0]*_thickness+cur[1]];if(vertices.push(upper[0],upper[1],inner[0],inner[1]),vertexData.push(point.distance,1,-point.direction[1],point.direction[0],point.distance,0,point.direction[1],-point.direction[0]),extraData.push(type,type),0!=i){var n_1=2*i;triangles.push(n_1-1,n_1-2,n_1,n_1-1,n_1,n_1+1)}}var pointN=points[points.length-1],last=pointN.position,toN=Vector2.sub(last,points[points.length-2].position).rescale(_thickness);vertices.push(last[0]-toN[1],last[1]+toN[0],last[0]+toN[1],last[1]-toN[0]),vertexData.push(pointN.distance,1,-pointN.direction[1],pointN.direction[0],pointN.distance,0,pointN.direction[1],-pointN.direction[0]),extraData.push(type,type);var n=2*points.length-2;return triangles.push(n-1,n-2,n,n-1,n,n+1),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},Mesh.from=function(vertices,triangles,vertexShader,fragmentShader,uniforms,normals){var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",vertices,2),normals&&geometry.addAttribute("inputNormals",normals,2),geometry.addIndex(triangles);var shader=PIXI.Shader.from(vertexShader,fragmentShader,uniforms);return new PIXI.Mesh(geometry,shader)},Mesh.SimpleLine=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness;function GetNormal(index){if(0===index)return Vector2.sub(points[1],points[0]).mutable.rotate90().rescale(1);if(index===points.length-1)return Vector2.sub(points[points.length-1],points[points.length-2]).mutable.rotate90().rescale(1);var prev=points[index-1],cur=points[index],next=points[index+1];return Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1)}for(var prevUpperRight,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<points.length-1;i++){var cur=points[i],next=points[i+1],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=GetNormal(i),rightNormal=GetNormal(i+1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh.Polygon=function(points){var vertices=flatten(points);return{vertices:vertices,triangles:earcut(vertices)}},Mesh.PolygonOutline=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness;function GetIndex(index){var r=index%points.length;return r<0&&(r+=points.length),r}for(var prevUpperRight,firstUpperLeft,firstDirN,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<points.length;i++){var prev=points[GetIndex(i-1)],cur=points[GetIndex(i)],next=points[GetIndex(i+1)],next2=points[GetIndex(i+2)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1),rightNormal=Vector2.lerpRot(Vector2.sub(next,cur),Vector2.sub(next2,next),.5).mutable.rotate90().rescale(1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}else firstUpperLeft=upperLeft,firstDirN=dirN;if(i===points.length-1){var toLastUpper=Vector2.sub(upperRight,firstUpperLeft);Vector2.signedAngle(firstDirN,toLastUpper)<0?triangles.push(0,baseTris-2,1):triangles.push(0,baseTris-1,1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh}(),OutlineModule=function(_super){function OutlineModule(config){var _this=_super.call(this)||this;return _this.outlineDict={},_this.spawned=[],_this.config={baseWidth:.1,minZoom:0,maxZoom:18,minExtraWidth:.1,maxExtraWidth:10},_this.state={extraWidth:1},config?(isNaN(config.minZoom)||(_this.config.minZoom=config.minZoom),isNaN(config.maxZoom)||(_this.config.maxZoom=config.maxZoom),isNaN(config.minExtraWidth)||(_this.config.minExtraWidth=config.minExtraWidth),isNaN(config.maxExtraWidth)||(_this.config.maxExtraWidth=config.maxExtraWidth),_this):_this}return __extends(OutlineModule,_super),OutlineModule.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,width:_this.state.extraWidth,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms;for(var coordinates=outlineCollection.coordinates,n=0;n<coordinates.length;n++){for(var polygon=coordinates[n],projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project(p);projected.push([pos.x,pos.y])}var outlineData=void 0;if(Vector2.equals(projected[0],projected[projected.length-1],1e-6)){if(projected.pop(),projected.length<=2){log("Skipping outline (Polygon) with "+projected.length+" points.");continue}outlineData=Mesh.PolygonOutline(projected,_this.config.baseWidth)}else{if(projected.length<=1){log("Skipping outline (Line) with "+projected.length+" points.");continue}outlineData=Mesh.SimpleLine(projected,_this.config.baseWidth)}var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineModule.vertexShader,OutlineModule.fragmentShader,uniforms,outlineData.normals);_this.root.addChild(outline),_this.spawned.push(outline)}}))},OutlineModule.prototype.setVisibleLayers=function(names){var _this=this;Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].visible=!1})),names.forEach((function(name){var uniforms=_this.outlineDict[name];uniforms&&(uniforms.visible=!0)}))},OutlineModule.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineModule.prototype.resize=function(zoom){var _this=this,t=inverseLerp(this.config.minZoom,this.config.maxZoom,zoom),width=lerp(this.config.maxExtraWidth,this.config.minExtraWidth,t);this.state.extraWidth=width,Object.keys(this.outlineDict).forEach((function(key){_this.outlineDict[key].width=width}))},OutlineModule}(ModuleInterface);function toShader(n){return n-Math.floor(n)==0?n.toString()+".0":n.toString()}OutlineModule.vertexShader="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineModule.fragmentShader="\n precision mediump float;\n\n uniform vec3 color;\n uniform bool visible;\n\n void main() {\n if (!visible) discard;\n gl_FragColor = vec4(color, 1.0);\n }\n";var WellboreShader=function(){function WellboreShader(){}return WellboreShader.build=function(maxScale,wellboreDash){WellboreShader.vertexShader="\n attribute vec2 verts;\n attribute vec4 vertCol;\n attribute float typeData;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n uniform float wellboreRadius;\n\n varying vec4 vCol;\n varying float type;\n\n void main() {\n vCol = vertCol;\n type = typeData;\n\n vec2 normal = vertCol.zw;\n\n float extraRadius = wellboreRadius - "+toShader(maxScale)+";\n\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts + normal * extraRadius, 1.0)).xy, 0.0, 1.0);\n }\n ";var dash=toShader(wellboreDash),doubleDash=toShader(2*wellboreDash),quadrupleDash=toShader(4*wellboreDash);WellboreShader.fragmentShader="\n precision mediump float;\n\n varying vec4 vCol;\n varying float type;\n\n uniform vec3 wellboreColor1;\n uniform vec3 wellboreColor2;\n uniform bool completionVisible;\n uniform bool wellboreVisible;\n uniform int status;\n\n const vec3 sunDir = vec3(0.6247, -0.6247, 0.4685);\n\n void main() {\n vec3 col = vec3(0.0);\n float alpha = 1.0;\n\n if (status == 0) {\n if(type == 0.0) {\n if (!wellboreVisible) {\n alpha = 0.03;\n }\n } else if (type == 1.0) {\n if(completionVisible){\n if(mod(vCol.x, "+doubleDash+") > "+dash+") discard;\n } else if(!wellboreVisible){\n alpha = 0.03;\n }\n }\n if (!completionVisible && type == 2.0) discard;\n\n float dist = clamp(vCol.z * vCol.z + vCol.w * vCol.w, 0.0, 1.0);\n\n vec3 dir3D = vec3(vCol.zw, sqrt(1.0 - dist * dist));\n\n float light = 0.4 + dot(dir3D, sunDir) * 0.6;\n light = clamp(light, 0.0, 1.0);\n\n col = mix(wellboreColor2, wellboreColor1, light);\n }\n\n else if (status == 1) {\n if (type == 2.0) discard;\n if(mod(vCol.x + vCol.y * 0.2, "+quadrupleDash+") > "+doubleDash+") discard;\n vec3 c = wellboreColor2 + wellboreColor1 * 0.5;\n vec3 gray = vec3(0.9);\n col = mix(gray, c, 0.3);\n }\n\n else if (status == 2) {\n if (type == 2.0) discard;\n alpha = 0.03;\n }\n\n else discard;\n\n col *= alpha;\n gl_FragColor = vec4(col, alpha);\n }\n "},WellboreShader.vertexShader="",WellboreShader.fragmentShader="",WellboreShader}(),RootShader=function(){function RootShader(){}return RootShader.get=function(){return PIXI.Shader.from(RootShader.vertexShader,RootShader.fragmentShader,{active:!0,circleColor1:[0,0,0],circleColor2:[0,0,0]})},RootShader.build=function(maxScale){RootShader.vertexShader="\n attribute vec2 verts;\n attribute vec2 inputUVs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n uniform float rootRadius;\n\n varying vec2 UVs;\n\n void main() {\n UVs = inputUVs;\n\n vec2 dir = 2.0 * inputUVs - 1.0;\n\n float extraRadius = rootRadius - "+toShader(maxScale)+";\n\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts + dir * extraRadius, 1.0)).xy, 0.0, 1.0);\n }\n "},RootShader.vertexShader="",RootShader.fragmentShader="\n precision mediump float;\n\n varying vec2 UVs;\n\n uniform vec3 circleColor1;\n uniform vec3 circleColor2;\n uniform bool active;\n\n const vec3 sunDir = vec3(0.6247, -0.6247, 0.4685);\n\n void main() {\n if (!active) {\n discard;\n return;\n }\n vec2 dir = 2.0 * UVs - 1.0;\n float dist = dir.x * dir.x + dir.y * dir.y;\n if (dist > 1.0) discard;\n\n vec3 dir3D = vec3(dir, sqrt(1.0 - dist * dist));\n\n float light = dot(dir3D, sunDir);\n light = 0.4 + light * 0.6;\n\n vec3 col = mix(circleColor2, circleColor1, clamp(light, 0.0, 1.0));\n\n gl_FragColor = vec4(col, 1.0);\n }\n ",RootShader}();function generateCircle(center,radius,shader){var geometry=new PIXI.Geometry;return geometry.addAttribute("verts",[center[0]-radius,center[1]-radius,center[0]+radius,center[1]-radius,center[0]-radius,center[1]+radius,center[0]+radius,center[1]+radius],2),geometry.addAttribute("inputUVs",[0,0,1,0,0,1,1,1],2),geometry.addIndex([0,2,3,0,3,1]),new PIXI.Mesh(geometry,shader)}var Label=function(){function Label(label,fontColor,bgColor){this._attachToRoot=!1;var text=new PIXI.Text(label,Label.style);text.resolution=window.devicePixelRatio,text.visible=Label.state.visible,text.tint=fontColor,text.zIndex=1,this.text=text;var metrics=PIXI.TextMetrics.measureText(label,Label.style);this.metrics=metrics;var background=new PIXI.Graphics;background.beginFill(16777215),background.drawRect(.55*-metrics.width,.525*-Label.height,1.1*metrics.width,1.05*Label.height),background.endFill(),background.visible=Label.state.visible,background.alpha=Label.config.backgroundOpacity,background.tint=bgColor,background.zIndex=0,this.background=background}return Label.setStyle=function(fontSize){Label.style=new PIXI.TextStyle({fontFamily:"Arial",fontSize:fontSize,fill:16777215,align:"center"}),Label.height=PIXI.TextMetrics.measureText(" ",Label.style).height},Label.setCommon=function(config){Label.config=config},Object.defineProperty(Label.prototype,"visible",{get:function(){return this.text.visible},set:function(flag){this.text.visible=flag&&Label.state.visible,this.background.visible=flag&&Label.state.visible},enumerable:!1,configurable:!0}),Object.defineProperty(Label.prototype,"attachToRoot",{get:function(){return this._attachToRoot},set:function(val){val!==this._attachToRoot&&(this._attachToRoot=val)},enumerable:!1,configurable:!0}),Label.prototype.getBoundingBox=function(){var _a=this.background,y=_a.y,width=_a.width,height=_a.height,x=this.background.x-width/2;return new PIXI.Rectangle(x,y,width,height)},Label.state={zoom:1,scale:1,visible:!0,rootDisplacement:1},Label}();var RootData=function(){function RootData(position,radius){this.wellbores=[],this.labelIndex=0,this.rootLabelsBBox=null,this.target=null,this.position=position,this.radius=radius;var shader=RootShader.get();this.mesh=generateCircle(position,radius,shader)}return Object.defineProperty(RootData.prototype,"active",{get:function(){return this.target&&this.target.active},enumerable:!1,configurable:!0}),RootData.prototype.updateLabelsBBox=function(label){var bbox=label.getBoundingBox();this.rootLabelsBBox?(this.rootLabelsBBox.height=bbox.y+bbox.height-this.rootLabelsBBox.y,bbox.width>this.rootLabelsBBox.width&&(this.rootLabelsBBox.x=bbox.x,this.rootLabelsBBox.width=bbox.width)):this.rootLabelsBBox=bbox},RootData.prototype.positionLabel=function(wellbore){wellbore.label.attachToRoot?(!function(wellbore,position){wellbore.label.attachToRoot=!0;var _a=wellbore.label,text=_a.text,background=_a.background,_b=Label.state,scale=_b.scale,rootDisplacement=_b.rootDisplacement;text.anchor.set(.5,0),text.rotation=0,background.rotation=0,background.pivot.set(0,.5*-Label.height);var yPos=rootDisplacement+5*scale+position*(Label.height+5)*scale+wellbore.root.position[1];text.position.set(wellbore.root.position[0],yPos),text.scale.set(scale),background.position.set(wellbore.root.position[0],yPos),background.scale.set(scale)}(wellbore,this.labelIndex++),this.updateLabelsBBox(wellbore.label)):function(wellbore){wellbore.label.attachToRoot=!1;var anchorX,anchorY,pivotX,pivotY,angle,pos,_a=wellbore.label,text=_a.text,background=_a.background,metrics=_a.metrics,end=wellbore.interpolator.GetPoint(1).position,width=metrics.width*Label.state.scale,start=wellbore.interpolator.GetPointFromEnd(width),dir=Vector2.sub(end,start.position).mutable;dir.x<0?(anchorX=0,anchorY=0,pivotX=.5*-metrics.width,pivotY=.5*-metrics.height,angle=Vector2.signedAngle(Vector2.left,dir),pos=dir.rotate270().rescale(.5*wellbore.wellboreWidth+.075).add(end)):(anchorX=1,anchorY=0,pivotX=.5*metrics.width,pivotY=.5*-metrics.height,angle=Vector2.signedAngle(Vector2.right,dir),pos=dir.rotate90().rescale(.5*wellbore.wellboreWidth+.075).add(end)),text.position.set(pos[0],pos[1]),text.rotation=angle,text.anchor.set(anchorX,anchorY),text.scale.set(Label.state.scale),background.position.set(pos[0],pos[1]),background.pivot.set(pivotX,pivotY),background.rotation=angle,background.scale.set(Label.state.scale)}(wellbore)},RootData.prototype.append=function(wellbore){this.wellbores.push(wellbore),wellbore.active&&(this.target?wellbore.order<this.target.order&&wellbore.status>this.target.status?this.recalculate(!0):this.positionLabel(wellbore):this.recalculate(!0))},RootData.prototype.recalculate=function(labelUpdate){void 0===labelUpdate&&(labelUpdate=!1),this.updateTarget(),this.updateUniforms(),labelUpdate&&this.updateLabels()},RootData.prototype.updateTarget=function(){for(var target,smallest=Number.MAX_VALUE,i=0;i<this.wellbores.length;i++){var wellbore=this.wellbores[i];if(wellbore.active){if(wellbore.selected){target=wellbore;break}var weighted=wellbore.order-1e6*wellbore.status;weighted<smallest&&(smallest=weighted,target=wellbore)}}this.target=target},RootData.prototype.updateUniforms=function(){var uniform=this.mesh.shader.uniforms;if(uniform.active=this.active,this.target){var color=this.target.color;uniform.circleColor1=color.col1,uniform.circleColor2=color.col2,this.mesh.zIndex=this.target.status}},RootData.prototype.updateLabels=function(){var _this=this;this.labelIndex=0,this.rootLabelsBBox=null,this.wellbores.forEach((function(wellbore){wellbore.active&&_this.positionLabel(wellbore)}))},RootData.prototype.setLabelVisibility=function(visible){visible?this.updateLabels():this.rootLabelsBBox=null,this.wellbores.forEach((function(wellbore){wellbore.active&&(wellbore.label.visible=visible)}))},RootData}();var WellboreStatus,FilterStatus,LineInterpolator=function(){function LineInterpolator(points,radius){this.singlePoint=!0;var initDir,amount=points.length,path=new Array(amount),root=points[0];initDir=points.length>=2?Vector2.sub(points[1],points[0]).normalize():Vector2.right,path[0]={point:root,direction:initDir,distance:0,relative:0};for(var length=0,i=1;i<amount;i++){var point=points[i];length+=Vector2.distance(point,path[i-1].point),path[i]={point:point,direction:this.GetDirection(points,i),distance:length,relative:0},Vector2.distance(point,root)>radius&&(this.singlePoint=!1)}for(i=1;i<amount;i++){var p=path[i];p.relative=0===length?0:p.distance/length}this.amount=amount,this.length=length,this.path=path}return LineInterpolator.prototype.GetPoint=function(relative){if(this.singlePoint)return{position:this.path[0].point,direction:Vector2.up,distance:0};if(relative<0){var first=this.path[0];return{position:first.point,direction:first.direction,distance:0}}if(relative>=1){var last=this.path[this.amount-1];return{position:last.point,direction:last.direction,distance:this.length}}var base=this.GetClosestPointBelow(relative),prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relative-prev.relative)/dist;return{position:mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prev.direction,cur.direction,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac}},LineInterpolator.prototype.GetSection=function(relativeStart,relativeEnd){if(this.singlePoint)return[{position:this.path[0].point,direction:Vector2.up,distance:0},{position:this.path[0].point,direction:Vector2.up,distance:0}];if(relativeStart>=1){var last=this.path[this.path.length-1];return[{position:last.point,direction:last.direction,distance:this.length},{position:last.point,direction:last.direction,distance:this.length}]}var base=this.GetClosestPointBelow(relativeStart),points=[],prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relativeStart-prev.relative)/dist;points.push({position:mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prev.direction,cur.direction,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac});for(var i=base+1;i<this.amount;i++){var cur_1=this.path[i];if(cur_1.relative>=relativeEnd){var cur_2=this.path[i],prev_1=this.path[i-1],dist_1=cur_2.relative-prev_1.relative,frac_1=(relativeEnd-prev_1.relative)/dist_1;points.push({position:mix(prev_1.point,cur_2.point,frac_1,Vector2.zero),direction:Vector2.lerpRot(prev_1.direction,cur_2.direction,frac_1).normalize(),distance:prev_1.distance*(1-frac_1)+cur_2.distance*frac_1});break}points.push({position:cur_1.point,direction:this.path[i].direction,distance:cur_1.distance})}return points},LineInterpolator.prototype.GetClosestPointBelow=function(relative){for(var base=0,range=this.amount,idx=Math.floor(.5*range);range>1;)relative<this.path[idx].relative?(range=Math.floor(.5*range),idx=base+Math.floor(.5*range)):(base+=Math.floor(.5*range),range=Math.ceil(.5*range),idx=base+Math.floor(.5*range));return base},LineInterpolator.prototype.GetPointFromStart=function(distance){var relative=distance/this.length;return clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetPointFromEnd=function(distance){var relative=1-distance/this.length;return clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetRangeFromStart=function(relative,width,resolution){void 0===resolution&&(resolution=10);for(var relativeDisp=(relative+width/this.length-relative)/resolution,points=[],i=0;i<=resolution;i++)points.push(this.GetPoint(relative+relativeDisp*i));return points},LineInterpolator.prototype.GetDirection=function(points,idx){var end=points.length-1;if(0===idx)return Vector2.sub(points[1],points[0]).normalize();if(idx===end)return Vector2.sub(points[end],points[end-1]).normalize();var cur=points[idx],to=Vector2.sub(cur,points[idx-1]),from=Vector2.sub(points[idx+1],cur);return Vector2.lerpRot(to,from,.5).normalize()},LineInterpolator}(),WellboreMesh=function(){function WellboreMesh(interp,thickness,tick){this.interp=interp,this.thickness=thickness,this.baseTris=0,this.tick=tick}return WellboreMesh.prototype.generate=function(intervals){var _this=this;void 0===intervals&&(intervals=[]);var vertices=[],triangles=[],vertexData=[],extraData=[];if(intervals.length<=0){var path=this.interp.GetSection(0,1);this.appendSegment(path,0,vertices,triangles,vertexData,extraData)}else if(intervals.length>0){var p_1=0;intervals.forEach((function(i){var path1=_this.interp.GetSection(p_1,i[0]);_this.appendSegment(path1,0,vertices,triangles,vertexData,extraData);var path2=_this.interp.GetSection(i[0],i[1]);_this.appendSegment(path2,1,vertices,triangles,vertexData,extraData),p_1=i[1]}));var end=intervals[intervals.length-1][1];if(end<1){var lastPath=this.interp.GetSection(end,1);this.appendSegment(lastPath,0,vertices,triangles,vertexData,extraData)}}return intervals.forEach((function(i){var p1=_this.interp.GetPoint(i[0]);if(_this.generateCrossline(p1,vertices,triangles,vertexData,extraData),!(Math.abs(i[0]-i[1])<.001)){var p2=_this.interp.GetPoint(i[1]);_this.generateCrossline(p2,vertices,triangles,vertexData,extraData)}})),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},WellboreMesh.prototype.appendSegment=function(section,type,vertices,triangles,vertexData,extraData){var _this=this,mesh=Mesh.WellboreSegment(section,this.thickness,type);vertices.push.apply(vertices,mesh.vertices),mesh.triangles.forEach((function(d){return triangles.push(d+_this.baseTris)})),vertexData.push.apply(vertexData,mesh.vertexData),extraData.push.apply(extraData,mesh.extraData),this.baseTris+=mesh.vertices.length/2},WellboreMesh.prototype.generateCrossline=function(p,vertices,triangles,vertexData,extraData){var px=p.position[0],py=p.position[1],crosslinesWidth=this.tick.width,dirX=p.direction[0]*crosslinesWidth,dirY=p.direction[1]*crosslinesWidth,crosslinesHeight=this.tick.height,normX=-p.direction[1]*crosslinesHeight,normY=p.direction[0]*crosslinesHeight;vertices.push(px-dirX-normX,py-dirY-normY,px+dirX-normX,py+dirY-normY,px-dirX+normX,py-dirY+normY,px+dirX+normX,py+dirY+normY),triangles.push(this.baseTris,this.baseTris+2,this.baseTris+3,this.baseTris,this.baseTris+3,this.baseTris+1),extraData.push(2,2,2,2);var normalizedNormal=new Vector2(normX,normY).normalized(),nnx=normalizedNormal.x,nny=normalizedNormal.y;vertexData.push(p.distance,0,-nnx,-nny,p.distance,0,-nnx,-nny,p.distance,1,nnx,nny,p.distance,1,nnx,nny),this.baseTris+=4},WellboreMesh}();!function(WellboreStatus){WellboreStatus[WellboreStatus.normal=0]="normal",WellboreStatus[WellboreStatus.highlighted=1]="highlighted",WellboreStatus[WellboreStatus.multiHighlighted=2]="multiHighlighted",WellboreStatus[WellboreStatus.selected=3]="selected"}(WellboreStatus||(WellboreStatus={})),function(FilterStatus){FilterStatus[FilterStatus.none=0]="none",FilterStatus[FilterStatus.soft=1]="soft",FilterStatus[FilterStatus.hard=2]="hard"}(FilterStatus||(FilterStatus={}));var ColorType,WellboreData=function(){function WellboreData(input){if(this._zIndex=0,this.status=WellboreStatus.normal,this.filter=FilterStatus.none,this.data=input.data,this.group=input.group,this.root=input.root,this.wellboreWidth=input.wellboreWidth,this.interpolator=new LineInterpolator(input.coords,input.pointThreshold),this.label=new Label(input.data.labelShort,this.colors.fontColor,this.colors.default.labelBg),this.interpolator.singlePoint)this.label.attachToRoot=!0;else{var intervals=function(intervals){var output=intervals.map((function(i){return[i.l1,i.l2]})).sort((function(a,b){return a[0]<b[0]?-1:a[0]>b[0]?1:0}));return output.length>0&&(output=function(intervals){for(var output=[],prev=intervals[0].slice(0),i=1;i<intervals.length;i++){var cur=intervals[i].slice(0);cur[0]<prev[1]?cur[1]>prev[1]&&(prev[1]=cur[1]):(output.push(prev),prev=cur)}return output.push(prev),output}(output)),output}(input.data.intervals);this.mesh=this.createWellboreMesh(intervals,input.tick)}this.update()}return Object.defineProperty(WellboreData.prototype,"zIndex",{set:function(val){this._zIndex=val,this.mesh&&(this.mesh.zIndex=this._zIndex)},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"colors",{get:function(){return this.group.colors},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"color",{get:function(){var colors=this.group.colors;switch(this.status){case WellboreStatus.normal:return colors.default;case WellboreStatus.highlighted:return colors.highlight;case WellboreStatus.multiHighlighted:return colors.multiHighlight;case WellboreStatus.selected:return colors.selected}},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"active",{get:function(){var activeUniform=this.mesh&&0==this.mesh.shader.uniforms.status;return this.group.active&&(activeUniform||this.filter===FilterStatus.none)},enumerable:!1,configurable:!0}),WellboreData.prototype.setFilter=function(filter){this.filter!==filter&&(this.filter=filter,this.update())},Object.defineProperty(WellboreData.prototype,"selected",{get:function(){return this.status==WellboreStatus.selected},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"highlighted",{get:function(){return this.status==WellboreStatus.highlighted||this.status==WellboreStatus.multiHighlighted},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"order",{get:function(){return this.group.order},enumerable:!1,configurable:!0}),Object.defineProperty(WellboreData.prototype,"uniforms",{get:function(){return this.mesh.shader.uniforms},enumerable:!1,configurable:!0}),WellboreData.prototype.createWellboreMesh=function(intervals,tick){var _a=new WellboreMesh(this.interpolator,this.wellboreWidth,tick).generate(intervals),vertices=_a.vertices,triangles=_a.triangles,vertexData=_a.vertexData,extraData=_a.extraData,geometry=new PIXI.Geometry;geometry.addAttribute("verts",vertices,2),geometry.addAttribute("vertCol",vertexData,4),geometry.addAttribute("typeData",extraData,1),geometry.addIndex(triangles);var shader=function(color,completionVisible,wellboreVisible){return PIXI.Shader.from(WellboreShader.vertexShader,WellboreShader.fragmentShader,{wellboreColor1:color.col1,wellboreColor2:color.col2,completionVisible:completionVisible,wellboreVisible:wellboreVisible,status:0})}(this.colors.default,this.group.state.completionVisible,this.group.state.wellboreVisible);return new PIXI.Mesh(geometry,shader)},WellboreData.prototype.setCompletionVisibility=function(visible){this.mesh&&(this.uniforms.completionVisible=visible)},WellboreData.prototype.setWellboreVisibility=function(visible){this.mesh&&(this.uniforms.wellboreVisible=visible)},WellboreData.prototype.setHighlight=function(isHighlighted,multiple){if(void 0===multiple&&(multiple=!1),this.status!==WellboreStatus.selected)if(this.status=isHighlighted?multiple?WellboreStatus.multiHighlighted:WellboreStatus.highlighted:WellboreStatus.normal,isHighlighted){var color=multiple?this.colors.multiHighlight:this.colors.highlight;this.mesh&&(this.mesh.shader.uniforms.wellboreColor1=color.col1,this.mesh.shader.uniforms.wellboreColor2=color.col2,this.mesh.zIndex=this._zIndex+1e5),this.label.background.tint=color.labelBg,this.label.background.alpha=.75,this.label.background.zIndex=2,this.label.text.zIndex=3,this.label.text.tint=this.colors.interactFontColor}else this.mesh&&(this.mesh.shader.uniforms.wellboreColor1=this.colors.default.col1,this.mesh.shader.uniforms.wellboreColor2=this.colors.default.col2,this.mesh.zIndex=this._zIndex),this.label.background.tint=this.colors.default.labelBg,this.label.background.alpha=Label.config.backgroundOpacity,this.label.background.zIndex=0,this.label.text.zIndex=1,this.label.text.tint=this.colors.fontColor},WellboreData.prototype.setSelected=function(isSelected){this.status=isSelected?WellboreStatus.selected:WellboreStatus.normal,isSelected?(this.mesh&&(this.mesh.shader.uniforms.wellboreColor1=this.colors.selected.col1,this.mesh.shader.uniforms.wellboreColor2=this.colors.selected.col2,this.mesh.zIndex=this._zIndex+1e6),this.label.background.tint=this.colors.selected.labelBg,this.label.background.alpha=.75,this.label.background.zIndex=2,this.label.text.zIndex=3):(this.mesh&&(this.mesh.shader.uniforms.wellboreColor1=this.colors.default.col1,this.mesh.shader.uniforms.wellboreColor2=this.colors.default.col2,this.mesh.zIndex=this._zIndex),this.label.background.tint=this.colors.default.labelBg,this.label.background.alpha=Label.config.backgroundOpacity,this.label.background.zIndex=0,this.label.text.zIndex=1),this.label.text.tint=this.colors.fontColor,this.root.recalculate()},WellboreData.prototype.update=function(){var active=this.group.active&&this.filter===FilterStatus.none;if(this.mesh){var status_1=this.filter;this.group.active||(status_1=4),this.mesh.shader.uniforms.status=status_1}this.label.visible=active},WellboreData}();function getDefaultColors(input){var output={fontColor:0,interactFontColor:16777215,default:{col1:[.3,.3,.3],col2:[.05,.05,.05],labelBg:16777215},highlight:{col1:[.8,.2,.9],col2:[.5,.05,.6],labelBg:10685091},multiHighlight:{col1:[.55,.55,.55],col2:[.3,.3,.3],labelBg:6710886},selected:{col1:[1,0,0],col2:[.5,0,0],labelBg:16777215}};if(!input)return output;function transfer(key){isNaN(input[key])||(output[key]=input[key])}function transferColor(color){var inputCol1=input[color+"Color1"],inputCol2=input[color+"Color2"],inputLabelBg=input[color+"LabelBg"],outputColor=output[color];inputCol1&&(outputColor.col1=inputCol1),inputCol2&&(outputColor.col2=inputCol2),inputLabelBg&&(outputColor.labelBg=inputLabelBg)}return transfer("fontColor"),transfer("interactFontColor"),transferColor("default"),transferColor("highlight"),transferColor("multiHighlight"),transferColor("selected"),output}!function(ColorType){ColorType[ColorType.Default=0]="Default",ColorType[ColorType.Highlight=1]="Highlight",ColorType[ColorType.MultiHighlight=2]="MultiHighlight",ColorType[ColorType.Selected=3]="Selected"}(ColorType||(ColorType={}));var Group=function(){function Group(key,options){this.wellbores=[],this.active=!0,this.order=0,this.activeFilter=null,this.state={completionVisible:!0,wellboreVisible:!0},this.key=key,options?(this.colors=getDefaultColors(options.colors),isNaN(options.order)||(this.order=options.order)):this.colors=getDefaultColors()}return Group.prototype.append=function(wellbore){if(wellbore.zIndex=1e4*this.order+this.wellbores.length,this.activeFilter){var targetFilter=this.isHardFilter?FilterStatus.hard:FilterStatus.soft;wellbore.setFilter(this.activeFilter(wellbore.data)?FilterStatus.none:targetFilter),wellbore.root.recalculate(!0)}this.wellbores.push(wellbore)},Group.prototype.forAll=function(wellboreFunc,rootFunc){for(var roots=new Set,wellbores=this.wellbores,i=0;i<wellbores.length;i++){var wellbore=wellbores[i];wellboreFunc(wellbore),roots.add(wellbore.root)}roots.forEach((function(root){return rootFunc(root)}))},Group.prototype.setActive=function(active){this.active!==active&&(this.active=active,this.forAll((function(wellbore){return wellbore.update()}),(function(root){return root.recalculate(!0)})))},Group.prototype.softFilter=function(filter){this.activeFilter=filter,this.isHardFilter=!1,this.forAll((function(wellbore){return wellbore.setFilter(filter(wellbore.data)?FilterStatus.none:FilterStatus.soft)}),(function(root){return root.recalculate(!0)}))},Group.prototype.hardFilter=function(filter){this.activeFilter=filter,this.isHardFilter=!0,this.forAll((function(wellbore){return wellbore.setFilter(filter(wellbore.data)?FilterStatus.none:FilterStatus.hard)}),(function(root){return root.recalculate(!0)}))},Group.prototype.clearFilter=function(){this.activeFilter=null,this.forAll((function(wellbore){return wellbore.setFilter(FilterStatus.none)}),(function(root){return root.recalculate(!0)}))},Group.prototype.setCompletionVisibility=function(visible){this.state.completionVisible=visible,this.wellbores.forEach((function(wellbore){wellbore.mesh&&(wellbore.uniforms.completionVisible=visible)}))},Group.prototype.setWellboreVisibility=function(visible){this.state.wellboreVisible=visible,this.wellbores.forEach((function(wellbore){wellbore.mesh&&(wellbore.uniforms.wellboreVisible=visible)}))},Group}(),WellboreEventData=function(){function WellboreEventData(group,data){this.group=group,this.data=data}return WellboreEventData.from=function(wellbore){return new WellboreEventData(wellbore.group.key,wellbore.data)},WellboreEventData}(),HighlightEvent=function(){function HighlightEvent(eventData,changed,originalEvent){this.eventData=eventData,this.changed=changed,this.originalEvent=originalEvent}return HighlightEvent.from=function(wellbores,changed,originalEvent){return new HighlightEvent(wellbores.map((function(w){return new WellboreEventData(w.group.key,w.data)})),changed,originalEvent)},Object.defineProperty(HighlightEvent.prototype,"count",{get:function(){return this.eventData.length},enumerable:!1,configurable:!0}),HighlightEvent}();function distanceToLine(point,lineStart,lineEnd){var lineDir=Vector2.sub(lineEnd,lineStart),lineAngle=Vector2.angleRight(lineDir),len=lineDir.magnitude,dir=Vector2.sub(point,lineStart).mutable.rotate(-lineAngle);return dir[0]<0?dir.magnitude:dir[0]>len?Vector2.distance(point,lineEnd):Math.abs(dir.y)}var LineDictionary=function(){function LineDictionary(gridsize,testActive){void 0===gridsize&&(gridsize=10),this.tiles=new Map,this.lineValues=new Map,this.gridsize=gridsize,this.lineSeq=0,this.testActiveFunction=testActive}return LineDictionary.prototype.add=function(points,value,id){var lineID=Number.isFinite(id)?id:++this.lineSeq,line={id:lineID,value:value,segments:[]};this.lineValues.set(lineID,line);for(var i=1;i<points.length;i++){var p1=points[i-1],p2=points[i];this.addSegment(p1[0],p1[1],p2[0],p2[1],line)}return line},LineDictionary.prototype.addSegment=function(x1,y1,x2,y2,line){var _this=this,segment={lineID:line.id,geometry:{x1:x1,y1:y1,x2:x2,y2:y2}};line.segments.push(segment),function(x1,x2,y1,y2,gridsize){var downwards,xMin,xMax,yMin,yMax,m,y0,intersections=new Set;if(x1<x2){xMin=Math.floor(x1/gridsize),xMax=Math.floor(x2/gridsize),y0=(y1-x1*(m=(y2-y1)/(x2-x1)))/gridsize,downwards=y2<y1;var key=Math.floor(x1/gridsize)+"."+Math.floor(y1/gridsize);intersections.add(key)}else xMin=Math.floor(x2/gridsize),xMax=Math.floor(x1/gridsize),y0=(y2-x2*(m=(y1-y2)/(x1-x2)))/gridsize,downwards=y1<y2,key=Math.floor(x2/gridsize)+"."+Math.floor(y2/gridsize),intersections.add(key);y1<y2?(yMin=Math.floor(y1/gridsize),yMax=Math.floor(y2/gridsize)):(yMin=Math.floor(y2/gridsize),yMax=Math.floor(y1/gridsize));for(var x=xMin+1;x<=xMax;x++){var y=y0+x*m;intersections.add(x+"."+Math.floor(y))}for(y=yMin+1;y<=yMax;y++)x=(y-y0)/m,intersections.add(Math.floor(x)+"."+Math.floor(downwards?y-1:y));return intersections}(x1,x2,y1,y2,this.gridsize).forEach((function(key){_this.tiles.has(key)?_this.tiles.get(key).push(segment):_this.tiles.set(key,[segment])}))},LineDictionary.prototype.getClosest=function(target,maxDist){void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0!==segments.size){var minDist=1/0,minLineID=-1;if(segments.forEach((function(seg){var dist=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));dist<minDist&&(minDist=dist,minLineID=seg.lineID)})),!(minDist>maxDist*this.gridsize))return this.lineValues.get(minLineID).value}},LineDictionary.prototype.getAllClosest=function(target,epsilon,maxDist,filter){var _a,_this=this;void 0===epsilon&&(epsilon=0),void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0===segments.size)return[];var minDist=1/0,minID=-1,extraLines=[];if(segments.forEach((function(seg){var distance=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));if(distance<minDist+epsilon)if(distance<minDist){var upperLimit_1=distance+epsilon,newLines_1=[];minDist<=upperLimit_1&&newLines_1.push({ID:minID,distance:minDist}),extraLines.forEach((function(d){d.distance<=upperLimit_1&&newLines_1.push(d)})),extraLines=newLines_1,minDist=distance,minID=seg.lineID}else extraLines.push({ID:seg.lineID,distance:distance})})),minDist>maxDist*this.gridsize)return[];var unique=((_a={})[minID]=!0,_a),uniqueLines=[];extraLines.forEach((function(d){unique.hasOwnProperty(d.ID)||(unique[d.ID]=!0,uniqueLines.push(d))}));var minT=this.lineValues.get(minID).value,extraT=uniqueLines.map((function(d){return _this.lineValues.get(d.ID).value}));if(filter){var filtered_1=[];extraT.forEach((function(curT){filter(minT,curT)&&filtered_1.push(curT)})),extraT=filtered_1}return __spreadArray([minT],extraT)},LineDictionary.prototype.isActive=function(line){return!this.testActiveFunction||line&&this.testActiveFunction(line.value)},LineDictionary.prototype.getSegmentsOn3Grid=function(target){for(var _this=this,gridSegments=new Set,keyX=Math.floor(target[0]/this.gridsize),keyY=Math.floor(target[1]/this.gridsize),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);this.tiles.has(key)&&this.tiles.get(key).forEach((function(tileSegment){gridSegments.has(tileSegment)||_this.isActive(_this.lineValues.get(tileSegment.lineID))&&gridSegments.add(tileSegment)}))}return gridSegments},LineDictionary.prototype.clear=function(filter){var _this=this;if(filter){var segmentsToDelete_1=new Set;this.lineValues.forEach((function(line,key){filter(line.value,key)&&(line.segments.forEach(segmentsToDelete_1.add,segmentsToDelete_1),_this.lineValues.delete(key))})),segmentsToDelete_1.size>0&&this.tiles.forEach((function(list,key){var filtered=list.filter((function(s){return!segmentsToDelete_1.has(s)}));filtered.length>0?_this.tiles.set(key,filtered):_this.tiles.delete(key)}))}else this.tiles=new Map,this.lineValues=new Map},LineDictionary}(),PointDictionary=function(){function PointDictionary(distThreshold,gridSize,radius,testActive){if(void 0===gridSize&&(gridSize=2),this.tiles=new Map,this.pointValues=new Map,this.pointSeq=0,gridSize<radius)throw"Gridsize of point dictionary must be greater than scaled radius of root.";this.distThreshold=distThreshold,this.gridSize=gridSize,this.radius=radius,this.testActiveFunction=testActive}return PointDictionary.prototype.add=function(pos,val){var id=++this.pointSeq,point={val:val,pos:pos,id:id};this.pointValues.set(id,point);for(var keys=this.getKeys(pos),i=0;i<keys.length;i++){var key=keys[i];if(this.tiles.has(key))this.tiles.get(key).set(id,point);else{var map=new Map;map.set(id,point),this.tiles.set(key,map)}}return id},PointDictionary.prototype.getKeys=function(pos){var radius=this.radius,gridSize=this.gridSize,keyX=Math.floor(pos[0]/gridSize),keyY=Math.floor(pos[1]/gridSize),keys=[keyX+"."+keyY],localX=pos[0]-keyX*gridSize,localY=pos[1]-keyY*gridSize,local=[localX,localY],addKey=function(deltaX,deltaY){keys.push(keyX+deltaX+"."+(keyY+deltaY))},tryAddDiagKey=function(cornerLocal,deltaX,deltaY){Vector2.distance(local,cornerLocal)<radius&&keys.push(keyX+deltaX+"."+(keyY+deltaY))},l=!1,r=!1,d=!1,u=!1;return localX<radius&&(addKey(-1,0),l=!0),localX>gridSize-radius&&(addKey(1,0),r=!0),localY<radius&&(addKey(0,-1),d=!0),localY>gridSize-radius&&(addKey(0,1),u=!0),l?u?tryAddDiagKey([0,gridSize],-1,1):d&&tryAddDiagKey([0,0],-1,-1):r&&(u?tryAddDiagKey([gridSize,gridSize],1,1):d&&tryAddDiagKey([gridSize,0],1,-1)),keys},PointDictionary.prototype.isActive=function(point){return!this.testActiveFunction||point&&this.testActiveFunction(point.val)},PointDictionary.prototype.getKey=function(position){return Math.floor(position[0]/this.gridSize)+"."+Math.floor(position[1]/this.gridSize)},PointDictionary.prototype.getOverlapping=function(pos){var key=this.getKey(pos);if(!this.tiles.has(key))return null;for(var points=Array.from(this.tiles.get(key).values()),i=0;i<points.length;i++){var point=points[i];if(Vector2.distance(pos,point.pos)<this.distThreshold)return point}return null},PointDictionary.prototype.getClosestUnder=function(pos,radius){var _this=this;void 0===radius&&(radius=this.radius);var key=this.getKey(pos),minDist=1/0,closest=null;return this.tiles.has(key)?(this.tiles.get(key).forEach((function(point){var distance=Vector2.distance(pos,point.pos);_this.isActive(point)&&distance<radius&&distance<minDist&&(minDist=distance,closest=point)})),closest):null},PointDictionary.prototype.clear=function(filter){var _this=this;filter?this.pointValues.forEach((function(point){if(filter(point.val,point.id)){for(var keys=_this.getKeys(point.pos),i=0;i<keys.length;i++){var key=keys[i],tile=_this.tiles.get(key);tile.delete(point.id),0==tile.size&&_this.tiles.delete(key)}_this.pointValues.delete(point.id)}})):(this.tiles=new Map,this.pointValues=new Map)},PointDictionary}(),Projector=function(){function Projector(project){this.project=project}return Projector.prototype.get=function(coord,zoom){return this.project(coord,zoom)},Projector.prototype.getVector2=function(coord,zoom){return new Vector2(this.project(coord,zoom))},Projector.prototype.batch=function(coords,zoom){for(var output=new Array(coords.length),i=0;i<coords.length;i++)output[i]=this.project(coords[i],zoom);return output},Projector.prototype.batchVector2=function(coords,zoom){for(var output=new Array(coords.length),i=0;i<coords.length;i++)output[i]=new Vector2(this.project(coords[i],zoom));return output},Projector}();function forceHighlight(module,wellbore){var highlight=module.highlight,pixiOverlay=module.pixiOverlay,root=wellbore.root,wellbores=[wellbore];highlight&&!highlight.equals(root,wellbores)&&(highlight.set(root,wellbores),pixiOverlay.redraw())}function clearHighlight(module,onHighlightOff){module.highlight.clear(),onHighlightOff&&onHighlightOff(),module.pixiOverlay.redraw()}var Highlight=function(){function Highlight(){this.active=!1}return Object.defineProperty(Highlight.prototype,"single",{get:function(){return 1==this.wellbores.length},enumerable:!1,configurable:!0}),Object.defineProperty(Highlight.prototype,"first",{get:function(){return this.wellbores[0]},enumerable:!1,configurable:!0}),Highlight.prototype.set=function(root,wellbores){if(!this.active)return this.root=root,this.wellbores=wellbores,this.highlightWellbores(),this.highlightRoot(),void(this.active=!0);this.root!==root||this.wellbores.length!==wellbores.length?(this.clear(),this.root=root,this.wellbores=wellbores,this.highlightWellbores(),this.highlightRoot()):(this.clearWellbores(),this.wellbores=wellbores,this.highlightWellbores()),this.active=!0},Highlight.prototype.highlightRoot=function(){this.root.recalculate(!1)},Highlight.prototype.highlightWellbores=function(){for(var multiple=this.wellbores.length>1,i=0;i<this.wellbores.length;i++)this.wellbores[i].setHighlight(!0,multiple)},Highlight.prototype.clear=function(){this.active&&(this.clearWellbores(),this.clearRoot(),this.active=!1)},Highlight.prototype.clearRoot=function(){this.root.recalculate(!1),delete this.root},Highlight.prototype.clearWellbores=function(){for(var i=0;i<this.wellbores.length;i++)this.wellbores[i].setHighlight(!1);delete this.wellbores},Highlight.prototype.equals=function(root,wellbores){if(this.root!=root)return!1;if(this.wellbores.length!=wellbores.length)return!1;for(var i=0;i<this.wellbores.length;i++){var wellbore=this.wellbores[i];if(!wellbores.includes(wellbore))return!1}return!0},Highlight}(),AsyncLoop=function(){function AsyncLoop(){this.timers={}}return AsyncLoop.prototype.Start=function(key,config,interval){var _this=this;void 0===interval&&(interval=3),this.Stop(key);var iterations=config.iterations,batchSize=config.batchSize,func=config.func,postFunc=config.postFunc,endFunc=config.endFunc,front=0,batch=function(){if(front>=iterations)return delete _this.timers[key],void(endFunc&&endFunc());for(var tail=Math.min(front+batchSize,iterations),i=front;i<tail;i++)func(i);postFunc&&postFunc(),front+=batchSize,_this.timers[key]=setTimeout(batch,interval)};this.timers[key]=setTimeout(batch,interval)},AsyncLoop.prototype.Stop=function(key){key in this.timers&&(clearTimeout(this.timers[key]),delete this.timers[key])},AsyncLoop.prototype.StopAll=function(){for(var keys=Object.keys(this.timers),i=0;i<keys.length;i++){var key=keys[i];clearTimeout(this.timers[key]),delete this.timers[key]}},AsyncLoop}(),DefaultEventHandler=function(){function DefaultEventHandler(){}return DefaultEventHandler.prototype.register=function(map,element,callbacks){this.map=map,this.element=element,this.callbacks=callbacks,element.addEventListener("mousemove",this.callbacks.mousemove),element.addEventListener("mouseout",this.callbacks.mouseout),element.addEventListener("click",this.callbacks.click),element.addEventListener("mousedown",this.callbacks.mousedown),element.addEventListener("mouseup",this.callbacks.mouseup)},DefaultEventHandler.prototype.unregister=function(){var element=this.element;element.removeEventListener("mousemove",this.callbacks.mousemove),element.removeEventListener("mouseout",this.callbacks.mouseout),element.removeEventListener("click",this.callbacks.click),element.removeEventListener("mousedown",this.callbacks.mousedown),element.removeEventListener("mouseup",this.callbacks.mouseup),this.map=null,this.element=null},DefaultEventHandler}(),RealtimeWellbore=function(){function RealtimeWellbore(mapInput,wellbore){if(this.prevCoords=[Number.MIN_VALUE,Number.MIN_VALUE],mapInput.utils&&"getMap"in mapInput.utils){var pixiOverlay=mapInput;this.map=pixiOverlay.utils.getMap()}else this.map=mapInput;this.root=wellbore.data.path[0]}return Object.defineProperty(RealtimeWellbore.prototype,"pixelCoordinates",{get:function(){var map=this.map,containerPoint=map.latLngToContainerPoint(this.root),rect=map.getContainer().getBoundingClientRect(),coords=[rect.x+containerPoint.x,rect.y+containerPoint.y];return this.prevCoords=coords,coords},enumerable:!1,configurable:!0}),RealtimeWellbore.prototype.getPixelCoordinates=function(){var prevCoords=this.prevCoords,coords=this.pixelCoordinates;return{coords:coords,changed:!this.coordinatesEqual(coords,prevCoords,1e-5)}},RealtimeWellbore.prototype.coordinatesEqual=function(c1,c2,delta){return!(Math.abs(c1[0]-c2[0])>delta)&&!(Math.abs(c1[1]-c2[1])>delta)},RealtimeWellbore}(),WellboreModule=function(_super){function WellboreModule(inputConfig){var _this=_super.call(this)||this;_this.groups={},_this.roots=[],_this.asyncLoop=new AsyncLoop,_this.highlight=new Highlight,_this.currentZoom=20;var _a=function(input){var outputConfig={scale:1,batchSize:20,zoomOrigin:0,gridSize:2,wellboreResize:{min:{zoom:10,scale:.01},max:{zoom:18,scale:.001}},rootResize:{min:{zoom:0,scale:1e3},max:{zoom:18,scale:.2}},tick:{width:.02,height:.2}},outputExtra={labelBgOpacity:.5,labelScale:.011,fontSize:18,scaling:void 0,wellboreDash:.01};if(!input)return[outputConfig,outputExtra];function transfer(key,target){isNaN(input[key])||(target[key]=input[key])}function transferFunction(key,target){"function"==typeof input[key]&&(target[key]=input[key])}function transferObj(key,target){input[key]&&(target[key]=input[key])}return transfer("rootRadius",outputConfig),transfer("batchSize",outputConfig),transfer("zoomOrigin",outputConfig),transfer("gridSize",outputConfig),transfer("labelBgOpacity",outputExtra),transfer("labelScale",outputExtra),transfer("fontSize",outputExtra),transfer("wellboreDash",outputExtra),transferFunction("scaling",outputExtra),transferFunction("onWellboreClick",outputConfig),transferFunction("onHighlightOn",outputConfig),transferFunction("onHighlightOff",outputConfig),transferObj("wellboreResize",outputConfig),transferObj("rootResize",outputConfig),transferObj("tick",outputConfig),[outputConfig,outputExtra]}(inputConfig),config=_a[0],extra=_a[1];_this.config=config,_this.scaling=extra.scaling,_this.lineDict=new LineDictionary(config.gridSize,(function(value){return value.active})),_this.pointDict=new PointDictionary(.25,10*config.gridSize,_this.getRootRadius(20),(function(value){return value.active})),_this.registerGroup("default");var createContainer=function(){var container=new PIXI.Container;return container.sortableChildren=!0,_this.root.addChild(container),container};return _this.containers={wellbores:createContainer(),roots:createContainer(),labels:createContainer()},Label.setStyle(extra.fontSize),Label.setCommon({backgroundOpacity:extra.labelBgOpacity}),_this._eventHandler=inputConfig&&inputConfig.customEventHandler||new DefaultEventHandler,RootShader.build(config.rootResize.max.scale),WellboreShader.build(config.wellboreResize.max.scale,extra.wellboreDash),_this}return __extends(WellboreModule,_super),WellboreModule.prototype.destroy=function(){this.asyncLoop.StopAll(),_super.prototype.destroy.call(this)},WellboreModule.prototype.registerGroup=function(key,options){if(this.groups[key])throw Error("Group ["+key+"] already registered!");this.groups[key]=new Group(key,options)},WellboreModule.prototype.addRoot=function(position){var overlapping=this.pointDict.getOverlapping(position);if(overlapping)return overlapping.val;var wellboreRoot=new RootData(position,this.config.rootResize.max.scale);return this.containers.roots.addChild(wellboreRoot.mesh),this.pointDict.add(position,wellboreRoot),this.roots.push(wellboreRoot),wellboreRoot},WellboreModule.prototype.addWellbore=function(data,group){if(void 0===group&&(group=this.groups.default),0===data.path.length)throw Error("Empty wellbore path!");var projectedPath=this.projector.batchVector2(data.path),root=this.addRoot(projectedPath[0]),_a=this.config,rootResize=_a.rootResize,wellboreResize=_a.wellboreResize,tick=_a.tick,wellbore=new WellboreData({data:data,group:group,root:root,coords:projectedPath,pointThreshold:1.5*rootResize.max.scale,wellboreWidth:wellboreResize.max.scale,tick:tick});wellbore.mesh&&this.containers.wellbores.addChild(wellbore.mesh),this.containers.labels.addChild(wellbore.label.text),this.containers.labels.addChild(wellbore.label.background),group.append(wellbore),null==root||root.recalculate(!0),wellbore.interpolator.singlePoint||this.lineDict.add(projectedPath,wellbore),null==root||root.append(wellbore),this._deferredSelector&&this._deferredSelector(wellbore.data)&&(this._deferredSelector=void 0,wellbore.setSelected(!0))},WellboreModule.prototype.set=function(wells,key,batchSize){var _this=this;return void 0===key&&(key="default"),void 0===batchSize&&(batchSize=null),new Promise((function(resolve,reject){var group=_this.groups[key];if(group)try{_this.groups[key].wellbores.length>0&&_this.clear(key),_this.asyncLoop.Start(key,{iterations:wells.length,batchSize:batchSize||_this.config.batchSize||20,func:function(i){return _this.addWellbore(wells[i],group)},postFunc:function(){return _this.pixiOverlay.redraw()},endFunc:function(){_this.pixiOverlay.redraw(),resolve()}},0)}catch(err){reject(err)}else reject(Error("Group ["+key+"] not registered!"))}))},WellboreModule.prototype.forEachGroup=function(keys,func){var _this=this,registeredKeys=Object.keys(this.groups);(keys=0==keys.length?registeredKeys:keys.filter((function(key){return registeredKeys.includes(key)}))).forEach((function(key){return func(_this.groups[key],key)})),this.pixiOverlay.redraw()},WellboreModule.prototype.setActive=function(active,keys){this.forEachGroup(keys,(function(group){return group.setActive(active)}))},WellboreModule.prototype.handleMouseMove=function(event){var latLng=this.pixiOverlay.utils.getMap().mouseEventToLatLng(event);return function(module,pos,onHighlightOn,onHighlightOff,originalEvent){var wellbores;!(wellbores=function(pos,radius,pointDict){var root=pointDict.getClosestUnder(pos,radius);return root?root.val.wellbores.filter((function(d){return d.active})):null}(pos,module.getRootRadius(),module.pointDict))&&module.containers.labels.visible&&(wellbores=function(pos,roots){for(var candidates=roots.filter((function(root){return root.active&&root.rootLabelsBBox&&root.rootLabelsBBox.contains(pos.x,pos.y)})),i=0;i<candidates.length;i++)for(var j=0;j<candidates[i].wellbores.length;j++){var wellbore=candidates[i].wellbores[j];if(wellbore.active&&wellbore.label.attachToRoot){var bbox=wellbore.label.getBoundingBox();if(bbox.y>pos.y)break;if(bbox.contains(pos.x,pos.y))return[wellbore]}}return null}(pos,module.roots)),wellbores||(wellbores=function(pos,lineDict,distanceThreshold){void 0===distanceThreshold&&(distanceThreshold=.5);var hit=lineDict.getClosest(pos,distanceThreshold);return hit?[hit]:null}(pos,module.lineDict,.5));var highlight=module.highlight,pixiOverlay=module.pixiOverlay;if(wellbores){var root=wellbores[0].root,changed=!1;highlight&&!highlight.equals(root,wellbores)&&(changed=!0,highlight.set(root,wellbores),pixiOverlay.redraw()),onHighlightOn&&onHighlightOn(HighlightEvent.from(wellbores,changed,originalEvent))}else highlight&&clearHighlight(module,onHighlightOff)}(this,this.projector.getVector2(latLng),this.config.onHighlightOn,this.config.onHighlightOff,event),this.highlight.active},WellboreModule.prototype.handleMouseOut=function(){return this.clearHighlight(this.config.onHighlightOff)},WellboreModule.prototype.handleMouseClick=function(){if(this.config.onWellboreClick&&this.highlight.active&&this.highlight.single){var wellbore=this.highlight.first;return this.config.onWellboreClick({group:wellbore.group.key,data:wellbore.data}),!0}return!1},WellboreModule.prototype.enable=function(){for(var keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];this.setActive(!0,keys)},WellboreModule.prototype.disable=function(){for(var keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];this.setActive(!1,keys)},WellboreModule.prototype.setLabelVisibility=function(visible){Label.state.visible=visible,this.roots.forEach((function(root){return root.setLabelVisibility(visible)})),this.pixiOverlay.redraw()},WellboreModule.prototype.setCompletionVisibility=function(visible){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];this.forEachGroup(keys,(function(group){return group.setCompletionVisibility(visible)}))},WellboreModule.prototype.setWellboresVisibility=function(visible){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];this.forEachGroup(keys,(function(group){return group.setWellboreVisibility(visible)}))},WellboreModule.prototype.softFilter=function(filterFunction){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];this.forEachGroup(keys,(function(group){return group.softFilter(filterFunction)}))},WellboreModule.prototype.hardFilter=function(filterFunction){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];this.forEachGroup(keys,(function(group){return group.hardFilter(filterFunction)}))},WellboreModule.prototype.clearFilter=function(){for(var keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];this.forEachGroup(keys,(function(group){return group.clearFilter()}))},WellboreModule.prototype.setSelected=function(selectFunction){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];var nSelected=0;this.forEachGroup(keys,(function(group){group&&group.wellbores.forEach((function(wellbore){selectFunction(wellbore.data)?(wellbore.setSelected(!0),nSelected++):wellbore.selected&&wellbore.setSelected(!1)}))})),0===nSelected&&(this._deferredSelector=selectFunction)},WellboreModule.prototype.clearSelected=function(){for(var keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];this.forEachGroup(keys,(function(group){group&&group.wellbores.forEach((function(wellbore){wellbore.selected&&wellbore.setSelected(!1)}))}))},WellboreModule.prototype.setHighlight=function(label){for(var keys=[],_i=1;_i<arguments.length;_i++)keys[_i-1]=arguments[_i];var registeredKeys=Object.keys(this.groups);keys=0==keys.length?registeredKeys:keys.filter((function(key){return registeredKeys.includes(key)}));for(var n=0;n<keys.length;n++){var group=this.groups[keys[n]];if(group)for(var wellbores=group.wellbores,i=0;i<wellbores.length;i++){var wellbore=wellbores[i];if(wellbore.data.label===label)return forceHighlight(this,wellbore),new RealtimeWellbore(this.pixiOverlay,wellbore)}}return null},WellboreModule.prototype.clearHighlight=function(onHighlightOff){return!!this.highlight.active&&(clearHighlight(this,onHighlightOff),!0)},WellboreModule.prototype.clearAll=function(){this.highlight.clear(),this.asyncLoop.StopAll(),this.lineDict.clear(),this.pointDict.clear(),Object.values(this.groups).forEach((function(g){g.wellbores=[]})),this.roots=[],this.containers.wellbores.removeChildren().forEach((function(child){return child.destroy()})),this.containers.labels.removeChildren().forEach((function(child){return child.destroy()})),this.containers.roots.removeChildren().forEach((function(child){return child.destroy()})),this.pixiOverlay.redraw()},WellboreModule.prototype.clear=function(){for(var _this=this,keys=[],_i=0;_i<arguments.length;_i++)keys[_i]=arguments[_i];if(0===keys.length)return this.clearAll();this.highlight.clear();var roots=new Set;this.forEachGroup(keys,(function(group,key){_this.asyncLoop.Stop(key),_this.lineDict.clear((function(d){return group.wellbores.includes(d)})),group.wellbores.forEach((function(w){var _a,_b,_c,_d,_e;roots.add(w.root);var wellboreIdx=w.root.wellbores.indexOf(w);-1!==wellboreIdx&&w.root.wellbores.splice(wellboreIdx,1),null===(_a=w.mesh)||void 0===_a||_a.destroy(),null===(_c=null===(_b=w.label)||void 0===_b?void 0:_b.text)||void 0===_c||_c.destroy(),null===(_e=null===(_d=w.label)||void 0===_d?void 0:_d.background)||void 0===_e||_e.destroy()})),group.wellbores=[]})),roots.forEach((function(root){if(root.wellbores.length>0)root.recalculate(!0);else{var rootIdx=_this.roots.indexOf(root);-1!==rootIdx&&_this.roots.splice(rootIdx,1),_this.pointDict.clear((function(d){return d===root})),_this.containers.roots.removeChild(root.mesh)}})),this.pixiOverlay.redraw()},WellboreModule.prototype.resize=function(zoom){this.currentZoom=zoom;var wellboreRadius=this.getWellboreRadius(zoom),rootRadius=this.getRootRadius(zoom);if(this.pixiOverlay._renderer.globalUniforms.uniforms.wellboreRadius=wellboreRadius,this.pixiOverlay._renderer.globalUniforms.uniforms.rootRadius=rootRadius,this.scaling){var scale=this.scaling(zoom-this.config.zoomOrigin);Number.isFinite(scale)||(scale=1),Label.state.zoom=zoom,Label.state.scale=scale,Label.state.rootDisplacement=rootRadius;var labelVisible=zoom>10;this.containers.labels.visible=labelVisible,labelVisible&&Label.state.visible&&this.roots.forEach((function(root){return root.updateLabels()}))}},WellboreModule.prototype.onAdd=function(map){var element=this.pixiOverlay.utils.getRenderer().view.parentNode,callbacks={mousemove:this.handleMouseMove.bind(this),mouseout:this.handleMouseOut.bind(this),click:this.handleMouseClick.bind(this),mousedown:function(){return!0},mouseup:function(){return!0}};this._eventHandler.register(map,element,callbacks)},WellboreModule.prototype.onRemove=function(map){this._eventHandler.unregister()},Object.defineProperty(WellboreModule.prototype,"projector",{get:function(){return this._projector||(this._projector=new Projector(this.pixiOverlay.utils.latLngToLayerPoint)),this._projector},enumerable:!1,configurable:!0}),WellboreModule.prototype.getRootRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),this.getRadius(zoom,this.config.rootResize)},WellboreModule.prototype.getWellboreRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),this.getRadius(zoom,this.config.wellboreResize)},WellboreModule.prototype.getRadius=function(zoom,_a){var min=_a.min,max=_a.max,zoomClamped=clamp(zoom,min.zoom,max.zoom)-min.zoom,t=Math.pow(2,-zoomClamped);return lerp(max.scale,min.scale,t)},WellboreModule}(ModuleInterface);function centerOfMass(vertices,triangles){for(var comX=0,comY=0,totalMass=0,i=0;i<triangles.length;i+=3){var a=vertices[triangles[i]],b=vertices[triangles[i+1]],c=vertices[triangles[i+2]],ab=Vector2.sub(b,a),ac=Vector2.sub(c,a),mass=.5*Vector2.cross(ab,ac);comX+=mass*(a.x+b.x+c.x)/3,comY+=mass*(a.y+b.y+c.y)/3,totalMass+=mass}return[new Vector2(comX/totalMass,comY/totalMass),totalMass]}var Hightlighter=function(){function Hightlighter(fillColor1,fillColor2,outlineColor){this.fields=[],this.cached=[],this.fillColor1=fillColor1,this.fillColor2=fillColor2,this.outlineColor=outlineColor}return Hightlighter.prototype.add=function(group){this.fields.push(group)},Hightlighter.prototype.highlight=function(index){var target=this.fields[index];this.cached&&this.revert(),this.cached=new Array(target.length);for(var i=0;i<target.length;i++){var field=target[i];this.cached[i]={fillCol1:field.fill.uniform.col1,fillCol2:field.fill.uniform.col2,outlineCol:field.outline.uniform.color,baseZIndex:field.fill.mesh.zIndex,field:field},field.fill.uniform.col1=this.fillColor1,field.fill.uniform.col2=this.fillColor2,field.fill.mesh.zIndex+=1e4,field.outline.uniform.color=this.outlineColor,field.outline.mesh.zIndex+=1e4}},Hightlighter.prototype.revert=function(){return!!this.cached&&(this.cached.forEach((function(d){d.field.fill.uniform.col1=d.fillCol1,d.field.fill.uniform.col2=d.fillCol2,d.field.fill.mesh.zIndex=d.baseZIndex,d.field.outline.uniform.color=d.outlineCol,d.field.outline.mesh.zIndex=d.baseZIndex+1})),this.cached=void 0,!0)},Hightlighter}();function recalculatePosition(labels,selfIndex,targetIndiced){var self=labels[selfIndex],comX=self.mass*self.position[0],comY=self.mass*self.position[1],totalMass=self.mass;return targetIndiced.forEach((function(idx){var target=labels[idx];comX+=target.mass*target.position[0],comY+=target.mass*target.position[1],totalMass+=target.mass})),[comX/totalMass,comY/totalMass]}var LabelManager=function(){function LabelManager(textStyle,baseScale){this.fields=[],this.multiFields=[],this.prevScale=1,this.visible=!0,this.textStyle=textStyle,this.baseScale=baseScale}return LabelManager.prototype.addField=function(name,entries){if(entries.length<=1)this.fields.push({name:name,position:entries[0].position,instance:null});else{var textMetrics=PIXI.TextMetrics.measureText(name,this.textStyle),width=textMetrics.width*this.baseScale,height=textMetrics.height*this.baseScale,labels=entries.map((function(entry){return{position:entry.position,mass:entry.mass,instance:null,active:!0,consumed:[],consumer:-1}}));this.multiFields.push({name:name,labels:labels,width:width,height:height})}},LabelManager.prototype.draw=function(root){var _this=this,drawLabel=function(name,position){var instance=new PIXI.Text(name,_this.textStyle);return instance.resolution=2,instance.position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor.set(.5),instance.zIndex=1e5,root.addChild(instance),instance};this.fields.forEach((function(field){field.instance=drawLabel(field.name,field.position)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance=drawLabel(field.name,label.position)}))}))},LabelManager.prototype.resize=function(scale){var _this=this;this.fields.forEach((function(field){field.instance.scale.set(scale*_this.baseScale)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.scale.set(scale*_this.baseScale)}));for(var centers=function(field,scale){for(var labels=field.labels,groups=[],i=0;i<labels.length;i++)groups.push({index:i,consumed:[],consumer:-1});for(i=0;i<labels.length;i++)if(!((group=groups[i]).consumer>=0))for(var label=labels[i],_loop_1=function(j){var _a;if(i===j)return"continue";var a,b,dist,compLabel=labels[j];if(a=label,b=compLabel,dist=Vector2.sub(a.position,b.position),Math.abs(dist[0])<field.width*scale&&Math.abs(dist[1])<field.height*scale){var compIndex_1=j,compGroup=groups[j];if(compGroup.consumer>=0){if((compIndex_1=compGroup.consumer)===i)return"continue";compGroup=groups[compGroup.consumer]}return(_a=compGroup.consumed).push.apply(_a,__spreadArray(__spreadArray([],group.consumed),[i])),group.consumed.forEach((function(d){return groups[d].consumer=compIndex_1})),group.consumed=[],group.consumer=compIndex_1,"break"}},j=0;j<labels.length&&"break"!==_loop_1(j);j++);var output=[];for(i=0;i<groups.length;i++){var group;(group=groups[i]).consumer>=0||output.push(recalculatePosition(labels,group.index,group.consumed))}return output}(field,scale),i=0;i<centers.length;i++){var label=field.labels[i],pos=centers[i];label.instance.visible=!0,label.instance.position.set(pos[0],pos[1])}for(i=centers.length;i<field.labels.length;i++){(label=field.labels[i]).instance.visible=!1}})),this.prevScale=scale},LabelManager.prototype.hideLabels=function(){this.fields.forEach((function(field){field.instance.visible=!1})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.visible=!1}))})),this.visible=!1},LabelManager.prototype.showLabels=function(){this.fields.forEach((function(field){field.instance.visible=!0})),this.visible=!0},LabelManager}();var TriangleDictionary=function(){function TriangleDictionary(decimals){void 0===decimals&&(decimals=0),this.tiles=new Map,this.triangles=[],this.polygonValues=[],this.resolution=Math.pow(10,decimals)}return TriangleDictionary.prototype.add=function(vertices,triangles,value){var v1,v2,v3,polygonID=this.polygonValues.length;this.polygonValues.push(value);for(var i=0;i<triangles.length;i+=3){var triangleID=this.triangles.length;v1=vertices[triangles[i]],v2=vertices[triangles[i+1]],v3=vertices[triangles[i+2]],this.triangles.push({v1:v1,v2:v2,v3:v3,polygonID:polygonID});for(var minX=Math.min(v1[0],v2[0],v3[0]),maxX=Math.max(v1[0],v2[0],v3[0]),minY=Math.min(v1[1],v2[1],v3[1]),maxY=Math.max(v1[1],v2[1],v3[1]),tileMinX=Math.floor(minX*this.resolution),tileMaxX=Math.floor(maxX*this.resolution),tileMinY=Math.floor(minY*this.resolution),tileMaxY=Math.floor(maxY*this.resolution),x=tileMinX;x<=tileMaxX;x++)for(var y=tileMinY;y<=tileMaxY;y++){var key=x+"."+y;this.tiles.has(key)?this.tiles.get(key).push(triangleID):this.tiles.set(key,[triangleID])}}},TriangleDictionary.prototype.getPolygonAt=function(target){var key=Math.floor(target[0]*this.resolution)+"."+Math.floor(target[1]*this.resolution);if(!this.tiles.has(key))return null;for(var p,v1,v2,v3,k1,k2,k3,triangles=this.tiles.get(key),i=0;i<triangles.length;i++){var triangle=this.triangles[triangles[i]];if(p=target,v1=triangle.v1,v2=triangle.v2,v3=triangle.v3,k1=void 0,k2=void 0,k3=void 0,k1=(p[0]-v1[0])*(v2[1]-v1[1])-(p[1]-v1[1])*(v2[0]-v1[0]),k2=(p[0]-v2[0])*(v3[1]-v2[1])-(p[1]-v2[1])*(v3[0]-v2[0]),k3=(p[0]-v3[0])*(v1[1]-v3[1])-(p[1]-v3[1])*(v1[0]-v3[0]),k1<0?k2<0&&k3<0:k2>=0&&k3>=0)return this.polygonValues[triangle.polygonID]}return null},TriangleDictionary}(),red=[.8,0,0],green=[.133,.6,.133],pink=[1,.753,.796],gray=[.6,.6,.6],outlineRed=[.6,0,0],outlineGray=[.5,.5,.5],FieldModule=function(_super){function FieldModule(config){var _this=_super.call(this)||this;return _this.fields=[],_this.config={initialHash:1,minHash:0,maxHash:1/0},_this.dict=new TriangleDictionary(1.2),_this.prevField=-1,config?(config.initialHash&&"number"==typeof config.initialHash&&(_this.config.initialHash=config.initialHash),config.minHash&&"number"==typeof config.minHash&&(_this.config.minHash=config.minHash),config.maxHash&&"number"==typeof config.maxHash&&(_this.config.maxHash=config.maxHash),_this):_this}return __extends(FieldModule,_super),FieldModule.prototype.set=function(data){var _this=this;this.config.initialHash=clamp(this.config.initialHash),this.fields=[];var textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:64,fontWeight:"600",fill:4539717,align:"center"});this.labelManager=new LabelManager(textStyle,.029),this.highlighter=new Hightlighter([.5,0,.5],[.25,0,.25],[.35,0,.35]);var preprocessedData=function(data){var unique={};return data.forEach((function(field){var fieldName=field.properties.label,coordinates=[],geometry=field.geometry;if("Polygon"===geometry.type)coordinates=geometry.coordinates;else for(var multipolygons=geometry.coordinates,i=0;i<multipolygons.length;i++)coordinates.push.apply(coordinates,multipolygons[i]);function appendIndex(index){unique[fieldName].geometry.push({coordinates:coordinates[index],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}})}if(unique.hasOwnProperty(fieldName))for(i=0;i<coordinates.length;i++)appendIndex(i);else if(unique[fieldName]={type:field.type,geometry:[{coordinates:coordinates[0],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}}],properties:{group:field.properties.group,guid:field.properties.guid,label:field.properties.label,lat:field.properties.lat,long:field.properties.long}},coordinates.length>1)for(i=1;i<coordinates.length;i++)appendIndex(i)})),Object.values(unique)}(data),fieldID=0,baseZIndex=0;preprocessedData.forEach((function(field){var _a,name=field.properties.label;if("Troll"!==name){var guid=field.properties.guid,entries=[],meshes=[];field.geometry.forEach((function(polygon){var fieldStyle=_this.getFieldStyle(guid,polygon.properties.hctype),projected=_this.projectPolygons(polygon.coordinates);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(polygon.coordinates,meshData.triangles,fieldID);var outlineData=Mesh.PolygonOutline(projected,.15),_a=centerOfMass(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(meshData,outlineData,fieldStyle,baseZIndex)),baseZIndex+=2,entries.push({position:position,mass:mass})})),fieldID++,_this.labelManager.addField(name,entries),(_a=_this.fields).push.apply(_a,meshes),_this.highlighter.add(meshes)}})),this.labelManager.draw(this.root)},FieldModule.prototype.drawPolygons=function(meshData,outlineData,fieldStyle,zIndex){var fillUniform={col1:fieldStyle.fillColor1,col2:fieldStyle.fillColor2,opacity:fieldStyle.fillOpacity,hashed:fieldStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},outlineUniform={color:fieldStyle.outlineColor,width:0},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,FieldModule.vertexShaderFill,FieldModule.fragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,this.root.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,FieldModule.vertexShaderOutline,FieldModule.fragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,this.root.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},FieldModule.prototype.getFieldStyle=function(guid,hctype){if(!guid)return{fillColor1:gray,fillColor2:gray,outlineColor:outlineGray,fillOpacity:.15,hashed:!1};var fill={fillColor1:green,fillColor2:green,outlineColor:green,fillOpacity:.6,hashed:!1};switch(hctype){case"GAS":fill.fillColor1=red,fill.fillColor2=red,fill.outlineColor=outlineRed;break;case"GAS/CONDENSATE":fill.fillColor1=pink,fill.fillColor2=red,fill.outlineColor=outlineRed,fill.hashed=!0;break;case"OIL/GAS":fill.fillColor1=red,fill.hashed=!0}return fill},FieldModule.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},FieldModule.prototype.resize=function(zoom){},FieldModule.prototype.highlight=function(lat,long){var field=this.dict.getPolygonAt([long,lat]);return field?(this.prevField===field||(this.highlighter.highlight(field),this.pixiOverlay.redraw(),this.prevField=field),!0):(this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1,!1)},FieldModule.prototype.tryUnselect=function(){this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1},FieldModule}(ModuleInterface);FieldModule.vertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2, 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1, 1.0) * opacity;\n }\n }\n",FieldModule.vertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color, 1.0);\n }\n";var GeoJSONLabels=function(){function GeoJSONLabels(root,textStyle,baseScale,fontName){this.labels=[],this.visible=!0,this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.textStyle=textStyle,this.baseScale=baseScale,this.fontName=fontName||v4(),this.font=PIXI.BitmapFont.from(this.fontName,this.textStyle,{resolution:window.devicePixelRatio,chars:PIXI.BitmapFont.ASCII})}return GeoJSONLabels.prototype.addLabel=function(name,data){this.labels.push({name:name,position:data.position,instance:null})},GeoJSONLabels.prototype.draw=function(){var _this=this;this.labels.forEach((function(label){var name,position,instance;label.instance=(name=label.name,position=label.position,(instance=new PIXI.BitmapText(name,{fontName:_this.fontName})).position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor=new PIXI.Point(.5,.5),instance.zIndex=1e3,_this.container.addChild(instance),instance)}))},GeoJSONLabels.prototype.hideLabels=function(){this.container.visible=!1,this.visible=!1},GeoJSONLabels.prototype.showLabels=function(){this.container.visible=!0,this.visible=!0},GeoJSONLabels.prototype.resize=function(scale){this.labels.forEach((function(lbl){return lbl.instance.scale.set(scale)}))},GeoJSONLabels}(),GeoJSONVertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n ",GeoJSONFragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2 / 255., 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1 / 255., 1.0) * opacity;\n }\n }\n ",GeoJSONVertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float outlineWidth;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * outlineWidth;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n ",GeoJSONFragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color / 255., 1.0);\n }\n ";function getRadius(zoom,_a){var min=_a.min,max=_a.max,zoomClamped=clamp(zoom,min.zoom,max.zoom)-min.zoom,t=Math.pow(2,-zoomClamped);return lerp(max.scale,min.scale,t)}var Defaults=function(){function Defaults(){}return Defaults.DEFAULT_Z_INDEX=1e3,Defaults.DEFAULT_LINE_WIDTH=.15,Defaults.INITIAL_ZOOM=20,Defaults.DEFAULT_FONT_FAMILY="Arial",Defaults.DEFAULT_FONT_SIZE=64,Defaults.DEFAULT_FONT_WEIGHT="600",Defaults.DEFAULT_LABEL_COLOR=4539717,Defaults.DEFAULT_LABEL_ALIGN="center",Defaults.INITIAL_HASH=1,Defaults.DEFAULT_MIN_HASH=0,Defaults.DEFAULT_BASE_SCALE=.1,Defaults}(),GeoJSONMultiPolygon=function(){function GeoJSONMultiPolygon(root,labelRoot,pixiOverlay,config){var _a;this.features=[],this.config={initialHash:Defaults.INITIAL_HASH,minHash:Defaults.DEFAULT_MIN_HASH,maxHash:1/0},this.dict=new TriangleDictionary(1.2),this.currentZoom=Defaults.INITIAL_ZOOM,(null==config?void 0:config.initialHash)&&"number"==typeof config.initialHash&&(this.config.initialHash=config.initialHash),(null==config?void 0:config.minHash)&&"number"==typeof config.minHash&&(this.config.minHash=config.minHash),(null==config?void 0:config.maxHash)&&"number"==typeof config.maxHash&&(this.config.maxHash=config.maxHash),this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.pixiOverlay=pixiOverlay,this.features=[],this.config=config,this.config.initialHash=clamp(this.config.initialHash),this.textStyle=new PIXI.TextStyle({fontFamily:(null==config?void 0:config.labelFontFamily)||Defaults.DEFAULT_FONT_FAMILY,fontSize:(null==config?void 0:config.labelFontSize)||Defaults.DEFAULT_FONT_SIZE,fontWeight:(null==config?void 0:config.labelFontWeight)||Defaults.DEFAULT_FONT_WEIGHT,fill:(null==config?void 0:config.labelColor)||Defaults.DEFAULT_LABEL_COLOR,align:(null==config?void 0:config.labelAlign)||Defaults.DEFAULT_LABEL_ALIGN}),this.labels=new GeoJSONLabels(labelRoot||this.container,this.textStyle,(null===(_a=this.config.labelResize)||void 0===_a?void 0:_a.baseScale)||Defaults.DEFAULT_BASE_SCALE)}return GeoJSONMultiPolygon.prototype.add=function(feature,props){var _a,_this=this,geom=feature.geometry,properties=props(feature);properties.style.labelScale&&(this.labels.baseScale=properties.style.labelScale);var meshes=[],coordinateGroup=geom.coordinates;(null==coordinateGroup?void 0:coordinateGroup.length)>0&&(coordinateGroup.forEach((function(coordinates){var projected=_this.projectPolygons(coordinates[0]);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(coordinates[0],meshData.triangles,feature.properties);var outlineData=Mesh.PolygonOutline(projected,Defaults.DEFAULT_LINE_WIDTH),_a=centerOfMass(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(_this.container,meshData,outlineData,properties.style,Defaults.DEFAULT_Z_INDEX)),properties.label&&_this.labels.addLabel(properties.label,{position:position,mass:mass})})),(_a=this.features).push.apply(_a,meshes))},GeoJSONMultiPolygon.prototype.drawPolygons=function(container,meshData,outlineData,featureStyle,zIndex){var fillColor=featureStyle.fillColor?color(featureStyle.fillColor).rgb():void 0,fillColor2=featureStyle.fillColor2?color(featureStyle.fillColor2).rgb():void 0,fillUniform={col1:fillColor?[fillColor.r,fillColor.g,fillColor.b]:[0,0,0],col2:fillColor2?[fillColor2.r,fillColor2.g,fillColor2.b]:[0,0,0],opacity:featureStyle.fillOpacity,hashed:featureStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},lineColor=color(featureStyle.lineColor).rgb(),outlineUniform={color:[lineColor.r,lineColor.g,lineColor.b],outlineWidth:featureStyle.lineWidth},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,GeoJSONVertexShaderFill,GeoJSONFragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,container.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,GeoJSONVertexShaderOutline,GeoJSONFragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,container.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},GeoJSONMultiPolygon.prototype.drawLabels=function(){this.labels.draw()},GeoJSONMultiPolygon.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},GeoJSONMultiPolygon.prototype.resize=function(zoom){if(this.config.outlineResize){var outlineRadius=this.getOutlineRadius(zoom);if(this.config.labelResize){var labelSize=this.getLabelSize(zoom);zoom<=this.config.labelResize.threshold?this.labels.hideLabels():(this.labels.showLabels(),this.labels.resize(labelSize))}this.container.children.map((function(child){child.shader.uniformGroup.uniforms.outlineWidth&&(child.shader.uniformGroup.uniforms.outlineWidth=outlineRadius)})),this.currentZoom=zoom}},GeoJSONMultiPolygon.prototype.testPosition=function(pos){return this.dict.getPolygonAt([pos.x,pos.y])},GeoJSONMultiPolygon.prototype.getOutlineRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.outlineResize)},GeoJSONMultiPolygon.prototype.getLabelSize=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.labelResize)},GeoJSONMultiPolygon}(),GeoJSONPolygon=function(){function GeoJSONPolygon(root,labelRoot,pixiOverlay,config){var _a;this.features=[],this.config={initialHash:Defaults.INITIAL_HASH,minHash:Defaults.DEFAULT_MIN_HASH,maxHash:1/0},this.dict=new TriangleDictionary(1.2),this.currentZoom=Defaults.INITIAL_ZOOM,this.outlineThickness=Defaults.DEFAULT_LINE_WIDTH,this.zIndex=Defaults.DEFAULT_Z_INDEX,(null==config?void 0:config.initialHash)&&"number"==typeof config.initialHash&&(this.config.initialHash=config.initialHash),(null==config?void 0:config.minHash)&&"number"==typeof config.minHash&&(this.config.minHash=config.minHash),(null==config?void 0:config.maxHash)&&"number"==typeof config.maxHash&&(this.config.maxHash=config.maxHash),this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.pixiOverlay=pixiOverlay,this.features=[],this.config=config,this.config.initialHash=clamp(this.config.initialHash),this.textStyle=new PIXI.TextStyle({fontFamily:(null==config?void 0:config.labelFontFamily)||Defaults.DEFAULT_FONT_FAMILY,fontSize:(null==config?void 0:config.labelFontSize)||Defaults.DEFAULT_FONT_SIZE,fontWeight:(null==config?void 0:config.labelFontWeight)||Defaults.DEFAULT_FONT_WEIGHT,fill:(null==config?void 0:config.labelColor)||Defaults.DEFAULT_LABEL_COLOR,align:(null==config?void 0:config.labelAlign)||Defaults.DEFAULT_LABEL_ALIGN}),this.labels=new GeoJSONLabels(labelRoot||this.container,this.textStyle,(null===(_a=this.config.labelResize)||void 0===_a?void 0:_a.baseScale)||Defaults.DEFAULT_BASE_SCALE)}return GeoJSONPolygon.prototype.add=function(feature,props){var _a,geom=feature.geometry,properties=props(feature);properties.style.labelScale&&(this.labels.baseScale=properties.style.labelScale);var meshes=[],coordinates=geom.coordinates;if((null==coordinates?void 0:coordinates.length)>0){var projected=this.projectPolygons(coordinates[0]);projected.pop();var meshData=Mesh.Polygon(projected);this.dict.add(coordinates[0],meshData.triangles,feature.properties);var outlineData=Mesh.PolygonOutline(projected,this.outlineThickness),_b=centerOfMass(projected,meshData.triangles),position=_b[0],mass=_b[1];meshes.push(this.drawPolygons(this.container,meshData,outlineData,properties.style,this.zIndex)),properties.label&&this.labels.addLabel(properties.label,{position:position,mass:mass}),(_a=this.features).push.apply(_a,meshes)}},GeoJSONPolygon.prototype.drawPolygons=function(container,meshData,outlineData,featureStyle,zIndex){var fillColor=featureStyle.fillColor?color(featureStyle.fillColor).rgb():void 0,fillColor2=featureStyle.fillColor2?color(featureStyle.fillColor2).rgb():void 0,fillUniform={col1:fillColor?[fillColor.r,fillColor.g,fillColor.b]:[0,0,0],col2:fillColor2?[fillColor2.r,fillColor2.g,fillColor2.b]:[0,0,0],opacity:featureStyle.fillOpacity,hashed:featureStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},lineColor=color(featureStyle.lineColor).rgb(),outlineUniform={color:[lineColor.r,lineColor.g,lineColor.b],outlineWidth:featureStyle.lineWidth},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,GeoJSONVertexShaderFill,GeoJSONFragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,container.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,GeoJSONVertexShaderOutline,GeoJSONFragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,container.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},GeoJSONPolygon.prototype.drawLabels=function(){this.labels.draw()},GeoJSONPolygon.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},GeoJSONPolygon.prototype.resize=function(zoom){if(this.config.outlineResize){var outlineRadius=this.getOutlineRadius(zoom);if(this.config.labelResize){var labelSize=this.getLabelSize(zoom);zoom<=this.config.labelResize.threshold?this.labels.hideLabels():(this.labels.showLabels(),this.labels.resize(labelSize))}this.container.children.map((function(child){child.shader.uniformGroup.uniforms.outlineWidth&&(child.shader.uniformGroup.uniforms.outlineWidth=outlineRadius)})),this.currentZoom=zoom}},GeoJSONPolygon.prototype.testPosition=function(pos){return this.dict.getPolygonAt([pos.x,pos.y])},GeoJSONPolygon.prototype.getOutlineRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.outlineResize)},GeoJSONPolygon.prototype.getLabelSize=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.labelResize)},GeoJSONPolygon}(),GeoJSONLineString=function(){function GeoJSONLineString(root,pixiOverlay,config){this.features=[],this.config={},this.dict=new LineDictionary(1.2),this.currentZoom=Defaults.INITIAL_ZOOM,this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.pixiOverlay=pixiOverlay,this.features=[],this.config=config}return GeoJSONLineString.prototype.add=function(feature,props){var _a,geom=feature.geometry,properties=props(feature),meshes=[],coordinates=geom.coordinates;if((null==coordinates?void 0:coordinates.length)>0){var projected=this.projectPolygons(coordinates);projected.pop(),this.dict.add(projected,feature.properties);var outlineData=Mesh.SimpleLine(projected,Defaults.DEFAULT_LINE_WIDTH);meshes.push(this.drawPolygons(this.container,outlineData,properties.style,Defaults.DEFAULT_Z_INDEX)),(_a=this.features).push.apply(_a,meshes)}},GeoJSONLineString.prototype.drawPolygons=function(container,outlineData,featureStyle,zIndex){var lineColor=color(featureStyle.lineColor).rgb(),outlineUniform={color:[lineColor.r,lineColor.g,lineColor.b],width:featureStyle.lineWidth},polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,GeoJSONVertexShaderOutline,GeoJSONFragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex,container.addChild(polygonOutlineMesh),{outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},GeoJSONLineString.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},GeoJSONLineString.prototype.resize=function(zoom){if(this.config.outlineResize){var outlineRadius=this.getOutlineRadius(zoom);this.container.children.map((function(child){child.shader.uniformGroup.uniforms.outlineWidth&&(child.shader.uniformGroup.uniforms.outlineWidth=outlineRadius)})),this.currentZoom=zoom}},GeoJSONLineString.prototype.testPosition=function(pos){return this.dict.getClosest(pos)},GeoJSONLineString.prototype.getOutlineRadius=function(zoom){return void 0===zoom&&(zoom=this.currentZoom),getRadius(zoom,this.config.outlineResize)},GeoJSONLineString}(),GeoJSONPoint=function(){function GeoJSONPoint(root,pixiOverlay){this.spawned=[],this.pool=[],this.dict=new PointDictionary(.25,20,4),this.container=new PIXI.Container,this.container.sortableChildren=!0,root.addChild(this.container),this.pixiOverlay=pixiOverlay}return GeoJSONPoint.prototype.add=function(feature,props){var geom=feature.geometry,properties=props(feature),coordinates=geom.coordinates;if((null==coordinates?void 0:coordinates.length)>0){var projected=this.projectPoint(coordinates);this.dict.add(projected,feature.properties);var point=void 0;this.pool.length>0?point=this.pool.pop():(point=new PIXI.Graphics,this.container.addChild(point));var fillColor=properties.style.fillColor?PIXI.utils.string2hex(color(properties.style.fillColor).hex()):0,lineColor=properties.style.lineColor?PIXI.utils.string2hex(color(properties.style.lineColor).hex()):0,opacity=properties.style.fillOpacity||0;point.lineStyle(properties.style.lineWidth,lineColor),point.beginFill(fillColor,opacity),point.drawRect(projected[0]-4,projected[1]-4,8,8),point.endFill(),this.spawned.push(point)}},GeoJSONPoint.prototype.projectPoint=function(point){var coord=(0,this.pixiOverlay.utils.latLngToLayerPoint)([point[1],point[0]]);return new Vector2(coord.x,coord.y)},GeoJSONPoint.prototype.resize=function(zoom){},GeoJSONPoint.prototype.testPosition=function(pos){return this.dict.getClosestUnder(pos)},GeoJSONPoint}(),GeoJSONModule=function(_super){function GeoJSONModule(config){var _this=_super.call(this)||this;return _this.mapmoving=!1,_this._eventHandler=(null==config?void 0:config.customEventHandler)||new DefaultEventHandler,_this.onFeatureHover=null==config?void 0:config.onFeatureHover,_this.config=config,_this}return __extends(GeoJSONModule,_super),GeoJSONModule.prototype.set=function(data,props){var _this=this;this.labelRoot=new PIXI.Container,data.features.forEach((function(feature){"Point"===feature.geometry.type?(void 0===_this.points&&(_this.points=new GeoJSONPoint(_this.root,_this.pixiOverlay)),_this.points.add(feature,props)):"LineString"===feature.geometry.type?(void 0===_this.linestrings&&(_this.linestrings=new GeoJSONLineString(_this.root,_this.pixiOverlay,_this.config)),_this.linestrings.add(feature,props)):"Polygon"===feature.geometry.type?(void 0===_this.polygons&&(_this.polygons=new GeoJSONPolygon(_this.root,_this.labelRoot,_this.pixiOverlay,_this.config)),_this.polygons.add(feature,props)):"MultiPolygon"===feature.geometry.type&&(void 0===_this.multipolygons&&(_this.multipolygons=new GeoJSONMultiPolygon(_this.root,_this.labelRoot,_this.pixiOverlay,_this.config)),_this.multipolygons.add(feature,props))})),this.root.addChild(this.labelRoot),this.polygons&&this.polygons.drawLabels(),this.multipolygons&&this.multipolygons.drawLabels()},GeoJSONModule.prototype.testPosition=function(pos){var result=[];return this.polygons&&result.push(this.polygons.testPosition(pos)),this.multipolygons&&result.push(this.multipolygons.testPosition(pos)),this.linestrings&&result.push(this.linestrings.testPosition(pos)),this.points&&result.push(this.points.testPosition(pos)),result=result.filter((function(v){return v}))},GeoJSONModule.prototype.onAdd=function(map){var element=this.pixiOverlay.utils.getRenderer().view.parentNode,callbacks={mousemove:this.handleMouseMove.bind(this),mouseout:this.handleMouseOut.bind(this),click:this.handleMouseClick.bind(this),mousedown:this.handleMouseDown.bind(this),mouseup:this.handleMouseUp.bind(this)};this._eventHandler.register(map,element,callbacks)},GeoJSONModule.prototype.onRemove=function(map){this._eventHandler.unregister()},GeoJSONModule.prototype.resize=function(zoom){this.points&&this.points.resize(zoom),this.linestrings&&this.linestrings.resize(zoom),this.polygons&&this.polygons.resize(zoom),this.multipolygons&&this.multipolygons.resize(zoom)},GeoJSONModule.prototype.handleMouseMove=function(event){if(this.mapmoving)return!1;var latLng=this.pixiOverlay.utils.getMap().mouseEventToLatLng(event),layerCoords=new Vector2([latLng.lng,latLng.lat]),hits=this.testPosition(layerCoords);return this.onFeatureHover&&this.onFeatureHover(event,hits),!0},GeoJSONModule.prototype.handleMouseOut=function(event){return this.onFeatureHover&&this.onFeatureHover(event,[]),!0},GeoJSONModule.prototype.handleMouseClick=function(){return!0},GeoJSONModule.prototype.handleMouseDown=function(){return this.mapmoving=!0,!0},GeoJSONModule.prototype.handleMouseUp=function(){return this.mapmoving=!1,!0},GeoJSONModule}(ModuleInterface),ExplorationLayer=function(_super){function ExplorationLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.pointDict=new PointDictionary(.25,-2,-1),_this}return __extends(ExplorationLayer,_super),ExplorationLayer.prototype.appendExploration=function(scale){void 0===scale&&(scale=1);var project=this.pixiOverlay.utils.latLngToLayerPoint,targetScale=this.clampScale(scale);this.prevScale=targetScale;for(var i=0;i<null.length;i++){var projected=project([null[i].latitude,null[i].longitude]),pos=new Vector2(projected.x,projected.y),well=generateCircle(pos,.3,void 0);this.root.addChild(well),this.pointDict.add(pos,{mesh:well,uniforms:void 0})}},ExplorationLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.05*scale;return targetScale>1&&(targetScale=1),targetScale},ExplorationLayer.prototype.highlight=function(lat,long){var project=this.pixiOverlay.utils.latLngToLayerPoint;this.selection&&((point=this.selection.point).uniforms.circleColor1=[.3,.3,.3],point.mesh.zIndex=this.selection.zIndex,this.selection=null);var _a=project([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y),circleUnder=this.pointDict.getClosestUnder(worldSpace);if(circleUnder){var point=circleUnder.val;return this.selection={point:point,zIndex:point.mesh.zIndex},point.uniforms.circleColor1=[.2,.6,.7],point.mesh.zIndex=1/0,!0}return!1},ExplorationLayer}(ModuleInterface);export{DefaultEventHandler,ExplorationLayer,FaultlineModule,FieldModule,GeoJSONModule,ModuleInterface,OutlineModule,WellboreModule};
|