@equinor/esv-intersection 1.4.3 → 1.5.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/README.md +1 -1
- package/dist/control/ExtendedCurveInterpolator.d.ts +58 -0
- package/dist/control/IntersectionReferenceSystem.d.ts +4 -4
- package/dist/datautils/seismicimage.d.ts +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/interfaces.d.ts +10 -1
- package/dist/layers/CasingLayer.d.ts +11 -1
- package/dist/layers/GeomodelCanvasLayer.d.ts +1 -0
- package/dist/utils/arc-length.d.ts +23 -0
- package/dist/utils/binary-search.d.ts +8 -0
- package/dist/utils/root-finder.d.ts +34 -0
- package/package.json +14 -12
- package/CHANGELOG.md +0 -217
package/dist/index.umd.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
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 __)}var __assign=function(){return(__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t}).apply(this,arguments)};function __awaiter(thisArg,_arguments,P,generator){return new(P||(P=Promise))((function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P((function(resolve){resolve(value)}))).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())}))}function __generator(thisArg,body){var f,y,t,g,_={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return function(op){if(f)throw new TypeError("Generator is already executing.");for(;_;)try{if(f=1,y&&(t=2&op[0]?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;switch(y=0,t&&(op=[2&op[0],t.value]),op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if(!(t=_.trys,(t=t.length>0&&t[t.length-1])||6!==op[0]&&2!==op[0])){_=0;continue}if(3===op[0]&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(6===op[0]&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}t[2]&&_.ops.pop(),_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(5&op[0])throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}([n,v])}}}function __spreadArray(to,from){for(var i=0,il=from.length,j=to.length;i<il;i++,j++)to[j]=from[i];return to}var defaultOptions={order:1,layerOpacity:1,interactive:!1},Layer=function(){function Layer(id,options){this._referenceSystem=null,this._interactive=!1,this._id=id||"layer-"+Math.floor(1e3*Math.random());var opts=options||defaultOptions;this._order=opts.order||1,this._options=__assign({},opts),this.loading=!1,this._element=null,this._opacity=opts.layerOpacity||1,this._visible=!0,this._interactive=opts.interactive||!1,options&&options.data&&this.setData(options.data),this._referenceSystem=options&&options.referenceSystem,this.onMount=this.onMount.bind(this),this.onUnmount=this.onUnmount.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onRescale=this.onRescale.bind(this),this.onResize=this.onResize.bind(this),this.onOrderChanged=this.onOrderChanged.bind(this),this.onOpacityChanged=this.onOpacityChanged.bind(this),this.setVisibility=this.setVisibility.bind(this)}return Object.defineProperty(Layer.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"element",{get:function(){return this._element},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"options",{get:function(){return this._options},set:function(options){this._options=options},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"isLoading",{get:function(){return this.loading},set:function(loading){this.loading=loading},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"opacity",{get:function(){return this._opacity},set:function(opacity){this._opacity=opacity,this.onOpacityChanged(opacity)},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"order",{get:function(){return this._order},set:function(order){this._order=order,this.onOrderChanged(order)},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"interactive",{get:function(){return this._interactive},set:function(shouldBeInteractive){this._interactive=shouldBeInteractive,this.onInteractivityChanged(shouldBeInteractive)},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"referenceSystem",{get:function(){return this._referenceSystem},set:function(referenceSystem){this._referenceSystem=referenceSystem},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"data",{get:function(){return this.getData()},set:function(data){this.setData(data)},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"isVisible",{get:function(){return this._visible},enumerable:!1,configurable:!0}),Layer.prototype.getData=function(){return this._data},Layer.prototype.setData=function(data){this._data=data,this.element&&this.onUpdate({data:data})},Layer.prototype.clearData=function(includeReferenceSystem){void 0===includeReferenceSystem&&(includeReferenceSystem=!0),this._data=null,includeReferenceSystem&&(this.referenceSystem=null),this.onUpdate({})},Layer.prototype.setVisibility=function(visible){this._visible=visible},Layer.prototype.onMount=function(event){this._element=event.elm,this._options.onMount&&this._options.onMount(event,this)},Layer.prototype.onUnmount=function(event){this._options.onUnmount&&this._options.onUnmount(event,this)},Layer.prototype.onResize=function(event){this._options.onResize&&this._options.onResize(event,this)},Layer.prototype.onUpdate=function(event){event.data&&(this._data=event.data),this._options.onUpdate&&this._options.onUpdate(event,this)},Layer.prototype.onRescale=function(event){this.optionsRescale(event)},Layer.prototype.optionsRescale=function(event){this._options.onRescale&&this._options.onRescale(event,this)},Layer.prototype.onOpacityChanged=function(opacity){},Layer.prototype.onOrderChanged=function(order){},Layer.prototype.onInteractivityChanged=function(interactive){},Layer}(),CanvasLayer=function(_super){function CanvasLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(CanvasLayer,_super),CanvasLayer.prototype.onOpacityChanged=function(opacity){this.canvas&&this.updateStyle()},CanvasLayer.prototype.onOrderChanged=function(order){this.canvas&&this.updateStyle()},CanvasLayer.prototype.onInteractivityChanged=function(interactive){this.canvas&&this.updateStyle()},CanvasLayer.prototype.setVisibility=function(visible){_super.prototype.setVisibility.call(this,visible),this.canvas&&this.updateStyle(visible)},CanvasLayer.prototype.updateStyle=function(visible){var visibility=visible||this.isVisible?"visible":"hidden",interactive=this.interactive?"auto":"none";this.canvas.setAttribute("style","position:absolute;pointer-events:"+interactive+";z-index:"+this.order+";opacity:"+this.opacity+";visibility:"+visibility)},CanvasLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event);var canvas,elm=event.elm,width=event.width||parseInt(elm.getAttribute("width"),10)||200,height=event.height||parseInt(elm.getAttribute("height"),10)||300;this.elm=elm,this.canvas||(canvas=document.createElement("canvas"),this.canvas=canvas,event.elm.appendChild(canvas)),this.canvas.setAttribute("id",""+this.id),this.canvas.setAttribute("width",width+"px"),this.canvas.setAttribute("height",height+"px"),this.canvas.setAttribute("class","canvas-layer"),this.updateStyle(),this.ctx=this.canvas.getContext("2d")},CanvasLayer.prototype.onUnmount=function(){_super.prototype.onUnmount.call(this),this.canvas.remove(),this.canvas=null},CanvasLayer.prototype.onResize=function(event){var ctx=this.ctx,width=event.width,height=event.height;ctx.canvas.setAttribute("width",width+"px"),ctx.canvas.setAttribute("height",height+"px")},CanvasLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event)},CanvasLayer.prototype.resetTransform=function(){this.ctx.resetTransform()},CanvasLayer.prototype.setTransform=function(event){this.resetTransform();var flippedX=event.xBounds[0]>event.xBounds[1],flippedY=event.yBounds[0]>event.yBounds[1];this.ctx.translate(event.xScale(0),event.yScale(0)),this.ctx.scale(event.xRatio*(flippedX?-1:1),event.yRatio*(flippedY?-1:1))},CanvasLayer.prototype.clearCanvas=function(){var ctx=this.ctx,canvas=this.canvas;ctx.save(),ctx.resetTransform(),ctx.clearRect(0,0,canvas.width,canvas.height),ctx.restore()},CanvasLayer}(Layer),defaultOptions$1={minorColor:"lightgray",majorColor:"gray",minorWidth:.25,majorWidth:.75},GridLayer=function(_super){function GridLayer(id,options){var _this=_super.call(this,id,options)||this;return _this._offsetX=0,_this._offsetY=0,_this.options=__assign(__assign({},_this.options),options||defaultOptions$1),_this.render=_this.render.bind(_this),_this}return __extends(GridLayer,_super),GridLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.render(event)},GridLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.render(event)},GridLayer.prototype.render=function(event){var ctx=this.ctx,_a=this.options,minorWidth=_a.minorWidth,minorColor=_a.minorColor,majorWidth=_a.majorWidth,majorColor=_a.majorColor;if(ctx&&(this.clearCanvas(),event.xScale||event.yScale)){var xScale=event.xScale.copy(),yScale=event.yScale.copy(),xDomain=xScale.domain(),yDomain=yScale.domain(),offsetX=this.offsetX,offsetY=this.offsetY;xScale.domain([xDomain[0]-offsetX,xDomain[1]-offsetX]),yScale.domain([yDomain[0]-offsetY,yDomain[1]-offsetY]);var _b=xScale.range(),rx1=_b[0],rx2=_b[1],_c=yScale.range(),ry1=_c[0],ry2=_c[1];ctx.lineWidth=minorWidth||.25,ctx.strokeStyle=minorColor||"lightgray";var xminticks=this.mapMinorTicks(xScale.ticks()),yminticks=this.mapMinorTicks(yScale.ticks());this.renderTicksX(xScale,xminticks,ry1,ry2),this.renderTicksY(yScale,yminticks,rx1,rx2),ctx.lineWidth=majorWidth||.75,ctx.strokeStyle=majorColor||"gray",this.renderTicksX(xScale,xScale.ticks(),ry1,ry2),this.renderTicksY(yScale,yScale.ticks(),rx1,rx2),ctx.restore()}},GridLayer.prototype.renderTicksX=function(xscale,xticks,ry1,ry2){var _this=this;xticks.forEach((function(tx){var x=xscale(tx);_this.ctx.beginPath(),_this.ctx.moveTo(x,ry1),_this.ctx.lineTo(x,ry2),_this.ctx.stroke()}))},GridLayer.prototype.renderTicksY=function(yscale,yticks,rx1,rx2){var _this=this;yticks.forEach((function(ty){var y=yscale(ty);_this.ctx.beginPath(),_this.ctx.moveTo(rx1,y),_this.ctx.lineTo(rx2,y),_this.ctx.stroke()}))},GridLayer.prototype.mapMinorTicks=function(ticks){var xminticks=[];return ticks.length>=2&&(xminticks=ticks.map((function(v){return v+(ticks[1]-ticks[0])/2}))).pop(),xminticks},Object.defineProperty(GridLayer.prototype,"offsetX",{get:function(){return this._offsetX},set:function(offset){this._offsetX=offset},enumerable:!1,configurable:!0}),Object.defineProperty(GridLayer.prototype,"offsetY",{get:function(){return this._offsetY},set:function(offset){this._offsetY=offset},enumerable:!1,configurable:!0}),GridLayer}(CanvasLayer),xhtml="http://www.w3.org/1999/xhtml",namespaces={svg:"http://www.w3.org/2000/svg",xhtml:xhtml,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function namespace(name){var prefix=name+="",i=prefix.indexOf(":");return i>=0&&"xmlns"!==(prefix=name.slice(0,i))&&(name=name.slice(i+1)),namespaces.hasOwnProperty(prefix)?{space:namespaces[prefix],local:name}:name}function creatorInherit(name){return function(){var document=this.ownerDocument,uri=this.namespaceURI;return uri===xhtml&&document.documentElement.namespaceURI===xhtml?document.createElement(name):document.createElementNS(uri,name)}}function creatorFixed(fullname){return function(){return this.ownerDocument.createElementNS(fullname.space,fullname.local)}}function creator(name){var fullname=namespace(name);return(fullname.local?creatorFixed:creatorInherit)(fullname)}function none(){}function selector(selector){return null==selector?none:function(){return this.querySelector(selector)}}function empty(){return[]}function selectorAll(selector){return null==selector?empty:function(){return this.querySelectorAll(selector)}}function matcher(selector){return function(){return this.matches(selector)}}function sparse(update){return new Array(update.length)}function EnterNode(parent,datum){this.ownerDocument=parent.ownerDocument,this.namespaceURI=parent.namespaceURI,this._next=null,this._parent=parent,this.__data__=datum}EnterNode.prototype={constructor:EnterNode,appendChild:function(child){return this._parent.insertBefore(child,this._next)},insertBefore:function(child,next){return this._parent.insertBefore(child,next)},querySelector:function(selector){return this._parent.querySelector(selector)},querySelectorAll:function(selector){return this._parent.querySelectorAll(selector)}};function bindIndex(parent,group,enter,update,exit,data){for(var node,i=0,groupLength=group.length,dataLength=data.length;i<dataLength;++i)(node=group[i])?(node.__data__=data[i],update[i]=node):enter[i]=new EnterNode(parent,data[i]);for(;i<groupLength;++i)(node=group[i])&&(exit[i]=node)}function bindKey(parent,group,enter,update,exit,data,key){var i,node,keyValue,nodeByKeyValue={},groupLength=group.length,dataLength=data.length,keyValues=new Array(groupLength);for(i=0;i<groupLength;++i)(node=group[i])&&(keyValues[i]=keyValue="$"+key.call(node,node.__data__,i,group),keyValue in nodeByKeyValue?exit[i]=node:nodeByKeyValue[keyValue]=node);for(i=0;i<dataLength;++i)(node=nodeByKeyValue[keyValue="$"+key.call(parent,data[i],i,data)])?(update[i]=node,node.__data__=data[i],nodeByKeyValue[keyValue]=null):enter[i]=new EnterNode(parent,data[i]);for(i=0;i<groupLength;++i)(node=group[i])&&nodeByKeyValue[keyValues[i]]===node&&(exit[i]=node)}function ascending(a,b){return a<b?-1:a>b?1:a>=b?0:NaN}function attrRemove(name){return function(){this.removeAttribute(name)}}function attrRemoveNS(fullname){return function(){this.removeAttributeNS(fullname.space,fullname.local)}}function attrConstant(name,value){return function(){this.setAttribute(name,value)}}function attrConstantNS(fullname,value){return function(){this.setAttributeNS(fullname.space,fullname.local,value)}}function attrFunction(name,value){return function(){var v=value.apply(this,arguments);null==v?this.removeAttribute(name):this.setAttribute(name,v)}}function attrFunctionNS(fullname,value){return function(){var v=value.apply(this,arguments);null==v?this.removeAttributeNS(fullname.space,fullname.local):this.setAttributeNS(fullname.space,fullname.local,v)}}function defaultView(node){return node.ownerDocument&&node.ownerDocument.defaultView||node.document&&node||node.defaultView}function styleRemove(name){return function(){this.style.removeProperty(name)}}function styleConstant(name,value,priority){return function(){this.style.setProperty(name,value,priority)}}function styleFunction(name,value,priority){return function(){var v=value.apply(this,arguments);null==v?this.style.removeProperty(name):this.style.setProperty(name,v,priority)}}function styleValue(node,name){return node.style.getPropertyValue(name)||defaultView(node).getComputedStyle(node,null).getPropertyValue(name)}function propertyRemove(name){return function(){delete this[name]}}function propertyConstant(name,value){return function(){this[name]=value}}function propertyFunction(name,value){return function(){var v=value.apply(this,arguments);null==v?delete this[name]:this[name]=v}}function classArray(string){return string.trim().split(/^|\s+/)}function classList(node){return node.classList||new ClassList(node)}function ClassList(node){this._node=node,this._names=classArray(node.getAttribute("class")||"")}function classedAdd(node,names){for(var list=classList(node),i=-1,n=names.length;++i<n;)list.add(names[i])}function classedRemove(node,names){for(var list=classList(node),i=-1,n=names.length;++i<n;)list.remove(names[i])}function classedTrue(names){return function(){classedAdd(this,names)}}function classedFalse(names){return function(){classedRemove(this,names)}}function classedFunction(names,value){return function(){(value.apply(this,arguments)?classedAdd:classedRemove)(this,names)}}function textRemove(){this.textContent=""}function textConstant(value){return function(){this.textContent=value}}function textFunction(value){return function(){var v=value.apply(this,arguments);this.textContent=null==v?"":v}}function htmlRemove(){this.innerHTML=""}function htmlConstant(value){return function(){this.innerHTML=value}}function htmlFunction(value){return function(){var v=value.apply(this,arguments);this.innerHTML=null==v?"":v}}function raise(){this.nextSibling&&this.parentNode.appendChild(this)}function lower(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function constantNull(){return null}function remove(){var parent=this.parentNode;parent&&parent.removeChild(this)}function selection_cloneShallow(){var clone=this.cloneNode(!1),parent=this.parentNode;return parent?parent.insertBefore(clone,this.nextSibling):clone}function selection_cloneDeep(){var clone=this.cloneNode(!0),parent=this.parentNode;return parent?parent.insertBefore(clone,this.nextSibling):clone}ClassList.prototype={add:function(name){this._names.indexOf(name)<0&&(this._names.push(name),this._node.setAttribute("class",this._names.join(" ")))},remove:function(name){var i=this._names.indexOf(name);i>=0&&(this._names.splice(i,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(name){return this._names.indexOf(name)>=0}};var filterEvents={},event=null;"undefined"!=typeof document&&("onmouseenter"in document.documentElement||(filterEvents={mouseenter:"mouseover",mouseleave:"mouseout"}));function filterContextListener(listener,index,group){return listener=contextListener(listener,index,group),function(event){var related=event.relatedTarget;related&&(related===this||8&related.compareDocumentPosition(this))||listener.call(this,event)}}function contextListener(listener,index,group){return function(event1){var event0=event;event=event1;try{listener.call(this,this.__data__,index,group)}finally{event=event0}}}function parseTypenames(typenames){return typenames.trim().split(/^|\s+/).map((function(t){var name="",i=t.indexOf(".");return i>=0&&(name=t.slice(i+1),t=t.slice(0,i)),{type:t,name:name}}))}function onRemove(typename){return function(){var on=this.__on;if(on){for(var o,j=0,i=-1,m=on.length;j<m;++j)o=on[j],typename.type&&o.type!==typename.type||o.name!==typename.name?on[++i]=o:this.removeEventListener(o.type,o.listener,o.capture);++i?on.length=i:delete this.__on}}}function onAdd(typename,value,capture){var wrap=filterEvents.hasOwnProperty(typename.type)?filterContextListener:contextListener;return function(d,i,group){var o,on=this.__on,listener=wrap(value,i,group);if(on)for(var j=0,m=on.length;j<m;++j)if((o=on[j]).type===typename.type&&o.name===typename.name)return this.removeEventListener(o.type,o.listener,o.capture),this.addEventListener(o.type,o.listener=listener,o.capture=capture),void(o.value=value);this.addEventListener(typename.type,listener,capture),o={type:typename.type,name:typename.name,value:value,listener:listener,capture:capture},on?on.push(o):this.__on=[o]}}function dispatchEvent(node,type,params){var window=defaultView(node),event=window.CustomEvent;"function"==typeof event?event=new event(type,params):(event=window.document.createEvent("Event"),params?(event.initEvent(type,params.bubbles,params.cancelable),event.detail=params.detail):event.initEvent(type,!1,!1)),node.dispatchEvent(event)}function dispatchConstant(type,params){return function(){return dispatchEvent(this,type,params)}}function dispatchFunction(type,params){return function(){return dispatchEvent(this,type,params.apply(this,arguments))}}var root=[null];function Selection(groups,parents){this._groups=groups,this._parents=parents}function selection(){return new Selection([[document.documentElement]],root)}function select(selector){return"string"==typeof selector?new Selection([[document.querySelector(selector)]],[document.documentElement]):new Selection([[selector]],root)}function sourceEvent(){for(var source,current=event;source=current.sourceEvent;)current=source;return current}function point(node,event){var svg=node.ownerSVGElement||node;if(svg.createSVGPoint){var point=svg.createSVGPoint();return point.x=event.clientX,point.y=event.clientY,[(point=point.matrixTransform(node.getScreenCTM().inverse())).x,point.y]}var rect=node.getBoundingClientRect();return[event.clientX-rect.left-node.clientLeft,event.clientY-rect.top-node.clientTop]}function mouse(node){var event=sourceEvent();return event.changedTouches&&(event=event.changedTouches[0]),point(node,event)}function touch(node,touches,identifier){arguments.length<3&&(identifier=touches,touches=sourceEvent().changedTouches);for(var touch,i=0,n=touches?touches.length:0;i<n;++i)if((touch=touches[i]).identifier===identifier)return point(node,touch);return null}Selection.prototype=selection.prototype={constructor:Selection,select:function(select){"function"!=typeof select&&(select=selector(select));for(var groups=this._groups,m=groups.length,subgroups=new Array(m),j=0;j<m;++j)for(var node,subnode,group=groups[j],n=group.length,subgroup=subgroups[j]=new Array(n),i=0;i<n;++i)(node=group[i])&&(subnode=select.call(node,node.__data__,i,group))&&("__data__"in node&&(subnode.__data__=node.__data__),subgroup[i]=subnode);return new Selection(subgroups,this._parents)},selectAll:function(select){"function"!=typeof select&&(select=selectorAll(select));for(var groups=this._groups,m=groups.length,subgroups=[],parents=[],j=0;j<m;++j)for(var node,group=groups[j],n=group.length,i=0;i<n;++i)(node=group[i])&&(subgroups.push(select.call(node,node.__data__,i,group)),parents.push(node));return new Selection(subgroups,parents)},filter:function(match){"function"!=typeof match&&(match=matcher(match));for(var groups=this._groups,m=groups.length,subgroups=new Array(m),j=0;j<m;++j)for(var node,group=groups[j],n=group.length,subgroup=subgroups[j]=[],i=0;i<n;++i)(node=group[i])&&match.call(node,node.__data__,i,group)&&subgroup.push(node);return new Selection(subgroups,this._parents)},data:function(value,key){if(!value)return data=new Array(this.size()),j=-1,this.each((function(d){data[++j]=d})),data;var bind=key?bindKey:bindIndex,parents=this._parents,groups=this._groups;"function"!=typeof value&&(value=function(x){return function(){return x}}(value));for(var m=groups.length,update=new Array(m),enter=new Array(m),exit=new Array(m),j=0;j<m;++j){var parent=parents[j],group=groups[j],groupLength=group.length,data=value.call(parent,parent&&parent.__data__,j,parents),dataLength=data.length,enterGroup=enter[j]=new Array(dataLength),updateGroup=update[j]=new Array(dataLength);bind(parent,group,enterGroup,updateGroup,exit[j]=new Array(groupLength),data,key);for(var previous,next,i0=0,i1=0;i0<dataLength;++i0)if(previous=enterGroup[i0]){for(i0>=i1&&(i1=i0+1);!(next=updateGroup[i1])&&++i1<dataLength;);previous._next=next||null}}return(update=new Selection(update,parents))._enter=enter,update._exit=exit,update},enter:function(){return new Selection(this._enter||this._groups.map(sparse),this._parents)},exit:function(){return new Selection(this._exit||this._groups.map(sparse),this._parents)},join:function(onenter,onupdate,onexit){var enter=this.enter(),update=this,exit=this.exit();return enter="function"==typeof onenter?onenter(enter):enter.append(onenter+""),null!=onupdate&&(update=onupdate(update)),null==onexit?exit.remove():onexit(exit),enter&&update?enter.merge(update).order():update},merge:function(selection){for(var groups0=this._groups,groups1=selection._groups,m0=groups0.length,m1=groups1.length,m=Math.min(m0,m1),merges=new Array(m0),j=0;j<m;++j)for(var node,group0=groups0[j],group1=groups1[j],n=group0.length,merge=merges[j]=new Array(n),i=0;i<n;++i)(node=group0[i]||group1[i])&&(merge[i]=node);for(;j<m0;++j)merges[j]=groups0[j];return new Selection(merges,this._parents)},order:function(){for(var groups=this._groups,j=-1,m=groups.length;++j<m;)for(var node,group=groups[j],i=group.length-1,next=group[i];--i>=0;)(node=group[i])&&(next&&4^node.compareDocumentPosition(next)&&next.parentNode.insertBefore(node,next),next=node);return this},sort:function(compare){function compareNode(a,b){return a&&b?compare(a.__data__,b.__data__):!a-!b}compare||(compare=ascending);for(var groups=this._groups,m=groups.length,sortgroups=new Array(m),j=0;j<m;++j){for(var node,group=groups[j],n=group.length,sortgroup=sortgroups[j]=new Array(n),i=0;i<n;++i)(node=group[i])&&(sortgroup[i]=node);sortgroup.sort(compareNode)}return new Selection(sortgroups,this._parents).order()},call:function(){var callback=arguments[0];return arguments[0]=this,callback.apply(null,arguments),this},nodes:function(){var nodes=new Array(this.size()),i=-1;return this.each((function(){nodes[++i]=this})),nodes},node:function(){for(var groups=this._groups,j=0,m=groups.length;j<m;++j)for(var group=groups[j],i=0,n=group.length;i<n;++i){var node=group[i];if(node)return node}return null},size:function(){var size=0;return this.each((function(){++size})),size},empty:function(){return!this.node()},each:function(callback){for(var groups=this._groups,j=0,m=groups.length;j<m;++j)for(var node,group=groups[j],i=0,n=group.length;i<n;++i)(node=group[i])&&callback.call(node,node.__data__,i,group);return this},attr:function(name,value){var fullname=namespace(name);if(arguments.length<2){var node=this.node();return fullname.local?node.getAttributeNS(fullname.space,fullname.local):node.getAttribute(fullname)}return this.each((null==value?fullname.local?attrRemoveNS:attrRemove:"function"==typeof value?fullname.local?attrFunctionNS:attrFunction:fullname.local?attrConstantNS:attrConstant)(fullname,value))},style:function(name,value,priority){return arguments.length>1?this.each((null==value?styleRemove:"function"==typeof value?styleFunction:styleConstant)(name,value,null==priority?"":priority)):styleValue(this.node(),name)},property:function(name,value){return arguments.length>1?this.each((null==value?propertyRemove:"function"==typeof value?propertyFunction:propertyConstant)(name,value)):this.node()[name]},classed:function(name,value){var names=classArray(name+"");if(arguments.length<2){for(var list=classList(this.node()),i=-1,n=names.length;++i<n;)if(!list.contains(names[i]))return!1;return!0}return this.each(("function"==typeof value?classedFunction:value?classedTrue:classedFalse)(names,value))},text:function(value){return arguments.length?this.each(null==value?textRemove:("function"==typeof value?textFunction:textConstant)(value)):this.node().textContent},html:function(value){return arguments.length?this.each(null==value?htmlRemove:("function"==typeof value?htmlFunction:htmlConstant)(value)):this.node().innerHTML},raise:function(){return this.each(raise)},lower:function(){return this.each(lower)},append:function(name){var create="function"==typeof name?name:creator(name);return this.select((function(){return this.appendChild(create.apply(this,arguments))}))},insert:function(name,before){var create="function"==typeof name?name:creator(name),select=null==before?constantNull:"function"==typeof before?before:selector(before);return this.select((function(){return this.insertBefore(create.apply(this,arguments),select.apply(this,arguments)||null)}))},remove:function(){return this.each(remove)},clone:function(deep){return this.select(deep?selection_cloneDeep:selection_cloneShallow)},datum:function(value){return arguments.length?this.property("__data__",value):this.node().__data__},on:function(typename,value,capture){var i,t,typenames=parseTypenames(typename+""),n=typenames.length;if(!(arguments.length<2)){for(on=value?onAdd:onRemove,null==capture&&(capture=!1),i=0;i<n;++i)this.each(on(typenames[i],value,capture));return this}var on=this.node().__on;if(on)for(var o,j=0,m=on.length;j<m;++j)for(i=0,o=on[j];i<n;++i)if((t=typenames[i]).type===o.type&&t.name===o.name)return o.value},dispatch:function(type,params){return this.each(("function"==typeof params?dispatchFunction:dispatchConstant)(type,params))}};var SVGLayer=function(_super){function SVGLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(SVGLayer,_super),SVGLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event);var elm=event.elm,width=event.width||parseInt(elm.getAttribute("width"),10)||200,height=event.height||parseInt(elm.getAttribute("height"),10)||300;this.elm||(this.elm=select(elm).append("svg"),this.elm.attr("id",""+this.id),this.elm.attr("class","svg-layer")),this.elm.attr("height",height).attr("width",width);var interactive=this.interactive?"auto":"none";this.elm.style("position","absolute").style("pointer-events",interactive).style("opacity",this.opacity).style("z-index",this.order)},SVGLayer.prototype.onUnmount=function(){_super.prototype.onUnmount.call(this),this.elm.remove(),this.elm=null},SVGLayer.prototype.onResize=function(event){this.elm&&(_super.prototype.onResize.call(this,event),this.elm.attr("height",event.height).attr("width",event.width))},SVGLayer.prototype.setVisibility=function(visible){_super.prototype.setVisibility.call(this,visible),this.elm&&this.elm.attr("visibility",visible?"visible":"hidden")},SVGLayer.prototype.onOpacityChanged=function(opacity){this.elm&&this.elm.style("opacity",opacity)},SVGLayer.prototype.onOrderChanged=function(order){this.elm&&this.elm.style("z-index",order)},SVGLayer.prototype.onInteractivityChanged=function(shouldBeInteractive){if(this.elm){var interactive=shouldBeInteractive?"auto":"none";this.elm.style("pointer-events",interactive)}},SVGLayer}(Layer),HTMLLayer=function(_super){function HTMLLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(HTMLLayer,_super),HTMLLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event);var elm=event.elm,width=event.width||parseInt(elm.getAttribute("width"),10)||200,height=event.height||parseInt(elm.getAttribute("height"),10)||300;this.elm||(this.elm=select(elm).append("div"),this.elm.attr("id",""+this.id),this.elm.attr("class","html-layer"));var interactive=this.interactive?"auto":"none";this.elm.style("position","absolute").style("height",height+"px").style("width",width+"px").style("opacity",this.opacity).style("overflow","hidden").style("pointer-events",interactive).style("z-index",this.order)},HTMLLayer.prototype.onUnmount=function(){_super.prototype.onUnmount.call(this),this.elm.remove(),this.elm=null},HTMLLayer.prototype.onResize=function(event){this.elm&&(_super.prototype.onResize.call(this,event),this.elm.style("height",event.height+"px").style("width",event.width+"px"))},HTMLLayer.prototype.setVisibility=function(visible){_super.prototype.setVisibility.call(this,visible),this.elm&&this.elm.attr("visibility",visible?"visible":"hidden")},HTMLLayer.prototype.onOpacityChanged=function(opacity){this.elm&&this.elm.style("opacity",opacity)},HTMLLayer.prototype.onOrderChanged=function(order){this.elm&&this.elm.style("z-index",order)},HTMLLayer.prototype.onInteractivityChanged=function(shouldBeInteractive){if(this.elm){var interactive=shouldBeInteractive?"auto":"none";this.elm.style("pointer-events",interactive)}},HTMLLayer}(Layer),pi=Math.PI,tau=2*pi,tauEpsilon=tau-1e-6;function Path(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function path(){return new Path}function constant$1(x){return function(){return x}}Path.prototype=path.prototype={constructor:Path,moveTo:function(x,y){this._+="M"+(this._x0=this._x1=+x)+","+(this._y0=this._y1=+y)},closePath:function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(x,y){this._+="L"+(this._x1=+x)+","+(this._y1=+y)},quadraticCurveTo:function(x1,y1,x,y){this._+="Q"+ +x1+","+ +y1+","+(this._x1=+x)+","+(this._y1=+y)},bezierCurveTo:function(x1,y1,x2,y2,x,y){this._+="C"+ +x1+","+ +y1+","+ +x2+","+ +y2+","+(this._x1=+x)+","+(this._y1=+y)},arcTo:function(x1,y1,x2,y2,r){x1=+x1,y1=+y1,x2=+x2,y2=+y2,r=+r;var x0=this._x1,y0=this._y1,x21=x2-x1,y21=y2-y1,x01=x0-x1,y01=y0-y1,l01_2=x01*x01+y01*y01;if(r<0)throw new Error("negative radius: "+r);if(null===this._x1)this._+="M"+(this._x1=x1)+","+(this._y1=y1);else if(l01_2>1e-6)if(Math.abs(y01*x21-y21*x01)>1e-6&&r){var x20=x2-x0,y20=y2-y0,l21_2=x21*x21+y21*y21,l20_2=x20*x20+y20*y20,l21=Math.sqrt(l21_2),l01=Math.sqrt(l01_2),l=r*Math.tan((pi-Math.acos((l21_2+l01_2-l20_2)/(2*l21*l01)))/2),t01=l/l01,t21=l/l21;Math.abs(t01-1)>1e-6&&(this._+="L"+(x1+t01*x01)+","+(y1+t01*y01)),this._+="A"+r+","+r+",0,0,"+ +(y01*x20>x01*y20)+","+(this._x1=x1+t21*x21)+","+(this._y1=y1+t21*y21)}else this._+="L"+(this._x1=x1)+","+(this._y1=y1);else;},arc:function(x,y,r,a0,a1,ccw){x=+x,y=+y,ccw=!!ccw;var dx=(r=+r)*Math.cos(a0),dy=r*Math.sin(a0),x0=x+dx,y0=y+dy,cw=1^ccw,da=ccw?a0-a1:a1-a0;if(r<0)throw new Error("negative radius: "+r);null===this._x1?this._+="M"+x0+","+y0:(Math.abs(this._x1-x0)>1e-6||Math.abs(this._y1-y0)>1e-6)&&(this._+="L"+x0+","+y0),r&&(da<0&&(da=da%tau+tau),da>tauEpsilon?this._+="A"+r+","+r+",0,1,"+cw+","+(x-dx)+","+(y-dy)+"A"+r+","+r+",0,1,"+cw+","+(this._x1=x0)+","+(this._y1=y0):da>1e-6&&(this._+="A"+r+","+r+",0,"+ +(da>=pi)+","+cw+","+(this._x1=x+r*Math.cos(a1))+","+(this._y1=y+r*Math.sin(a1))))},rect:function(x,y,w,h){this._+="M"+(this._x0=this._x1=+x)+","+(this._y0=this._y1=+y)+"h"+ +w+"v"+ +h+"h"+-w+"Z"},toString:function(){return this._}};function Linear(context){this._context=context}function curveLinear(context){return new Linear(context)}function x(p){return p[0]}function y(p){return p[1]}function point$1(that,x,y){that._context.bezierCurveTo(that._x1+that._k*(that._x2-that._x0),that._y1+that._k*(that._y2-that._y0),that._x2+that._k*(that._x1-x),that._y2+that._k*(that._y1-y),that._x2,that._y2)}function Cardinal(context,tension){this._context=context,this._k=(1-tension)/6}function CatmullRom(context,alpha){this._context=context,this._alpha=alpha}Linear.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(x,y){switch(x=+x,y=+y,this._point){case 0:this._point=1,this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;default:this._context.lineTo(x,y)}}},Cardinal.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:point$1(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(x,y){switch(x=+x,y=+y,this._point){case 0:this._point=1,this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2,this._x1=x,this._y1=y;break;case 2:this._point=3;default:point$1(this,x,y)}this._x0=this._x1,this._x1=this._x2,this._x2=x,this._y0=this._y1,this._y1=this._y2,this._y2=y}},CatmullRom.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(x,y){if(x=+x,y=+y,this._point){var x23=this._x2-x,y23=this._y2-y;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(x23*x23+y23*y23,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3;default:!function(that,x,y){var x1=that._x1,y1=that._y1,x2=that._x2,y2=that._y2;if(that._l01_a>1e-12){var a=2*that._l01_2a+3*that._l01_a*that._l12_a+that._l12_2a,n=3*that._l01_a*(that._l01_a+that._l12_a);x1=(x1*a-that._x0*that._l12_2a+that._x2*that._l01_2a)/n,y1=(y1*a-that._y0*that._l12_2a+that._y2*that._l01_2a)/n}if(that._l23_a>1e-12){var b=2*that._l23_2a+3*that._l23_a*that._l12_a+that._l12_2a,m=3*that._l23_a*(that._l23_a+that._l12_a);x2=(x2*b+that._x1*that._l23_2a-x*that._l12_2a)/m,y2=(y2*b+that._y1*that._l23_2a-y*that._l12_2a)/m}that._context.bezierCurveTo(x1,y1,x2,y2,that._x2,that._y2)}(this,x,y)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=x,this._y0=this._y1,this._y1=this._y2,this._y2=y}};var curveCatmullRom=function custom(alpha){function catmullRom(context){return alpha?new CatmullRom(context,alpha):new Cardinal(context,0)}return catmullRom.alpha=function(alpha){return custom(+alpha)},catmullRom}(.5),WellborepathLayer=function(_super){function WellborepathLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.options=__assign(__assign({},_this.options),options),_this.render=_this.render.bind(_this),_this}return __extends(WellborepathLayer,_super),WellborepathLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.render()},WellborepathLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.elm&&(this.rescaleEvent=event,this.render())},WellborepathLayer.prototype.render=function(){var _a=this.options,strokeWidth=_a.strokeWidth,stroke=_a.stroke;if(this.elm){this.elm.select("g").remove();var data=this.data||this.referenceSystem&&this.referenceSystem.projectedPath;data&&this.rescaleEvent&&this.elm.append("g").attr("class","well-path").append("path").attr("d",this.renderWellborePath(data)).attr("stroke-width",strokeWidth||"2px").attr("stroke",stroke||"red").attr("fill","none")}},WellborepathLayer.prototype.renderWellborePath=function(data){var _a=this.rescaleEvent,xScale=_a.xScale,yScale=_a.yScale,transformedData=data.map((function(d){return[xScale(d[0]),yScale(d[1])]}));return function(){var x$1=x,y$1=y,defined=constant$1(!0),context=null,curve=curveLinear,output=null;function line(data){var i,d,buffer,n=data.length,defined0=!1;for(null==context&&(output=curve(buffer=path())),i=0;i<=n;++i)!(i<n&&defined(d=data[i],i,data))===defined0&&((defined0=!defined0)?output.lineStart():output.lineEnd()),defined0&&output.point(+x$1(d,i,data),+y$1(d,i,data));if(buffer)return output=null,buffer+""||null}return line.x=function(_){return arguments.length?(x$1="function"==typeof _?_:constant$1(+_),line):x$1},line.y=function(_){return arguments.length?(y$1="function"==typeof _?_:constant$1(+_),line):y$1},line.defined=function(_){return arguments.length?(defined="function"==typeof _?_:constant$1(!!_),line):defined},line.curve=function(_){return arguments.length?(curve=_,null!=context&&(output=curve(context)),line):curve},line.context=function(_){return arguments.length?(null==_?context=output=null:output=curve(context=_),line):context},line}().curve(curveCatmullRom)(transformedData)},WellborepathLayer}(SVGLayer),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(fn,module){return fn(module={exports:{}},module.exports),module.exports}var promise=createCommonjsModule((function(module,exports){!function(global){var NativePromise=global.Promise,nativePromiseSupported=NativePromise&&"resolve"in NativePromise&&"reject"in NativePromise&&"all"in NativePromise&&"race"in NativePromise&&function(){var resolve;return new NativePromise((function(r){resolve=r})),"function"==typeof resolve}();exports?(exports.Promise=nativePromiseSupported?NativePromise:Promise,exports.Polyfill=Promise):nativePromiseSupported||(global.Promise=Promise);var NOOP=function(){};function isArray(value){return"[object Array]"===Object.prototype.toString.call(value)}var asyncTimer,asyncSetTimer="undefined"!=typeof setImmediate?setImmediate:setTimeout,asyncQueue=[];function asyncFlush(){for(var i=0;i<asyncQueue.length;i++)asyncQueue[i][0](asyncQueue[i][1]);asyncQueue=[],asyncTimer=!1}function asyncCall(callback,arg){asyncQueue.push([callback,arg]),asyncTimer||(asyncTimer=!0,asyncSetTimer(asyncFlush,0))}function invokeCallback(subscriber){var owner=subscriber.owner,settled=owner.state_,value=owner.data_,callback=subscriber[settled],promise=subscriber.then;if("function"==typeof callback){settled="fulfilled";try{value=callback(value)}catch(e){reject(promise,e)}}handleThenable(promise,value)||("fulfilled"===settled&&resolve(promise,value),"rejected"===settled&&reject(promise,value))}function handleThenable(promise,value){var resolved;try{if(promise===value)throw new TypeError("A promises callback cannot return that same promise.");if(value&&("function"==typeof value||"object"==typeof value)){var then=value.then;if("function"==typeof then)return then.call(value,(function(val){resolved||(resolved=!0,value!==val?resolve(promise,val):fulfill(promise,val))}),(function(reason){resolved||(resolved=!0,reject(promise,reason))})),!0}}catch(e){return resolved||reject(promise,e),!0}return!1}function resolve(promise,value){promise!==value&&handleThenable(promise,value)||fulfill(promise,value)}function fulfill(promise,value){"pending"===promise.state_&&(promise.state_="sealed",promise.data_=value,asyncCall(publishFulfillment,promise))}function reject(promise,reason){"pending"===promise.state_&&(promise.state_="sealed",promise.data_=reason,asyncCall(publishRejection,promise))}function publish(promise){var callbacks=promise.then_;promise.then_=void 0;for(var i=0;i<callbacks.length;i++)invokeCallback(callbacks[i])}function publishFulfillment(promise){promise.state_="fulfilled",publish(promise)}function publishRejection(promise){promise.state_="rejected",publish(promise)}function Promise(resolver){if("function"!=typeof resolver)throw new TypeError("Promise constructor takes a function argument");if(this instanceof Promise==!1)throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this.then_=[],function(resolver,promise){function rejectPromise(reason){reject(promise,reason)}try{resolver((function(value){resolve(promise,value)}),rejectPromise)}catch(e){rejectPromise(e)}}(resolver,this)}Promise.prototype={constructor:Promise,state_:"pending",then_:null,data_:void 0,then:function(onFulfillment,onRejection){var subscriber={owner:this,then:new this.constructor(NOOP),fulfilled:onFulfillment,rejected:onRejection};return"fulfilled"===this.state_||"rejected"===this.state_?asyncCall(invokeCallback,subscriber):this.then_.push(subscriber),subscriber.then},catch:function(onRejection){return this.then(null,onRejection)}},Promise.all=function(promises){if(!isArray(promises))throw new TypeError("You must pass an array to Promise.all().");return new this((function(resolve,reject){var results=[],remaining=0;function resolver(index){return remaining++,function(value){results[index]=value,--remaining||resolve(results)}}for(var promise,i=0;i<promises.length;i++)(promise=promises[i])&&"function"==typeof promise.then?promise.then(resolver(i),reject):results[i]=promise;remaining||resolve(results)}))},Promise.race=function(promises){if(!isArray(promises))throw new TypeError("You must pass an array to Promise.race().");return new this((function(resolve,reject){for(var promise,i=0;i<promises.length;i++)(promise=promises[i])&&"function"==typeof promise.then?promise.then(resolve,reject):resolve(promise)}))},Promise.resolve=function(value){return value&&"object"==typeof value&&value.constructor===this?value:new this((function(resolve){resolve(value)}))},Promise.reject=function(reason){return new this((function(resolve,reject){reject(reason)}))}}("undefined"!=typeof window?window:void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:commonjsGlobal)}));promise.Promise;var promise_2=promise.Polyfill,getOwnPropertySymbols=Object.getOwnPropertySymbols,hasOwnProperty=Object.prototype.hasOwnProperty,propIsEnumerable=Object.prototype.propertyIsEnumerable;
|
|
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 __)}var __assign=function(){return(__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t}).apply(this,arguments)};function __awaiter(thisArg,_arguments,P,generator){return new(P||(P=Promise))((function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P((function(resolve){resolve(value)}))).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())}))}function __generator(thisArg,body){var f,y,t,g,_={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return function(op){if(f)throw new TypeError("Generator is already executing.");for(;_;)try{if(f=1,y&&(t=2&op[0]?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;switch(y=0,t&&(op=[2&op[0],t.value]),op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if(!(t=_.trys,(t=t.length>0&&t[t.length-1])||6!==op[0]&&2!==op[0])){_=0;continue}if(3===op[0]&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(6===op[0]&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}t[2]&&_.ops.pop(),_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(5&op[0])throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}([n,v])}}}function __spreadArray(to,from){for(var i=0,il=from.length,j=to.length;i<il;i++,j++)to[j]=from[i];return to}var defaultOptions={order:1,layerOpacity:1,interactive:!1},Layer=function(){function Layer(id,options){this._referenceSystem=null,this._interactive=!1,this._id=id||"layer-"+Math.floor(1e3*Math.random());var opts=options||defaultOptions;this._order=opts.order||1,this._options=__assign({},opts),this.loading=!1,this._element=null,this._opacity=opts.layerOpacity||1,this._visible=!0,this._interactive=opts.interactive||!1,options&&options.data&&this.setData(options.data),this._referenceSystem=options&&options.referenceSystem,this.onMount=this.onMount.bind(this),this.onUnmount=this.onUnmount.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onRescale=this.onRescale.bind(this),this.onResize=this.onResize.bind(this),this.onOrderChanged=this.onOrderChanged.bind(this),this.onOpacityChanged=this.onOpacityChanged.bind(this),this.setVisibility=this.setVisibility.bind(this)}return Object.defineProperty(Layer.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"element",{get:function(){return this._element},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"options",{get:function(){return this._options},set:function(options){this._options=options},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"isLoading",{get:function(){return this.loading},set:function(loading){this.loading=loading},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"opacity",{get:function(){return this._opacity},set:function(opacity){this._opacity=opacity,this.onOpacityChanged(opacity)},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"order",{get:function(){return this._order},set:function(order){this._order=order,this.onOrderChanged(order)},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"interactive",{get:function(){return this._interactive},set:function(shouldBeInteractive){this._interactive=shouldBeInteractive,this.onInteractivityChanged(shouldBeInteractive)},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"referenceSystem",{get:function(){return this._referenceSystem},set:function(referenceSystem){this._referenceSystem=referenceSystem},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"data",{get:function(){return this.getData()},set:function(data){this.setData(data)},enumerable:!1,configurable:!0}),Object.defineProperty(Layer.prototype,"isVisible",{get:function(){return this._visible},enumerable:!1,configurable:!0}),Layer.prototype.getData=function(){return this._data},Layer.prototype.setData=function(data){this._data=data,this.element&&this.onUpdate({data:data})},Layer.prototype.clearData=function(includeReferenceSystem){void 0===includeReferenceSystem&&(includeReferenceSystem=!0),this._data=null,includeReferenceSystem&&(this.referenceSystem=null),this.onUpdate({})},Layer.prototype.setVisibility=function(visible){this._visible=visible},Layer.prototype.onMount=function(event){this._element=event.elm,this._options.onMount&&this._options.onMount(event,this)},Layer.prototype.onUnmount=function(event){this._options.onUnmount&&this._options.onUnmount(event,this)},Layer.prototype.onResize=function(event){this._options.onResize&&this._options.onResize(event,this)},Layer.prototype.onUpdate=function(event){event.data&&(this._data=event.data),this._options.onUpdate&&this._options.onUpdate(event,this)},Layer.prototype.onRescale=function(event){this.optionsRescale(event)},Layer.prototype.optionsRescale=function(event){this._options.onRescale&&this._options.onRescale(event,this)},Layer.prototype.onOpacityChanged=function(opacity){},Layer.prototype.onOrderChanged=function(order){},Layer.prototype.onInteractivityChanged=function(interactive){},Layer}(),CanvasLayer=function(_super){function CanvasLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(CanvasLayer,_super),CanvasLayer.prototype.onOpacityChanged=function(opacity){this.canvas&&this.updateStyle()},CanvasLayer.prototype.onOrderChanged=function(order){this.canvas&&this.updateStyle()},CanvasLayer.prototype.onInteractivityChanged=function(interactive){this.canvas&&this.updateStyle()},CanvasLayer.prototype.setVisibility=function(visible){_super.prototype.setVisibility.call(this,visible),this.canvas&&this.updateStyle(visible)},CanvasLayer.prototype.updateStyle=function(visible){var visibility=visible||this.isVisible?"visible":"hidden",interactive=this.interactive?"auto":"none";this.canvas.setAttribute("style","position:absolute;pointer-events:"+interactive+";z-index:"+this.order+";opacity:"+this.opacity+";visibility:"+visibility)},CanvasLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event);var canvas,elm=event.elm,width=event.width||parseInt(elm.getAttribute("width"),10)||200,height=event.height||parseInt(elm.getAttribute("height"),10)||300;this.elm=elm,this.canvas||(canvas=document.createElement("canvas"),this.canvas=canvas,event.elm.appendChild(canvas)),this.canvas.setAttribute("id",""+this.id),this.canvas.setAttribute("width",width+"px"),this.canvas.setAttribute("height",height+"px"),this.canvas.setAttribute("class","canvas-layer"),this.updateStyle(),this.ctx=this.canvas.getContext("2d")},CanvasLayer.prototype.onUnmount=function(){_super.prototype.onUnmount.call(this),this.canvas.remove(),this.canvas=null},CanvasLayer.prototype.onResize=function(event){var ctx=this.ctx,width=event.width,height=event.height;ctx.canvas.setAttribute("width",width+"px"),ctx.canvas.setAttribute("height",height+"px")},CanvasLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event)},CanvasLayer.prototype.resetTransform=function(){this.ctx.resetTransform()},CanvasLayer.prototype.setTransform=function(event){this.resetTransform();var flippedX=event.xBounds[0]>event.xBounds[1],flippedY=event.yBounds[0]>event.yBounds[1];this.ctx.translate(event.xScale(0),event.yScale(0)),this.ctx.scale(event.xRatio*(flippedX?-1:1),event.yRatio*(flippedY?-1:1))},CanvasLayer.prototype.clearCanvas=function(){var ctx=this.ctx,canvas=this.canvas;ctx.save(),ctx.resetTransform(),ctx.clearRect(0,0,canvas.width,canvas.height),ctx.restore()},CanvasLayer}(Layer),defaultOptions$1={minorColor:"lightgray",majorColor:"gray",minorWidth:.25,majorWidth:.75},GridLayer=function(_super){function GridLayer(id,options){var _this=_super.call(this,id,options)||this;return _this._offsetX=0,_this._offsetY=0,_this.options=__assign(__assign({},_this.options),options||defaultOptions$1),_this.render=_this.render.bind(_this),_this}return __extends(GridLayer,_super),GridLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.render(event)},GridLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.render(event)},GridLayer.prototype.render=function(event){var ctx=this.ctx,_a=this.options,minorWidth=_a.minorWidth,minorColor=_a.minorColor,majorWidth=_a.majorWidth,majorColor=_a.majorColor;if(ctx&&(this.clearCanvas(),event.xScale||event.yScale)){var xScale=event.xScale.copy(),yScale=event.yScale.copy(),xDomain=xScale.domain(),yDomain=yScale.domain(),offsetX=this.offsetX,offsetY=this.offsetY;xScale.domain([xDomain[0]-offsetX,xDomain[1]-offsetX]),yScale.domain([yDomain[0]-offsetY,yDomain[1]-offsetY]);var _b=xScale.range(),rx1=_b[0],rx2=_b[1],_c=yScale.range(),ry1=_c[0],ry2=_c[1];ctx.lineWidth=minorWidth||.25,ctx.strokeStyle=minorColor||"lightgray";var xminticks=this.mapMinorTicks(xScale.ticks()),yminticks=this.mapMinorTicks(yScale.ticks());this.renderTicksX(xScale,xminticks,ry1,ry2),this.renderTicksY(yScale,yminticks,rx1,rx2),ctx.lineWidth=majorWidth||.75,ctx.strokeStyle=majorColor||"gray",this.renderTicksX(xScale,xScale.ticks(),ry1,ry2),this.renderTicksY(yScale,yScale.ticks(),rx1,rx2),ctx.restore()}},GridLayer.prototype.renderTicksX=function(xscale,xticks,ry1,ry2){var _this=this;xticks.forEach((function(tx){var x=xscale(tx);_this.ctx.beginPath(),_this.ctx.moveTo(x,ry1),_this.ctx.lineTo(x,ry2),_this.ctx.stroke()}))},GridLayer.prototype.renderTicksY=function(yscale,yticks,rx1,rx2){var _this=this;yticks.forEach((function(ty){var y=yscale(ty);_this.ctx.beginPath(),_this.ctx.moveTo(rx1,y),_this.ctx.lineTo(rx2,y),_this.ctx.stroke()}))},GridLayer.prototype.mapMinorTicks=function(ticks){var xminticks=[];return ticks.length>=2&&(xminticks=ticks.map((function(v){return v+(ticks[1]-ticks[0])/2}))).pop(),xminticks},Object.defineProperty(GridLayer.prototype,"offsetX",{get:function(){return this._offsetX},set:function(offset){this._offsetX=offset},enumerable:!1,configurable:!0}),Object.defineProperty(GridLayer.prototype,"offsetY",{get:function(){return this._offsetY},set:function(offset){this._offsetY=offset},enumerable:!1,configurable:!0}),GridLayer}(CanvasLayer),xhtml="http://www.w3.org/1999/xhtml",namespaces={svg:"http://www.w3.org/2000/svg",xhtml:xhtml,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function namespace(name){var prefix=name+="",i=prefix.indexOf(":");return i>=0&&"xmlns"!==(prefix=name.slice(0,i))&&(name=name.slice(i+1)),namespaces.hasOwnProperty(prefix)?{space:namespaces[prefix],local:name}:name}function creatorInherit(name){return function(){var document=this.ownerDocument,uri=this.namespaceURI;return uri===xhtml&&document.documentElement.namespaceURI===xhtml?document.createElement(name):document.createElementNS(uri,name)}}function creatorFixed(fullname){return function(){return this.ownerDocument.createElementNS(fullname.space,fullname.local)}}function creator(name){var fullname=namespace(name);return(fullname.local?creatorFixed:creatorInherit)(fullname)}function none(){}function selector(selector){return null==selector?none:function(){return this.querySelector(selector)}}function empty(){return[]}function selectorAll(selector){return null==selector?empty:function(){return this.querySelectorAll(selector)}}function matcher(selector){return function(){return this.matches(selector)}}function sparse(update){return new Array(update.length)}function EnterNode(parent,datum){this.ownerDocument=parent.ownerDocument,this.namespaceURI=parent.namespaceURI,this._next=null,this._parent=parent,this.__data__=datum}EnterNode.prototype={constructor:EnterNode,appendChild:function(child){return this._parent.insertBefore(child,this._next)},insertBefore:function(child,next){return this._parent.insertBefore(child,next)},querySelector:function(selector){return this._parent.querySelector(selector)},querySelectorAll:function(selector){return this._parent.querySelectorAll(selector)}};function bindIndex(parent,group,enter,update,exit,data){for(var node,i=0,groupLength=group.length,dataLength=data.length;i<dataLength;++i)(node=group[i])?(node.__data__=data[i],update[i]=node):enter[i]=new EnterNode(parent,data[i]);for(;i<groupLength;++i)(node=group[i])&&(exit[i]=node)}function bindKey(parent,group,enter,update,exit,data,key){var i,node,keyValue,nodeByKeyValue={},groupLength=group.length,dataLength=data.length,keyValues=new Array(groupLength);for(i=0;i<groupLength;++i)(node=group[i])&&(keyValues[i]=keyValue="$"+key.call(node,node.__data__,i,group),keyValue in nodeByKeyValue?exit[i]=node:nodeByKeyValue[keyValue]=node);for(i=0;i<dataLength;++i)(node=nodeByKeyValue[keyValue="$"+key.call(parent,data[i],i,data)])?(update[i]=node,node.__data__=data[i],nodeByKeyValue[keyValue]=null):enter[i]=new EnterNode(parent,data[i]);for(i=0;i<groupLength;++i)(node=group[i])&&nodeByKeyValue[keyValues[i]]===node&&(exit[i]=node)}function ascending(a,b){return a<b?-1:a>b?1:a>=b?0:NaN}function attrRemove(name){return function(){this.removeAttribute(name)}}function attrRemoveNS(fullname){return function(){this.removeAttributeNS(fullname.space,fullname.local)}}function attrConstant(name,value){return function(){this.setAttribute(name,value)}}function attrConstantNS(fullname,value){return function(){this.setAttributeNS(fullname.space,fullname.local,value)}}function attrFunction(name,value){return function(){var v=value.apply(this,arguments);null==v?this.removeAttribute(name):this.setAttribute(name,v)}}function attrFunctionNS(fullname,value){return function(){var v=value.apply(this,arguments);null==v?this.removeAttributeNS(fullname.space,fullname.local):this.setAttributeNS(fullname.space,fullname.local,v)}}function defaultView(node){return node.ownerDocument&&node.ownerDocument.defaultView||node.document&&node||node.defaultView}function styleRemove(name){return function(){this.style.removeProperty(name)}}function styleConstant(name,value,priority){return function(){this.style.setProperty(name,value,priority)}}function styleFunction(name,value,priority){return function(){var v=value.apply(this,arguments);null==v?this.style.removeProperty(name):this.style.setProperty(name,v,priority)}}function styleValue(node,name){return node.style.getPropertyValue(name)||defaultView(node).getComputedStyle(node,null).getPropertyValue(name)}function propertyRemove(name){return function(){delete this[name]}}function propertyConstant(name,value){return function(){this[name]=value}}function propertyFunction(name,value){return function(){var v=value.apply(this,arguments);null==v?delete this[name]:this[name]=v}}function classArray(string){return string.trim().split(/^|\s+/)}function classList(node){return node.classList||new ClassList(node)}function ClassList(node){this._node=node,this._names=classArray(node.getAttribute("class")||"")}function classedAdd(node,names){for(var list=classList(node),i=-1,n=names.length;++i<n;)list.add(names[i])}function classedRemove(node,names){for(var list=classList(node),i=-1,n=names.length;++i<n;)list.remove(names[i])}function classedTrue(names){return function(){classedAdd(this,names)}}function classedFalse(names){return function(){classedRemove(this,names)}}function classedFunction(names,value){return function(){(value.apply(this,arguments)?classedAdd:classedRemove)(this,names)}}function textRemove(){this.textContent=""}function textConstant(value){return function(){this.textContent=value}}function textFunction(value){return function(){var v=value.apply(this,arguments);this.textContent=null==v?"":v}}function htmlRemove(){this.innerHTML=""}function htmlConstant(value){return function(){this.innerHTML=value}}function htmlFunction(value){return function(){var v=value.apply(this,arguments);this.innerHTML=null==v?"":v}}function raise(){this.nextSibling&&this.parentNode.appendChild(this)}function lower(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function constantNull(){return null}function remove(){var parent=this.parentNode;parent&&parent.removeChild(this)}function selection_cloneShallow(){var clone=this.cloneNode(!1),parent=this.parentNode;return parent?parent.insertBefore(clone,this.nextSibling):clone}function selection_cloneDeep(){var clone=this.cloneNode(!0),parent=this.parentNode;return parent?parent.insertBefore(clone,this.nextSibling):clone}ClassList.prototype={add:function(name){this._names.indexOf(name)<0&&(this._names.push(name),this._node.setAttribute("class",this._names.join(" ")))},remove:function(name){var i=this._names.indexOf(name);i>=0&&(this._names.splice(i,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(name){return this._names.indexOf(name)>=0}};var filterEvents={},event=null;"undefined"!=typeof document&&("onmouseenter"in document.documentElement||(filterEvents={mouseenter:"mouseover",mouseleave:"mouseout"}));function filterContextListener(listener,index,group){return listener=contextListener(listener,index,group),function(event){var related=event.relatedTarget;related&&(related===this||8&related.compareDocumentPosition(this))||listener.call(this,event)}}function contextListener(listener,index,group){return function(event1){var event0=event;event=event1;try{listener.call(this,this.__data__,index,group)}finally{event=event0}}}function parseTypenames(typenames){return typenames.trim().split(/^|\s+/).map((function(t){var name="",i=t.indexOf(".");return i>=0&&(name=t.slice(i+1),t=t.slice(0,i)),{type:t,name:name}}))}function onRemove(typename){return function(){var on=this.__on;if(on){for(var o,j=0,i=-1,m=on.length;j<m;++j)o=on[j],typename.type&&o.type!==typename.type||o.name!==typename.name?on[++i]=o:this.removeEventListener(o.type,o.listener,o.capture);++i?on.length=i:delete this.__on}}}function onAdd(typename,value,capture){var wrap=filterEvents.hasOwnProperty(typename.type)?filterContextListener:contextListener;return function(d,i,group){var o,on=this.__on,listener=wrap(value,i,group);if(on)for(var j=0,m=on.length;j<m;++j)if((o=on[j]).type===typename.type&&o.name===typename.name)return this.removeEventListener(o.type,o.listener,o.capture),this.addEventListener(o.type,o.listener=listener,o.capture=capture),void(o.value=value);this.addEventListener(typename.type,listener,capture),o={type:typename.type,name:typename.name,value:value,listener:listener,capture:capture},on?on.push(o):this.__on=[o]}}function dispatchEvent(node,type,params){var window=defaultView(node),event=window.CustomEvent;"function"==typeof event?event=new event(type,params):(event=window.document.createEvent("Event"),params?(event.initEvent(type,params.bubbles,params.cancelable),event.detail=params.detail):event.initEvent(type,!1,!1)),node.dispatchEvent(event)}function dispatchConstant(type,params){return function(){return dispatchEvent(this,type,params)}}function dispatchFunction(type,params){return function(){return dispatchEvent(this,type,params.apply(this,arguments))}}var root=[null];function Selection(groups,parents){this._groups=groups,this._parents=parents}function selection(){return new Selection([[document.documentElement]],root)}function select(selector){return"string"==typeof selector?new Selection([[document.querySelector(selector)]],[document.documentElement]):new Selection([[selector]],root)}function sourceEvent(){for(var source,current=event;source=current.sourceEvent;)current=source;return current}function point(node,event){var svg=node.ownerSVGElement||node;if(svg.createSVGPoint){var point=svg.createSVGPoint();return point.x=event.clientX,point.y=event.clientY,[(point=point.matrixTransform(node.getScreenCTM().inverse())).x,point.y]}var rect=node.getBoundingClientRect();return[event.clientX-rect.left-node.clientLeft,event.clientY-rect.top-node.clientTop]}function mouse(node){var event=sourceEvent();return event.changedTouches&&(event=event.changedTouches[0]),point(node,event)}function touch(node,touches,identifier){arguments.length<3&&(identifier=touches,touches=sourceEvent().changedTouches);for(var touch,i=0,n=touches?touches.length:0;i<n;++i)if((touch=touches[i]).identifier===identifier)return point(node,touch);return null}Selection.prototype=selection.prototype={constructor:Selection,select:function(select){"function"!=typeof select&&(select=selector(select));for(var groups=this._groups,m=groups.length,subgroups=new Array(m),j=0;j<m;++j)for(var node,subnode,group=groups[j],n=group.length,subgroup=subgroups[j]=new Array(n),i=0;i<n;++i)(node=group[i])&&(subnode=select.call(node,node.__data__,i,group))&&("__data__"in node&&(subnode.__data__=node.__data__),subgroup[i]=subnode);return new Selection(subgroups,this._parents)},selectAll:function(select){"function"!=typeof select&&(select=selectorAll(select));for(var groups=this._groups,m=groups.length,subgroups=[],parents=[],j=0;j<m;++j)for(var node,group=groups[j],n=group.length,i=0;i<n;++i)(node=group[i])&&(subgroups.push(select.call(node,node.__data__,i,group)),parents.push(node));return new Selection(subgroups,parents)},filter:function(match){"function"!=typeof match&&(match=matcher(match));for(var groups=this._groups,m=groups.length,subgroups=new Array(m),j=0;j<m;++j)for(var node,group=groups[j],n=group.length,subgroup=subgroups[j]=[],i=0;i<n;++i)(node=group[i])&&match.call(node,node.__data__,i,group)&&subgroup.push(node);return new Selection(subgroups,this._parents)},data:function(value,key){if(!value)return data=new Array(this.size()),j=-1,this.each((function(d){data[++j]=d})),data;var bind=key?bindKey:bindIndex,parents=this._parents,groups=this._groups;"function"!=typeof value&&(value=function(x){return function(){return x}}(value));for(var m=groups.length,update=new Array(m),enter=new Array(m),exit=new Array(m),j=0;j<m;++j){var parent=parents[j],group=groups[j],groupLength=group.length,data=value.call(parent,parent&&parent.__data__,j,parents),dataLength=data.length,enterGroup=enter[j]=new Array(dataLength),updateGroup=update[j]=new Array(dataLength);bind(parent,group,enterGroup,updateGroup,exit[j]=new Array(groupLength),data,key);for(var previous,next,i0=0,i1=0;i0<dataLength;++i0)if(previous=enterGroup[i0]){for(i0>=i1&&(i1=i0+1);!(next=updateGroup[i1])&&++i1<dataLength;);previous._next=next||null}}return(update=new Selection(update,parents))._enter=enter,update._exit=exit,update},enter:function(){return new Selection(this._enter||this._groups.map(sparse),this._parents)},exit:function(){return new Selection(this._exit||this._groups.map(sparse),this._parents)},join:function(onenter,onupdate,onexit){var enter=this.enter(),update=this,exit=this.exit();return enter="function"==typeof onenter?onenter(enter):enter.append(onenter+""),null!=onupdate&&(update=onupdate(update)),null==onexit?exit.remove():onexit(exit),enter&&update?enter.merge(update).order():update},merge:function(selection){for(var groups0=this._groups,groups1=selection._groups,m0=groups0.length,m1=groups1.length,m=Math.min(m0,m1),merges=new Array(m0),j=0;j<m;++j)for(var node,group0=groups0[j],group1=groups1[j],n=group0.length,merge=merges[j]=new Array(n),i=0;i<n;++i)(node=group0[i]||group1[i])&&(merge[i]=node);for(;j<m0;++j)merges[j]=groups0[j];return new Selection(merges,this._parents)},order:function(){for(var groups=this._groups,j=-1,m=groups.length;++j<m;)for(var node,group=groups[j],i=group.length-1,next=group[i];--i>=0;)(node=group[i])&&(next&&4^node.compareDocumentPosition(next)&&next.parentNode.insertBefore(node,next),next=node);return this},sort:function(compare){function compareNode(a,b){return a&&b?compare(a.__data__,b.__data__):!a-!b}compare||(compare=ascending);for(var groups=this._groups,m=groups.length,sortgroups=new Array(m),j=0;j<m;++j){for(var node,group=groups[j],n=group.length,sortgroup=sortgroups[j]=new Array(n),i=0;i<n;++i)(node=group[i])&&(sortgroup[i]=node);sortgroup.sort(compareNode)}return new Selection(sortgroups,this._parents).order()},call:function(){var callback=arguments[0];return arguments[0]=this,callback.apply(null,arguments),this},nodes:function(){var nodes=new Array(this.size()),i=-1;return this.each((function(){nodes[++i]=this})),nodes},node:function(){for(var groups=this._groups,j=0,m=groups.length;j<m;++j)for(var group=groups[j],i=0,n=group.length;i<n;++i){var node=group[i];if(node)return node}return null},size:function(){var size=0;return this.each((function(){++size})),size},empty:function(){return!this.node()},each:function(callback){for(var groups=this._groups,j=0,m=groups.length;j<m;++j)for(var node,group=groups[j],i=0,n=group.length;i<n;++i)(node=group[i])&&callback.call(node,node.__data__,i,group);return this},attr:function(name,value){var fullname=namespace(name);if(arguments.length<2){var node=this.node();return fullname.local?node.getAttributeNS(fullname.space,fullname.local):node.getAttribute(fullname)}return this.each((null==value?fullname.local?attrRemoveNS:attrRemove:"function"==typeof value?fullname.local?attrFunctionNS:attrFunction:fullname.local?attrConstantNS:attrConstant)(fullname,value))},style:function(name,value,priority){return arguments.length>1?this.each((null==value?styleRemove:"function"==typeof value?styleFunction:styleConstant)(name,value,null==priority?"":priority)):styleValue(this.node(),name)},property:function(name,value){return arguments.length>1?this.each((null==value?propertyRemove:"function"==typeof value?propertyFunction:propertyConstant)(name,value)):this.node()[name]},classed:function(name,value){var names=classArray(name+"");if(arguments.length<2){for(var list=classList(this.node()),i=-1,n=names.length;++i<n;)if(!list.contains(names[i]))return!1;return!0}return this.each(("function"==typeof value?classedFunction:value?classedTrue:classedFalse)(names,value))},text:function(value){return arguments.length?this.each(null==value?textRemove:("function"==typeof value?textFunction:textConstant)(value)):this.node().textContent},html:function(value){return arguments.length?this.each(null==value?htmlRemove:("function"==typeof value?htmlFunction:htmlConstant)(value)):this.node().innerHTML},raise:function(){return this.each(raise)},lower:function(){return this.each(lower)},append:function(name){var create="function"==typeof name?name:creator(name);return this.select((function(){return this.appendChild(create.apply(this,arguments))}))},insert:function(name,before){var create="function"==typeof name?name:creator(name),select=null==before?constantNull:"function"==typeof before?before:selector(before);return this.select((function(){return this.insertBefore(create.apply(this,arguments),select.apply(this,arguments)||null)}))},remove:function(){return this.each(remove)},clone:function(deep){return this.select(deep?selection_cloneDeep:selection_cloneShallow)},datum:function(value){return arguments.length?this.property("__data__",value):this.node().__data__},on:function(typename,value,capture){var i,t,typenames=parseTypenames(typename+""),n=typenames.length;if(!(arguments.length<2)){for(on=value?onAdd:onRemove,null==capture&&(capture=!1),i=0;i<n;++i)this.each(on(typenames[i],value,capture));return this}var on=this.node().__on;if(on)for(var o,j=0,m=on.length;j<m;++j)for(i=0,o=on[j];i<n;++i)if((t=typenames[i]).type===o.type&&t.name===o.name)return o.value},dispatch:function(type,params){return this.each(("function"==typeof params?dispatchFunction:dispatchConstant)(type,params))}};var SVGLayer=function(_super){function SVGLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(SVGLayer,_super),SVGLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event);var elm=event.elm,width=event.width||parseInt(elm.getAttribute("width"),10)||200,height=event.height||parseInt(elm.getAttribute("height"),10)||300;this.elm||(this.elm=select(elm).append("svg"),this.elm.attr("id",""+this.id),this.elm.attr("class","svg-layer")),this.elm.attr("height",height).attr("width",width);var interactive=this.interactive?"auto":"none";this.elm.style("position","absolute").style("pointer-events",interactive).style("opacity",this.opacity).style("z-index",this.order)},SVGLayer.prototype.onUnmount=function(){_super.prototype.onUnmount.call(this),this.elm.remove(),this.elm=null},SVGLayer.prototype.onResize=function(event){this.elm&&(_super.prototype.onResize.call(this,event),this.elm.attr("height",event.height).attr("width",event.width))},SVGLayer.prototype.setVisibility=function(visible){_super.prototype.setVisibility.call(this,visible),this.elm&&this.elm.attr("visibility",visible?"visible":"hidden")},SVGLayer.prototype.onOpacityChanged=function(opacity){this.elm&&this.elm.style("opacity",opacity)},SVGLayer.prototype.onOrderChanged=function(order){this.elm&&this.elm.style("z-index",order)},SVGLayer.prototype.onInteractivityChanged=function(shouldBeInteractive){if(this.elm){var interactive=shouldBeInteractive?"auto":"none";this.elm.style("pointer-events",interactive)}},SVGLayer}(Layer),HTMLLayer=function(_super){function HTMLLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(HTMLLayer,_super),HTMLLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event);var elm=event.elm,width=event.width||parseInt(elm.getAttribute("width"),10)||200,height=event.height||parseInt(elm.getAttribute("height"),10)||300;this.elm||(this.elm=select(elm).append("div"),this.elm.attr("id",""+this.id),this.elm.attr("class","html-layer"));var interactive=this.interactive?"auto":"none";this.elm.style("position","absolute").style("height",height+"px").style("width",width+"px").style("opacity",this.opacity).style("overflow","hidden").style("pointer-events",interactive).style("z-index",this.order)},HTMLLayer.prototype.onUnmount=function(){_super.prototype.onUnmount.call(this),this.elm.remove(),this.elm=null},HTMLLayer.prototype.onResize=function(event){this.elm&&(_super.prototype.onResize.call(this,event),this.elm.style("height",event.height+"px").style("width",event.width+"px"))},HTMLLayer.prototype.setVisibility=function(visible){_super.prototype.setVisibility.call(this,visible),this.elm&&this.elm.attr("visibility",visible?"visible":"hidden")},HTMLLayer.prototype.onOpacityChanged=function(opacity){this.elm&&this.elm.style("opacity",opacity)},HTMLLayer.prototype.onOrderChanged=function(order){this.elm&&this.elm.style("z-index",order)},HTMLLayer.prototype.onInteractivityChanged=function(shouldBeInteractive){if(this.elm){var interactive=shouldBeInteractive?"auto":"none";this.elm.style("pointer-events",interactive)}},HTMLLayer}(Layer),pi=Math.PI,tau=2*pi,tauEpsilon=tau-1e-6;function Path(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function path(){return new Path}function constant$1(x){return function(){return x}}Path.prototype=path.prototype={constructor:Path,moveTo:function(x,y){this._+="M"+(this._x0=this._x1=+x)+","+(this._y0=this._y1=+y)},closePath:function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(x,y){this._+="L"+(this._x1=+x)+","+(this._y1=+y)},quadraticCurveTo:function(x1,y1,x,y){this._+="Q"+ +x1+","+ +y1+","+(this._x1=+x)+","+(this._y1=+y)},bezierCurveTo:function(x1,y1,x2,y2,x,y){this._+="C"+ +x1+","+ +y1+","+ +x2+","+ +y2+","+(this._x1=+x)+","+(this._y1=+y)},arcTo:function(x1,y1,x2,y2,r){x1=+x1,y1=+y1,x2=+x2,y2=+y2,r=+r;var x0=this._x1,y0=this._y1,x21=x2-x1,y21=y2-y1,x01=x0-x1,y01=y0-y1,l01_2=x01*x01+y01*y01;if(r<0)throw new Error("negative radius: "+r);if(null===this._x1)this._+="M"+(this._x1=x1)+","+(this._y1=y1);else if(l01_2>1e-6)if(Math.abs(y01*x21-y21*x01)>1e-6&&r){var x20=x2-x0,y20=y2-y0,l21_2=x21*x21+y21*y21,l20_2=x20*x20+y20*y20,l21=Math.sqrt(l21_2),l01=Math.sqrt(l01_2),l=r*Math.tan((pi-Math.acos((l21_2+l01_2-l20_2)/(2*l21*l01)))/2),t01=l/l01,t21=l/l21;Math.abs(t01-1)>1e-6&&(this._+="L"+(x1+t01*x01)+","+(y1+t01*y01)),this._+="A"+r+","+r+",0,0,"+ +(y01*x20>x01*y20)+","+(this._x1=x1+t21*x21)+","+(this._y1=y1+t21*y21)}else this._+="L"+(this._x1=x1)+","+(this._y1=y1);else;},arc:function(x,y,r,a0,a1,ccw){x=+x,y=+y,ccw=!!ccw;var dx=(r=+r)*Math.cos(a0),dy=r*Math.sin(a0),x0=x+dx,y0=y+dy,cw=1^ccw,da=ccw?a0-a1:a1-a0;if(r<0)throw new Error("negative radius: "+r);null===this._x1?this._+="M"+x0+","+y0:(Math.abs(this._x1-x0)>1e-6||Math.abs(this._y1-y0)>1e-6)&&(this._+="L"+x0+","+y0),r&&(da<0&&(da=da%tau+tau),da>tauEpsilon?this._+="A"+r+","+r+",0,1,"+cw+","+(x-dx)+","+(y-dy)+"A"+r+","+r+",0,1,"+cw+","+(this._x1=x0)+","+(this._y1=y0):da>1e-6&&(this._+="A"+r+","+r+",0,"+ +(da>=pi)+","+cw+","+(this._x1=x+r*Math.cos(a1))+","+(this._y1=y+r*Math.sin(a1))))},rect:function(x,y,w,h){this._+="M"+(this._x0=this._x1=+x)+","+(this._y0=this._y1=+y)+"h"+ +w+"v"+ +h+"h"+-w+"Z"},toString:function(){return this._}};function Linear(context){this._context=context}function curveLinear(context){return new Linear(context)}function x(p){return p[0]}function y(p){return p[1]}function noop(){}function point$1(that,x,y){that._context.bezierCurveTo((2*that._x0+that._x1)/3,(2*that._y0+that._y1)/3,(that._x0+2*that._x1)/3,(that._y0+2*that._y1)/3,(that._x0+4*that._x1+x)/6,(that._y0+4*that._y1+y)/6)}function Basis(context){this._context=context}function curveBasis(context){return new Basis(context)}function BasisClosed(context){this._context=context}function curveBasisClosed(context){return new BasisClosed(context)}function Bundle(context,beta){this._basis=new Basis(context),this._beta=beta}Linear.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(x,y){switch(x=+x,y=+y,this._point){case 0:this._point=1,this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;default:this._context.lineTo(x,y)}}},Basis.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:point$1(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(x,y){switch(x=+x,y=+y,this._point){case 0:this._point=1,this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:point$1(this,x,y)}this._x0=this._x1,this._x1=x,this._y0=this._y1,this._y1=y}},BasisClosed.prototype={areaStart:noop,areaEnd:noop,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(x,y){switch(x=+x,y=+y,this._point){case 0:this._point=1,this._x2=x,this._y2=y;break;case 1:this._point=2,this._x3=x,this._y3=y;break;case 2:this._point=3,this._x4=x,this._y4=y,this._context.moveTo((this._x0+4*this._x1+x)/6,(this._y0+4*this._y1+y)/6);break;default:point$1(this,x,y)}this._x0=this._x1,this._x1=x,this._y0=this._y1,this._y1=y}},Bundle.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var x=this._x,y=this._y,j=x.length-1;if(j>0)for(var t,x0=x[0],y0=y[0],dx=x[j]-x0,dy=y[j]-y0,i=-1;++i<=j;)t=i/j,this._basis.point(this._beta*x[i]+(1-this._beta)*(x0+t*dx),this._beta*y[i]+(1-this._beta)*(y0+t*dy));this._x=this._y=null,this._basis.lineEnd()},point:function(x,y){this._x.push(+x),this._y.push(+y)}};var curveBundle=function custom(beta){function bundle(context){return 1===beta?new Basis(context):new Bundle(context,beta)}return bundle.beta=function(beta){return custom(+beta)},bundle}(.85);function point$2(that,x,y){that._context.bezierCurveTo(that._x1+that._k*(that._x2-that._x0),that._y1+that._k*(that._y2-that._y0),that._x2+that._k*(that._x1-x),that._y2+that._k*(that._y1-y),that._x2,that._y2)}function Cardinal(context,tension){this._context=context,this._k=(1-tension)/6}Cardinal.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:point$2(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(x,y){switch(x=+x,y=+y,this._point){case 0:this._point=1,this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2,this._x1=x,this._y1=y;break;case 2:this._point=3;default:point$2(this,x,y)}this._x0=this._x1,this._x1=this._x2,this._x2=x,this._y0=this._y1,this._y1=this._y2,this._y2=y}};var curveCardinal=function custom(tension){function cardinal(context){return new Cardinal(context,tension)}return cardinal.tension=function(tension){return custom(+tension)},cardinal}(0);function CatmullRom(context,alpha){this._context=context,this._alpha=alpha}CatmullRom.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(x,y){if(x=+x,y=+y,this._point){var x23=this._x2-x,y23=this._y2-y;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(x23*x23+y23*y23,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3;default:!function(that,x,y){var x1=that._x1,y1=that._y1,x2=that._x2,y2=that._y2;if(that._l01_a>1e-12){var a=2*that._l01_2a+3*that._l01_a*that._l12_a+that._l12_2a,n=3*that._l01_a*(that._l01_a+that._l12_a);x1=(x1*a-that._x0*that._l12_2a+that._x2*that._l01_2a)/n,y1=(y1*a-that._y0*that._l12_2a+that._y2*that._l01_2a)/n}if(that._l23_a>1e-12){var b=2*that._l23_2a+3*that._l23_a*that._l12_a+that._l12_2a,m=3*that._l23_a*(that._l23_a+that._l12_a);x2=(x2*b+that._x1*that._l23_2a-x*that._l12_2a)/m,y2=(y2*b+that._y1*that._l23_2a-y*that._l12_2a)/m}that._context.bezierCurveTo(x1,y1,x2,y2,that._x2,that._y2)}(this,x,y)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=x,this._y0=this._y1,this._y1=this._y2,this._y2=y}};var curveCatmullRom=function custom(alpha){function catmullRom(context){return alpha?new CatmullRom(context,alpha):new Cardinal(context,0)}return catmullRom.alpha=function(alpha){return custom(+alpha)},catmullRom}(.5);function sign(x){return x<0?-1:1}function slope3(that,x2,y2){var h0=that._x1-that._x0,h1=x2-that._x1,s0=(that._y1-that._y0)/(h0||h1<0&&-0),s1=(y2-that._y1)/(h1||h0<0&&-0),p=(s0*h1+s1*h0)/(h0+h1);return(sign(s0)+sign(s1))*Math.min(Math.abs(s0),Math.abs(s1),.5*Math.abs(p))||0}function slope2(that,t){var h=that._x1-that._x0;return h?(3*(that._y1-that._y0)/h-t)/2:t}function point$4(that,t0,t1){var x0=that._x0,y0=that._y0,x1=that._x1,y1=that._y1,dx=(x1-x0)/3;that._context.bezierCurveTo(x0+dx,y0+dx*t0,x1-dx,y1-dx*t1,x1,y1)}function MonotoneX(context){this._context=context}function MonotoneY(context){this._context=new ReflectContext(context)}function ReflectContext(context){this._context=context}function monotoneX(context){return new MonotoneX(context)}function monotoneY(context){return new MonotoneY(context)}function Natural(context){this._context=context}function controlPoints(x){var i,m,n=x.length-1,a=new Array(n),b=new Array(n),r=new Array(n);for(a[0]=0,b[0]=2,r[0]=x[0]+2*x[1],i=1;i<n-1;++i)a[i]=1,b[i]=4,r[i]=4*x[i]+2*x[i+1];for(a[n-1]=2,b[n-1]=7,r[n-1]=8*x[n-1]+x[n],i=1;i<n;++i)m=a[i]/b[i-1],b[i]-=m,r[i]-=m*r[i-1];for(a[n-1]=r[n-1]/b[n-1],i=n-2;i>=0;--i)a[i]=(r[i]-a[i+1])/b[i];for(b[n-1]=(x[n]+a[n-1])/2,i=0;i<n-1;++i)b[i]=2*x[i+1]-a[i+1];return[a,b]}function curveNatural(context){return new Natural(context)}function Step(context,t){this._context=context,this._t=t}function curveStep(context){return new Step(context,.5)}function stepBefore(context){return new Step(context,0)}function stepAfter(context){return new Step(context,1)}MonotoneX.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:point$4(this,this._t0,slope2(this,this._t0))}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(x,y){var t1=NaN;if(y=+y,(x=+x)!==this._x1||y!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3,point$4(this,slope2(this,t1=slope3(this,x,y)),t1);break;default:point$4(this,this._t0,t1=slope3(this,x,y))}this._x0=this._x1,this._x1=x,this._y0=this._y1,this._y1=y,this._t0=t1}}},(MonotoneY.prototype=Object.create(MonotoneX.prototype)).point=function(x,y){MonotoneX.prototype.point.call(this,y,x)},ReflectContext.prototype={moveTo:function(x,y){this._context.moveTo(y,x)},closePath:function(){this._context.closePath()},lineTo:function(x,y){this._context.lineTo(y,x)},bezierCurveTo:function(x1,y1,x2,y2,x,y){this._context.bezierCurveTo(y1,x1,y2,x2,y,x)}},Natural.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var x=this._x,y=this._y,n=x.length;if(n)if(this._line?this._context.lineTo(x[0],y[0]):this._context.moveTo(x[0],y[0]),2===n)this._context.lineTo(x[1],y[1]);else for(var px=controlPoints(x),py=controlPoints(y),i0=0,i1=1;i1<n;++i0,++i1)this._context.bezierCurveTo(px[0][i0],py[0][i0],px[1][i0],py[1][i0],x[i1],y[i1]);(this._line||0!==this._line&&1===n)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(x,y){this._x.push(+x),this._y.push(+y)}},Step.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(x,y){switch(x=+x,y=+y,this._point){case 0:this._point=1,this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,y),this._context.lineTo(x,y);else{var x1=this._x*(1-this._t)+x*this._t;this._context.lineTo(x1,this._y),this._context.lineTo(x1,y)}}this._x=x,this._y=y}};var WellborepathLayer=function(_super){function WellborepathLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.options=__assign(__assign({},_this.options),options),_this.render=_this.render.bind(_this),_this}return __extends(WellborepathLayer,_super),WellborepathLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.render()},WellborepathLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.elm&&(this.rescaleEvent=event,this.render())},WellborepathLayer.prototype.render=function(){var _a=this.options,strokeWidth=_a.strokeWidth,stroke=_a.stroke;if(this.elm){this.elm.select("g").remove();var data=this.data||this.referenceSystem&&this.referenceSystem.projectedPath;data&&this.rescaleEvent&&this.elm.append("g").attr("class","well-path").append("path").attr("d",this.renderWellborePath(data)).attr("stroke-width",strokeWidth||"2px").attr("stroke",stroke||"red").attr("fill","none")}},WellborepathLayer.prototype.renderWellborePath=function(data){var curveFactory,_a=this.rescaleEvent,xScale=_a.xScale,yScale=_a.yScale,transformedData=data.map((function(d){return[xScale(d[0]),yScale(d[1])]})),_b=this.options,curveType=_b.curveType,tension=_b.tension;switch(curveType){default:case"curveCatmullRom":curveFactory=curveCatmullRom.alpha(tension||.7);break;case"curveLinear":curveFactory=curveLinear;break;case"curveBasis":curveFactory=curveBasis;break;case"curveBasisClosed":curveFactory=curveBasisClosed;break;case"curveBundle":curveFactory=curveBundle.beta(tension||1);break;case"curveCardinal":curveFactory=curveCardinal.tension(tension||.9);break;case"curveMonotoneX":curveFactory=monotoneX;break;case"curveMonotoneY":curveFactory=monotoneY;break;case"curveNatural":curveFactory=curveNatural;break;case"curveStep":curveFactory=curveStep;break;case"curveStepAfter":curveFactory=stepAfter;break;case"curveStepBefore":curveFactory=stepBefore}return function(){var x$1=x,y$1=y,defined=constant$1(!0),context=null,curve=curveLinear,output=null;function line(data){var i,d,buffer,n=data.length,defined0=!1;for(null==context&&(output=curve(buffer=path())),i=0;i<=n;++i)!(i<n&&defined(d=data[i],i,data))===defined0&&((defined0=!defined0)?output.lineStart():output.lineEnd()),defined0&&output.point(+x$1(d,i,data),+y$1(d,i,data));if(buffer)return output=null,buffer+""||null}return line.x=function(_){return arguments.length?(x$1="function"==typeof _?_:constant$1(+_),line):x$1},line.y=function(_){return arguments.length?(y$1="function"==typeof _?_:constant$1(+_),line):y$1},line.defined=function(_){return arguments.length?(defined="function"==typeof _?_:constant$1(!!_),line):defined},line.curve=function(_){return arguments.length?(curve=_,null!=context&&(output=curve(context)),line):curve},line.context=function(_){return arguments.length?(null==_?context=output=null:output=curve(context=_),line):context},line}().curve(curveFactory)(transformedData)},WellborepathLayer}(SVGLayer),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(fn,module){return fn(module={exports:{}},module.exports),module.exports}var promise=createCommonjsModule((function(module,exports){!function(global){var NativePromise=global.Promise,nativePromiseSupported=NativePromise&&"resolve"in NativePromise&&"reject"in NativePromise&&"all"in NativePromise&&"race"in NativePromise&&function(){var resolve;return new NativePromise((function(r){resolve=r})),"function"==typeof resolve}();exports?(exports.Promise=nativePromiseSupported?NativePromise:Promise,exports.Polyfill=Promise):nativePromiseSupported||(global.Promise=Promise);var NOOP=function(){};function isArray(value){return"[object Array]"===Object.prototype.toString.call(value)}var asyncTimer,asyncSetTimer="undefined"!=typeof setImmediate?setImmediate:setTimeout,asyncQueue=[];function asyncFlush(){for(var i=0;i<asyncQueue.length;i++)asyncQueue[i][0](asyncQueue[i][1]);asyncQueue=[],asyncTimer=!1}function asyncCall(callback,arg){asyncQueue.push([callback,arg]),asyncTimer||(asyncTimer=!0,asyncSetTimer(asyncFlush,0))}function invokeCallback(subscriber){var owner=subscriber.owner,settled=owner.state_,value=owner.data_,callback=subscriber[settled],promise=subscriber.then;if("function"==typeof callback){settled="fulfilled";try{value=callback(value)}catch(e){reject(promise,e)}}handleThenable(promise,value)||("fulfilled"===settled&&resolve(promise,value),"rejected"===settled&&reject(promise,value))}function handleThenable(promise,value){var resolved;try{if(promise===value)throw new TypeError("A promises callback cannot return that same promise.");if(value&&("function"==typeof value||"object"==typeof value)){var then=value.then;if("function"==typeof then)return then.call(value,(function(val){resolved||(resolved=!0,value!==val?resolve(promise,val):fulfill(promise,val))}),(function(reason){resolved||(resolved=!0,reject(promise,reason))})),!0}}catch(e){return resolved||reject(promise,e),!0}return!1}function resolve(promise,value){promise!==value&&handleThenable(promise,value)||fulfill(promise,value)}function fulfill(promise,value){"pending"===promise.state_&&(promise.state_="sealed",promise.data_=value,asyncCall(publishFulfillment,promise))}function reject(promise,reason){"pending"===promise.state_&&(promise.state_="sealed",promise.data_=reason,asyncCall(publishRejection,promise))}function publish(promise){var callbacks=promise.then_;promise.then_=void 0;for(var i=0;i<callbacks.length;i++)invokeCallback(callbacks[i])}function publishFulfillment(promise){promise.state_="fulfilled",publish(promise)}function publishRejection(promise){promise.state_="rejected",publish(promise)}function Promise(resolver){if("function"!=typeof resolver)throw new TypeError("Promise constructor takes a function argument");if(this instanceof Promise==!1)throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this.then_=[],function(resolver,promise){function rejectPromise(reason){reject(promise,reason)}try{resolver((function(value){resolve(promise,value)}),rejectPromise)}catch(e){rejectPromise(e)}}(resolver,this)}Promise.prototype={constructor:Promise,state_:"pending",then_:null,data_:void 0,then:function(onFulfillment,onRejection){var subscriber={owner:this,then:new this.constructor(NOOP),fulfilled:onFulfillment,rejected:onRejection};return"fulfilled"===this.state_||"rejected"===this.state_?asyncCall(invokeCallback,subscriber):this.then_.push(subscriber),subscriber.then},catch:function(onRejection){return this.then(null,onRejection)}},Promise.all=function(promises){if(!isArray(promises))throw new TypeError("You must pass an array to Promise.all().");return new this((function(resolve,reject){var results=[],remaining=0;function resolver(index){return remaining++,function(value){results[index]=value,--remaining||resolve(results)}}for(var promise,i=0;i<promises.length;i++)(promise=promises[i])&&"function"==typeof promise.then?promise.then(resolver(i),reject):results[i]=promise;remaining||resolve(results)}))},Promise.race=function(promises){if(!isArray(promises))throw new TypeError("You must pass an array to Promise.race().");return new this((function(resolve,reject){for(var promise,i=0;i<promises.length;i++)(promise=promises[i])&&"function"==typeof promise.then?promise.then(resolve,reject):resolve(promise)}))},Promise.resolve=function(value){return value&&"object"==typeof value&&value.constructor===this?value:new this((function(resolve){resolve(value)}))},Promise.reject=function(reason){return new this((function(resolve,reject){reject(reason)}))}}("undefined"!=typeof window?window:void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:commonjsGlobal)}));promise.Promise;var promise_2=promise.Polyfill,getOwnPropertySymbols=Object.getOwnPropertySymbols,hasOwnProperty=Object.prototype.hasOwnProperty,propIsEnumerable=Object.prototype.propertyIsEnumerable;
|
|
16
16
|
/*
|
|
17
17
|
object-assign
|
|
18
18
|
(c) Sindre Sorhus
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* @pixi/settings is licensed under the MIT License.
|
|
33
33
|
* http://www.opensource.org/licenses/mit-license
|
|
34
34
|
*/
|
|
35
|
-
var isMobile$1=function(param){var nav={userAgent:"",platform:"",maxTouchPoints:0};param||"undefined"==typeof navigator?"string"==typeof param?nav.userAgent=param:param&¶m.userAgent&&(nav={userAgent:param.userAgent,platform:param.platform,maxTouchPoints:param.maxTouchPoints||0}):nav={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var userAgent=nav.userAgent,tmp=userAgent.split("[FBAN");void 0!==tmp[1]&&(userAgent=tmp[0]),void 0!==(tmp=userAgent.split("Twitter"))[1]&&(userAgent=tmp[0]);var match=function(userAgent){return function(regex){return regex.test(userAgent)}}(userAgent),result={apple:{phone:match(appleIphone)&&!match(windowsPhone),ipod:match(appleIpod),tablet:!match(appleIphone)&&(match(appleTablet)||isAppleTabletOnIos13(nav))&&!match(windowsPhone),universal:match(appleUniversal),device:(match(appleIphone)||match(appleIpod)||match(appleTablet)||match(appleUniversal)||isAppleTabletOnIos13(nav))&&!match(windowsPhone)},amazon:{phone:match(amazonPhone),tablet:!match(amazonPhone)&&match(amazonTablet),device:match(amazonPhone)||match(amazonTablet)},android:{phone:!match(windowsPhone)&&match(amazonPhone)||!match(windowsPhone)&&match(androidPhone),tablet:!match(windowsPhone)&&!match(amazonPhone)&&!match(androidPhone)&&(match(amazonTablet)||match(androidTablet)),device:!match(windowsPhone)&&(match(amazonPhone)||match(amazonTablet)||match(androidPhone)||match(androidTablet))||match(/\bokhttp\b/i)},windows:{phone:match(windowsPhone),tablet:match(windowsTablet),device:match(windowsPhone)||match(windowsTablet)},other:{blackberry:match(otherBlackBerry),blackberry10:match(otherBlackBerry10),opera:match(otherOpera),firefox:match(otherFirefox),chrome:match(otherChrome),device:match(otherBlackBerry)||match(otherBlackBerry10)||match(otherOpera)||match(otherFirefox)||match(otherChrome)},any:!1,phone:!1,tablet:!1};return result.any=result.apple.device||result.android.device||result.windows.device||result.other.device,result.phone=result.apple.phone||result.android.phone||result.windows.phone,result.tablet=result.apple.tablet||result.android.tablet||result.windows.tablet,result}(window.navigator);var ENV,RENDERER_TYPE,BUFFER_BITS,BLEND_MODES,DRAW_MODES,FORMATS,TARGETS,TYPES,SCALE_MODES,WRAP_MODES,MIPMAP_MODES,ALPHA_MODES,CLEAR_MODES,GC_MODES,PRECISION,MASK_TYPES,MSAA_QUALITY,settings={MIPMAP_TEXTURES:1,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,SPRITE_MAX_TEXTURES:function(max){var allowMax=!0;if(isMobile$1.tablet||isMobile$1.phone){var match;if(isMobile$1.apple.device)if(match=navigator.userAgent.match(/OS (\d+)_(\d+)?/))parseInt(match[1],10)<11&&(allowMax=!1);if(isMobile$1.android.device)if(match=navigator.userAgent.match(/Android\s([0-9.]*)/))parseInt(match[1],10)<7&&(allowMax=!1)}return allowMax?max:4}(32),SPRITE_BATCH_SIZE:4096,RENDER_OPTIONS:{view:null,antialias:!1,autoDensity:!1,transparent:!1,backgroundColor:0,clearBeforeRender:!0,preserveDrawingBuffer:!1,width:800,height:600,legacy:!1},GC_MODE:0,GC_MAX_IDLE:3600,GC_MAX_CHECK_COUNT:600,WRAP_MODE:33071,SCALE_MODE:1,PRECISION_VERTEX:"highp",PRECISION_FRAGMENT:isMobile$1.apple.device?"highp":"mediump",CAN_UPLOAD_SAME_BUFFER:!isMobile$1.apple.device,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1},eventemitter3=createCommonjsModule((function(module){var has=Object.prototype.hasOwnProperty,prefix="~";function Events(){}function EE(fn,context,once){this.fn=fn,this.context=context,this.once=once||!1}function addListener(emitter,event,fn,context,once){if("function"!=typeof fn)throw new TypeError("The listener must be a function");var listener=new EE(fn,context||emitter,once),evt=prefix?prefix+event:event;return emitter._events[evt]?emitter._events[evt].fn?emitter._events[evt]=[emitter._events[evt],listener]:emitter._events[evt].push(listener):(emitter._events[evt]=listener,emitter._eventsCount++),emitter}function clearEvent(emitter,evt){0==--emitter._eventsCount?emitter._events=new Events:delete emitter._events[evt]}function EventEmitter(){this._events=new Events,this._eventsCount=0}Object.create&&(Events.prototype=Object.create(null),(new Events).__proto__||(prefix=!1)),EventEmitter.prototype.eventNames=function(){var events,name,names=[];if(0===this._eventsCount)return names;for(name in events=this._events)has.call(events,name)&&names.push(prefix?name.slice(1):name);return Object.getOwnPropertySymbols?names.concat(Object.getOwnPropertySymbols(events)):names},EventEmitter.prototype.listeners=function(event){var evt=prefix?prefix+event:event,handlers=this._events[evt];if(!handlers)return[];if(handlers.fn)return[handlers.fn];for(var i=0,l=handlers.length,ee=new Array(l);i<l;i++)ee[i]=handlers[i].fn;return ee},EventEmitter.prototype.listenerCount=function(event){var evt=prefix?prefix+event:event,listeners=this._events[evt];return listeners?listeners.fn?1:listeners.length:0},EventEmitter.prototype.emit=function(event,a1,a2,a3,a4,a5){var evt=prefix?prefix+event:event;if(!this._events[evt])return!1;var args,i,listeners=this._events[evt],len=arguments.length;if(listeners.fn){switch(listeners.once&&this.removeListener(event,listeners.fn,void 0,!0),len){case 1:return listeners.fn.call(listeners.context),!0;case 2:return listeners.fn.call(listeners.context,a1),!0;case 3:return listeners.fn.call(listeners.context,a1,a2),!0;case 4:return listeners.fn.call(listeners.context,a1,a2,a3),!0;case 5:return listeners.fn.call(listeners.context,a1,a2,a3,a4),!0;case 6:return listeners.fn.call(listeners.context,a1,a2,a3,a4,a5),!0}for(i=1,args=new Array(len-1);i<len;i++)args[i-1]=arguments[i];listeners.fn.apply(listeners.context,args)}else{var j,length=listeners.length;for(i=0;i<length;i++)switch(listeners[i].once&&this.removeListener(event,listeners[i].fn,void 0,!0),len){case 1:listeners[i].fn.call(listeners[i].context);break;case 2:listeners[i].fn.call(listeners[i].context,a1);break;case 3:listeners[i].fn.call(listeners[i].context,a1,a2);break;case 4:listeners[i].fn.call(listeners[i].context,a1,a2,a3);break;default:if(!args)for(j=1,args=new Array(len-1);j<len;j++)args[j-1]=arguments[j];listeners[i].fn.apply(listeners[i].context,args)}}return!0},EventEmitter.prototype.on=function(event,fn,context){return addListener(this,event,fn,context,!1)},EventEmitter.prototype.once=function(event,fn,context){return addListener(this,event,fn,context,!0)},EventEmitter.prototype.removeListener=function(event,fn,context,once){var evt=prefix?prefix+event:event;if(!this._events[evt])return this;if(!fn)return clearEvent(this,evt),this;var listeners=this._events[evt];if(listeners.fn)listeners.fn!==fn||once&&!listeners.once||context&&listeners.context!==context||clearEvent(this,evt);else{for(var i=0,events=[],length=listeners.length;i<length;i++)(listeners[i].fn!==fn||once&&!listeners[i].once||context&&listeners[i].context!==context)&&events.push(listeners[i]);events.length?this._events[evt]=1===events.length?events[0]:events:clearEvent(this,evt)}return this},EventEmitter.prototype.removeAllListeners=function(event){var evt;return event?(evt=prefix?prefix+event:event,this._events[evt]&&clearEvent(this,evt)):(this._events=new Events,this._eventsCount=0),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prefixed=prefix,EventEmitter.EventEmitter=EventEmitter,module.exports=EventEmitter})),earcut_1=earcut,default_1=earcut;function earcut(data,holeIndices,dim){dim=dim||2;var minX,minY,maxX,maxY,x,y,invSize,hasHoles=holeIndices&&holeIndices.length,outerLen=hasHoles?holeIndices[0]*dim:data.length,outerNode=linkedList(data,0,outerLen,dim,!0),triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles&&(outerNode=function(data,holeIndices,outerNode,dim){var i,len,list,queue=[];for(i=0,len=holeIndices.length;i<len;i++)(list=linkedList(data,holeIndices[i]*dim,i<len-1?holeIndices[i+1]*dim:data.length,dim,!1))===list.next&&(list.steiner=!0),queue.push(getLeftmost(list));for(queue.sort(compareX),i=0;i<queue.length;i++)eliminateHole(queue[i],outerNode),outerNode=filterPoints(outerNode,outerNode.next);return outerNode}(data,holeIndices,outerNode,dim)),data.length>80*dim){minX=maxX=data[0],minY=maxY=data[1];for(var i=dim;i<outerLen;i+=dim)(x=data[i])<minX&&(minX=x),(y=data[i+1])<minY&&(minY=y),x>maxX&&(maxX=x),y>maxY&&(maxY=y);invSize=0!==(invSize=Math.max(maxX-minX,maxY-minY))?1/invSize:0}return earcutLinked(outerNode,triangles,dim,minX,minY,invSize),triangles}function linkedList(data,start,end,dim,clockwise){var i,last;if(clockwise===signedArea(data,start,end,dim)>0)for(i=start;i<end;i+=dim)last=insertNode(i,data[i],data[i+1],last);else for(i=end-dim;i>=start;i-=dim)last=insertNode(i,data[i],data[i+1],last);return last&&equals(last,last.next)&&(removeNode(last),last=last.next),last}function filterPoints(start,end){if(!start)return start;end||(end=start);var again,p=start;do{if(again=!1,p.steiner||!equals(p,p.next)&&0!==area(p.prev,p,p.next))p=p.next;else{if(removeNode(p),(p=end=p.prev)===p.next)break;again=!0}}while(again||p!==end);return end}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(ear){!pass&&invSize&&function(start,minX,minY,invSize){var p=start;do{null===p.z&&(p.z=zOrder(p.x,p.y,minX,minY,invSize)),p.prevZ=p.prev,p.nextZ=p.next,p=p.next}while(p!==start);p.prevZ.nextZ=null,p.prevZ=null,function(list){var i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{for(p=list,list=null,tail=null,numMerges=0;p;){for(numMerges++,q=p,pSize=0,i=0;i<inSize&&(pSize++,q=q.nextZ);i++);for(qSize=inSize;pSize>0||qSize>0&&q;)0!==pSize&&(0===qSize||!q||p.z<=q.z)?(e=p,p=p.nextZ,pSize--):(e=q,q=q.nextZ,qSize--),tail?tail.nextZ=e:list=e,e.prevZ=tail,tail=e;p=q}tail.nextZ=null,inSize*=2}while(numMerges>1)}(p)}(ear,minX,minY,invSize);for(var prev,next,stop=ear;ear.prev!==ear.next;)if(prev=ear.prev,next=ear.next,invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear))triangles.push(prev.i/dim),triangles.push(ear.i/dim),triangles.push(next.i/dim),removeNode(ear),ear=next.next,stop=next.next;else if((ear=next)===stop){pass?1===pass?earcutLinked(ear=cureLocalIntersections(filterPoints(ear),triangles,dim),triangles,dim,minX,minY,invSize,2):2===pass&&splitEarcut(ear,triangles,dim,minX,minY,invSize):earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1);break}}}function isEar(ear){var a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return!1;for(var p=ear.next.next;p!==ear.prev;){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function isEarHashed(ear,minX,minY,invSize){var a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return!1;for(var minTX=a.x<b.x?a.x<c.x?a.x:c.x:b.x<c.x?b.x:c.x,minTY=a.y<b.y?a.y<c.y?a.y:c.y:b.y<c.y?b.y:c.y,maxTX=a.x>b.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x,maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y,minZ=zOrder(minTX,minTY,minX,minY,invSize),maxZ=zOrder(maxTX,maxTY,minX,minY,invSize),p=ear.prevZ,n=ear.nextZ;p&&p.z>=minZ&&n&&n.z<=maxZ;){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return!1;n=n.nextZ}for(;p&&p.z>=minZ;){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;n&&n.z<=maxZ;){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return!1;n=n.nextZ}return!0}function cureLocalIntersections(start,triangles,dim){var p=start;do{var a=p.prev,b=p.next.next;!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)&&(triangles.push(a.i/dim),triangles.push(p.i/dim),triangles.push(b.i/dim),removeNode(p),removeNode(p.next),p=start=b),p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){var a=start;do{for(var b=a.next.next;b!==a.prev;){if(a.i!==b.i&&isValidDiagonal(a,b)){var c=splitPolygon(a,b);return a=filterPoints(a,a.next),c=filterPoints(c,c.next),earcutLinked(a,triangles,dim,minX,minY,invSize),void earcutLinked(c,triangles,dim,minX,minY,invSize)}b=b.next}a=a.next}while(a!==start)}function compareX(a,b){return a.x-b.x}function eliminateHole(hole,outerNode){if(outerNode=function(hole,outerNode){var m,p=outerNode,hx=hole.x,hy=hole.y,qx=-1/0;do{if(hy<=p.y&&hy>=p.next.y&&p.next.y!==p.y){var x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){if(qx=x,x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x<p.next.x?p:p.next}}p=p.next}while(p!==outerNode);if(!m)return null;if(hx===qx)return m;var tan,stop=m,mx=m.x,my=m.y,tanMin=1/0;p=m;do{hx>=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hy<my?hx:qx,hy,mx,my,hy<my?qx:hx,hy,p.x,p.y)&&(tan=Math.abs(hy-p.y)/(hx-p.x),locallyInside(p,hole)&&(tan<tanMin||tan===tanMin&&(p.x>m.x||p.x===m.x&§orContainsSector(m,p)))&&(m=p,tanMin=tan)),p=p.next}while(p!==stop);return m}(hole,outerNode)){var b=splitPolygon(outerNode,hole);filterPoints(outerNode,outerNode.next),filterPoints(b,b.next)}}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function zOrder(x,y,minX,minY,invSize){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=32767*(x-minX)*invSize)|x<<8))|x<<4))|x<<2))|x<<1))|(y=1431655765&((y=858993459&((y=252645135&((y=16711935&((y=32767*(y-minY)*invSize)|y<<8))|y<<4))|y<<2))|y<<1))<<1}function getLeftmost(start){var p=start,leftmost=start;do{(p.x<leftmost.x||p.x===leftmost.x&&p.y<leftmost.y)&&(leftmost=p),p=p.next}while(p!==start);return leftmost}function pointInTriangle(ax,ay,bx,by,cx,cy,px,py){return(cx-px)*(ay-py)-(ax-px)*(cy-py)>=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(a,b){var p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return!0;p=p.next}while(p!==a);return!1}(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&function(a,b){var p=a,inside=!1,px=(a.x+b.x)/2,py=(a.y+b.y)/2;do{p.y>py!=p.next.y>py&&p.next.y!==p.y&&px<(p.next.x-p.x)*(py-p.y)/(p.next.y-p.y)+p.x&&(inside=!inside),p=p.next}while(p!==a);return inside}(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){var o1=sign(area(p1,q1,p2)),o2=sign(area(p1,q1,q2)),o3=sign(area(p2,q2,p1)),o4=sign(area(p2,q2,q1));return o1!==o2&&o3!==o4||(!(0!==o1||!onSegment(p1,p2,q1))||(!(0!==o2||!onSegment(p1,q2,q1))||(!(0!==o3||!onSegment(p2,p1,q2))||!(0!==o4||!onSegment(p2,q1,q2)))))}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function splitPolygon(a,b){var a2=new Node(a.i,a.x,a.y),b2=new Node(b.i,b.x,b.y),an=a.next,bp=b.prev;return a.next=b,b.prev=a,a2.next=an,an.prev=a2,b2.next=a2,a2.prev=b2,bp.next=b2,b2.prev=bp,b2}function insertNode(i,x,y,last){var p=new Node(i,x,y);return last?(p.next=last.next,p.prev=last,last.next.prev=p,last.next=p):(p.prev=p,p.next=p),p}function removeNode(p){p.next.prev=p.prev,p.prev.next=p.next,p.prevZ&&(p.prevZ.nextZ=p.nextZ),p.nextZ&&(p.nextZ.prevZ=p.prevZ)}function Node(i,x,y){this.i=i,this.x=x,this.y=y,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(data,start,end,dim){for(var sum=0,i=start,j=end-dim;i<end;i+=dim)sum+=(data[j]-data[i])*(data[i+1]+data[j+1]),j=i;return sum}earcut.deviation=function(data,holeIndices,dim,triangles){var hasHoles=holeIndices&&holeIndices.length,outerLen=hasHoles?holeIndices[0]*dim:data.length,polygonArea=Math.abs(signedArea(data,0,outerLen,dim));if(hasHoles)for(var i=0,len=holeIndices.length;i<len;i++){var start=holeIndices[i]*dim,end=i<len-1?holeIndices[i+1]*dim:data.length;polygonArea-=Math.abs(signedArea(data,start,end,dim))}var trianglesArea=0;for(i=0;i<triangles.length;i+=3){var a=triangles[i]*dim,b=triangles[i+1]*dim,c=triangles[i+2]*dim;trianglesArea+=Math.abs((data[a]-data[c])*(data[b+1]-data[a+1])-(data[a]-data[b])*(data[c+1]-data[a+1]))}return 0===polygonArea&&0===trianglesArea?0:Math.abs((trianglesArea-polygonArea)/polygonArea)},earcut.flatten=function(data){for(var dim=data[0][0].length,result={vertices:[],holes:[],dimensions:dim},holeIndex=0,i=0;i<data.length;i++){for(var j=0;j<data[i].length;j++)for(var d=0;d<dim;d++)result.vertices.push(data[i][j][d]);i>0&&(holeIndex+=data[i-1].length,result.holes.push(holeIndex))}return result},earcut_1.default=default_1,function(ENV){ENV[ENV.WEBGL_LEGACY=0]="WEBGL_LEGACY",ENV[ENV.WEBGL=1]="WEBGL",ENV[ENV.WEBGL2=2]="WEBGL2"}(ENV||(ENV={})),function(RENDERER_TYPE){RENDERER_TYPE[RENDERER_TYPE.UNKNOWN=0]="UNKNOWN",RENDERER_TYPE[RENDERER_TYPE.WEBGL=1]="WEBGL",RENDERER_TYPE[RENDERER_TYPE.CANVAS=2]="CANVAS"}(RENDERER_TYPE||(RENDERER_TYPE={})),function(BUFFER_BITS){BUFFER_BITS[BUFFER_BITS.COLOR=16384]="COLOR",BUFFER_BITS[BUFFER_BITS.DEPTH=256]="DEPTH",BUFFER_BITS[BUFFER_BITS.STENCIL=1024]="STENCIL"}(BUFFER_BITS||(BUFFER_BITS={})),function(BLEND_MODES){BLEND_MODES[BLEND_MODES.NORMAL=0]="NORMAL",BLEND_MODES[BLEND_MODES.ADD=1]="ADD",BLEND_MODES[BLEND_MODES.MULTIPLY=2]="MULTIPLY",BLEND_MODES[BLEND_MODES.SCREEN=3]="SCREEN",BLEND_MODES[BLEND_MODES.OVERLAY=4]="OVERLAY",BLEND_MODES[BLEND_MODES.DARKEN=5]="DARKEN",BLEND_MODES[BLEND_MODES.LIGHTEN=6]="LIGHTEN",BLEND_MODES[BLEND_MODES.COLOR_DODGE=7]="COLOR_DODGE",BLEND_MODES[BLEND_MODES.COLOR_BURN=8]="COLOR_BURN",BLEND_MODES[BLEND_MODES.HARD_LIGHT=9]="HARD_LIGHT",BLEND_MODES[BLEND_MODES.SOFT_LIGHT=10]="SOFT_LIGHT",BLEND_MODES[BLEND_MODES.DIFFERENCE=11]="DIFFERENCE",BLEND_MODES[BLEND_MODES.EXCLUSION=12]="EXCLUSION",BLEND_MODES[BLEND_MODES.HUE=13]="HUE",BLEND_MODES[BLEND_MODES.SATURATION=14]="SATURATION",BLEND_MODES[BLEND_MODES.COLOR=15]="COLOR",BLEND_MODES[BLEND_MODES.LUMINOSITY=16]="LUMINOSITY",BLEND_MODES[BLEND_MODES.NORMAL_NPM=17]="NORMAL_NPM",BLEND_MODES[BLEND_MODES.ADD_NPM=18]="ADD_NPM",BLEND_MODES[BLEND_MODES.SCREEN_NPM=19]="SCREEN_NPM",BLEND_MODES[BLEND_MODES.NONE=20]="NONE",BLEND_MODES[BLEND_MODES.SRC_OVER=0]="SRC_OVER",BLEND_MODES[BLEND_MODES.SRC_IN=21]="SRC_IN",BLEND_MODES[BLEND_MODES.SRC_OUT=22]="SRC_OUT",BLEND_MODES[BLEND_MODES.SRC_ATOP=23]="SRC_ATOP",BLEND_MODES[BLEND_MODES.DST_OVER=24]="DST_OVER",BLEND_MODES[BLEND_MODES.DST_IN=25]="DST_IN",BLEND_MODES[BLEND_MODES.DST_OUT=26]="DST_OUT",BLEND_MODES[BLEND_MODES.DST_ATOP=27]="DST_ATOP",BLEND_MODES[BLEND_MODES.ERASE=26]="ERASE",BLEND_MODES[BLEND_MODES.SUBTRACT=28]="SUBTRACT",BLEND_MODES[BLEND_MODES.XOR=29]="XOR"}(BLEND_MODES||(BLEND_MODES={})),function(DRAW_MODES){DRAW_MODES[DRAW_MODES.POINTS=0]="POINTS",DRAW_MODES[DRAW_MODES.LINES=1]="LINES",DRAW_MODES[DRAW_MODES.LINE_LOOP=2]="LINE_LOOP",DRAW_MODES[DRAW_MODES.LINE_STRIP=3]="LINE_STRIP",DRAW_MODES[DRAW_MODES.TRIANGLES=4]="TRIANGLES",DRAW_MODES[DRAW_MODES.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",DRAW_MODES[DRAW_MODES.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(DRAW_MODES||(DRAW_MODES={})),function(FORMATS){FORMATS[FORMATS.RGBA=6408]="RGBA",FORMATS[FORMATS.RGB=6407]="RGB",FORMATS[FORMATS.ALPHA=6406]="ALPHA",FORMATS[FORMATS.LUMINANCE=6409]="LUMINANCE",FORMATS[FORMATS.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",FORMATS[FORMATS.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",FORMATS[FORMATS.DEPTH_STENCIL=34041]="DEPTH_STENCIL"}(FORMATS||(FORMATS={})),function(TARGETS){TARGETS[TARGETS.TEXTURE_2D=3553]="TEXTURE_2D",TARGETS[TARGETS.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",TARGETS[TARGETS.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",TARGETS[TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",TARGETS[TARGETS.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",TARGETS[TARGETS.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",TARGETS[TARGETS.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",TARGETS[TARGETS.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",TARGETS[TARGETS.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"}(TARGETS||(TARGETS={})),function(TYPES){TYPES[TYPES.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",TYPES[TYPES.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",TYPES[TYPES.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",TYPES[TYPES.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",TYPES[TYPES.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",TYPES[TYPES.FLOAT=5126]="FLOAT",TYPES[TYPES.HALF_FLOAT=36193]="HALF_FLOAT"}(TYPES||(TYPES={})),function(SCALE_MODES){SCALE_MODES[SCALE_MODES.NEAREST=0]="NEAREST",SCALE_MODES[SCALE_MODES.LINEAR=1]="LINEAR"}(SCALE_MODES||(SCALE_MODES={})),function(WRAP_MODES){WRAP_MODES[WRAP_MODES.CLAMP=33071]="CLAMP",WRAP_MODES[WRAP_MODES.REPEAT=10497]="REPEAT",WRAP_MODES[WRAP_MODES.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(WRAP_MODES||(WRAP_MODES={})),function(MIPMAP_MODES){MIPMAP_MODES[MIPMAP_MODES.OFF=0]="OFF",MIPMAP_MODES[MIPMAP_MODES.POW2=1]="POW2",MIPMAP_MODES[MIPMAP_MODES.ON=2]="ON"}(MIPMAP_MODES||(MIPMAP_MODES={})),function(ALPHA_MODES){ALPHA_MODES[ALPHA_MODES.NPM=0]="NPM",ALPHA_MODES[ALPHA_MODES.UNPACK=1]="UNPACK",ALPHA_MODES[ALPHA_MODES.PMA=2]="PMA",ALPHA_MODES[ALPHA_MODES.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",ALPHA_MODES[ALPHA_MODES.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",ALPHA_MODES[ALPHA_MODES.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA"}(ALPHA_MODES||(ALPHA_MODES={})),function(CLEAR_MODES){CLEAR_MODES[CLEAR_MODES.NO=0]="NO",CLEAR_MODES[CLEAR_MODES.YES=1]="YES",CLEAR_MODES[CLEAR_MODES.AUTO=2]="AUTO",CLEAR_MODES[CLEAR_MODES.BLEND=0]="BLEND",CLEAR_MODES[CLEAR_MODES.CLEAR=1]="CLEAR",CLEAR_MODES[CLEAR_MODES.BLIT=2]="BLIT"}(CLEAR_MODES||(CLEAR_MODES={})),function(GC_MODES){GC_MODES[GC_MODES.AUTO=0]="AUTO",GC_MODES[GC_MODES.MANUAL=1]="MANUAL"}(GC_MODES||(GC_MODES={})),function(PRECISION){PRECISION.LOW="lowp",PRECISION.MEDIUM="mediump",PRECISION.HIGH="highp"}(PRECISION||(PRECISION={})),function(MASK_TYPES){MASK_TYPES[MASK_TYPES.NONE=0]="NONE",MASK_TYPES[MASK_TYPES.SCISSOR=1]="SCISSOR",MASK_TYPES[MASK_TYPES.STENCIL=2]="STENCIL",MASK_TYPES[MASK_TYPES.SPRITE=3]="SPRITE"}(MASK_TYPES||(MASK_TYPES={})),function(MSAA_QUALITY){MSAA_QUALITY[MSAA_QUALITY.NONE=0]="NONE",MSAA_QUALITY[MSAA_QUALITY.LOW=2]="LOW",MSAA_QUALITY[MSAA_QUALITY.MEDIUM=4]="MEDIUM",MSAA_QUALITY[MSAA_QUALITY.HIGH=8]="HIGH"}(MSAA_QUALITY||(MSAA_QUALITY={})),
|
|
35
|
+
var isMobile$1=function(param){var nav={userAgent:"",platform:"",maxTouchPoints:0};param||"undefined"==typeof navigator?"string"==typeof param?nav.userAgent=param:param&¶m.userAgent&&(nav={userAgent:param.userAgent,platform:param.platform,maxTouchPoints:param.maxTouchPoints||0}):nav={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var userAgent=nav.userAgent,tmp=userAgent.split("[FBAN");void 0!==tmp[1]&&(userAgent=tmp[0]),void 0!==(tmp=userAgent.split("Twitter"))[1]&&(userAgent=tmp[0]);var match=function(userAgent){return function(regex){return regex.test(userAgent)}}(userAgent),result={apple:{phone:match(appleIphone)&&!match(windowsPhone),ipod:match(appleIpod),tablet:!match(appleIphone)&&(match(appleTablet)||isAppleTabletOnIos13(nav))&&!match(windowsPhone),universal:match(appleUniversal),device:(match(appleIphone)||match(appleIpod)||match(appleTablet)||match(appleUniversal)||isAppleTabletOnIos13(nav))&&!match(windowsPhone)},amazon:{phone:match(amazonPhone),tablet:!match(amazonPhone)&&match(amazonTablet),device:match(amazonPhone)||match(amazonTablet)},android:{phone:!match(windowsPhone)&&match(amazonPhone)||!match(windowsPhone)&&match(androidPhone),tablet:!match(windowsPhone)&&!match(amazonPhone)&&!match(androidPhone)&&(match(amazonTablet)||match(androidTablet)),device:!match(windowsPhone)&&(match(amazonPhone)||match(amazonTablet)||match(androidPhone)||match(androidTablet))||match(/\bokhttp\b/i)},windows:{phone:match(windowsPhone),tablet:match(windowsTablet),device:match(windowsPhone)||match(windowsTablet)},other:{blackberry:match(otherBlackBerry),blackberry10:match(otherBlackBerry10),opera:match(otherOpera),firefox:match(otherFirefox),chrome:match(otherChrome),device:match(otherBlackBerry)||match(otherBlackBerry10)||match(otherOpera)||match(otherFirefox)||match(otherChrome)},any:!1,phone:!1,tablet:!1};return result.any=result.apple.device||result.android.device||result.windows.device||result.other.device,result.phone=result.apple.phone||result.android.phone||result.windows.phone,result.tablet=result.apple.tablet||result.android.tablet||result.windows.tablet,result}(window.navigator);var ENV,RENDERER_TYPE,BUFFER_BITS,BLEND_MODES,DRAW_MODES,FORMATS,TARGETS,TYPES,SCALE_MODES,WRAP_MODES,MIPMAP_MODES,ALPHA_MODES,CLEAR_MODES,GC_MODES,PRECISION,MASK_TYPES,MSAA_QUALITY,settings={MIPMAP_TEXTURES:1,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,SPRITE_MAX_TEXTURES:function(max){var allowMax=!0;if(isMobile$1.tablet||isMobile$1.phone){var match;if(isMobile$1.apple.device)if(match=navigator.userAgent.match(/OS (\d+)_(\d+)?/))parseInt(match[1],10)<11&&(allowMax=!1);if(isMobile$1.android.device)if(match=navigator.userAgent.match(/Android\s([0-9.]*)/))parseInt(match[1],10)<7&&(allowMax=!1)}return allowMax?max:4}(32),SPRITE_BATCH_SIZE:4096,RENDER_OPTIONS:{view:null,antialias:!1,autoDensity:!1,transparent:!1,backgroundColor:0,clearBeforeRender:!0,preserveDrawingBuffer:!1,width:800,height:600,legacy:!1},GC_MODE:0,GC_MAX_IDLE:3600,GC_MAX_CHECK_COUNT:600,WRAP_MODE:33071,SCALE_MODE:1,PRECISION_VERTEX:"highp",PRECISION_FRAGMENT:isMobile$1.apple.device?"highp":"mediump",CAN_UPLOAD_SAME_BUFFER:!isMobile$1.apple.device,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1},eventemitter3=createCommonjsModule((function(module){var has=Object.prototype.hasOwnProperty,prefix="~";function Events(){}function EE(fn,context,once){this.fn=fn,this.context=context,this.once=once||!1}function addListener(emitter,event,fn,context,once){if("function"!=typeof fn)throw new TypeError("The listener must be a function");var listener=new EE(fn,context||emitter,once),evt=prefix?prefix+event:event;return emitter._events[evt]?emitter._events[evt].fn?emitter._events[evt]=[emitter._events[evt],listener]:emitter._events[evt].push(listener):(emitter._events[evt]=listener,emitter._eventsCount++),emitter}function clearEvent(emitter,evt){0==--emitter._eventsCount?emitter._events=new Events:delete emitter._events[evt]}function EventEmitter(){this._events=new Events,this._eventsCount=0}Object.create&&(Events.prototype=Object.create(null),(new Events).__proto__||(prefix=!1)),EventEmitter.prototype.eventNames=function(){var events,name,names=[];if(0===this._eventsCount)return names;for(name in events=this._events)has.call(events,name)&&names.push(prefix?name.slice(1):name);return Object.getOwnPropertySymbols?names.concat(Object.getOwnPropertySymbols(events)):names},EventEmitter.prototype.listeners=function(event){var evt=prefix?prefix+event:event,handlers=this._events[evt];if(!handlers)return[];if(handlers.fn)return[handlers.fn];for(var i=0,l=handlers.length,ee=new Array(l);i<l;i++)ee[i]=handlers[i].fn;return ee},EventEmitter.prototype.listenerCount=function(event){var evt=prefix?prefix+event:event,listeners=this._events[evt];return listeners?listeners.fn?1:listeners.length:0},EventEmitter.prototype.emit=function(event,a1,a2,a3,a4,a5){var evt=prefix?prefix+event:event;if(!this._events[evt])return!1;var args,i,listeners=this._events[evt],len=arguments.length;if(listeners.fn){switch(listeners.once&&this.removeListener(event,listeners.fn,void 0,!0),len){case 1:return listeners.fn.call(listeners.context),!0;case 2:return listeners.fn.call(listeners.context,a1),!0;case 3:return listeners.fn.call(listeners.context,a1,a2),!0;case 4:return listeners.fn.call(listeners.context,a1,a2,a3),!0;case 5:return listeners.fn.call(listeners.context,a1,a2,a3,a4),!0;case 6:return listeners.fn.call(listeners.context,a1,a2,a3,a4,a5),!0}for(i=1,args=new Array(len-1);i<len;i++)args[i-1]=arguments[i];listeners.fn.apply(listeners.context,args)}else{var j,length=listeners.length;for(i=0;i<length;i++)switch(listeners[i].once&&this.removeListener(event,listeners[i].fn,void 0,!0),len){case 1:listeners[i].fn.call(listeners[i].context);break;case 2:listeners[i].fn.call(listeners[i].context,a1);break;case 3:listeners[i].fn.call(listeners[i].context,a1,a2);break;case 4:listeners[i].fn.call(listeners[i].context,a1,a2,a3);break;default:if(!args)for(j=1,args=new Array(len-1);j<len;j++)args[j-1]=arguments[j];listeners[i].fn.apply(listeners[i].context,args)}}return!0},EventEmitter.prototype.on=function(event,fn,context){return addListener(this,event,fn,context,!1)},EventEmitter.prototype.once=function(event,fn,context){return addListener(this,event,fn,context,!0)},EventEmitter.prototype.removeListener=function(event,fn,context,once){var evt=prefix?prefix+event:event;if(!this._events[evt])return this;if(!fn)return clearEvent(this,evt),this;var listeners=this._events[evt];if(listeners.fn)listeners.fn!==fn||once&&!listeners.once||context&&listeners.context!==context||clearEvent(this,evt);else{for(var i=0,events=[],length=listeners.length;i<length;i++)(listeners[i].fn!==fn||once&&!listeners[i].once||context&&listeners[i].context!==context)&&events.push(listeners[i]);events.length?this._events[evt]=1===events.length?events[0]:events:clearEvent(this,evt)}return this},EventEmitter.prototype.removeAllListeners=function(event){var evt;return event?(evt=prefix?prefix+event:event,this._events[evt]&&clearEvent(this,evt)):(this._events=new Events,this._eventsCount=0),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prefixed=prefix,EventEmitter.EventEmitter=EventEmitter,module.exports=EventEmitter})),earcut_1=earcut,default_1=earcut;function earcut(data,holeIndices,dim){dim=dim||2;var minX,minY,maxX,maxY,x,y,invSize,hasHoles=holeIndices&&holeIndices.length,outerLen=hasHoles?holeIndices[0]*dim:data.length,outerNode=linkedList(data,0,outerLen,dim,!0),triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles&&(outerNode=function(data,holeIndices,outerNode,dim){var i,len,list,queue=[];for(i=0,len=holeIndices.length;i<len;i++)(list=linkedList(data,holeIndices[i]*dim,i<len-1?holeIndices[i+1]*dim:data.length,dim,!1))===list.next&&(list.steiner=!0),queue.push(getLeftmost(list));for(queue.sort(compareX),i=0;i<queue.length;i++)eliminateHole(queue[i],outerNode),outerNode=filterPoints(outerNode,outerNode.next);return outerNode}(data,holeIndices,outerNode,dim)),data.length>80*dim){minX=maxX=data[0],minY=maxY=data[1];for(var i=dim;i<outerLen;i+=dim)(x=data[i])<minX&&(minX=x),(y=data[i+1])<minY&&(minY=y),x>maxX&&(maxX=x),y>maxY&&(maxY=y);invSize=0!==(invSize=Math.max(maxX-minX,maxY-minY))?1/invSize:0}return earcutLinked(outerNode,triangles,dim,minX,minY,invSize),triangles}function linkedList(data,start,end,dim,clockwise){var i,last;if(clockwise===signedArea(data,start,end,dim)>0)for(i=start;i<end;i+=dim)last=insertNode(i,data[i],data[i+1],last);else for(i=end-dim;i>=start;i-=dim)last=insertNode(i,data[i],data[i+1],last);return last&&equals(last,last.next)&&(removeNode(last),last=last.next),last}function filterPoints(start,end){if(!start)return start;end||(end=start);var again,p=start;do{if(again=!1,p.steiner||!equals(p,p.next)&&0!==area(p.prev,p,p.next))p=p.next;else{if(removeNode(p),(p=end=p.prev)===p.next)break;again=!0}}while(again||p!==end);return end}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(ear){!pass&&invSize&&function(start,minX,minY,invSize){var p=start;do{null===p.z&&(p.z=zOrder(p.x,p.y,minX,minY,invSize)),p.prevZ=p.prev,p.nextZ=p.next,p=p.next}while(p!==start);p.prevZ.nextZ=null,p.prevZ=null,function(list){var i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{for(p=list,list=null,tail=null,numMerges=0;p;){for(numMerges++,q=p,pSize=0,i=0;i<inSize&&(pSize++,q=q.nextZ);i++);for(qSize=inSize;pSize>0||qSize>0&&q;)0!==pSize&&(0===qSize||!q||p.z<=q.z)?(e=p,p=p.nextZ,pSize--):(e=q,q=q.nextZ,qSize--),tail?tail.nextZ=e:list=e,e.prevZ=tail,tail=e;p=q}tail.nextZ=null,inSize*=2}while(numMerges>1)}(p)}(ear,minX,minY,invSize);for(var prev,next,stop=ear;ear.prev!==ear.next;)if(prev=ear.prev,next=ear.next,invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear))triangles.push(prev.i/dim),triangles.push(ear.i/dim),triangles.push(next.i/dim),removeNode(ear),ear=next.next,stop=next.next;else if((ear=next)===stop){pass?1===pass?earcutLinked(ear=cureLocalIntersections(filterPoints(ear),triangles,dim),triangles,dim,minX,minY,invSize,2):2===pass&&splitEarcut(ear,triangles,dim,minX,minY,invSize):earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1);break}}}function isEar(ear){var a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return!1;for(var p=ear.next.next;p!==ear.prev;){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function isEarHashed(ear,minX,minY,invSize){var a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return!1;for(var minTX=a.x<b.x?a.x<c.x?a.x:c.x:b.x<c.x?b.x:c.x,minTY=a.y<b.y?a.y<c.y?a.y:c.y:b.y<c.y?b.y:c.y,maxTX=a.x>b.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x,maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y,minZ=zOrder(minTX,minTY,minX,minY,invSize),maxZ=zOrder(maxTX,maxTY,minX,minY,invSize),p=ear.prevZ,n=ear.nextZ;p&&p.z>=minZ&&n&&n.z<=maxZ;){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return!1;n=n.nextZ}for(;p&&p.z>=minZ;){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;n&&n.z<=maxZ;){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return!1;n=n.nextZ}return!0}function cureLocalIntersections(start,triangles,dim){var p=start;do{var a=p.prev,b=p.next.next;!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)&&(triangles.push(a.i/dim),triangles.push(p.i/dim),triangles.push(b.i/dim),removeNode(p),removeNode(p.next),p=start=b),p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){var a=start;do{for(var b=a.next.next;b!==a.prev;){if(a.i!==b.i&&isValidDiagonal(a,b)){var c=splitPolygon(a,b);return a=filterPoints(a,a.next),c=filterPoints(c,c.next),earcutLinked(a,triangles,dim,minX,minY,invSize),void earcutLinked(c,triangles,dim,minX,minY,invSize)}b=b.next}a=a.next}while(a!==start)}function compareX(a,b){return a.x-b.x}function eliminateHole(hole,outerNode){if(outerNode=function(hole,outerNode){var m,p=outerNode,hx=hole.x,hy=hole.y,qx=-1/0;do{if(hy<=p.y&&hy>=p.next.y&&p.next.y!==p.y){var x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){if(qx=x,x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x<p.next.x?p:p.next}}p=p.next}while(p!==outerNode);if(!m)return null;if(hx===qx)return m;var tan,stop=m,mx=m.x,my=m.y,tanMin=1/0;p=m;do{hx>=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hy<my?hx:qx,hy,mx,my,hy<my?qx:hx,hy,p.x,p.y)&&(tan=Math.abs(hy-p.y)/(hx-p.x),locallyInside(p,hole)&&(tan<tanMin||tan===tanMin&&(p.x>m.x||p.x===m.x&§orContainsSector(m,p)))&&(m=p,tanMin=tan)),p=p.next}while(p!==stop);return m}(hole,outerNode)){var b=splitPolygon(outerNode,hole);filterPoints(outerNode,outerNode.next),filterPoints(b,b.next)}}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function zOrder(x,y,minX,minY,invSize){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=32767*(x-minX)*invSize)|x<<8))|x<<4))|x<<2))|x<<1))|(y=1431655765&((y=858993459&((y=252645135&((y=16711935&((y=32767*(y-minY)*invSize)|y<<8))|y<<4))|y<<2))|y<<1))<<1}function getLeftmost(start){var p=start,leftmost=start;do{(p.x<leftmost.x||p.x===leftmost.x&&p.y<leftmost.y)&&(leftmost=p),p=p.next}while(p!==start);return leftmost}function pointInTriangle(ax,ay,bx,by,cx,cy,px,py){return(cx-px)*(ay-py)-(ax-px)*(cy-py)>=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(a,b){var p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return!0;p=p.next}while(p!==a);return!1}(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&function(a,b){var p=a,inside=!1,px=(a.x+b.x)/2,py=(a.y+b.y)/2;do{p.y>py!=p.next.y>py&&p.next.y!==p.y&&px<(p.next.x-p.x)*(py-p.y)/(p.next.y-p.y)+p.x&&(inside=!inside),p=p.next}while(p!==a);return inside}(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){var o1=sign$1(area(p1,q1,p2)),o2=sign$1(area(p1,q1,q2)),o3=sign$1(area(p2,q2,p1)),o4=sign$1(area(p2,q2,q1));return o1!==o2&&o3!==o4||(!(0!==o1||!onSegment(p1,p2,q1))||(!(0!==o2||!onSegment(p1,q2,q1))||(!(0!==o3||!onSegment(p2,p1,q2))||!(0!==o4||!onSegment(p2,q1,q2)))))}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign$1(num){return num>0?1:num<0?-1:0}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function splitPolygon(a,b){var a2=new Node(a.i,a.x,a.y),b2=new Node(b.i,b.x,b.y),an=a.next,bp=b.prev;return a.next=b,b.prev=a,a2.next=an,an.prev=a2,b2.next=a2,a2.prev=b2,bp.next=b2,b2.prev=bp,b2}function insertNode(i,x,y,last){var p=new Node(i,x,y);return last?(p.next=last.next,p.prev=last,last.next.prev=p,last.next=p):(p.prev=p,p.next=p),p}function removeNode(p){p.next.prev=p.prev,p.prev.next=p.next,p.prevZ&&(p.prevZ.nextZ=p.nextZ),p.nextZ&&(p.nextZ.prevZ=p.prevZ)}function Node(i,x,y){this.i=i,this.x=x,this.y=y,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(data,start,end,dim){for(var sum=0,i=start,j=end-dim;i<end;i+=dim)sum+=(data[j]-data[i])*(data[i+1]+data[j+1]),j=i;return sum}earcut.deviation=function(data,holeIndices,dim,triangles){var hasHoles=holeIndices&&holeIndices.length,outerLen=hasHoles?holeIndices[0]*dim:data.length,polygonArea=Math.abs(signedArea(data,0,outerLen,dim));if(hasHoles)for(var i=0,len=holeIndices.length;i<len;i++){var start=holeIndices[i]*dim,end=i<len-1?holeIndices[i+1]*dim:data.length;polygonArea-=Math.abs(signedArea(data,start,end,dim))}var trianglesArea=0;for(i=0;i<triangles.length;i+=3){var a=triangles[i]*dim,b=triangles[i+1]*dim,c=triangles[i+2]*dim;trianglesArea+=Math.abs((data[a]-data[c])*(data[b+1]-data[a+1])-(data[a]-data[b])*(data[c+1]-data[a+1]))}return 0===polygonArea&&0===trianglesArea?0:Math.abs((trianglesArea-polygonArea)/polygonArea)},earcut.flatten=function(data){for(var dim=data[0][0].length,result={vertices:[],holes:[],dimensions:dim},holeIndex=0,i=0;i<data.length;i++){for(var j=0;j<data[i].length;j++)for(var d=0;d<dim;d++)result.vertices.push(data[i][j][d]);i>0&&(holeIndex+=data[i-1].length,result.holes.push(holeIndex))}return result},earcut_1.default=default_1,function(ENV){ENV[ENV.WEBGL_LEGACY=0]="WEBGL_LEGACY",ENV[ENV.WEBGL=1]="WEBGL",ENV[ENV.WEBGL2=2]="WEBGL2"}(ENV||(ENV={})),function(RENDERER_TYPE){RENDERER_TYPE[RENDERER_TYPE.UNKNOWN=0]="UNKNOWN",RENDERER_TYPE[RENDERER_TYPE.WEBGL=1]="WEBGL",RENDERER_TYPE[RENDERER_TYPE.CANVAS=2]="CANVAS"}(RENDERER_TYPE||(RENDERER_TYPE={})),function(BUFFER_BITS){BUFFER_BITS[BUFFER_BITS.COLOR=16384]="COLOR",BUFFER_BITS[BUFFER_BITS.DEPTH=256]="DEPTH",BUFFER_BITS[BUFFER_BITS.STENCIL=1024]="STENCIL"}(BUFFER_BITS||(BUFFER_BITS={})),function(BLEND_MODES){BLEND_MODES[BLEND_MODES.NORMAL=0]="NORMAL",BLEND_MODES[BLEND_MODES.ADD=1]="ADD",BLEND_MODES[BLEND_MODES.MULTIPLY=2]="MULTIPLY",BLEND_MODES[BLEND_MODES.SCREEN=3]="SCREEN",BLEND_MODES[BLEND_MODES.OVERLAY=4]="OVERLAY",BLEND_MODES[BLEND_MODES.DARKEN=5]="DARKEN",BLEND_MODES[BLEND_MODES.LIGHTEN=6]="LIGHTEN",BLEND_MODES[BLEND_MODES.COLOR_DODGE=7]="COLOR_DODGE",BLEND_MODES[BLEND_MODES.COLOR_BURN=8]="COLOR_BURN",BLEND_MODES[BLEND_MODES.HARD_LIGHT=9]="HARD_LIGHT",BLEND_MODES[BLEND_MODES.SOFT_LIGHT=10]="SOFT_LIGHT",BLEND_MODES[BLEND_MODES.DIFFERENCE=11]="DIFFERENCE",BLEND_MODES[BLEND_MODES.EXCLUSION=12]="EXCLUSION",BLEND_MODES[BLEND_MODES.HUE=13]="HUE",BLEND_MODES[BLEND_MODES.SATURATION=14]="SATURATION",BLEND_MODES[BLEND_MODES.COLOR=15]="COLOR",BLEND_MODES[BLEND_MODES.LUMINOSITY=16]="LUMINOSITY",BLEND_MODES[BLEND_MODES.NORMAL_NPM=17]="NORMAL_NPM",BLEND_MODES[BLEND_MODES.ADD_NPM=18]="ADD_NPM",BLEND_MODES[BLEND_MODES.SCREEN_NPM=19]="SCREEN_NPM",BLEND_MODES[BLEND_MODES.NONE=20]="NONE",BLEND_MODES[BLEND_MODES.SRC_OVER=0]="SRC_OVER",BLEND_MODES[BLEND_MODES.SRC_IN=21]="SRC_IN",BLEND_MODES[BLEND_MODES.SRC_OUT=22]="SRC_OUT",BLEND_MODES[BLEND_MODES.SRC_ATOP=23]="SRC_ATOP",BLEND_MODES[BLEND_MODES.DST_OVER=24]="DST_OVER",BLEND_MODES[BLEND_MODES.DST_IN=25]="DST_IN",BLEND_MODES[BLEND_MODES.DST_OUT=26]="DST_OUT",BLEND_MODES[BLEND_MODES.DST_ATOP=27]="DST_ATOP",BLEND_MODES[BLEND_MODES.ERASE=26]="ERASE",BLEND_MODES[BLEND_MODES.SUBTRACT=28]="SUBTRACT",BLEND_MODES[BLEND_MODES.XOR=29]="XOR"}(BLEND_MODES||(BLEND_MODES={})),function(DRAW_MODES){DRAW_MODES[DRAW_MODES.POINTS=0]="POINTS",DRAW_MODES[DRAW_MODES.LINES=1]="LINES",DRAW_MODES[DRAW_MODES.LINE_LOOP=2]="LINE_LOOP",DRAW_MODES[DRAW_MODES.LINE_STRIP=3]="LINE_STRIP",DRAW_MODES[DRAW_MODES.TRIANGLES=4]="TRIANGLES",DRAW_MODES[DRAW_MODES.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",DRAW_MODES[DRAW_MODES.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(DRAW_MODES||(DRAW_MODES={})),function(FORMATS){FORMATS[FORMATS.RGBA=6408]="RGBA",FORMATS[FORMATS.RGB=6407]="RGB",FORMATS[FORMATS.ALPHA=6406]="ALPHA",FORMATS[FORMATS.LUMINANCE=6409]="LUMINANCE",FORMATS[FORMATS.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",FORMATS[FORMATS.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",FORMATS[FORMATS.DEPTH_STENCIL=34041]="DEPTH_STENCIL"}(FORMATS||(FORMATS={})),function(TARGETS){TARGETS[TARGETS.TEXTURE_2D=3553]="TEXTURE_2D",TARGETS[TARGETS.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",TARGETS[TARGETS.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",TARGETS[TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",TARGETS[TARGETS.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",TARGETS[TARGETS.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",TARGETS[TARGETS.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",TARGETS[TARGETS.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",TARGETS[TARGETS.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"}(TARGETS||(TARGETS={})),function(TYPES){TYPES[TYPES.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",TYPES[TYPES.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",TYPES[TYPES.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",TYPES[TYPES.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",TYPES[TYPES.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",TYPES[TYPES.FLOAT=5126]="FLOAT",TYPES[TYPES.HALF_FLOAT=36193]="HALF_FLOAT"}(TYPES||(TYPES={})),function(SCALE_MODES){SCALE_MODES[SCALE_MODES.NEAREST=0]="NEAREST",SCALE_MODES[SCALE_MODES.LINEAR=1]="LINEAR"}(SCALE_MODES||(SCALE_MODES={})),function(WRAP_MODES){WRAP_MODES[WRAP_MODES.CLAMP=33071]="CLAMP",WRAP_MODES[WRAP_MODES.REPEAT=10497]="REPEAT",WRAP_MODES[WRAP_MODES.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(WRAP_MODES||(WRAP_MODES={})),function(MIPMAP_MODES){MIPMAP_MODES[MIPMAP_MODES.OFF=0]="OFF",MIPMAP_MODES[MIPMAP_MODES.POW2=1]="POW2",MIPMAP_MODES[MIPMAP_MODES.ON=2]="ON"}(MIPMAP_MODES||(MIPMAP_MODES={})),function(ALPHA_MODES){ALPHA_MODES[ALPHA_MODES.NPM=0]="NPM",ALPHA_MODES[ALPHA_MODES.UNPACK=1]="UNPACK",ALPHA_MODES[ALPHA_MODES.PMA=2]="PMA",ALPHA_MODES[ALPHA_MODES.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",ALPHA_MODES[ALPHA_MODES.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",ALPHA_MODES[ALPHA_MODES.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA"}(ALPHA_MODES||(ALPHA_MODES={})),function(CLEAR_MODES){CLEAR_MODES[CLEAR_MODES.NO=0]="NO",CLEAR_MODES[CLEAR_MODES.YES=1]="YES",CLEAR_MODES[CLEAR_MODES.AUTO=2]="AUTO",CLEAR_MODES[CLEAR_MODES.BLEND=0]="BLEND",CLEAR_MODES[CLEAR_MODES.CLEAR=1]="CLEAR",CLEAR_MODES[CLEAR_MODES.BLIT=2]="BLIT"}(CLEAR_MODES||(CLEAR_MODES={})),function(GC_MODES){GC_MODES[GC_MODES.AUTO=0]="AUTO",GC_MODES[GC_MODES.MANUAL=1]="MANUAL"}(GC_MODES||(GC_MODES={})),function(PRECISION){PRECISION.LOW="lowp",PRECISION.MEDIUM="mediump",PRECISION.HIGH="highp"}(PRECISION||(PRECISION={})),function(MASK_TYPES){MASK_TYPES[MASK_TYPES.NONE=0]="NONE",MASK_TYPES[MASK_TYPES.SCISSOR=1]="SCISSOR",MASK_TYPES[MASK_TYPES.STENCIL=2]="STENCIL",MASK_TYPES[MASK_TYPES.SPRITE=3]="SPRITE"}(MASK_TYPES||(MASK_TYPES={})),function(MSAA_QUALITY){MSAA_QUALITY[MSAA_QUALITY.NONE=0]="NONE",MSAA_QUALITY[MSAA_QUALITY.LOW=2]="LOW",MSAA_QUALITY[MSAA_QUALITY.MEDIUM=4]="MEDIUM",MSAA_QUALITY[MSAA_QUALITY.HIGH=8]="HIGH"}(MSAA_QUALITY||(MSAA_QUALITY={})),
|
|
36
36
|
/*!
|
|
37
37
|
* @pixi/utils - v5.3.8
|
|
38
38
|
* Compiled Sat, 20 Feb 2021 22:28:33 UTC
|
|
@@ -40,7 +40,7 @@ var isMobile$1=function(param){var nav={userAgent:"",platform:"",maxTouchPoints:
|
|
|
40
40
|
* @pixi/utils is licensed under the MIT License.
|
|
41
41
|
* http://www.opensource.org/licenses/mit-license
|
|
42
42
|
*/
|
|
43
|
-
settings.RETINA_PREFIX=/@([0-9\.]+)x/,settings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!0;var supported,saidHello=!1;function hex2rgb(hex,out){return void 0===out&&(out=[]),out[0]=(hex>>16&255)/255,out[1]=(hex>>8&255)/255,out[2]=(255&hex)/255,out}function hex2string(hex){var hexString=hex.toString(16);return"#"+(hexString="000000".substr(0,6-hexString.length)+hexString)}function string2hex(string){return"string"==typeof string&&"#"===string[0]&&(string=string.substr(1)),parseInt(string,16)}var premultiplyBlendMode=function(){for(var pm=[],npm=[],i=0;i<32;i++)pm[i]=i,npm[i]=i;pm[BLEND_MODES.NORMAL_NPM]=BLEND_MODES.NORMAL,pm[BLEND_MODES.ADD_NPM]=BLEND_MODES.ADD,pm[BLEND_MODES.SCREEN_NPM]=BLEND_MODES.SCREEN,npm[BLEND_MODES.NORMAL]=BLEND_MODES.NORMAL_NPM,npm[BLEND_MODES.ADD]=BLEND_MODES.ADD_NPM,npm[BLEND_MODES.SCREEN]=BLEND_MODES.SCREEN_NPM;var array=[];return array.push(npm),array.push(pm),array}();function correctBlendMode(blendMode,premultiplied){return premultiplyBlendMode[premultiplied?1:0][blendMode]}function premultiplyTint(tint,alpha){if(1===alpha)return(255*alpha<<24)+tint;if(0===alpha)return 0;var R=tint>>16&255,G=tint>>8&255,B=255∭return(255*alpha<<24)+((R=R*alpha+.5|0)<<16)+((G=G*alpha+.5|0)<<8)+(B=B*alpha+.5|0)}function premultiplyTintToRgba(tint,alpha,out,premultiply){return(out=out||new Float32Array(4))[0]=(tint>>16&255)/255,out[1]=(tint>>8&255)/255,out[2]=(255&tint)/255,(premultiply||void 0===premultiply)&&(out[0]*=alpha,out[1]*=alpha,out[2]*=alpha),out[3]=alpha,out}function nextPow2(v){return v+=0===v?1:0,--v,v|=v>>>1,v|=v>>>2,v|=v>>>4,v|=v>>>8,(v|=v>>>16)+1}function isPow2(v){return!(v&v-1||!v)}function log2(v){var r=(v>65535?1:0)<<4,shift=((v>>>=r)>255?1:0)<<3;return r|=shift,r|=shift=((v>>>=shift)>15?1:0)<<2,(r|=shift=((v>>>=shift)>3?1:0)<<1)|(v>>>=shift)>>1}function removeItems(arr,startIdx,removeCount){var i,length=arr.length;if(!(startIdx>=length||0===removeCount)){var len=length-(removeCount=startIdx+removeCount>length?length-startIdx:removeCount);for(i=startIdx;i<len;++i)arr[i]=arr[i+removeCount];arr.length=len}}function sign$
|
|
43
|
+
settings.RETINA_PREFIX=/@([0-9\.]+)x/,settings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!0;var supported,saidHello=!1;function hex2rgb(hex,out){return void 0===out&&(out=[]),out[0]=(hex>>16&255)/255,out[1]=(hex>>8&255)/255,out[2]=(255&hex)/255,out}function hex2string(hex){var hexString=hex.toString(16);return"#"+(hexString="000000".substr(0,6-hexString.length)+hexString)}function string2hex(string){return"string"==typeof string&&"#"===string[0]&&(string=string.substr(1)),parseInt(string,16)}var premultiplyBlendMode=function(){for(var pm=[],npm=[],i=0;i<32;i++)pm[i]=i,npm[i]=i;pm[BLEND_MODES.NORMAL_NPM]=BLEND_MODES.NORMAL,pm[BLEND_MODES.ADD_NPM]=BLEND_MODES.ADD,pm[BLEND_MODES.SCREEN_NPM]=BLEND_MODES.SCREEN,npm[BLEND_MODES.NORMAL]=BLEND_MODES.NORMAL_NPM,npm[BLEND_MODES.ADD]=BLEND_MODES.ADD_NPM,npm[BLEND_MODES.SCREEN]=BLEND_MODES.SCREEN_NPM;var array=[];return array.push(npm),array.push(pm),array}();function correctBlendMode(blendMode,premultiplied){return premultiplyBlendMode[premultiplied?1:0][blendMode]}function premultiplyTint(tint,alpha){if(1===alpha)return(255*alpha<<24)+tint;if(0===alpha)return 0;var R=tint>>16&255,G=tint>>8&255,B=255∭return(255*alpha<<24)+((R=R*alpha+.5|0)<<16)+((G=G*alpha+.5|0)<<8)+(B=B*alpha+.5|0)}function premultiplyTintToRgba(tint,alpha,out,premultiply){return(out=out||new Float32Array(4))[0]=(tint>>16&255)/255,out[1]=(tint>>8&255)/255,out[2]=(255&tint)/255,(premultiply||void 0===premultiply)&&(out[0]*=alpha,out[1]*=alpha,out[2]*=alpha),out[3]=alpha,out}function nextPow2(v){return v+=0===v?1:0,--v,v|=v>>>1,v|=v>>>2,v|=v>>>4,v|=v>>>8,(v|=v>>>16)+1}function isPow2(v){return!(v&v-1||!v)}function log2(v){var r=(v>65535?1:0)<<4,shift=((v>>>=r)>255?1:0)<<3;return r|=shift,r|=shift=((v>>>=shift)>15?1:0)<<2,(r|=shift=((v>>>=shift)>3?1:0)<<1)|(v>>>=shift)>>1}function removeItems(arr,startIdx,removeCount){var i,length=arr.length;if(!(startIdx>=length||0===removeCount)){var len=length-(removeCount=startIdx+removeCount>length?length-startIdx:removeCount);for(i=startIdx;i<len;++i)arr[i]=arr[i+removeCount];arr.length=len}}function sign$2(n){return 0===n?0:n<0?-1:1}var nextUid=0;function uid(){return++nextUid}var warnings={};function deprecation(version,message,ignoreDepth){if(void 0===ignoreDepth&&(ignoreDepth=3),!warnings[message]){var stack=(new Error).stack;void 0===stack?console.warn("PixiJS Deprecation Warning: ",message+"\nDeprecated since v"+version):(stack=stack.split("\n").splice(ignoreDepth).join("\n"),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",message+"\nDeprecated since v"+version),console.warn(stack),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",message+"\nDeprecated since v"+version),console.warn(stack))),warnings[message]=!0}}var tempAnchor,ProgramCache={},TextureCache=Object.create(null),BaseTextureCache=Object.create(null),CanvasRenderTarget=function(){function CanvasRenderTarget(width,height,resolution){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.resolution=resolution||settings.RESOLUTION,this.resize(width,height)}return CanvasRenderTarget.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},CanvasRenderTarget.prototype.resize=function(width,height){this.canvas.width=width*this.resolution,this.canvas.height=height*this.resolution},CanvasRenderTarget.prototype.destroy=function(){this.context=null,this.canvas=null},Object.defineProperty(CanvasRenderTarget.prototype,"width",{get:function(){return this.canvas.width},set:function(val){this.canvas.width=val},enumerable:!1,configurable:!0}),Object.defineProperty(CanvasRenderTarget.prototype,"height",{get:function(){return this.canvas.height},set:function(val){this.canvas.height=val},enumerable:!1,configurable:!0}),CanvasRenderTarget}();function determineCrossOrigin(url$1,loc){if(void 0===loc&&(loc=window.location),0===url$1.indexOf("data:"))return"";loc=loc||window.location,tempAnchor||(tempAnchor=document.createElement("a")),tempAnchor.href=url$1;var parsedUrl=url.parse(tempAnchor.href),samePort=!parsedUrl.port&&""===loc.port||parsedUrl.port===loc.port;return parsedUrl.hostname===loc.hostname&&samePort&&parsedUrl.protocol===loc.protocol?"":"anonymous"}function getResolutionOfUrl(url,defaultValue){var resolution=settings.RETINA_PREFIX.exec(url);return resolution?parseFloat(resolution[1]):void 0!==defaultValue?defaultValue:1}
|
|
44
44
|
/*!
|
|
45
45
|
* @pixi/math - v5.3.8
|
|
46
46
|
* Compiled Sat, 20 Feb 2021 22:28:33 UTC
|
|
@@ -159,7 +159,7 @@ var LoaderResource=Resource$1,extendStatics$4=function(d,b){return(extendStatics
|
|
|
159
159
|
|
|
160
160
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
161
161
|
and limitations under the License.
|
|
162
|
-
***************************************************************************** */function __extends$5(d,b){function __(){this.constructor=d}extendStatics$5(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}!function(_super){function ParticleContainer(maxSize,properties,batchSize,autoResize){void 0===maxSize&&(maxSize=1500),void 0===batchSize&&(batchSize=16384),void 0===autoResize&&(autoResize=!1);var _this=_super.call(this)||this;return batchSize>16384&&(batchSize=16384),_this._properties=[!1,!0,!1,!1,!1],_this._maxSize=maxSize,_this._batchSize=batchSize,_this._buffers=null,_this._bufferUpdateIDs=[],_this._updateID=0,_this.interactiveChildren=!1,_this.blendMode=BLEND_MODES.NORMAL,_this.autoResize=autoResize,_this.roundPixels=!0,_this.baseTexture=null,_this.setProperties(properties),_this._tint=0,_this.tintRgb=new Float32Array(4),_this.tint=16777215,_this}__extends$5(ParticleContainer,_super),ParticleContainer.prototype.setProperties=function(properties){properties&&(this._properties[0]="vertices"in properties||"scale"in properties?!!properties.vertices||!!properties.scale:this._properties[0],this._properties[1]="position"in properties?!!properties.position:this._properties[1],this._properties[2]="rotation"in properties?!!properties.rotation:this._properties[2],this._properties[3]="uvs"in properties?!!properties.uvs:this._properties[3],this._properties[4]="tint"in properties||"alpha"in properties?!!properties.tint||!!properties.alpha:this._properties[4])},ParticleContainer.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},Object.defineProperty(ParticleContainer.prototype,"tint",{get:function(){return this._tint},set:function(value){this._tint=value,hex2rgb(value,this.tintRgb)},enumerable:!1,configurable:!0}),ParticleContainer.prototype.render=function(renderer){var _this=this;this.visible&&!(this.worldAlpha<=0)&&this.children.length&&this.renderable&&(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",(function(){return _this.onChildrenChange(0)}))),renderer.batch.setObjectRenderer(renderer.plugins.particle),renderer.plugins.particle.render(this))},ParticleContainer.prototype.onChildrenChange=function(smallestChildIndex){for(var bufferIndex=Math.floor(smallestChildIndex/this._batchSize);this._bufferUpdateIDs.length<bufferIndex;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[bufferIndex]=++this._updateID},ParticleContainer.prototype.dispose=function(){if(this._buffers){for(var i=0;i<this._buffers.length;++i)this._buffers[i].destroy();this._buffers=null}},ParticleContainer.prototype.destroy=function(options){_super.prototype.destroy.call(this,options),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null}}(Container);var LINE_JOIN,LINE_CAP,ParticleBuffer=function(){function ParticleBuffer(properties,dynamicPropertyFlags,size){this.geometry=new Geometry,this.indexBuffer=null,this.size=size,this.dynamicProperties=[],this.staticProperties=[];for(var i=0;i<properties.length;++i){var property=properties[i];property={attributeName:property.attributeName,size:property.size,uploadFunction:property.uploadFunction,type:property.type||TYPES.FLOAT,offset:property.offset},dynamicPropertyFlags[i]?this.dynamicProperties.push(property):this.staticProperties.push(property)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}return ParticleBuffer.prototype.initBuffers=function(){var geometry=this.geometry,dynamicOffset=0;this.indexBuffer=new Buffer(function(size,outBuffer){void 0===outBuffer&&(outBuffer=null);var totalIndices=6*size;if((outBuffer=outBuffer||new Uint16Array(totalIndices)).length!==totalIndices)throw new Error("Out buffer length is incorrect, got "+outBuffer.length+" and expected "+totalIndices);for(var i=0,j=0;i<totalIndices;i+=6,j+=4)outBuffer[i+0]=j+0,outBuffer[i+1]=j+1,outBuffer[i+2]=j+2,outBuffer[i+3]=j+0,outBuffer[i+4]=j+2,outBuffer[i+5]=j+3;return outBuffer}(this.size),!0,!0),geometry.addIndex(this.indexBuffer),this.dynamicStride=0;for(var i=0;i<this.dynamicProperties.length;++i){(property=this.dynamicProperties[i]).offset=dynamicOffset,dynamicOffset+=property.size,this.dynamicStride+=property.size}var dynBuffer=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(dynBuffer),this.dynamicDataUint32=new Uint32Array(dynBuffer),this.dynamicBuffer=new Buffer(this.dynamicData,!1,!1);var staticOffset=0;this.staticStride=0;for(i=0;i<this.staticProperties.length;++i){(property=this.staticProperties[i]).offset=staticOffset,staticOffset+=property.size,this.staticStride+=property.size}var statBuffer=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(statBuffer),this.staticDataUint32=new Uint32Array(statBuffer),this.staticBuffer=new Buffer(this.staticData,!0,!1);for(i=0;i<this.dynamicProperties.length;++i){var property=this.dynamicProperties[i];geometry.addAttribute(property.attributeName,this.dynamicBuffer,0,property.type===TYPES.UNSIGNED_BYTE,property.type,4*this.dynamicStride,4*property.offset)}for(i=0;i<this.staticProperties.length;++i){property=this.staticProperties[i];geometry.addAttribute(property.attributeName,this.staticBuffer,0,property.type===TYPES.UNSIGNED_BYTE,property.type,4*this.staticStride,4*property.offset)}},ParticleBuffer.prototype.uploadDynamic=function(children,startIndex,amount){for(var i=0;i<this.dynamicProperties.length;i++){var property=this.dynamicProperties[i];property.uploadFunction(children,startIndex,amount,property.type===TYPES.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,property.offset)}this.dynamicBuffer._updateID++},ParticleBuffer.prototype.uploadStatic=function(children,startIndex,amount){for(var i=0;i<this.staticProperties.length;i++){var property=this.staticProperties[i];property.uploadFunction(children,startIndex,amount,property.type===TYPES.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,property.offset)}this.staticBuffer._updateID++},ParticleBuffer.prototype.destroy=function(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()},ParticleBuffer}(),ParticleRenderer=function(_super){function ParticleRenderer(renderer){var _this=_super.call(this,renderer)||this;return _this.shader=null,_this.properties=null,_this.tempMatrix=new Matrix,_this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:_this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:_this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:_this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:_this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:TYPES.UNSIGNED_BYTE,uploadFunction:_this.uploadTint,offset:0}],_this.shader=Shader.from("attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nattribute vec2 aPositionCoord;\nattribute float aRotation;\n\nuniform mat3 translationMatrix;\nuniform vec4 uColor;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void){\n float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);\n float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);\n\n vec2 v = vec2(x, y);\n v = v + aPositionCoord;\n\n gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vColor = aColor * uColor;\n}\n","varying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n vec4 color = texture2D(uSampler, vTextureCoord) * vColor;\n gl_FragColor = color;\n}",{}),_this.state=State.for2d(),_this}return __extends$5(ParticleRenderer,_super),ParticleRenderer.prototype.render=function(container){var children=container.children,maxSize=container._maxSize,batchSize=container._batchSize,renderer=this.renderer,totalChildren=children.length;if(0!==totalChildren){totalChildren>maxSize&&!container.autoResize&&(totalChildren=maxSize);var buffers=container._buffers;buffers||(buffers=container._buffers=this.generateBuffers(container));var baseTexture=children[0]._texture.baseTexture;this.state.blendMode=correctBlendMode(container.blendMode,baseTexture.alphaMode),renderer.state.set(this.state);var gl=renderer.gl,m=container.worldTransform.copyTo(this.tempMatrix);m.prepend(renderer.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=m.toArray(!0),this.shader.uniforms.uColor=function(rgb,alpha,out,premultiply){return out=out||new Float32Array(4),premultiply||void 0===premultiply?(out[0]=rgb[0]*alpha,out[1]=rgb[1]*alpha,out[2]=rgb[2]*alpha):(out[0]=rgb[0],out[1]=rgb[1],out[2]=rgb[2]),out[3]=alpha,out}(container.tintRgb,container.worldAlpha,this.shader.uniforms.uColor,baseTexture.alphaMode),this.shader.uniforms.uSampler=baseTexture,this.renderer.shader.bind(this.shader);for(var updateStatic=!1,i=0,j=0;i<totalChildren;i+=batchSize,j+=1){var amount=totalChildren-i;amount>batchSize&&(amount=batchSize),j>=buffers.length&&buffers.push(this._generateOneMoreBuffer(container));var buffer=buffers[j];buffer.uploadDynamic(children,i,amount);var bid=container._bufferUpdateIDs[j]||0;(updateStatic=updateStatic||buffer._updateID<bid)&&(buffer._updateID=container._updateID,buffer.uploadStatic(children,i,amount)),renderer.geometry.bind(buffer.geometry),gl.drawElements(gl.TRIANGLES,6*amount,gl.UNSIGNED_SHORT,0)}}},ParticleRenderer.prototype.generateBuffers=function(container){for(var buffers=[],size=container._maxSize,batchSize=container._batchSize,dynamicPropertyFlags=container._properties,i=0;i<size;i+=batchSize)buffers.push(new ParticleBuffer(this.properties,dynamicPropertyFlags,batchSize));return buffers},ParticleRenderer.prototype._generateOneMoreBuffer=function(container){var batchSize=container._batchSize,dynamicPropertyFlags=container._properties;return new ParticleBuffer(this.properties,dynamicPropertyFlags,batchSize)},ParticleRenderer.prototype.uploadVertices=function(children,startIndex,amount,array,stride,offset){for(var w0=0,w1=0,h0=0,h1=0,i=0;i<amount;++i){var sprite=children[startIndex+i],texture=sprite._texture,sx=sprite.scale.x,sy=sprite.scale.y,trim=texture.trim,orig=texture.orig;trim?(w0=(w1=trim.x-sprite.anchor.x*orig.width)+trim.width,h0=(h1=trim.y-sprite.anchor.y*orig.height)+trim.height):(w0=orig.width*(1-sprite.anchor.x),w1=orig.width*-sprite.anchor.x,h0=orig.height*(1-sprite.anchor.y),h1=orig.height*-sprite.anchor.y),array[offset]=w1*sx,array[offset+1]=h1*sy,array[offset+stride]=w0*sx,array[offset+stride+1]=h1*sy,array[offset+2*stride]=w0*sx,array[offset+2*stride+1]=h0*sy,array[offset+3*stride]=w1*sx,array[offset+3*stride+1]=h0*sy,offset+=4*stride}},ParticleRenderer.prototype.uploadPosition=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;i++){var spritePosition=children[startIndex+i].position;array[offset]=spritePosition.x,array[offset+1]=spritePosition.y,array[offset+stride]=spritePosition.x,array[offset+stride+1]=spritePosition.y,array[offset+2*stride]=spritePosition.x,array[offset+2*stride+1]=spritePosition.y,array[offset+3*stride]=spritePosition.x,array[offset+3*stride+1]=spritePosition.y,offset+=4*stride}},ParticleRenderer.prototype.uploadRotation=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;i++){var spriteRotation=children[startIndex+i].rotation;array[offset]=spriteRotation,array[offset+stride]=spriteRotation,array[offset+2*stride]=spriteRotation,array[offset+3*stride]=spriteRotation,offset+=4*stride}},ParticleRenderer.prototype.uploadUvs=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;++i){var textureUvs=children[startIndex+i]._texture._uvs;textureUvs?(array[offset]=textureUvs.x0,array[offset+1]=textureUvs.y0,array[offset+stride]=textureUvs.x1,array[offset+stride+1]=textureUvs.y1,array[offset+2*stride]=textureUvs.x2,array[offset+2*stride+1]=textureUvs.y2,array[offset+3*stride]=textureUvs.x3,array[offset+3*stride+1]=textureUvs.y3,offset+=4*stride):(array[offset]=0,array[offset+1]=0,array[offset+stride]=0,array[offset+stride+1]=0,array[offset+2*stride]=0,array[offset+2*stride+1]=0,array[offset+3*stride]=0,array[offset+3*stride+1]=0,offset+=4*stride)}},ParticleRenderer.prototype.uploadTint=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;++i){var sprite=children[startIndex+i],premultiplied=sprite._texture.baseTexture.alphaMode>0,alpha=sprite.alpha,argb=alpha<1&&premultiplied?premultiplyTint(sprite._tintRGB,alpha):sprite._tintRGB+(255*alpha<<24);array[offset]=argb,array[offset+stride]=argb,array[offset+2*stride]=argb,array[offset+3*stride]=argb,offset+=4*stride}},ParticleRenderer.prototype.destroy=function(){_super.prototype.destroy.call(this),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null},ParticleRenderer}(ObjectRenderer);!function(LINE_JOIN){LINE_JOIN.MITER="miter",LINE_JOIN.BEVEL="bevel",LINE_JOIN.ROUND="round"}(LINE_JOIN||(LINE_JOIN={})),function(LINE_CAP){LINE_CAP.BUTT="butt",LINE_CAP.ROUND="round",LINE_CAP.SQUARE="square"}(LINE_CAP||(LINE_CAP={}));var GRAPHICS_CURVES={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount:function(length,defaultSegments){if(void 0===defaultSegments&&(defaultSegments=20),!this.adaptive||!length||isNaN(length))return defaultSegments;var result=Math.ceil(length/this.maxLength);return result<this.minSegments?result=this.minSegments:result>this.maxSegments&&(result=this.maxSegments),result}},FillStyle=function(){function FillStyle(){this.color=16777215,this.alpha=1,this.texture=Texture.WHITE,this.matrix=null,this.visible=!1,this.reset()}return FillStyle.prototype.clone=function(){var obj=new FillStyle;return obj.color=this.color,obj.alpha=this.alpha,obj.texture=this.texture,obj.matrix=this.matrix,obj.visible=this.visible,obj},FillStyle.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=Texture.WHITE,this.matrix=null,this.visible=!1},FillStyle.prototype.destroy=function(){this.texture=null,this.matrix=null},FillStyle}(),extendStatics$6=function(d,b){return(extendStatics$6=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};function __extends$6(d,b){function __(){this.constructor=d}extendStatics$6(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}var buildPoly={build:function(graphicsData){graphicsData.points=graphicsData.shape.points.slice()},triangulate:function(graphicsData,graphicsGeometry){var points=graphicsData.points,holes=graphicsData.holes,verts=graphicsGeometry.points,indices=graphicsGeometry.indices;if(points.length>=6){for(var holeArray=[],i=0;i<holes.length;i++){var hole=holes[i];holeArray.push(points.length/2),points=points.concat(hole.points)}var triangles=earcut_1(points,holeArray,2);if(!triangles)return;var vertPos=verts.length/2;for(i=0;i<triangles.length;i+=3)indices.push(triangles[i]+vertPos),indices.push(triangles[i+1]+vertPos),indices.push(triangles[i+2]+vertPos);for(i=0;i<points.length;i++)verts.push(points[i])}}},buildCircle={build:function(graphicsData){var width,height,circleData=graphicsData.shape,points=graphicsData.points,x=circleData.x,y=circleData.y;if(points.length=0,graphicsData.type===SHAPES.CIRC)width=circleData.radius,height=circleData.radius;else{var ellipseData=graphicsData.shape;width=ellipseData.width,height=ellipseData.height}if(0!==width&&0!==height){var totalSegs=Math.floor(30*Math.sqrt(circleData.radius))||Math.floor(15*Math.sqrt(width+height));totalSegs/=2.3;for(var seg=2*Math.PI/totalSegs,i=0;i<totalSegs-.5;i++)points.push(x+Math.sin(-seg*i)*width,y+Math.cos(-seg*i)*height);points.push(points[0],points[1])}},triangulate:function(graphicsData,graphicsGeometry){var points=graphicsData.points,verts=graphicsGeometry.points,indices=graphicsGeometry.indices,vertPos=verts.length/2,center=vertPos,circle=graphicsData.shape,matrix=graphicsData.matrix,x=circle.x,y=circle.y;verts.push(graphicsData.matrix?matrix.a*x+matrix.c*y+matrix.tx:x,graphicsData.matrix?matrix.b*x+matrix.d*y+matrix.ty:y);for(var i=0;i<points.length;i+=2)verts.push(points[i],points[i+1]),indices.push(vertPos++,center,vertPos)}};function getPt(n1,n2,perc){return n1+(n2-n1)*perc}function quadraticBezierCurve(fromX,fromY,cpX,cpY,toX,toY,out){void 0===out&&(out=[]);for(var points=out,xa=0,ya=0,xb=0,yb=0,x=0,y=0,i=0,j=0;i<=20;++i)xa=getPt(fromX,cpX,j=i/20),ya=getPt(fromY,cpY,j),xb=getPt(cpX,toX,j),yb=getPt(cpY,toY,j),x=getPt(xa,xb,j),y=getPt(ya,yb,j),points.push(x,y);return points}var buildRoundedRectangle={build:function(graphicsData){var rrectData=graphicsData.shape,points=graphicsData.points,x=rrectData.x,y=rrectData.y,width=rrectData.width,height=rrectData.height,radius=Math.max(0,Math.min(rrectData.radius,Math.min(width,height)/2));points.length=0,radius?(quadraticBezierCurve(x,y+radius,x,y,x+radius,y,points),quadraticBezierCurve(x+width-radius,y,x+width,y,x+width,y+radius,points),quadraticBezierCurve(x+width,y+height-radius,x+width,y+height,x+width-radius,y+height,points),quadraticBezierCurve(x+radius,y+height,x,y+height,x,y+height-radius,points)):points.push(x,y,x+width,y,x+width,y+height,x,y+height)},triangulate:function(graphicsData,graphicsGeometry){for(var points=graphicsData.points,verts=graphicsGeometry.points,indices=graphicsGeometry.indices,vecPos=verts.length/2,triangles=earcut_1(points,null,2),i=0,j=triangles.length;i<j;i+=3)indices.push(triangles[i]+vecPos),indices.push(triangles[i+1]+vecPos),indices.push(triangles[i+2]+vecPos);for(i=0,j=points.length;i<j;i++)verts.push(points[i],points[++i])}};function square(x,y,nx,ny,innerWeight,outerWeight,clockwise,verts){var exx,eyy;clockwise?(exx=ny,eyy=-nx):(exx=-ny,eyy=nx);var eix=x-nx*innerWeight+exx,eiy=y-ny*innerWeight+eyy,eox=x+nx*outerWeight+exx,eoy=y+ny*outerWeight+eyy;return verts.push(eix,eiy),verts.push(eox,eoy),2}function round(cx,cy,sx,sy,ex,ey,verts,clockwise){var cx2p0x=sx-cx,cy2p0y=sy-cy,angle0=Math.atan2(cx2p0x,cy2p0y),angle1=Math.atan2(ex-cx,ey-cy);clockwise&&angle0<angle1?angle0+=2*Math.PI:!clockwise&&angle0>angle1&&(angle1+=2*Math.PI);var startAngle=angle0,angleDiff=angle1-angle0,absAngleDiff=Math.abs(angleDiff),radius=Math.sqrt(cx2p0x*cx2p0x+cy2p0y*cy2p0y),segCount=1+(15*absAngleDiff*Math.sqrt(radius)/Math.PI>>0),angleInc=angleDiff/segCount;if(startAngle+=angleInc,clockwise){verts.push(cx,cy),verts.push(sx,sy);for(var i=1,angle=startAngle;i<segCount;i++,angle+=angleInc)verts.push(cx,cy),verts.push(cx+Math.sin(angle)*radius,cy+Math.cos(angle)*radius);verts.push(cx,cy),verts.push(ex,ey)}else{verts.push(sx,sy),verts.push(cx,cy);for(i=1,angle=startAngle;i<segCount;i++,angle+=angleInc)verts.push(cx+Math.sin(angle)*radius,cy+Math.cos(angle)*radius),verts.push(cx,cy);verts.push(ex,ey),verts.push(cx,cy)}return 2*segCount}function buildLine(graphicsData,graphicsGeometry){graphicsData.lineStyle.native?function(graphicsData,graphicsGeometry){var i=0,shape=graphicsData.shape,points=graphicsData.points||shape.points,closedShape=shape.type!==SHAPES.POLY||shape.closeStroke;if(0!==points.length){var verts=graphicsGeometry.points,indices=graphicsGeometry.indices,length=points.length/2,startIndex=verts.length/2,currentIndex=startIndex;for(verts.push(points[0],points[1]),i=1;i<length;i++)verts.push(points[2*i],points[2*i+1]),indices.push(currentIndex,currentIndex+1),currentIndex++;closedShape&&indices.push(currentIndex,startIndex)}}(graphicsData,graphicsGeometry):function(graphicsData,graphicsGeometry){var shape=graphicsData.shape,points=graphicsData.points||shape.points.slice(),eps=graphicsGeometry.closePointEps;if(0!==points.length){var style=graphicsData.lineStyle,firstPoint=new Point(points[0],points[1]),lastPoint=new Point(points[points.length-2],points[points.length-1]),closedShape=shape.type!==SHAPES.POLY||shape.closeStroke,closedPath=Math.abs(firstPoint.x-lastPoint.x)<eps&&Math.abs(firstPoint.y-lastPoint.y)<eps;if(closedShape){points=points.slice(),closedPath&&(points.pop(),points.pop(),lastPoint.set(points[points.length-2],points[points.length-1]));var midPointX=.5*(firstPoint.x+lastPoint.x),midPointY=.5*(lastPoint.y+firstPoint.y);points.unshift(midPointX,midPointY),points.push(midPointX,midPointY)}var verts=graphicsGeometry.points,length=points.length/2,indexCount=points.length,indexStart=verts.length/2,width=style.width/2,widthSquared=width*width,miterLimitSquared=style.miterLimit*style.miterLimit,x0=points[0],y0=points[1],x1=points[2],y1=points[3],x2=0,y2=0,perpx=-(y0-y1),perpy=x0-x1,perp1x=0,perp1y=0,dist=Math.sqrt(perpx*perpx+perpy*perpy);perpx/=dist,perpy/=dist,perpx*=width,perpy*=width;var ratio=style.alignment,innerWeight=2*(1-ratio),outerWeight=2*ratio;closedShape||(style.cap===LINE_CAP.ROUND?indexCount+=round(x0-perpx*(innerWeight-outerWeight)*.5,y0-perpy*(innerWeight-outerWeight)*.5,x0-perpx*innerWeight,y0-perpy*innerWeight,x0+perpx*outerWeight,y0+perpy*outerWeight,verts,!0)+2:style.cap===LINE_CAP.SQUARE&&(indexCount+=square(x0,y0,perpx,perpy,innerWeight,outerWeight,!0,verts))),verts.push(x0-perpx*innerWeight,y0-perpy*innerWeight),verts.push(x0+perpx*outerWeight,y0+perpy*outerWeight);for(var i=1;i<length-1;++i){x0=points[2*(i-1)],y0=points[2*(i-1)+1],x1=points[2*i],y1=points[2*i+1],x2=points[2*(i+1)],y2=points[2*(i+1)+1],perpx=-(y0-y1),perpy=x0-x1,perpx/=dist=Math.sqrt(perpx*perpx+perpy*perpy),perpy/=dist,perpx*=width,perpy*=width,perp1x=-(y1-y2),perp1y=x1-x2,perp1x/=dist=Math.sqrt(perp1x*perp1x+perp1y*perp1y),perp1y/=dist,perp1x*=width,perp1y*=width;var dx0=x1-x0,dy0=y0-y1,dx1=x1-x2,dy1=y2-y1,cross=dy0*dx1-dy1*dx0,clockwise=cross<0;if(Math.abs(cross)<.1)verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight);else{var c1=(-perpx+x0)*(-perpy+y1)-(-perpx+x1)*(-perpy+y0),c2=(-perp1x+x2)*(-perp1y+y1)-(-perp1x+x1)*(-perp1y+y2),px=(dx0*c2-dx1*c1)/cross,py=(dy1*c1-dy0*c2)/cross,pdist=(px-x1)*(px-x1)+(py-y1)*(py-y1),imx=x1+(px-x1)*innerWeight,imy=y1+(py-y1)*innerWeight,omx=x1-(px-x1)*outerWeight,omy=y1-(py-y1)*outerWeight,insideWeight=clockwise?innerWeight:outerWeight;pdist<=Math.min(dx0*dx0+dy0*dy0,dx1*dx1+dy1*dy1)+insideWeight*insideWeight*widthSquared?style.join===LINE_JOIN.BEVEL||pdist/widthSquared>miterLimitSquared?(clockwise?(verts.push(imx,imy),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight),verts.push(imx,imy),verts.push(x1+perp1x*outerWeight,y1+perp1y*outerWeight)):(verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(omx,omy),verts.push(x1-perp1x*innerWeight,y1-perp1y*innerWeight),verts.push(omx,omy)),indexCount+=2):style.join===LINE_JOIN.ROUND?clockwise?(verts.push(imx,imy),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight),indexCount+=round(x1,y1,x1+perpx*outerWeight,y1+perpy*outerWeight,x1+perp1x*outerWeight,y1+perp1y*outerWeight,verts,!0)+4,verts.push(imx,imy),verts.push(x1+perp1x*outerWeight,y1+perp1y*outerWeight)):(verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(omx,omy),indexCount+=round(x1,y1,x1-perpx*innerWeight,y1-perpy*innerWeight,x1-perp1x*innerWeight,y1-perp1y*innerWeight,verts,!1)+4,verts.push(x1-perp1x*innerWeight,y1-perp1y*innerWeight),verts.push(omx,omy)):(verts.push(imx,imy),verts.push(omx,omy)):(verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight),style.join===LINE_JOIN.BEVEL||pdist/widthSquared>miterLimitSquared||(style.join===LINE_JOIN.ROUND?indexCount+=clockwise?round(x1,y1,x1+perpx*outerWeight,y1+perpy*outerWeight,x1+perp1x*outerWeight,y1+perp1y*outerWeight,verts,!0)+2:round(x1,y1,x1-perpx*innerWeight,y1-perpy*innerWeight,x1-perp1x*innerWeight,y1-perp1y*innerWeight,verts,!1)+2:(clockwise?(verts.push(omx,omy),verts.push(omx,omy)):(verts.push(imx,imy),verts.push(imx,imy)),indexCount+=2)),verts.push(x1-perp1x*innerWeight,y1-perp1y*innerWeight),verts.push(x1+perp1x*outerWeight,y1+perp1y*outerWeight),indexCount+=2)}}x0=points[2*(length-2)],y0=points[2*(length-2)+1],x1=points[2*(length-1)],perpx=-(y0-(y1=points[2*(length-1)+1])),perpy=x0-x1,perpx/=dist=Math.sqrt(perpx*perpx+perpy*perpy),perpy/=dist,perpx*=width,perpy*=width,verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight),closedShape||(style.cap===LINE_CAP.ROUND?indexCount+=round(x1-perpx*(innerWeight-outerWeight)*.5,y1-perpy*(innerWeight-outerWeight)*.5,x1-perpx*innerWeight,y1-perpy*innerWeight,x1+perpx*outerWeight,y1+perpy*outerWeight,verts,!1)+2:style.cap===LINE_CAP.SQUARE&&(indexCount+=square(x1,y1,perpx,perpy,innerWeight,outerWeight,!1,verts)));var indices=graphicsGeometry.indices,eps2=GRAPHICS_CURVES.epsilon*GRAPHICS_CURVES.epsilon;for(i=indexStart;i<indexCount+indexStart-2;++i)x0=verts[2*i],y0=verts[2*i+1],x1=verts[2*(i+1)],y1=verts[2*(i+1)+1],x2=verts[2*(i+2)],y2=verts[2*(i+2)+1],Math.abs(x0*(y1-y2)+x1*(y2-y0)+x2*(y0-y1))<eps2||indices.push(i,i+1,i+2)}}(graphicsData,graphicsGeometry)}var _a,Star=function(_super){function Star(x,y,points,radius,innerRadius,rotation){void 0===rotation&&(rotation=0);innerRadius=innerRadius||radius/2;for(var startAngle=-1*Math.PI/2+rotation,len=2*points,delta=PI_2/len,polygon=[],i=0;i<len;i++){var r=i%2?innerRadius:radius,angle=i*delta+startAngle;polygon.push(x+r*Math.cos(angle),y+r*Math.sin(angle))}return _super.call(this,polygon)||this}return __extends$6(Star,_super),Star}(Polygon),ArcUtils=function(){function ArcUtils(){}return ArcUtils.curveTo=function(x1,y1,x2,y2,radius,points){var fromX=points[points.length-2],a1=points[points.length-1]-y1,b1=fromX-x1,a2=y2-y1,b2=x2-x1,mm=Math.abs(a1*b2-b1*a2);if(mm<1e-8||0===radius)return points[points.length-2]===x1&&points[points.length-1]===y1||points.push(x1,y1),null;var dd=a1*a1+b1*b1,cc=a2*a2+b2*b2,tt=a1*a2+b1*b2,k1=radius*Math.sqrt(dd)/mm,k2=radius*Math.sqrt(cc)/mm,j1=k1*tt/dd,j2=k2*tt/cc,cx=k1*b2+k2*b1,cy=k1*a2+k2*a1,px=b1*(k2+j1),py=a1*(k2+j1),qx=b2*(k1+j2),qy=a2*(k1+j2);return{cx:cx+x1,cy:cy+y1,radius:radius,startAngle:Math.atan2(py-cy,px-cx),endAngle:Math.atan2(qy-cy,qx-cx),anticlockwise:b1*a2>b2*a1}},ArcUtils.arc=function(_startX,_startY,cx,cy,radius,startAngle,endAngle,_anticlockwise,points){for(var sweep=endAngle-startAngle,n=GRAPHICS_CURVES._segmentsCount(Math.abs(sweep)*radius,40*Math.ceil(Math.abs(sweep)/PI_2)),theta=sweep/(2*n),theta2=2*theta,cTheta=Math.cos(theta),sTheta=Math.sin(theta),segMinus=n-1,remainder=segMinus%1/segMinus,i=0;i<=segMinus;++i){var angle=theta+startAngle+theta2*(i+remainder*i),c=Math.cos(angle),s=-Math.sin(angle);points.push((cTheta*c+sTheta*s)*radius+cx,(cTheta*-s+sTheta*c)*radius+cy)}},ArcUtils}(),BezierUtils=function(){function BezierUtils(){}return BezierUtils.curveLength=function(fromX,fromY,cpX,cpY,cpX2,cpY2,toX,toY){for(var result=0,t=0,t2=0,t3=0,nt=0,nt2=0,nt3=0,x=0,y=0,dx=0,dy=0,prevX=fromX,prevY=fromY,i=1;i<=10;++i)dx=prevX-(x=(nt3=(nt2=(nt=1-(t=i/10))*nt)*nt)*fromX+3*nt2*t*cpX+3*nt*(t2=t*t)*cpX2+(t3=t2*t)*toX),dy=prevY-(y=nt3*fromY+3*nt2*t*cpY+3*nt*t2*cpY2+t3*toY),prevX=x,prevY=y,result+=Math.sqrt(dx*dx+dy*dy);return result},BezierUtils.curveTo=function(cpX,cpY,cpX2,cpY2,toX,toY,points){var fromX=points[points.length-2],fromY=points[points.length-1];points.length-=2;var n=GRAPHICS_CURVES._segmentsCount(BezierUtils.curveLength(fromX,fromY,cpX,cpY,cpX2,cpY2,toX,toY)),dt=0,dt2=0,dt3=0,t2=0,t3=0;points.push(fromX,fromY);for(var i=1,j=0;i<=n;++i)dt3=(dt2=(dt=1-(j=i/n))*dt)*dt,t3=(t2=j*j)*j,points.push(dt3*fromX+3*dt2*j*cpX+3*dt*t2*cpX2+t3*toX,dt3*fromY+3*dt2*j*cpY+3*dt*t2*cpY2+t3*toY)},BezierUtils}(),QuadraticUtils=function(){function QuadraticUtils(){}return QuadraticUtils.curveLength=function(fromX,fromY,cpX,cpY,toX,toY){var ax=fromX-2*cpX+toX,ay=fromY-2*cpY+toY,bx=2*cpX-2*fromX,by=2*cpY-2*fromY,a=4*(ax*ax+ay*ay),b=4*(ax*bx+ay*by),c=bx*bx+by*by,s=2*Math.sqrt(a+b+c),a2=Math.sqrt(a),a32=2*a*a2,c2=2*Math.sqrt(c),ba=b/a2;return(a32*s+a2*b*(s-c2)+(4*c*a-b*b)*Math.log((2*a2+ba+s)/(ba+c2)))/(4*a32)},QuadraticUtils.curveTo=function(cpX,cpY,toX,toY,points){for(var fromX=points[points.length-2],fromY=points[points.length-1],n=GRAPHICS_CURVES._segmentsCount(QuadraticUtils.curveLength(fromX,fromY,cpX,cpY,toX,toY)),xa=0,ya=0,i=1;i<=n;++i){var j=i/n;xa=fromX+(cpX-fromX)*j,ya=fromY+(cpY-fromY)*j,points.push(xa+(cpX+(toX-cpX)*j-xa)*j,ya+(cpY+(toY-cpY)*j-ya)*j)}},QuadraticUtils}(),BatchPart=function(){function BatchPart(){this.reset()}return BatchPart.prototype.begin=function(style,startIndex,attribStart){this.reset(),this.style=style,this.start=startIndex,this.attribStart=attribStart},BatchPart.prototype.end=function(endIndex,endAttrib){this.attribSize=endAttrib-this.attribStart,this.size=endIndex-this.start},BatchPart.prototype.reset=function(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0},BatchPart}(),FILL_COMMANDS=((_a={})[SHAPES.POLY]=buildPoly,_a[SHAPES.CIRC]=buildCircle,_a[SHAPES.ELIP]=buildCircle,_a[SHAPES.RECT]={build:function(graphicsData){var rectData=graphicsData.shape,x=rectData.x,y=rectData.y,width=rectData.width,height=rectData.height,points=graphicsData.points;points.length=0,points.push(x,y,x+width,y,x+width,y+height,x,y+height)},triangulate:function(graphicsData,graphicsGeometry){var points=graphicsData.points,verts=graphicsGeometry.points,vertPos=verts.length/2;verts.push(points[0],points[1],points[2],points[3],points[6],points[7],points[4],points[5]),graphicsGeometry.indices.push(vertPos,vertPos+1,vertPos+2,vertPos+1,vertPos+2,vertPos+3)}},_a[SHAPES.RREC]=buildRoundedRectangle,_a),BATCH_POOL=[],DRAW_CALL_POOL=[],GraphicsData=function(){function GraphicsData(shape,fillStyle,lineStyle,matrix){void 0===fillStyle&&(fillStyle=null),void 0===lineStyle&&(lineStyle=null),void 0===matrix&&(matrix=null),this.shape=shape,this.lineStyle=lineStyle,this.fillStyle=fillStyle,this.matrix=matrix,this.type=shape.type,this.points=[],this.holes=[]}return GraphicsData.prototype.clone=function(){return new GraphicsData(this.shape,this.fillStyle,this.lineStyle,this.matrix)},GraphicsData.prototype.destroy=function(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null},GraphicsData}(),tmpPoint=new Point,tmpBounds=new Bounds,GraphicsGeometry=function(_super){function GraphicsGeometry(){var _this=_super.call(this)||this;return _this.uvsFloat32=null,_this.indicesUint16=null,_this.points=[],_this.colors=[],_this.uvs=[],_this.indices=[],_this.textureIds=[],_this.graphicsData=[],_this.dirty=0,_this.batchDirty=-1,_this.cacheDirty=-1,_this.clearDirty=0,_this.drawCalls=[],_this.batches=[],_this.shapeIndex=0,_this._bounds=new Bounds,_this.boundsDirty=-1,_this.boundsPadding=0,_this.batchable=!1,_this.indicesUint16=null,_this.uvsFloat32=null,_this.closePointEps=1e-4,_this}return __extends$6(GraphicsGeometry,_super),Object.defineProperty(GraphicsGeometry.prototype,"bounds",{get:function(){return this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds},enumerable:!1,configurable:!0}),GraphicsGeometry.prototype.invalidate=function(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(var i=0;i<this.drawCalls.length;i++)this.drawCalls[i].texArray.clear(),DRAW_CALL_POOL.push(this.drawCalls[i]);this.drawCalls.length=0;for(i=0;i<this.batches.length;i++){var batchPart=this.batches[i];batchPart.reset(),BATCH_POOL.push(batchPart)}this.batches.length=0},GraphicsGeometry.prototype.clear=function(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this},GraphicsGeometry.prototype.drawShape=function(shape,fillStyle,lineStyle,matrix){void 0===fillStyle&&(fillStyle=null),void 0===lineStyle&&(lineStyle=null),void 0===matrix&&(matrix=null);var data=new GraphicsData(shape,fillStyle,lineStyle,matrix);return this.graphicsData.push(data),this.dirty++,this},GraphicsGeometry.prototype.drawHole=function(shape,matrix){if(void 0===matrix&&(matrix=null),!this.graphicsData.length)return null;var data=new GraphicsData(shape,null,null,matrix),lastShape=this.graphicsData[this.graphicsData.length-1];return data.lineStyle=lastShape.lineStyle,lastShape.holes.push(data),this.dirty++,this},GraphicsGeometry.prototype.destroy=function(){_super.prototype.destroy.call(this);for(var i=0;i<this.graphicsData.length;++i)this.graphicsData[i].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null},GraphicsGeometry.prototype.containsPoint=function(point){for(var graphicsData=this.graphicsData,i=0;i<graphicsData.length;++i){var data=graphicsData[i];if(data.fillStyle.visible&&(data.shape&&(data.matrix?data.matrix.applyInverse(point,tmpPoint):tmpPoint.copyFrom(point),data.shape.contains(tmpPoint.x,tmpPoint.y)))){var hitHole=!1;if(data.holes)for(var i_1=0;i_1<data.holes.length;i_1++){if(data.holes[i_1].shape.contains(tmpPoint.x,tmpPoint.y)){hitHole=!0;break}}if(!hitHole)return!0}}return!1},GraphicsGeometry.prototype.updateBatches=function(allow32Indices){if(this.graphicsData.length){if(this.validateBatching()){this.cacheDirty=this.dirty;var uvs=this.uvs,graphicsData=this.graphicsData,batchPart=null,currentStyle=null;this.batches.length>0&&(currentStyle=(batchPart=this.batches[this.batches.length-1]).style);for(var i=this.shapeIndex;i<graphicsData.length;i++){this.shapeIndex++;var data=graphicsData[i],fillStyle=data.fillStyle,lineStyle=data.lineStyle;FILL_COMMANDS[data.type].build(data),data.matrix&&this.transformPoints(data.points,data.matrix);for(var j=0;j<2;j++){var style=0===j?fillStyle:lineStyle;if(style.visible){var nextTexture=style.texture.baseTexture,index_1=this.indices.length,attribIndex=this.points.length/2;nextTexture.wrapMode=WRAP_MODES.REPEAT,0===j?this.processFill(data):this.processLine(data);var size=this.points.length/2-attribIndex;0!==size&&(batchPart&&!this._compareStyles(currentStyle,style)&&(batchPart.end(index_1,attribIndex),batchPart=null),batchPart||((batchPart=BATCH_POOL.pop()||new BatchPart).begin(style,index_1,attribIndex),this.batches.push(batchPart),currentStyle=style),this.addUvs(this.points,uvs,style.texture,attribIndex,size,style.matrix))}}}var index=this.indices.length,attrib=this.points.length/2;if(batchPart&&batchPart.end(index,attrib),0!==this.batches.length){if(this.indicesUint16&&this.indices.length===this.indicesUint16.length)this.indicesUint16.set(this.indices);else{var need32=attrib>65535&&allow32Indices;this.indicesUint16=need32?new Uint32Array(this.indices):new Uint16Array(this.indices)}this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}else this.batchable=!0}}else this.batchable=!0},GraphicsGeometry.prototype._compareStyles=function(styleA,styleB){return!(!styleA||!styleB)&&(styleA.texture.baseTexture===styleB.texture.baseTexture&&(styleA.color+styleA.alpha===styleB.color+styleB.alpha&&!!styleA.native==!!styleB.native))},GraphicsGeometry.prototype.validateBatching=function(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(var i=0,l=this.graphicsData.length;i<l;i++){var data=this.graphicsData[i],fill=data.fillStyle,line=data.lineStyle;if(fill&&!fill.texture.baseTexture.valid)return!1;if(line&&!line.texture.baseTexture.valid)return!1}return!0},GraphicsGeometry.prototype.packBatches=function(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);for(var batches=this.batches,i=0,l=batches.length;i<l;i++)for(var batch=batches[i],j=0;j<batch.size;j++){var index=batch.start+j;this.indicesUint16[index]=this.indicesUint16[index]-batch.attribStart}},GraphicsGeometry.prototype.isBatchable=function(){if(this.points.length>131070)return!1;for(var batches=this.batches,i=0;i<batches.length;i++)if(batches[i].style.native)return!1;return this.points.length<2*GraphicsGeometry.BATCHABLE_SIZE},GraphicsGeometry.prototype.buildDrawCalls=function(){for(var TICK=++BaseTexture._globalBatch,i=0;i<this.drawCalls.length;i++)this.drawCalls[i].texArray.clear(),DRAW_CALL_POOL.push(this.drawCalls[i]);this.drawCalls.length=0;var colors=this.colors,textureIds=this.textureIds,currentGroup=DRAW_CALL_POOL.pop();currentGroup||((currentGroup=new BatchDrawCall).texArray=new BatchTextureArray),currentGroup.texArray.count=0,currentGroup.start=0,currentGroup.size=0,currentGroup.type=DRAW_MODES.TRIANGLES;var textureCount=0,currentTexture=null,textureId=0,native=!1,drawMode=DRAW_MODES.TRIANGLES,index=0;this.drawCalls.push(currentGroup);for(i=0;i<this.batches.length;i++){var data=this.batches[i],style=data.style,nextTexture=style.texture.baseTexture;native!==!!style.native&&(drawMode=(native=!!style.native)?DRAW_MODES.LINES:DRAW_MODES.TRIANGLES,currentTexture=null,textureCount=8,TICK++),currentTexture!==nextTexture&&(currentTexture=nextTexture,nextTexture._batchEnabled!==TICK&&(8===textureCount&&(TICK++,textureCount=0,currentGroup.size>0&&((currentGroup=DRAW_CALL_POOL.pop())||((currentGroup=new BatchDrawCall).texArray=new BatchTextureArray),this.drawCalls.push(currentGroup)),currentGroup.start=index,currentGroup.size=0,currentGroup.texArray.count=0,currentGroup.type=drawMode),nextTexture.touched=1,nextTexture._batchEnabled=TICK,nextTexture._batchLocation=textureCount,nextTexture.wrapMode=10497,currentGroup.texArray.elements[currentGroup.texArray.count++]=nextTexture,textureCount++)),currentGroup.size+=data.size,index+=data.size,textureId=nextTexture._batchLocation,this.addColors(colors,style.color,style.alpha,data.attribSize),this.addTextureIds(textureIds,textureId,data.attribSize)}BaseTexture._globalBatch=TICK,this.packAttributes()},GraphicsGeometry.prototype.packAttributes=function(){for(var verts=this.points,uvs=this.uvs,colors=this.colors,textureIds=this.textureIds,glPoints=new ArrayBuffer(3*verts.length*4),f32=new Float32Array(glPoints),u32=new Uint32Array(glPoints),p=0,i=0;i<verts.length/2;i++)f32[p++]=verts[2*i],f32[p++]=verts[2*i+1],f32[p++]=uvs[2*i],f32[p++]=uvs[2*i+1],u32[p++]=colors[i],f32[p++]=textureIds[i];this._buffer.update(glPoints),this._indexBuffer.update(this.indicesUint16)},GraphicsGeometry.prototype.processFill=function(data){data.holes.length?(this.processHoles(data.holes),buildPoly.triangulate(data,this)):FILL_COMMANDS[data.type].triangulate(data,this)},GraphicsGeometry.prototype.processLine=function(data){buildLine(data,this);for(var i=0;i<data.holes.length;i++)buildLine(data.holes[i],this)},GraphicsGeometry.prototype.processHoles=function(holes){for(var i=0;i<holes.length;i++){var hole=holes[i];FILL_COMMANDS[hole.type].build(hole),hole.matrix&&this.transformPoints(hole.points,hole.matrix)}},GraphicsGeometry.prototype.calculateBounds=function(){var bounds=this._bounds,sequenceBounds=tmpBounds,curMatrix=Matrix.IDENTITY;this._bounds.clear(),sequenceBounds.clear();for(var i=0;i<this.graphicsData.length;i++){var data=this.graphicsData[i],shape=data.shape,type=data.type,lineStyle=data.lineStyle,nextMatrix=data.matrix||Matrix.IDENTITY,lineWidth=0;if(lineStyle&&lineStyle.visible){var alignment=lineStyle.alignment;lineWidth=lineStyle.width,type===SHAPES.POLY?lineWidth*=.5+Math.abs(.5-alignment):lineWidth*=Math.max(0,alignment)}if(curMatrix!==nextMatrix&&(sequenceBounds.isEmpty()||(bounds.addBoundsMatrix(sequenceBounds,curMatrix),sequenceBounds.clear()),curMatrix=nextMatrix),type===SHAPES.RECT||type===SHAPES.RREC){var rect=shape;sequenceBounds.addFramePad(rect.x,rect.y,rect.x+rect.width,rect.y+rect.height,lineWidth,lineWidth)}else if(type===SHAPES.CIRC){var circle=shape;sequenceBounds.addFramePad(circle.x,circle.y,circle.x,circle.y,circle.radius+lineWidth,circle.radius+lineWidth)}else if(type===SHAPES.ELIP){var ellipse=shape;sequenceBounds.addFramePad(ellipse.x,ellipse.y,ellipse.x,ellipse.y,ellipse.width+lineWidth,ellipse.height+lineWidth)}else{var poly=shape;bounds.addVerticesMatrix(curMatrix,poly.points,0,poly.points.length,lineWidth,lineWidth)}}sequenceBounds.isEmpty()||bounds.addBoundsMatrix(sequenceBounds,curMatrix),bounds.pad(this.boundsPadding,this.boundsPadding)},GraphicsGeometry.prototype.transformPoints=function(points,matrix){for(var i=0;i<points.length/2;i++){var x=points[2*i],y=points[2*i+1];points[2*i]=matrix.a*x+matrix.c*y+matrix.tx,points[2*i+1]=matrix.b*x+matrix.d*y+matrix.ty}},GraphicsGeometry.prototype.addColors=function(colors,color,alpha,size){for(var rgba=premultiplyTint((color>>16)+(65280&color)+((255&color)<<16),alpha);size-- >0;)colors.push(rgba)},GraphicsGeometry.prototype.addTextureIds=function(textureIds,id,size){for(;size-- >0;)textureIds.push(id)},GraphicsGeometry.prototype.addUvs=function(verts,uvs,texture,start,size,matrix){void 0===matrix&&(matrix=null);for(var index=0,uvsStart=uvs.length,frame=texture.frame;index<size;){var x=verts[2*(start+index)],y=verts[2*(start+index)+1];if(matrix){var nx=matrix.a*x+matrix.c*y+matrix.tx;y=matrix.b*x+matrix.d*y+matrix.ty,x=nx}index++,uvs.push(x/frame.width,y/frame.height)}var baseTexture=texture.baseTexture;(frame.width<baseTexture.width||frame.height<baseTexture.height)&&this.adjustUvs(uvs,texture,uvsStart,size)},GraphicsGeometry.prototype.adjustUvs=function(uvs,texture,start,size){for(var baseTexture=texture.baseTexture,eps=1e-6,finish=start+2*size,frame=texture.frame,scaleX=frame.width/baseTexture.width,scaleY=frame.height/baseTexture.height,offsetX=frame.x/frame.width,offsetY=frame.y/frame.height,minX=Math.floor(uvs[start]+eps),minY=Math.floor(uvs[start+1]+eps),i=start+2;i<finish;i+=2)minX=Math.min(minX,Math.floor(uvs[i]+eps)),minY=Math.min(minY,Math.floor(uvs[i+1]+eps));offsetX-=minX,offsetY-=minY;for(i=start;i<finish;i+=2)uvs[i]=(uvs[i]+offsetX)*scaleX,uvs[i+1]=(uvs[i+1]+offsetY)*scaleY},GraphicsGeometry.BATCHABLE_SIZE=100,GraphicsGeometry}(BatchGeometry),LineStyle=function(_super){function LineStyle(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.width=0,_this.alignment=.5,_this.native=!1,_this.cap=LINE_CAP.BUTT,_this.join=LINE_JOIN.MITER,_this.miterLimit=10,_this}return __extends$6(LineStyle,_super),LineStyle.prototype.clone=function(){var obj=new LineStyle;return obj.color=this.color,obj.alpha=this.alpha,obj.texture=this.texture,obj.matrix=this.matrix,obj.visible=this.visible,obj.width=this.width,obj.alignment=this.alignment,obj.native=this.native,obj.cap=this.cap,obj.join=this.join,obj.miterLimit=this.miterLimit,obj},LineStyle.prototype.reset=function(){_super.prototype.reset.call(this),this.color=0,this.alignment=.5,this.width=0,this.native=!1},LineStyle}(FillStyle),temp=new Float32Array(3),DEFAULT_SHADERS={},Graphics=function(_super){function Graphics(geometry){void 0===geometry&&(geometry=null);var _this=_super.call(this)||this;return _this._geometry=geometry||new GraphicsGeometry,_this._geometry.refCount++,_this.shader=null,_this.state=State.for2d(),_this._fillStyle=new FillStyle,_this._lineStyle=new LineStyle,_this._matrix=null,_this._holeMode=!1,_this.currentPath=null,_this.batches=[],_this.batchTint=-1,_this.batchDirty=-1,_this.vertexData=null,_this.pluginName="batch",_this._transformID=-1,_this.tint=16777215,_this.blendMode=BLEND_MODES.NORMAL,_this}return __extends$6(Graphics,_super),Object.defineProperty(Graphics.prototype,"geometry",{get:function(){return this._geometry},enumerable:!1,configurable:!0}),Graphics.prototype.clone=function(){return this.finishPoly(),new Graphics(this._geometry)},Object.defineProperty(Graphics.prototype,"blendMode",{get:function(){return this.state.blendMode},set:function(value){this.state.blendMode=value},enumerable:!1,configurable:!0}),Object.defineProperty(Graphics.prototype,"tint",{get:function(){return this._tint},set:function(value){this._tint=value},enumerable:!1,configurable:!0}),Object.defineProperty(Graphics.prototype,"fill",{get:function(){return this._fillStyle},enumerable:!1,configurable:!0}),Object.defineProperty(Graphics.prototype,"line",{get:function(){return this._lineStyle},enumerable:!1,configurable:!0}),Graphics.prototype.lineStyle=function(options){if(void 0===options&&(options=null),"number"==typeof options){var args=arguments;options={width:args[0]||0,color:args[1]||0,alpha:void 0!==args[2]?args[2]:1,alignment:void 0!==args[3]?args[3]:.5,native:!!args[4]}}return this.lineTextureStyle(options)},Graphics.prototype.lineTextureStyle=function(options){if("number"==typeof options){deprecation("v5.2.0","Please use object-based options for Graphics#lineTextureStyle");var _a=arguments,width=_a[0],texture=_a[1],color=_a[2],alpha=_a[3],matrix=_a[4],alignment=_a[5],native=_a[6];options={width:width,texture:texture,color:color,alpha:alpha,matrix:matrix,alignment:alignment,native:native},Object.keys(options).forEach((function(key){return void 0===options[key]&&delete options[key]}))}options=Object.assign({width:0,texture:Texture.WHITE,color:options&&options.texture?16777215:0,alpha:1,matrix:null,alignment:.5,native:!1,cap:LINE_CAP.BUTT,join:LINE_JOIN.MITER,miterLimit:10},options),this.currentPath&&this.startPoly();var visible=options.width>0&&options.alpha>0;return visible?(options.matrix&&(options.matrix=options.matrix.clone(),options.matrix.invert()),Object.assign(this._lineStyle,{visible:visible},options)):this._lineStyle.reset(),this},Graphics.prototype.startPoly=function(){if(this.currentPath){var points=this.currentPath.points,len=this.currentPath.points.length;len>2&&(this.drawShape(this.currentPath),this.currentPath=new Polygon,this.currentPath.closeStroke=!1,this.currentPath.points.push(points[len-2],points[len-1]))}else this.currentPath=new Polygon,this.currentPath.closeStroke=!1},Graphics.prototype.finishPoly=function(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)},Graphics.prototype.moveTo=function(x,y){return this.startPoly(),this.currentPath.points[0]=x,this.currentPath.points[1]=y,this},Graphics.prototype.lineTo=function(x,y){this.currentPath||this.moveTo(0,0);var points=this.currentPath.points,fromX=points[points.length-2],fromY=points[points.length-1];return fromX===x&&fromY===y||points.push(x,y),this},Graphics.prototype._initCurve=function(x,y){void 0===x&&(x=0),void 0===y&&(y=0),this.currentPath?0===this.currentPath.points.length&&(this.currentPath.points=[x,y]):this.moveTo(x,y)},Graphics.prototype.quadraticCurveTo=function(cpX,cpY,toX,toY){this._initCurve();var points=this.currentPath.points;return 0===points.length&&this.moveTo(0,0),QuadraticUtils.curveTo(cpX,cpY,toX,toY,points),this},Graphics.prototype.bezierCurveTo=function(cpX,cpY,cpX2,cpY2,toX,toY){return this._initCurve(),BezierUtils.curveTo(cpX,cpY,cpX2,cpY2,toX,toY,this.currentPath.points),this},Graphics.prototype.arcTo=function(x1,y1,x2,y2,radius){this._initCurve(x1,y1);var points=this.currentPath.points,result=ArcUtils.curveTo(x1,y1,x2,y2,radius,points);if(result){var cx=result.cx,cy=result.cy,radius_1=result.radius,startAngle=result.startAngle,endAngle=result.endAngle,anticlockwise=result.anticlockwise;this.arc(cx,cy,radius_1,startAngle,endAngle,anticlockwise)}return this},Graphics.prototype.arc=function(cx,cy,radius,startAngle,endAngle,anticlockwise){if(void 0===anticlockwise&&(anticlockwise=!1),startAngle===endAngle)return this;if(!anticlockwise&&endAngle<=startAngle?endAngle+=PI_2:anticlockwise&&startAngle<=endAngle&&(startAngle+=PI_2),0===endAngle-startAngle)return this;var startX=cx+Math.cos(startAngle)*radius,startY=cy+Math.sin(startAngle)*radius,eps=this._geometry.closePointEps,points=this.currentPath?this.currentPath.points:null;if(points){var xDiff=Math.abs(points[points.length-2]-startX),yDiff=Math.abs(points[points.length-1]-startY);xDiff<eps&&yDiff<eps||points.push(startX,startY)}else this.moveTo(startX,startY),points=this.currentPath.points;return ArcUtils.arc(startX,startY,cx,cy,radius,startAngle,endAngle,anticlockwise,points),this},Graphics.prototype.beginFill=function(color,alpha){return void 0===color&&(color=0),void 0===alpha&&(alpha=1),this.beginTextureFill({texture:Texture.WHITE,color:color,alpha:alpha})},Graphics.prototype.beginTextureFill=function(options){if(options instanceof Texture){deprecation("v5.2.0","Please use object-based options for Graphics#beginTextureFill");var _a=arguments,texture=_a[0],color=_a[1],alpha=_a[2],matrix=_a[3];options={texture:texture,color:color,alpha:alpha,matrix:matrix},Object.keys(options).forEach((function(key){return void 0===options[key]&&delete options[key]}))}options=Object.assign({texture:Texture.WHITE,color:16777215,alpha:1,matrix:null},options),this.currentPath&&this.startPoly();var visible=options.alpha>0;return visible?(options.matrix&&(options.matrix=options.matrix.clone(),options.matrix.invert()),Object.assign(this._fillStyle,{visible:visible},options)):this._fillStyle.reset(),this},Graphics.prototype.endFill=function(){return this.finishPoly(),this._fillStyle.reset(),this},Graphics.prototype.drawRect=function(x,y,width,height){return this.drawShape(new Rectangle(x,y,width,height))},Graphics.prototype.drawRoundedRect=function(x,y,width,height,radius){return this.drawShape(new RoundedRectangle(x,y,width,height,radius))},Graphics.prototype.drawCircle=function(x,y,radius){return this.drawShape(new Circle(x,y,radius))},Graphics.prototype.drawEllipse=function(x,y,width,height){return this.drawShape(new Ellipse(x,y,width,height))},Graphics.prototype.drawPolygon=function(){for(var points,arguments$1=arguments,path=[],_i=0;_i<arguments.length;_i++)path[_i]=arguments$1[_i];var closeStroke=!0,poly=path[0];poly.points?(closeStroke=poly.closeStroke,points=poly.points):points=Array.isArray(path[0])?path[0]:path;var shape=new Polygon(points);return shape.closeStroke=closeStroke,this.drawShape(shape),this},Graphics.prototype.drawShape=function(shape){return this._holeMode?this._geometry.drawHole(shape,this._matrix):this._geometry.drawShape(shape,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this},Graphics.prototype.drawStar=function(x,y,points,radius,innerRadius,rotation){return void 0===rotation&&(rotation=0),this.drawPolygon(new Star(x,y,points,radius,innerRadius,rotation))},Graphics.prototype.clear=function(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this},Graphics.prototype.isFastRect=function(){var data=this._geometry.graphicsData;return 1===data.length&&data[0].shape.type===SHAPES.RECT&&!(data[0].lineStyle.visible&&data[0].lineStyle.width)},Graphics.prototype._render=function(renderer){this.finishPoly();var geometry=this._geometry,hasuint32=renderer.context.supports.uint32Indices;geometry.updateBatches(hasuint32),geometry.batchable?(this.batchDirty!==geometry.batchDirty&&this._populateBatches(),this._renderBatched(renderer)):(renderer.batch.flush(),this._renderDirect(renderer))},Graphics.prototype._populateBatches=function(){var geometry=this._geometry,blendMode=this.blendMode,len=geometry.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=geometry.batchDirty,this.batches.length=len,this.vertexData=new Float32Array(geometry.points);for(var i=0;i<len;i++){var gI=geometry.batches[i],color=gI.style.color,vertexData=new Float32Array(this.vertexData.buffer,4*gI.attribStart*2,2*gI.attribSize),uvs=new Float32Array(geometry.uvsFloat32.buffer,4*gI.attribStart*2,2*gI.attribSize),batch={vertexData:vertexData,blendMode:blendMode,indices:new Uint16Array(geometry.indicesUint16.buffer,2*gI.start,gI.size),uvs:uvs,_batchRGB:hex2rgb(color),_tintRGB:color,_texture:gI.style.texture,alpha:gI.style.alpha,worldAlpha:1};this.batches[i]=batch}},Graphics.prototype._renderBatched=function(renderer){if(this.batches.length){renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(var i=0,l=this.batches.length;i<l;i++){var batch=this.batches[i];batch.worldAlpha=this.worldAlpha*batch.alpha,renderer.plugins[this.pluginName].render(batch)}}},Graphics.prototype._renderDirect=function(renderer){var shader=this._resolveDirectShader(renderer),geometry=this._geometry,tint=this.tint,worldAlpha=this.worldAlpha,uniforms=shader.uniforms,drawCalls=geometry.drawCalls;uniforms.translationMatrix=this.transform.worldTransform,uniforms.tint[0]=(tint>>16&255)/255*worldAlpha,uniforms.tint[1]=(tint>>8&255)/255*worldAlpha,uniforms.tint[2]=(255&tint)/255*worldAlpha,uniforms.tint[3]=worldAlpha,renderer.shader.bind(shader),renderer.geometry.bind(geometry,shader),renderer.state.set(this.state);for(var i=0,l=drawCalls.length;i<l;i++)this._renderDrawCallDirect(renderer,geometry.drawCalls[i])},Graphics.prototype._renderDrawCallDirect=function(renderer,drawCall){for(var texArray=drawCall.texArray,type=drawCall.type,size=drawCall.size,start=drawCall.start,groupTextureCount=texArray.count,j=0;j<groupTextureCount;j++)renderer.texture.bind(texArray.elements[j],j);renderer.geometry.draw(type,size,start)},Graphics.prototype._resolveDirectShader=function(renderer){var shader=this.shader,pluginName=this.pluginName;if(!shader){if(!DEFAULT_SHADERS[pluginName]){for(var MAX_TEXTURES=renderer.plugins.batch.MAX_TEXTURES,sampleValues=new Int32Array(MAX_TEXTURES),i=0;i<MAX_TEXTURES;i++)sampleValues[i]=i;var uniforms={tint:new Float32Array([1,1,1,1]),translationMatrix:new Matrix,default:UniformGroup.from({uSamplers:sampleValues},!0)},program=renderer.plugins[pluginName]._shader.program;DEFAULT_SHADERS[pluginName]=new Shader(program,uniforms)}shader=DEFAULT_SHADERS[pluginName]}return shader},Graphics.prototype._calculateBounds=function(){this.finishPoly();var geometry=this._geometry;if(geometry.graphicsData.length){var _a=geometry.bounds,minX=_a.minX,minY=_a.minY,maxX=_a.maxX,maxY=_a.maxY;this._bounds.addFrame(this.transform,minX,minY,maxX,maxY)}},Graphics.prototype.containsPoint=function(point){return this.worldTransform.applyInverse(point,Graphics._TEMP_POINT),this._geometry.containsPoint(Graphics._TEMP_POINT)},Graphics.prototype.calculateTints=function(){if(this.batchTint!==this.tint){this.batchTint=this.tint;for(var tintRGB=hex2rgb(this.tint,temp),i=0;i<this.batches.length;i++){var batch=this.batches[i],batchTint=batch._batchRGB,color=(tintRGB[0]*batchTint[0]*255<<16)+(tintRGB[1]*batchTint[1]*255<<8)+(0|tintRGB[2]*batchTint[2]*255);batch._tintRGB=(color>>16)+(65280&color)+((255&color)<<16)}}},Graphics.prototype.calculateVertices=function(){var wtID=this.transform._worldID;if(this._transformID!==wtID){this._transformID=wtID;for(var wt=this.transform.worldTransform,a=wt.a,b=wt.b,c=wt.c,d=wt.d,tx=wt.tx,ty=wt.ty,data=this._geometry.points,vertexData=this.vertexData,count=0,i=0;i<data.length;i+=2){var x=data[i],y=data[i+1];vertexData[count++]=a*x+c*y+tx,vertexData[count++]=d*y+b*x+ty}}},Graphics.prototype.closePath=function(){var currentPath=this.currentPath;return currentPath&&(currentPath.closeStroke=!0),this},Graphics.prototype.setMatrix=function(matrix){return this._matrix=matrix,this},Graphics.prototype.beginHole=function(){return this.finishPoly(),this._holeMode=!0,this},Graphics.prototype.endHole=function(){return this.finishPoly(),this._holeMode=!1,this},Graphics.prototype.destroy=function(options){this._geometry.refCount--,0===this._geometry.refCount&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,_super.prototype.destroy.call(this,options)},Graphics._TEMP_POINT=new Point,Graphics}(Container),extendStatics$7=function(d,b){return(extendStatics$7=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};var TEXT_GRADIENT,tempPoint=new Point,indices=new Uint16Array([0,1,2,0,2,3]),Sprite=function(_super){function Sprite(texture){var _this=_super.call(this)||this;return _this._anchor=new ObservablePoint(_this._onAnchorUpdate,_this,texture?texture.defaultAnchor.x:0,texture?texture.defaultAnchor.y:0),_this._texture=null,_this._width=0,_this._height=0,_this._tint=null,_this._tintRGB=null,_this.tint=16777215,_this.blendMode=BLEND_MODES.NORMAL,_this._cachedTint=16777215,_this.uvs=null,_this.texture=texture||Texture.EMPTY,_this.vertexData=new Float32Array(8),_this.vertexTrimmedData=null,_this._transformID=-1,_this._textureID=-1,_this._transformTrimmedID=-1,_this._textureTrimmedID=-1,_this.indices=indices,_this.pluginName="batch",_this.isSprite=!0,_this._roundPixels=settings.ROUND_PIXELS,_this}return function(d,b){function __(){this.constructor=d}extendStatics$7(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}(Sprite,_super),Sprite.prototype._onTextureUpdate=function(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=sign$1(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=sign$1(this.scale.y)*this._height/this._texture.orig.height)},Sprite.prototype._onAnchorUpdate=function(){this._transformID=-1,this._transformTrimmedID=-1},Sprite.prototype.calculateVertices=function(){var texture=this._texture;if(this._transformID!==this.transform._worldID||this._textureID!==texture._updateID){this._textureID!==texture._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=texture._updateID;var wt=this.transform.worldTransform,a=wt.a,b=wt.b,c=wt.c,d=wt.d,tx=wt.tx,ty=wt.ty,vertexData=this.vertexData,trim=texture.trim,orig=texture.orig,anchor=this._anchor,w0=0,w1=0,h0=0,h1=0;if(trim?(w0=(w1=trim.x-anchor._x*orig.width)+trim.width,h0=(h1=trim.y-anchor._y*orig.height)+trim.height):(w0=(w1=-anchor._x*orig.width)+orig.width,h0=(h1=-anchor._y*orig.height)+orig.height),vertexData[0]=a*w1+c*h1+tx,vertexData[1]=d*h1+b*w1+ty,vertexData[2]=a*w0+c*h1+tx,vertexData[3]=d*h1+b*w0+ty,vertexData[4]=a*w0+c*h0+tx,vertexData[5]=d*h0+b*w0+ty,vertexData[6]=a*w1+c*h0+tx,vertexData[7]=d*h0+b*w1+ty,this._roundPixels)for(var resolution=settings.RESOLUTION,i=0;i<vertexData.length;++i)vertexData[i]=Math.round((vertexData[i]*resolution|0)/resolution)}},Sprite.prototype.calculateTrimmedVertices=function(){if(this.vertexTrimmedData){if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return}else this.vertexTrimmedData=new Float32Array(8);this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;var texture=this._texture,vertexData=this.vertexTrimmedData,orig=texture.orig,anchor=this._anchor,wt=this.transform.worldTransform,a=wt.a,b=wt.b,c=wt.c,d=wt.d,tx=wt.tx,ty=wt.ty,w1=-anchor._x*orig.width,w0=w1+orig.width,h1=-anchor._y*orig.height,h0=h1+orig.height;vertexData[0]=a*w1+c*h1+tx,vertexData[1]=d*h1+b*w1+ty,vertexData[2]=a*w0+c*h1+tx,vertexData[3]=d*h1+b*w0+ty,vertexData[4]=a*w0+c*h0+tx,vertexData[5]=d*h0+b*w0+ty,vertexData[6]=a*w1+c*h0+tx,vertexData[7]=d*h0+b*w1+ty},Sprite.prototype._render=function(renderer){this.calculateVertices(),renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]),renderer.plugins[this.pluginName].render(this)},Sprite.prototype._calculateBounds=function(){var trim=this._texture.trim,orig=this._texture.orig;!trim||trim.width===orig.width&&trim.height===orig.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))},Sprite.prototype.getLocalBounds=function(rect){return 0===this.children.length?(this._bounds.minX=this._texture.orig.width*-this._anchor._x,this._bounds.minY=this._texture.orig.height*-this._anchor._y,this._bounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._bounds.maxY=this._texture.orig.height*(1-this._anchor._y),rect||(this._localBoundsRect||(this._localBoundsRect=new Rectangle),rect=this._localBoundsRect),this._bounds.getRectangle(rect)):_super.prototype.getLocalBounds.call(this,rect)},Sprite.prototype.containsPoint=function(point){this.worldTransform.applyInverse(point,tempPoint);var width=this._texture.orig.width,height=this._texture.orig.height,x1=-width*this.anchor.x,y1=0;return tempPoint.x>=x1&&tempPoint.x<x1+width&&(y1=-height*this.anchor.y,tempPoint.y>=y1&&tempPoint.y<y1+height)},Sprite.prototype.destroy=function(options){if(_super.prototype.destroy.call(this,options),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,"boolean"==typeof options?options:options&&options.texture){var destroyBaseTexture="boolean"==typeof options?options:options&&options.baseTexture;this._texture.destroy(!!destroyBaseTexture)}this._texture=null},Sprite.from=function(source,options){return new Sprite(source instanceof Texture?source:Texture.from(source,options))},Object.defineProperty(Sprite.prototype,"roundPixels",{get:function(){return this._roundPixels},set:function(value){this._roundPixels!==value&&(this._transformID=-1),this._roundPixels=value},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"width",{get:function(){return Math.abs(this.scale.x)*this._texture.orig.width},set:function(value){var s=sign$1(this.scale.x)||1;this.scale.x=s*value/this._texture.orig.width,this._width=value},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"height",{get:function(){return Math.abs(this.scale.y)*this._texture.orig.height},set:function(value){var s=sign$1(this.scale.y)||1;this.scale.y=s*value/this._texture.orig.height,this._height=value},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"anchor",{get:function(){return this._anchor},set:function(value){this._anchor.copyFrom(value)},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"tint",{get:function(){return this._tint},set:function(value){this._tint=value,this._tintRGB=(value>>16)+(65280&value)+((255&value)<<16)},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"texture",{get:function(){return this._texture},set:function(value){this._texture!==value&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=value||Texture.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,value&&(value.baseTexture.valid?this._onTextureUpdate():value.once("update",this._onTextureUpdate,this)))},enumerable:!1,configurable:!0}),Sprite}(Container),extendStatics$8=function(d,b){return(extendStatics$8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};!function(TEXT_GRADIENT){TEXT_GRADIENT[TEXT_GRADIENT.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",TEXT_GRADIENT[TEXT_GRADIENT.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL"}(TEXT_GRADIENT||(TEXT_GRADIENT={}));var defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:TEXT_GRADIENT.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],TextStyle=function(){function TextStyle(style){this.styleID=0,this.reset(),deepCopyProperties(this,style,style)}return TextStyle.prototype.clone=function(){var clonedProperties={};return deepCopyProperties(clonedProperties,this,defaultStyle),new TextStyle(clonedProperties)},TextStyle.prototype.reset=function(){deepCopyProperties(this,defaultStyle,defaultStyle)},Object.defineProperty(TextStyle.prototype,"align",{get:function(){return this._align},set:function(align){this._align!==align&&(this._align=align,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"breakWords",{get:function(){return this._breakWords},set:function(breakWords){this._breakWords!==breakWords&&(this._breakWords=breakWords,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadow",{get:function(){return this._dropShadow},set:function(dropShadow){this._dropShadow!==dropShadow&&(this._dropShadow=dropShadow,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowAlpha",{get:function(){return this._dropShadowAlpha},set:function(dropShadowAlpha){this._dropShadowAlpha!==dropShadowAlpha&&(this._dropShadowAlpha=dropShadowAlpha,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowAngle",{get:function(){return this._dropShadowAngle},set:function(dropShadowAngle){this._dropShadowAngle!==dropShadowAngle&&(this._dropShadowAngle=dropShadowAngle,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowBlur",{get:function(){return this._dropShadowBlur},set:function(dropShadowBlur){this._dropShadowBlur!==dropShadowBlur&&(this._dropShadowBlur=dropShadowBlur,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowColor",{get:function(){return this._dropShadowColor},set:function(dropShadowColor){var outputColor=getColor(dropShadowColor);this._dropShadowColor!==outputColor&&(this._dropShadowColor=outputColor,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowDistance",{get:function(){return this._dropShadowDistance},set:function(dropShadowDistance){this._dropShadowDistance!==dropShadowDistance&&(this._dropShadowDistance=dropShadowDistance,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fill",{get:function(){return this._fill},set:function(fill){var outputColor=getColor(fill);this._fill!==outputColor&&(this._fill=outputColor,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fillGradientType",{get:function(){return this._fillGradientType},set:function(fillGradientType){this._fillGradientType!==fillGradientType&&(this._fillGradientType=fillGradientType,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fillGradientStops",{get:function(){return this._fillGradientStops},set:function(fillGradientStops){(function(array1,array2){if(!Array.isArray(array1)||!Array.isArray(array2))return!1;if(array1.length!==array2.length)return!1;for(var i=0;i<array1.length;++i)if(array1[i]!==array2[i])return!1;return!0})(this._fillGradientStops,fillGradientStops)||(this._fillGradientStops=fillGradientStops,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(fontFamily){this.fontFamily!==fontFamily&&(this._fontFamily=fontFamily,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontSize",{get:function(){return this._fontSize},set:function(fontSize){this._fontSize!==fontSize&&(this._fontSize=fontSize,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(fontStyle){this._fontStyle!==fontStyle&&(this._fontStyle=fontStyle,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontVariant",{get:function(){return this._fontVariant},set:function(fontVariant){this._fontVariant!==fontVariant&&(this._fontVariant=fontVariant,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(fontWeight){this._fontWeight!==fontWeight&&(this._fontWeight=fontWeight,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(letterSpacing){this._letterSpacing!==letterSpacing&&(this._letterSpacing=letterSpacing,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"lineHeight",{get:function(){return this._lineHeight},set:function(lineHeight){this._lineHeight!==lineHeight&&(this._lineHeight=lineHeight,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"leading",{get:function(){return this._leading},set:function(leading){this._leading!==leading&&(this._leading=leading,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"lineJoin",{get:function(){return this._lineJoin},set:function(lineJoin){this._lineJoin!==lineJoin&&(this._lineJoin=lineJoin,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"miterLimit",{get:function(){return this._miterLimit},set:function(miterLimit){this._miterLimit!==miterLimit&&(this._miterLimit=miterLimit,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"padding",{get:function(){return this._padding},set:function(padding){this._padding!==padding&&(this._padding=padding,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"stroke",{get:function(){return this._stroke},set:function(stroke){var outputColor=getColor(stroke);this._stroke!==outputColor&&(this._stroke=outputColor,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"strokeThickness",{get:function(){return this._strokeThickness},set:function(strokeThickness){this._strokeThickness!==strokeThickness&&(this._strokeThickness=strokeThickness,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"textBaseline",{get:function(){return this._textBaseline},set:function(textBaseline){this._textBaseline!==textBaseline&&(this._textBaseline=textBaseline,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"trim",{get:function(){return this._trim},set:function(trim){this._trim!==trim&&(this._trim=trim,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"whiteSpace",{get:function(){return this._whiteSpace},set:function(whiteSpace){this._whiteSpace!==whiteSpace&&(this._whiteSpace=whiteSpace,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"wordWrap",{get:function(){return this._wordWrap},set:function(wordWrap){this._wordWrap!==wordWrap&&(this._wordWrap=wordWrap,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"wordWrapWidth",{get:function(){return this._wordWrapWidth},set:function(wordWrapWidth){this._wordWrapWidth!==wordWrapWidth&&(this._wordWrapWidth=wordWrapWidth,this.styleID++)},enumerable:!1,configurable:!0}),TextStyle.prototype.toFontString=function(){var fontSizeString="number"==typeof this.fontSize?this.fontSize+"px":this.fontSize,fontFamilies=this.fontFamily;Array.isArray(this.fontFamily)||(fontFamilies=this.fontFamily.split(","));for(var i=fontFamilies.length-1;i>=0;i--){var fontFamily=fontFamilies[i].trim();!/([\"\'])[^\'\"]+\1/.test(fontFamily)&&genericFontFamilies.indexOf(fontFamily)<0&&(fontFamily='"'+fontFamily+'"'),fontFamilies[i]=fontFamily}return this.fontStyle+" "+this.fontVariant+" "+this.fontWeight+" "+fontSizeString+" "+fontFamilies.join(",")},TextStyle}();function getSingleColor(color){return"number"==typeof color?hex2string(color):("string"==typeof color&&0===color.indexOf("0x")&&(color=color.replace("0x","#")),color)}function getColor(color){if(Array.isArray(color)){for(var i=0;i<color.length;++i)color[i]=getSingleColor(color[i]);return color}return getSingleColor(color)}function deepCopyProperties(target,source,propertyObj){for(var prop in propertyObj)Array.isArray(source[prop])?target[prop]=source[prop].slice():target[prop]=source[prop]}var TextMetrics=function(){function TextMetrics(text,style,width,height,lines,lineWidths,lineHeight,maxLineWidth,fontProperties){this.text=text,this.style=style,this.width=width,this.height=height,this.lines=lines,this.lineWidths=lineWidths,this.lineHeight=lineHeight,this.maxLineWidth=maxLineWidth,this.fontProperties=fontProperties}return TextMetrics.measureText=function(text,style,wordWrap,canvas){void 0===canvas&&(canvas=TextMetrics._canvas),wordWrap=null==wordWrap?style.wordWrap:wordWrap;var font=style.toFontString(),fontProperties=TextMetrics.measureFont(font);0===fontProperties.fontSize&&(fontProperties.fontSize=style.fontSize,fontProperties.ascent=style.fontSize);var context=canvas.getContext("2d");context.font=font;for(var lines=(wordWrap?TextMetrics.wordWrap(text,style,canvas):text).split(/(?:\r\n|\r|\n)/),lineWidths=new Array(lines.length),maxLineWidth=0,i=0;i<lines.length;i++){var lineWidth=context.measureText(lines[i]).width+(lines[i].length-1)*style.letterSpacing;lineWidths[i]=lineWidth,maxLineWidth=Math.max(maxLineWidth,lineWidth)}var width=maxLineWidth+style.strokeThickness;style.dropShadow&&(width+=style.dropShadowDistance);var lineHeight=style.lineHeight||fontProperties.fontSize+style.strokeThickness,height=Math.max(lineHeight,fontProperties.fontSize+style.strokeThickness)+(lines.length-1)*(lineHeight+style.leading);return style.dropShadow&&(height+=style.dropShadowDistance),new TextMetrics(text,style,width,height,lines,lineWidths,lineHeight+style.leading,maxLineWidth,fontProperties)},TextMetrics.wordWrap=function(text,style,canvas){void 0===canvas&&(canvas=TextMetrics._canvas);for(var context=canvas.getContext("2d"),width=0,line="",lines="",cache=Object.create(null),letterSpacing=style.letterSpacing,whiteSpace=style.whiteSpace,collapseSpaces=TextMetrics.collapseSpaces(whiteSpace),collapseNewlines=TextMetrics.collapseNewlines(whiteSpace),canPrependSpaces=!collapseSpaces,wordWrapWidth=style.wordWrapWidth+letterSpacing,tokens=TextMetrics.tokenize(text),i=0;i<tokens.length;i++){var token=tokens[i];if(TextMetrics.isNewline(token)){if(!collapseNewlines){lines+=TextMetrics.addLine(line),canPrependSpaces=!collapseSpaces,line="",width=0;continue}token=" "}if(collapseSpaces){var currIsBreakingSpace=TextMetrics.isBreakingSpace(token),lastIsBreakingSpace=TextMetrics.isBreakingSpace(line[line.length-1]);if(currIsBreakingSpace&&lastIsBreakingSpace)continue}var tokenWidth=TextMetrics.getFromCache(token,letterSpacing,cache,context);if(tokenWidth>wordWrapWidth)if(""!==line&&(lines+=TextMetrics.addLine(line),line="",width=0),TextMetrics.canBreakWords(token,style.breakWords))for(var characters=TextMetrics.wordWrapSplit(token),j=0;j<characters.length;j++){for(var char=characters[j],k=1;characters[j+k];){var nextChar=characters[j+k],lastChar=char[char.length-1];if(TextMetrics.canBreakChars(lastChar,nextChar,token,j,style.breakWords))break;char+=nextChar,k++}j+=char.length-1;var characterWidth=TextMetrics.getFromCache(char,letterSpacing,cache,context);characterWidth+width>wordWrapWidth&&(lines+=TextMetrics.addLine(line),canPrependSpaces=!1,line="",width=0),line+=char,width+=characterWidth}else{line.length>0&&(lines+=TextMetrics.addLine(line),line="",width=0);var isLastToken=i===tokens.length-1;lines+=TextMetrics.addLine(token,!isLastToken),canPrependSpaces=!1,line="",width=0}else tokenWidth+width>wordWrapWidth&&(canPrependSpaces=!1,lines+=TextMetrics.addLine(line),line="",width=0),(line.length>0||!TextMetrics.isBreakingSpace(token)||canPrependSpaces)&&(line+=token,width+=tokenWidth)}return lines+=TextMetrics.addLine(line,!1)},TextMetrics.addLine=function(line,newLine){return void 0===newLine&&(newLine=!0),line=TextMetrics.trimRight(line),line=newLine?line+"\n":line},TextMetrics.getFromCache=function(key,letterSpacing,cache,context){var width=cache[key];if("number"!=typeof width){var spacing=key.length*letterSpacing;width=context.measureText(key).width+spacing,cache[key]=width}return width},TextMetrics.collapseSpaces=function(whiteSpace){return"normal"===whiteSpace||"pre-line"===whiteSpace},TextMetrics.collapseNewlines=function(whiteSpace){return"normal"===whiteSpace},TextMetrics.trimRight=function(text){if("string"!=typeof text)return"";for(var i=text.length-1;i>=0;i--){var char=text[i];if(!TextMetrics.isBreakingSpace(char))break;text=text.slice(0,-1)}return text},TextMetrics.isNewline=function(char){return"string"==typeof char&&TextMetrics._newlines.indexOf(char.charCodeAt(0))>=0},TextMetrics.isBreakingSpace=function(char){return"string"==typeof char&&TextMetrics._breakingSpaces.indexOf(char.charCodeAt(0))>=0},TextMetrics.tokenize=function(text){var tokens=[],token="";if("string"!=typeof text)return tokens;for(var i=0;i<text.length;i++){var char=text[i];TextMetrics.isBreakingSpace(char)||TextMetrics.isNewline(char)?(""!==token&&(tokens.push(token),token=""),tokens.push(char)):token+=char}return""!==token&&tokens.push(token),tokens},TextMetrics.canBreakWords=function(_token,breakWords){return breakWords},TextMetrics.canBreakChars=function(_char,_nextChar,_token,_index,_breakWords){return!0},TextMetrics.wordWrapSplit=function(token){return token.split("")},TextMetrics.measureFont=function(font){if(TextMetrics._fonts[font])return TextMetrics._fonts[font];var properties={ascent:0,descent:0,fontSize:0},canvas=TextMetrics._canvas,context=TextMetrics._context;context.font=font;var metricsString=TextMetrics.METRICS_STRING+TextMetrics.BASELINE_SYMBOL,width=Math.ceil(context.measureText(metricsString).width),baseline=Math.ceil(context.measureText(TextMetrics.BASELINE_SYMBOL).width),height=2*baseline;baseline=baseline*TextMetrics.BASELINE_MULTIPLIER|0,canvas.width=width,canvas.height=height,context.fillStyle="#f00",context.fillRect(0,0,width,height),context.font=font,context.textBaseline="alphabetic",context.fillStyle="#000",context.fillText(metricsString,0,baseline);var imagedata=context.getImageData(0,0,width,height).data,pixels=imagedata.length,line=4*width,i=0,idx=0,stop=!1;for(i=0;i<baseline;++i){for(var j=0;j<line;j+=4)if(255!==imagedata[idx+j]){stop=!0;break}if(stop)break;idx+=line}for(properties.ascent=baseline-i,idx=pixels-line,stop=!1,i=height;i>baseline;--i){for(j=0;j<line;j+=4)if(255!==imagedata[idx+j]){stop=!0;break}if(stop)break;idx-=line}return properties.descent=i-baseline,properties.fontSize=properties.ascent+properties.descent,TextMetrics._fonts[font]=properties,properties},TextMetrics.clearMetrics=function(font){void 0===font&&(font=""),font?delete TextMetrics._fonts[font]:TextMetrics._fonts={}},TextMetrics}(),canvas=function(){try{var c=new OffscreenCanvas(0,0),context=c.getContext("2d");return context&&context.measureText?c:document.createElement("canvas")}catch(ex){return document.createElement("canvas")}}();canvas.width=canvas.height=10,TextMetrics._canvas=canvas,TextMetrics._context=canvas.getContext("2d"),TextMetrics._fonts={},TextMetrics.METRICS_STRING="|ÉqÅ",TextMetrics.BASELINE_SYMBOL="M",TextMetrics.BASELINE_MULTIPLIER=1.4,TextMetrics._newlines=[10,13],TextMetrics._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];var defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Text=function(_super){function Text(text,style,canvas){var _this=this,ownCanvas=!1;canvas||(canvas=document.createElement("canvas"),ownCanvas=!0),canvas.width=3,canvas.height=3;var texture=Texture.from(canvas);return texture.orig=new Rectangle,texture.trim=new Rectangle,(_this=_super.call(this,texture)||this)._ownCanvas=ownCanvas,_this.canvas=canvas,_this.context=_this.canvas.getContext("2d"),_this._resolution=settings.RESOLUTION,_this._autoResolution=!0,_this._text=null,_this._style=null,_this._styleListener=null,_this._font="",_this.text=text,_this.style=style,_this.localStyleID=-1,_this}return function(d,b){function __(){this.constructor=d}extendStatics$8(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}(Text,_super),Text.prototype.updateText=function(respectDirty){var style=this._style;if(this.localStyleID!==style.styleID&&(this.dirty=!0,this.localStyleID=style.styleID),this.dirty||!respectDirty){this._font=this._style.toFontString();var linePositionX,linePositionY,context=this.context,measured=TextMetrics.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),width=measured.width,height=measured.height,lines=measured.lines,lineHeight=measured.lineHeight,lineWidths=measured.lineWidths,maxLineWidth=measured.maxLineWidth,fontProperties=measured.fontProperties;this.canvas.width=Math.ceil((Math.max(1,width)+2*style.padding)*this._resolution),this.canvas.height=Math.ceil((Math.max(1,height)+2*style.padding)*this._resolution),context.scale(this._resolution,this._resolution),context.clearRect(0,0,this.canvas.width,this.canvas.height),context.font=this._font,context.lineWidth=style.strokeThickness,context.textBaseline=style.textBaseline,context.lineJoin=style.lineJoin,context.miterLimit=style.miterLimit;for(var passesCount=style.dropShadow?2:1,i=0;i<passesCount;++i){var isShadowPass=style.dropShadow&&0===i,dsOffsetText=isShadowPass?Math.ceil(Math.max(1,height)+2*style.padding):0,dsOffsetShadow=dsOffsetText*this._resolution;if(isShadowPass){context.fillStyle="black",context.strokeStyle="black";var dropShadowColor=style.dropShadowColor,rgb=hex2rgb("number"==typeof dropShadowColor?dropShadowColor:string2hex(dropShadowColor));context.shadowColor="rgba("+255*rgb[0]+","+255*rgb[1]+","+255*rgb[2]+","+style.dropShadowAlpha+")",context.shadowBlur=style.dropShadowBlur,context.shadowOffsetX=Math.cos(style.dropShadowAngle)*style.dropShadowDistance,context.shadowOffsetY=Math.sin(style.dropShadowAngle)*style.dropShadowDistance+dsOffsetShadow}else context.fillStyle=this._generateFillStyle(style,lines,measured),context.strokeStyle=style.stroke,context.shadowColor="black",context.shadowBlur=0,context.shadowOffsetX=0,context.shadowOffsetY=0;for(var i_1=0;i_1<lines.length;i_1++)linePositionX=style.strokeThickness/2,linePositionY=style.strokeThickness/2+i_1*lineHeight+fontProperties.ascent,"right"===style.align?linePositionX+=maxLineWidth-lineWidths[i_1]:"center"===style.align&&(linePositionX+=(maxLineWidth-lineWidths[i_1])/2),style.stroke&&style.strokeThickness&&this.drawLetterSpacing(lines[i_1],linePositionX+style.padding,linePositionY+style.padding-dsOffsetText,!0),style.fill&&this.drawLetterSpacing(lines[i_1],linePositionX+style.padding,linePositionY+style.padding-dsOffsetText)}this.updateTexture()}},Text.prototype.drawLetterSpacing=function(text,x,y,isStroke){void 0===isStroke&&(isStroke=!1);var letterSpacing=this._style.letterSpacing;if(0!==letterSpacing)for(var currentPosition=x,stringArray=Array.from?Array.from(text):text.split(""),previousWidth=this.context.measureText(text).width,currentWidth=0,i=0;i<stringArray.length;++i){var currentChar=stringArray[i];isStroke?this.context.strokeText(currentChar,currentPosition,y):this.context.fillText(currentChar,currentPosition,y),currentPosition+=previousWidth-(currentWidth=this.context.measureText(text.substring(i+1)).width)+letterSpacing,previousWidth=currentWidth}else isStroke?this.context.strokeText(text,x,y):this.context.fillText(text,x,y)},Text.prototype.updateTexture=function(){var canvas=this.canvas;if(this._style.trim){var trimmed=function(canvas){var i,x,y,width=canvas.width,height=canvas.height,context=canvas.getContext("2d"),pixels=context.getImageData(0,0,width,height).data,len=pixels.length,bound={top:null,left:null,right:null,bottom:null},data=null;for(i=0;i<len;i+=4)0!==pixels[i+3]&&(x=i/4%width,y=~~(i/4/width),null===bound.top&&(bound.top=y),(null===bound.left||x<bound.left)&&(bound.left=x),(null===bound.right||bound.right<x)&&(bound.right=x+1),(null===bound.bottom||bound.bottom<y)&&(bound.bottom=y));return null!==bound.top&&(width=bound.right-bound.left,height=bound.bottom-bound.top+1,data=context.getImageData(bound.left,bound.top,width,height)),{height:height,width:width,data:data}}(canvas);trimmed.data&&(canvas.width=trimmed.width,canvas.height=trimmed.height,this.context.putImageData(trimmed.data,0,0))}var texture=this._texture,style=this._style,padding=style.trim?0:style.padding,baseTexture=texture.baseTexture;texture.trim.width=texture._frame.width=Math.ceil(canvas.width/this._resolution),texture.trim.height=texture._frame.height=Math.ceil(canvas.height/this._resolution),texture.trim.x=-padding,texture.trim.y=-padding,texture.orig.width=texture._frame.width-2*padding,texture.orig.height=texture._frame.height-2*padding,this._onTextureUpdate(),baseTexture.setRealSize(canvas.width,canvas.height,this._resolution),this._recursivePostUpdateTransform(),this.dirty=!1},Text.prototype._render=function(renderer){this._autoResolution&&this._resolution!==renderer.resolution&&(this._resolution=renderer.resolution,this.dirty=!0),this.updateText(!0),_super.prototype._render.call(this,renderer)},Text.prototype.getLocalBounds=function(rect){return this.updateText(!0),_super.prototype.getLocalBounds.call(this,rect)},Text.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},Text.prototype._generateFillStyle=function(style,lines,metrics){var gradient,fillStyle=style.fill;if(!Array.isArray(fillStyle))return fillStyle;if(1===fillStyle.length)return fillStyle[0];var dropShadowCorrection=style.dropShadow?style.dropShadowDistance:0,padding=style.padding||0,width=Math.ceil(this.canvas.width/this._resolution)-dropShadowCorrection-2*padding,height=Math.ceil(this.canvas.height/this._resolution)-dropShadowCorrection-2*padding,fill=fillStyle.slice(),fillGradientStops=style.fillGradientStops.slice();if(!fillGradientStops.length)for(var lengthPlus1=fill.length+1,i=1;i<lengthPlus1;++i)fillGradientStops.push(i/lengthPlus1);if(fill.unshift(fillStyle[0]),fillGradientStops.unshift(0),fill.push(fillStyle[fillStyle.length-1]),fillGradientStops.push(1),style.fillGradientType===TEXT_GRADIENT.LINEAR_VERTICAL){gradient=this.context.createLinearGradient(width/2,padding,width/2,height+padding);var lastIterationStop=0,gradStopLineHeight=(metrics.fontProperties.fontSize+style.strokeThickness)/height;for(i=0;i<lines.length;i++)for(var thisLineTop=metrics.lineHeight*i,j=0;j<fill.length;j++){var globalStop=thisLineTop/height+("number"==typeof fillGradientStops[j]?fillGradientStops[j]:j/fill.length)*gradStopLineHeight,clampedStop=Math.max(lastIterationStop,globalStop);clampedStop=Math.min(clampedStop,1),gradient.addColorStop(clampedStop,fill[j]),lastIterationStop=clampedStop}}else{gradient=this.context.createLinearGradient(padding,height/2,width+padding,height/2);var totalIterations=fill.length+1,currentIteration=1;for(i=0;i<fill.length;i++){var stop=void 0;stop="number"==typeof fillGradientStops[i]?fillGradientStops[i]:currentIteration/totalIterations,gradient.addColorStop(stop,fill[i]),currentIteration++}}return gradient},Text.prototype.destroy=function(options){"boolean"==typeof options&&(options={children:options}),options=Object.assign({},defaultDestroyOptions,options),_super.prototype.destroy.call(this,options),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null},Object.defineProperty(Text.prototype,"width",{get:function(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width},set:function(value){this.updateText(!0);var s=sign$1(this.scale.x)||1;this.scale.x=s*value/this._texture.orig.width,this._width=value},enumerable:!1,configurable:!0}),Object.defineProperty(Text.prototype,"height",{get:function(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height},set:function(value){this.updateText(!0);var s=sign$1(this.scale.y)||1;this.scale.y=s*value/this._texture.orig.height,this._height=value},enumerable:!1,configurable:!0}),Object.defineProperty(Text.prototype,"style",{get:function(){return this._style},set:function(style){style=style||{},this._style=style instanceof TextStyle?style:new TextStyle(style),this.localStyleID=-1,this.dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(Text.prototype,"text",{get:function(){return this._text},set:function(text){text=String(null==text?"":text),this._text!==text&&(this._text=text,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(Text.prototype,"resolution",{get:function(){return this._resolution},set:function(value){this._autoResolution=!1,this._resolution!==value&&(this._resolution=value,this.dirty=!0)},enumerable:!1,configurable:!0}),Text}(Sprite);
|
|
162
|
+
***************************************************************************** */function __extends$5(d,b){function __(){this.constructor=d}extendStatics$5(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}!function(_super){function ParticleContainer(maxSize,properties,batchSize,autoResize){void 0===maxSize&&(maxSize=1500),void 0===batchSize&&(batchSize=16384),void 0===autoResize&&(autoResize=!1);var _this=_super.call(this)||this;return batchSize>16384&&(batchSize=16384),_this._properties=[!1,!0,!1,!1,!1],_this._maxSize=maxSize,_this._batchSize=batchSize,_this._buffers=null,_this._bufferUpdateIDs=[],_this._updateID=0,_this.interactiveChildren=!1,_this.blendMode=BLEND_MODES.NORMAL,_this.autoResize=autoResize,_this.roundPixels=!0,_this.baseTexture=null,_this.setProperties(properties),_this._tint=0,_this.tintRgb=new Float32Array(4),_this.tint=16777215,_this}__extends$5(ParticleContainer,_super),ParticleContainer.prototype.setProperties=function(properties){properties&&(this._properties[0]="vertices"in properties||"scale"in properties?!!properties.vertices||!!properties.scale:this._properties[0],this._properties[1]="position"in properties?!!properties.position:this._properties[1],this._properties[2]="rotation"in properties?!!properties.rotation:this._properties[2],this._properties[3]="uvs"in properties?!!properties.uvs:this._properties[3],this._properties[4]="tint"in properties||"alpha"in properties?!!properties.tint||!!properties.alpha:this._properties[4])},ParticleContainer.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},Object.defineProperty(ParticleContainer.prototype,"tint",{get:function(){return this._tint},set:function(value){this._tint=value,hex2rgb(value,this.tintRgb)},enumerable:!1,configurable:!0}),ParticleContainer.prototype.render=function(renderer){var _this=this;this.visible&&!(this.worldAlpha<=0)&&this.children.length&&this.renderable&&(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",(function(){return _this.onChildrenChange(0)}))),renderer.batch.setObjectRenderer(renderer.plugins.particle),renderer.plugins.particle.render(this))},ParticleContainer.prototype.onChildrenChange=function(smallestChildIndex){for(var bufferIndex=Math.floor(smallestChildIndex/this._batchSize);this._bufferUpdateIDs.length<bufferIndex;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[bufferIndex]=++this._updateID},ParticleContainer.prototype.dispose=function(){if(this._buffers){for(var i=0;i<this._buffers.length;++i)this._buffers[i].destroy();this._buffers=null}},ParticleContainer.prototype.destroy=function(options){_super.prototype.destroy.call(this,options),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null}}(Container);var LINE_JOIN,LINE_CAP,ParticleBuffer=function(){function ParticleBuffer(properties,dynamicPropertyFlags,size){this.geometry=new Geometry,this.indexBuffer=null,this.size=size,this.dynamicProperties=[],this.staticProperties=[];for(var i=0;i<properties.length;++i){var property=properties[i];property={attributeName:property.attributeName,size:property.size,uploadFunction:property.uploadFunction,type:property.type||TYPES.FLOAT,offset:property.offset},dynamicPropertyFlags[i]?this.dynamicProperties.push(property):this.staticProperties.push(property)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}return ParticleBuffer.prototype.initBuffers=function(){var geometry=this.geometry,dynamicOffset=0;this.indexBuffer=new Buffer(function(size,outBuffer){void 0===outBuffer&&(outBuffer=null);var totalIndices=6*size;if((outBuffer=outBuffer||new Uint16Array(totalIndices)).length!==totalIndices)throw new Error("Out buffer length is incorrect, got "+outBuffer.length+" and expected "+totalIndices);for(var i=0,j=0;i<totalIndices;i+=6,j+=4)outBuffer[i+0]=j+0,outBuffer[i+1]=j+1,outBuffer[i+2]=j+2,outBuffer[i+3]=j+0,outBuffer[i+4]=j+2,outBuffer[i+5]=j+3;return outBuffer}(this.size),!0,!0),geometry.addIndex(this.indexBuffer),this.dynamicStride=0;for(var i=0;i<this.dynamicProperties.length;++i){(property=this.dynamicProperties[i]).offset=dynamicOffset,dynamicOffset+=property.size,this.dynamicStride+=property.size}var dynBuffer=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(dynBuffer),this.dynamicDataUint32=new Uint32Array(dynBuffer),this.dynamicBuffer=new Buffer(this.dynamicData,!1,!1);var staticOffset=0;this.staticStride=0;for(i=0;i<this.staticProperties.length;++i){(property=this.staticProperties[i]).offset=staticOffset,staticOffset+=property.size,this.staticStride+=property.size}var statBuffer=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(statBuffer),this.staticDataUint32=new Uint32Array(statBuffer),this.staticBuffer=new Buffer(this.staticData,!0,!1);for(i=0;i<this.dynamicProperties.length;++i){var property=this.dynamicProperties[i];geometry.addAttribute(property.attributeName,this.dynamicBuffer,0,property.type===TYPES.UNSIGNED_BYTE,property.type,4*this.dynamicStride,4*property.offset)}for(i=0;i<this.staticProperties.length;++i){property=this.staticProperties[i];geometry.addAttribute(property.attributeName,this.staticBuffer,0,property.type===TYPES.UNSIGNED_BYTE,property.type,4*this.staticStride,4*property.offset)}},ParticleBuffer.prototype.uploadDynamic=function(children,startIndex,amount){for(var i=0;i<this.dynamicProperties.length;i++){var property=this.dynamicProperties[i];property.uploadFunction(children,startIndex,amount,property.type===TYPES.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,property.offset)}this.dynamicBuffer._updateID++},ParticleBuffer.prototype.uploadStatic=function(children,startIndex,amount){for(var i=0;i<this.staticProperties.length;i++){var property=this.staticProperties[i];property.uploadFunction(children,startIndex,amount,property.type===TYPES.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,property.offset)}this.staticBuffer._updateID++},ParticleBuffer.prototype.destroy=function(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()},ParticleBuffer}(),ParticleRenderer=function(_super){function ParticleRenderer(renderer){var _this=_super.call(this,renderer)||this;return _this.shader=null,_this.properties=null,_this.tempMatrix=new Matrix,_this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:_this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:_this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:_this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:_this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:TYPES.UNSIGNED_BYTE,uploadFunction:_this.uploadTint,offset:0}],_this.shader=Shader.from("attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nattribute vec2 aPositionCoord;\nattribute float aRotation;\n\nuniform mat3 translationMatrix;\nuniform vec4 uColor;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void){\n float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);\n float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);\n\n vec2 v = vec2(x, y);\n v = v + aPositionCoord;\n\n gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vColor = aColor * uColor;\n}\n","varying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n vec4 color = texture2D(uSampler, vTextureCoord) * vColor;\n gl_FragColor = color;\n}",{}),_this.state=State.for2d(),_this}return __extends$5(ParticleRenderer,_super),ParticleRenderer.prototype.render=function(container){var children=container.children,maxSize=container._maxSize,batchSize=container._batchSize,renderer=this.renderer,totalChildren=children.length;if(0!==totalChildren){totalChildren>maxSize&&!container.autoResize&&(totalChildren=maxSize);var buffers=container._buffers;buffers||(buffers=container._buffers=this.generateBuffers(container));var baseTexture=children[0]._texture.baseTexture;this.state.blendMode=correctBlendMode(container.blendMode,baseTexture.alphaMode),renderer.state.set(this.state);var gl=renderer.gl,m=container.worldTransform.copyTo(this.tempMatrix);m.prepend(renderer.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=m.toArray(!0),this.shader.uniforms.uColor=function(rgb,alpha,out,premultiply){return out=out||new Float32Array(4),premultiply||void 0===premultiply?(out[0]=rgb[0]*alpha,out[1]=rgb[1]*alpha,out[2]=rgb[2]*alpha):(out[0]=rgb[0],out[1]=rgb[1],out[2]=rgb[2]),out[3]=alpha,out}(container.tintRgb,container.worldAlpha,this.shader.uniforms.uColor,baseTexture.alphaMode),this.shader.uniforms.uSampler=baseTexture,this.renderer.shader.bind(this.shader);for(var updateStatic=!1,i=0,j=0;i<totalChildren;i+=batchSize,j+=1){var amount=totalChildren-i;amount>batchSize&&(amount=batchSize),j>=buffers.length&&buffers.push(this._generateOneMoreBuffer(container));var buffer=buffers[j];buffer.uploadDynamic(children,i,amount);var bid=container._bufferUpdateIDs[j]||0;(updateStatic=updateStatic||buffer._updateID<bid)&&(buffer._updateID=container._updateID,buffer.uploadStatic(children,i,amount)),renderer.geometry.bind(buffer.geometry),gl.drawElements(gl.TRIANGLES,6*amount,gl.UNSIGNED_SHORT,0)}}},ParticleRenderer.prototype.generateBuffers=function(container){for(var buffers=[],size=container._maxSize,batchSize=container._batchSize,dynamicPropertyFlags=container._properties,i=0;i<size;i+=batchSize)buffers.push(new ParticleBuffer(this.properties,dynamicPropertyFlags,batchSize));return buffers},ParticleRenderer.prototype._generateOneMoreBuffer=function(container){var batchSize=container._batchSize,dynamicPropertyFlags=container._properties;return new ParticleBuffer(this.properties,dynamicPropertyFlags,batchSize)},ParticleRenderer.prototype.uploadVertices=function(children,startIndex,amount,array,stride,offset){for(var w0=0,w1=0,h0=0,h1=0,i=0;i<amount;++i){var sprite=children[startIndex+i],texture=sprite._texture,sx=sprite.scale.x,sy=sprite.scale.y,trim=texture.trim,orig=texture.orig;trim?(w0=(w1=trim.x-sprite.anchor.x*orig.width)+trim.width,h0=(h1=trim.y-sprite.anchor.y*orig.height)+trim.height):(w0=orig.width*(1-sprite.anchor.x),w1=orig.width*-sprite.anchor.x,h0=orig.height*(1-sprite.anchor.y),h1=orig.height*-sprite.anchor.y),array[offset]=w1*sx,array[offset+1]=h1*sy,array[offset+stride]=w0*sx,array[offset+stride+1]=h1*sy,array[offset+2*stride]=w0*sx,array[offset+2*stride+1]=h0*sy,array[offset+3*stride]=w1*sx,array[offset+3*stride+1]=h0*sy,offset+=4*stride}},ParticleRenderer.prototype.uploadPosition=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;i++){var spritePosition=children[startIndex+i].position;array[offset]=spritePosition.x,array[offset+1]=spritePosition.y,array[offset+stride]=spritePosition.x,array[offset+stride+1]=spritePosition.y,array[offset+2*stride]=spritePosition.x,array[offset+2*stride+1]=spritePosition.y,array[offset+3*stride]=spritePosition.x,array[offset+3*stride+1]=spritePosition.y,offset+=4*stride}},ParticleRenderer.prototype.uploadRotation=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;i++){var spriteRotation=children[startIndex+i].rotation;array[offset]=spriteRotation,array[offset+stride]=spriteRotation,array[offset+2*stride]=spriteRotation,array[offset+3*stride]=spriteRotation,offset+=4*stride}},ParticleRenderer.prototype.uploadUvs=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;++i){var textureUvs=children[startIndex+i]._texture._uvs;textureUvs?(array[offset]=textureUvs.x0,array[offset+1]=textureUvs.y0,array[offset+stride]=textureUvs.x1,array[offset+stride+1]=textureUvs.y1,array[offset+2*stride]=textureUvs.x2,array[offset+2*stride+1]=textureUvs.y2,array[offset+3*stride]=textureUvs.x3,array[offset+3*stride+1]=textureUvs.y3,offset+=4*stride):(array[offset]=0,array[offset+1]=0,array[offset+stride]=0,array[offset+stride+1]=0,array[offset+2*stride]=0,array[offset+2*stride+1]=0,array[offset+3*stride]=0,array[offset+3*stride+1]=0,offset+=4*stride)}},ParticleRenderer.prototype.uploadTint=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;++i){var sprite=children[startIndex+i],premultiplied=sprite._texture.baseTexture.alphaMode>0,alpha=sprite.alpha,argb=alpha<1&&premultiplied?premultiplyTint(sprite._tintRGB,alpha):sprite._tintRGB+(255*alpha<<24);array[offset]=argb,array[offset+stride]=argb,array[offset+2*stride]=argb,array[offset+3*stride]=argb,offset+=4*stride}},ParticleRenderer.prototype.destroy=function(){_super.prototype.destroy.call(this),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null},ParticleRenderer}(ObjectRenderer);!function(LINE_JOIN){LINE_JOIN.MITER="miter",LINE_JOIN.BEVEL="bevel",LINE_JOIN.ROUND="round"}(LINE_JOIN||(LINE_JOIN={})),function(LINE_CAP){LINE_CAP.BUTT="butt",LINE_CAP.ROUND="round",LINE_CAP.SQUARE="square"}(LINE_CAP||(LINE_CAP={}));var GRAPHICS_CURVES={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount:function(length,defaultSegments){if(void 0===defaultSegments&&(defaultSegments=20),!this.adaptive||!length||isNaN(length))return defaultSegments;var result=Math.ceil(length/this.maxLength);return result<this.minSegments?result=this.minSegments:result>this.maxSegments&&(result=this.maxSegments),result}},FillStyle=function(){function FillStyle(){this.color=16777215,this.alpha=1,this.texture=Texture.WHITE,this.matrix=null,this.visible=!1,this.reset()}return FillStyle.prototype.clone=function(){var obj=new FillStyle;return obj.color=this.color,obj.alpha=this.alpha,obj.texture=this.texture,obj.matrix=this.matrix,obj.visible=this.visible,obj},FillStyle.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=Texture.WHITE,this.matrix=null,this.visible=!1},FillStyle.prototype.destroy=function(){this.texture=null,this.matrix=null},FillStyle}(),extendStatics$6=function(d,b){return(extendStatics$6=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};function __extends$6(d,b){function __(){this.constructor=d}extendStatics$6(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}var buildPoly={build:function(graphicsData){graphicsData.points=graphicsData.shape.points.slice()},triangulate:function(graphicsData,graphicsGeometry){var points=graphicsData.points,holes=graphicsData.holes,verts=graphicsGeometry.points,indices=graphicsGeometry.indices;if(points.length>=6){for(var holeArray=[],i=0;i<holes.length;i++){var hole=holes[i];holeArray.push(points.length/2),points=points.concat(hole.points)}var triangles=earcut_1(points,holeArray,2);if(!triangles)return;var vertPos=verts.length/2;for(i=0;i<triangles.length;i+=3)indices.push(triangles[i]+vertPos),indices.push(triangles[i+1]+vertPos),indices.push(triangles[i+2]+vertPos);for(i=0;i<points.length;i++)verts.push(points[i])}}},buildCircle={build:function(graphicsData){var width,height,circleData=graphicsData.shape,points=graphicsData.points,x=circleData.x,y=circleData.y;if(points.length=0,graphicsData.type===SHAPES.CIRC)width=circleData.radius,height=circleData.radius;else{var ellipseData=graphicsData.shape;width=ellipseData.width,height=ellipseData.height}if(0!==width&&0!==height){var totalSegs=Math.floor(30*Math.sqrt(circleData.radius))||Math.floor(15*Math.sqrt(width+height));totalSegs/=2.3;for(var seg=2*Math.PI/totalSegs,i=0;i<totalSegs-.5;i++)points.push(x+Math.sin(-seg*i)*width,y+Math.cos(-seg*i)*height);points.push(points[0],points[1])}},triangulate:function(graphicsData,graphicsGeometry){var points=graphicsData.points,verts=graphicsGeometry.points,indices=graphicsGeometry.indices,vertPos=verts.length/2,center=vertPos,circle=graphicsData.shape,matrix=graphicsData.matrix,x=circle.x,y=circle.y;verts.push(graphicsData.matrix?matrix.a*x+matrix.c*y+matrix.tx:x,graphicsData.matrix?matrix.b*x+matrix.d*y+matrix.ty:y);for(var i=0;i<points.length;i+=2)verts.push(points[i],points[i+1]),indices.push(vertPos++,center,vertPos)}};function getPt(n1,n2,perc){return n1+(n2-n1)*perc}function quadraticBezierCurve(fromX,fromY,cpX,cpY,toX,toY,out){void 0===out&&(out=[]);for(var points=out,xa=0,ya=0,xb=0,yb=0,x=0,y=0,i=0,j=0;i<=20;++i)xa=getPt(fromX,cpX,j=i/20),ya=getPt(fromY,cpY,j),xb=getPt(cpX,toX,j),yb=getPt(cpY,toY,j),x=getPt(xa,xb,j),y=getPt(ya,yb,j),points.push(x,y);return points}var buildRoundedRectangle={build:function(graphicsData){var rrectData=graphicsData.shape,points=graphicsData.points,x=rrectData.x,y=rrectData.y,width=rrectData.width,height=rrectData.height,radius=Math.max(0,Math.min(rrectData.radius,Math.min(width,height)/2));points.length=0,radius?(quadraticBezierCurve(x,y+radius,x,y,x+radius,y,points),quadraticBezierCurve(x+width-radius,y,x+width,y,x+width,y+radius,points),quadraticBezierCurve(x+width,y+height-radius,x+width,y+height,x+width-radius,y+height,points),quadraticBezierCurve(x+radius,y+height,x,y+height,x,y+height-radius,points)):points.push(x,y,x+width,y,x+width,y+height,x,y+height)},triangulate:function(graphicsData,graphicsGeometry){for(var points=graphicsData.points,verts=graphicsGeometry.points,indices=graphicsGeometry.indices,vecPos=verts.length/2,triangles=earcut_1(points,null,2),i=0,j=triangles.length;i<j;i+=3)indices.push(triangles[i]+vecPos),indices.push(triangles[i+1]+vecPos),indices.push(triangles[i+2]+vecPos);for(i=0,j=points.length;i<j;i++)verts.push(points[i],points[++i])}};function square(x,y,nx,ny,innerWeight,outerWeight,clockwise,verts){var exx,eyy;clockwise?(exx=ny,eyy=-nx):(exx=-ny,eyy=nx);var eix=x-nx*innerWeight+exx,eiy=y-ny*innerWeight+eyy,eox=x+nx*outerWeight+exx,eoy=y+ny*outerWeight+eyy;return verts.push(eix,eiy),verts.push(eox,eoy),2}function round(cx,cy,sx,sy,ex,ey,verts,clockwise){var cx2p0x=sx-cx,cy2p0y=sy-cy,angle0=Math.atan2(cx2p0x,cy2p0y),angle1=Math.atan2(ex-cx,ey-cy);clockwise&&angle0<angle1?angle0+=2*Math.PI:!clockwise&&angle0>angle1&&(angle1+=2*Math.PI);var startAngle=angle0,angleDiff=angle1-angle0,absAngleDiff=Math.abs(angleDiff),radius=Math.sqrt(cx2p0x*cx2p0x+cy2p0y*cy2p0y),segCount=1+(15*absAngleDiff*Math.sqrt(radius)/Math.PI>>0),angleInc=angleDiff/segCount;if(startAngle+=angleInc,clockwise){verts.push(cx,cy),verts.push(sx,sy);for(var i=1,angle=startAngle;i<segCount;i++,angle+=angleInc)verts.push(cx,cy),verts.push(cx+Math.sin(angle)*radius,cy+Math.cos(angle)*radius);verts.push(cx,cy),verts.push(ex,ey)}else{verts.push(sx,sy),verts.push(cx,cy);for(i=1,angle=startAngle;i<segCount;i++,angle+=angleInc)verts.push(cx+Math.sin(angle)*radius,cy+Math.cos(angle)*radius),verts.push(cx,cy);verts.push(ex,ey),verts.push(cx,cy)}return 2*segCount}function buildLine(graphicsData,graphicsGeometry){graphicsData.lineStyle.native?function(graphicsData,graphicsGeometry){var i=0,shape=graphicsData.shape,points=graphicsData.points||shape.points,closedShape=shape.type!==SHAPES.POLY||shape.closeStroke;if(0!==points.length){var verts=graphicsGeometry.points,indices=graphicsGeometry.indices,length=points.length/2,startIndex=verts.length/2,currentIndex=startIndex;for(verts.push(points[0],points[1]),i=1;i<length;i++)verts.push(points[2*i],points[2*i+1]),indices.push(currentIndex,currentIndex+1),currentIndex++;closedShape&&indices.push(currentIndex,startIndex)}}(graphicsData,graphicsGeometry):function(graphicsData,graphicsGeometry){var shape=graphicsData.shape,points=graphicsData.points||shape.points.slice(),eps=graphicsGeometry.closePointEps;if(0!==points.length){var style=graphicsData.lineStyle,firstPoint=new Point(points[0],points[1]),lastPoint=new Point(points[points.length-2],points[points.length-1]),closedShape=shape.type!==SHAPES.POLY||shape.closeStroke,closedPath=Math.abs(firstPoint.x-lastPoint.x)<eps&&Math.abs(firstPoint.y-lastPoint.y)<eps;if(closedShape){points=points.slice(),closedPath&&(points.pop(),points.pop(),lastPoint.set(points[points.length-2],points[points.length-1]));var midPointX=.5*(firstPoint.x+lastPoint.x),midPointY=.5*(lastPoint.y+firstPoint.y);points.unshift(midPointX,midPointY),points.push(midPointX,midPointY)}var verts=graphicsGeometry.points,length=points.length/2,indexCount=points.length,indexStart=verts.length/2,width=style.width/2,widthSquared=width*width,miterLimitSquared=style.miterLimit*style.miterLimit,x0=points[0],y0=points[1],x1=points[2],y1=points[3],x2=0,y2=0,perpx=-(y0-y1),perpy=x0-x1,perp1x=0,perp1y=0,dist=Math.sqrt(perpx*perpx+perpy*perpy);perpx/=dist,perpy/=dist,perpx*=width,perpy*=width;var ratio=style.alignment,innerWeight=2*(1-ratio),outerWeight=2*ratio;closedShape||(style.cap===LINE_CAP.ROUND?indexCount+=round(x0-perpx*(innerWeight-outerWeight)*.5,y0-perpy*(innerWeight-outerWeight)*.5,x0-perpx*innerWeight,y0-perpy*innerWeight,x0+perpx*outerWeight,y0+perpy*outerWeight,verts,!0)+2:style.cap===LINE_CAP.SQUARE&&(indexCount+=square(x0,y0,perpx,perpy,innerWeight,outerWeight,!0,verts))),verts.push(x0-perpx*innerWeight,y0-perpy*innerWeight),verts.push(x0+perpx*outerWeight,y0+perpy*outerWeight);for(var i=1;i<length-1;++i){x0=points[2*(i-1)],y0=points[2*(i-1)+1],x1=points[2*i],y1=points[2*i+1],x2=points[2*(i+1)],y2=points[2*(i+1)+1],perpx=-(y0-y1),perpy=x0-x1,perpx/=dist=Math.sqrt(perpx*perpx+perpy*perpy),perpy/=dist,perpx*=width,perpy*=width,perp1x=-(y1-y2),perp1y=x1-x2,perp1x/=dist=Math.sqrt(perp1x*perp1x+perp1y*perp1y),perp1y/=dist,perp1x*=width,perp1y*=width;var dx0=x1-x0,dy0=y0-y1,dx1=x1-x2,dy1=y2-y1,cross=dy0*dx1-dy1*dx0,clockwise=cross<0;if(Math.abs(cross)<.1)verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight);else{var c1=(-perpx+x0)*(-perpy+y1)-(-perpx+x1)*(-perpy+y0),c2=(-perp1x+x2)*(-perp1y+y1)-(-perp1x+x1)*(-perp1y+y2),px=(dx0*c2-dx1*c1)/cross,py=(dy1*c1-dy0*c2)/cross,pdist=(px-x1)*(px-x1)+(py-y1)*(py-y1),imx=x1+(px-x1)*innerWeight,imy=y1+(py-y1)*innerWeight,omx=x1-(px-x1)*outerWeight,omy=y1-(py-y1)*outerWeight,insideWeight=clockwise?innerWeight:outerWeight;pdist<=Math.min(dx0*dx0+dy0*dy0,dx1*dx1+dy1*dy1)+insideWeight*insideWeight*widthSquared?style.join===LINE_JOIN.BEVEL||pdist/widthSquared>miterLimitSquared?(clockwise?(verts.push(imx,imy),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight),verts.push(imx,imy),verts.push(x1+perp1x*outerWeight,y1+perp1y*outerWeight)):(verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(omx,omy),verts.push(x1-perp1x*innerWeight,y1-perp1y*innerWeight),verts.push(omx,omy)),indexCount+=2):style.join===LINE_JOIN.ROUND?clockwise?(verts.push(imx,imy),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight),indexCount+=round(x1,y1,x1+perpx*outerWeight,y1+perpy*outerWeight,x1+perp1x*outerWeight,y1+perp1y*outerWeight,verts,!0)+4,verts.push(imx,imy),verts.push(x1+perp1x*outerWeight,y1+perp1y*outerWeight)):(verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(omx,omy),indexCount+=round(x1,y1,x1-perpx*innerWeight,y1-perpy*innerWeight,x1-perp1x*innerWeight,y1-perp1y*innerWeight,verts,!1)+4,verts.push(x1-perp1x*innerWeight,y1-perp1y*innerWeight),verts.push(omx,omy)):(verts.push(imx,imy),verts.push(omx,omy)):(verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight),style.join===LINE_JOIN.BEVEL||pdist/widthSquared>miterLimitSquared||(style.join===LINE_JOIN.ROUND?indexCount+=clockwise?round(x1,y1,x1+perpx*outerWeight,y1+perpy*outerWeight,x1+perp1x*outerWeight,y1+perp1y*outerWeight,verts,!0)+2:round(x1,y1,x1-perpx*innerWeight,y1-perpy*innerWeight,x1-perp1x*innerWeight,y1-perp1y*innerWeight,verts,!1)+2:(clockwise?(verts.push(omx,omy),verts.push(omx,omy)):(verts.push(imx,imy),verts.push(imx,imy)),indexCount+=2)),verts.push(x1-perp1x*innerWeight,y1-perp1y*innerWeight),verts.push(x1+perp1x*outerWeight,y1+perp1y*outerWeight),indexCount+=2)}}x0=points[2*(length-2)],y0=points[2*(length-2)+1],x1=points[2*(length-1)],perpx=-(y0-(y1=points[2*(length-1)+1])),perpy=x0-x1,perpx/=dist=Math.sqrt(perpx*perpx+perpy*perpy),perpy/=dist,perpx*=width,perpy*=width,verts.push(x1-perpx*innerWeight,y1-perpy*innerWeight),verts.push(x1+perpx*outerWeight,y1+perpy*outerWeight),closedShape||(style.cap===LINE_CAP.ROUND?indexCount+=round(x1-perpx*(innerWeight-outerWeight)*.5,y1-perpy*(innerWeight-outerWeight)*.5,x1-perpx*innerWeight,y1-perpy*innerWeight,x1+perpx*outerWeight,y1+perpy*outerWeight,verts,!1)+2:style.cap===LINE_CAP.SQUARE&&(indexCount+=square(x1,y1,perpx,perpy,innerWeight,outerWeight,!1,verts)));var indices=graphicsGeometry.indices,eps2=GRAPHICS_CURVES.epsilon*GRAPHICS_CURVES.epsilon;for(i=indexStart;i<indexCount+indexStart-2;++i)x0=verts[2*i],y0=verts[2*i+1],x1=verts[2*(i+1)],y1=verts[2*(i+1)+1],x2=verts[2*(i+2)],y2=verts[2*(i+2)+1],Math.abs(x0*(y1-y2)+x1*(y2-y0)+x2*(y0-y1))<eps2||indices.push(i,i+1,i+2)}}(graphicsData,graphicsGeometry)}var _a,Star=function(_super){function Star(x,y,points,radius,innerRadius,rotation){void 0===rotation&&(rotation=0);innerRadius=innerRadius||radius/2;for(var startAngle=-1*Math.PI/2+rotation,len=2*points,delta=PI_2/len,polygon=[],i=0;i<len;i++){var r=i%2?innerRadius:radius,angle=i*delta+startAngle;polygon.push(x+r*Math.cos(angle),y+r*Math.sin(angle))}return _super.call(this,polygon)||this}return __extends$6(Star,_super),Star}(Polygon),ArcUtils=function(){function ArcUtils(){}return ArcUtils.curveTo=function(x1,y1,x2,y2,radius,points){var fromX=points[points.length-2],a1=points[points.length-1]-y1,b1=fromX-x1,a2=y2-y1,b2=x2-x1,mm=Math.abs(a1*b2-b1*a2);if(mm<1e-8||0===radius)return points[points.length-2]===x1&&points[points.length-1]===y1||points.push(x1,y1),null;var dd=a1*a1+b1*b1,cc=a2*a2+b2*b2,tt=a1*a2+b1*b2,k1=radius*Math.sqrt(dd)/mm,k2=radius*Math.sqrt(cc)/mm,j1=k1*tt/dd,j2=k2*tt/cc,cx=k1*b2+k2*b1,cy=k1*a2+k2*a1,px=b1*(k2+j1),py=a1*(k2+j1),qx=b2*(k1+j2),qy=a2*(k1+j2);return{cx:cx+x1,cy:cy+y1,radius:radius,startAngle:Math.atan2(py-cy,px-cx),endAngle:Math.atan2(qy-cy,qx-cx),anticlockwise:b1*a2>b2*a1}},ArcUtils.arc=function(_startX,_startY,cx,cy,radius,startAngle,endAngle,_anticlockwise,points){for(var sweep=endAngle-startAngle,n=GRAPHICS_CURVES._segmentsCount(Math.abs(sweep)*radius,40*Math.ceil(Math.abs(sweep)/PI_2)),theta=sweep/(2*n),theta2=2*theta,cTheta=Math.cos(theta),sTheta=Math.sin(theta),segMinus=n-1,remainder=segMinus%1/segMinus,i=0;i<=segMinus;++i){var angle=theta+startAngle+theta2*(i+remainder*i),c=Math.cos(angle),s=-Math.sin(angle);points.push((cTheta*c+sTheta*s)*radius+cx,(cTheta*-s+sTheta*c)*radius+cy)}},ArcUtils}(),BezierUtils=function(){function BezierUtils(){}return BezierUtils.curveLength=function(fromX,fromY,cpX,cpY,cpX2,cpY2,toX,toY){for(var result=0,t=0,t2=0,t3=0,nt=0,nt2=0,nt3=0,x=0,y=0,dx=0,dy=0,prevX=fromX,prevY=fromY,i=1;i<=10;++i)dx=prevX-(x=(nt3=(nt2=(nt=1-(t=i/10))*nt)*nt)*fromX+3*nt2*t*cpX+3*nt*(t2=t*t)*cpX2+(t3=t2*t)*toX),dy=prevY-(y=nt3*fromY+3*nt2*t*cpY+3*nt*t2*cpY2+t3*toY),prevX=x,prevY=y,result+=Math.sqrt(dx*dx+dy*dy);return result},BezierUtils.curveTo=function(cpX,cpY,cpX2,cpY2,toX,toY,points){var fromX=points[points.length-2],fromY=points[points.length-1];points.length-=2;var n=GRAPHICS_CURVES._segmentsCount(BezierUtils.curveLength(fromX,fromY,cpX,cpY,cpX2,cpY2,toX,toY)),dt=0,dt2=0,dt3=0,t2=0,t3=0;points.push(fromX,fromY);for(var i=1,j=0;i<=n;++i)dt3=(dt2=(dt=1-(j=i/n))*dt)*dt,t3=(t2=j*j)*j,points.push(dt3*fromX+3*dt2*j*cpX+3*dt*t2*cpX2+t3*toX,dt3*fromY+3*dt2*j*cpY+3*dt*t2*cpY2+t3*toY)},BezierUtils}(),QuadraticUtils=function(){function QuadraticUtils(){}return QuadraticUtils.curveLength=function(fromX,fromY,cpX,cpY,toX,toY){var ax=fromX-2*cpX+toX,ay=fromY-2*cpY+toY,bx=2*cpX-2*fromX,by=2*cpY-2*fromY,a=4*(ax*ax+ay*ay),b=4*(ax*bx+ay*by),c=bx*bx+by*by,s=2*Math.sqrt(a+b+c),a2=Math.sqrt(a),a32=2*a*a2,c2=2*Math.sqrt(c),ba=b/a2;return(a32*s+a2*b*(s-c2)+(4*c*a-b*b)*Math.log((2*a2+ba+s)/(ba+c2)))/(4*a32)},QuadraticUtils.curveTo=function(cpX,cpY,toX,toY,points){for(var fromX=points[points.length-2],fromY=points[points.length-1],n=GRAPHICS_CURVES._segmentsCount(QuadraticUtils.curveLength(fromX,fromY,cpX,cpY,toX,toY)),xa=0,ya=0,i=1;i<=n;++i){var j=i/n;xa=fromX+(cpX-fromX)*j,ya=fromY+(cpY-fromY)*j,points.push(xa+(cpX+(toX-cpX)*j-xa)*j,ya+(cpY+(toY-cpY)*j-ya)*j)}},QuadraticUtils}(),BatchPart=function(){function BatchPart(){this.reset()}return BatchPart.prototype.begin=function(style,startIndex,attribStart){this.reset(),this.style=style,this.start=startIndex,this.attribStart=attribStart},BatchPart.prototype.end=function(endIndex,endAttrib){this.attribSize=endAttrib-this.attribStart,this.size=endIndex-this.start},BatchPart.prototype.reset=function(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0},BatchPart}(),FILL_COMMANDS=((_a={})[SHAPES.POLY]=buildPoly,_a[SHAPES.CIRC]=buildCircle,_a[SHAPES.ELIP]=buildCircle,_a[SHAPES.RECT]={build:function(graphicsData){var rectData=graphicsData.shape,x=rectData.x,y=rectData.y,width=rectData.width,height=rectData.height,points=graphicsData.points;points.length=0,points.push(x,y,x+width,y,x+width,y+height,x,y+height)},triangulate:function(graphicsData,graphicsGeometry){var points=graphicsData.points,verts=graphicsGeometry.points,vertPos=verts.length/2;verts.push(points[0],points[1],points[2],points[3],points[6],points[7],points[4],points[5]),graphicsGeometry.indices.push(vertPos,vertPos+1,vertPos+2,vertPos+1,vertPos+2,vertPos+3)}},_a[SHAPES.RREC]=buildRoundedRectangle,_a),BATCH_POOL=[],DRAW_CALL_POOL=[],GraphicsData=function(){function GraphicsData(shape,fillStyle,lineStyle,matrix){void 0===fillStyle&&(fillStyle=null),void 0===lineStyle&&(lineStyle=null),void 0===matrix&&(matrix=null),this.shape=shape,this.lineStyle=lineStyle,this.fillStyle=fillStyle,this.matrix=matrix,this.type=shape.type,this.points=[],this.holes=[]}return GraphicsData.prototype.clone=function(){return new GraphicsData(this.shape,this.fillStyle,this.lineStyle,this.matrix)},GraphicsData.prototype.destroy=function(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null},GraphicsData}(),tmpPoint=new Point,tmpBounds=new Bounds,GraphicsGeometry=function(_super){function GraphicsGeometry(){var _this=_super.call(this)||this;return _this.uvsFloat32=null,_this.indicesUint16=null,_this.points=[],_this.colors=[],_this.uvs=[],_this.indices=[],_this.textureIds=[],_this.graphicsData=[],_this.dirty=0,_this.batchDirty=-1,_this.cacheDirty=-1,_this.clearDirty=0,_this.drawCalls=[],_this.batches=[],_this.shapeIndex=0,_this._bounds=new Bounds,_this.boundsDirty=-1,_this.boundsPadding=0,_this.batchable=!1,_this.indicesUint16=null,_this.uvsFloat32=null,_this.closePointEps=1e-4,_this}return __extends$6(GraphicsGeometry,_super),Object.defineProperty(GraphicsGeometry.prototype,"bounds",{get:function(){return this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds},enumerable:!1,configurable:!0}),GraphicsGeometry.prototype.invalidate=function(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(var i=0;i<this.drawCalls.length;i++)this.drawCalls[i].texArray.clear(),DRAW_CALL_POOL.push(this.drawCalls[i]);this.drawCalls.length=0;for(i=0;i<this.batches.length;i++){var batchPart=this.batches[i];batchPart.reset(),BATCH_POOL.push(batchPart)}this.batches.length=0},GraphicsGeometry.prototype.clear=function(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this},GraphicsGeometry.prototype.drawShape=function(shape,fillStyle,lineStyle,matrix){void 0===fillStyle&&(fillStyle=null),void 0===lineStyle&&(lineStyle=null),void 0===matrix&&(matrix=null);var data=new GraphicsData(shape,fillStyle,lineStyle,matrix);return this.graphicsData.push(data),this.dirty++,this},GraphicsGeometry.prototype.drawHole=function(shape,matrix){if(void 0===matrix&&(matrix=null),!this.graphicsData.length)return null;var data=new GraphicsData(shape,null,null,matrix),lastShape=this.graphicsData[this.graphicsData.length-1];return data.lineStyle=lastShape.lineStyle,lastShape.holes.push(data),this.dirty++,this},GraphicsGeometry.prototype.destroy=function(){_super.prototype.destroy.call(this);for(var i=0;i<this.graphicsData.length;++i)this.graphicsData[i].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null},GraphicsGeometry.prototype.containsPoint=function(point){for(var graphicsData=this.graphicsData,i=0;i<graphicsData.length;++i){var data=graphicsData[i];if(data.fillStyle.visible&&(data.shape&&(data.matrix?data.matrix.applyInverse(point,tmpPoint):tmpPoint.copyFrom(point),data.shape.contains(tmpPoint.x,tmpPoint.y)))){var hitHole=!1;if(data.holes)for(var i_1=0;i_1<data.holes.length;i_1++){if(data.holes[i_1].shape.contains(tmpPoint.x,tmpPoint.y)){hitHole=!0;break}}if(!hitHole)return!0}}return!1},GraphicsGeometry.prototype.updateBatches=function(allow32Indices){if(this.graphicsData.length){if(this.validateBatching()){this.cacheDirty=this.dirty;var uvs=this.uvs,graphicsData=this.graphicsData,batchPart=null,currentStyle=null;this.batches.length>0&&(currentStyle=(batchPart=this.batches[this.batches.length-1]).style);for(var i=this.shapeIndex;i<graphicsData.length;i++){this.shapeIndex++;var data=graphicsData[i],fillStyle=data.fillStyle,lineStyle=data.lineStyle;FILL_COMMANDS[data.type].build(data),data.matrix&&this.transformPoints(data.points,data.matrix);for(var j=0;j<2;j++){var style=0===j?fillStyle:lineStyle;if(style.visible){var nextTexture=style.texture.baseTexture,index_1=this.indices.length,attribIndex=this.points.length/2;nextTexture.wrapMode=WRAP_MODES.REPEAT,0===j?this.processFill(data):this.processLine(data);var size=this.points.length/2-attribIndex;0!==size&&(batchPart&&!this._compareStyles(currentStyle,style)&&(batchPart.end(index_1,attribIndex),batchPart=null),batchPart||((batchPart=BATCH_POOL.pop()||new BatchPart).begin(style,index_1,attribIndex),this.batches.push(batchPart),currentStyle=style),this.addUvs(this.points,uvs,style.texture,attribIndex,size,style.matrix))}}}var index=this.indices.length,attrib=this.points.length/2;if(batchPart&&batchPart.end(index,attrib),0!==this.batches.length){if(this.indicesUint16&&this.indices.length===this.indicesUint16.length)this.indicesUint16.set(this.indices);else{var need32=attrib>65535&&allow32Indices;this.indicesUint16=need32?new Uint32Array(this.indices):new Uint16Array(this.indices)}this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}else this.batchable=!0}}else this.batchable=!0},GraphicsGeometry.prototype._compareStyles=function(styleA,styleB){return!(!styleA||!styleB)&&(styleA.texture.baseTexture===styleB.texture.baseTexture&&(styleA.color+styleA.alpha===styleB.color+styleB.alpha&&!!styleA.native==!!styleB.native))},GraphicsGeometry.prototype.validateBatching=function(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(var i=0,l=this.graphicsData.length;i<l;i++){var data=this.graphicsData[i],fill=data.fillStyle,line=data.lineStyle;if(fill&&!fill.texture.baseTexture.valid)return!1;if(line&&!line.texture.baseTexture.valid)return!1}return!0},GraphicsGeometry.prototype.packBatches=function(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);for(var batches=this.batches,i=0,l=batches.length;i<l;i++)for(var batch=batches[i],j=0;j<batch.size;j++){var index=batch.start+j;this.indicesUint16[index]=this.indicesUint16[index]-batch.attribStart}},GraphicsGeometry.prototype.isBatchable=function(){if(this.points.length>131070)return!1;for(var batches=this.batches,i=0;i<batches.length;i++)if(batches[i].style.native)return!1;return this.points.length<2*GraphicsGeometry.BATCHABLE_SIZE},GraphicsGeometry.prototype.buildDrawCalls=function(){for(var TICK=++BaseTexture._globalBatch,i=0;i<this.drawCalls.length;i++)this.drawCalls[i].texArray.clear(),DRAW_CALL_POOL.push(this.drawCalls[i]);this.drawCalls.length=0;var colors=this.colors,textureIds=this.textureIds,currentGroup=DRAW_CALL_POOL.pop();currentGroup||((currentGroup=new BatchDrawCall).texArray=new BatchTextureArray),currentGroup.texArray.count=0,currentGroup.start=0,currentGroup.size=0,currentGroup.type=DRAW_MODES.TRIANGLES;var textureCount=0,currentTexture=null,textureId=0,native=!1,drawMode=DRAW_MODES.TRIANGLES,index=0;this.drawCalls.push(currentGroup);for(i=0;i<this.batches.length;i++){var data=this.batches[i],style=data.style,nextTexture=style.texture.baseTexture;native!==!!style.native&&(drawMode=(native=!!style.native)?DRAW_MODES.LINES:DRAW_MODES.TRIANGLES,currentTexture=null,textureCount=8,TICK++),currentTexture!==nextTexture&&(currentTexture=nextTexture,nextTexture._batchEnabled!==TICK&&(8===textureCount&&(TICK++,textureCount=0,currentGroup.size>0&&((currentGroup=DRAW_CALL_POOL.pop())||((currentGroup=new BatchDrawCall).texArray=new BatchTextureArray),this.drawCalls.push(currentGroup)),currentGroup.start=index,currentGroup.size=0,currentGroup.texArray.count=0,currentGroup.type=drawMode),nextTexture.touched=1,nextTexture._batchEnabled=TICK,nextTexture._batchLocation=textureCount,nextTexture.wrapMode=10497,currentGroup.texArray.elements[currentGroup.texArray.count++]=nextTexture,textureCount++)),currentGroup.size+=data.size,index+=data.size,textureId=nextTexture._batchLocation,this.addColors(colors,style.color,style.alpha,data.attribSize),this.addTextureIds(textureIds,textureId,data.attribSize)}BaseTexture._globalBatch=TICK,this.packAttributes()},GraphicsGeometry.prototype.packAttributes=function(){for(var verts=this.points,uvs=this.uvs,colors=this.colors,textureIds=this.textureIds,glPoints=new ArrayBuffer(3*verts.length*4),f32=new Float32Array(glPoints),u32=new Uint32Array(glPoints),p=0,i=0;i<verts.length/2;i++)f32[p++]=verts[2*i],f32[p++]=verts[2*i+1],f32[p++]=uvs[2*i],f32[p++]=uvs[2*i+1],u32[p++]=colors[i],f32[p++]=textureIds[i];this._buffer.update(glPoints),this._indexBuffer.update(this.indicesUint16)},GraphicsGeometry.prototype.processFill=function(data){data.holes.length?(this.processHoles(data.holes),buildPoly.triangulate(data,this)):FILL_COMMANDS[data.type].triangulate(data,this)},GraphicsGeometry.prototype.processLine=function(data){buildLine(data,this);for(var i=0;i<data.holes.length;i++)buildLine(data.holes[i],this)},GraphicsGeometry.prototype.processHoles=function(holes){for(var i=0;i<holes.length;i++){var hole=holes[i];FILL_COMMANDS[hole.type].build(hole),hole.matrix&&this.transformPoints(hole.points,hole.matrix)}},GraphicsGeometry.prototype.calculateBounds=function(){var bounds=this._bounds,sequenceBounds=tmpBounds,curMatrix=Matrix.IDENTITY;this._bounds.clear(),sequenceBounds.clear();for(var i=0;i<this.graphicsData.length;i++){var data=this.graphicsData[i],shape=data.shape,type=data.type,lineStyle=data.lineStyle,nextMatrix=data.matrix||Matrix.IDENTITY,lineWidth=0;if(lineStyle&&lineStyle.visible){var alignment=lineStyle.alignment;lineWidth=lineStyle.width,type===SHAPES.POLY?lineWidth*=.5+Math.abs(.5-alignment):lineWidth*=Math.max(0,alignment)}if(curMatrix!==nextMatrix&&(sequenceBounds.isEmpty()||(bounds.addBoundsMatrix(sequenceBounds,curMatrix),sequenceBounds.clear()),curMatrix=nextMatrix),type===SHAPES.RECT||type===SHAPES.RREC){var rect=shape;sequenceBounds.addFramePad(rect.x,rect.y,rect.x+rect.width,rect.y+rect.height,lineWidth,lineWidth)}else if(type===SHAPES.CIRC){var circle=shape;sequenceBounds.addFramePad(circle.x,circle.y,circle.x,circle.y,circle.radius+lineWidth,circle.radius+lineWidth)}else if(type===SHAPES.ELIP){var ellipse=shape;sequenceBounds.addFramePad(ellipse.x,ellipse.y,ellipse.x,ellipse.y,ellipse.width+lineWidth,ellipse.height+lineWidth)}else{var poly=shape;bounds.addVerticesMatrix(curMatrix,poly.points,0,poly.points.length,lineWidth,lineWidth)}}sequenceBounds.isEmpty()||bounds.addBoundsMatrix(sequenceBounds,curMatrix),bounds.pad(this.boundsPadding,this.boundsPadding)},GraphicsGeometry.prototype.transformPoints=function(points,matrix){for(var i=0;i<points.length/2;i++){var x=points[2*i],y=points[2*i+1];points[2*i]=matrix.a*x+matrix.c*y+matrix.tx,points[2*i+1]=matrix.b*x+matrix.d*y+matrix.ty}},GraphicsGeometry.prototype.addColors=function(colors,color,alpha,size){for(var rgba=premultiplyTint((color>>16)+(65280&color)+((255&color)<<16),alpha);size-- >0;)colors.push(rgba)},GraphicsGeometry.prototype.addTextureIds=function(textureIds,id,size){for(;size-- >0;)textureIds.push(id)},GraphicsGeometry.prototype.addUvs=function(verts,uvs,texture,start,size,matrix){void 0===matrix&&(matrix=null);for(var index=0,uvsStart=uvs.length,frame=texture.frame;index<size;){var x=verts[2*(start+index)],y=verts[2*(start+index)+1];if(matrix){var nx=matrix.a*x+matrix.c*y+matrix.tx;y=matrix.b*x+matrix.d*y+matrix.ty,x=nx}index++,uvs.push(x/frame.width,y/frame.height)}var baseTexture=texture.baseTexture;(frame.width<baseTexture.width||frame.height<baseTexture.height)&&this.adjustUvs(uvs,texture,uvsStart,size)},GraphicsGeometry.prototype.adjustUvs=function(uvs,texture,start,size){for(var baseTexture=texture.baseTexture,eps=1e-6,finish=start+2*size,frame=texture.frame,scaleX=frame.width/baseTexture.width,scaleY=frame.height/baseTexture.height,offsetX=frame.x/frame.width,offsetY=frame.y/frame.height,minX=Math.floor(uvs[start]+eps),minY=Math.floor(uvs[start+1]+eps),i=start+2;i<finish;i+=2)minX=Math.min(minX,Math.floor(uvs[i]+eps)),minY=Math.min(minY,Math.floor(uvs[i+1]+eps));offsetX-=minX,offsetY-=minY;for(i=start;i<finish;i+=2)uvs[i]=(uvs[i]+offsetX)*scaleX,uvs[i+1]=(uvs[i+1]+offsetY)*scaleY},GraphicsGeometry.BATCHABLE_SIZE=100,GraphicsGeometry}(BatchGeometry),LineStyle=function(_super){function LineStyle(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.width=0,_this.alignment=.5,_this.native=!1,_this.cap=LINE_CAP.BUTT,_this.join=LINE_JOIN.MITER,_this.miterLimit=10,_this}return __extends$6(LineStyle,_super),LineStyle.prototype.clone=function(){var obj=new LineStyle;return obj.color=this.color,obj.alpha=this.alpha,obj.texture=this.texture,obj.matrix=this.matrix,obj.visible=this.visible,obj.width=this.width,obj.alignment=this.alignment,obj.native=this.native,obj.cap=this.cap,obj.join=this.join,obj.miterLimit=this.miterLimit,obj},LineStyle.prototype.reset=function(){_super.prototype.reset.call(this),this.color=0,this.alignment=.5,this.width=0,this.native=!1},LineStyle}(FillStyle),temp=new Float32Array(3),DEFAULT_SHADERS={},Graphics=function(_super){function Graphics(geometry){void 0===geometry&&(geometry=null);var _this=_super.call(this)||this;return _this._geometry=geometry||new GraphicsGeometry,_this._geometry.refCount++,_this.shader=null,_this.state=State.for2d(),_this._fillStyle=new FillStyle,_this._lineStyle=new LineStyle,_this._matrix=null,_this._holeMode=!1,_this.currentPath=null,_this.batches=[],_this.batchTint=-1,_this.batchDirty=-1,_this.vertexData=null,_this.pluginName="batch",_this._transformID=-1,_this.tint=16777215,_this.blendMode=BLEND_MODES.NORMAL,_this}return __extends$6(Graphics,_super),Object.defineProperty(Graphics.prototype,"geometry",{get:function(){return this._geometry},enumerable:!1,configurable:!0}),Graphics.prototype.clone=function(){return this.finishPoly(),new Graphics(this._geometry)},Object.defineProperty(Graphics.prototype,"blendMode",{get:function(){return this.state.blendMode},set:function(value){this.state.blendMode=value},enumerable:!1,configurable:!0}),Object.defineProperty(Graphics.prototype,"tint",{get:function(){return this._tint},set:function(value){this._tint=value},enumerable:!1,configurable:!0}),Object.defineProperty(Graphics.prototype,"fill",{get:function(){return this._fillStyle},enumerable:!1,configurable:!0}),Object.defineProperty(Graphics.prototype,"line",{get:function(){return this._lineStyle},enumerable:!1,configurable:!0}),Graphics.prototype.lineStyle=function(options){if(void 0===options&&(options=null),"number"==typeof options){var args=arguments;options={width:args[0]||0,color:args[1]||0,alpha:void 0!==args[2]?args[2]:1,alignment:void 0!==args[3]?args[3]:.5,native:!!args[4]}}return this.lineTextureStyle(options)},Graphics.prototype.lineTextureStyle=function(options){if("number"==typeof options){deprecation("v5.2.0","Please use object-based options for Graphics#lineTextureStyle");var _a=arguments,width=_a[0],texture=_a[1],color=_a[2],alpha=_a[3],matrix=_a[4],alignment=_a[5],native=_a[6];options={width:width,texture:texture,color:color,alpha:alpha,matrix:matrix,alignment:alignment,native:native},Object.keys(options).forEach((function(key){return void 0===options[key]&&delete options[key]}))}options=Object.assign({width:0,texture:Texture.WHITE,color:options&&options.texture?16777215:0,alpha:1,matrix:null,alignment:.5,native:!1,cap:LINE_CAP.BUTT,join:LINE_JOIN.MITER,miterLimit:10},options),this.currentPath&&this.startPoly();var visible=options.width>0&&options.alpha>0;return visible?(options.matrix&&(options.matrix=options.matrix.clone(),options.matrix.invert()),Object.assign(this._lineStyle,{visible:visible},options)):this._lineStyle.reset(),this},Graphics.prototype.startPoly=function(){if(this.currentPath){var points=this.currentPath.points,len=this.currentPath.points.length;len>2&&(this.drawShape(this.currentPath),this.currentPath=new Polygon,this.currentPath.closeStroke=!1,this.currentPath.points.push(points[len-2],points[len-1]))}else this.currentPath=new Polygon,this.currentPath.closeStroke=!1},Graphics.prototype.finishPoly=function(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)},Graphics.prototype.moveTo=function(x,y){return this.startPoly(),this.currentPath.points[0]=x,this.currentPath.points[1]=y,this},Graphics.prototype.lineTo=function(x,y){this.currentPath||this.moveTo(0,0);var points=this.currentPath.points,fromX=points[points.length-2],fromY=points[points.length-1];return fromX===x&&fromY===y||points.push(x,y),this},Graphics.prototype._initCurve=function(x,y){void 0===x&&(x=0),void 0===y&&(y=0),this.currentPath?0===this.currentPath.points.length&&(this.currentPath.points=[x,y]):this.moveTo(x,y)},Graphics.prototype.quadraticCurveTo=function(cpX,cpY,toX,toY){this._initCurve();var points=this.currentPath.points;return 0===points.length&&this.moveTo(0,0),QuadraticUtils.curveTo(cpX,cpY,toX,toY,points),this},Graphics.prototype.bezierCurveTo=function(cpX,cpY,cpX2,cpY2,toX,toY){return this._initCurve(),BezierUtils.curveTo(cpX,cpY,cpX2,cpY2,toX,toY,this.currentPath.points),this},Graphics.prototype.arcTo=function(x1,y1,x2,y2,radius){this._initCurve(x1,y1);var points=this.currentPath.points,result=ArcUtils.curveTo(x1,y1,x2,y2,radius,points);if(result){var cx=result.cx,cy=result.cy,radius_1=result.radius,startAngle=result.startAngle,endAngle=result.endAngle,anticlockwise=result.anticlockwise;this.arc(cx,cy,radius_1,startAngle,endAngle,anticlockwise)}return this},Graphics.prototype.arc=function(cx,cy,radius,startAngle,endAngle,anticlockwise){if(void 0===anticlockwise&&(anticlockwise=!1),startAngle===endAngle)return this;if(!anticlockwise&&endAngle<=startAngle?endAngle+=PI_2:anticlockwise&&startAngle<=endAngle&&(startAngle+=PI_2),0===endAngle-startAngle)return this;var startX=cx+Math.cos(startAngle)*radius,startY=cy+Math.sin(startAngle)*radius,eps=this._geometry.closePointEps,points=this.currentPath?this.currentPath.points:null;if(points){var xDiff=Math.abs(points[points.length-2]-startX),yDiff=Math.abs(points[points.length-1]-startY);xDiff<eps&&yDiff<eps||points.push(startX,startY)}else this.moveTo(startX,startY),points=this.currentPath.points;return ArcUtils.arc(startX,startY,cx,cy,radius,startAngle,endAngle,anticlockwise,points),this},Graphics.prototype.beginFill=function(color,alpha){return void 0===color&&(color=0),void 0===alpha&&(alpha=1),this.beginTextureFill({texture:Texture.WHITE,color:color,alpha:alpha})},Graphics.prototype.beginTextureFill=function(options){if(options instanceof Texture){deprecation("v5.2.0","Please use object-based options for Graphics#beginTextureFill");var _a=arguments,texture=_a[0],color=_a[1],alpha=_a[2],matrix=_a[3];options={texture:texture,color:color,alpha:alpha,matrix:matrix},Object.keys(options).forEach((function(key){return void 0===options[key]&&delete options[key]}))}options=Object.assign({texture:Texture.WHITE,color:16777215,alpha:1,matrix:null},options),this.currentPath&&this.startPoly();var visible=options.alpha>0;return visible?(options.matrix&&(options.matrix=options.matrix.clone(),options.matrix.invert()),Object.assign(this._fillStyle,{visible:visible},options)):this._fillStyle.reset(),this},Graphics.prototype.endFill=function(){return this.finishPoly(),this._fillStyle.reset(),this},Graphics.prototype.drawRect=function(x,y,width,height){return this.drawShape(new Rectangle(x,y,width,height))},Graphics.prototype.drawRoundedRect=function(x,y,width,height,radius){return this.drawShape(new RoundedRectangle(x,y,width,height,radius))},Graphics.prototype.drawCircle=function(x,y,radius){return this.drawShape(new Circle(x,y,radius))},Graphics.prototype.drawEllipse=function(x,y,width,height){return this.drawShape(new Ellipse(x,y,width,height))},Graphics.prototype.drawPolygon=function(){for(var points,arguments$1=arguments,path=[],_i=0;_i<arguments.length;_i++)path[_i]=arguments$1[_i];var closeStroke=!0,poly=path[0];poly.points?(closeStroke=poly.closeStroke,points=poly.points):points=Array.isArray(path[0])?path[0]:path;var shape=new Polygon(points);return shape.closeStroke=closeStroke,this.drawShape(shape),this},Graphics.prototype.drawShape=function(shape){return this._holeMode?this._geometry.drawHole(shape,this._matrix):this._geometry.drawShape(shape,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this},Graphics.prototype.drawStar=function(x,y,points,radius,innerRadius,rotation){return void 0===rotation&&(rotation=0),this.drawPolygon(new Star(x,y,points,radius,innerRadius,rotation))},Graphics.prototype.clear=function(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this},Graphics.prototype.isFastRect=function(){var data=this._geometry.graphicsData;return 1===data.length&&data[0].shape.type===SHAPES.RECT&&!(data[0].lineStyle.visible&&data[0].lineStyle.width)},Graphics.prototype._render=function(renderer){this.finishPoly();var geometry=this._geometry,hasuint32=renderer.context.supports.uint32Indices;geometry.updateBatches(hasuint32),geometry.batchable?(this.batchDirty!==geometry.batchDirty&&this._populateBatches(),this._renderBatched(renderer)):(renderer.batch.flush(),this._renderDirect(renderer))},Graphics.prototype._populateBatches=function(){var geometry=this._geometry,blendMode=this.blendMode,len=geometry.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=geometry.batchDirty,this.batches.length=len,this.vertexData=new Float32Array(geometry.points);for(var i=0;i<len;i++){var gI=geometry.batches[i],color=gI.style.color,vertexData=new Float32Array(this.vertexData.buffer,4*gI.attribStart*2,2*gI.attribSize),uvs=new Float32Array(geometry.uvsFloat32.buffer,4*gI.attribStart*2,2*gI.attribSize),batch={vertexData:vertexData,blendMode:blendMode,indices:new Uint16Array(geometry.indicesUint16.buffer,2*gI.start,gI.size),uvs:uvs,_batchRGB:hex2rgb(color),_tintRGB:color,_texture:gI.style.texture,alpha:gI.style.alpha,worldAlpha:1};this.batches[i]=batch}},Graphics.prototype._renderBatched=function(renderer){if(this.batches.length){renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(var i=0,l=this.batches.length;i<l;i++){var batch=this.batches[i];batch.worldAlpha=this.worldAlpha*batch.alpha,renderer.plugins[this.pluginName].render(batch)}}},Graphics.prototype._renderDirect=function(renderer){var shader=this._resolveDirectShader(renderer),geometry=this._geometry,tint=this.tint,worldAlpha=this.worldAlpha,uniforms=shader.uniforms,drawCalls=geometry.drawCalls;uniforms.translationMatrix=this.transform.worldTransform,uniforms.tint[0]=(tint>>16&255)/255*worldAlpha,uniforms.tint[1]=(tint>>8&255)/255*worldAlpha,uniforms.tint[2]=(255&tint)/255*worldAlpha,uniforms.tint[3]=worldAlpha,renderer.shader.bind(shader),renderer.geometry.bind(geometry,shader),renderer.state.set(this.state);for(var i=0,l=drawCalls.length;i<l;i++)this._renderDrawCallDirect(renderer,geometry.drawCalls[i])},Graphics.prototype._renderDrawCallDirect=function(renderer,drawCall){for(var texArray=drawCall.texArray,type=drawCall.type,size=drawCall.size,start=drawCall.start,groupTextureCount=texArray.count,j=0;j<groupTextureCount;j++)renderer.texture.bind(texArray.elements[j],j);renderer.geometry.draw(type,size,start)},Graphics.prototype._resolveDirectShader=function(renderer){var shader=this.shader,pluginName=this.pluginName;if(!shader){if(!DEFAULT_SHADERS[pluginName]){for(var MAX_TEXTURES=renderer.plugins.batch.MAX_TEXTURES,sampleValues=new Int32Array(MAX_TEXTURES),i=0;i<MAX_TEXTURES;i++)sampleValues[i]=i;var uniforms={tint:new Float32Array([1,1,1,1]),translationMatrix:new Matrix,default:UniformGroup.from({uSamplers:sampleValues},!0)},program=renderer.plugins[pluginName]._shader.program;DEFAULT_SHADERS[pluginName]=new Shader(program,uniforms)}shader=DEFAULT_SHADERS[pluginName]}return shader},Graphics.prototype._calculateBounds=function(){this.finishPoly();var geometry=this._geometry;if(geometry.graphicsData.length){var _a=geometry.bounds,minX=_a.minX,minY=_a.minY,maxX=_a.maxX,maxY=_a.maxY;this._bounds.addFrame(this.transform,minX,minY,maxX,maxY)}},Graphics.prototype.containsPoint=function(point){return this.worldTransform.applyInverse(point,Graphics._TEMP_POINT),this._geometry.containsPoint(Graphics._TEMP_POINT)},Graphics.prototype.calculateTints=function(){if(this.batchTint!==this.tint){this.batchTint=this.tint;for(var tintRGB=hex2rgb(this.tint,temp),i=0;i<this.batches.length;i++){var batch=this.batches[i],batchTint=batch._batchRGB,color=(tintRGB[0]*batchTint[0]*255<<16)+(tintRGB[1]*batchTint[1]*255<<8)+(0|tintRGB[2]*batchTint[2]*255);batch._tintRGB=(color>>16)+(65280&color)+((255&color)<<16)}}},Graphics.prototype.calculateVertices=function(){var wtID=this.transform._worldID;if(this._transformID!==wtID){this._transformID=wtID;for(var wt=this.transform.worldTransform,a=wt.a,b=wt.b,c=wt.c,d=wt.d,tx=wt.tx,ty=wt.ty,data=this._geometry.points,vertexData=this.vertexData,count=0,i=0;i<data.length;i+=2){var x=data[i],y=data[i+1];vertexData[count++]=a*x+c*y+tx,vertexData[count++]=d*y+b*x+ty}}},Graphics.prototype.closePath=function(){var currentPath=this.currentPath;return currentPath&&(currentPath.closeStroke=!0),this},Graphics.prototype.setMatrix=function(matrix){return this._matrix=matrix,this},Graphics.prototype.beginHole=function(){return this.finishPoly(),this._holeMode=!0,this},Graphics.prototype.endHole=function(){return this.finishPoly(),this._holeMode=!1,this},Graphics.prototype.destroy=function(options){this._geometry.refCount--,0===this._geometry.refCount&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,_super.prototype.destroy.call(this,options)},Graphics._TEMP_POINT=new Point,Graphics}(Container),extendStatics$7=function(d,b){return(extendStatics$7=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};var TEXT_GRADIENT,tempPoint=new Point,indices=new Uint16Array([0,1,2,0,2,3]),Sprite=function(_super){function Sprite(texture){var _this=_super.call(this)||this;return _this._anchor=new ObservablePoint(_this._onAnchorUpdate,_this,texture?texture.defaultAnchor.x:0,texture?texture.defaultAnchor.y:0),_this._texture=null,_this._width=0,_this._height=0,_this._tint=null,_this._tintRGB=null,_this.tint=16777215,_this.blendMode=BLEND_MODES.NORMAL,_this._cachedTint=16777215,_this.uvs=null,_this.texture=texture||Texture.EMPTY,_this.vertexData=new Float32Array(8),_this.vertexTrimmedData=null,_this._transformID=-1,_this._textureID=-1,_this._transformTrimmedID=-1,_this._textureTrimmedID=-1,_this.indices=indices,_this.pluginName="batch",_this.isSprite=!0,_this._roundPixels=settings.ROUND_PIXELS,_this}return function(d,b){function __(){this.constructor=d}extendStatics$7(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}(Sprite,_super),Sprite.prototype._onTextureUpdate=function(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=sign$2(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=sign$2(this.scale.y)*this._height/this._texture.orig.height)},Sprite.prototype._onAnchorUpdate=function(){this._transformID=-1,this._transformTrimmedID=-1},Sprite.prototype.calculateVertices=function(){var texture=this._texture;if(this._transformID!==this.transform._worldID||this._textureID!==texture._updateID){this._textureID!==texture._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=texture._updateID;var wt=this.transform.worldTransform,a=wt.a,b=wt.b,c=wt.c,d=wt.d,tx=wt.tx,ty=wt.ty,vertexData=this.vertexData,trim=texture.trim,orig=texture.orig,anchor=this._anchor,w0=0,w1=0,h0=0,h1=0;if(trim?(w0=(w1=trim.x-anchor._x*orig.width)+trim.width,h0=(h1=trim.y-anchor._y*orig.height)+trim.height):(w0=(w1=-anchor._x*orig.width)+orig.width,h0=(h1=-anchor._y*orig.height)+orig.height),vertexData[0]=a*w1+c*h1+tx,vertexData[1]=d*h1+b*w1+ty,vertexData[2]=a*w0+c*h1+tx,vertexData[3]=d*h1+b*w0+ty,vertexData[4]=a*w0+c*h0+tx,vertexData[5]=d*h0+b*w0+ty,vertexData[6]=a*w1+c*h0+tx,vertexData[7]=d*h0+b*w1+ty,this._roundPixels)for(var resolution=settings.RESOLUTION,i=0;i<vertexData.length;++i)vertexData[i]=Math.round((vertexData[i]*resolution|0)/resolution)}},Sprite.prototype.calculateTrimmedVertices=function(){if(this.vertexTrimmedData){if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return}else this.vertexTrimmedData=new Float32Array(8);this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;var texture=this._texture,vertexData=this.vertexTrimmedData,orig=texture.orig,anchor=this._anchor,wt=this.transform.worldTransform,a=wt.a,b=wt.b,c=wt.c,d=wt.d,tx=wt.tx,ty=wt.ty,w1=-anchor._x*orig.width,w0=w1+orig.width,h1=-anchor._y*orig.height,h0=h1+orig.height;vertexData[0]=a*w1+c*h1+tx,vertexData[1]=d*h1+b*w1+ty,vertexData[2]=a*w0+c*h1+tx,vertexData[3]=d*h1+b*w0+ty,vertexData[4]=a*w0+c*h0+tx,vertexData[5]=d*h0+b*w0+ty,vertexData[6]=a*w1+c*h0+tx,vertexData[7]=d*h0+b*w1+ty},Sprite.prototype._render=function(renderer){this.calculateVertices(),renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]),renderer.plugins[this.pluginName].render(this)},Sprite.prototype._calculateBounds=function(){var trim=this._texture.trim,orig=this._texture.orig;!trim||trim.width===orig.width&&trim.height===orig.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))},Sprite.prototype.getLocalBounds=function(rect){return 0===this.children.length?(this._bounds.minX=this._texture.orig.width*-this._anchor._x,this._bounds.minY=this._texture.orig.height*-this._anchor._y,this._bounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._bounds.maxY=this._texture.orig.height*(1-this._anchor._y),rect||(this._localBoundsRect||(this._localBoundsRect=new Rectangle),rect=this._localBoundsRect),this._bounds.getRectangle(rect)):_super.prototype.getLocalBounds.call(this,rect)},Sprite.prototype.containsPoint=function(point){this.worldTransform.applyInverse(point,tempPoint);var width=this._texture.orig.width,height=this._texture.orig.height,x1=-width*this.anchor.x,y1=0;return tempPoint.x>=x1&&tempPoint.x<x1+width&&(y1=-height*this.anchor.y,tempPoint.y>=y1&&tempPoint.y<y1+height)},Sprite.prototype.destroy=function(options){if(_super.prototype.destroy.call(this,options),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,"boolean"==typeof options?options:options&&options.texture){var destroyBaseTexture="boolean"==typeof options?options:options&&options.baseTexture;this._texture.destroy(!!destroyBaseTexture)}this._texture=null},Sprite.from=function(source,options){return new Sprite(source instanceof Texture?source:Texture.from(source,options))},Object.defineProperty(Sprite.prototype,"roundPixels",{get:function(){return this._roundPixels},set:function(value){this._roundPixels!==value&&(this._transformID=-1),this._roundPixels=value},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"width",{get:function(){return Math.abs(this.scale.x)*this._texture.orig.width},set:function(value){var s=sign$2(this.scale.x)||1;this.scale.x=s*value/this._texture.orig.width,this._width=value},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"height",{get:function(){return Math.abs(this.scale.y)*this._texture.orig.height},set:function(value){var s=sign$2(this.scale.y)||1;this.scale.y=s*value/this._texture.orig.height,this._height=value},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"anchor",{get:function(){return this._anchor},set:function(value){this._anchor.copyFrom(value)},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"tint",{get:function(){return this._tint},set:function(value){this._tint=value,this._tintRGB=(value>>16)+(65280&value)+((255&value)<<16)},enumerable:!1,configurable:!0}),Object.defineProperty(Sprite.prototype,"texture",{get:function(){return this._texture},set:function(value){this._texture!==value&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=value||Texture.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,value&&(value.baseTexture.valid?this._onTextureUpdate():value.once("update",this._onTextureUpdate,this)))},enumerable:!1,configurable:!0}),Sprite}(Container),extendStatics$8=function(d,b){return(extendStatics$8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};!function(TEXT_GRADIENT){TEXT_GRADIENT[TEXT_GRADIENT.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",TEXT_GRADIENT[TEXT_GRADIENT.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL"}(TEXT_GRADIENT||(TEXT_GRADIENT={}));var defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:TEXT_GRADIENT.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],TextStyle=function(){function TextStyle(style){this.styleID=0,this.reset(),deepCopyProperties(this,style,style)}return TextStyle.prototype.clone=function(){var clonedProperties={};return deepCopyProperties(clonedProperties,this,defaultStyle),new TextStyle(clonedProperties)},TextStyle.prototype.reset=function(){deepCopyProperties(this,defaultStyle,defaultStyle)},Object.defineProperty(TextStyle.prototype,"align",{get:function(){return this._align},set:function(align){this._align!==align&&(this._align=align,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"breakWords",{get:function(){return this._breakWords},set:function(breakWords){this._breakWords!==breakWords&&(this._breakWords=breakWords,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadow",{get:function(){return this._dropShadow},set:function(dropShadow){this._dropShadow!==dropShadow&&(this._dropShadow=dropShadow,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowAlpha",{get:function(){return this._dropShadowAlpha},set:function(dropShadowAlpha){this._dropShadowAlpha!==dropShadowAlpha&&(this._dropShadowAlpha=dropShadowAlpha,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowAngle",{get:function(){return this._dropShadowAngle},set:function(dropShadowAngle){this._dropShadowAngle!==dropShadowAngle&&(this._dropShadowAngle=dropShadowAngle,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowBlur",{get:function(){return this._dropShadowBlur},set:function(dropShadowBlur){this._dropShadowBlur!==dropShadowBlur&&(this._dropShadowBlur=dropShadowBlur,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowColor",{get:function(){return this._dropShadowColor},set:function(dropShadowColor){var outputColor=getColor(dropShadowColor);this._dropShadowColor!==outputColor&&(this._dropShadowColor=outputColor,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"dropShadowDistance",{get:function(){return this._dropShadowDistance},set:function(dropShadowDistance){this._dropShadowDistance!==dropShadowDistance&&(this._dropShadowDistance=dropShadowDistance,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fill",{get:function(){return this._fill},set:function(fill){var outputColor=getColor(fill);this._fill!==outputColor&&(this._fill=outputColor,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fillGradientType",{get:function(){return this._fillGradientType},set:function(fillGradientType){this._fillGradientType!==fillGradientType&&(this._fillGradientType=fillGradientType,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fillGradientStops",{get:function(){return this._fillGradientStops},set:function(fillGradientStops){(function(array1,array2){if(!Array.isArray(array1)||!Array.isArray(array2))return!1;if(array1.length!==array2.length)return!1;for(var i=0;i<array1.length;++i)if(array1[i]!==array2[i])return!1;return!0})(this._fillGradientStops,fillGradientStops)||(this._fillGradientStops=fillGradientStops,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(fontFamily){this.fontFamily!==fontFamily&&(this._fontFamily=fontFamily,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontSize",{get:function(){return this._fontSize},set:function(fontSize){this._fontSize!==fontSize&&(this._fontSize=fontSize,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(fontStyle){this._fontStyle!==fontStyle&&(this._fontStyle=fontStyle,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontVariant",{get:function(){return this._fontVariant},set:function(fontVariant){this._fontVariant!==fontVariant&&(this._fontVariant=fontVariant,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(fontWeight){this._fontWeight!==fontWeight&&(this._fontWeight=fontWeight,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(letterSpacing){this._letterSpacing!==letterSpacing&&(this._letterSpacing=letterSpacing,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"lineHeight",{get:function(){return this._lineHeight},set:function(lineHeight){this._lineHeight!==lineHeight&&(this._lineHeight=lineHeight,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"leading",{get:function(){return this._leading},set:function(leading){this._leading!==leading&&(this._leading=leading,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"lineJoin",{get:function(){return this._lineJoin},set:function(lineJoin){this._lineJoin!==lineJoin&&(this._lineJoin=lineJoin,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"miterLimit",{get:function(){return this._miterLimit},set:function(miterLimit){this._miterLimit!==miterLimit&&(this._miterLimit=miterLimit,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"padding",{get:function(){return this._padding},set:function(padding){this._padding!==padding&&(this._padding=padding,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"stroke",{get:function(){return this._stroke},set:function(stroke){var outputColor=getColor(stroke);this._stroke!==outputColor&&(this._stroke=outputColor,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"strokeThickness",{get:function(){return this._strokeThickness},set:function(strokeThickness){this._strokeThickness!==strokeThickness&&(this._strokeThickness=strokeThickness,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"textBaseline",{get:function(){return this._textBaseline},set:function(textBaseline){this._textBaseline!==textBaseline&&(this._textBaseline=textBaseline,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"trim",{get:function(){return this._trim},set:function(trim){this._trim!==trim&&(this._trim=trim,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"whiteSpace",{get:function(){return this._whiteSpace},set:function(whiteSpace){this._whiteSpace!==whiteSpace&&(this._whiteSpace=whiteSpace,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"wordWrap",{get:function(){return this._wordWrap},set:function(wordWrap){this._wordWrap!==wordWrap&&(this._wordWrap=wordWrap,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(TextStyle.prototype,"wordWrapWidth",{get:function(){return this._wordWrapWidth},set:function(wordWrapWidth){this._wordWrapWidth!==wordWrapWidth&&(this._wordWrapWidth=wordWrapWidth,this.styleID++)},enumerable:!1,configurable:!0}),TextStyle.prototype.toFontString=function(){var fontSizeString="number"==typeof this.fontSize?this.fontSize+"px":this.fontSize,fontFamilies=this.fontFamily;Array.isArray(this.fontFamily)||(fontFamilies=this.fontFamily.split(","));for(var i=fontFamilies.length-1;i>=0;i--){var fontFamily=fontFamilies[i].trim();!/([\"\'])[^\'\"]+\1/.test(fontFamily)&&genericFontFamilies.indexOf(fontFamily)<0&&(fontFamily='"'+fontFamily+'"'),fontFamilies[i]=fontFamily}return this.fontStyle+" "+this.fontVariant+" "+this.fontWeight+" "+fontSizeString+" "+fontFamilies.join(",")},TextStyle}();function getSingleColor(color){return"number"==typeof color?hex2string(color):("string"==typeof color&&0===color.indexOf("0x")&&(color=color.replace("0x","#")),color)}function getColor(color){if(Array.isArray(color)){for(var i=0;i<color.length;++i)color[i]=getSingleColor(color[i]);return color}return getSingleColor(color)}function deepCopyProperties(target,source,propertyObj){for(var prop in propertyObj)Array.isArray(source[prop])?target[prop]=source[prop].slice():target[prop]=source[prop]}var TextMetrics=function(){function TextMetrics(text,style,width,height,lines,lineWidths,lineHeight,maxLineWidth,fontProperties){this.text=text,this.style=style,this.width=width,this.height=height,this.lines=lines,this.lineWidths=lineWidths,this.lineHeight=lineHeight,this.maxLineWidth=maxLineWidth,this.fontProperties=fontProperties}return TextMetrics.measureText=function(text,style,wordWrap,canvas){void 0===canvas&&(canvas=TextMetrics._canvas),wordWrap=null==wordWrap?style.wordWrap:wordWrap;var font=style.toFontString(),fontProperties=TextMetrics.measureFont(font);0===fontProperties.fontSize&&(fontProperties.fontSize=style.fontSize,fontProperties.ascent=style.fontSize);var context=canvas.getContext("2d");context.font=font;for(var lines=(wordWrap?TextMetrics.wordWrap(text,style,canvas):text).split(/(?:\r\n|\r|\n)/),lineWidths=new Array(lines.length),maxLineWidth=0,i=0;i<lines.length;i++){var lineWidth=context.measureText(lines[i]).width+(lines[i].length-1)*style.letterSpacing;lineWidths[i]=lineWidth,maxLineWidth=Math.max(maxLineWidth,lineWidth)}var width=maxLineWidth+style.strokeThickness;style.dropShadow&&(width+=style.dropShadowDistance);var lineHeight=style.lineHeight||fontProperties.fontSize+style.strokeThickness,height=Math.max(lineHeight,fontProperties.fontSize+style.strokeThickness)+(lines.length-1)*(lineHeight+style.leading);return style.dropShadow&&(height+=style.dropShadowDistance),new TextMetrics(text,style,width,height,lines,lineWidths,lineHeight+style.leading,maxLineWidth,fontProperties)},TextMetrics.wordWrap=function(text,style,canvas){void 0===canvas&&(canvas=TextMetrics._canvas);for(var context=canvas.getContext("2d"),width=0,line="",lines="",cache=Object.create(null),letterSpacing=style.letterSpacing,whiteSpace=style.whiteSpace,collapseSpaces=TextMetrics.collapseSpaces(whiteSpace),collapseNewlines=TextMetrics.collapseNewlines(whiteSpace),canPrependSpaces=!collapseSpaces,wordWrapWidth=style.wordWrapWidth+letterSpacing,tokens=TextMetrics.tokenize(text),i=0;i<tokens.length;i++){var token=tokens[i];if(TextMetrics.isNewline(token)){if(!collapseNewlines){lines+=TextMetrics.addLine(line),canPrependSpaces=!collapseSpaces,line="",width=0;continue}token=" "}if(collapseSpaces){var currIsBreakingSpace=TextMetrics.isBreakingSpace(token),lastIsBreakingSpace=TextMetrics.isBreakingSpace(line[line.length-1]);if(currIsBreakingSpace&&lastIsBreakingSpace)continue}var tokenWidth=TextMetrics.getFromCache(token,letterSpacing,cache,context);if(tokenWidth>wordWrapWidth)if(""!==line&&(lines+=TextMetrics.addLine(line),line="",width=0),TextMetrics.canBreakWords(token,style.breakWords))for(var characters=TextMetrics.wordWrapSplit(token),j=0;j<characters.length;j++){for(var char=characters[j],k=1;characters[j+k];){var nextChar=characters[j+k],lastChar=char[char.length-1];if(TextMetrics.canBreakChars(lastChar,nextChar,token,j,style.breakWords))break;char+=nextChar,k++}j+=char.length-1;var characterWidth=TextMetrics.getFromCache(char,letterSpacing,cache,context);characterWidth+width>wordWrapWidth&&(lines+=TextMetrics.addLine(line),canPrependSpaces=!1,line="",width=0),line+=char,width+=characterWidth}else{line.length>0&&(lines+=TextMetrics.addLine(line),line="",width=0);var isLastToken=i===tokens.length-1;lines+=TextMetrics.addLine(token,!isLastToken),canPrependSpaces=!1,line="",width=0}else tokenWidth+width>wordWrapWidth&&(canPrependSpaces=!1,lines+=TextMetrics.addLine(line),line="",width=0),(line.length>0||!TextMetrics.isBreakingSpace(token)||canPrependSpaces)&&(line+=token,width+=tokenWidth)}return lines+=TextMetrics.addLine(line,!1)},TextMetrics.addLine=function(line,newLine){return void 0===newLine&&(newLine=!0),line=TextMetrics.trimRight(line),line=newLine?line+"\n":line},TextMetrics.getFromCache=function(key,letterSpacing,cache,context){var width=cache[key];if("number"!=typeof width){var spacing=key.length*letterSpacing;width=context.measureText(key).width+spacing,cache[key]=width}return width},TextMetrics.collapseSpaces=function(whiteSpace){return"normal"===whiteSpace||"pre-line"===whiteSpace},TextMetrics.collapseNewlines=function(whiteSpace){return"normal"===whiteSpace},TextMetrics.trimRight=function(text){if("string"!=typeof text)return"";for(var i=text.length-1;i>=0;i--){var char=text[i];if(!TextMetrics.isBreakingSpace(char))break;text=text.slice(0,-1)}return text},TextMetrics.isNewline=function(char){return"string"==typeof char&&TextMetrics._newlines.indexOf(char.charCodeAt(0))>=0},TextMetrics.isBreakingSpace=function(char){return"string"==typeof char&&TextMetrics._breakingSpaces.indexOf(char.charCodeAt(0))>=0},TextMetrics.tokenize=function(text){var tokens=[],token="";if("string"!=typeof text)return tokens;for(var i=0;i<text.length;i++){var char=text[i];TextMetrics.isBreakingSpace(char)||TextMetrics.isNewline(char)?(""!==token&&(tokens.push(token),token=""),tokens.push(char)):token+=char}return""!==token&&tokens.push(token),tokens},TextMetrics.canBreakWords=function(_token,breakWords){return breakWords},TextMetrics.canBreakChars=function(_char,_nextChar,_token,_index,_breakWords){return!0},TextMetrics.wordWrapSplit=function(token){return token.split("")},TextMetrics.measureFont=function(font){if(TextMetrics._fonts[font])return TextMetrics._fonts[font];var properties={ascent:0,descent:0,fontSize:0},canvas=TextMetrics._canvas,context=TextMetrics._context;context.font=font;var metricsString=TextMetrics.METRICS_STRING+TextMetrics.BASELINE_SYMBOL,width=Math.ceil(context.measureText(metricsString).width),baseline=Math.ceil(context.measureText(TextMetrics.BASELINE_SYMBOL).width),height=2*baseline;baseline=baseline*TextMetrics.BASELINE_MULTIPLIER|0,canvas.width=width,canvas.height=height,context.fillStyle="#f00",context.fillRect(0,0,width,height),context.font=font,context.textBaseline="alphabetic",context.fillStyle="#000",context.fillText(metricsString,0,baseline);var imagedata=context.getImageData(0,0,width,height).data,pixels=imagedata.length,line=4*width,i=0,idx=0,stop=!1;for(i=0;i<baseline;++i){for(var j=0;j<line;j+=4)if(255!==imagedata[idx+j]){stop=!0;break}if(stop)break;idx+=line}for(properties.ascent=baseline-i,idx=pixels-line,stop=!1,i=height;i>baseline;--i){for(j=0;j<line;j+=4)if(255!==imagedata[idx+j]){stop=!0;break}if(stop)break;idx-=line}return properties.descent=i-baseline,properties.fontSize=properties.ascent+properties.descent,TextMetrics._fonts[font]=properties,properties},TextMetrics.clearMetrics=function(font){void 0===font&&(font=""),font?delete TextMetrics._fonts[font]:TextMetrics._fonts={}},TextMetrics}(),canvas=function(){try{var c=new OffscreenCanvas(0,0),context=c.getContext("2d");return context&&context.measureText?c:document.createElement("canvas")}catch(ex){return document.createElement("canvas")}}();canvas.width=canvas.height=10,TextMetrics._canvas=canvas,TextMetrics._context=canvas.getContext("2d"),TextMetrics._fonts={},TextMetrics.METRICS_STRING="|ÉqÅ",TextMetrics.BASELINE_SYMBOL="M",TextMetrics.BASELINE_MULTIPLIER=1.4,TextMetrics._newlines=[10,13],TextMetrics._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];var defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Text=function(_super){function Text(text,style,canvas){var _this=this,ownCanvas=!1;canvas||(canvas=document.createElement("canvas"),ownCanvas=!0),canvas.width=3,canvas.height=3;var texture=Texture.from(canvas);return texture.orig=new Rectangle,texture.trim=new Rectangle,(_this=_super.call(this,texture)||this)._ownCanvas=ownCanvas,_this.canvas=canvas,_this.context=_this.canvas.getContext("2d"),_this._resolution=settings.RESOLUTION,_this._autoResolution=!0,_this._text=null,_this._style=null,_this._styleListener=null,_this._font="",_this.text=text,_this.style=style,_this.localStyleID=-1,_this}return function(d,b){function __(){this.constructor=d}extendStatics$8(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}(Text,_super),Text.prototype.updateText=function(respectDirty){var style=this._style;if(this.localStyleID!==style.styleID&&(this.dirty=!0,this.localStyleID=style.styleID),this.dirty||!respectDirty){this._font=this._style.toFontString();var linePositionX,linePositionY,context=this.context,measured=TextMetrics.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),width=measured.width,height=measured.height,lines=measured.lines,lineHeight=measured.lineHeight,lineWidths=measured.lineWidths,maxLineWidth=measured.maxLineWidth,fontProperties=measured.fontProperties;this.canvas.width=Math.ceil((Math.max(1,width)+2*style.padding)*this._resolution),this.canvas.height=Math.ceil((Math.max(1,height)+2*style.padding)*this._resolution),context.scale(this._resolution,this._resolution),context.clearRect(0,0,this.canvas.width,this.canvas.height),context.font=this._font,context.lineWidth=style.strokeThickness,context.textBaseline=style.textBaseline,context.lineJoin=style.lineJoin,context.miterLimit=style.miterLimit;for(var passesCount=style.dropShadow?2:1,i=0;i<passesCount;++i){var isShadowPass=style.dropShadow&&0===i,dsOffsetText=isShadowPass?Math.ceil(Math.max(1,height)+2*style.padding):0,dsOffsetShadow=dsOffsetText*this._resolution;if(isShadowPass){context.fillStyle="black",context.strokeStyle="black";var dropShadowColor=style.dropShadowColor,rgb=hex2rgb("number"==typeof dropShadowColor?dropShadowColor:string2hex(dropShadowColor));context.shadowColor="rgba("+255*rgb[0]+","+255*rgb[1]+","+255*rgb[2]+","+style.dropShadowAlpha+")",context.shadowBlur=style.dropShadowBlur,context.shadowOffsetX=Math.cos(style.dropShadowAngle)*style.dropShadowDistance,context.shadowOffsetY=Math.sin(style.dropShadowAngle)*style.dropShadowDistance+dsOffsetShadow}else context.fillStyle=this._generateFillStyle(style,lines,measured),context.strokeStyle=style.stroke,context.shadowColor="black",context.shadowBlur=0,context.shadowOffsetX=0,context.shadowOffsetY=0;for(var i_1=0;i_1<lines.length;i_1++)linePositionX=style.strokeThickness/2,linePositionY=style.strokeThickness/2+i_1*lineHeight+fontProperties.ascent,"right"===style.align?linePositionX+=maxLineWidth-lineWidths[i_1]:"center"===style.align&&(linePositionX+=(maxLineWidth-lineWidths[i_1])/2),style.stroke&&style.strokeThickness&&this.drawLetterSpacing(lines[i_1],linePositionX+style.padding,linePositionY+style.padding-dsOffsetText,!0),style.fill&&this.drawLetterSpacing(lines[i_1],linePositionX+style.padding,linePositionY+style.padding-dsOffsetText)}this.updateTexture()}},Text.prototype.drawLetterSpacing=function(text,x,y,isStroke){void 0===isStroke&&(isStroke=!1);var letterSpacing=this._style.letterSpacing;if(0!==letterSpacing)for(var currentPosition=x,stringArray=Array.from?Array.from(text):text.split(""),previousWidth=this.context.measureText(text).width,currentWidth=0,i=0;i<stringArray.length;++i){var currentChar=stringArray[i];isStroke?this.context.strokeText(currentChar,currentPosition,y):this.context.fillText(currentChar,currentPosition,y),currentPosition+=previousWidth-(currentWidth=this.context.measureText(text.substring(i+1)).width)+letterSpacing,previousWidth=currentWidth}else isStroke?this.context.strokeText(text,x,y):this.context.fillText(text,x,y)},Text.prototype.updateTexture=function(){var canvas=this.canvas;if(this._style.trim){var trimmed=function(canvas){var i,x,y,width=canvas.width,height=canvas.height,context=canvas.getContext("2d"),pixels=context.getImageData(0,0,width,height).data,len=pixels.length,bound={top:null,left:null,right:null,bottom:null},data=null;for(i=0;i<len;i+=4)0!==pixels[i+3]&&(x=i/4%width,y=~~(i/4/width),null===bound.top&&(bound.top=y),(null===bound.left||x<bound.left)&&(bound.left=x),(null===bound.right||bound.right<x)&&(bound.right=x+1),(null===bound.bottom||bound.bottom<y)&&(bound.bottom=y));return null!==bound.top&&(width=bound.right-bound.left,height=bound.bottom-bound.top+1,data=context.getImageData(bound.left,bound.top,width,height)),{height:height,width:width,data:data}}(canvas);trimmed.data&&(canvas.width=trimmed.width,canvas.height=trimmed.height,this.context.putImageData(trimmed.data,0,0))}var texture=this._texture,style=this._style,padding=style.trim?0:style.padding,baseTexture=texture.baseTexture;texture.trim.width=texture._frame.width=Math.ceil(canvas.width/this._resolution),texture.trim.height=texture._frame.height=Math.ceil(canvas.height/this._resolution),texture.trim.x=-padding,texture.trim.y=-padding,texture.orig.width=texture._frame.width-2*padding,texture.orig.height=texture._frame.height-2*padding,this._onTextureUpdate(),baseTexture.setRealSize(canvas.width,canvas.height,this._resolution),this._recursivePostUpdateTransform(),this.dirty=!1},Text.prototype._render=function(renderer){this._autoResolution&&this._resolution!==renderer.resolution&&(this._resolution=renderer.resolution,this.dirty=!0),this.updateText(!0),_super.prototype._render.call(this,renderer)},Text.prototype.getLocalBounds=function(rect){return this.updateText(!0),_super.prototype.getLocalBounds.call(this,rect)},Text.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},Text.prototype._generateFillStyle=function(style,lines,metrics){var gradient,fillStyle=style.fill;if(!Array.isArray(fillStyle))return fillStyle;if(1===fillStyle.length)return fillStyle[0];var dropShadowCorrection=style.dropShadow?style.dropShadowDistance:0,padding=style.padding||0,width=Math.ceil(this.canvas.width/this._resolution)-dropShadowCorrection-2*padding,height=Math.ceil(this.canvas.height/this._resolution)-dropShadowCorrection-2*padding,fill=fillStyle.slice(),fillGradientStops=style.fillGradientStops.slice();if(!fillGradientStops.length)for(var lengthPlus1=fill.length+1,i=1;i<lengthPlus1;++i)fillGradientStops.push(i/lengthPlus1);if(fill.unshift(fillStyle[0]),fillGradientStops.unshift(0),fill.push(fillStyle[fillStyle.length-1]),fillGradientStops.push(1),style.fillGradientType===TEXT_GRADIENT.LINEAR_VERTICAL){gradient=this.context.createLinearGradient(width/2,padding,width/2,height+padding);var lastIterationStop=0,gradStopLineHeight=(metrics.fontProperties.fontSize+style.strokeThickness)/height;for(i=0;i<lines.length;i++)for(var thisLineTop=metrics.lineHeight*i,j=0;j<fill.length;j++){var globalStop=thisLineTop/height+("number"==typeof fillGradientStops[j]?fillGradientStops[j]:j/fill.length)*gradStopLineHeight,clampedStop=Math.max(lastIterationStop,globalStop);clampedStop=Math.min(clampedStop,1),gradient.addColorStop(clampedStop,fill[j]),lastIterationStop=clampedStop}}else{gradient=this.context.createLinearGradient(padding,height/2,width+padding,height/2);var totalIterations=fill.length+1,currentIteration=1;for(i=0;i<fill.length;i++){var stop=void 0;stop="number"==typeof fillGradientStops[i]?fillGradientStops[i]:currentIteration/totalIterations,gradient.addColorStop(stop,fill[i]),currentIteration++}}return gradient},Text.prototype.destroy=function(options){"boolean"==typeof options&&(options={children:options}),options=Object.assign({},defaultDestroyOptions,options),_super.prototype.destroy.call(this,options),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null},Object.defineProperty(Text.prototype,"width",{get:function(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width},set:function(value){this.updateText(!0);var s=sign$2(this.scale.x)||1;this.scale.x=s*value/this._texture.orig.width,this._width=value},enumerable:!1,configurable:!0}),Object.defineProperty(Text.prototype,"height",{get:function(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height},set:function(value){this.updateText(!0);var s=sign$2(this.scale.y)||1;this.scale.y=s*value/this._texture.orig.height,this._height=value},enumerable:!1,configurable:!0}),Object.defineProperty(Text.prototype,"style",{get:function(){return this._style},set:function(style){style=style||{},this._style=style instanceof TextStyle?style:new TextStyle(style),this.localStyleID=-1,this.dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(Text.prototype,"text",{get:function(){return this._text},set:function(text){text=String(null==text?"":text),this._text!==text&&(this._text=text,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(Text.prototype,"resolution",{get:function(){return this._resolution},set:function(value){this._autoResolution=!1,this._resolution!==value&&(this._resolution=value,this.dirty=!0)},enumerable:!1,configurable:!0}),Text}(Sprite);
|
|
163
163
|
/*!
|
|
164
164
|
* @pixi/prepare - v5.3.8
|
|
165
165
|
* Compiled Sat, 20 Feb 2021 22:28:33 UTC
|
|
@@ -396,7 +396,7 @@ var extendStatics$k=function(d,b){return(extendStatics$k=Object.setPrototypeOf||
|
|
|
396
396
|
* pixi.js is licensed under the MIT License.
|
|
397
397
|
* http://www.opensource.org/licenses/mit-license
|
|
398
398
|
*/
|
|
399
|
-
Renderer.registerPlugin("accessibility",AccessibilityManager),Renderer.registerPlugin("extract",Extract),Renderer.registerPlugin("interaction",InteractionManager),Renderer.registerPlugin("particle",ParticleRenderer),Renderer.registerPlugin("prepare",Prepare),Renderer.registerPlugin("batch",BatchRenderer),Renderer.registerPlugin("tilingSprite",TilingSpriteRenderer),Loader$1.registerPlugin(BitmapFontLoader),Loader$1.registerPlugin(SpritesheetLoader),Application.registerPlugin(TickerPlugin),Application.registerPlugin(AppLoaderPlugin);var PixiLayer=function(_super){function PixiLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(PixiLayer,_super),PixiLayer.prototype.onMount=function(event){if(_super.prototype.onMount.call(this,event),!this.elm){var container=document.createElement("div");container.setAttribute("id",""+this.id),container.setAttribute("class","webgl-layer"),this.elm=container,this.updateStyle();var elm=event.elm,height=event.height,pixiOptions={width:event.width||parseInt(this.elm.getAttribute("width"),10)||200,height:height||parseInt(this.elm.getAttribute("height"),10)||300,antialias:!0,transparent:!0,clearBeforeRender:!0,autoResize:!0,preserveDrawingBuffer:!0};this.ctx=new Application(pixiOptions),container.appendChild(this.ctx.view),elm.appendChild(container)}},PixiLayer.prototype.onUnmount=function(event){var _a,_b;_super.prototype.onUnmount.call(this,event);var renderType=this.renderType(),glContext=null===(_a=this.ctx.renderer)||void 0===_a?void 0:_a.gl;this.ctx.stop(),this.ctx.destroy(!0,{children:!0,texture:!0,baseTexture:!0}),renderType===RENDERER_TYPE.WEBGL&&(null===(_b=null==glContext?void 0:glContext.getExtension("WEBGL_lose_context"))||void 0===_b||_b.loseContext()),this.elm.remove(),this.elm=null,this.ctx=null},PixiLayer.prototype.onResize=function(event){_super.prototype.onResize.call(this,event),this.ctx.renderer.resize(event.width,event.height)},PixiLayer.prototype.onRescale=function(event){if(_super.prototype.onRescale.call(this,event),this.ctx){var flippedX=event.xBounds[0]>event.xBounds[1],flippedY=event.yBounds[0]>event.yBounds[1];this.ctx.stage.position.set(event.xScale(0),event.yScale(0)),this.ctx.stage.scale.set(event.xRatio*(flippedX?-1:1),event.yRatio*(flippedY?-1:1))}},PixiLayer.prototype.updateStyle=function(visible){var visibility=visible||this.isVisible?"visible":"hidden",interactive=this.interactive?"auto":"none";this.elm.setAttribute("style","position:absolute;pointer-events:"+interactive+";z-index:"+this.order+";opacity:"+this.opacity+";visibility:"+visibility)},PixiLayer.prototype.setVisibility=function(visible){_super.prototype.setVisibility.call(this,visible),this.elm&&this.updateStyle(visible)},PixiLayer.prototype.onOpacityChanged=function(opacity){this.elm&&this.updateStyle()},PixiLayer.prototype.onOrderChanged=function(order){this.elm&&this.updateStyle()},PixiLayer.prototype.onInteractivityChanged=function(interactive){this.elm&&this.updateStyle()},PixiLayer.prototype.renderType=function(){return this.ctx.renderer.type},PixiLayer}(Layer),GeomodelLayerV2=function(_super){function GeomodelLayerV2(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.isRendered=!1,_this.createPolygons=function(data){for(var polygons=[],polygon=null,i=0;i<data.length;i++){var topIsValid=!!data[i][1];topIsValid&&(null===polygon&&(polygon=[]),polygon.push(data[i][0],data[i][1]));var endIsReached=i===data.length-1;if((!topIsValid||endIsReached)&&polygon){for(var j=topIsValid?i:i-1;j>=0&&data[j][1];j--)polygon.push(data[j][0],data[j][2]||1e4);polygons.push(polygon),polygon=null}}return polygons},_this.generateAreaPolygon=function(s){var g=new Graphics;g.lineStyle(1,s.color,1),g.beginFill(s.color),_this.createPolygons(s.data).forEach((function(polygon){return g.drawPolygon(polygon)})),g.endFill(),_this.ctx.stage.addChild(g)},_this.generateSurfaceLine=function(s){var g=new Graphics,d=s.data;g.lineStyle(1,s.color,1,.5,!0);for(var penDown=!1,i=0;i<d.length;i++)d[i][1]?penDown?g.lineTo(d[i][0],d[i][1]):(g.moveTo(d[i][0],d[i][1]),penDown=!0):penDown=!1;_this.ctx.stage.addChild(g)},_this}return __extends(GeomodelLayerV2,_super),GeomodelLayerV2.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.isRendered||this.render()},GeomodelLayerV2.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.isRendered=!1,this.cleanUpStage(),this.render()},GeomodelLayerV2.prototype.cleanUpStage=function(){this.ctx.stage.children.forEach((function(g){return g.destroy()})),this.ctx.stage.removeChildren()},GeomodelLayerV2.prototype.render=function(){var _this=this,data=this.data;data&&(data.areas.forEach((function(a){return _this.generateAreaPolygon(a)})),data.lines.forEach((function(l){return _this.generateSurfaceLine(l)})),this.isRendered=!0)},GeomodelLayerV2}(PixiLayer),GeomodelLayer=function(_super){function GeomodelLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(GeomodelLayer,_super),GeomodelLayer}(GeomodelLayerV2);function define(constructor,factory,prototype){constructor.prototype=factory.prototype=prototype,prototype.constructor=constructor}function extend(parent,definition){var prototype=Object.create(parent.prototype);for(var key in definition)prototype[key]=definition[key];return prototype}function Color(){}var brighter=1/.7,reI="\\s*([+-]?\\d+)\\s*",reN="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",reP="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",reHex=/^#([0-9a-f]{3,8})$/,reRgbInteger=new RegExp("^rgb\\("+[reI,reI,reI]+"\\)$"),reRgbPercent=new RegExp("^rgb\\("+[reP,reP,reP]+"\\)$"),reRgbaInteger=new RegExp("^rgba\\("+[reI,reI,reI,reN]+"\\)$"),reRgbaPercent=new RegExp("^rgba\\("+[reP,reP,reP,reN]+"\\)$"),reHslPercent=new RegExp("^hsl\\("+[reN,reP,reP]+"\\)$"),reHslaPercent=new RegExp("^hsla\\("+[reN,reP,reP,reN]+"\\)$"),named={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function color_formatHex(){return this.rgb().formatHex()}function color_formatRgb(){return this.rgb().formatRgb()}function color(format){var m,l;return format=(format+"").trim().toLowerCase(),(m=reHex.exec(format))?(l=m[1].length,m=parseInt(m[1],16),6===l?rgbn(m):3===l?new Rgb(m>>8&15|m>>4&240,m>>4&15|240&m,(15&m)<<4|15&m,1):8===l?rgba(m>>24&255,m>>16&255,m>>8&255,(255&m)/255):4===l?rgba(m>>12&15|m>>8&240,m>>8&15|m>>4&240,m>>4&15|240&m,((15&m)<<4|15&m)/255):null):(m=reRgbInteger.exec(format))?new Rgb(m[1],m[2],m[3],1):(m=reRgbPercent.exec(format))?new Rgb(255*m[1]/100,255*m[2]/100,255*m[3]/100,1):(m=reRgbaInteger.exec(format))?rgba(m[1],m[2],m[3],m[4]):(m=reRgbaPercent.exec(format))?rgba(255*m[1]/100,255*m[2]/100,255*m[3]/100,m[4]):(m=reHslPercent.exec(format))?hsla(m[1],m[2]/100,m[3]/100,1):(m=reHslaPercent.exec(format))?hsla(m[1],m[2]/100,m[3]/100,m[4]):named.hasOwnProperty(format)?rgbn(named[format]):"transparent"===format?new Rgb(NaN,NaN,NaN,0):null}function rgbn(n){return new Rgb(n>>16&255,n>>8&255,255&n,1)}function rgba(r,g,b,a){return a<=0&&(r=g=b=NaN),new Rgb(r,g,b,a)}function rgbConvert(o){return o instanceof Color||(o=color(o)),o?new Rgb((o=o.rgb()).r,o.g,o.b,o.opacity):new Rgb}function rgb(r,g,b,opacity){return 1===arguments.length?rgbConvert(r):new Rgb(r,g,b,null==opacity?1:opacity)}function Rgb(r,g,b,opacity){this.r=+r,this.g=+g,this.b=+b,this.opacity=+opacity}function rgb_formatHex(){return"#"+hex(this.r)+hex(this.g)+hex(this.b)}function rgb_formatRgb(){var a=this.opacity;return(1===(a=isNaN(a)?1:Math.max(0,Math.min(1,a)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===a?")":", "+a+")")}function hex(value){return((value=Math.max(0,Math.min(255,Math.round(value)||0)))<16?"0":"")+value.toString(16)}function hsla(h,s,l,a){return a<=0?h=s=l=NaN:l<=0||l>=1?h=s=NaN:s<=0&&(h=NaN),new Hsl(h,s,l,a)}function hslConvert(o){if(o instanceof Hsl)return new Hsl(o.h,o.s,o.l,o.opacity);if(o instanceof Color||(o=color(o)),!o)return new Hsl;if(o instanceof Hsl)return o;var r=(o=o.rgb()).r/255,g=o.g/255,b=o.b/255,min=Math.min(r,g,b),max=Math.max(r,g,b),h=NaN,s=max-min,l=(max+min)/2;return s?(h=r===max?(g-b)/s+6*(g<b):g===max?(b-r)/s+2:(r-g)/s+4,s/=l<.5?max+min:2-max-min,h*=60):s=l>0&&l<1?0:h,new Hsl(h,s,l,o.opacity)}function Hsl(h,s,l,opacity){this.h=+h,this.s=+s,this.l=+l,this.opacity=+opacity}function hsl2rgb(h,m1,m2){return 255*(h<60?m1+(m2-m1)*h/60:h<180?m2:h<240?m1+(m2-m1)*(240-h)/60:m1)}function convertColor(colorStr){var d=color(colorStr).hex();return parseInt(d.replace("#","0x"))}define(Color,color,{copy:function(channels){return Object.assign(new this.constructor,this,channels)},displayable:function(){return this.rgb().displayable()},hex:color_formatHex,formatHex:color_formatHex,formatHsl:function(){return hslConvert(this).formatHsl()},formatRgb:color_formatRgb,toString:color_formatRgb}),define(Rgb,rgb,extend(Color,{brighter:function(k){return k=null==k?brighter:Math.pow(brighter,k),new Rgb(this.r*k,this.g*k,this.b*k,this.opacity)},darker:function(k){return k=null==k?.7:Math.pow(.7,k),new Rgb(this.r*k,this.g*k,this.b*k,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rgb_formatHex,formatHex:rgb_formatHex,formatRgb:rgb_formatRgb,toString:rgb_formatRgb})),define(Hsl,(function(h,s,l,opacity){return 1===arguments.length?hslConvert(h):new Hsl(h,s,l,null==opacity?1:opacity)}),extend(Color,{brighter:function(k){return k=null==k?brighter:Math.pow(brighter,k),new Hsl(this.h,this.s,this.l*k,this.opacity)},darker:function(k){return k=null==k?.7:Math.pow(.7,k),new Hsl(this.h,this.s,this.l*k,this.opacity)},rgb:function(){var h=this.h%360+360*(this.h<0),s=isNaN(h)||isNaN(this.s)?0:this.s,l=this.l,m2=l+(l<.5?l:1-l)*s,m1=2*l-m2;return new Rgb(hsl2rgb(h>=240?h-240:h+120,m1,m2),hsl2rgb(h,m1,m2),hsl2rgb(h<120?h+240:h-120,m1,m2),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var a=this.opacity;return(1===(a=isNaN(a)?1:Math.max(0,Math.min(1,a)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===a?")":", "+a+")")}}));var GeomodelCanvasLayer=function(_super){function GeomodelCanvasLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.surfaceAreasPaths=[],_this.surfaceLinesPaths=[],_this.maxDepth=1e4,_this.drawPolygonPath=function(color,path){var ctx=_this.ctx;ctx.fillStyle=color,ctx.fill(path)},_this.drawLinePath=function(color,path){var ctx=_this.ctx;ctx.strokeStyle=color,ctx.stroke(path)},_this.createPolygons=function(data){for(var polygons=[],polygon=null,i=0;i<data.length;i++){var topIsValid=!!data[i][1];topIsValid&&(null===polygon&&(polygon=[]),polygon.push(data[i][0],data[i][1]));var endIsReached=i===data.length-1;if((!topIsValid||endIsReached)&&polygon){for(var j=topIsValid?i:i-1;j>=0&&data[j][1];j--)polygon.push(data[j][0],data[j][2]||_this.maxDepth);polygons.push(polygon),polygon=null}}return polygons},_this.generatePolygonPath=function(polygon){var path=new Path2D;path.moveTo(polygon[0],polygon[1]);for(var i=2;i<polygon.length;i+=2)path.lineTo(polygon[i],polygon[i+1]);return path.closePath(),path},_this.generateLinePaths=function(s){for(var paths=[],d=s.data,penDown=!1,path=null,i=0;i<d.length;i++)d[i][1]?penDown?path.lineTo(d[i][0],d[i][1]):((path=new Path2D).moveTo(d[i][0],d[i][1]),penDown=!0):penDown&&(paths.push(path),penDown=!1);return penDown&&paths.push(path),paths},_this.render=_this.render.bind(_this),_this.generateSurfaceAreasPaths=_this.generateSurfaceAreasPaths.bind(_this),_this.generateSurfaceLinesPaths=_this.generateSurfaceLinesPaths.bind(_this),_this.drawPolygonPath=_this.drawPolygonPath.bind(_this),_this.drawLinePath=_this.drawLinePath.bind(_this),_this}return __extends(GeomodelCanvasLayer,_super),Object.defineProperty(GeomodelCanvasLayer.prototype,"data",{get:function(){return _super.prototype.getData.call(this)},set:function(data){this.setData(data)},enumerable:!1,configurable:!0}),GeomodelCanvasLayer.prototype.getData=function(){return _super.prototype.getData.call(this)},GeomodelCanvasLayer.prototype.setData=function(data){_super.prototype.setData.call(this,data)},GeomodelCanvasLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event)},GeomodelCanvasLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.data?(this.generateSurfaceAreasPaths(),this.generateSurfaceLinesPaths()):(this.surfaceAreasPaths=[],this.surfaceLinesPaths=[]),this.render()},GeomodelCanvasLayer.prototype.onRescale=function(event){this.rescaleEvent=event,this.setTransform(this.rescaleEvent),this.render()},GeomodelCanvasLayer.prototype.render=function(){var _this=this;this.ctx&&this.rescaleEvent&&(this.clearCanvas(),this.surfaceAreasPaths.forEach((function(p){return _this.drawPolygonPath(p.color,p.path)})),this.surfaceLinesPaths.forEach((function(l){return _this.drawLinePath(l.color,l.path)})))},GeomodelCanvasLayer.prototype.colorToCSSColor=function(color){return function(color){if("string"==typeof color)return color;var hexString=color.toString(16);return"#"+("000000".substr(0,6-hexString.length)+hexString)}(color)},GeomodelCanvasLayer.prototype.generateSurfaceAreasPaths=function(){var _this=this;this.surfaceAreasPaths=this.data.areas.reduce((function(acc,s){var mapped=_this.createPolygons(s.data).map((function(polygon){return{color:_this.colorToCSSColor(s.color),path:_this.generatePolygonPath(polygon)}}));return __spreadArray(__spreadArray([],acc),mapped)}),[])},GeomodelCanvasLayer.prototype.generateSurfaceLinesPaths=function(){var _this=this;this.surfaceLinesPaths=this.data.lines.reduce((function(acc,l){var mapped=_this.generateLinePaths(l).map((function(path){return{color:_this.colorToCSSColor(l.color),path:path}}));return __spreadArray(__spreadArray([],acc),mapped)}),[])},GeomodelCanvasLayer}(CanvasLayer),DEG2RAD=Math.PI/180;function clamp(value,min,max){return void 0===min&&(min=0),void 0===max&&(max=1),value<min?min:value>max?max:value}function seqI(steps){var target=new Array(steps),incr=1/(steps-1);target[0]=0;for(var i=1;i<steps-1;i++)target[i]=i*incr;return target[steps-1]=1,target}function add(a,b,target){void 0===target&&(target=a);for(var i=0;i<a.length;i++)target[i]=a[i]+b[i];return target}function sub(a,b,target){void 0===target&&(target=a);for(var i=0;i<a.length;i++)target[i]=a[i]-b[i];return target}function scale(a,factor,target){void 0===target&&(target=a);for(var i=0;i<a.length;i++)target[i]=a[i]*factor;return target}function magnitude(a){var sq=function(a){for(var sum=0,i=0;i<a.length;i++)sum+=Math.pow(a[i],2);return sum}(a);return 0===sq?sq:Math.sqrt(sq)}function normalize(a,target){void 0===target&&(target=a);var len=magnitude(a);return 0===len?function(value,target){for(var i=0;i<target.length;i++)target[i]=value;return target}(0,target):scale(a,1/len,target)}function isZeroVector(a,epsilon){void 0===epsilon&&(epsilon=0),void 0===epsilon&&(epsilon=0);for(var i=0;i<a.length;i++)if(Math.abs(a[i])>epsilon)return!1;return!0}var RAD2DEG=180/Math.PI,DEG2RAD$1=Math.PI/180;function rotate(v,rad,target){var cr=Math.cos(rad),sr=Math.sin(rad),x=v[0];return target[0]=cr*x-sr*v[1],target[1]=sr*x+cr*v[1],target}function angleRight(v){return Math.atan2(v[1],v[0])}function signedAngle(a,b){var phi=Math.atan2(b[1],b[0])-Math.atan2(a[1],a[0]);return phi>Math.PI?phi-=2*Math.PI:phi<=-Math.PI&&(phi+=2*Math.PI),phi}var Vector2=function(){function Vector2(a){for(var b=[],_i=1;_i<arguments.length;_i++)b[_i-1]=arguments[_i];this.isMutating=!1,this.length=2,"number"==typeof a?"number"==typeof b[0]?(this[0]=a,this[1]=b[0]):(this[0]=a,this[1]=a):"x"in a&&"y"in a?(this[0]=a.x,this[1]=a.y):(this[0]=a[0],this[1]=a[1])}return Object.defineProperty(Vector2.prototype,"x",{get:function(){return this[0]},set:function(value){this[0]=value},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2.prototype,"y",{get:function(){return this[1]},set:function(value){this[1]=value},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2.prototype,"magnitude",{get:function(){return magnitude(this)},set:function(val){scale(this,val/magnitude(this),this)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2.prototype,"mutable",{get:function(){return this.isMutating=!0,this},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2.prototype,"immutable",{get:function(){return this.isMutating=!1,this},enumerable:!0,configurable:!0}),Vector2.prototype.set=function(a,b){return"number"==typeof a?"number"==typeof b?(this[0]=a,this[1]=b):(this[0]=a,this[1]=a):(this[0]=a[0],this[1]=a[1]),this},Vector2.prototype.add=function(a,b){return void 0===b&&(b=0),"number"==typeof a?this.isMutating?add(this,[a,b]):add(this.clone(),[a,b]):this.isMutating?add(this,a):add(this.clone(),a)},Vector2.add=function(a,b){return add(new Vector2(a),b)},Vector2.prototype.sub=function(a,b){return void 0===b&&(b=0),"number"==typeof a?this.isMutating?sub(this,[a,b]):sub(this.clone(),[a,b]):this.isMutating?sub(this,a):sub(this.clone(),a)},Vector2.sub=function(a,b){return sub(new Vector2(a),b)},Vector2.prototype.subFrom=function(a,b){return void 0===b&&(b=0),"number"==typeof a?this.isMutating?(this[0]=a-this[0],this[1]=b-this[1],this):new Vector2(a-this[0],b-this[1]):this.isMutating?(this[0]=a[0]-this[0],this[1]=a[1]-this[1],this):new Vector2(a[0]-this[0],a[1]-this[1])},Vector2.divide=function(v,n){return scale(new Vector2(v),1/n)},Vector2.multiply=function(v,n){return scale(new Vector2(v),n)},Vector2.prototype.scale=function(n){return scale(this,n,this.isMutating?this:Vector2.zero)},Vector2.prototype.rescale=function(n){var len=magnitude(this);return len<=0?this.isMutating?this:Vector2.zero:scale(this,n/len,this.isMutating?this:Vector2.zero)},Vector2.prototype.clampMagnitude=function(n){var len=magnitude(this);return len>n?scale(this,n/len,this.isMutating?this:Vector2.zero):this.isMutating?this:this.clone()},Vector2.prototype.rotate=function(rad){return rotate(this,rad,this.isMutating?this:Vector2.zero)},Vector2.prototype.rotateDeg=function(deg){return rotate(this,deg*DEG2RAD$1,this.isMutating?this:Vector2.zero)},Vector2.prototype.rotate90=function(){return this,target=this.isMutating?this:Vector2.zero,x=this[0],target[0]=-this[1],target[1]=x,target;var target,x},Vector2.prototype.rotate180=function(){return this,(target=this.isMutating?this:Vector2.zero)[0]=-this[0],target[1]=-this[1],target;var target},Vector2.prototype.rotate270=function(){return this,target=this.isMutating?this:Vector2.zero,x=this[0],target[0]=this[1],target[1]=-x,target;var target,x},Vector2.prototype.normalize=function(){return normalize(this)},Vector2.prototype.normalized=function(){return normalize(this,Vector2.zero)},Vector2.distance=function(a,b){return function(a,b){for(var sq=0,i=0;i<a.length;i++)sq+=Math.pow(b[i]-a[i],2);return 0===sq?sq:Math.sqrt(sq)}(a,b)},Vector2.dot=function(a,b){return function(a,b){for(var sum=0,i=0;i<a.length;i++)sum+=a[i]*b[i];return sum}(a,b)},Vector2.cross=function(a,b){return function(a,b){return a[0]*b[1]-a[1]*b[0]}(a,b)},Vector2.angleRight=function(v){return angleRight(v)},Vector2.angleRightDeg=function(v){return angleRight(v)*RAD2DEG},Vector2.angle=function(a,b){return Math.abs(signedAngle(a,b))},Vector2.angleDeg=function(a,b){return Math.abs(signedAngle(a,b))*RAD2DEG},Vector2.signedAngle=function(a,b){return signedAngle(a,b)},Vector2.signedAngleDeg=function(a,b){return signedAngle(a,b)*RAD2DEG},Vector2.lerp=function(a,b,t){return function(a,b,t,target){void 0===target&&(target=a);for(var n=clamp(t,0,1),m=1-n,i=0;i<a.length;i++)target[i]=a[i]*m+b[i]*n;return target}(new Vector2(a),b,t)},Vector2.lerpRot=function(a,b,t){return function(a,b,n,target){return void 0===target&&(target=a),rotate(a,n*signedAngle(a,b),target)}(a,b,t,Vector2.zero)},Vector2.prototype.clone=function(){return new Vector2(this[0],this[1])},Vector2.equals=function(a,b,epsilon){return void 0===epsilon&&(epsilon=0),!(Math.abs(a[0]-b[0])>epsilon||Math.abs(a[1]-b[1])>epsilon)},Vector2.prototype.equals=function(vector,epsilon){return void 0===epsilon&&(epsilon=0),Vector2.equals(this,vector,epsilon)},Vector2.isZeroVector=function(vector,epsilon){return void 0===epsilon&&(epsilon=0),isZeroVector(vector,epsilon)},Vector2.prototype.isZeroVector=function(epsilon){return void 0===epsilon&&(epsilon=0),isZeroVector(this,epsilon)},Vector2.prototype.toArray=function(){return[this[0],this[1]]},Vector2.prototype.modify=function(modifier){return function(a,modifier,target){void 0===target&&(target=a);for(var i=0;i<a.length;i++)target[i]=modifier(a[i],i);return target}(this,modifier)},Vector2.prototype[Symbol.iterator]=function(){var _this=this,i=0;return{next:function(){switch(i++){case 0:return{value:_this[0],done:!1};case 1:return{value:_this[1],done:!1};default:return{value:-1,done:!0}}}}},Object.defineProperty(Vector2,"zero",{get:function(){return new Vector2(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"one",{get:function(){return new Vector2(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"positiveInfinity",{get:function(){return new Vector2(1/0,1/0)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"negativeInfinity",{get:function(){return new Vector2(-1/0,-1/0)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"up",{get:function(){return new Vector2(0,1)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"right",{get:function(){return new Vector2(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"down",{get:function(){return new Vector2(0,-1)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"left",{get:function(){return new Vector2(-1,0)},enumerable:!0,configurable:!0}),Vector2}(),constant$2=x=>()=>x;function gamma(y){return 1==(y=+y)?nogamma:function(a,b){return b-a?function(a,b,y){return a=Math.pow(a,y),b=Math.pow(b,y)-a,y=1/y,function(t){return Math.pow(a+t*b,y)}}(a,b,y):constant$2(isNaN(a)?b:a)}}function nogamma(a,b){var d=b-a;return d?function(a,d){return function(t){return a+t*d}}(a,d):constant$2(isNaN(a)?b:a)}var interpolateRgb=function rgbGamma(y){var color=gamma(y);function rgb$1(start,end){var r=color((start=rgb(start)).r,(end=rgb(end)).r),g=color(start.g,end.g),b=color(start.b,end.b),opacity=nogamma(start.opacity,end.opacity);return function(t){return start.r=r(t),start.g=g(t),start.b=b(t),start.opacity=opacity(t),start+""}}return rgb$1.gamma=rgbGamma,rgb$1}(1);function numberArray(a,b){b||(b=[]);var i,n=a?Math.min(b.length,a.length):0,c=b.slice();return function(t){for(i=0;i<n;++i)c[i]=a[i]*(1-t)+b[i]*t;return c}}function genericArray(a,b){var i,nb=b?b.length:0,na=a?Math.min(nb,a.length):0,x=new Array(na),c=new Array(nb);for(i=0;i<na;++i)x[i]=interpolate(a[i],b[i]);for(;i<nb;++i)c[i]=b[i];return function(t){for(i=0;i<na;++i)c[i]=x[i](t);return c}}function date(a,b){var d=new Date;return a=+a,b=+b,function(t){return d.setTime(a*(1-t)+b*t),d}}function interpolateNumber(a,b){return a=+a,b=+b,function(t){return a*(1-t)+b*t}}function object(a,b){var k,i={},c={};for(k in null!==a&&"object"==typeof a||(a={}),null!==b&&"object"==typeof b||(b={}),b)k in a?i[k]=interpolate(a[k],b[k]):c[k]=b[k];return function(t){for(k in i)c[k]=i[k](t);return c}}var reA=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,reB=new RegExp(reA.source,"g");function string(a,b){var am,bm,bs,bi=reA.lastIndex=reB.lastIndex=0,i=-1,s=[],q=[];for(a+="",b+="";(am=reA.exec(a))&&(bm=reB.exec(b));)(bs=bm.index)>bi&&(bs=b.slice(bi,bs),s[i]?s[i]+=bs:s[++i]=bs),(am=am[0])===(bm=bm[0])?s[i]?s[i]+=bm:s[++i]=bm:(s[++i]=null,q.push({i:i,x:interpolateNumber(am,bm)})),bi=reB.lastIndex;return bi<b.length&&(bs=b.slice(bi),s[i]?s[i]+=bs:s[++i]=bs),s.length<2?q[0]?function(b){return function(t){return b(t)+""}}(q[0].x):function(b){return function(){return b}}(b):(b=q.length,function(t){for(var o,i=0;i<b;++i)s[(o=q[i]).i]=o.x(t);return s.join("")})}function interpolate(a,b){var c,t=typeof b;return null==b||"boolean"===t?constant$2(b):("number"===t?interpolateNumber:"string"===t?(c=color(b))?(b=c,interpolateRgb):string:b instanceof color?interpolateRgb:b instanceof Date?date:function(x){return ArrayBuffer.isView(x)&&!(x instanceof DataView)}(b)?numberArray:Array.isArray(b)?genericArray:"function"!=typeof b.valueOf&&"function"!=typeof b.toString||isNaN(b)?object:interpolateNumber)(a,b)}function interpolateRound(a,b){return a=+a,b=+b,function(t){return Math.round(a*(1-t)+b*t)}}function ascending$1(a,b){return a<b?-1:a>b?1:a>=b?0:NaN}function bisector(f){let delta=f,compare=f;function left(a,x,lo,hi){for(null==lo&&(lo=0),null==hi&&(hi=a.length);lo<hi;){const mid=lo+hi>>>1;compare(a[mid],x)<0?lo=mid+1:hi=mid}return lo}return 1===f.length&&(delta=(d,x)=>f(d)-x,compare=function(f){return(d,x)=>ascending$1(f(d),x)}(f)),{left:left,center:function(a,x,lo,hi){null==lo&&(lo=0),null==hi&&(hi=a.length);const i=left(a,x,lo,hi-1);return i>lo&&delta(a[i-1],x)>-delta(a[i],x)?i-1:i},right:function(a,x,lo,hi){for(null==lo&&(lo=0),null==hi&&(hi=a.length);lo<hi;){const mid=lo+hi>>>1;compare(a[mid],x)>0?hi=mid:lo=mid+1}return lo}}}const bisectRight=bisector(ascending$1).right;bisector((function(x){return null===x?NaN:+x})).center;var e10=Math.sqrt(50),e5=Math.sqrt(10),e2=Math.sqrt(2);function tickIncrement(start,stop,count){var step=(stop-start)/Math.max(0,count),power=Math.floor(Math.log(step)/Math.LN10),error=step/Math.pow(10,power);return power>=0?(error>=e10?10:error>=e5?5:error>=e2?2:1)*Math.pow(10,power):-Math.pow(10,-power)/(error>=e10?10:error>=e5?5:error>=e2?2:1)}function merge(arrays){return Array.from(function*(arrays){for(const array of arrays)yield*array}(arrays))}function initRange(domain,range){switch(arguments.length){case 0:break;case 1:this.range(domain);break;default:this.range(range).domain(domain)}return this}const implicit=Symbol("implicit");function number$1(x){return+x}var unit=[0,1];function identity(x){return x}function normalize$1(a,b){return(b-=a=+a)?function(x){return(x-a)/b}:function(x){return function(){return x}}(isNaN(b)?NaN:.5)}function bimap(domain,range,interpolate){var d0=domain[0],d1=domain[1],r0=range[0],r1=range[1];return d1<d0?(d0=normalize$1(d1,d0),r0=interpolate(r1,r0)):(d0=normalize$1(d0,d1),r0=interpolate(r0,r1)),function(x){return r0(d0(x))}}function polymap(domain,range,interpolate){var j=Math.min(domain.length,range.length)-1,d=new Array(j),r=new Array(j),i=-1;for(domain[j]<domain[0]&&(domain=domain.slice().reverse(),range=range.slice().reverse());++i<j;)d[i]=normalize$1(domain[i],domain[i+1]),r[i]=interpolate(range[i],range[i+1]);return function(x){var i=bisectRight(domain,x,1,j)-1;return r[i](d[i](x))}}function copy(source,target){return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown())}function transformer(){var transform,untransform,unknown,piecewise,output,input,domain=unit,range=unit,interpolate$1=interpolate,clamp=identity;function rescale(){var a,b,t,n=Math.min(domain.length,range.length);return clamp!==identity&&(a=domain[0],b=domain[n-1],a>b&&(t=a,a=b,b=t),clamp=function(x){return Math.max(a,Math.min(b,x))}),piecewise=n>2?polymap:bimap,output=input=null,scale}function scale(x){return isNaN(x=+x)?unknown:(output||(output=piecewise(domain.map(transform),range,interpolate$1)))(transform(clamp(x)))}return scale.invert=function(y){return clamp(untransform((input||(input=piecewise(range,domain.map(transform),interpolateNumber)))(y)))},scale.domain=function(_){return arguments.length?(domain=Array.from(_,number$1),rescale()):domain.slice()},scale.range=function(_){return arguments.length?(range=Array.from(_),rescale()):range.slice()},scale.rangeRound=function(_){return range=Array.from(_),interpolate$1=interpolateRound,rescale()},scale.clamp=function(_){return arguments.length?(clamp=!!_||identity,rescale()):clamp!==identity},scale.interpolate=function(_){return arguments.length?(interpolate$1=_,rescale()):interpolate$1},scale.unknown=function(_){return arguments.length?(unknown=_,scale):unknown},function(t,u){return transform=t,untransform=u,rescale()}}function continuous(){return transformer()(identity,identity)}function formatDecimalParts(x,p){if((i=(x=p?x.toExponential(p-1):x.toExponential()).indexOf("e"))<0)return null;var i,coefficient=x.slice(0,i);return[coefficient.length>1?coefficient[0]+coefficient.slice(2):coefficient,+x.slice(i+1)]}function exponent(x){return(x=formatDecimalParts(Math.abs(x)))?x[1]:NaN}var prefixExponent,re=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function formatSpecifier(specifier){if(!(match=re.exec(specifier)))throw new Error("invalid format: "+specifier);var match;return new FormatSpecifier({fill:match[1],align:match[2],sign:match[3],symbol:match[4],zero:match[5],width:match[6],comma:match[7],precision:match[8]&&match[8].slice(1),trim:match[9],type:match[10]})}function FormatSpecifier(specifier){this.fill=void 0===specifier.fill?" ":specifier.fill+"",this.align=void 0===specifier.align?">":specifier.align+"",this.sign=void 0===specifier.sign?"-":specifier.sign+"",this.symbol=void 0===specifier.symbol?"":specifier.symbol+"",this.zero=!!specifier.zero,this.width=void 0===specifier.width?void 0:+specifier.width,this.comma=!!specifier.comma,this.precision=void 0===specifier.precision?void 0:+specifier.precision,this.trim=!!specifier.trim,this.type=void 0===specifier.type?"":specifier.type+""}function formatRounded(x,p){var d=formatDecimalParts(x,p);if(!d)return x+"";var coefficient=d[0],exponent=d[1];return exponent<0?"0."+new Array(-exponent).join("0")+coefficient:coefficient.length>exponent+1?coefficient.slice(0,exponent+1)+"."+coefficient.slice(exponent+1):coefficient+new Array(exponent-coefficient.length+2).join("0")}formatSpecifier.prototype=FormatSpecifier.prototype,FormatSpecifier.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var formatTypes={"%":(x,p)=>(100*x).toFixed(p),b:x=>Math.round(x).toString(2),c:x=>x+"",d:function(x){return Math.abs(x=Math.round(x))>=1e21?x.toLocaleString("en").replace(/,/g,""):x.toString(10)},e:(x,p)=>x.toExponential(p),f:(x,p)=>x.toFixed(p),g:(x,p)=>x.toPrecision(p),o:x=>Math.round(x).toString(8),p:(x,p)=>formatRounded(100*x,p),r:formatRounded,s:function(x,p){var d=formatDecimalParts(x,p);if(!d)return x+"";var coefficient=d[0],exponent=d[1],i=exponent-(prefixExponent=3*Math.max(-8,Math.min(8,Math.floor(exponent/3))))+1,n=coefficient.length;return i===n?coefficient:i>n?coefficient+new Array(i-n+1).join("0"):i>0?coefficient.slice(0,i)+"."+coefficient.slice(i):"0."+new Array(1-i).join("0")+formatDecimalParts(x,Math.max(0,p+i-1))[0]},X:x=>Math.round(x).toString(16).toUpperCase(),x:x=>Math.round(x).toString(16)};function identity$1(x){return x}var locale,format,formatPrefix,map$2=Array.prototype.map,prefixes=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function formatLocale(locale){var grouping,thousands,group=void 0===locale.grouping||void 0===locale.thousands?identity$1:(grouping=map$2.call(locale.grouping,Number),thousands=locale.thousands+"",function(value,width){for(var i=value.length,t=[],j=0,g=grouping[0],length=0;i>0&&g>0&&(length+g+1>width&&(g=Math.max(1,width-length)),t.push(value.substring(i-=g,i+g)),!((length+=g+1)>width));)g=grouping[j=(j+1)%grouping.length];return t.reverse().join(thousands)}),currencyPrefix=void 0===locale.currency?"":locale.currency[0]+"",currencySuffix=void 0===locale.currency?"":locale.currency[1]+"",decimal=void 0===locale.decimal?".":locale.decimal+"",numerals=void 0===locale.numerals?identity$1:function(numerals){return function(value){return value.replace(/[0-9]/g,(function(i){return numerals[+i]}))}}(map$2.call(locale.numerals,String)),percent=void 0===locale.percent?"%":locale.percent+"",minus=void 0===locale.minus?"−":locale.minus+"",nan=void 0===locale.nan?"NaN":locale.nan+"";function newFormat(specifier){var fill=(specifier=formatSpecifier(specifier)).fill,align=specifier.align,sign=specifier.sign,symbol=specifier.symbol,zero=specifier.zero,width=specifier.width,comma=specifier.comma,precision=specifier.precision,trim=specifier.trim,type=specifier.type;"n"===type?(comma=!0,type="g"):formatTypes[type]||(void 0===precision&&(precision=12),trim=!0,type="g"),(zero||"0"===fill&&"="===align)&&(zero=!0,fill="0",align="=");var prefix="$"===symbol?currencyPrefix:"#"===symbol&&/[boxX]/.test(type)?"0"+type.toLowerCase():"",suffix="$"===symbol?currencySuffix:/[%p]/.test(type)?percent:"",formatType=formatTypes[type],maybeSuffix=/[defgprs%]/.test(type);function format(value){var i,n,c,valuePrefix=prefix,valueSuffix=suffix;if("c"===type)valueSuffix=formatType(value)+valueSuffix,value="";else{var valueNegative=(value=+value)<0||1/value<0;if(value=isNaN(value)?nan:formatType(Math.abs(value),precision),trim&&(value=function(s){out:for(var i1,n=s.length,i=1,i0=-1;i<n;++i)switch(s[i]){case".":i0=i1=i;break;case"0":0===i0&&(i0=i),i1=i;break;default:if(!+s[i])break out;i0>0&&(i0=0)}return i0>0?s.slice(0,i0)+s.slice(i1+1):s}(value)),valueNegative&&0==+value&&"+"!==sign&&(valueNegative=!1),valuePrefix=(valueNegative?"("===sign?sign:minus:"-"===sign||"("===sign?"":sign)+valuePrefix,valueSuffix=("s"===type?prefixes[8+prefixExponent/3]:"")+valueSuffix+(valueNegative&&"("===sign?")":""),maybeSuffix)for(i=-1,n=value.length;++i<n;)if(48>(c=value.charCodeAt(i))||c>57){valueSuffix=(46===c?decimal+value.slice(i+1):value.slice(i))+valueSuffix,value=value.slice(0,i);break}}comma&&!zero&&(value=group(value,1/0));var length=valuePrefix.length+value.length+valueSuffix.length,padding=length<width?new Array(width-length+1).join(fill):"";switch(comma&&zero&&(value=group(padding+value,padding.length?width-valueSuffix.length:1/0),padding=""),align){case"<":value=valuePrefix+value+valueSuffix+padding;break;case"=":value=valuePrefix+padding+value+valueSuffix;break;case"^":value=padding.slice(0,length=padding.length>>1)+valuePrefix+value+valueSuffix+padding.slice(length);break;default:value=padding+valuePrefix+value+valueSuffix}return numerals(value)}return precision=void 0===precision?6:/[gprs]/.test(type)?Math.max(1,Math.min(21,precision)):Math.max(0,Math.min(20,precision)),format.toString=function(){return specifier+""},format}return{format:newFormat,formatPrefix:function(specifier,value){var f=newFormat(((specifier=formatSpecifier(specifier)).type="f",specifier)),e=3*Math.max(-8,Math.min(8,Math.floor(exponent(value)/3))),k=Math.pow(10,-e),prefix=prefixes[8+e/3];return function(value){return f(k*value)+prefix}}}}function tickFormat(start,stop,count,specifier){var precision,step=function(start,stop,count){var step0=Math.abs(stop-start)/Math.max(0,count),step1=Math.pow(10,Math.floor(Math.log(step0)/Math.LN10)),error=step0/step1;return error>=e10?step1*=10:error>=e5?step1*=5:error>=e2&&(step1*=2),stop<start?-step1:step1}(start,stop,count);switch((specifier=formatSpecifier(null==specifier?",f":specifier)).type){case"s":var value=Math.max(Math.abs(start),Math.abs(stop));return null!=specifier.precision||isNaN(precision=function(step,value){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(exponent(value)/3)))-exponent(Math.abs(step)))}(step,value))||(specifier.precision=precision),formatPrefix(specifier,value);case"":case"e":case"g":case"p":case"r":null!=specifier.precision||isNaN(precision=function(step,max){return step=Math.abs(step),max=Math.abs(max)-step,Math.max(0,exponent(max)-exponent(step))+1}(step,Math.max(Math.abs(start),Math.abs(stop))))||(specifier.precision=precision-("e"===specifier.type));break;case"f":case"%":null!=specifier.precision||isNaN(precision=function(step){return Math.max(0,-exponent(Math.abs(step)))}(step))||(specifier.precision=precision-2*("%"===specifier.type))}return format(specifier)}function linearish(scale){var domain=scale.domain;return scale.ticks=function(count){var d=domain();return function(start,stop,count){var reverse,n,ticks,step,i=-1;if(count=+count,(start=+start)==(stop=+stop)&&count>0)return[start];if((reverse=stop<start)&&(n=start,start=stop,stop=n),0===(step=tickIncrement(start,stop,count))||!isFinite(step))return[];if(step>0)for(start=Math.ceil(start/step),stop=Math.floor(stop/step),ticks=new Array(n=Math.ceil(stop-start+1));++i<n;)ticks[i]=(start+i)*step;else for(step=-step,start=Math.ceil(start*step),stop=Math.floor(stop*step),ticks=new Array(n=Math.ceil(stop-start+1));++i<n;)ticks[i]=(start+i)/step;return reverse&&ticks.reverse(),ticks}(d[0],d[d.length-1],null==count?10:count)},scale.tickFormat=function(count,specifier){var d=domain();return tickFormat(d[0],d[d.length-1],null==count?10:count,specifier)},scale.nice=function(count){null==count&&(count=10);var prestep,step,d=domain(),i0=0,i1=d.length-1,start=d[i0],stop=d[i1],maxIter=10;for(stop<start&&(step=start,start=stop,stop=step,step=i0,i0=i1,i1=step);maxIter-- >0;){if((step=tickIncrement(start,stop,count))===prestep)return d[i0]=start,d[i1]=stop,domain(d);if(step>0)start=Math.floor(start/step)*step,stop=Math.ceil(stop/step)*step;else{if(!(step<0))break;start=Math.ceil(start*step)/step,stop=Math.floor(stop*step)/step}prestep=step}return scale},scale}function linear$1(){var scale=continuous();return scale.copy=function(){return copy(scale,linear$1())},initRange.apply(scale,arguments),linearish(scale)}function findStratcolumnUnit(units,unitname,path){void 0===path&&(path=[]);var unit=units.find((function(u){return u.identifier.toLowerCase()===unitname.toLowerCase()}));if(unit){var temp_1=unit;do{path.unshift(temp_1),temp_1=units.find((function(u){return u.identifier===temp_1.stratUnitParent}))}while(temp_1);return unit}return null}function getColorFromUnit(unit){return null===unit.colorR||null===unit.colorG||null===unit.colorB?2147483648:unit.colorR<<16|unit.colorG<<8|unit.colorB}locale=formatLocale({thousands:",",grouping:[3],currency:["$",""]}),format=locale.format,formatPrefix=locale.formatPrefix;var unassignedColorScale=function ordinal(){var index=new Map,domain=[],range=[],unknown=implicit;function scale(d){var key=d+"",i=index.get(key);if(!i){if(unknown!==implicit)return unknown;index.set(key,i=domain.push(d))}return range[(i-1)%range.length]}return scale.domain=function(_){if(!arguments.length)return domain.slice();domain=[],index=new Map;for(const value of _){const key=value+"";index.has(key)||index.set(key,domain.push(value))}return scale},scale.range=function(_){return arguments.length?(range=Array.from(_),scale):range.slice()},scale.unknown=function(_){return arguments.length?(unknown=_,scale):unknown},scale.copy=function(){return ordinal(domain,range).unknown(unknown)},initRange.apply(scale,arguments),scale}().domain([0,100]).range(function(interpolator,n){for(var samples=new Array(n),i=0;i<n;++i)samples[i]=interpolator(i/(n-1));return samples}(interpolateRgb("#e6f1cf","#85906d"),10));function isAnchestor(descendant,candidate,stratColumn){var path=[];return findStratcolumnUnit(stratColumn,descendant.name,path),path.some((function(p){return candidate.name===p.identifier}))}
|
|
399
|
+
Renderer.registerPlugin("accessibility",AccessibilityManager),Renderer.registerPlugin("extract",Extract),Renderer.registerPlugin("interaction",InteractionManager),Renderer.registerPlugin("particle",ParticleRenderer),Renderer.registerPlugin("prepare",Prepare),Renderer.registerPlugin("batch",BatchRenderer),Renderer.registerPlugin("tilingSprite",TilingSpriteRenderer),Loader$1.registerPlugin(BitmapFontLoader),Loader$1.registerPlugin(SpritesheetLoader),Application.registerPlugin(TickerPlugin),Application.registerPlugin(AppLoaderPlugin);var PixiLayer=function(_super){function PixiLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(PixiLayer,_super),PixiLayer.prototype.onMount=function(event){if(_super.prototype.onMount.call(this,event),!this.elm){var container=document.createElement("div");container.setAttribute("id",""+this.id),container.setAttribute("class","webgl-layer"),this.elm=container,this.updateStyle();var elm=event.elm,height=event.height,pixiOptions={width:event.width||parseInt(this.elm.getAttribute("width"),10)||200,height:height||parseInt(this.elm.getAttribute("height"),10)||300,antialias:!0,transparent:!0,clearBeforeRender:!0,autoResize:!0,preserveDrawingBuffer:!0};this.ctx=new Application(pixiOptions),container.appendChild(this.ctx.view),elm.appendChild(container)}},PixiLayer.prototype.onUnmount=function(event){var _a,_b;_super.prototype.onUnmount.call(this,event);var renderType=this.renderType(),glContext=null===(_a=this.ctx.renderer)||void 0===_a?void 0:_a.gl;this.ctx.stop(),this.ctx.destroy(!0,{children:!0,texture:!0,baseTexture:!0}),renderType===RENDERER_TYPE.WEBGL&&(null===(_b=null==glContext?void 0:glContext.getExtension("WEBGL_lose_context"))||void 0===_b||_b.loseContext()),this.elm.remove(),this.elm=null,this.ctx=null},PixiLayer.prototype.onResize=function(event){_super.prototype.onResize.call(this,event),this.ctx.renderer.resize(event.width,event.height)},PixiLayer.prototype.onRescale=function(event){if(_super.prototype.onRescale.call(this,event),this.ctx){var flippedX=event.xBounds[0]>event.xBounds[1],flippedY=event.yBounds[0]>event.yBounds[1];this.ctx.stage.position.set(event.xScale(0),event.yScale(0)),this.ctx.stage.scale.set(event.xRatio*(flippedX?-1:1),event.yRatio*(flippedY?-1:1))}},PixiLayer.prototype.updateStyle=function(visible){var visibility=visible||this.isVisible?"visible":"hidden",interactive=this.interactive?"auto":"none";this.elm.setAttribute("style","position:absolute;pointer-events:"+interactive+";z-index:"+this.order+";opacity:"+this.opacity+";visibility:"+visibility)},PixiLayer.prototype.setVisibility=function(visible){_super.prototype.setVisibility.call(this,visible),this.elm&&this.updateStyle(visible)},PixiLayer.prototype.onOpacityChanged=function(opacity){this.elm&&this.updateStyle()},PixiLayer.prototype.onOrderChanged=function(order){this.elm&&this.updateStyle()},PixiLayer.prototype.onInteractivityChanged=function(interactive){this.elm&&this.updateStyle()},PixiLayer.prototype.renderType=function(){return this.ctx.renderer.type},PixiLayer}(Layer),GeomodelLayerV2=function(_super){function GeomodelLayerV2(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.isRendered=!1,_this.createPolygons=function(data){for(var polygons=[],polygon=null,i=0;i<data.length;i++){var topIsValid=!!data[i][1];topIsValid&&(null===polygon&&(polygon=[]),polygon.push(data[i][0],data[i][1]));var endIsReached=i===data.length-1;if((!topIsValid||endIsReached)&&polygon){for(var j=topIsValid?i:i-1;j>=0&&data[j][1];j--)polygon.push(data[j][0],data[j][2]||1e4);polygons.push(polygon),polygon=null}}return polygons},_this.generateAreaPolygon=function(s){var g=new Graphics;g.lineStyle(1,s.color,1),g.beginFill(s.color),_this.createPolygons(s.data).forEach((function(polygon){return g.drawPolygon(polygon)})),g.endFill(),_this.ctx.stage.addChild(g)},_this.generateSurfaceLine=function(s){var g=new Graphics,d=s.data;g.lineStyle(1,s.color,1,.5,!0);for(var penDown=!1,i=0;i<d.length;i++)d[i][1]?penDown?g.lineTo(d[i][0],d[i][1]):(g.moveTo(d[i][0],d[i][1]),penDown=!0):penDown=!1;_this.ctx.stage.addChild(g)},_this}return __extends(GeomodelLayerV2,_super),GeomodelLayerV2.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.isRendered||this.render()},GeomodelLayerV2.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.isRendered=!1,this.cleanUpStage(),this.render()},GeomodelLayerV2.prototype.cleanUpStage=function(){this.ctx.stage.children.forEach((function(g){return g.destroy()})),this.ctx.stage.removeChildren()},GeomodelLayerV2.prototype.render=function(){var _this=this,data=this.data;data&&(data.areas.forEach((function(a){return _this.generateAreaPolygon(a)})),data.lines.forEach((function(l){return _this.generateSurfaceLine(l)})),this.isRendered=!0)},GeomodelLayerV2}(PixiLayer),GeomodelLayer=function(_super){function GeomodelLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(GeomodelLayer,_super),GeomodelLayer}(GeomodelLayerV2);function define(constructor,factory,prototype){constructor.prototype=factory.prototype=prototype,prototype.constructor=constructor}function extend(parent,definition){var prototype=Object.create(parent.prototype);for(var key in definition)prototype[key]=definition[key];return prototype}function Color(){}var brighter=1/.7,reI="\\s*([+-]?\\d+)\\s*",reN="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",reP="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",reHex=/^#([0-9a-f]{3,8})$/,reRgbInteger=new RegExp("^rgb\\("+[reI,reI,reI]+"\\)$"),reRgbPercent=new RegExp("^rgb\\("+[reP,reP,reP]+"\\)$"),reRgbaInteger=new RegExp("^rgba\\("+[reI,reI,reI,reN]+"\\)$"),reRgbaPercent=new RegExp("^rgba\\("+[reP,reP,reP,reN]+"\\)$"),reHslPercent=new RegExp("^hsl\\("+[reN,reP,reP]+"\\)$"),reHslaPercent=new RegExp("^hsla\\("+[reN,reP,reP,reN]+"\\)$"),named={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function color_formatHex(){return this.rgb().formatHex()}function color_formatRgb(){return this.rgb().formatRgb()}function color(format){var m,l;return format=(format+"").trim().toLowerCase(),(m=reHex.exec(format))?(l=m[1].length,m=parseInt(m[1],16),6===l?rgbn(m):3===l?new Rgb(m>>8&15|m>>4&240,m>>4&15|240&m,(15&m)<<4|15&m,1):8===l?rgba(m>>24&255,m>>16&255,m>>8&255,(255&m)/255):4===l?rgba(m>>12&15|m>>8&240,m>>8&15|m>>4&240,m>>4&15|240&m,((15&m)<<4|15&m)/255):null):(m=reRgbInteger.exec(format))?new Rgb(m[1],m[2],m[3],1):(m=reRgbPercent.exec(format))?new Rgb(255*m[1]/100,255*m[2]/100,255*m[3]/100,1):(m=reRgbaInteger.exec(format))?rgba(m[1],m[2],m[3],m[4]):(m=reRgbaPercent.exec(format))?rgba(255*m[1]/100,255*m[2]/100,255*m[3]/100,m[4]):(m=reHslPercent.exec(format))?hsla(m[1],m[2]/100,m[3]/100,1):(m=reHslaPercent.exec(format))?hsla(m[1],m[2]/100,m[3]/100,m[4]):named.hasOwnProperty(format)?rgbn(named[format]):"transparent"===format?new Rgb(NaN,NaN,NaN,0):null}function rgbn(n){return new Rgb(n>>16&255,n>>8&255,255&n,1)}function rgba(r,g,b,a){return a<=0&&(r=g=b=NaN),new Rgb(r,g,b,a)}function rgbConvert(o){return o instanceof Color||(o=color(o)),o?new Rgb((o=o.rgb()).r,o.g,o.b,o.opacity):new Rgb}function rgb(r,g,b,opacity){return 1===arguments.length?rgbConvert(r):new Rgb(r,g,b,null==opacity?1:opacity)}function Rgb(r,g,b,opacity){this.r=+r,this.g=+g,this.b=+b,this.opacity=+opacity}function rgb_formatHex(){return"#"+hex(this.r)+hex(this.g)+hex(this.b)}function rgb_formatRgb(){var a=this.opacity;return(1===(a=isNaN(a)?1:Math.max(0,Math.min(1,a)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===a?")":", "+a+")")}function hex(value){return((value=Math.max(0,Math.min(255,Math.round(value)||0)))<16?"0":"")+value.toString(16)}function hsla(h,s,l,a){return a<=0?h=s=l=NaN:l<=0||l>=1?h=s=NaN:s<=0&&(h=NaN),new Hsl(h,s,l,a)}function hslConvert(o){if(o instanceof Hsl)return new Hsl(o.h,o.s,o.l,o.opacity);if(o instanceof Color||(o=color(o)),!o)return new Hsl;if(o instanceof Hsl)return o;var r=(o=o.rgb()).r/255,g=o.g/255,b=o.b/255,min=Math.min(r,g,b),max=Math.max(r,g,b),h=NaN,s=max-min,l=(max+min)/2;return s?(h=r===max?(g-b)/s+6*(g<b):g===max?(b-r)/s+2:(r-g)/s+4,s/=l<.5?max+min:2-max-min,h*=60):s=l>0&&l<1?0:h,new Hsl(h,s,l,o.opacity)}function Hsl(h,s,l,opacity){this.h=+h,this.s=+s,this.l=+l,this.opacity=+opacity}function hsl2rgb(h,m1,m2){return 255*(h<60?m1+(m2-m1)*h/60:h<180?m2:h<240?m1+(m2-m1)*(240-h)/60:m1)}function convertColor(colorStr){var d=color(colorStr).hex();return parseInt(d.replace("#","0x"))}define(Color,color,{copy:function(channels){return Object.assign(new this.constructor,this,channels)},displayable:function(){return this.rgb().displayable()},hex:color_formatHex,formatHex:color_formatHex,formatHsl:function(){return hslConvert(this).formatHsl()},formatRgb:color_formatRgb,toString:color_formatRgb}),define(Rgb,rgb,extend(Color,{brighter:function(k){return k=null==k?brighter:Math.pow(brighter,k),new Rgb(this.r*k,this.g*k,this.b*k,this.opacity)},darker:function(k){return k=null==k?.7:Math.pow(.7,k),new Rgb(this.r*k,this.g*k,this.b*k,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rgb_formatHex,formatHex:rgb_formatHex,formatRgb:rgb_formatRgb,toString:rgb_formatRgb})),define(Hsl,(function(h,s,l,opacity){return 1===arguments.length?hslConvert(h):new Hsl(h,s,l,null==opacity?1:opacity)}),extend(Color,{brighter:function(k){return k=null==k?brighter:Math.pow(brighter,k),new Hsl(this.h,this.s,this.l*k,this.opacity)},darker:function(k){return k=null==k?.7:Math.pow(.7,k),new Hsl(this.h,this.s,this.l*k,this.opacity)},rgb:function(){var h=this.h%360+360*(this.h<0),s=isNaN(h)||isNaN(this.s)?0:this.s,l=this.l,m2=l+(l<.5?l:1-l)*s,m1=2*l-m2;return new Rgb(hsl2rgb(h>=240?h-240:h+120,m1,m2),hsl2rgb(h,m1,m2),hsl2rgb(h<120?h+240:h-120,m1,m2),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var a=this.opacity;return(1===(a=isNaN(a)?1:Math.max(0,Math.min(1,a)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===a?")":", "+a+")")}}));var GeomodelCanvasLayer=function(_super){function GeomodelCanvasLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.surfaceAreasPaths=[],_this.surfaceLinesPaths=[],_this.maxDepth=1e4,_this.drawPolygonPath=function(color,path){var ctx=_this.ctx;ctx.fillStyle=color,ctx.fill(path)},_this.drawLinePath=function(color,path){var ctx=_this.ctx;ctx.strokeStyle=color,ctx.stroke(path)},_this.createPolygons=function(data){for(var polygons=[],polygon=null,i=0;i<data.length;i++){var topIsValid=!!data[i][1];topIsValid&&(null===polygon&&(polygon=[]),polygon.push(data[i][0],data[i][1]));var endIsReached=i===data.length-1;if((!topIsValid||endIsReached)&&polygon){for(var j=topIsValid?i:i-1;j>=0&&data[j][1];j--)polygon.push(data[j][0],data[j][2]||_this.maxDepth);polygons.push(polygon),polygon=null}}return polygons},_this.generatePolygonPath=function(polygon){var path=new Path2D;path.moveTo(polygon[0],polygon[1]);for(var i=2;i<polygon.length;i+=2)path.lineTo(polygon[i],polygon[i+1]);return path.closePath(),path},_this.generateLinePaths=function(s){for(var paths=[],d=s.data,penDown=!1,path=null,i=0;i<d.length;i++)d[i][1]?penDown?path.lineTo(d[i][0],d[i][1]):((path=new Path2D).moveTo(d[i][0],d[i][1]),penDown=!0):penDown&&(paths.push(path),penDown=!1);return penDown&&paths.push(path),paths},_this.render=_this.render.bind(_this),_this.generateSurfaceAreasPaths=_this.generateSurfaceAreasPaths.bind(_this),_this.generateSurfaceLinesPaths=_this.generateSurfaceLinesPaths.bind(_this),_this.drawPolygonPath=_this.drawPolygonPath.bind(_this),_this.drawLinePath=_this.drawLinePath.bind(_this),_this.updatePaths=_this.updatePaths.bind(_this),_this}return __extends(GeomodelCanvasLayer,_super),Object.defineProperty(GeomodelCanvasLayer.prototype,"data",{get:function(){return _super.prototype.getData.call(this)},set:function(data){this.setData(data)},enumerable:!1,configurable:!0}),GeomodelCanvasLayer.prototype.getData=function(){return _super.prototype.getData.call(this)},GeomodelCanvasLayer.prototype.setData=function(data){_super.prototype.setData.call(this,data),this.updatePaths()},GeomodelCanvasLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event)},GeomodelCanvasLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.updatePaths(),this.render()},GeomodelCanvasLayer.prototype.onRescale=function(event){this.rescaleEvent=event,this.setTransform(this.rescaleEvent),this.render()},GeomodelCanvasLayer.prototype.updatePaths=function(){this.data?(this.generateSurfaceAreasPaths(),this.generateSurfaceLinesPaths()):(this.surfaceAreasPaths=[],this.surfaceLinesPaths=[])},GeomodelCanvasLayer.prototype.render=function(){var _this=this;this.ctx&&this.rescaleEvent&&requestAnimationFrame((function(){_this.clearCanvas(),_this.surfaceAreasPaths.forEach((function(p){return _this.drawPolygonPath(p.color,p.path)})),_this.surfaceLinesPaths.forEach((function(l){return _this.drawLinePath(l.color,l.path)}))}))},GeomodelCanvasLayer.prototype.colorToCSSColor=function(color){return function(color){if("string"==typeof color)return color;var hexString=color.toString(16);return"#"+("000000".substr(0,6-hexString.length)+hexString)}(color)},GeomodelCanvasLayer.prototype.generateSurfaceAreasPaths=function(){var _this=this;this.surfaceAreasPaths=this.data.areas.reduce((function(acc,s){var mapped=_this.createPolygons(s.data).map((function(polygon){return{color:_this.colorToCSSColor(s.color),path:_this.generatePolygonPath(polygon)}}));return __spreadArray(__spreadArray([],acc),mapped)}),[])},GeomodelCanvasLayer.prototype.generateSurfaceLinesPaths=function(){var _this=this;this.surfaceLinesPaths=this.data.lines.reduce((function(acc,l){var mapped=_this.generateLinePaths(l).map((function(path){return{color:_this.colorToCSSColor(l.color),path:path}}));return __spreadArray(__spreadArray([],acc),mapped)}),[])},GeomodelCanvasLayer}(CanvasLayer),DEG2RAD=Math.PI/180;function clamp(value,min,max){return void 0===min&&(min=0),void 0===max&&(max=1),value<min?min:value>max?max:value}function seqI(steps){var target=new Array(steps),incr=1/(steps-1);target[0]=0;for(var i=1;i<steps-1;i++)target[i]=i*incr;return target[steps-1]=1,target}function add(a,b,target){void 0===target&&(target=a);for(var i=0;i<a.length;i++)target[i]=a[i]+b[i];return target}function sub(a,b,target){void 0===target&&(target=a);for(var i=0;i<a.length;i++)target[i]=a[i]-b[i];return target}function scale(a,factor,target){void 0===target&&(target=a);for(var i=0;i<a.length;i++)target[i]=a[i]*factor;return target}function magnitude(a){var sq=function(a){for(var sum=0,i=0;i<a.length;i++)sum+=Math.pow(a[i],2);return sum}(a);return 0===sq?sq:Math.sqrt(sq)}function normalize(a,target){void 0===target&&(target=a);var len=magnitude(a);return 0===len?function(value,target){for(var i=0;i<target.length;i++)target[i]=value;return target}(0,target):scale(a,1/len,target)}function isZeroVector(a,epsilon){void 0===epsilon&&(epsilon=0),void 0===epsilon&&(epsilon=0);for(var i=0;i<a.length;i++)if(Math.abs(a[i])>epsilon)return!1;return!0}var RAD2DEG=180/Math.PI,DEG2RAD$1=Math.PI/180;function rotate(v,rad,target){var cr=Math.cos(rad),sr=Math.sin(rad),x=v[0];return target[0]=cr*x-sr*v[1],target[1]=sr*x+cr*v[1],target}function angleRight(v){return Math.atan2(v[1],v[0])}function signedAngle(a,b){var phi=Math.atan2(b[1],b[0])-Math.atan2(a[1],a[0]);return phi>Math.PI?phi-=2*Math.PI:phi<=-Math.PI&&(phi+=2*Math.PI),phi}var Vector2=function(){function Vector2(a){for(var b=[],_i=1;_i<arguments.length;_i++)b[_i-1]=arguments[_i];this.isMutating=!1,this.length=2,"number"==typeof a?"number"==typeof b[0]?(this[0]=a,this[1]=b[0]):(this[0]=a,this[1]=a):"x"in a&&"y"in a?(this[0]=a.x,this[1]=a.y):(this[0]=a[0],this[1]=a[1])}return Object.defineProperty(Vector2.prototype,"x",{get:function(){return this[0]},set:function(value){this[0]=value},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2.prototype,"y",{get:function(){return this[1]},set:function(value){this[1]=value},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2.prototype,"magnitude",{get:function(){return magnitude(this)},set:function(val){scale(this,val/magnitude(this),this)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2.prototype,"mutable",{get:function(){return this.isMutating=!0,this},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2.prototype,"immutable",{get:function(){return this.isMutating=!1,this},enumerable:!0,configurable:!0}),Vector2.prototype.set=function(a,b){return"number"==typeof a?"number"==typeof b?(this[0]=a,this[1]=b):(this[0]=a,this[1]=a):(this[0]=a[0],this[1]=a[1]),this},Vector2.prototype.add=function(a,b){return void 0===b&&(b=0),"number"==typeof a?this.isMutating?add(this,[a,b]):add(this.clone(),[a,b]):this.isMutating?add(this,a):add(this.clone(),a)},Vector2.add=function(a,b){return add(new Vector2(a),b)},Vector2.prototype.sub=function(a,b){return void 0===b&&(b=0),"number"==typeof a?this.isMutating?sub(this,[a,b]):sub(this.clone(),[a,b]):this.isMutating?sub(this,a):sub(this.clone(),a)},Vector2.sub=function(a,b){return sub(new Vector2(a),b)},Vector2.prototype.subFrom=function(a,b){return void 0===b&&(b=0),"number"==typeof a?this.isMutating?(this[0]=a-this[0],this[1]=b-this[1],this):new Vector2(a-this[0],b-this[1]):this.isMutating?(this[0]=a[0]-this[0],this[1]=a[1]-this[1],this):new Vector2(a[0]-this[0],a[1]-this[1])},Vector2.divide=function(v,n){return scale(new Vector2(v),1/n)},Vector2.multiply=function(v,n){return scale(new Vector2(v),n)},Vector2.prototype.scale=function(n){return scale(this,n,this.isMutating?this:Vector2.zero)},Vector2.prototype.rescale=function(n){var len=magnitude(this);return len<=0?this.isMutating?this:Vector2.zero:scale(this,n/len,this.isMutating?this:Vector2.zero)},Vector2.prototype.clampMagnitude=function(n){var len=magnitude(this);return len>n?scale(this,n/len,this.isMutating?this:Vector2.zero):this.isMutating?this:this.clone()},Vector2.prototype.rotate=function(rad){return rotate(this,rad,this.isMutating?this:Vector2.zero)},Vector2.prototype.rotateDeg=function(deg){return rotate(this,deg*DEG2RAD$1,this.isMutating?this:Vector2.zero)},Vector2.prototype.rotate90=function(){return this,target=this.isMutating?this:Vector2.zero,x=this[0],target[0]=-this[1],target[1]=x,target;var target,x},Vector2.prototype.rotate180=function(){return this,(target=this.isMutating?this:Vector2.zero)[0]=-this[0],target[1]=-this[1],target;var target},Vector2.prototype.rotate270=function(){return this,target=this.isMutating?this:Vector2.zero,x=this[0],target[0]=this[1],target[1]=-x,target;var target,x},Vector2.prototype.normalize=function(){return normalize(this)},Vector2.prototype.normalized=function(){return normalize(this,Vector2.zero)},Vector2.distance=function(a,b){return function(a,b){for(var sq=0,i=0;i<a.length;i++)sq+=Math.pow(b[i]-a[i],2);return 0===sq?sq:Math.sqrt(sq)}(a,b)},Vector2.dot=function(a,b){return function(a,b){for(var sum=0,i=0;i<a.length;i++)sum+=a[i]*b[i];return sum}(a,b)},Vector2.cross=function(a,b){return function(a,b){return a[0]*b[1]-a[1]*b[0]}(a,b)},Vector2.angleRight=function(v){return angleRight(v)},Vector2.angleRightDeg=function(v){return angleRight(v)*RAD2DEG},Vector2.angle=function(a,b){return Math.abs(signedAngle(a,b))},Vector2.angleDeg=function(a,b){return Math.abs(signedAngle(a,b))*RAD2DEG},Vector2.signedAngle=function(a,b){return signedAngle(a,b)},Vector2.signedAngleDeg=function(a,b){return signedAngle(a,b)*RAD2DEG},Vector2.lerp=function(a,b,t){return function(a,b,t,target){void 0===target&&(target=a);for(var n=clamp(t,0,1),m=1-n,i=0;i<a.length;i++)target[i]=a[i]*m+b[i]*n;return target}(new Vector2(a),b,t)},Vector2.lerpRot=function(a,b,t){return function(a,b,n,target){return void 0===target&&(target=a),rotate(a,n*signedAngle(a,b),target)}(a,b,t,Vector2.zero)},Vector2.prototype.clone=function(){return new Vector2(this[0],this[1])},Vector2.equals=function(a,b,epsilon){return void 0===epsilon&&(epsilon=0),!(Math.abs(a[0]-b[0])>epsilon||Math.abs(a[1]-b[1])>epsilon)},Vector2.prototype.equals=function(vector,epsilon){return void 0===epsilon&&(epsilon=0),Vector2.equals(this,vector,epsilon)},Vector2.isZeroVector=function(vector,epsilon){return void 0===epsilon&&(epsilon=0),isZeroVector(vector,epsilon)},Vector2.prototype.isZeroVector=function(epsilon){return void 0===epsilon&&(epsilon=0),isZeroVector(this,epsilon)},Vector2.prototype.toArray=function(){return[this[0],this[1]]},Vector2.prototype.modify=function(modifier){return function(a,modifier,target){void 0===target&&(target=a);for(var i=0;i<a.length;i++)target[i]=modifier(a[i],i);return target}(this,modifier)},Vector2.prototype[Symbol.iterator]=function(){var _this=this,i=0;return{next:function(){switch(i++){case 0:return{value:_this[0],done:!1};case 1:return{value:_this[1],done:!1};default:return{value:-1,done:!0}}}}},Object.defineProperty(Vector2,"zero",{get:function(){return new Vector2(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"one",{get:function(){return new Vector2(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"positiveInfinity",{get:function(){return new Vector2(1/0,1/0)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"negativeInfinity",{get:function(){return new Vector2(-1/0,-1/0)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"up",{get:function(){return new Vector2(0,1)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"right",{get:function(){return new Vector2(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"down",{get:function(){return new Vector2(0,-1)},enumerable:!0,configurable:!0}),Object.defineProperty(Vector2,"left",{get:function(){return new Vector2(-1,0)},enumerable:!0,configurable:!0}),Vector2}(),constant$2=x=>()=>x;function gamma(y){return 1==(y=+y)?nogamma:function(a,b){return b-a?function(a,b,y){return a=Math.pow(a,y),b=Math.pow(b,y)-a,y=1/y,function(t){return Math.pow(a+t*b,y)}}(a,b,y):constant$2(isNaN(a)?b:a)}}function nogamma(a,b){var d=b-a;return d?function(a,d){return function(t){return a+t*d}}(a,d):constant$2(isNaN(a)?b:a)}var interpolateRgb=function rgbGamma(y){var color=gamma(y);function rgb$1(start,end){var r=color((start=rgb(start)).r,(end=rgb(end)).r),g=color(start.g,end.g),b=color(start.b,end.b),opacity=nogamma(start.opacity,end.opacity);return function(t){return start.r=r(t),start.g=g(t),start.b=b(t),start.opacity=opacity(t),start+""}}return rgb$1.gamma=rgbGamma,rgb$1}(1);function numberArray(a,b){b||(b=[]);var i,n=a?Math.min(b.length,a.length):0,c=b.slice();return function(t){for(i=0;i<n;++i)c[i]=a[i]*(1-t)+b[i]*t;return c}}function genericArray(a,b){var i,nb=b?b.length:0,na=a?Math.min(nb,a.length):0,x=new Array(na),c=new Array(nb);for(i=0;i<na;++i)x[i]=interpolate(a[i],b[i]);for(;i<nb;++i)c[i]=b[i];return function(t){for(i=0;i<na;++i)c[i]=x[i](t);return c}}function date(a,b){var d=new Date;return a=+a,b=+b,function(t){return d.setTime(a*(1-t)+b*t),d}}function interpolateNumber(a,b){return a=+a,b=+b,function(t){return a*(1-t)+b*t}}function object(a,b){var k,i={},c={};for(k in null!==a&&"object"==typeof a||(a={}),null!==b&&"object"==typeof b||(b={}),b)k in a?i[k]=interpolate(a[k],b[k]):c[k]=b[k];return function(t){for(k in i)c[k]=i[k](t);return c}}var reA=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,reB=new RegExp(reA.source,"g");function string(a,b){var am,bm,bs,bi=reA.lastIndex=reB.lastIndex=0,i=-1,s=[],q=[];for(a+="",b+="";(am=reA.exec(a))&&(bm=reB.exec(b));)(bs=bm.index)>bi&&(bs=b.slice(bi,bs),s[i]?s[i]+=bs:s[++i]=bs),(am=am[0])===(bm=bm[0])?s[i]?s[i]+=bm:s[++i]=bm:(s[++i]=null,q.push({i:i,x:interpolateNumber(am,bm)})),bi=reB.lastIndex;return bi<b.length&&(bs=b.slice(bi),s[i]?s[i]+=bs:s[++i]=bs),s.length<2?q[0]?function(b){return function(t){return b(t)+""}}(q[0].x):function(b){return function(){return b}}(b):(b=q.length,function(t){for(var o,i=0;i<b;++i)s[(o=q[i]).i]=o.x(t);return s.join("")})}function interpolate(a,b){var c,t=typeof b;return null==b||"boolean"===t?constant$2(b):("number"===t?interpolateNumber:"string"===t?(c=color(b))?(b=c,interpolateRgb):string:b instanceof color?interpolateRgb:b instanceof Date?date:function(x){return ArrayBuffer.isView(x)&&!(x instanceof DataView)}(b)?numberArray:Array.isArray(b)?genericArray:"function"!=typeof b.valueOf&&"function"!=typeof b.toString||isNaN(b)?object:interpolateNumber)(a,b)}function interpolateRound(a,b){return a=+a,b=+b,function(t){return Math.round(a*(1-t)+b*t)}}function ascending$1(a,b){return a<b?-1:a>b?1:a>=b?0:NaN}function bisector(f){let delta=f,compare=f;function left(a,x,lo,hi){for(null==lo&&(lo=0),null==hi&&(hi=a.length);lo<hi;){const mid=lo+hi>>>1;compare(a[mid],x)<0?lo=mid+1:hi=mid}return lo}return 1===f.length&&(delta=(d,x)=>f(d)-x,compare=function(f){return(d,x)=>ascending$1(f(d),x)}(f)),{left:left,center:function(a,x,lo,hi){null==lo&&(lo=0),null==hi&&(hi=a.length);const i=left(a,x,lo,hi-1);return i>lo&&delta(a[i-1],x)>-delta(a[i],x)?i-1:i},right:function(a,x,lo,hi){for(null==lo&&(lo=0),null==hi&&(hi=a.length);lo<hi;){const mid=lo+hi>>>1;compare(a[mid],x)>0?hi=mid:lo=mid+1}return lo}}}const bisectRight=bisector(ascending$1).right;bisector((function(x){return null===x?NaN:+x})).center;var e10=Math.sqrt(50),e5=Math.sqrt(10),e2=Math.sqrt(2);function tickIncrement(start,stop,count){var step=(stop-start)/Math.max(0,count),power=Math.floor(Math.log(step)/Math.LN10),error=step/Math.pow(10,power);return power>=0?(error>=e10?10:error>=e5?5:error>=e2?2:1)*Math.pow(10,power):-Math.pow(10,-power)/(error>=e10?10:error>=e5?5:error>=e2?2:1)}function transpose(matrix){if(!(n=matrix.length))return[];for(var i=-1,m=function(values,valueof){let min;if(void 0===valueof)for(const value of values)null!=value&&(min>value||void 0===min&&value>=value)&&(min=value);else{let index=-1;for(let value of values)null!=(value=valueof(value,++index,values))&&(min>value||void 0===min&&value>=value)&&(min=value)}return min}(matrix,length),transpose=new Array(m);++i<m;)for(var n,j=-1,row=transpose[i]=new Array(n);++j<n;)row[j]=matrix[j][i];return transpose}function length(d){return d.length}function initRange(domain,range){switch(arguments.length){case 0:break;case 1:this.range(domain);break;default:this.range(range).domain(domain)}return this}const implicit=Symbol("implicit");function number$1(x){return+x}var unit=[0,1];function identity(x){return x}function normalize$1(a,b){return(b-=a=+a)?function(x){return(x-a)/b}:function(x){return function(){return x}}(isNaN(b)?NaN:.5)}function bimap(domain,range,interpolate){var d0=domain[0],d1=domain[1],r0=range[0],r1=range[1];return d1<d0?(d0=normalize$1(d1,d0),r0=interpolate(r1,r0)):(d0=normalize$1(d0,d1),r0=interpolate(r0,r1)),function(x){return r0(d0(x))}}function polymap(domain,range,interpolate){var j=Math.min(domain.length,range.length)-1,d=new Array(j),r=new Array(j),i=-1;for(domain[j]<domain[0]&&(domain=domain.slice().reverse(),range=range.slice().reverse());++i<j;)d[i]=normalize$1(domain[i],domain[i+1]),r[i]=interpolate(range[i],range[i+1]);return function(x){var i=bisectRight(domain,x,1,j)-1;return r[i](d[i](x))}}function copy(source,target){return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown())}function transformer(){var transform,untransform,unknown,piecewise,output,input,domain=unit,range=unit,interpolate$1=interpolate,clamp=identity;function rescale(){var a,b,t,n=Math.min(domain.length,range.length);return clamp!==identity&&(a=domain[0],b=domain[n-1],a>b&&(t=a,a=b,b=t),clamp=function(x){return Math.max(a,Math.min(b,x))}),piecewise=n>2?polymap:bimap,output=input=null,scale}function scale(x){return null==x||isNaN(x=+x)?unknown:(output||(output=piecewise(domain.map(transform),range,interpolate$1)))(transform(clamp(x)))}return scale.invert=function(y){return clamp(untransform((input||(input=piecewise(range,domain.map(transform),interpolateNumber)))(y)))},scale.domain=function(_){return arguments.length?(domain=Array.from(_,number$1),rescale()):domain.slice()},scale.range=function(_){return arguments.length?(range=Array.from(_),rescale()):range.slice()},scale.rangeRound=function(_){return range=Array.from(_),interpolate$1=interpolateRound,rescale()},scale.clamp=function(_){return arguments.length?(clamp=!!_||identity,rescale()):clamp!==identity},scale.interpolate=function(_){return arguments.length?(interpolate$1=_,rescale()):interpolate$1},scale.unknown=function(_){return arguments.length?(unknown=_,scale):unknown},function(t,u){return transform=t,untransform=u,rescale()}}function continuous(){return transformer()(identity,identity)}function formatDecimalParts(x,p){if((i=(x=p?x.toExponential(p-1):x.toExponential()).indexOf("e"))<0)return null;var i,coefficient=x.slice(0,i);return[coefficient.length>1?coefficient[0]+coefficient.slice(2):coefficient,+x.slice(i+1)]}function exponent(x){return(x=formatDecimalParts(Math.abs(x)))?x[1]:NaN}var prefixExponent,re=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function formatSpecifier(specifier){if(!(match=re.exec(specifier)))throw new Error("invalid format: "+specifier);var match;return new FormatSpecifier({fill:match[1],align:match[2],sign:match[3],symbol:match[4],zero:match[5],width:match[6],comma:match[7],precision:match[8]&&match[8].slice(1),trim:match[9],type:match[10]})}function FormatSpecifier(specifier){this.fill=void 0===specifier.fill?" ":specifier.fill+"",this.align=void 0===specifier.align?">":specifier.align+"",this.sign=void 0===specifier.sign?"-":specifier.sign+"",this.symbol=void 0===specifier.symbol?"":specifier.symbol+"",this.zero=!!specifier.zero,this.width=void 0===specifier.width?void 0:+specifier.width,this.comma=!!specifier.comma,this.precision=void 0===specifier.precision?void 0:+specifier.precision,this.trim=!!specifier.trim,this.type=void 0===specifier.type?"":specifier.type+""}function formatRounded(x,p){var d=formatDecimalParts(x,p);if(!d)return x+"";var coefficient=d[0],exponent=d[1];return exponent<0?"0."+new Array(-exponent).join("0")+coefficient:coefficient.length>exponent+1?coefficient.slice(0,exponent+1)+"."+coefficient.slice(exponent+1):coefficient+new Array(exponent-coefficient.length+2).join("0")}formatSpecifier.prototype=FormatSpecifier.prototype,FormatSpecifier.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var formatTypes={"%":(x,p)=>(100*x).toFixed(p),b:x=>Math.round(x).toString(2),c:x=>x+"",d:function(x){return Math.abs(x=Math.round(x))>=1e21?x.toLocaleString("en").replace(/,/g,""):x.toString(10)},e:(x,p)=>x.toExponential(p),f:(x,p)=>x.toFixed(p),g:(x,p)=>x.toPrecision(p),o:x=>Math.round(x).toString(8),p:(x,p)=>formatRounded(100*x,p),r:formatRounded,s:function(x,p){var d=formatDecimalParts(x,p);if(!d)return x+"";var coefficient=d[0],exponent=d[1],i=exponent-(prefixExponent=3*Math.max(-8,Math.min(8,Math.floor(exponent/3))))+1,n=coefficient.length;return i===n?coefficient:i>n?coefficient+new Array(i-n+1).join("0"):i>0?coefficient.slice(0,i)+"."+coefficient.slice(i):"0."+new Array(1-i).join("0")+formatDecimalParts(x,Math.max(0,p+i-1))[0]},X:x=>Math.round(x).toString(16).toUpperCase(),x:x=>Math.round(x).toString(16)};function identity$1(x){return x}var locale,format,formatPrefix,map$2=Array.prototype.map,prefixes=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function formatLocale(locale){var grouping,thousands,group=void 0===locale.grouping||void 0===locale.thousands?identity$1:(grouping=map$2.call(locale.grouping,Number),thousands=locale.thousands+"",function(value,width){for(var i=value.length,t=[],j=0,g=grouping[0],length=0;i>0&&g>0&&(length+g+1>width&&(g=Math.max(1,width-length)),t.push(value.substring(i-=g,i+g)),!((length+=g+1)>width));)g=grouping[j=(j+1)%grouping.length];return t.reverse().join(thousands)}),currencyPrefix=void 0===locale.currency?"":locale.currency[0]+"",currencySuffix=void 0===locale.currency?"":locale.currency[1]+"",decimal=void 0===locale.decimal?".":locale.decimal+"",numerals=void 0===locale.numerals?identity$1:function(numerals){return function(value){return value.replace(/[0-9]/g,(function(i){return numerals[+i]}))}}(map$2.call(locale.numerals,String)),percent=void 0===locale.percent?"%":locale.percent+"",minus=void 0===locale.minus?"−":locale.minus+"",nan=void 0===locale.nan?"NaN":locale.nan+"";function newFormat(specifier){var fill=(specifier=formatSpecifier(specifier)).fill,align=specifier.align,sign=specifier.sign,symbol=specifier.symbol,zero=specifier.zero,width=specifier.width,comma=specifier.comma,precision=specifier.precision,trim=specifier.trim,type=specifier.type;"n"===type?(comma=!0,type="g"):formatTypes[type]||(void 0===precision&&(precision=12),trim=!0,type="g"),(zero||"0"===fill&&"="===align)&&(zero=!0,fill="0",align="=");var prefix="$"===symbol?currencyPrefix:"#"===symbol&&/[boxX]/.test(type)?"0"+type.toLowerCase():"",suffix="$"===symbol?currencySuffix:/[%p]/.test(type)?percent:"",formatType=formatTypes[type],maybeSuffix=/[defgprs%]/.test(type);function format(value){var i,n,c,valuePrefix=prefix,valueSuffix=suffix;if("c"===type)valueSuffix=formatType(value)+valueSuffix,value="";else{var valueNegative=(value=+value)<0||1/value<0;if(value=isNaN(value)?nan:formatType(Math.abs(value),precision),trim&&(value=function(s){out:for(var i1,n=s.length,i=1,i0=-1;i<n;++i)switch(s[i]){case".":i0=i1=i;break;case"0":0===i0&&(i0=i),i1=i;break;default:if(!+s[i])break out;i0>0&&(i0=0)}return i0>0?s.slice(0,i0)+s.slice(i1+1):s}(value)),valueNegative&&0==+value&&"+"!==sign&&(valueNegative=!1),valuePrefix=(valueNegative?"("===sign?sign:minus:"-"===sign||"("===sign?"":sign)+valuePrefix,valueSuffix=("s"===type?prefixes[8+prefixExponent/3]:"")+valueSuffix+(valueNegative&&"("===sign?")":""),maybeSuffix)for(i=-1,n=value.length;++i<n;)if(48>(c=value.charCodeAt(i))||c>57){valueSuffix=(46===c?decimal+value.slice(i+1):value.slice(i))+valueSuffix,value=value.slice(0,i);break}}comma&&!zero&&(value=group(value,1/0));var length=valuePrefix.length+value.length+valueSuffix.length,padding=length<width?new Array(width-length+1).join(fill):"";switch(comma&&zero&&(value=group(padding+value,padding.length?width-valueSuffix.length:1/0),padding=""),align){case"<":value=valuePrefix+value+valueSuffix+padding;break;case"=":value=valuePrefix+padding+value+valueSuffix;break;case"^":value=padding.slice(0,length=padding.length>>1)+valuePrefix+value+valueSuffix+padding.slice(length);break;default:value=padding+valuePrefix+value+valueSuffix}return numerals(value)}return precision=void 0===precision?6:/[gprs]/.test(type)?Math.max(1,Math.min(21,precision)):Math.max(0,Math.min(20,precision)),format.toString=function(){return specifier+""},format}return{format:newFormat,formatPrefix:function(specifier,value){var f=newFormat(((specifier=formatSpecifier(specifier)).type="f",specifier)),e=3*Math.max(-8,Math.min(8,Math.floor(exponent(value)/3))),k=Math.pow(10,-e),prefix=prefixes[8+e/3];return function(value){return f(k*value)+prefix}}}}function tickFormat(start,stop,count,specifier){var precision,step=function(start,stop,count){var step0=Math.abs(stop-start)/Math.max(0,count),step1=Math.pow(10,Math.floor(Math.log(step0)/Math.LN10)),error=step0/step1;return error>=e10?step1*=10:error>=e5?step1*=5:error>=e2&&(step1*=2),stop<start?-step1:step1}(start,stop,count);switch((specifier=formatSpecifier(null==specifier?",f":specifier)).type){case"s":var value=Math.max(Math.abs(start),Math.abs(stop));return null!=specifier.precision||isNaN(precision=function(step,value){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(exponent(value)/3)))-exponent(Math.abs(step)))}(step,value))||(specifier.precision=precision),formatPrefix(specifier,value);case"":case"e":case"g":case"p":case"r":null!=specifier.precision||isNaN(precision=function(step,max){return step=Math.abs(step),max=Math.abs(max)-step,Math.max(0,exponent(max)-exponent(step))+1}(step,Math.max(Math.abs(start),Math.abs(stop))))||(specifier.precision=precision-("e"===specifier.type));break;case"f":case"%":null!=specifier.precision||isNaN(precision=function(step){return Math.max(0,-exponent(Math.abs(step)))}(step))||(specifier.precision=precision-2*("%"===specifier.type))}return format(specifier)}function linearish(scale){var domain=scale.domain;return scale.ticks=function(count){var d=domain();return function(start,stop,count){var reverse,n,ticks,step,i=-1;if(count=+count,(start=+start)==(stop=+stop)&&count>0)return[start];if((reverse=stop<start)&&(n=start,start=stop,stop=n),0===(step=tickIncrement(start,stop,count))||!isFinite(step))return[];if(step>0){let r0=Math.round(start/step),r1=Math.round(stop/step);for(r0*step<start&&++r0,r1*step>stop&&--r1,ticks=new Array(n=r1-r0+1);++i<n;)ticks[i]=(r0+i)*step}else{step=-step;let r0=Math.round(start*step),r1=Math.round(stop*step);for(r0/step<start&&++r0,r1/step>stop&&--r1,ticks=new Array(n=r1-r0+1);++i<n;)ticks[i]=(r0+i)/step}return reverse&&ticks.reverse(),ticks}(d[0],d[d.length-1],null==count?10:count)},scale.tickFormat=function(count,specifier){var d=domain();return tickFormat(d[0],d[d.length-1],null==count?10:count,specifier)},scale.nice=function(count){null==count&&(count=10);var prestep,step,d=domain(),i0=0,i1=d.length-1,start=d[i0],stop=d[i1],maxIter=10;for(stop<start&&(step=start,start=stop,stop=step,step=i0,i0=i1,i1=step);maxIter-- >0;){if((step=tickIncrement(start,stop,count))===prestep)return d[i0]=start,d[i1]=stop,domain(d);if(step>0)start=Math.floor(start/step)*step,stop=Math.ceil(stop/step)*step;else{if(!(step<0))break;start=Math.ceil(start*step)/step,stop=Math.floor(stop*step)/step}prestep=step}return scale},scale}function linear$1(){var scale=continuous();return scale.copy=function(){return copy(scale,linear$1())},initRange.apply(scale,arguments),linearish(scale)}function findStratcolumnUnit(units,unitname,path){void 0===path&&(path=[]);var unit=units.find((function(u){return u.identifier.toLowerCase()===unitname.toLowerCase()}));if(unit){var temp_1=unit;do{path.unshift(temp_1),temp_1=units.find((function(u){return u.identifier===temp_1.stratUnitParent}))}while(temp_1);return unit}return null}function getColorFromUnit(unit){return null===unit.colorR||null===unit.colorG||null===unit.colorB?2147483648:unit.colorR<<16|unit.colorG<<8|unit.colorB}locale=formatLocale({thousands:",",grouping:[3],currency:["$",""]}),format=locale.format,formatPrefix=locale.formatPrefix;var unassignedColorScale=function ordinal(){var index=new Map,domain=[],range=[],unknown=implicit;function scale(d){var key=d+"",i=index.get(key);if(!i){if(unknown!==implicit)return unknown;index.set(key,i=domain.push(d))}return range[(i-1)%range.length]}return scale.domain=function(_){if(!arguments.length)return domain.slice();domain=[],index=new Map;for(const value of _){const key=value+"";index.has(key)||index.set(key,domain.push(value))}return scale},scale.range=function(_){return arguments.length?(range=Array.from(_),scale):range.slice()},scale.unknown=function(_){return arguments.length?(unknown=_,scale):unknown},scale.copy=function(){return ordinal(domain,range).unknown(unknown)},initRange.apply(scale,arguments),scale}().domain([0,100]).range(function(interpolator,n){for(var samples=new Array(n),i=0;i<n;++i)samples[i]=interpolator(i/(n-1));return samples}(interpolateRgb("#e6f1cf","#85906d"),10));function isAnchestor(descendant,candidate,stratColumn){var path=[];return findStratcolumnUnit(stratColumn,descendant.name,path),path.some((function(p){return candidate.name===p.identifier}))}
|
|
400
400
|
/*! *****************************************************************************
|
|
401
401
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
402
402
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
@@ -411,4 +411,4 @@ Renderer.registerPlugin("accessibility",AccessibilityManager),Renderer.registerP
|
|
|
411
411
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
412
412
|
and limitations under the License.
|
|
413
413
|
***************************************************************************** */
|
|
414
|
-
var extendStatics$l=function(d,b){return(extendStatics$l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)},__assign$1=function(){return(__assign$1=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t}).apply(this,arguments)};function reduce(v,func,r){void 0===r&&(r=0);for(var i=0;i<v.length;i++)r=func(r,v[i],i);return r}var EPS=Math.pow(2,-42);function cuberoot(x){var y=Math.pow(Math.abs(x),1/3);return x<0?-y:y}function getQuadRoots(a,b,c){if(Math.abs(a)<EPS)return Math.abs(b)<EPS?[]:[-c/b];var D=b*b-4*a*c;return Math.abs(D)<EPS?[-b/(2*a)]:D>0?[(-b+Math.sqrt(D))/(2*a),(-b-Math.sqrt(D))/(2*a)]:[]}function getCoefficients(v0,v1,v2,v3,v,tension){void 0===v&&(v=0),void 0===tension&&(tension=.5);var c=(1-tension)*(v2-v0)*.5,x=(1-tension)*(v3-v1)*.5;return[2*v1-2*v2+c+x,-3*v1+3*v2-2*c-x,c,v1-v]}function solveForT(t,tension,v0,v1,v2,v3){if(Math.abs(t)<EPS)return v1;if(Math.abs(1-t)<EPS)return v2;var t2=t*t,t3=t*t2,_a=getCoefficients(v0,v1,v2,v3,0,tension);return _a[0]*t3+_a[1]*t2+_a[2]*t+_a[3]}function getDerivativeOfT(t,tension,v0,v1,v2,v3){var t2=t*t,_a=getCoefficients(v0,v1,v2,v3,0,tension);return 3*_a[0]*t2+2*_a[1]*t+_a[2]}function distance(p1,p2){return Math.sqrt(reduce(p2,(function(s,c,i){return s+Math.pow(c-p1[i],2)})))}function normalize$2(v){var squared=reduce(v,(function(s,c){return s+Math.pow(c,2)})),l=Math.sqrt(squared);return 0===l?function(v,val){for(var i=0;i<v.length;i++)v[i]=val;return v}(v,0):function(v,func){for(var i=0;i<v.length;i++)v[i]=func(v[i],i);return v}(v,(function(c){return c/l}))}function getControlPoints(idx,points,closed){var p0,p1,p2,p3,maxIndex=points.length-1;return closed?(p0=points[idx-1<0?maxIndex:idx-1],p1=points[idx%points.length],p2=points[(idx+1)%points.length],p3=points[(idx+2)%points.length]):(p0=points[Math.max(0,idx-1)],p1=points[idx],p2=points[Math.min(maxIndex,idx+1)],p3=points[Math.min(maxIndex,idx+2)]),[p0,p1,p2,p3]}function getPointAtT(t,points,options,target){void 0===options&&(options={});var tension=Number.isFinite(options.tension)?options.tension:.5,closed=!!options.closed,func=options.func||solveForT,nPoints=closed?points.length:points.length-1,p=nPoints*t,idx=Math.floor(p),weight=p-idx,_a=getControlPoints(idx,points,closed),p0=_a[0],p1=_a[1],p2=_a[2],p3=_a[3];target=target||new Array(p0.length);for(var i=0;i<p0.length;i++)target[i]=func(weight,tension,p0[i],p1[i],p2[i],p3[i]);return 3===nPoints&&target[1],target}function getTangentAtT(t,points,options,target){void 0===options&&(options={});var tension=Number.isFinite(options.tension)?options.tension:.5,closed=!!options.closed;return 1===tension&&0===t?t+=EPS:1===tension&&1===t&&(t-=EPS),getPointAtT(t,points,{tension:tension,closed:closed,func:getDerivativeOfT},target)}function getArcLengths(points,divisions,options){void 0===options&&(options={});var current,lengths=[],last=getPointAtT(0,points,options),sum=0;divisions=divisions||300,lengths.push(0);for(var p=1;p<=divisions;p++)sum+=distance(current=getPointAtT(p/divisions,points,options),last),lengths.push(sum),last=current;return lengths}function getUtoTmapping(u,arcLengths){for(var comparison,il=arcLengths.length,targetArcLength=u*arcLengths[il-1],low=0,high=il-1,i=0;low<=high;)if((comparison=arcLengths[i=Math.floor(low+(high-low)/2)]-targetArcLength)<0)low=i+1;else{if(!(comparison>0)){high=i;break}high=i-1}if(arcLengths[i=high]===targetArcLength)return i/(il-1);var lengthBefore=arcLengths[i];return(i+(targetArcLength-lengthBefore)/(arcLengths[i+1]-lengthBefore))/(il-1)}function getTtoUmapping(t,arcLengths){if(0===t)return 0;if(1===t)return 1;var al=arcLengths.length-1,totalLength=arcLengths[al],tIdx=t*al,subIdx=Math.floor(tIdx),l1=arcLengths[subIdx];return tIdx===subIdx?l1/totalLength:(l1+(tIdx-subIdx)*(arcLengths[subIdx+1]-l1))/totalLength}function getTAtValue(lookup,tension,v0,v1,v2,v3){var _a=getCoefficients(v0,v1,v2,v3,lookup,tension),a=_a[0],b=_a[1],c=_a[2],d=_a[3];return 0===a&&0===b&&0===c&&0===d?[0]:function(a,b,c,d){if(Math.abs(a)<EPS)return getQuadRoots(b,c,d);var roots,p=(3*a*c-b*b)/(3*a*a),q=(2*b*b*b-9*a*b*c+27*a*a*d)/(27*a*a*a);if(Math.abs(p)<EPS)roots=[cuberoot(-q)];else if(Math.abs(q)<EPS)roots=[0].concat(p<0?[Math.sqrt(-p),-Math.sqrt(-p)]:[]);else{var D=q*q/4+p*p*p/27;if(Math.abs(D)<EPS)roots=[-1.5*q/p,3*q/p];else if(D>0)roots=[(u=cuberoot(-q/2-Math.sqrt(D)))-p/(3*u)];else{var u=2*Math.sqrt(-p/3),t=Math.acos(3*q/p/u)/3,k=2*Math.PI/3;roots=[u*Math.cos(t),u*Math.cos(t-k),u*Math.cos(t-2*k)]}}for(var i=0;i<roots.length;i++)roots[i]-=b/(3*a);return roots}(a,b,c,d).filter((function(t){return t>-EPS&&t<=1+EPS})).map((function(t){return void 0===(min=0)&&(min=0),void 0===(max=1)&&(max=1),(value=t)<min?min:value>max?max:value;var value,min,max}))}var CurveInterpolator=function(){function CurveInterpolator(points,options){void 0===options&&(options={}),options=__assign$1({tension:.5,arcDivisions:300,closed:!1},options),this._cache={},this._tension=options.tension,this._arcDivisions=options.arcDivisions,this._lmargin=options.lmargin||1-this._tension,this._closed=options.closed,this.points=points}return CurveInterpolator.prototype.getT=function(position){return getUtoTmapping(position,this.arcLengths)},CurveInterpolator.prototype.getPointAt=function(position,target){var options={tension:this.tension,closed:this.closed};return getPointAtT(this.getT(position),this.points,options,target)},CurveInterpolator.prototype.getTangentAt=function(position,target){return void 0===target&&(target=null),normalize$2(getTangentAtT(this.getT(position),this.points,{tension:this.tension,closed:this.closed},target))},CurveInterpolator.prototype.getBoundingBox=function(from,to){if(void 0===from&&(from=0),void 0===to&&(to=1),0===from&&1===to&&this._cache.bbox)return this._cache.bbox;var bbox=function(points,options){void 0===options&&(options={});for(var _a=__assign$1({tension:.5,closed:!1,from:0,to:1,arcLengths:null,arcDivisions:300},options),tension=_a.tension,closed=_a.closed,u0=_a.from,u1=_a.to,arcLengths=_a.arcLengths,arcDivisions=_a.arcDivisions,nPoints=closed?points.length:points.length-1,t0=getUtoTmapping(u0,arcLengths=arcLengths||getArcLengths(points,arcDivisions,{tension:tension,closed:closed})),t1=getUtoTmapping(u1,arcLengths),i0=Math.floor(nPoints*t0),i1=Math.ceil(nPoints*t1),start=getPointAtT(t0,points,{tension:tension,closed:closed}),end=getPointAtT(t1,points,{tension:tension,closed:closed}),min=[],max=[],c=0;c<start.length;c++)min[c]=Math.min(start[c],end[c]),max[c]=Math.max(start[c],end[c]);for(var _loop_1=function(i){var _a=getControlPoints(i-1,points,closed),p0=_a[0],p1=_a[1],p2=_a[2],p3=_a[3];if(i<i1)for(var c=0;c<p2.length;c++)p2[c]<min[c]&&(min[c]=p2[c]),p2[c]>max[c]&&(max[c]=p2[c]);if(tension<1){var w0_1=nPoints*t0-(i-1),w1_1=nPoints*t1-(i-1),valid=function(t){return t>-EPS&&t<=1+EPS&&(i-1!==i0||t>w0_1)&&(i!==i1||t<w1_1)},_loop_2=function(c){var _a=getCoefficients(p0[c],p1[c],p2[c],p3[c],0,tension);getQuadRoots(3*_a[0],2*_a[1],_a[2]).filter(valid).forEach((function(t){var v=solveForT(t,tension,p0[c],p1[c],p2[c],p3[c]);v<min[c]&&(min[c]=v),v>max[c]&&(max[c]=v)}))};for(c=0;c<p0.length;c++)_loop_2(c)}},i=i0+1;i<=i1;i++)_loop_1(i);return{min:min,max:max}}(this.points,{from:from,to:to,tension:this.tension,closed:this.closed,arcLengths:this.arcLengths});return 0===from&&1===to&&(this._cache.bbox=bbox),bbox},CurveInterpolator.prototype.getPoints=function(samples,returnType,from,to){if(void 0===samples&&(samples=100),void 0===from&&(from=0),void 0===to&&(to=1),!samples||samples<=0)throw Error("Invalid arguments passed to getPoints(). You must specify at least 1 sample/segment.");if(!(from<0||to>1||to<from)){for(var pts=[],d=0;d<=samples;d++){var u=0===from&&1===to?d/samples:from+d/samples*(to-from);pts.push(this.getPointAt(u,returnType&&new returnType))}return pts}},CurveInterpolator.prototype.lookup=function(v,axis,max,margin){void 0===axis&&(axis=0),void 0===max&&(max=0),void 0===margin&&(margin=this._lmargin);var matches=function(lookup,points,options){for(var _a=__assign$1({axis:0,tension:.5,closed:!1,margin:.5,max:0,processRefAxis:!1,func:solveForT},options),func=_a.func,axis=_a.axis,tension=_a.tension,closed=_a.closed,margin=_a.margin,max=_a.max,processRefAxis=_a.processRefAxis,k=axis,solutions=[],nPoints=closed?points.length:points.length-1,i=0;i<nPoints;i+=1){var idx=max<0?nPoints-(i+1):i,_b=getControlPoints(idx,points,closed),p0=_b[0],p1=_b[1],p2=_b[2],p3=_b[3],vmin=void 0,vmax=void 0;if(p1[k]<p2[k]?(vmin=p1[k],vmax=p2[k]):(vmin=p2[k],vmax=p1[k]),lookup-margin<=vmax&&lookup+margin>=vmin){var ts=getTAtValue(lookup,tension,p0[k],p1[k],p2[k],p3[k]);max<0?ts.sort((function(a,b){return b-a})):max>=0&&ts.sort((function(a,b){return a-b}));for(var j=0;j<ts.length;j++)if(!(0===ts[j]&&i>0)){for(var coord=[],c=0;c<p0.length;c++){var v;v=c!==k||processRefAxis?func(ts[j],tension,p0[c],p1[c],p2[c],p3[c],idx-1):lookup,coord[c]=v}if(solutions.push(coord),solutions.length===Math.abs(max))return solutions}}}return solutions}(v,this.points,{axis:axis,tension:this.tension,closed:this.closed,max:max,margin:margin});return 1===Math.abs(max)&&1===matches.length?matches[0]:matches},CurveInterpolator.prototype.lookupPositions=function(v,axis,max,margin){return void 0===axis&&(axis=0),void 0===max&&(max=0),void 0===margin&&(margin=this._lmargin),function(lookup,points,options){for(var _a=__assign$1({axis:0,tension:.5,closed:!1,margin:.5,max:0},options),axis=_a.axis,tension=_a.tension,closed=_a.closed,margin=_a.margin,max=_a.max,k=axis,solutions=new Set,arcLengths=options.arcLengths||getArcLengths(points,options.arcDivisions||300,{tension:tension,closed:closed}),nPoints=closed?points.length:points.length-1,i=0;i<nPoints;i+=1){var idx=max<0?points.length-i:i,_b=getControlPoints(idx,points,closed),p0=_b[0],p1=_b[1],p2=_b[2],p3=_b[3],vmin=void 0,vmax=void 0;if(p1[k]<p2[k]?(vmin=p1[k],vmax=p2[k]):(vmin=p2[k],vmax=p1[k]),lookup-margin<=vmax&&lookup+margin>=vmin){var ts=getTAtValue(lookup,tension,p0[k],p1[k],p2[k],p3[k]);max<0?ts.sort((function(a,b){return b-a})):max>=0&&ts.sort((function(a,b){return a-b}));for(var j=0;j<ts.length;j++)if(!(0===ts[j]&&i>0)){var u=getTtoUmapping((ts[j]+idx)/nPoints,arcLengths);if(solutions.add(u),solutions.size===Math.abs(max))return Array.from(solutions)}}}return Array.from(solutions)}(v,this.points,{axis:axis,arcLengths:this.arcLengths,tension:this.tension,closed:this.closed,max:max,margin:margin})},CurveInterpolator.prototype.invalidateCache=function(){var _this=this;return Object.keys(this._cache).forEach((function(key){delete _this._cache[key]})),this},Object.defineProperty(CurveInterpolator.prototype,"points",{get:function(){return this._points},set:function(pts){this._points=pts,this.invalidateCache()},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"tension",{get:function(){return this._tension},set:function(t){t!==this._tension&&(this._tension=t,this.invalidateCache())},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"closed",{get:function(){return this._closed},set:function(isClosed){isClosed!==this._closed&&(this._closed=isClosed,this.invalidateCache())},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"arcDivisions",{get:function(){return this._arcDivisions},set:function(n){n!==this._arcDivisions&&(this._arcDivisions=n,this.invalidateCache())},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"arcLengths",{get:function(){if(this._cache.arcLengths)return this._cache.arcLengths;var arcLengths=getArcLengths(this.points,this.arcDivisions,{tension:this.tension,closed:this.closed});return this._cache.arcLengths=arcLengths,arcLengths},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"length",{get:function(){var lengths=this.arcLengths;return lengths[lengths.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"minX",{get:function(){return this.getBoundingBox().min[0]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"maxX",{get:function(){return this.getBoundingBox().max[0]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"minY",{get:function(){return this.getBoundingBox().min[1]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"maxY",{get:function(){return this.getBoundingBox().max[1]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"minZ",{get:function(){return this.getBoundingBox().min[2]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"maxZ",{get:function(){return this.getBoundingBox().max[2]},enumerable:!0,configurable:!0}),CurveInterpolator}();!function(_super){function CurveInterpolator2D(points,tension,arcDivisions,closed){return void 0===tension&&(tension=.5),void 0===arcDivisions&&(arcDivisions=300),void 0===closed&&(closed=!1),_super.call(this,points,{tension:tension,arcDivisions:arcDivisions,closed:closed})||this}(function(d,b){function __(){this.constructor=d}extendStatics$l(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)})(CurveInterpolator2D,_super),CurveInterpolator2D.prototype.x=function(y,max,margin){void 0===max&&(max=0),void 0===margin&&(margin=this._lmargin);var res=this.lookup(y,1,max,margin);return 1===Math.abs(max)?res[0]:res.map((function(d){return d[0]}))},CurveInterpolator2D.prototype.y=function(x,max,margin){void 0===max&&(max=0),void 0===margin&&(margin=this._lmargin);var res=this.lookup(x,0,max,margin);return 1===Math.abs(max)?res[1]:res.map((function(d){return d[1]}))},CurveInterpolator2D.prototype.getNormalAt=function(position,target){return normalize$2(function(v){if(v.length>2)throw Error("Only supported for 2d vectors");var x=-v[1];return v[1]=v[0],v[0]=x,v}(getTangentAtT(this.getT(position),this.points,{tension:this.tension,closed:this.closed},target)))},CurveInterpolator2D.prototype.getAngleAt=function(position){var tan=getTangentAtT(this.getT(position),this.points,{tension:this.tension,closed:this.closed});return Math.atan2(tan[1],tan[0])},CurveInterpolator2D.prototype.getBoundingBox=function(from,to){void 0===from&&(from=0),void 0===to&&(to=1);var bbox=_super.prototype.getBoundingBox.call(this,from,to);return{x1:bbox.min[0],x2:bbox.max[0],y1:bbox.min[1],y2:bbox.max[1],min:bbox.min,max:bbox.max}}}(CurveInterpolator),function(){function Point(x,y,z,w){void 0===x&&(x=0),void 0===y&&(y=0),void 0===z&&(z=null),void 0===w&&(w=null),this.x=x,this.y=y,this.z=z,this.w=w}Object.defineProperty(Point.prototype,0,{get:function(){return this.x},set:function(x){this.x=x},enumerable:!0,configurable:!0}),Object.defineProperty(Point.prototype,1,{get:function(){return this.y},set:function(y){this.y=y},enumerable:!0,configurable:!0}),Object.defineProperty(Point.prototype,2,{get:function(){return this.z},set:function(z){this.z=z},enumerable:!0,configurable:!0}),Object.defineProperty(Point.prototype,3,{get:function(){return this.w},set:function(w){this.w=w},enumerable:!0,configurable:!0}),Object.defineProperty(Point.prototype,"length",{get:function(){return Number.isFinite(this.w)?4:Number.isFinite(this.z)?3:2},enumerable:!0,configurable:!0})}();function simplify(inputArr,maxOffset,maxDistance){var _a;if(void 0===maxOffset&&(maxOffset=.001),void 0===maxDistance&&(maxDistance=10),inputArr.length<=4)return inputArr;for(var _b=inputArr[0],o0=_b[0],o1=_b[1],arr=inputArr.map((function(d){return[d[0]-o0,d[1]-o1]})),_c=arr[0],a0=_c[0],a1=_c[1],sim=[inputArr[0]],i=1;i+1<arr.length;i++){var _d=arr[i],t0=_d[0],t1=_d[1],_e=arr[i+1],b0=_e[0],b1=_e[1];if(b0-t0!=0||b1-t1!=0){var proximity=Math.abs(a0*b1-a1*b0+b0*t1-b1*t0+a1*t0-a0*t1)/Math.sqrt(Math.pow(b0-a0,2)+Math.pow(b1-a1,2)),dir=[a0-t0,a1-t1],len=Math.sqrt(Math.pow(dir[0],2)+Math.pow(dir[1],2));(proximity>maxOffset||len>=maxDistance)&&(sim.push([t0+o0,t1+o1]),a0=(_a=[t0,t1])[0],a1=_a[1])}}var last=arr[arr.length-1];return sim.push([last[0]+o0,last[1]+o1]),sim}function projectCurtain(points,origin,offset){void 0===origin&&(origin=null),void 0===offset&&(offset=0);var p0=origin||points[0],l=0;return points.map((function(p1){var dx=p1[0]-p0[0],dy=p1[1]-p0[1];return l+=Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2)),p0=p1,[offset>0?offset-l:l,p1[2]||0]}))}function findIndexOfSample(data,pos){for(var a=0,b=data.length-1,aPos=data[a][0],bPos=data[b][0];b-a>20;){var splitAt=Math.floor((b+a)/2),splitPos=data[splitAt][0];if(pos>=aPos&&pos<splitPos)bPos=data[b=splitAt][0];else if(pos>=splitPos&&pos<=bPos)aPos=data[a=splitAt][0];else if(pos<=aPos&&pos>splitPos)bPos=data[b=splitAt][0];else{if(!(pos<=splitPos&&pos>=bPos))return-1;aPos=data[a=splitAt][0]}}for(var index=-1,i=a;i<b;i++){var v1=data[i][0],v2=data[i+1][0];if(Math.min(v1,v2)<=pos&&pos<=Math.max(v1,v2)){index=i;break}}return index}function findSampleAtPos(data,pos,topLimit,bottomLimit){void 0===topLimit&&(topLimit=null),void 0===bottomLimit&&(bottomLimit=null);var y=null,index=findIndexOfSample(data,pos);if(-1!==index){var v1=data[index][1],v2=data[index+1][1];if(v2&&v2){var x1=data[index][0],f=(pos-x1)/(data[index+1][0]-x1);y=v1*(1-f)+v2*f,topLimit&&topLimit>y&&(y=topLimit),bottomLimit&&bottomLimit<y&&(y=bottomLimit)}}return y}function mapPick(p,groupName){return{title:p.pickIdentifier||p.identifier,group:groupName,label:p.md+" "+p.mdUnit+" "+p.depthReferencePoint,color:"strat-picks"===groupName?"#227":"rgba(0,0,0,0.8)",md:p.md}}var GeomodelLabelsLayer=function(_super){function GeomodelLabelsLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.defaultMargins=18,_this.defaultMinFontSize=8,_this.defaultMaxFontSize=13,_this.defaultTextColor="black",_this.defaultFont="Arial",_this.isLabelsOnLeftSide=!0,_this.maxFontSizeInWorldCoordinates=70,_this.isXFlipped=!1,_this.areasWithAvgTopDepth=null,_this.drawAreaLabel=function(surfaceArea,nextSurfaceArea,surfaces,i){var data=surfaceArea.data,_a=_this,ctx=_a.ctx,maxFontSizeInWorldCoordinates=_a.maxFontSizeInWorldCoordinates,isXFlipped=_a.isXFlipped,_b=_this.rescaleEvent,xScale=_b.xScale,yScale=_b.yScale,xRatio=_b.xRatio,yRatio=_b.yRatio,zFactor=_b.zFactor,isLabelsOnLeftSide=_this.checkDrawLabelsOnLeftSide(),marginsInWorldCoords=(_this.options.margins||_this.defaultMargins)*(isXFlipped?-1:1)/xRatio,minFontSize=_this.options.minFontSize||_this.defaultMinFontSize,fontSizeInWorldCoords=(_this.options.maxFontSize||_this.defaultMaxFontSize)/yRatio;fontSizeInWorldCoords>maxFontSizeInWorldCoordinates&&(fontSizeInWorldCoords=maxFontSizeInWorldCoordinates)*yRatio<minFontSize&&(fontSizeInWorldCoords=minFontSize/yRatio);var leftEdge=xScale.invert(xScale.range()[0])+marginsInWorldCoords,rightEdge=xScale.invert(xScale.range()[1])-marginsInWorldCoords,_c=_this.getSurfacesAreaEdges(),surfaceAreaLeftEdge=_c[0],surfaceAreaRightEdge=_c[1];ctx.save(),ctx.font=fontSizeInWorldCoords*yRatio+"px "+(_this.options.font||_this.defaultFont);var startPos,labelMetrics=ctx.measureText(surfaceArea.label),labelLengthInWorldCoords=labelMetrics.width/xRatio;if(isLabelsOnLeftSide){var labelRightEdge=leftEdge+(isXFlipped?-labelLengthInWorldCoords:labelLengthInWorldCoords);(!isXFlipped&&labelRightEdge>surfaceAreaRightEdge||isXFlipped&&labelRightEdge<surfaceAreaRightEdge)&&(isLabelsOnLeftSide=!1)}else{var labelLeftEdge=rightEdge+(isXFlipped?labelLengthInWorldCoords:-labelLengthInWorldCoords);(!isXFlipped&&labelLeftEdge<surfaceAreaLeftEdge||isXFlipped&&labelLeftEdge>surfaceAreaLeftEdge)&&(isLabelsOnLeftSide=!0)}startPos=isLabelsOnLeftSide?isXFlipped?Math.min(surfaceAreaLeftEdge,leftEdge):Math.max(surfaceAreaLeftEdge,leftEdge):isXFlipped?Math.max(surfaceAreaRightEdge,rightEdge):Math.min(surfaceAreaRightEdge,rightEdge);var topEdge=yScale.invert(yScale.range()[0]),bottomEdge=yScale.invert(yScale.range()[1]),posStep=labelLengthInWorldCoords/3*.07*(isLabelsOnLeftSide?1:-1)*(isXFlipped?-1:1),dirStep=labelLengthInWorldCoords/5*(isLabelsOnLeftSide?1:-1)*(isXFlipped?-1:1),topData=data.map((function(d){return[d[0],d[1]]})),topPos=_this.calcPos(topData,startPos,3,posStep,topEdge,bottomEdge);if(topPos){var bottomData=data.map((function(d){return[d[0],d[2]]})),bottomPos=_this.calcPos(bottomData,startPos,3,posStep,topEdge,bottomEdge,nextSurfaceArea?nextSurfaceArea.data.map((function(d){return[d[0],d[1]]})):null,surfaces,i);bottomPos||(bottomPos=new Vector2(topPos.x,bottomEdge));var thickness=bottomPos.y-topPos.y;if(thickness<fontSizeInWorldCoords){if(thickness*yRatio<minFontSize)return;fontSizeInWorldCoords=thickness,ctx.font=fontSizeInWorldCoords*yRatio+"px "+(_this.options.font||_this.defaultFont),labelLengthInWorldCoords=(labelMetrics=ctx.measureText(surfaceArea.label)).width/xRatio}var initialDirVec=isLabelsOnLeftSide!==isXFlipped?Vector2.right:Vector2.left,areaDir=_this.calcAreaDir(topData,bottomData,startPos,5,dirStep,initialDirVec,topEdge,bottomEdge,0,Math.PI/4,4,nextSurfaceArea?nextSurfaceArea.data.map((function(d){return[d[0],d[1]]})):null,surfaces,i),scaledAngle=Math.atan(Math.tan(areaDir)*zFactor),textX=startPos,textY=(topPos.y+bottomPos.y)/2,textAngle=isXFlipped?-scaledAngle:scaledAngle;ctx.textAlign=isLabelsOnLeftSide?"left":"right",ctx.translate(xScale(textX),yScale(textY)),ctx.rotate(textAngle),ctx.fillStyle=_this.options.textColor||_this.defaultTextColor,ctx.font=fontSizeInWorldCoords*yRatio+"px "+(_this.options.font||_this.defaultFont),ctx.textBaseline="middle",ctx.fillText(surfaceArea.label,0,0),ctx.restore()}},_this.drawLineLabel=function(s){var _a=_this,ctx=_a.ctx,isXFlipped=_a.isXFlipped,_b=_this.rescaleEvent,xScale=_b.xScale,yScale=_b.yScale,xRatio=_b.xRatio,yRatio=_b.yRatio,zFactor=_b.zFactor,isLabelsOnLeftSide=_this.checkDrawLabelsOnLeftSide(),marginsInWorldCoords=_this.getMarginsInWorldCoordinates(),fontSizeInWorldCoords=(_this.options.maxFontSize||_this.defaultMaxFontSize)/yRatio;ctx.save(),ctx.font=fontSizeInWorldCoords*yRatio+"px "+(_this.options.font||_this.defaultFont);var startPos,labelLengthInWorldCoords=ctx.measureText(s.label).width/xRatio,leftEdge=xScale.invert(xScale.range()[0])+marginsInWorldCoords,rightEdge=xScale.invert(xScale.range()[1])-marginsInWorldCoords,_c=_this.getSurfacesAreaEdges(),surfaceAreaLeftEdge=_c[0],surfaceAreaRightEdge=_c[1];startPos=isLabelsOnLeftSide?isXFlipped?Math.max(surfaceAreaRightEdge,rightEdge):Math.min(surfaceAreaRightEdge,rightEdge):isXFlipped?Math.min(surfaceAreaLeftEdge,leftEdge):Math.max(surfaceAreaLeftEdge,leftEdge);var step=labelLengthInWorldCoords/5*(isLabelsOnLeftSide?-1:1),data=s.data,pos=_this.calcPos(data,startPos,5,step),dir=_this.calcLineDir(data,startPos,5,step,zFactor,isLabelsOnLeftSide?Vector2.left:Vector2.right);if(pos&&dir){var textX=startPos,textY=pos.y-1-fontSizeInWorldCoords/2,textDir=Vector2.angleRight(dir)-(isLabelsOnLeftSide?Math.PI:0);ctx.textAlign=isLabelsOnLeftSide?"right":"left",ctx.translate(xScale(textX),yScale(textY)),ctx.rotate(textDir),ctx.fillStyle=_this.colorToCSSColor(s.color),ctx.textBaseline="middle",ctx.fillText(s.label,0,0),ctx.restore()}},_this.render=_this.render.bind(_this),_this.getMarginsInWorldCoordinates=_this.getMarginsInWorldCoordinates.bind(_this),_this.getSurfacesAreaEdges=_this.getSurfacesAreaEdges.bind(_this),_this.updateXFlipped=_this.updateXFlipped.bind(_this),_this.generateSurfacesWithAvgDepth=_this.generateSurfacesWithAvgDepth.bind(_this),_this}return __extends(GeomodelLabelsLayer,_super),Object.defineProperty(GeomodelLabelsLayer.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),GeomodelLabelsLayer.prototype.setData=function(data){_super.prototype.setData.call(this,data),this.areasWithAvgTopDepth=null},GeomodelLabelsLayer.prototype.generateSurfacesWithAvgDepth=function(){var areas=this.data.areas;this.areasWithAvgTopDepth=areas.reduce((function(acc,area){if(!area.label)return acc;var sumAndCount=area.data.reduce((function(a,d){return null!=d[1]&&(a.sum+=d[1],a.count++),a}),{sum:0,count:0});if(0===sumAndCount.count)return acc;var avgTopDepth=sumAndCount.sum/sumAndCount.count;return __spreadArray(__spreadArray([],acc),[__assign(__assign({},area),{avgTopDepth:avgTopDepth})])}),[])},GeomodelLabelsLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event)},GeomodelLabelsLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.render()},GeomodelLabelsLayer.prototype.onRescale=function(event){this.rescaleEvent=event,this.updateXFlipped(),this.resetTransform(),this.render()},GeomodelLabelsLayer.prototype.render=function(){this.rescaleEvent&&(this.clearCanvas(),this.data&&(this.areasWithAvgTopDepth||this.generateSurfacesWithAvgDepth(),this.drawAreaLabels(),this.drawLineLabels()))},GeomodelLabelsLayer.prototype.drawAreaLabels=function(){var _this=this;this.areasWithAvgTopDepth.forEach((function(s,i,array){var topmostSurfaceNotDrawnYet=array.reduce((function(acc,v,index){return index>i&&(null==acc||v.avgTopDepth<acc.avgTopDepth)&&(acc=v),acc}),null);_this.drawAreaLabel(s,topmostSurfaceNotDrawnYet,array,i)}))},GeomodelLabelsLayer.prototype.drawLineLabels=function(){var _this=this;this.data.lines.filter((function(surfaceLine){return surfaceLine.label})).forEach((function(surfaceLine){return _this.drawLineLabel(surfaceLine)}))},GeomodelLabelsLayer.prototype.colorToCSSColor=function(color){if("string"==typeof color)return color;var hexString=color.toString(16);return"#"+(hexString="000000".substr(0,6-hexString.length)+hexString)},GeomodelLabelsLayer.prototype.calcPos=function(data,offset,count,step,topLimit,bottomLimit,alternativeSurfaceData,surfaces,currentSurfaceIndex){void 0===topLimit&&(topLimit=null),void 0===bottomLimit&&(bottomLimit=null),void 0===alternativeSurfaceData&&(alternativeSurfaceData=null),void 0===surfaces&&(surfaces=null),void 0===currentSurfaceIndex&&(currentSurfaceIndex=null);for(var pos=Vector2.zero.mutable,samples=0,i=0;i<count;i++){var x=offset+i*step,y=findSampleAtPos(data,x,topLimit,bottomLimit);if(y){var alternativeY=this.getAlternativeYValueIfAvailable(x,topLimit,bottomLimit,alternativeSurfaceData,surfaces,currentSurfaceIndex),usedY=alternativeY?Math.min(y,alternativeY):y;pos.add(x,usedY),samples++}}return 0===samples?null:Vector2.divide(pos,samples)},GeomodelLabelsLayer.prototype.getAlternativeYValueIfAvailable=function(x,topLimit,bottomLimit,alternativeSurfaceData,surfaces,currentSurfaceIndex){if(!alternativeSurfaceData)return null;var altY=findSampleAtPos(alternativeSurfaceData,x,topLimit,bottomLimit);if(null==altY&&surfaces&&null!=currentSurfaceIndex)for(var si=currentSurfaceIndex+1;null==altY&&si<surfaces.length;){altY=findSampleAtPos(surfaces[si++].data.map((function(d){return[d[0],d[1]]})),x,topLimit,bottomLimit)}return altY},GeomodelLabelsLayer.prototype.calcLineDir=function(data,offset,count,step,zFactor,initalVector,topLimit,bottomLimit){void 0===initalVector&&(initalVector=Vector2.left),void 0===topLimit&&(topLimit=null),void 0===bottomLimit&&(bottomLimit=null);var dir=initalVector.mutable,startY=findSampleAtPos(data,offset,topLimit,bottomLimit);if(null===startY)return dir;for(var vecAtEnd=new Vector2(offset,startY*zFactor),tmpVec=Vector2.zero.mutable,i=1;i<=count;i++){var x=offset+i*step,y=findSampleAtPos(data,offset,topLimit,bottomLimit);null!==y&&(tmpVec.set(x,y*zFactor),tmpVec.sub(vecAtEnd),dir.add(tmpVec))}return dir},GeomodelLabelsLayer.prototype.calcAreaDir=function(top,bottom,offset,count,step,initalVector,topLimit,bottomLimit,minReductionAngle,maxReductionAngle,angleReductionExponent,alternativeSurfaceBottomData,surfaces,currentSurfaceIndex){void 0===initalVector&&(initalVector=Vector2.left),void 0===topLimit&&(topLimit=null),void 0===bottomLimit&&(bottomLimit=null),void 0===minReductionAngle&&(minReductionAngle=0),void 0===maxReductionAngle&&(maxReductionAngle=Math.PI/4),void 0===angleReductionExponent&&(angleReductionExponent=4),void 0===alternativeSurfaceBottomData&&(alternativeSurfaceBottomData=null),void 0===surfaces&&(surfaces=null),void 0===currentSurfaceIndex&&(currentSurfaceIndex=null);for(var vecAtEnd,angles=[],tmpVec=Vector2.zero.mutable,i=0;i<=count;i++){var x=offset+i*step,topY=findSampleAtPos(top,x,topLimit,bottomLimit),bottomY=findSampleAtPos(bottom,x,topLimit,bottomLimit)||bottomLimit,alternativeBottomY=this.getAlternativeYValueIfAvailable(x,topLimit,bottomLimit,alternativeSurfaceBottomData,surfaces,currentSurfaceIndex),usedBottomY=alternativeBottomY?Math.min(bottomY,alternativeBottomY):bottomY;if(0===i){if(null===topY)return Vector2.angleRight(initalVector);vecAtEnd=new Vector2(offset,(topY+usedBottomY)/2)}else null!==topY?(tmpVec.set(x,(topY+usedBottomY)/2),tmpVec.sub(vecAtEnd),angles.push(Vector2.angleRight(tmpVec))):angles.push(Vector2.angleRight(initalVector))}var refAngle=angles[0],offsetAngles=angles.map((function(d){return d-refAngle})),factors=0;return offsetAngles.reduce((function(acc,v){var ratio=(Math.abs(v)-minReductionAngle)/maxReductionAngle,factor=Math.pow(1-clamp(ratio,0,1),angleReductionExponent);return factors+=factor,acc+v*factor}),0)/factors+refAngle},GeomodelLabelsLayer.prototype.updateXFlipped=function(){var xBounds=this.rescaleEvent.xBounds;this.isXFlipped=xBounds[0]>xBounds[1]},GeomodelLabelsLayer.prototype.getMarginsInWorldCoordinates=function(){var xRatio=this.rescaleEvent.xRatio;return(this.options.margins||this.defaultMargins)*(this.isXFlipped?-1:1)/xRatio},GeomodelLabelsLayer.prototype.getSurfacesAreaEdges=function(){var data=this.data.areas[0].data,maxX=Math.max(data[data.length-1][0],data[0][0]),minX=Math.min(data[0][0],data[data.length-1][0]),marginsInWorldCoords=this.getMarginsInWorldCoordinates(),isXFlipped=this.isXFlipped;return[isXFlipped?maxX+marginsInWorldCoords:minX+marginsInWorldCoords,isXFlipped?minX-marginsInWorldCoords:maxX-marginsInWorldCoords]},GeomodelLabelsLayer.prototype.checkDrawLabelsOnLeftSide=function(){var referenceSystem=this.referenceSystem,isXFlipped=this.isXFlipped;if(!referenceSystem)return!0;var _b=this.rescaleEvent,xScale=_b.xScale,yScale=_b.yScale,xRatio=_b.xRatio,_c=xScale.domain(),dx1=_c[0],dx2=_c[1],_d=yScale.domain(),dy1=_d[0],dy2=_d[1],top=referenceSystem.interpolators.curtain.lookup(dy1,1,0);0===top.length&&(top=[referenceSystem.interpolators.curtain.getPointAt(0)]);var bottom=referenceSystem.interpolators.curtain.lookup(dy2,1,0);0===bottom.length&&(bottom=[referenceSystem.interpolators.curtain.getPointAt(1)]);var maxX=Math.max(top[0][0],bottom[0][0]),minX=Math.min(top[0][0],bottom[0][0]),wbBBox_left=isXFlipped?maxX:minX,wbBBox_right=isXFlipped?minX:maxX,margin=this.getMarginsInWorldCoordinates(),screenLeftEdge=dx1+margin,screenRightEdge=dx2-margin,_e=this.getSurfacesAreaEdges(),surfaceAreaLeftEdge=_e[0],surfaceAreaRightEdge=_e[1],leftLimit=isXFlipped?Math.min(screenLeftEdge,surfaceAreaLeftEdge):Math.max(screenLeftEdge,surfaceAreaLeftEdge),rightLimit=isXFlipped?Math.max(screenRightEdge,surfaceAreaRightEdge):Math.min(screenRightEdge,surfaceAreaRightEdge),spaceOnLeftSide=Math.max(isXFlipped?leftLimit-wbBBox_left:wbBBox_left-leftLimit,0),spaceOnRightSide=Math.max(isXFlipped?wbBBox_right-rightLimit:rightLimit-wbBBox_right,0),spaceOnLeftSideInScreenCoordinates=spaceOnLeftSide*xRatio;return spaceOnLeftSide>spaceOnRightSide||spaceOnLeftSideInScreenCoordinates>200||spaceOnLeftSideInScreenCoordinates<200&&spaceOnRightSide*xRatio<200&&isXFlipped||bottom[1]<dy1},GeomodelLabelsLayer}(CanvasLayer);function pixelsPerUnit(x){var min=x.domain()[0];return Math.abs(x(min+1))}function calcSize(factor,min,max,x){return clamp(pixelsPerUnit(x)*factor,min,max)}function isOverlapping(r1,r2,horizontalPadding,verticalPadding){void 0===horizontalPadding&&(horizontalPadding=4),void 0===verticalPadding&&(verticalPadding=2);var r1x2=r1.x+r1.width+horizontalPadding,r2x2=r2.x+r2.width+horizontalPadding,r1y2=r1.y+r1.height+verticalPadding,r2y2=r2.y+r2.height+verticalPadding;return!(r2.x-horizontalPadding>r1x2||r2.y-verticalPadding>r1y2||r2x2+horizontalPadding<r1.x||r2y2+verticalPadding<r1.y)}function getOverlapOffset(r1,r2,horizontalPadding,verticalPadding){void 0===horizontalPadding&&(horizontalPadding=4),void 0===verticalPadding&&(verticalPadding=2);var r1x2=r1.x+r1.width,r2x2=r2.x+r2.width,r1y2=r1.y+r1.height,r2y2=r2.y+r2.height;return r2.x-horizontalPadding>r1x2||r2.y-verticalPadding>r1y2||r2x2+horizontalPadding<r1.x||r2y2+verticalPadding<r1.y?null:{dx:r1.x+r1.width-r2.x+horizontalPadding,dy:r1.y+r1.height-r2.y+verticalPadding}}var Location_topleft="topleft",Location_topright="topright",Location_bottomleft="bottomleft",Location_bottomright="bottomright",CalloutCanvasLayer=function(_super){function CalloutCanvasLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.groupFilter=null,_this.renderAnnotation=function(title,label,x,y,fontSize,color){_this.renderText(title,x,y-fontSize,fontSize,color,"arial","bold"),_this.renderText(label,x,y,fontSize,color)},_this.renderLine=function(x,y,width,dotX,dotY,color,placeLeft){void 0===placeLeft&&(placeLeft=!0);var ctx=_this.ctx,textX=placeLeft?x:x+width,inverseTextX=placeLeft?x+width:x,textY=y+2;ctx.strokeStyle=color,ctx.lineWidth=1,ctx.beginPath(),ctx.moveTo(dotX,dotY),ctx.lineTo(textX,textY),ctx.lineTo(inverseTextX,textY),ctx.stroke()},_this.minFontSize=options.minFontSize||7,_this.maxFontSize=options.maxFontSize||11,_this.fontSizeFactor=options.fontSizeFactor||7,_this.offsetMin=options.offsetMin||20,_this.offsetMax=options.offsetMax||120,_this.offsetFactor=options.offsetFactor||19,_this}return __extends(CalloutCanvasLayer,_super),CalloutCanvasLayer.prototype.setGroupFilter=function(filter){this.groupFilter=filter,this.callouts=void 0,this.render()},CalloutCanvasLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.callouts=void 0,this.render()},CalloutCanvasLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event);var isPanning=this.rescaleEvent&&this.rescaleEvent.xRatio===event.xRatio;this.rescaleEvent=event,this.render(isPanning)},CalloutCanvasLayer.prototype.render=function(isPanning){var _this=this;if(void 0===isPanning&&(isPanning=!1),this.clearCanvas(),this.data&&this.rescaleEvent&&this.referenceSystem){var _a=this.rescaleEvent,xScale=_a.xScale,yScale=_a.yScale,xBounds=_a.xBounds,fontSize=calcSize(this.fontSizeFactor,this.minFontSize,this.maxFontSize,xScale);if(!isPanning||!this.callouts){var data=this.data,ctx=this.ctx,groupFilter_1=this.groupFilter,isLeftToRight=this.referenceSystem.options.calculateDisplacementFromBottom?xBounds[0]<xBounds[1]:xBounds[0]>xBounds[1];ctx.font="bold "+fontSize+"px arial";var filtered=data.filter((function(d){return!groupFilter_1||groupFilter_1.includes(d.group)})),offset=calcSize(this.offsetFactor,this.offsetMin,this.offsetMax,xScale);this.callouts=this.positionCallouts(filtered,isLeftToRight,xScale,yScale,0,fontSize,offset)}this.callouts.forEach((function(callout){var pos=callout.pos,title=callout.title,color=callout.color,calloutBB={x:xScale(pos.x),y:yScale(pos.y),width:callout.boundingBox.width,height:fontSize,offsetX:callout.dx,offsetY:callout.dy};_this.renderCallout(title,callout.label,calloutBB,color,callout.alignment)}))}},CalloutCanvasLayer.prototype.renderText=function(title,x,y,fontSize,color,font,fontStyle){void 0===font&&(font="arial"),void 0===fontStyle&&(fontStyle="normal");var ctx=this.ctx;ctx.font=fontStyle+" "+fontSize+"px "+font,ctx.fillStyle=color,ctx.fillText(title,x,y)},CalloutCanvasLayer.prototype.renderPoint=function(x,y,radius){void 0===radius&&(radius=3);var ctx=this.ctx;ctx.beginPath(),ctx.moveTo(x,y),ctx.arc(x,y,radius,0,2*Math.PI),ctx.fill()},CalloutCanvasLayer.prototype.renderCallout=function(title,label,boundingBox,color,location){var pos=this.getPosition(boundingBox,location),x=pos.x,y=pos.y,height=boundingBox.height,width=boundingBox.width,dotX=boundingBox.x,dotY=boundingBox.y,placeLeft=location===Location_topright||location===Location_bottomright;this.renderAnnotation(title,label,x,y,height,color),this.renderPoint(dotX,dotY),this.renderLine(x,y,width,dotX,dotY,color,placeLeft)},CalloutCanvasLayer.prototype.getPosition=function(boundingBox,location){var x=boundingBox.x,y=boundingBox.y,offsetX=boundingBox.offsetX,offsetY=boundingBox.offsetY,width=boundingBox.width;switch(location){case Location_topleft:return{x:x-width-offsetX,y:y-offsetY};case Location_topright:return{x:x+offsetX,y:y-offsetY};case Location_bottomleft:return{x:x-width-offsetX,y:y+offsetY};case Location_bottomright:return{x:x+offsetX,y:y+offsetY};default:return{x:x,y:y}}},CalloutCanvasLayer.prototype.positionCallouts=function(annotations,isLeftToRight,xScale,yScale,scale,fontSize,offset){var _this=this;if(void 0===offset&&(offset=20),0===annotations.length)return[];var alignment=isLeftToRight?Location_topleft:Location_topright,nodes=annotations.map((function(a){var pos=a.pos?a.pos:_this.referenceSystem.project(a.md);return{title:a.title,label:a.label,color:a.color,pos:{x:pos[0],y:pos[1]},group:a.group,alignment:alignment,boundingBox:_this.getAnnotationBoundingBox(a.title,a.label,pos,xScale,yScale,fontSize),dx:offset,dy:offset}})),top=[nodes[nodes.length-1]],bottom=[];return this.chooseTopOrBottomPosition(nodes,bottom,top),this.adjustTopPositions(top),this.adjustBottomPositions(bottom),nodes},CalloutCanvasLayer.prototype.getAnnotationBoundingBox=function(title,label,pos,xScale,yScale,height){var ctx=this.ctx,ax1=xScale(pos[0]),ay1=yScale(pos[1]),labelWidth=ctx.measureText(label).width,titleWidth=ctx.measureText(title).width;return{x:ax1,y:ay1,width:Math.max(labelWidth,titleWidth),height:2*height+4}},CalloutCanvasLayer.prototype.chooseTopOrBottomPosition=function(nodes,bottom,top){for(var i=nodes.length-2;i>=0;--i){var node=nodes[i],prevNode=top[0];isOverlapping(node.boundingBox,prevNode.boundingBox)?(node.alignment=node.alignment===Location_topleft?Location_bottomright:Location_bottomleft,bottom.push(node),i>0&&top.unshift(nodes[--i])):top.unshift(node)}},CalloutCanvasLayer.prototype.adjustTopPositions=function(top){for(var i=top.length-2;i>=0;--i)for(var currentNode=top[i],j=top.length-1;j>i;--j){var prevNode=top[j],overlap=getOverlapOffset(currentNode.boundingBox,prevNode.boundingBox);overlap&&(currentNode.dy+=overlap.dy,currentNode.boundingBox.y-=overlap.dy)}},CalloutCanvasLayer.prototype.adjustBottomPositions=function(bottom){for(var i=bottom.length-2;i>=0;--i)for(var currentNode=bottom[i],j=bottom.length-1;j>i;--j){var overlap=getOverlapOffset(bottom[j].boundingBox,currentNode.boundingBox);overlap&&(currentNode.dy+=overlap.dy,currentNode.boundingBox.y+=overlap.dy)}},CalloutCanvasLayer}(CanvasLayer),ImageLayer=function(_super){function ImageLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(ImageLayer,_super),ImageLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event);var img=document.createElement("img");this.img=img,this.isLoading=!0},ImageLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.img.src=event.url,this.render(event)},ImageLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.setTransform(event),this.render(event)},ImageLayer.prototype.render=function(event){var _this=this,width=parseInt(this.elm.getAttribute("width"),10),height=parseInt(this.elm.getAttribute("height"),10),xScale=event.xScale,yScale=event.yScale,xRatio=event.xRatio,yRatio=event.yRatio,x=event.x,y=event.y,calcWidth=width*(xRatio||1),calcHeight=height*(yRatio||1);this.clearCanvas(),this.isLoading?this.img.onload=function(){_this.isLoading=!1,_this.ctx.drawImage(_this.img,xScale(x||0),yScale(y||0),calcWidth,calcHeight)}:this.ctx.drawImage(this.img,xScale(x||0),yScale(y||0),calcWidth,calcHeight)},ImageLayer}(CanvasLayer),WellboreBaseComponentLayer=function(_super){function WellboreBaseComponentLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.getMdPoint=function(md){return{point:_this.referenceSystem.project(md),md:md}},_this.getPathForPoints=function(start,end,interestPoints){var pathPoints=_this.referenceSystem.getCurtainPath(start,end),interestMdPoints=interestPoints.filter((function(ip){return!pathPoints.some((function(p){return p.md===ip}))})).map(_this.getMdPoint),points=merge([pathPoints,interestMdPoints]);return points.sort((function(a,b){return a.md-b.md})),points},_this.getZFactorScaledPathForPoints=function(start,end,interestPoints){var y=function(y){return y*_this.rescaleEvent.zFactor};return _this.getPathForPoints(start,end,interestPoints).map((function(p){return{point:[p.point[0],y(p.point[1])],md:p.md}}))},_this.drawBigPolygon=function(coords,color){void 0===color&&(color=0);var polygon=new Graphics;return polygon.beginFill(color),polygon.drawPolygon(coords),polygon.endFill(),_this.ctx.stage.addChild(polygon),polygon},_this.drawBigTexturedPolygon=function(coords,t){var polygon=new Graphics;return polygon.beginTextureFill({texture:t}),polygon.drawPolygon(coords),polygon.endFill(),_this.ctx.stage.addChild(polygon),polygon},_this.options=__assign(__assign(__assign({},_this.options),{exaggerationFactor:2}),options),_this.render=_this.render.bind(_this),_this}return __extends(WellboreBaseComponentLayer,_super),WellboreBaseComponentLayer.prototype.onUnmount=function(event){_super.prototype.onUnmount.call(this,event),this._textureCache=null,this.rescaleEvent=null},WellboreBaseComponentLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.clear(),this.render()},WellboreBaseComponentLayer.prototype.onRescale=function(event){var _a,shouldRender=(null===(_a=this.rescaleEvent)||void 0===_a?void 0:_a.zFactor)!==event.zFactor;if(this.rescaleEvent=event,_super.prototype.optionsRescale.call(this,event),this.ctx){var yRatio=this.yRatio(),flippedX=event.xBounds[0]>event.xBounds[1],flippedY=event.yBounds[0]>event.yBounds[1];this.ctx.stage.position.set(event.xScale(0),event.yScale(0)),this.ctx.stage.scale.set(event.xRatio*(flippedX?-1:1),yRatio*(flippedY?-1:1)),shouldRender&&(this.clear(),this.render())}},WellboreBaseComponentLayer.prototype.clear=function(){this.ctx.stage.removeChildren().forEach((function(child){child.destroy()}))},WellboreBaseComponentLayer.prototype.yRatio=function(){var domain=this.rescaleEvent.yScale.domain(),baseYSpan=(domain[1]-domain[0])*this.rescaleEvent.zFactor,baseDomain=[domain[0],domain[0]+baseYSpan];return Math.abs(this.rescaleEvent.height/(baseDomain[1]-baseDomain[0]))},WellboreBaseComponentLayer.prototype.drawRopeWithMask=function(path,maskPolygon,texture){if(0===maskPolygon.length||0===path.length)return null;var rope=new SimpleRope(texture,path,1),mask=new Graphics;mask.beginFill(0),mask.drawPolygon(maskPolygon),mask.endFill(),this.ctx.stage.addChild(mask),rope.mask=mask,this.ctx.stage.addChild(rope)},WellboreBaseComponentLayer.prototype.drawRope=function(path,texture,tint){if(0===path.length)return null;var rope=new SimpleRope(texture,path,1);rope.tint=tint||rope.tint,this.ctx.stage.addChild(rope)},WellboreBaseComponentLayer.prototype.drawOutline=function(leftPath,rightPath,lineColor,lineWidth,close){void 0===lineWidth&&(lineWidth=1),void 0===close&&(close=!1);var leftPathReverse=leftPath.map((function(d){return d.clone()})).reverse(),startPointRight=rightPath[0],startPointLeft=leftPathReverse[0],line=new Graphics;line.lineStyle(lineWidth,lineColor,void 0,1),line.moveTo(startPointRight.x,startPointRight.y),rightPath.forEach((function(p){return line.lineTo(p.x,p.y)})),close||line.moveTo(startPointLeft.x,startPointLeft.y),leftPathReverse.forEach((function(p){return line.lineTo(p.x,p.y)})),close&&line.lineTo(startPointRight.x,startPointRight.y),this.ctx.stage.addChild(line)},WellboreBaseComponentLayer}(PixiLayer),makeTubularPolygon=function(rightPath,leftPath){return __spreadArray(__spreadArray([],leftPath),rightPath.map((function(d){return d.clone()})).reverse())},overlaps=function(top1,bottom1,top2,bottom2){return top1<=bottom2&&top2<=bottom1},cementDiameterChangeDepths=function(cement,bottomOfCement,diameterIntervals){var arr,topOfCement=cement.toc,diameterChangeDepths=merge(diameterIntervals.map((function(d){return[d.start-1e-4,d.start,d.end,d.end+1e-4]}))).filter((function(d){return d>=topOfCement&&d<=bottomOfCement}));return diameterChangeDepths.push(topOfCement),diameterChangeDepths.push(bottomOfCement),(arr=diameterChangeDepths,Array.from(new Set(arr))).sort((function(a,b){return a-b}))},arrayToVector=function(a){return new Vector2(a[0],a[1])},createNormals=function(points){return points.length<2?[new Vector2(0)]:points.map((function(coord,i,list){if(i<list.length-1){var p=arrayToVector(list[i]),rotate=arrayToVector(list[i+1]).sub(p).rotate90();return n=rotate.normalized()}return n}));var n},offsetPoint=function(point,vector,offset){var v,p=arrayToVector(point);return v=p.add(vector.scale(offset)),new Point(v[0],v[1])},offsetPoints=function(points,vectors,offset){if(points.length!==vectors.length)throw new Error("Number of vectors does not match number of points");return points.map((function(point,index){var vector=vectors[index];return offsetPoint(point,vector,offset)}))},HoleSizeLayer=function(_super){function HoleSizeLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.drawHoleSize=function(holeObject){if(null!=holeObject){var _a=_this.options,exaggerationFactor=_a.exaggerationFactor,firstColor=_a.firstColor,lineColor=_a.lineColor,diameter=holeObject.diameter*exaggerationFactor,radius=diameter/2,pathPoints=_this.getZFactorScaledPathForPoints(holeObject.start,holeObject.end,[holeObject.start,holeObject.end]).map((function(p){return p.point})),normals=createNormals(pathPoints),rightPath=offsetPoints(pathPoints,normals,radius),leftPath=offsetPoints(pathPoints,normals,-radius);if(0!==pathPoints.length){if(_this.renderType()===RENDERER_TYPE.CANVAS){var polygonCoords=makeTubularPolygon(leftPath,rightPath);_this.drawBigPolygon(polygonCoords,convertColor(firstColor))}else{var texture=_this.createTexture(diameter);_this.drawRope(pathPoints.map((function(p){return new Point(p[0],p[1])})),texture)}_this.drawOutline(leftPath,rightPath,lineColor,1,!1)}}},_this.options=__assign(__assign(__assign({},_this.options),{firstColor:"rgb(140, 84, 29)",secondColor:"rgb(238, 227, 216)",lineColor:9127187}),options),_this}return __extends(HoleSizeLayer,_super),HoleSizeLayer.prototype.render=function(){var _this=this,data=this.data;data&&this.rescaleEvent&&this.referenceSystem&&(data.sort((function(a,b){return b.diameter-a.diameter})),this.maxDiameter=data.length>0?data[0].diameter:100,data.forEach((function(hole){return _this.drawHoleSize(hole)})))},HoleSizeLayer.prototype.createTexture=function(diameter){var exaggerationFactor=this.options.exaggerationFactor,height=this.maxDiameter*exaggerationFactor;this._textureCache||(this._textureCache=this.createBaseTexture(16,height));var baseTexture=this._textureCache.baseTexture,sidePadding=Math.floor((height-diameter)/2),frame=new Rectangle(0,sidePadding,16,diameter);return new Texture(baseTexture,frame)},HoleSizeLayer.prototype.createBaseTexture=function(width,height){var _a=this.options,firstColor=_a.firstColor,secondColor=_a.secondColor,canvas=document.createElement("canvas");canvas.width=width,canvas.height=height;var canvasCtx=canvas.getContext("2d");return canvasCtx.fillStyle=function(canvas,canvasCtx,firstColor,secondColor,startPctOffset){var gradient=canvasCtx.createLinearGradient(0,0,0,canvas.height);return gradient.addColorStop(0,firstColor),gradient.addColorStop(.5-startPctOffset,secondColor),gradient.addColorStop(.5+startPctOffset,secondColor),gradient.addColorStop(1,firstColor),gradient}(canvas,canvasCtx,firstColor,secondColor,0),canvasCtx.fillRect(0,0,canvas.width,canvas.height),Texture.from(canvas)},HoleSizeLayer}(WellboreBaseComponentLayer),CasingLayer=function(_super){function CasingLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.drawCasing=function(casing){if(null!=casing){var _a=_this.options,exaggerationFactor=_a.exaggerationFactor,lineColor=_a.lineColor,solidColor=_a.solidColor,diameter=casing.diameter*exaggerationFactor,radius=diameter/2,innerRadius=casing.innerDiameter*exaggerationFactor/2,pathPoints=_this.getZFactorScaledPathForPoints(casing.start,casing.end,[casing.start,casing.end]).map((function(p){return p.point})),normals=createNormals(pathPoints),rightPath=offsetPoints(pathPoints,normals,radius),leftPath=offsetPoints(pathPoints,normals,-radius),polygon=makeTubularPolygon(leftPath,rightPath),casingWallWidth=Math.abs(radius-innerRadius);if(_this.renderType()===RENDERER_TYPE.CANVAS)_this.drawBigPolygon(polygon,solidColor);else{var texture=_this.createTexture(diameter);_this.drawRope(pathPoints.map((function(p){return new Point(p[0],p[1])})),texture,solidColor)}_this.drawOutline(leftPath,rightPath,lineColor,casingWallWidth,!0),casing.hasShoe&&_this.drawShoe(casing.end,radius)}},_this.generateShoe=function(casingEnd,casingRadius,length,width){var start=casingEnd-length,end=casingEnd,points=_this.getZFactorScaledPathForPoints(start,end,[start,end]).map((function(p){return p.point})),normal=createNormals(points),shoeEdge=offsetPoints(points,normal,casingRadius*(width<0?-1:1)),shoeTipPoint=points[points.length-1],shoeTipNormal=normal[normal.length-1],shoeTip=offsetPoint(shoeTipPoint,shoeTipNormal,width);return __spreadArray(__spreadArray([],shoeEdge),[shoeTip])},_this.options=__assign(__assign(__assign({},_this.options),{solidColor:14474460,lineColor:5723991}),options),_this}return __extends(CasingLayer,_super),CasingLayer.prototype.render=function(){var _this=this,data=this.data;data&&this.rescaleEvent&&this.referenceSystem&&data.sort((function(a,b){return b.diameter-a.diameter})).forEach((function(casing){return _this.drawCasing(casing)}))},CasingLayer.prototype.drawShoe=function(casingEnd,casingRadius){var exaggerationFactor=this.options.exaggerationFactor,shoeWidth=25*exaggerationFactor,shoeLength=12*exaggerationFactor,shoeCoords=this.generateShoe(casingEnd,casingRadius,shoeLength,shoeWidth),shoeCoords2=this.generateShoe(casingEnd,casingRadius,shoeLength,-shoeWidth);this.drawBigPolygon(shoeCoords2),this.drawBigPolygon(shoeCoords)},CasingLayer.prototype.createTexture=function(diameter){return new Texture(Texture.WHITE.baseTexture,null,new Rectangle(0,0,16,diameter))},CasingLayer}(WellboreBaseComponentLayer),CementLayer=function(_super){function CementLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.createCementShape=function(cement,casings,holes){var exaggerationFactor=_this.options.exaggerationFactor,attachedCasings=__spreadArray([cement.casingId],cement.casingIds||[]).filter((function(id){return id})).map((function(casingId){return casings.find((function(casing){return casing.casingId===casingId}))}));if(0===attachedCasings.length||attachedCasings.includes(void 0))throw new Error("Invalid cement data, cement is missing attached casing");attachedCasings.sort((function(a,b){return a.end-b.end}));for(var bottomOfCement=attachedCasings[attachedCasings.length-1].end,_a=function(cement,bottomOfCement,parentCasings,casings,holes){var start=cement.toc,end=bottomOfCement;return{holes:holes.filter((function(h){return overlaps(start,end,h.start,h.end)})),outerCasings:casings.filter((function(c){return!parentCasings.includes(c)})).filter((function(c){return overlaps(start,end,c.start,c.end)}))}}(cement,bottomOfCement,attachedCasings,casings,holes),outerCasings=_a.outerCasings,overlappingHoles=_a.holes,innerDiameterIntervals=attachedCasings,outerDiameterIntervals=__spreadArray(__spreadArray([],outerCasings),overlappingHoles).map((function(d){return{start:d.start,end:d.end}})),diameterAtChangeDepths=cementDiameterChangeDepths(cement,bottomOfCement,__spreadArray(__spreadArray([],innerDiameterIntervals),outerDiameterIntervals)).map(function(innerCasing,nonAttachedCasings,holes){return function(depth){var outerDiameter,innerCasingAtDepth=innerCasing.find((function(casing){return casing.start<=depth&&casing.end>=depth})),innerDiameter=innerCasingAtDepth?innerCasingAtDepth.diameter:0,outerCasings=nonAttachedCasings.filter((function(casing){return casing.innerDiameter>innerDiameter})),holeAtDepth=holes.find((function(hole){return hole.start<=depth&&hole.end>=depth&&hole.diameter>innerDiameter})),outerCasingAtDepth=outerCasings.filter((function(d){return d})).sort((function(a,b){return a.innerDiameter-b.innerDiameter})).find((function(casing){return casing.start<=depth&&casing.end>=depth&&casing.diameter>innerDiameter}));return outerDiameter=outerCasingAtDepth?outerCasingAtDepth.innerDiameter:holeAtDepth?holeAtDepth.diameter-1:100,{md:depth,innerDiameter:innerDiameter,outerDiameter:outerDiameter}}}(attachedCasings,outerCasings,overlappingHoles)),path=_this.getZFactorScaledPathForPoints(cement.toc,bottomOfCement,diameterAtChangeDepths.map((function(d){return d.md}))),normals=createNormals(path.map((function(p){return p.point}))),pathWithNormals=path.map((function(p,i){return __assign(__assign({},p),{normal:normals[i]})})),side1Left=[],side1Right=[],side2Left=[],side2Right=[],previousDepth=diameterAtChangeDepths.shift(),_loop_1=function(depth){var intervalMdPoints=pathWithNormals.filter((function(x){return x.md>=previousDepth.md&&x.md<=depth.md})),intervalPoints=intervalMdPoints.map((function(s){return s.point})),intervalPointNormals=intervalMdPoints.map((function(s){return s.normal})),outerRadius=previousDepth.outerDiameter/2*exaggerationFactor,innerRadius=previousDepth.innerDiameter/2*exaggerationFactor,intervalSide1Left=offsetPoints(intervalPoints,intervalPointNormals,outerRadius),intervalSide1Right=offsetPoints(intervalPoints,intervalPointNormals,innerRadius),intervalSide2Left=offsetPoints(intervalPoints,intervalPointNormals,-innerRadius),intervalSide2Right=offsetPoints(intervalPoints,intervalPointNormals,-outerRadius);side1Left.push.apply(side1Left,intervalSide1Left),side1Right.push.apply(side1Right,intervalSide1Right),side2Left.push.apply(side2Left,intervalSide2Left),side2Right.push.apply(side2Right,intervalSide2Right),previousDepth=depth},_i=0,diameterAtChangeDepths_1=diameterAtChangeDepths;_i<diameterAtChangeDepths_1.length;_i++){_loop_1(diameterAtChangeDepths_1[_i])}var pathPoints=pathWithNormals.map((function(p){return new Point(p.point[0],p.point[1])}));return{leftPolygon:makeTubularPolygon(side1Left,side1Right),rightPolygon:makeTubularPolygon(side2Left,side2Right),path:pathPoints}},_this.options=__assign(__assign(__assign({},_this.options),{firstColor:"#c7b9ab",secondColor:"#5b5b5b"}),options),_this}return __extends(CementLayer,_super),CementLayer.prototype.render=function(){var _this=this;if(this.data&&this.rescaleEvent&&this.referenceSystem){var _a=this.data,cement=_a.cement,casings=_a.casings,holes=_a.holes,cementShapes=cement.map((function(cement){return _this.createCementShape(cement,casings,holes)})),texture=this.createTexture();cementShapes.forEach((function(cementShape){_this.renderType()===RENDERER_TYPE.CANVAS?(_this.drawBigTexturedPolygon(cementShape.leftPolygon,texture),_this.drawBigTexturedPolygon(cementShape.rightPolygon,texture)):(_this.drawRopeWithMask(cementShape.path,cementShape.leftPolygon,texture),_this.drawRopeWithMask(cementShape.path,cementShape.rightPolygon,texture))}))}},CementLayer.prototype.createTexture=function(){if(this._textureCache)return this._textureCache;var _a=this.options,firstColor=_a.firstColor,secondColor=_a.secondColor,canvas=document.createElement("canvas");canvas.width=150,canvas.height=150;var canvasCtx=canvas.getContext("2d");canvasCtx.fillStyle=firstColor,canvasCtx.fillRect(0,0,canvas.width,canvas.height),canvasCtx.lineWidth=1,canvasCtx.fillStyle=secondColor,canvasCtx.beginPath(),canvasCtx.lineWidth=1;for(var i=-canvas.width;i<canvas.width;i++)canvasCtx.moveTo(-canvas.width+10*i,-canvas.height),canvasCtx.lineTo(canvas.width+10*i,canvas.height);return canvasCtx.stroke(),this._textureCache=Texture.from(canvas),this._textureCache},CementLayer}(WellboreBaseComponentLayer),SeismicCanvasLayer=function(_super){function SeismicCanvasLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(SeismicCanvasLayer,_super),SeismicCanvasLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event)},SeismicCanvasLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.clearCanvas(),this.render()},SeismicCanvasLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.setTransform(event),this.render()},SeismicCanvasLayer.prototype.render=function(){if(this.data&&this.ctx&&this.data.image){var ctx=this.ctx,_a=this.data,options=_a.options,image=_a.image;this.clearCanvas(),ctx.drawImage(image,options.x,options.y,options.width,options.height)}},SeismicCanvasLayer}(CanvasLayer),CompletionLayer=function(_super){function CompletionLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.options=__assign(__assign({},_this.options),options),_this.render=_this.render.bind(_this),_this}return __extends(CompletionLayer,_super),CompletionLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.render()},CompletionLayer.prototype.render=function(){var _a,_this=this,wellborePath=this.referenceSystem?this.referenceSystem.projectedPath:[];null!=wellborePath&&((null===(_a=this.data)||void 0===_a?void 0:_a.length)>0?this.data.map((function(d){return _this.generateCompletionItem(wellborePath,d)})):[]).map((function(s){return _this.drawCompletionItem(s)}))},CompletionLayer.prototype.getShape=function(type){var graphics=new Graphics;return graphics.beginFill(3421236),graphics.drawRect(-5,-5,10,10),graphics.endFill(),graphics},CompletionLayer.prototype.getScale=function(type,length,width){return{scaleX:1,scaleY:1}},CompletionLayer.prototype.generateCompletionItem=function(wbp,data){if(this.referenceSystem){var pointTop=this.referenceSystem.project(data.start),pointBottom=this.referenceSystem.project(data.end),rotation=Vector2.angle(pointTop,pointBottom),graphics=this.getShape(data.shape),_a=this.getScale(data.shape,data.start-data.end,data.diameter),scaleX=_a.scaleX,scaleY=_a.scaleY,x=pointTop[0],y=pointTop[1];return graphics.setTransform(x,y,scaleX,scaleY,rotation),{graphics:graphics}}},CompletionLayer.prototype.drawCompletionItem=function(item){this.ctx.stage.addChild(item.graphics)},CompletionLayer}(PixiLayer),noop={value:function(){}};function dispatch(){for(var t,i=0,n=arguments.length,_={};i<n;++i){if(!(t=arguments[i]+"")||t in _||/[\s.]/.test(t))throw new Error("illegal type: "+t);_[t]=[]}return new Dispatch(_)}function Dispatch(_){this._=_}function parseTypenames$1(typenames,types){return typenames.trim().split(/^|\s+/).map((function(t){var name="",i=t.indexOf(".");if(i>=0&&(name=t.slice(i+1),t=t.slice(0,i)),t&&!types.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:name}}))}function get(type,name){for(var c,i=0,n=type.length;i<n;++i)if((c=type[i]).name===name)return c.value}function set(type,name,callback){for(var i=0,n=type.length;i<n;++i)if(type[i].name===name){type[i]=noop,type=type.slice(0,i).concat(type.slice(i+1));break}return null!=callback&&type.push({name:name,value:callback}),type}function noevent(){event.preventDefault(),event.stopImmediatePropagation()}function dragDisable(view){var root=view.document.documentElement,selection=select(view).on("dragstart.drag",noevent,!0);"onselectstart"in root?selection.on("selectstart.drag",noevent,!0):(root.__noselect=root.style.MozUserSelect,root.style.MozUserSelect="none")}function yesdrag(view,noclick){var root=view.document.documentElement,selection=select(view).on("dragstart.drag",null);noclick&&(selection.on("click.drag",noevent,!0),setTimeout((function(){selection.on("click.drag",null)}),0)),"onselectstart"in root?selection.on("selectstart.drag",null):(root.style.MozUserSelect=root.__noselect,delete root.__noselect)}Dispatch.prototype=dispatch.prototype={constructor:Dispatch,on:function(typename,callback){var t,_=this._,T=parseTypenames$1(typename+"",_),i=-1,n=T.length;if(!(arguments.length<2)){if(null!=callback&&"function"!=typeof callback)throw new Error("invalid callback: "+callback);for(;++i<n;)if(t=(typename=T[i]).type)_[t]=set(_[t],typename.name,callback);else if(null==callback)for(t in _)_[t]=set(_[t],typename.name,null);return this}for(;++i<n;)if((t=(typename=T[i]).type)&&(t=get(_[t],typename.name)))return t},copy:function(){var copy={},_=this._;for(var t in _)copy[t]=_[t].slice();return new Dispatch(copy)},call:function(type,that){if((n=arguments.length-2)>0)for(var n,t,args=new Array(n),i=0;i<n;++i)args[i]=arguments[i+2];if(!this._.hasOwnProperty(type))throw new Error("unknown type: "+type);for(i=0,n=(t=this._[type]).length;i<n;++i)t[i].value.apply(that,args)},apply:function(type,that,args){if(!this._.hasOwnProperty(type))throw new Error("unknown type: "+type);for(var t=this._[type],i=0,n=t.length;i<n;++i)t[i].value.apply(that,args)}};var rho=Math.SQRT2;function cosh(x){return((x=Math.exp(x))+1/x)/2}function interpolateZoom(p0,p1){var i,S,ux0=p0[0],uy0=p0[1],w0=p0[2],ux1=p1[0],uy1=p1[1],w1=p1[2],dx=ux1-ux0,dy=uy1-uy0,d2=dx*dx+dy*dy;if(d2<1e-12)S=Math.log(w1/w0)/rho,i=function(t){return[ux0+t*dx,uy0+t*dy,w0*Math.exp(rho*t*S)]};else{var d1=Math.sqrt(d2),b0=(w1*w1-w0*w0+4*d2)/(2*w0*2*d1),b1=(w1*w1-w0*w0-4*d2)/(2*w1*2*d1),r0=Math.log(Math.sqrt(b0*b0+1)-b0),r1=Math.log(Math.sqrt(b1*b1+1)-b1);S=(r1-r0)/rho,i=function(t){var s=t*S,coshr0=cosh(r0),u=w0/(2*d1)*(coshr0*function(x){return((x=Math.exp(2*x))-1)/(x+1)}(rho*s+r0)-function(x){return((x=Math.exp(x))-1/x)/2}(r0));return[ux0+u*dx,uy0+u*dy,w0*coshr0/cosh(rho*s+r0)]}}return i.duration=1e3*S,i}var taskHead,taskTail,frame=0,timeout=0,interval=0,clockLast=0,clockNow=0,clockSkew=0,clock="object"==typeof performance&&performance.now?performance:Date,setFrame="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(f){setTimeout(f,17)};function now(){return clockNow||(setFrame(clearNow),clockNow=clock.now()+clockSkew)}function clearNow(){clockNow=0}function Timer(){this._call=this._time=this._next=null}function timer(callback,delay,time){var t=new Timer;return t.restart(callback,delay,time),t}function wake(){clockNow=(clockLast=clock.now())+clockSkew,frame=timeout=0;try{!function(){now(),++frame;for(var e,t=taskHead;t;)(e=clockNow-t._time)>=0&&t._call.call(null,e),t=t._next;--frame}()}finally{frame=0,function(){var t0,t2,t1=taskHead,time=1/0;for(;t1;)t1._call?(time>t1._time&&(time=t1._time),t0=t1,t1=t1._next):(t2=t1._next,t1._next=null,t1=t0?t0._next=t2:taskHead=t2);taskTail=t0,sleep(time)}(),clockNow=0}}function poke(){var now=clock.now(),delay=now-clockLast;delay>1e3&&(clockSkew-=delay,clockLast=now)}function sleep(time){frame||(timeout&&(timeout=clearTimeout(timeout)),time-clockNow>24?(time<1/0&&(timeout=setTimeout(wake,time-clock.now()-clockSkew)),interval&&(interval=clearInterval(interval))):(interval||(clockLast=clock.now(),interval=setInterval(poke,1e3)),frame=1,setFrame(wake)))}function timeout$1(callback,delay,time){var t=new Timer;return delay=null==delay?0:+delay,t.restart((function(elapsed){t.stop(),callback(elapsed+delay)}),delay,time),t}Timer.prototype=timer.prototype={constructor:Timer,restart:function(callback,delay,time){if("function"!=typeof callback)throw new TypeError("callback is not a function");time=(null==time?now():+time)+(null==delay?0:+delay),this._next||taskTail===this||(taskTail?taskTail._next=this:taskHead=this,taskTail=this),this._call=callback,this._time=time,sleep()},stop:function(){this._call&&(this._call=null,this._time=1/0,sleep())}};var emptyOn=dispatch("start","end","cancel","interrupt"),emptyTween=[];function schedule(node,name,id,index,group,timing){var schedules=node.__transition;if(schedules){if(id in schedules)return}else node.__transition={};!function(node,id,self){var tween,schedules=node.__transition;function schedule(elapsed){self.state=1,self.timer.restart(start,self.delay,self.time),self.delay<=elapsed&&start(elapsed-self.delay)}function start(elapsed){var i,j,n,o;if(1!==self.state)return stop();for(i in schedules)if((o=schedules[i]).name===self.name){if(3===o.state)return timeout$1(start);4===o.state?(o.state=6,o.timer.stop(),o.on.call("interrupt",node,node.__data__,o.index,o.group),delete schedules[i]):+i<id&&(o.state=6,o.timer.stop(),o.on.call("cancel",node,node.__data__,o.index,o.group),delete schedules[i])}if(timeout$1((function(){3===self.state&&(self.state=4,self.timer.restart(tick,self.delay,self.time),tick(elapsed))})),self.state=2,self.on.call("start",node,node.__data__,self.index,self.group),2===self.state){for(self.state=3,tween=new Array(n=self.tween.length),i=0,j=-1;i<n;++i)(o=self.tween[i].value.call(node,node.__data__,self.index,self.group))&&(tween[++j]=o);tween.length=j+1}}function tick(elapsed){for(var t=elapsed<self.duration?self.ease.call(null,elapsed/self.duration):(self.timer.restart(stop),self.state=5,1),i=-1,n=tween.length;++i<n;)tween[i].call(node,t);5===self.state&&(self.on.call("end",node,node.__data__,self.index,self.group),stop())}function stop(){for(var i in self.state=6,self.timer.stop(),delete schedules[id],schedules)return;delete node.__transition}schedules[id]=self,self.timer=timer(schedule,0,self.time)}(node,id,{name:name,index:index,group:group,on:emptyOn,tween:emptyTween,time:timing.time,delay:timing.delay,duration:timing.duration,ease:timing.ease,timer:null,state:0})}function init$1(node,id){var schedule=get$1(node,id);if(schedule.state>0)throw new Error("too late; already scheduled");return schedule}function set$1(node,id){var schedule=get$1(node,id);if(schedule.state>3)throw new Error("too late; already running");return schedule}function get$1(node,id){var schedule=node.__transition;if(!schedule||!(schedule=schedule[id]))throw new Error("transition not found");return schedule}function interrupt(node,name){var schedule,active,i,schedules=node.__transition,empty=!0;if(schedules){for(i in name=null==name?null:name+"",schedules)(schedule=schedules[i]).name===name?(active=schedule.state>2&&schedule.state<5,schedule.state=6,schedule.timer.stop(),schedule.on.call(active?"interrupt":"cancel",node,node.__data__,schedule.index,schedule.group),delete schedules[i]):empty=!1;empty&&delete node.__transition}}function define$1(constructor,factory,prototype){constructor.prototype=factory.prototype=prototype,prototype.constructor=constructor}function extend$1(parent,definition){var prototype=Object.create(parent.prototype);for(var key in definition)prototype[key]=definition[key];return prototype}function Color$1(){}var brighter$1=1/.7,reI$1="\\s*([+-]?\\d+)\\s*",reN$1="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",reP$1="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",reHex$1=/^#([0-9a-f]{3,8})$/,reRgbInteger$1=new RegExp("^rgb\\("+[reI$1,reI$1,reI$1]+"\\)$"),reRgbPercent$1=new RegExp("^rgb\\("+[reP$1,reP$1,reP$1]+"\\)$"),reRgbaInteger$1=new RegExp("^rgba\\("+[reI$1,reI$1,reI$1,reN$1]+"\\)$"),reRgbaPercent$1=new RegExp("^rgba\\("+[reP$1,reP$1,reP$1,reN$1]+"\\)$"),reHslPercent$1=new RegExp("^hsl\\("+[reN$1,reP$1,reP$1]+"\\)$"),reHslaPercent$1=new RegExp("^hsla\\("+[reN$1,reP$1,reP$1,reN$1]+"\\)$"),named$1={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function color_formatHex$1(){return this.rgb().formatHex()}function color_formatRgb$1(){return this.rgb().formatRgb()}function color$1(format){var m,l;return format=(format+"").trim().toLowerCase(),(m=reHex$1.exec(format))?(l=m[1].length,m=parseInt(m[1],16),6===l?rgbn$1(m):3===l?new Rgb$1(m>>8&15|m>>4&240,m>>4&15|240&m,(15&m)<<4|15&m,1):8===l?rgba$1(m>>24&255,m>>16&255,m>>8&255,(255&m)/255):4===l?rgba$1(m>>12&15|m>>8&240,m>>8&15|m>>4&240,m>>4&15|240&m,((15&m)<<4|15&m)/255):null):(m=reRgbInteger$1.exec(format))?new Rgb$1(m[1],m[2],m[3],1):(m=reRgbPercent$1.exec(format))?new Rgb$1(255*m[1]/100,255*m[2]/100,255*m[3]/100,1):(m=reRgbaInteger$1.exec(format))?rgba$1(m[1],m[2],m[3],m[4]):(m=reRgbaPercent$1.exec(format))?rgba$1(255*m[1]/100,255*m[2]/100,255*m[3]/100,m[4]):(m=reHslPercent$1.exec(format))?hsla$1(m[1],m[2]/100,m[3]/100,1):(m=reHslaPercent$1.exec(format))?hsla$1(m[1],m[2]/100,m[3]/100,m[4]):named$1.hasOwnProperty(format)?rgbn$1(named$1[format]):"transparent"===format?new Rgb$1(NaN,NaN,NaN,0):null}function rgbn$1(n){return new Rgb$1(n>>16&255,n>>8&255,255&n,1)}function rgba$1(r,g,b,a){return a<=0&&(r=g=b=NaN),new Rgb$1(r,g,b,a)}function rgbConvert$1(o){return o instanceof Color$1||(o=color$1(o)),o?new Rgb$1((o=o.rgb()).r,o.g,o.b,o.opacity):new Rgb$1}function rgb$1(r,g,b,opacity){return 1===arguments.length?rgbConvert$1(r):new Rgb$1(r,g,b,null==opacity?1:opacity)}function Rgb$1(r,g,b,opacity){this.r=+r,this.g=+g,this.b=+b,this.opacity=+opacity}function rgb_formatHex$1(){return"#"+hex$1(this.r)+hex$1(this.g)+hex$1(this.b)}function rgb_formatRgb$1(){var a=this.opacity;return(1===(a=isNaN(a)?1:Math.max(0,Math.min(1,a)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===a?")":", "+a+")")}function hex$1(value){return((value=Math.max(0,Math.min(255,Math.round(value)||0)))<16?"0":"")+value.toString(16)}function hsla$1(h,s,l,a){return a<=0?h=s=l=NaN:l<=0||l>=1?h=s=NaN:s<=0&&(h=NaN),new Hsl$1(h,s,l,a)}function hslConvert$1(o){if(o instanceof Hsl$1)return new Hsl$1(o.h,o.s,o.l,o.opacity);if(o instanceof Color$1||(o=color$1(o)),!o)return new Hsl$1;if(o instanceof Hsl$1)return o;var r=(o=o.rgb()).r/255,g=o.g/255,b=o.b/255,min=Math.min(r,g,b),max=Math.max(r,g,b),h=NaN,s=max-min,l=(max+min)/2;return s?(h=r===max?(g-b)/s+6*(g<b):g===max?(b-r)/s+2:(r-g)/s+4,s/=l<.5?max+min:2-max-min,h*=60):s=l>0&&l<1?0:h,new Hsl$1(h,s,l,o.opacity)}function Hsl$1(h,s,l,opacity){this.h=+h,this.s=+s,this.l=+l,this.opacity=+opacity}function hsl2rgb$1(h,m1,m2){return 255*(h<60?m1+(m2-m1)*h/60:h<180?m2:h<240?m1+(m2-m1)*(240-h)/60:m1)}function constant$3(x){return function(){return x}}function gamma$1(y){return 1==(y=+y)?nogamma$1:function(a,b){return b-a?function(a,b,y){return a=Math.pow(a,y),b=Math.pow(b,y)-a,y=1/y,function(t){return Math.pow(a+t*b,y)}}(a,b,y):constant$3(isNaN(a)?b:a)}}function nogamma$1(a,b){var d=b-a;return d?function(a,d){return function(t){return a+t*d}}(a,d):constant$3(isNaN(a)?b:a)}define$1(Color$1,color$1,{copy:function(channels){return Object.assign(new this.constructor,this,channels)},displayable:function(){return this.rgb().displayable()},hex:color_formatHex$1,formatHex:color_formatHex$1,formatHsl:function(){return hslConvert$1(this).formatHsl()},formatRgb:color_formatRgb$1,toString:color_formatRgb$1}),define$1(Rgb$1,rgb$1,extend$1(Color$1,{brighter:function(k){return k=null==k?brighter$1:Math.pow(brighter$1,k),new Rgb$1(this.r*k,this.g*k,this.b*k,this.opacity)},darker:function(k){return k=null==k?.7:Math.pow(.7,k),new Rgb$1(this.r*k,this.g*k,this.b*k,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rgb_formatHex$1,formatHex:rgb_formatHex$1,formatRgb:rgb_formatRgb$1,toString:rgb_formatRgb$1})),define$1(Hsl$1,(function(h,s,l,opacity){return 1===arguments.length?hslConvert$1(h):new Hsl$1(h,s,l,null==opacity?1:opacity)}),extend$1(Color$1,{brighter:function(k){return k=null==k?brighter$1:Math.pow(brighter$1,k),new Hsl$1(this.h,this.s,this.l*k,this.opacity)},darker:function(k){return k=null==k?.7:Math.pow(.7,k),new Hsl$1(this.h,this.s,this.l*k,this.opacity)},rgb:function(){var h=this.h%360+360*(this.h<0),s=isNaN(h)||isNaN(this.s)?0:this.s,l=this.l,m2=l+(l<.5?l:1-l)*s,m1=2*l-m2;return new Rgb$1(hsl2rgb$1(h>=240?h-240:h+120,m1,m2),hsl2rgb$1(h,m1,m2),hsl2rgb$1(h<120?h+240:h-120,m1,m2),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var a=this.opacity;return(1===(a=isNaN(a)?1:Math.max(0,Math.min(1,a)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===a?")":", "+a+")")}}));var interpolateRgb$1=function rgbGamma(y){var color=gamma$1(y);function rgb(start,end){var r=color((start=rgb$1(start)).r,(end=rgb$1(end)).r),g=color(start.g,end.g),b=color(start.b,end.b),opacity=nogamma$1(start.opacity,end.opacity);return function(t){return start.r=r(t),start.g=g(t),start.b=b(t),start.opacity=opacity(t),start+""}}return rgb.gamma=rgbGamma,rgb}(1);function interpolateNumber$1(a,b){return a=+a,b=+b,function(t){return a*(1-t)+b*t}}var reA$1=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,reB$1=new RegExp(reA$1.source,"g");function interpolateString(a,b){var am,bm,bs,bi=reA$1.lastIndex=reB$1.lastIndex=0,i=-1,s=[],q=[];for(a+="",b+="";(am=reA$1.exec(a))&&(bm=reB$1.exec(b));)(bs=bm.index)>bi&&(bs=b.slice(bi,bs),s[i]?s[i]+=bs:s[++i]=bs),(am=am[0])===(bm=bm[0])?s[i]?s[i]+=bm:s[++i]=bm:(s[++i]=null,q.push({i:i,x:interpolateNumber$1(am,bm)})),bi=reB$1.lastIndex;return bi<b.length&&(bs=b.slice(bi),s[i]?s[i]+=bs:s[++i]=bs),s.length<2?q[0]?function(b){return function(t){return b(t)+""}}(q[0].x):function(b){return function(){return b}}(b):(b=q.length,function(t){for(var o,i=0;i<b;++i)s[(o=q[i]).i]=o.x(t);return s.join("")})}var cssNode,cssRoot,cssView,svgNode,degrees=180/Math.PI,identity$2={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function decompose(a,b,c,d,e,f){var scaleX,scaleY,skewX;return(scaleX=Math.sqrt(a*a+b*b))&&(a/=scaleX,b/=scaleX),(skewX=a*c+b*d)&&(c-=a*skewX,d-=b*skewX),(scaleY=Math.sqrt(c*c+d*d))&&(c/=scaleY,d/=scaleY,skewX/=scaleY),a*d<b*c&&(a=-a,b=-b,skewX=-skewX,scaleX=-scaleX),{translateX:e,translateY:f,rotate:Math.atan2(b,a)*degrees,skewX:Math.atan(skewX)*degrees,scaleX:scaleX,scaleY:scaleY}}function interpolateTransform(parse,pxComma,pxParen,degParen){function pop(s){return s.length?s.pop()+" ":""}return function(a,b){var s=[],q=[];return a=parse(a),b=parse(b),function(xa,ya,xb,yb,s,q){if(xa!==xb||ya!==yb){var i=s.push("translate(",null,pxComma,null,pxParen);q.push({i:i-4,x:interpolateNumber$1(xa,xb)},{i:i-2,x:interpolateNumber$1(ya,yb)})}else(xb||yb)&&s.push("translate("+xb+pxComma+yb+pxParen)}(a.translateX,a.translateY,b.translateX,b.translateY,s,q),function(a,b,s,q){a!==b?(a-b>180?b+=360:b-a>180&&(a+=360),q.push({i:s.push(pop(s)+"rotate(",null,degParen)-2,x:interpolateNumber$1(a,b)})):b&&s.push(pop(s)+"rotate("+b+degParen)}(a.rotate,b.rotate,s,q),function(a,b,s,q){a!==b?q.push({i:s.push(pop(s)+"skewX(",null,degParen)-2,x:interpolateNumber$1(a,b)}):b&&s.push(pop(s)+"skewX("+b+degParen)}(a.skewX,b.skewX,s,q),function(xa,ya,xb,yb,s,q){if(xa!==xb||ya!==yb){var i=s.push(pop(s)+"scale(",null,",",null,")");q.push({i:i-4,x:interpolateNumber$1(xa,xb)},{i:i-2,x:interpolateNumber$1(ya,yb)})}else 1===xb&&1===yb||s.push(pop(s)+"scale("+xb+","+yb+")")}(a.scaleX,a.scaleY,b.scaleX,b.scaleY,s,q),a=b=null,function(t){for(var o,i=-1,n=q.length;++i<n;)s[(o=q[i]).i]=o.x(t);return s.join("")}}}var interpolateTransformCss=interpolateTransform((function(value){return"none"===value?identity$2:(cssNode||(cssNode=document.createElement("DIV"),cssRoot=document.documentElement,cssView=document.defaultView),cssNode.style.transform=value,value=cssView.getComputedStyle(cssRoot.appendChild(cssNode),null).getPropertyValue("transform"),cssRoot.removeChild(cssNode),decompose(+(value=value.slice(7,-1).split(","))[0],+value[1],+value[2],+value[3],+value[4],+value[5]))}),"px, ","px)","deg)"),interpolateTransformSvg=interpolateTransform((function(value){return null==value?identity$2:(svgNode||(svgNode=document.createElementNS("http://www.w3.org/2000/svg","g")),svgNode.setAttribute("transform",value),(value=svgNode.transform.baseVal.consolidate())?decompose((value=value.matrix).a,value.b,value.c,value.d,value.e,value.f):identity$2)}),", ",")",")");function tweenRemove(id,name){var tween0,tween1;return function(){var schedule=set$1(this,id),tween=schedule.tween;if(tween!==tween0)for(var i=0,n=(tween1=tween0=tween).length;i<n;++i)if(tween1[i].name===name){(tween1=tween1.slice()).splice(i,1);break}schedule.tween=tween1}}function tweenFunction(id,name,value){var tween0,tween1;if("function"!=typeof value)throw new Error;return function(){var schedule=set$1(this,id),tween=schedule.tween;if(tween!==tween0){tween1=(tween0=tween).slice();for(var t={name:name,value:value},i=0,n=tween1.length;i<n;++i)if(tween1[i].name===name){tween1[i]=t;break}i===n&&tween1.push(t)}schedule.tween=tween1}}function tweenValue(transition,name,value){var id=transition._id;return transition.each((function(){var schedule=set$1(this,id);(schedule.value||(schedule.value={}))[name]=value.apply(this,arguments)})),function(node){return get$1(node,id).value[name]}}function interpolate$1(a,b){var c;return("number"==typeof b?interpolateNumber$1:b instanceof color$1?interpolateRgb$1:(c=color$1(b))?(b=c,interpolateRgb$1):interpolateString)(a,b)}function attrRemove$1(name){return function(){this.removeAttribute(name)}}function attrRemoveNS$1(fullname){return function(){this.removeAttributeNS(fullname.space,fullname.local)}}function attrConstant$1(name,interpolate,value1){var string00,interpolate0,string1=value1+"";return function(){var string0=this.getAttribute(name);return string0===string1?null:string0===string00?interpolate0:interpolate0=interpolate(string00=string0,value1)}}function attrConstantNS$1(fullname,interpolate,value1){var string00,interpolate0,string1=value1+"";return function(){var string0=this.getAttributeNS(fullname.space,fullname.local);return string0===string1?null:string0===string00?interpolate0:interpolate0=interpolate(string00=string0,value1)}}function attrFunction$1(name,interpolate,value){var string00,string10,interpolate0;return function(){var string0,string1,value1=value(this);if(null!=value1)return(string0=this.getAttribute(name))===(string1=value1+"")?null:string0===string00&&string1===string10?interpolate0:(string10=string1,interpolate0=interpolate(string00=string0,value1));this.removeAttribute(name)}}function attrFunctionNS$1(fullname,interpolate,value){var string00,string10,interpolate0;return function(){var string0,string1,value1=value(this);if(null!=value1)return(string0=this.getAttributeNS(fullname.space,fullname.local))===(string1=value1+"")?null:string0===string00&&string1===string10?interpolate0:(string10=string1,interpolate0=interpolate(string00=string0,value1));this.removeAttributeNS(fullname.space,fullname.local)}}function attrInterpolate(name,i){return function(t){this.setAttribute(name,i.call(this,t))}}function attrInterpolateNS(fullname,i){return function(t){this.setAttributeNS(fullname.space,fullname.local,i.call(this,t))}}function attrTweenNS(fullname,value){var t0,i0;function tween(){var i=value.apply(this,arguments);return i!==i0&&(t0=(i0=i)&&attrInterpolateNS(fullname,i)),t0}return tween._value=value,tween}function attrTween(name,value){var t0,i0;function tween(){var i=value.apply(this,arguments);return i!==i0&&(t0=(i0=i)&&attrInterpolate(name,i)),t0}return tween._value=value,tween}function delayFunction(id,value){return function(){init$1(this,id).delay=+value.apply(this,arguments)}}function delayConstant(id,value){return value=+value,function(){init$1(this,id).delay=value}}function durationFunction(id,value){return function(){set$1(this,id).duration=+value.apply(this,arguments)}}function durationConstant(id,value){return value=+value,function(){set$1(this,id).duration=value}}function easeConstant(id,value){if("function"!=typeof value)throw new Error;return function(){set$1(this,id).ease=value}}function onFunction(id,name,listener){var on0,on1,sit=function(name){return(name+"").trim().split(/^|\s+/).every((function(t){var i=t.indexOf(".");return i>=0&&(t=t.slice(0,i)),!t||"start"===t}))}(name)?init$1:set$1;return function(){var schedule=sit(this,id),on=schedule.on;on!==on0&&(on1=(on0=on).copy()).on(name,listener),schedule.on=on1}}var Selection$1=selection.prototype.constructor;function styleRemove$1(name){return function(){this.style.removeProperty(name)}}function styleInterpolate(name,i,priority){return function(t){this.style.setProperty(name,i.call(this,t),priority)}}function styleTween(name,value,priority){var t,i0;function tween(){var i=value.apply(this,arguments);return i!==i0&&(t=(i0=i)&&styleInterpolate(name,i,priority)),t}return tween._value=value,tween}function textInterpolate(i){return function(t){this.textContent=i.call(this,t)}}function textTween(value){var t0,i0;function tween(){var i=value.apply(this,arguments);return i!==i0&&(t0=(i0=i)&&textInterpolate(i)),t0}return tween._value=value,tween}var id=0;function Transition(groups,parents,name,id){this._groups=groups,this._parents=parents,this._name=name,this._id=id}function newId(){return++id}var selection_prototype=selection.prototype;Transition.prototype={constructor:Transition,select:function(select){var name=this._name,id=this._id;"function"!=typeof select&&(select=selector(select));for(var groups=this._groups,m=groups.length,subgroups=new Array(m),j=0;j<m;++j)for(var node,subnode,group=groups[j],n=group.length,subgroup=subgroups[j]=new Array(n),i=0;i<n;++i)(node=group[i])&&(subnode=select.call(node,node.__data__,i,group))&&("__data__"in node&&(subnode.__data__=node.__data__),subgroup[i]=subnode,schedule(subgroup[i],name,id,i,subgroup,get$1(node,id)));return new Transition(subgroups,this._parents,name,id)},selectAll:function(select){var name=this._name,id=this._id;"function"!=typeof select&&(select=selectorAll(select));for(var groups=this._groups,m=groups.length,subgroups=[],parents=[],j=0;j<m;++j)for(var node,group=groups[j],n=group.length,i=0;i<n;++i)if(node=group[i]){for(var child,children=select.call(node,node.__data__,i,group),inherit=get$1(node,id),k=0,l=children.length;k<l;++k)(child=children[k])&&schedule(child,name,id,k,children,inherit);subgroups.push(children),parents.push(node)}return new Transition(subgroups,parents,name,id)},filter:function(match){"function"!=typeof match&&(match=matcher(match));for(var groups=this._groups,m=groups.length,subgroups=new Array(m),j=0;j<m;++j)for(var node,group=groups[j],n=group.length,subgroup=subgroups[j]=[],i=0;i<n;++i)(node=group[i])&&match.call(node,node.__data__,i,group)&&subgroup.push(node);return new Transition(subgroups,this._parents,this._name,this._id)},merge:function(transition){if(transition._id!==this._id)throw new Error;for(var groups0=this._groups,groups1=transition._groups,m0=groups0.length,m1=groups1.length,m=Math.min(m0,m1),merges=new Array(m0),j=0;j<m;++j)for(var node,group0=groups0[j],group1=groups1[j],n=group0.length,merge=merges[j]=new Array(n),i=0;i<n;++i)(node=group0[i]||group1[i])&&(merge[i]=node);for(;j<m0;++j)merges[j]=groups0[j];return new Transition(merges,this._parents,this._name,this._id)},selection:function(){return new Selection$1(this._groups,this._parents)},transition:function(){for(var name=this._name,id0=this._id,id1=newId(),groups=this._groups,m=groups.length,j=0;j<m;++j)for(var node,group=groups[j],n=group.length,i=0;i<n;++i)if(node=group[i]){var inherit=get$1(node,id0);schedule(node,name,id1,i,group,{time:inherit.time+inherit.delay+inherit.duration,delay:0,duration:inherit.duration,ease:inherit.ease})}return new Transition(groups,this._parents,name,id1)},call:selection_prototype.call,nodes:selection_prototype.nodes,node:selection_prototype.node,size:selection_prototype.size,empty:selection_prototype.empty,each:selection_prototype.each,on:function(name,listener){var id=this._id;return arguments.length<2?get$1(this.node(),id).on.on(name):this.each(onFunction(id,name,listener))},attr:function(name,value){var fullname=namespace(name),i="transform"===fullname?interpolateTransformSvg:interpolate$1;return this.attrTween(name,"function"==typeof value?(fullname.local?attrFunctionNS$1:attrFunction$1)(fullname,i,tweenValue(this,"attr."+name,value)):null==value?(fullname.local?attrRemoveNS$1:attrRemove$1)(fullname):(fullname.local?attrConstantNS$1:attrConstant$1)(fullname,i,value))},attrTween:function(name,value){var key="attr."+name;if(arguments.length<2)return(key=this.tween(key))&&key._value;if(null==value)return this.tween(key,null);if("function"!=typeof value)throw new Error;var fullname=namespace(name);return this.tween(key,(fullname.local?attrTweenNS:attrTween)(fullname,value))},style:function(name,value,priority){var i="transform"==(name+="")?interpolateTransformCss:interpolate$1;return null==value?this.styleTween(name,function(name,interpolate){var string00,string10,interpolate0;return function(){var string0=styleValue(this,name),string1=(this.style.removeProperty(name),styleValue(this,name));return string0===string1?null:string0===string00&&string1===string10?interpolate0:interpolate0=interpolate(string00=string0,string10=string1)}}(name,i)).on("end.style."+name,styleRemove$1(name)):"function"==typeof value?this.styleTween(name,function(name,interpolate,value){var string00,string10,interpolate0;return function(){var string0=styleValue(this,name),value1=value(this),string1=value1+"";return null==value1&&(this.style.removeProperty(name),string1=value1=styleValue(this,name)),string0===string1?null:string0===string00&&string1===string10?interpolate0:(string10=string1,interpolate0=interpolate(string00=string0,value1))}}(name,i,tweenValue(this,"style."+name,value))).each(function(id,name){var on0,on1,listener0,remove,key="style."+name,event="end."+key;return function(){var schedule=set$1(this,id),on=schedule.on,listener=null==schedule.value[key]?remove||(remove=styleRemove$1(name)):void 0;on===on0&&listener0===listener||(on1=(on0=on).copy()).on(event,listener0=listener),schedule.on=on1}}(this._id,name)):this.styleTween(name,function(name,interpolate,value1){var string00,interpolate0,string1=value1+"";return function(){var string0=styleValue(this,name);return string0===string1?null:string0===string00?interpolate0:interpolate0=interpolate(string00=string0,value1)}}(name,i,value),priority).on("end.style."+name,null)},styleTween:function(name,value,priority){var key="style."+(name+="");if(arguments.length<2)return(key=this.tween(key))&&key._value;if(null==value)return this.tween(key,null);if("function"!=typeof value)throw new Error;return this.tween(key,styleTween(name,value,null==priority?"":priority))},text:function(value){return this.tween("text","function"==typeof value?function(value){return function(){var value1=value(this);this.textContent=null==value1?"":value1}}(tweenValue(this,"text",value)):function(value){return function(){this.textContent=value}}(null==value?"":value+""))},textTween:function(value){var key="text";if(arguments.length<1)return(key=this.tween(key))&&key._value;if(null==value)return this.tween(key,null);if("function"!=typeof value)throw new Error;return this.tween(key,textTween(value))},remove:function(){return this.on("end.remove",function(id){return function(){var parent=this.parentNode;for(var i in this.__transition)if(+i!==id)return;parent&&parent.removeChild(this)}}(this._id))},tween:function(name,value){var id=this._id;if(name+="",arguments.length<2){for(var t,tween=get$1(this.node(),id).tween,i=0,n=tween.length;i<n;++i)if((t=tween[i]).name===name)return t.value;return null}return this.each((null==value?tweenRemove:tweenFunction)(id,name,value))},delay:function(value){var id=this._id;return arguments.length?this.each(("function"==typeof value?delayFunction:delayConstant)(id,value)):get$1(this.node(),id).delay},duration:function(value){var id=this._id;return arguments.length?this.each(("function"==typeof value?durationFunction:durationConstant)(id,value)):get$1(this.node(),id).duration},ease:function(value){var id=this._id;return arguments.length?this.each(easeConstant(id,value)):get$1(this.node(),id).ease},end:function(){var on0,on1,that=this,id=that._id,size=that.size();return new Promise((function(resolve,reject){var cancel={value:reject},end={value:function(){0==--size&&resolve()}};that.each((function(){var schedule=set$1(this,id),on=schedule.on;on!==on0&&((on1=(on0=on).copy())._.cancel.push(cancel),on1._.interrupt.push(cancel),on1._.end.push(end)),schedule.on=on1}))}))}};var defaultTiming={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function inherit(node,id){for(var timing;!(timing=node.__transition)||!(timing=timing[id]);)if(!(node=node.parentNode))return defaultTiming.time=now(),defaultTiming;return timing}function constant$4(x){return function(){return x}}function ZoomEvent(target,type,transform){this.target=target,this.type=type,this.transform=transform}function Transform$1(k,x,y){this.k=k,this.x=x,this.y=y}selection.prototype.interrupt=function(name){return this.each((function(){interrupt(this,name)}))},selection.prototype.transition=function(name){var id,timing;name instanceof Transition?(id=name._id,name=name._name):(id=newId(),(timing=defaultTiming).time=now(),name=null==name?null:name+"");for(var groups=this._groups,m=groups.length,j=0;j<m;++j)for(var node,group=groups[j],n=group.length,i=0;i<n;++i)(node=group[i])&&schedule(node,name,id,i,group,timing||inherit(node,id));return new Transition(groups,this._parents,name,id)},Transform$1.prototype={constructor:Transform$1,scale:function(k){return 1===k?this:new Transform$1(this.k*k,this.x,this.y)},translate:function(x,y){return 0===x&0===y?this:new Transform$1(this.k,this.x+this.k*x,this.y+this.k*y)},apply:function(point){return[point[0]*this.k+this.x,point[1]*this.k+this.y]},applyX:function(x){return x*this.k+this.x},applyY:function(y){return y*this.k+this.y},invert:function(location){return[(location[0]-this.x)/this.k,(location[1]-this.y)/this.k]},invertX:function(x){return(x-this.x)/this.k},invertY:function(y){return(y-this.y)/this.k},rescaleX:function(x){return x.copy().domain(x.range().map(this.invertX,this).map(x.invert,x))},rescaleY:function(y){return y.copy().domain(y.range().map(this.invertY,this).map(y.invert,y))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var identity$3=new Transform$1(1,0,0);function nopropagation(){event.stopImmediatePropagation()}function noevent$1(){event.preventDefault(),event.stopImmediatePropagation()}function defaultFilter$1(){return!event.ctrlKey&&!event.button}function defaultExtent(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function defaultTransform(){return this.__zoom||identity$3}function defaultWheelDelta(){return-event.deltaY*(1===event.deltaMode?.05:event.deltaMode?1:.002)}function defaultTouchable(){return navigator.maxTouchPoints||"ontouchstart"in this}function defaultConstrain(transform,extent,translateExtent){var dx0=transform.invertX(extent[0][0])-translateExtent[0][0],dx1=transform.invertX(extent[1][0])-translateExtent[1][0],dy0=transform.invertY(extent[0][1])-translateExtent[0][1],dy1=transform.invertY(extent[1][1])-translateExtent[1][1];return transform.translate(dx1>dx0?(dx0+dx1)/2:Math.min(0,dx0)||Math.max(0,dx1),dy1>dy0?(dy0+dy1)/2:Math.min(0,dy0)||Math.max(0,dy1))}function zoom(){var touchstarting,touchending,filter=defaultFilter$1,extent=defaultExtent,constrain=defaultConstrain,wheelDelta=defaultWheelDelta,touchable=defaultTouchable,scaleExtent=[0,1/0],translateExtent=[[-1/0,-1/0],[1/0,1/0]],duration=250,interpolate=interpolateZoom,listeners=dispatch("start","zoom","end"),clickDistance2=0;function zoom(selection){selection.property("__zoom",defaultTransform).on("wheel.zoom",wheeled).on("mousedown.zoom",mousedowned).on("dblclick.zoom",dblclicked).filter(touchable).on("touchstart.zoom",touchstarted).on("touchmove.zoom",touchmoved).on("touchend.zoom touchcancel.zoom",touchended).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function scale(transform,k){return(k=Math.max(scaleExtent[0],Math.min(scaleExtent[1],k)))===transform.k?transform:new Transform$1(k,transform.x,transform.y)}function translate(transform,p0,p1){var x=p0[0]-p1[0]*transform.k,y=p0[1]-p1[1]*transform.k;return x===transform.x&&y===transform.y?transform:new Transform$1(transform.k,x,y)}function centroid(extent){return[(+extent[0][0]+ +extent[1][0])/2,(+extent[0][1]+ +extent[1][1])/2]}function schedule(transition,transform,point){transition.on("start.zoom",(function(){gesture(this,arguments).start()})).on("interrupt.zoom end.zoom",(function(){gesture(this,arguments).end()})).tween("zoom",(function(){var that=this,args=arguments,g=gesture(that,args),e=extent.apply(that,args),p=null==point?centroid(e):"function"==typeof point?point.apply(that,args):point,w=Math.max(e[1][0]-e[0][0],e[1][1]-e[0][1]),a=that.__zoom,b="function"==typeof transform?transform.apply(that,args):transform,i=interpolate(a.invert(p).concat(w/a.k),b.invert(p).concat(w/b.k));return function(t){if(1===t)t=b;else{var l=i(t),k=w/l[2];t=new Transform$1(k,p[0]-l[0]*k,p[1]-l[1]*k)}g.zoom(null,t)}}))}function gesture(that,args,clean){return!clean&&that.__zooming||new Gesture(that,args)}function Gesture(that,args){this.that=that,this.args=args,this.active=0,this.extent=extent.apply(that,args),this.taps=0}function wheeled(){if(filter.apply(this,arguments)){var g=gesture(this,arguments),t=this.__zoom,k=Math.max(scaleExtent[0],Math.min(scaleExtent[1],t.k*Math.pow(2,wheelDelta.apply(this,arguments)))),p=mouse(this);if(g.wheel)g.mouse[0][0]===p[0]&&g.mouse[0][1]===p[1]||(g.mouse[1]=t.invert(g.mouse[0]=p)),clearTimeout(g.wheel);else{if(t.k===k)return;g.mouse=[p,t.invert(p)],interrupt(this),g.start()}noevent$1(),g.wheel=setTimeout(wheelidled,150),g.zoom("mouse",constrain(translate(scale(t,k),g.mouse[0],g.mouse[1]),g.extent,translateExtent))}function wheelidled(){g.wheel=null,g.end()}}function mousedowned(){if(!touchending&&filter.apply(this,arguments)){var g=gesture(this,arguments,!0),v=select(event.view).on("mousemove.zoom",mousemoved,!0).on("mouseup.zoom",mouseupped,!0),p=mouse(this),x0=event.clientX,y0=event.clientY;dragDisable(event.view),nopropagation(),g.mouse=[p,this.__zoom.invert(p)],interrupt(this),g.start()}function mousemoved(){if(noevent$1(),!g.moved){var dx=event.clientX-x0,dy=event.clientY-y0;g.moved=dx*dx+dy*dy>clickDistance2}g.zoom("mouse",constrain(translate(g.that.__zoom,g.mouse[0]=mouse(g.that),g.mouse[1]),g.extent,translateExtent))}function mouseupped(){v.on("mousemove.zoom mouseup.zoom",null),yesdrag(event.view,g.moved),noevent$1(),g.end()}}function dblclicked(){if(filter.apply(this,arguments)){var t0=this.__zoom,p0=mouse(this),p1=t0.invert(p0),k1=t0.k*(event.shiftKey?.5:2),t1=constrain(translate(scale(t0,k1),p0,p1),extent.apply(this,arguments),translateExtent);noevent$1(),duration>0?select(this).transition().duration(duration).call(schedule,t1,p0):select(this).call(zoom.transform,t1)}}function touchstarted(){if(filter.apply(this,arguments)){var started,i,t,p,touches=event.touches,n=touches.length,g=gesture(this,arguments,event.changedTouches.length===n);for(nopropagation(),i=0;i<n;++i)p=[p=touch(this,touches,(t=touches[i]).identifier),this.__zoom.invert(p),t.identifier],g.touch0?g.touch1||g.touch0[2]===p[2]||(g.touch1=p,g.taps=0):(g.touch0=p,started=!0,g.taps=1+!!touchstarting);touchstarting&&(touchstarting=clearTimeout(touchstarting)),started&&(g.taps<2&&(touchstarting=setTimeout((function(){touchstarting=null}),500)),interrupt(this),g.start())}}function touchmoved(){if(this.__zooming){var i,t,p,l,g=gesture(this,arguments),touches=event.changedTouches,n=touches.length;for(noevent$1(),touchstarting&&(touchstarting=clearTimeout(touchstarting)),g.taps=0,i=0;i<n;++i)p=touch(this,touches,(t=touches[i]).identifier),g.touch0&&g.touch0[2]===t.identifier?g.touch0[0]=p:g.touch1&&g.touch1[2]===t.identifier&&(g.touch1[0]=p);if(t=g.that.__zoom,g.touch1){var p0=g.touch0[0],l0=g.touch0[1],p1=g.touch1[0],l1=g.touch1[1],dp=(dp=p1[0]-p0[0])*dp+(dp=p1[1]-p0[1])*dp,dl=(dl=l1[0]-l0[0])*dl+(dl=l1[1]-l0[1])*dl;t=scale(t,Math.sqrt(dp/dl)),p=[(p0[0]+p1[0])/2,(p0[1]+p1[1])/2],l=[(l0[0]+l1[0])/2,(l0[1]+l1[1])/2]}else{if(!g.touch0)return;p=g.touch0[0],l=g.touch0[1]}g.zoom("touch",constrain(translate(t,p,l),g.extent,translateExtent))}}function touchended(){if(this.__zooming){var i,t,g=gesture(this,arguments),touches=event.changedTouches,n=touches.length;for(nopropagation(),touchending&&clearTimeout(touchending),touchending=setTimeout((function(){touchending=null}),500),i=0;i<n;++i)t=touches[i],g.touch0&&g.touch0[2]===t.identifier?delete g.touch0:g.touch1&&g.touch1[2]===t.identifier&&delete g.touch1;if(g.touch1&&!g.touch0&&(g.touch0=g.touch1,delete g.touch1),g.touch0)g.touch0[1]=this.__zoom.invert(g.touch0[0]);else if(g.end(),2===g.taps){var p=select(this).on("dblclick.zoom");p&&p.apply(this,arguments)}}}return zoom.transform=function(collection,transform,point){var selection=collection.selection?collection.selection():collection;selection.property("__zoom",defaultTransform),collection!==selection?schedule(collection,transform,point):selection.interrupt().each((function(){gesture(this,arguments).start().zoom(null,"function"==typeof transform?transform.apply(this,arguments):transform).end()}))},zoom.scaleBy=function(selection,k,p){zoom.scaleTo(selection,(function(){var k0=this.__zoom.k,k1="function"==typeof k?k.apply(this,arguments):k;return k0*k1}),p)},zoom.scaleTo=function(selection,k,p){zoom.transform(selection,(function(){var e=extent.apply(this,arguments),t0=this.__zoom,p0=null==p?centroid(e):"function"==typeof p?p.apply(this,arguments):p,p1=t0.invert(p0),k1="function"==typeof k?k.apply(this,arguments):k;return constrain(translate(scale(t0,k1),p0,p1),e,translateExtent)}),p)},zoom.translateBy=function(selection,x,y){zoom.transform(selection,(function(){return constrain(this.__zoom.translate("function"==typeof x?x.apply(this,arguments):x,"function"==typeof y?y.apply(this,arguments):y),extent.apply(this,arguments),translateExtent)}))},zoom.translateTo=function(selection,x,y,p){zoom.transform(selection,(function(){var e=extent.apply(this,arguments),t=this.__zoom,p0=null==p?centroid(e):"function"==typeof p?p.apply(this,arguments):p;return constrain(identity$3.translate(p0[0],p0[1]).scale(t.k).translate("function"==typeof x?-x.apply(this,arguments):-x,"function"==typeof y?-y.apply(this,arguments):-y),e,translateExtent)}),p)},Gesture.prototype={start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(key,transform){return this.mouse&&"mouse"!==key&&(this.mouse[1]=transform.invert(this.mouse[0])),this.touch0&&"touch"!==key&&(this.touch0[1]=transform.invert(this.touch0[0])),this.touch1&&"touch"!==key&&(this.touch1[1]=transform.invert(this.touch1[0])),this.that.__zoom=transform,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(type){!function(event1,listener,that,args){var event0=event;event1.sourceEvent=event,event=event1;try{listener.apply(that,args)}finally{event=event0}}(new ZoomEvent(zoom,type,this.that.__zoom),listeners.apply,listeners,[type,this.that,this.args])}},zoom.wheelDelta=function(_){return arguments.length?(wheelDelta="function"==typeof _?_:constant$4(+_),zoom):wheelDelta},zoom.filter=function(_){return arguments.length?(filter="function"==typeof _?_:constant$4(!!_),zoom):filter},zoom.touchable=function(_){return arguments.length?(touchable="function"==typeof _?_:constant$4(!!_),zoom):touchable},zoom.extent=function(_){return arguments.length?(extent="function"==typeof _?_:constant$4([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),zoom):extent},zoom.scaleExtent=function(_){return arguments.length?(scaleExtent[0]=+_[0],scaleExtent[1]=+_[1],zoom):[scaleExtent[0],scaleExtent[1]]},zoom.translateExtent=function(_){return arguments.length?(translateExtent[0][0]=+_[0][0],translateExtent[1][0]=+_[1][0],translateExtent[0][1]=+_[0][1],translateExtent[1][1]=+_[1][1],zoom):[[translateExtent[0][0],translateExtent[0][1]],[translateExtent[1][0],translateExtent[1][1]]]},zoom.constrain=function(_){return arguments.length?(constrain=_,zoom):constrain},zoom.duration=function(_){return arguments.length?(duration=+_,zoom):duration},zoom.interpolate=function(_){return arguments.length?(interpolate=_,zoom):interpolate},zoom.on=function(){var value=listeners.on.apply(listeners,arguments);return value===listeners?zoom:value},zoom.clickDistance=function(_){return arguments.length?(clickDistance2=(_=+_)*_,zoom):Math.sqrt(clickDistance2)},zoom}var ZoomPanHandler=function(){function ZoomPanHandler(elm,onRescale,options){void 0===options&&(options={maxZoomLevel:256,minZoomLevel:.1}),this.zoom=null,this.elm=null,this.container=null,this.onRescale=null,this.options=null,this.xBounds=[0,1],this.yBounds=[0,1],this.translateBoundsX=[0,1],this.translateBoundsY=[0,1],this.scaleX=null,this.scaleY=null,this._zFactor=1,this.onZoom=this.onZoom.bind(this),this.container=select(elm),this.options=options,this.onRescale=onRescale,this.onZoom=this.onZoom.bind(this),this.calculateTransform=this.calculateTransform.bind(this),this.applyTransform=this.applyTransform.bind(this),this.recalculateZoomTransform=this.recalculateZoomTransform.bind(this),this.rescale=this.rescale.bind(this),this.adjustToSize=this.adjustToSize.bind(this),this.setViewport=this.setViewport.bind(this),this.currentStateAsEvent=this.currentStateAsEvent.bind(this),this.updateTranslateExtent=this.updateTranslateExtent.bind(this),this.scaleX=linear$1().domain(this.xBounds).range([0,1]),this.scaleY=linear$1().domain(this.yBounds).range([0,1]),this.init()}return Object.defineProperty(ZoomPanHandler.prototype,"width",{get:function(){return this.scaleX.range()[1]},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"height",{get:function(){return this.scaleY.range()[1]},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"xSpan",{get:function(){var xBounds=this.xBounds;return Math.abs(xBounds[1]-xBounds[0])},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"ySpan",{get:function(){var yBounds=this.yBounds;return Math.abs(yBounds[1]-yBounds[0])},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"viewportRatio",{get:function(){return this.width/(this.height||1)},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"xRatio",{get:function(){var domain=this.scaleX.domain();return Math.abs(this.width/(domain[1]-domain[0]))},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"yRatio",{get:function(){var domain=this.scaleY.domain();return Math.abs(this.height/(domain[1]-domain[0]))},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"zFactor",{get:function(){return this._zFactor},set:function(factor){this._zFactor=factor,this.recalculateZoomTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"isXInverted",{get:function(){return this.xBounds[1]<this.xBounds[0]},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"isYInverted",{get:function(){return this.yBounds[1]<this.yBounds[0]},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"enableTranslateExtent",{get:function(){return this._enableTranslateExtent},set:function(enabled){this._enableTranslateExtent=enabled,this.updateTranslateExtent()},enumerable:!1,configurable:!0}),ZoomPanHandler.prototype.updateTranslateExtent=function(){var _a=this,width=_a.width,xSpan=_a.xSpan;_a.ySpan;var zFactor=_a.zFactor,enableTranslateExtent=_a.enableTranslateExtent,translateBoundsX=_a.translateBoundsX,translateBoundsY=_a.translateBoundsY,x1=-1/0,y1=-1/0,x2=1/0,y2=1/0;if(enableTranslateExtent){var ppu=width/xSpan;x1=translateBoundsX[0]*ppu,x2=translateBoundsX[1]*ppu,y1=translateBoundsY[0]*ppu*zFactor,y2=translateBoundsY[1]*ppu*zFactor}this.zoom.translateExtent([[x1,y1],[x2,y2]])},ZoomPanHandler.prototype.currentStateAsEvent=function(){var _a=this,scaleX=_a.scaleX,scaleY=_a.scaleY,xBounds=_a.xBounds,yBounds=_a.yBounds,zFactor=_a.zFactor,viewportRatio=_a.viewportRatio,currentTransform=_a.currentTransform,xRatio=_a.xRatio,yRatio=_a.yRatio,width=_a.width,height=_a.height;return{xScale:scaleX.copy(),yScale:scaleY.copy(),xBounds:xBounds,yBounds:yBounds,zFactor:zFactor,viewportRatio:viewportRatio,xRatio:xRatio,yRatio:yRatio,width:width,height:height,transform:__assign({},currentTransform)}},ZoomPanHandler.prototype.rescale=function(){var currentStateAsEvent=this.currentStateAsEvent;this.onRescale(currentStateAsEvent())},ZoomPanHandler.prototype.init=function(){this.zoom=zoom().scaleExtent([this.options.minZoomLevel,this.options.maxZoomLevel]).on("zoom",this.onZoom),this.container.call(this.zoom)},ZoomPanHandler.prototype.onZoom=function(){var transform=event.transform;transform&&(this.applyTransform(transform),this.rescale())},ZoomPanHandler.prototype.applyTransform=function(transform){var _a=this,width=_a.width,scaleX=_a.scaleX,scaleY=_a.scaleY,xSpan=_a.xSpan;_a.ySpan;var xBounds=_a.xBounds,yBounds=_a.yBounds,zFactor=_a.zFactor,ratio=this.viewportRatio,isXInverted=this.isXInverted,isYInverted=this.isYInverted,unitsPerPixels=xSpan/(width*transform.k),newXSpan=xSpan/transform.k,newYSpan=newXSpan/zFactor/ratio,shiftx=unitsPerPixels*transform.x,shifty=unitsPerPixels/zFactor*transform.y,dx0=xBounds[0]-(isXInverted?-shiftx:shiftx),dy0=yBounds[0]-(isYInverted?-shifty:shifty);scaleX.domain([dx0,dx0+(isXInverted?-newXSpan:newXSpan)]),scaleY.domain([dy0,dy0+(isYInverted?-newYSpan:newYSpan)]),this.currentTransform=transform},ZoomPanHandler.prototype.setViewport=function(cx,cy,displ,duration){void 0===cx&&(cx=null),void 0===cy&&(cy=null),void 0===displ&&(displ=null),void 0===duration&&(duration=null);var _a=this,zoom=_a.zoom,container=_a.container,calculateTransform=_a.calculateTransform;_a.viewportRatio;var scaleX=_a.scaleX,scaleY=_a.scaleY,isXInverted=_a.isXInverted;if(null===cx||null===displ){var xd=scaleX.domain(),dspan=xd[1]-xd[0];null===cx&&(cx=xd[0]+dspan/2||0),null===displ&&(displ=Math.abs(dspan)||1)}if(null===cy){var yd=scaleY.domain();cy=yd[0]+(yd[1]-yd[0])/2||0}var xdispl=isXInverted?-displ:displ,dx0=cx-xdispl/2,t=calculateTransform(dx0,dx0+xdispl,cy);Number.isFinite(duration)&&duration>0?zoom.transform(container.transition().duration(duration),t):zoom.transform(container,t)},ZoomPanHandler.prototype.setBounds=function(xBounds,yBounds){this.xBounds=xBounds,this.yBounds=yBounds,this.recalculateZoomTransform()},ZoomPanHandler.prototype.setTranslateBounds=function(xBounds,yBounds){this.translateBoundsX=xBounds,this.translateBoundsY=yBounds,this.updateTranslateExtent()},ZoomPanHandler.prototype.adjustToSize=function(width,height,force){void 0===force&&(force=!1);var _a=this,oldWidth=_a.width,oldHeight=_a.height,scaleX=_a.scaleX,scaleY=_a.scaleY,recalculateZoomTransform=_a.recalculateZoomTransform,w=0,h=0;if(void 0===width||"boolean"==typeof width){var _b=this.container.node().getBoundingClientRect();w=_b.containerWidth,h=_b.containerHeight}else w=width,h=height;var newWidth=Math.max(1,w),newHeight=Math.max(1,h);(force||oldWidth!==newWidth||oldHeight!==newHeight)&&(scaleX.range([0,newWidth]),scaleY.range([0,newHeight]),recalculateZoomTransform(),this.onRescale(this.currentStateAsEvent()))},ZoomPanHandler.prototype.calculateTransform=function(dx0,dx1,dy){var _a=this,scaleX=_a.scaleX,xSpan=_a.xSpan,xBounds=_a.xBounds,yBounds=_a.yBounds,zFactor=_a.zFactor,ratio=_a.viewportRatio,isXInverted=_a.isXInverted,isYInverted=_a.isYInverted,_b=scaleX.range(),rx1=_b[0],rx2=_b[1],displ=Math.abs(dx1-dx0),k=xSpan/displ,unitsPerPixels=displ/(rx2-rx1),dy0=dy-(isYInverted?-displ:displ)/zFactor/ratio/2,tx=(xBounds[0]-dx0)/(isXInverted?-unitsPerPixels:unitsPerPixels),ty=(yBounds[0]-dy0)/((isYInverted?-unitsPerPixels:unitsPerPixels)/zFactor);return identity$3.translate(tx,ty).scale(k)},ZoomPanHandler.prototype.recalculateZoomTransform=function(){var _a=this,scaleX=_a.scaleX,scaleY=_a.scaleY,container=_a.container,calculateTransform=_a.calculateTransform,updateTranslateExtent=_a.updateTranslateExtent,_b=scaleX.domain(),dx0=_b[0],dx1=_b[1],_c=scaleY.domain(),dy0=_c[0],transform=calculateTransform(dx0,dx1,dy0+(_c[1]-dy0)/2);updateTranslateExtent(),this.zoom.transform(container,transform)},ZoomPanHandler.prototype.setZoomLevelBoundary=function(zoomlevels){return this.zoom.scaleExtent(zoomlevels),this},ZoomPanHandler.prototype.setMaxZoomLevel=function(zoomlevel){var zoomLevels=this.zoom.scaleExtent();return this.zoom.scaleExtent([zoomLevels[0],zoomlevel]),this},ZoomPanHandler.prototype.setMinZoomLevel=function(zoomlevel){var zoomLevels=this.zoom.scaleExtent();return this.zoom.scaleExtent([zoomlevel,zoomLevels[1]]),this},ZoomPanHandler}(),slice=Array.prototype.slice;function identity$4(x){return x}function translateX(x){return"translate("+(x+.5)+",0)"}function translateY(y){return"translate(0,"+(y+.5)+")"}function number$2(scale){return function(d){return+scale(d)}}function center(scale){var offset=Math.max(0,scale.bandwidth()-1)/2;return scale.round()&&(offset=Math.round(offset)),function(d){return+scale(d)+offset}}function entering(){return!this.__axis}function axis(orient,scale){var tickArguments=[],tickValues=null,tickFormat=null,tickSizeInner=6,tickSizeOuter=6,tickPadding=3,k=1===orient||4===orient?-1:1,x=4===orient||2===orient?"x":"y",transform=1===orient||3===orient?translateX:translateY;function axis(context){var values=null==tickValues?scale.ticks?scale.ticks.apply(scale,tickArguments):scale.domain():tickValues,format=null==tickFormat?scale.tickFormat?scale.tickFormat.apply(scale,tickArguments):identity$4:tickFormat,spacing=Math.max(tickSizeInner,0)+tickPadding,range=scale.range(),range0=+range[0]+.5,range1=+range[range.length-1]+.5,position=(scale.bandwidth?center:number$2)(scale.copy()),selection=context.selection?context.selection():context,path=selection.selectAll(".domain").data([null]),tick=selection.selectAll(".tick").data(values,scale).order(),tickExit=tick.exit(),tickEnter=tick.enter().append("g").attr("class","tick"),line=tick.select("line"),text=tick.select("text");path=path.merge(path.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),tick=tick.merge(tickEnter),line=line.merge(tickEnter.append("line").attr("stroke","currentColor").attr(x+"2",k*tickSizeInner)),text=text.merge(tickEnter.append("text").attr("fill","currentColor").attr(x,k*spacing).attr("dy",1===orient?"0em":3===orient?"0.71em":"0.32em")),context!==selection&&(path=path.transition(context),tick=tick.transition(context),line=line.transition(context),text=text.transition(context),tickExit=tickExit.transition(context).attr("opacity",1e-6).attr("transform",(function(d){return isFinite(d=position(d))?transform(d):this.getAttribute("transform")})),tickEnter.attr("opacity",1e-6).attr("transform",(function(d){var p=this.parentNode.__axis;return transform(p&&isFinite(p=p(d))?p:position(d))}))),tickExit.remove(),path.attr("d",4===orient||2==orient?tickSizeOuter?"M"+k*tickSizeOuter+","+range0+"H0.5V"+range1+"H"+k*tickSizeOuter:"M0.5,"+range0+"V"+range1:tickSizeOuter?"M"+range0+","+k*tickSizeOuter+"V0.5H"+range1+"V"+k*tickSizeOuter:"M"+range0+",0.5H"+range1),tick.attr("opacity",1).attr("transform",(function(d){return transform(position(d))})),line.attr(x+"2",k*tickSizeInner),text.attr(x,k*spacing).text(format),selection.filter(entering).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===orient?"start":4===orient?"end":"middle"),selection.each((function(){this.__axis=position}))}return axis.scale=function(_){return arguments.length?(scale=_,axis):scale},axis.ticks=function(){return tickArguments=slice.call(arguments),axis},axis.tickArguments=function(_){return arguments.length?(tickArguments=null==_?[]:slice.call(_),axis):tickArguments.slice()},axis.tickValues=function(_){return arguments.length?(tickValues=null==_?null:slice.call(_),axis):tickValues&&tickValues.slice()},axis.tickFormat=function(_){return arguments.length?(tickFormat=_,axis):tickFormat},axis.tickSize=function(_){return arguments.length?(tickSizeInner=tickSizeOuter=+_,axis):tickSizeInner},axis.tickSizeInner=function(_){return arguments.length?(tickSizeInner=+_,axis):tickSizeInner},axis.tickSizeOuter=function(_){return arguments.length?(tickSizeOuter=+_,axis):tickSizeOuter},axis.tickPadding=function(_){return arguments.length?(tickPadding=+_,axis):tickPadding},axis}var Axis=function(){function Axis(mainGroup,showLabels,labelXDesc,labelYDesc,unitOfMeasure,options){var _this=this;void 0===showLabels&&(showLabels=!0),this._showLabels=!0,this._offsetX=0,this._offsetY=0,this._flipX=!1,this._flipY=!1,this.visible=!0,this.createOrGet=function(name){var mainGroup=_this.mainGroup,res=mainGroup.select("g."+name);return res.empty()&&(res=mainGroup.append("g").attr("class",name)),res},this.mainGroup=mainGroup,this._showLabels=showLabels,this._labelXDesc=labelXDesc,this._labelYDesc=labelYDesc,this._unitOfMeasure=unitOfMeasure,options&&options.offsetX&&(this._offsetX=options.offsetX),options&&options.offsetX&&(this._offsetY=options.offsetY),options&&options.visible&&(this.visible=options.visible),this.mainGroup.style("pointer-events","none"),this._scaleX=linear$1().domain([0,1]).range([0,1]),this._scaleY=linear$1().domain([0,1]).range([0,1])}return Axis.prototype.renderLabelx=function(){var labelXDesc=this._labelXDesc,unitOfMeasure=this._unitOfMeasure,_showLabels=this._showLabels,width=this._scaleX.range()[1],gx=this.renderGx(),labelx=gx.select("text.axis-labelx");return _showLabels?labelx.empty()&&(labelx=gx.append("text").attr("class","axis-labelx").attr("fill","rgba(0,0,0,0.3)").style("text-anchor","middle").style("font-weight","800").style("font-size","10px").text(labelXDesc+" ("+unitOfMeasure+")")):labelx.remove(),labelx.attr("transform","translate("+width/2+",-4)"),labelx},Axis.prototype.renderLabely=function(){var labelYDesc=this._labelYDesc,unitOfMeasure=this._unitOfMeasure,_showLabels=this._showLabels,height=this._scaleY.range()[1],gy=this.renderGy(),labely=gy.select("text.axis-labely");return _showLabels?(labely.empty()&&(labely=gy.append("text").attr("class","axis-labely").attr("fill","rgba(0,0,0,0.3)").style("text-anchor","middle").style("font-weight","800").style("font-size","10px").text(labelYDesc+" ("+unitOfMeasure+")")),labely.attr("transform","translate(-10,"+height/2+")rotate(90)")):labely.remove(),labely},Axis.prototype.renderGy=function(){var _scaleX=this._scaleX,yAxis=function(scale){return axis(2,scale)}(this._scaleY),width=_scaleX.range()[1],gy=this.createOrGet("y-axis");return gy.call(yAxis),gy.attr("transform","translate("+width+",0)"),gy},Axis.prototype.renderGx=function(){var _scaleX=this._scaleX,_scaleY=this._scaleY,xAxis=function(scale){return axis(3,scale)}(_scaleX),height=_scaleY.range()[1],gx=this.createOrGet("x-axis");return gx.attr("transform","translate(0 "+height+")"),gx.call(xAxis),gx},Axis.prototype.render=function(){this.renderLabelx(),this.renderLabely()},Axis.prototype.onResize=function(event){this.mainGroup.attr("height",event.height+"px").attr("width",event.width+"px")},Axis.prototype.onRescale=function(event){var _scaleX=this._scaleX,_scaleY=this._scaleY,offsetX=this.offsetX,offsetY=this.offsetY,xScale=event.xScale,yScale=event.yScale,xBounds=xScale.domain(),yBounds=yScale.domain(),xRange=xScale.range(),yRange=yScale.range();_scaleX.domain([xBounds[0]-offsetX,xBounds[1]-offsetX]).range(xRange),_scaleY.domain([yBounds[0]-offsetY,yBounds[1]-offsetY]).range(yRange),this.flipX(this._flipX),this.flipY(this._flipY),this.visible&&this.render()},Axis.prototype.show=function(){return this.visible=!0,this.mainGroup.attr("visibility","visible"),this.render(),this},Axis.prototype.hide=function(){return this.visible=!1,this.mainGroup.attr("visibility","hidden"),this},Axis.prototype.flipX=function(flipX){this._flipX=flipX;var domain=this._scaleX.domain(),flip=flipX?-1:1;return this._scaleX.domain([flip*domain[0],flip*domain[1]]),this},Axis.prototype.flipY=function(flipY){this._flipY=flipY;var domain=this._scaleY.domain(),flip=flipY?-1:1;return this._scaleY.domain([flip*domain[0],flip*domain[1]]),this},Axis.prototype.showLabels=function(){return this._showLabels=!0,this.render(),this},Axis.prototype.hideLabels=function(){return this._showLabels=!1,this.render(),this},Axis.prototype.setLabelX=function(label){return this._labelXDesc=label,this},Axis.prototype.setLabelY=function(label){return this._labelYDesc=label,this},Axis.prototype.setUnitOfMeasure=function(uom){return this._unitOfMeasure=uom,this},Axis.prototype.setLabels=function(labelX,labelY,unitOfMeasure){return this._labelXDesc=labelX,this._labelYDesc=labelY,this._unitOfMeasure=unitOfMeasure,this},Object.defineProperty(Axis.prototype,"offsetX",{get:function(){return this._offsetX},set:function(offset){this._offsetX=offset},enumerable:!1,configurable:!0}),Object.defineProperty(Axis.prototype,"offsetY",{get:function(){return this._offsetY},set:function(offset){this._offsetY=offset},enumerable:!1,configurable:!0}),Object.defineProperty(Axis.prototype,"scaleX",{get:function(){return this._scaleX.copy()},enumerable:!1,configurable:!0}),Object.defineProperty(Axis.prototype,"scaleY",{get:function(){return this._scaleY.copy()},enumerable:!1,configurable:!0}),Axis}(),LayerManager=function(){function LayerManager(container,scaleOptions,axisOptions){var _this=this;if(this.layers=[],this.createAxis=function(options){var container=_this.container;_this._svgContainer=select(container).append("div").attr("class","axis").style("position","absolute").style("z-index","10").style("pointer-events","none");var svg=_this._svgContainer.append("svg").attr("height",container.offsetHeight+"px").attr("width",container.offsetWidth+"px");return new Axis(svg,!0,options.xLabel,options.yLabel,options.unitOfMeasure)},this.container=container,this.layerContainer=document.createElement("div"),this.layerContainer.className="layer-container",this.container.appendChild(this.layerContainer),this.adjustToSize(+this.container.getAttribute("width"),+this.container.getAttribute("height")),this._zoomPanHandler=new ZoomPanHandler(container,(function(event){return _this.rescale(event)})),scaleOptions){var xMin=scaleOptions.xMin,xMax=scaleOptions.xMax,yMin=scaleOptions.yMin,yMax=scaleOptions.yMax,xBounds=scaleOptions.xBounds,yBounds=scaleOptions.yBounds;void 0!==xMin&&void 0!==xMax&&void 0!==yMin&&void 0!==yMax&&this._zoomPanHandler.setBounds([xMin,xMax],[yMin,yMax]),xBounds&&yBounds&&this._zoomPanHandler.setBounds(xBounds,yBounds)}else this._zoomPanHandler.setBounds([0,1],[0,1]);axisOptions&&(this._axis=this.createAxis(axisOptions)),this.rescale=this.rescale.bind(this)}return LayerManager.prototype.addLayers=function(layers){var _this=this;return layers.forEach((function(layer){return _this.addLayer(layer)})),this},LayerManager.prototype.getLayers=function(){return this.layers},LayerManager.prototype.clearAllData=function(includeReferenceSystem){return void 0===includeReferenceSystem&&(includeReferenceSystem=!0),this.layers.forEach((function(l){return l.clearData(includeReferenceSystem)})),this},LayerManager.prototype.addLayer=function(layer,params){return this.layers.push(layer),this.initLayer(layer,params),this},LayerManager.prototype.removeLayer=function(layerId){var layer=this.layers.find((function(l){return l.id===layerId}));return layer&&(layer.onUnmount(),this.layers=this.layers.filter((function(l){return l.id!==layerId}))),this},LayerManager.prototype.removeAllLayers=function(){var _this=this;return this.layers.forEach((function(layer){_this.removeLayer(layer.id)})),this},LayerManager.prototype.getLayer=function(layerId){return this.layers.find((function(l){return l.id===layerId}))},LayerManager.prototype.initLayer=function(layer,params){var event={elm:this.layerContainer};layer.onMount(event);var rescaleEvent=this.zoomPanHandler.currentStateAsEvent();if(layer.onUpdate(__assign(__assign({},rescaleEvent),params)),layer.onRescale(rescaleEvent),this._svgContainer){var highestZIndex=this.layers.length>0?this.layers.reduce((function(max,layers){return max.order>layers.order?max:layers})).order:1;this._svgContainer.style("z-index",""+(highestZIndex+1))}return this},LayerManager.prototype.showLayer=function(layerId){var layer=this.getLayer(layerId);return layer.setVisibility(!0),layer.onRescale(this.zoomPanHandler.currentStateAsEvent()),this},LayerManager.prototype.hideLayer=function(layerId){return this.getLayer(layerId).setVisibility(!1),this},LayerManager.prototype.adjustToSize=function(width,height){var layersWidth=Math.max(this._axis?width-40:width,0),layersHeight=Math.max(this._axis?height-30:height,0);if(this._axis){var resizeEvent={width:width,height:height};this._axis.onResize(resizeEvent)}if(this.layers){var resizeEvent_1={width:layersWidth,height:layersHeight};this.layers.forEach((function(layer){return layer.onResize(resizeEvent_1)}))}this._zoomPanHandler&&this._zoomPanHandler.adjustToSize(layersWidth,layersHeight,!0)},LayerManager.prototype.setReferenceSystem=function(irs){this.layers.forEach((function(layer){return layer.referenceSystem=irs}))},LayerManager.prototype.showAxis=function(){return this._axis.show(),this},LayerManager.prototype.hideAxis=function(){return this._axis.hide(),this},LayerManager.prototype.showAxisLabels=function(){return this._axis.showLabels(),this},LayerManager.prototype.hideAxisLabels=function(){return this._axis.hideLabels(),this},LayerManager.prototype.setAxisOffset=function(x,y){return this._axis.offsetX=x,this._axis.offsetY=y,this.layers.filter((function(l){return l instanceof GridLayer})).forEach((function(l){l.offsetX=x,l.offsetY=y})),this},LayerManager.prototype.setXAxisOffset=function(x){return this._axis.offsetX=x,this.layers.filter((function(l){return l instanceof GridLayer})).forEach((function(l){l.offsetX=x})),this},LayerManager.prototype.setYAxisOffset=function(y){return this._axis.offsetY=y,this.layers.filter((function(l){return l instanceof GridLayer})).forEach((function(l){l.offsetY=y})),this},LayerManager.prototype.setZoomLevelBoundary=function(zoomlevels){return this._zoomPanHandler.setZoomLevelBoundary(zoomlevels),this},LayerManager.prototype.setMaxZoomLevel=function(zoomlevel){return this._zoomPanHandler.setMaxZoomLevel(zoomlevel),this},LayerManager.prototype.setMinZoomLevel=function(zoomlevel){return this._zoomPanHandler.setMinZoomLevel(zoomlevel),this},LayerManager.prototype.destroy=function(){return this.clearAllData(!0),this.removeAllLayers(),this.layerContainer.remove(),this.layerContainer=void 0,this.container=void 0,this.layers=void 0,this._zoomPanHandler=void 0,this._axis=void 0,this._svgContainer=void 0,this},Object.defineProperty(LayerManager.prototype,"zoomPanHandler",{get:function(){return this._zoomPanHandler},enumerable:!1,configurable:!0}),Object.defineProperty(LayerManager.prototype,"axis",{get:function(){return this._axis},enumerable:!1,configurable:!0}),LayerManager.prototype.rescale=function(event){this._axis&&this._axis.onRescale(event),this.layers&&this.layers.forEach((function(layer){return!0===layer.isVisible?layer.onRescale(event):{}}))},LayerManager}(),IntersectionReferenceSystem=function(){function IntersectionReferenceSystem(path,options){if(this.path=[],this.projectedPath=[],this._offset=0,path.length<1)throw new Error("Missing coordinates");if(path[0]&&3!==path[0].length)throw new Error("Coordinates should be in 3d");this.setPath(path,options),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.getPosition=this.getPosition.bind(this),this.getProjectedLength=this.getProjectedLength.bind(this),this.getTrajectory=this.getTrajectory.bind(this)}return IntersectionReferenceSystem.prototype.setPath=function(path,options){void 0===options&&(options={}),this.options=options;var _a=this.options,arcDivisions=_a.arcDivisions,tension=_a.tension,calculateDisplacementFromBottom=_a.calculateDisplacementFromBottom;this.path=path,this.projectedPath=IntersectionReferenceSystem.toDisplacement(path);var displacement=this.projectedPath[this.projectedPath.length-1][0];this.displacement=displacement,this.interpolators={curve:new CurveInterpolator(path),trajectory:new CurveInterpolator(path.map((function(d){return[d[0],d[1]]})),{tension:tension||.75,arcDivisions:arcDivisions||5e3}),curtain:new CurveInterpolator(this.projectedPath,{tension:tension||.75,arcDivisions:arcDivisions||5e3})};var trajVector=this.getTrajectoryVector(),negativeTrajVector=trajVector.map((function(d){return-1*d}));calculateDisplacementFromBottom?(this.endVector=negativeTrajVector,this.startVector=trajVector):(this.endVector=trajVector,this.startVector=negativeTrajVector),this._curtainPathCache=void 0},IntersectionReferenceSystem.prototype.project=function(length){var curtain=this.interpolators.curtain,_a=this.options,normalizedLength=_a.normalizedLength,calculateDisplacementFromBottom=_a.calculateDisplacementFromBottom,factor=(length-this._offset)/(normalizedLength||this.length),t=clamp(calculateDisplacementFromBottom?1-factor:factor,0,1);return curtain.getPointAt(t)},IntersectionReferenceSystem.prototype.curtainTangent=function(length){var curtain=this.interpolators.curtain,clampedL=clamp((length-this._offset)/this.length,0,1);return curtain.getTangentAt(clampedL)},IntersectionReferenceSystem.prototype.getCurtainPath=function(start,end){if(!this._curtainPathCache){for(var points=[],prevAngle=2*Math.PI,i=this._offset;i<=this.length+this._offset;i+=.1){var point=this.project(i),angle=Math.atan2(point[1],point[0]);Math.abs(angle-prevAngle)>5e-4&&(points.push({point:point,md:i}),prevAngle=angle)}this._curtainPathCache=points}return this._curtainPathCache.filter((function(p){return p.md>=start&&p.md<=end}))},IntersectionReferenceSystem.prototype.unproject=function(displacement){var _a=this.options,normalizedLength=_a.normalizedLength,displacementFromStart=_a.calculateDisplacementFromBottom?this.displacement-displacement:displacement,length=normalizedLength||this.length;if(displacementFromStart<0)return displacementFromStart;if(displacementFromStart>this.displacement)return length+(displacementFromStart-this.displacement);var ls=this.interpolators.curtain.lookupPositions(displacementFromStart,0,1);return ls&&ls.length?ls[0]*length+this._offset:null},IntersectionReferenceSystem.prototype.getProjectedLength=function(length){var curtain=this.interpolators.curtain,l=this.project(length)[0]/curtain.maxX;return Number.isNaN(l)||l<0?0:l>1?1:l},IntersectionReferenceSystem.prototype.getPosition=function(length){var trajectory=this.interpolators.trajectory,l=this.getProjectedLength(length);return trajectory.getPointAt(l)},IntersectionReferenceSystem.prototype.getTrajectory=function(steps,from,to){void 0===from&&(from=0),void 0===to&&(to=1);var p0,p3,extensionStart=from<0?-from:0,extensionEnd=to>1?to-1:0,refStart=this.interpolators.trajectory.getPointAt(0),refEnd=this.interpolators.trajectory.getPointAt(1),offset=0,t0=Math.max(0,from),t1=Math.min(1,to),p1=this.interpolators.trajectory.getPointAt(t0),p2=this.interpolators.trajectory.getPointAt(t1);extensionStart?(p0=[refStart[0]+this.startVector[0]*extensionStart*this.displacement,refStart[1]+this.startVector[1]*extensionStart*this.displacement],offset=-Vector2.distance(p0,refStart)):from>0&&(offset=Vector2.distance(p1,refStart)),extensionEnd&&(p3=[refEnd[0]+this.endVector[0]*extensionEnd*this.displacement,refEnd[1]+this.endVector[1]*extensionEnd*this.displacement]);var points=[],tl=to-from,preSteps=Math.floor(extensionStart/tl*steps),curveSteps=Math.ceil((t1-t0)/tl*steps),postSteps=steps-curveSteps-preSteps;if(p0){points.push(p0);for(var i=1;i<preSteps;i++){var f=i/preSteps*extensionStart*this.displacement;points.push([p0[0]-this.startVector[0]*f,p0[1]-this.startVector[1]*f])}}var cuvePoints=this.interpolators.trajectory.getPoints(curveSteps-1,null,t0,t1);if(points.push.apply(points,cuvePoints),p3){for(i=1;i<postSteps-1;i++){f=i/postSteps*extensionEnd*this.displacement;points.push([p2[0]+this.endVector[0]*f,p2[1]+this.endVector[1]*f])}points.push(p3)}return{points:points,offset:offset}},IntersectionReferenceSystem.prototype.getExtendedTrajectory=function(numPoints,startExtensionLength,endExtensionLength){if(void 0===startExtensionLength&&(startExtensionLength=1e3),void 0===endExtensionLength&&(endExtensionLength=1e3),!isFinite(startExtensionLength)||startExtensionLength<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive startExtensionLength parameter");if(!isFinite(endExtensionLength)||endExtensionLength<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive endExtensionLength parameter");for(var totalLength=this.displacement+startExtensionLength+endExtensionLength,startExtensionNumPoints=Math.floor(startExtensionLength/totalLength*numPoints),curveSteps=Math.max(Math.ceil(this.displacement/totalLength*numPoints),1),endExtensionNumPoints=numPoints-curveSteps-startExtensionNumPoints,points=[],refStart=new Vector2(this.interpolators.trajectory.getPointAt(0)),startVec=new Vector2(this.startVector),startExtensionStepLength=startExtensionLength/startExtensionNumPoints,i=startExtensionNumPoints;i>0;i--){var f=i*startExtensionStepLength,point=refStart.add(startVec.scale(f));points.push(point.toArray())}points.push.apply(points,this.interpolators.trajectory.getPoints(curveSteps,null,0,1));var refEnd=new Vector2(this.interpolators.trajectory.getPointAt(1)),endVec=new Vector2(this.endVector),endExtensionStepLength=endExtensionLength/(endExtensionNumPoints-1);for(i=1;i<endExtensionNumPoints;i++){f=i*endExtensionStepLength,point=refEnd.add(endVec.scale(f));points.push(point.toArray())}return{points:points,offset:-startExtensionLength}},IntersectionReferenceSystem.prototype.getTrajectoryVector=function(){var _a=this.options,trajectoryAngle=_a.trajectoryAngle,calculateDisplacementFromBottom=_a.calculateDisplacementFromBottom;if(isFinite(trajectoryAngle)){var angleInRad=trajectoryAngle*DEG2RAD;return new Vector2(Math.cos(angleInRad),Math.sin(angleInRad)).toArray()}return calculateDisplacementFromBottom?IntersectionReferenceSystem.getDirectionVector(this.interpolators.trajectory,.001,0):IntersectionReferenceSystem.getDirectionVector(this.interpolators.trajectory,.999,1)},IntersectionReferenceSystem.toDisplacement=function(points,offset){void 0===offset&&(offset=0);var p0=points[0],l=0;return points.map((function(p1){var dx=p1[0]-p0[0],dy=p1[1]-p0[1];return l+=Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2)),p0=p1,[offset>0?offset-l:l,p1[2]||0]}))},IntersectionReferenceSystem.getDirectionVector=function(interp,from,to){var p1=interp.getPointAt(to),p2=interp.getPointAt(from);return normalize$2([p1[0]-p2[0],p1[1]-p2[1]])},Object.defineProperty(IntersectionReferenceSystem.prototype,"length",{get:function(){return this.interpolators.curve.length},enumerable:!1,configurable:!0}),Object.defineProperty(IntersectionReferenceSystem.prototype,"offset",{get:function(){return this._offset},set:function(offset){this._curtainPathCache=void 0,this._offset=offset},enumerable:!1,configurable:!0}),IntersectionReferenceSystem}(),Overlay=function(){function Overlay(caller,container){var _this=this;this.elements={},this.listeners={},this.enabled=!0;var con=select(container);this.elm=con.append("div").attr("id","overlay").style("z-index","11").style("position","absolute"),this.source=this.elm.node();var elm=this.elm;elm.on("resize",(function(){var _a=event.detail,width=_a.width,height=_a.height;elm.style("width",width+"px").style("height",height+"px"),_this.enabled&&Object.keys(_this.listeners).forEach((function(key){var target=_this.elements[key]||null,ops=_this.listeners[key];ops&&ops.onResize&&requestAnimationFrame((function(){return ops.onResize({target:target,source:_this.source,caller:caller,width:width,height:height})}))}))})),elm.on("mousemove",(function(){if(_this.enabled){var _a=mouse(_this.elm.node()),mx=_a[0],my=_a[1];Object.keys(_this.listeners).forEach((function(key){var target=_this.elements[key]||null,ops=_this.listeners[key];ops&&ops.onMouseMove&&requestAnimationFrame((function(){return ops.onMouseMove({x:mx,y:my,target:target,source:_this.source,caller:caller})}))}))}})),elm.on("mouseout",(function(){_this.enabled&&Object.keys(_this.listeners).forEach((function(key){var target=_this.elements[key]||null,ops=_this.listeners[key];ops&&ops.onMouseExit&&requestAnimationFrame((function(){return ops.onMouseExit({target:target,source:_this.source,caller:caller})}))}))}))}return Overlay.prototype.create=function(key,callbacks){var newElm=this.elm.append("div").style("position","relative").style("pointer-events","none").node();return this.elements[key]=newElm,callbacks&&(this.listeners[key]=callbacks),newElm},Overlay.prototype.register=function(key,callbacks){this.listeners[key]=callbacks},Overlay.prototype.remove=function(key){var el=this.elements[key];el&&(select(el).remove(),delete this.elements[key]),delete this.listeners[key]},Overlay.prototype.setZIndex=function(zIndex){this.elm.style("z-index",zIndex)},Overlay.prototype.destroy=function(){this.source.remove()},Overlay}(),Controller=function(){function Controller(options){var container=options.container,axisOptions=options.axisOptions,scaleOptions=options.scaleOptions,referenceSystem=options.referenceSystem,layers=options.layers,path=options.path;this._referenceSystem=referenceSystem||path&&new IntersectionReferenceSystem(path),this._overlay=function(caller,container){return new Overlay(caller,container)}(this,container),this.layerManager=new LayerManager(this._overlay.elm.node(),scaleOptions,axisOptions),layers&&(this.layerManager.addLayers(layers),this.setOverlayZIndex(layers))}return Controller.prototype.setReferenceSystem=function(referenceSystem){return this._referenceSystem=referenceSystem,this.layerManager.setReferenceSystem(referenceSystem),this},Controller.prototype.updatePath=function(path,options){return this.setReferenceSystem(new IntersectionReferenceSystem(path,options)),this},Controller.prototype.clearAllData=function(includeReferenceSystem){return void 0===includeReferenceSystem&&(includeReferenceSystem=!0),this.layerManager.clearAllData(includeReferenceSystem),this},Controller.prototype.addLayer=function(layer,params){return this.layerManager.addLayer(layer,params),this.setOverlayZIndex(this.layerManager.getLayers()),this},Controller.prototype.removeLayer=function(layerId){return this.layerManager.removeLayer(layerId),this},Controller.prototype.removeAllLayers=function(){return this.layerManager.removeAllLayers(),this},Controller.prototype.getLayer=function(layerId){return this.layerManager.getLayer(layerId)},Controller.prototype.showLayer=function(layerId){return this.layerManager.showLayer(layerId),this},Controller.prototype.hideLayer=function(layerId){return this.layerManager.hideLayer(layerId),this},Controller.prototype.adjustToSize=function(width,height){this.layerManager.adjustToSize(width,height);var dimensions={width:Math.max(width-40,0),height:Math.max(height-30,0)};return this.overlay.elm.dispatch("resize",{detail:dimensions,bubbles:!0,cancelable:!0}),this},Controller.prototype.setViewport=function(cx,cy,displacement,duration){return this.zoomPanHandler.setViewport(cx,cy,displacement,duration),this},Controller.prototype.setBounds=function(xBounds,yBounds){return this.zoomPanHandler.setBounds(xBounds,yBounds),this},Controller.prototype.showAxis=function(){return this.layerManager.showAxis(),this},Controller.prototype.hideAxis=function(){return this.layerManager.hideAxis(),this},Controller.prototype.showAxisLabels=function(){return this.layerManager.showAxisLabels(),this},Controller.prototype.hideAxisLabels=function(){return this.layerManager.hideAxisLabels(),this},Controller.prototype.setAxisOffset=function(x,y){return this.layerManager.setAxisOffset(x,y),this},Controller.prototype.setXAxisOffset=function(x){return this.layerManager.setXAxisOffset(x),this},Controller.prototype.setYAxisOffset=function(y){return this.layerManager.setYAxisOffset(y),this},Controller.prototype.setZoomLevelBoundary=function(zoomlevels){return this.zoomPanHandler.setZoomLevelBoundary(zoomlevels),this},Controller.prototype.setMaxZoomLevel=function(zoomlevel){return this.zoomPanHandler.setMaxZoomLevel(zoomlevel),this},Controller.prototype.setMinZoomLevel=function(zoomlevel){return this.zoomPanHandler.setMinZoomLevel(zoomlevel),this},Controller.prototype.destroy=function(){return this.layerManager.destroy(),this._overlay.destroy(),this._referenceSystem=void 0,this.layerManager=void 0,this._overlay=void 0,this},Controller.prototype.getHighestZIndex=function(layers){return layers.length>0?layers.reduce((function(max,layers){return max.order>layers.order?max:layers})).order:1},Controller.prototype.setOverlayZIndex=function(layers){var highestZIndex=this.getHighestZIndex(layers);this.overlay.setZIndex(highestZIndex+2)},Object.defineProperty(Controller.prototype,"overlay",{get:function(){return this._overlay},enumerable:!1,configurable:!0}),Object.defineProperty(Controller.prototype,"referenceSystem",{get:function(){return this._referenceSystem},enumerable:!1,configurable:!0}),Object.defineProperty(Controller.prototype,"zoomPanHandler",{get:function(){return this.layerManager.zoomPanHandler},enumerable:!1,configurable:!0}),Object.defineProperty(Controller.prototype,"axis",{get:function(){return this.layerManager.axis},enumerable:!1,configurable:!0}),Object.defineProperty(Controller.prototype,"currentStateAsEvent",{get:function(){return this.zoomPanHandler.currentStateAsEvent()},enumerable:!1,configurable:!0}),Controller}();exports.Axis=Axis,exports.CalloutCanvasLayer=CalloutCanvasLayer,exports.CanvasLayer=CanvasLayer,exports.CasingLayer=CasingLayer,exports.CementLayer=CementLayer,exports.CompletionLayer=CompletionLayer,exports.Controller=Controller,exports.GeomodelCanvasLayer=GeomodelCanvasLayer,exports.GeomodelLabelsLayer=GeomodelLabelsLayer,exports.GeomodelLayer=GeomodelLayer,exports.GeomodelLayerV2=GeomodelLayerV2,exports.GridLayer=GridLayer,exports.HTMLLayer=HTMLLayer,exports.HoleSizeLayer=HoleSizeLayer,exports.ImageLayer=ImageLayer,exports.IntersectionReferenceSystem=IntersectionReferenceSystem,exports.Layer=Layer,exports.LayerManager=LayerManager,exports.PixiLayer=PixiLayer,exports.SVGLayer=SVGLayer,exports.SeismicCanvasLayer=SeismicCanvasLayer,exports.WellborepathLayer=WellborepathLayer,exports.ZoomPanHandler=ZoomPanHandler,exports.calcSize=calcSize,exports.findIndexOfSample=findIndexOfSample,exports.findSampleAtPos=findSampleAtPos,exports.generateProjectedTrajectory=function(poslog,defaultIntersectionAngle){if(!poslog||0===poslog.length)return[];var points=poslog?poslog.map((function(p){return[p.easting,p.northing,p.tvd,p.md]})):[],interpolator=new CurveInterpolator(points,{tension:.75,arcDivisions:5e3}),displacement=interpolator.length,nPoints=Math.round(10*displacement),path=null,first=(path=nPoints>0?simplify(interpolator.getPoints(nPoints),5e-4,10):[[points[0][0],points[0][1]]])[0],last=path[path.length-1],relativeDist=Vector2.distance(first,last),v=null;if(relativeDist<150){var radCurtainDirection=defaultIntersectionAngle/180*Math.PI;v=new Vector2(Math.cos(radCurtainDirection),Math.sin(radCurtainDirection)).mutable}else v=function(path,threshold){for(var res=Vector2.zero.mutable,len=0,temp=Vector2.zero.mutable,i=0;i<path.length-1;i++){var index=path.length-1-i;if(temp.set(path[index]).sub(path[index-1]),res.add(temp),(len=res.magnitude)>threshold)break}return 0===len?new Vector2([0,0]):res.scale(1/len)}(path,30);var extensionLengthStart=Math.max(0,1e3-displacement),offset=extensionLengthStart+displacement,trajectory=[],firstPoints=[],initial=v.toArray();extensionLengthStart>0&&((firstPoints=seqI(Math.ceil(.1*extensionLengthStart)).map((function(t){return v.set(initial).scale(extensionLengthStart*(1-t)).subFrom(first).toArray()}))).pop(),trajectory.push.apply(trajectory,firstPoints)),trajectory.push.apply(trajectory,path);var endPoints=seqI(Math.ceil(100)).map((function(t){return v.set(initial).scale(1e3*t).add(last).toArray()})).splice(1);return trajectory.push.apply(trajectory,endPoints),Vector2.angleRight(initial),projectCurtain(trajectory,null,offset)},exports.generateProjectedWellborePath=function(poslog){if(!poslog||0===poslog.length)return[];var projection=simplify(projectCurtain(poslog?poslog.map((function(p){return[p.easting,p.northing,p.tvd,p.md]})):[])),offset=projection[projection.length-1][0];return projection.forEach((function(p,i){projection[i][0]=offset-p[0]})),projection},exports.generateSeismicSliceImage=function(data,trajectory,colormap,options){return __awaiter(this,void 0,void 0,(function(){var dp,min,max,absMax,dmin,dmax,domain,length,width,height,colorTable,d,offset,colorFactor,pos,step,val1,val2,i,col,black,opacity,x,index,x1,x2,ratio,y,imageData;return __generator(this,(function(_a){switch(_a.label){case 0:if(!(data&&data.datapoints&&data.datapoints.length>0))return[2];for(dp=data.datapoints,min=(null==options?void 0:options.seismicMin)||(null==options?void 0:options.seismicRange)||dp.reduce((function(val,array){return Math.min.apply(Math,__spreadArray(__spreadArray([],array),[val]))}),0),max=(null==options?void 0:options.seismicMax)||(null==options?void 0:options.seismicRange)||dp.reduce((function(val,array){return Math.max.apply(Math,__spreadArray(__spreadArray([],array),[val]))}),0),absMax=Math.max(Math.abs(min),Math.abs(max)),domain={min:dmin=-absMax,max:dmax=absMax,difference:dmax-dmin},length=trajectory[0][0]-trajectory[trajectory.length-1][0],width=Math.abs(Math.floor(length/5)),height=data.yAxisValues.length,1e3,size=1e3,colorDomain=(colorMap=colormap).map((function(v,i){return i*size/colorMap.length})),colorScale=linear$1().domain(colorDomain).range(colorMap),colorTable=Array.from(new Array(size).keys()).map((function(i){var rgb=color(colorScale(i)).rgb();return[rgb.r,rgb.g,rgb.b]})),d=new Uint8ClampedArray(width*height*4),offset=0,colorFactor=999/domain.difference,pos=(null==options?void 0:options.isLeftToRight)?trajectory[0][0]:trajectory[trajectory.length-1][0],step=length/width*((null==options?void 0:options.isLeftToRight)?-1:1),black=[0,0,0],x=0;x<width;x++){for(offset=4*x,index=findIndexOfSample(trajectory,pos),x1=trajectory[index][0],x2=trajectory[index+1][0],ratio=(pos-x1)/(x2-x1),y=0;y<height;y++)val1=dp[y][index],val2=dp[y][index+1],null==val1||null==val2?(col=black,opacity=0):(i=(val1*(1-ratio)+val2*ratio-domain.min)*colorFactor,i=clamp(Math.floor(i),0,999),col=colorTable[i],opacity=255),d.set([col[0],col[1],col[2],opacity],offset),offset+=4*width;pos+=step}return imageData=new ImageData(d,width,height),[4,createImageBitmap(imageData,0,0,width,height)];case 1:return[2,_a.sent()]}var colorMap,size,colorDomain,colorScale}))}))},exports.generateSurfaceData=function(trajectory,stratColumn,surfaceData){if(!(trajectory.length<0)){var filteredSurfaces=surfaceData.filter((function(s){return s.data.values})),mappedSurfaces=filteredSurfaces.map((function(s){var displayName=s.visualSettings.displayName;return{name:displayName.replace(/\s(Base|Top)/gi,""),isBase:displayName.toLowerCase().endsWith("base"),values:s.data.values,color:s.visualSettings.colors.crossSection,visualization:s.visualSettings.crossSection.toLowerCase()}})),stratGroups=new Map,stratigraphies=function(mappedSurfaces,stratColumn,stratGroups){var firstUnit=stratColumn&&stratColumn.find((function(d){return 1===d.stratUnitLevel})),defaultGroupName=firstUnit?firstUnit.identifier:"SEABED";return mappedSurfaces.filter((function(d){return"interval"===d.visualization||"none"===d.visualization})).map((function(s){var path=[],stratUnit=findStratcolumnUnit(stratColumn,s.name,path);stratUnit||console.warn("No match for "+s.name+" in strat column");var group=path[0]||stratUnit,groupName=group&&group.identifier||defaultGroupName;return group&&!stratGroups.has(groupName)&&stratGroups.set(groupName,{age:group.topAge,name:group.identifier}),__assign(__assign({},s),{unit:stratUnit,group:groupName})}))}(mappedSurfaces,stratColumn,stratGroups);stratigraphies.sort((function(a,b){if(!a.unit&&!b.unit)return 0;if(!a.unit)return-1;if(!b.unit)return 1;var aAge=a.isBase?a.unit.baseAge:a.unit.topAge,bAge=b.isBase?b.unit.baseAge:b.unit.topAge;return aAge!==bAge?aAge-bAge:a.isBase&&!b.isBase?1:!a.isBase&&b.isBase?-1:a.unit.stratUnitLevel-b.unit.stratUnitLevel}));var lines=function(mappedSurfaces,trajectory){return mappedSurfaces.filter((function(d){return"line"===d.visualization})).map((function(l){return{id:l.name,label:l.name,width:2,color:convertColor(l.color||"black"),data:trajectory.map((function(p,j){return[p[0],l.values[j]]}))}}))}(mappedSurfaces,trajectory),surfaceAreas=function(projection,surfaces,stratColumn){return surfaces.reduce((function(acc,surface,i){if(!surface.isBase){acc[surface.group]||(acc[surface.group]=[]);var baseIndex_1=function(top,index,surfaces,stratColumn){var nextIndex=index+1;if(!surfaces||nextIndex>=surfaces.length)return null;var baseSurfaceIndex=surfaces.findIndex((function(candidate){return candidate.isBase&&candidate.name===top.name}));if(-1!==baseSurfaceIndex)return baseSurfaceIndex;for(var i=nextIndex;i<surfaces.length;i++){var candidate=surfaces[i];if(!candidate.isBase)return i;if(isAnchestor(top,candidate,stratColumn))return i}return null}(surface,i,surfaces,stratColumn);acc[surface.group].push({id:surface.name,label:surface.name,color:surface.unit&&getColorFromUnit(surface.unit)||4294967295,exclude:"none"===surface.visualization||!surface.unit,data:projection.map((function(p,j){var baseValue=null!==surface.values[j]?function(index,surfaces,datapoint){if(!surfaces||!index||index>=surfaces.length)return null;for(var i=index;i<surfaces.length;i++)if(null!==surfaces[i].values[datapoint])return surfaces[i].values[datapoint];return null}(baseIndex_1,surfaces,j):null;return[p[0],surface.values[j],baseValue]}))})}return acc}),{})}(trajectory,stratigraphies,stratColumn);return{lines:lines,areas:__spreadArray(__spreadArray([],function(groups,trajectory){return groups.map((function(g,i){var next=i+1<groups.length?groups[i+1]:null;return{id:g.id,color:convertColor(g.color),data:trajectory.map((function(p,j){return[p[0],g.top[j],next?next.top[j]:null]}))}}))}(function(stratGroups,surfaceAreas){return Array.from(stratGroups.values()).sort((function(a,b){return a.age-b.age})).filter((function(g){var surfaces=surfaceAreas[g.name],isValid=surfaces&&surfaces.length>0;return isValid||console.warn("Intersection surface group '"+g.name+"' has no valid entries and will be discarded."),isValid})).map((function(g,i){var top=surfaceAreas[g.name][0];return{id:g.name,label:g.name,color:unassignedColorScale(i),top:top.data.map((function(d){return d[1]}))}}))}(stratGroups,surfaceAreas),trajectory)),Object.values(surfaceAreas).flat().filter((function(d){return!d.exclude})))}}},exports.getOverlap=function(r1,r2){var r1x2=r1.x+r1.width,r2x2=r2.x+r2.width,r1y2=r1.y+r1.height,r2y2=r2.y+r2.height;return r2.x>r1x2||r2.y>r1y2||r2x2<r1.x||r2y2<r1.y?null:{dx:Math.max(0,Math.min(r1.x+r1.width,r2.x+r2.width)-Math.max(r1.x,r2.x)),dy:Math.max(0,Math.min(r1.y+r1.height,r2.y+r2.height)-Math.max(r1.y,r2.y))}},exports.getOverlapOffset=getOverlapOffset,exports.getPicksData=function(picksData){var formationPicks,unitPicks=picksData.unitPicks,picks=__spreadArray(__spreadArray(__spreadArray([],function(picks){return picks?picks.map((function(p){return mapPick(p,"ref-picks")})):[]}(picksData.nonUnitPicks)),(formationPicks=unitPicks)?formationPicks.filter((function(d){return d.entryPick.md===d.from})).map((function(p){return mapPick(p.entryPick,"strat-picks")})):[]),function(formationPicks){return formationPicks?formationPicks.filter((function(d){return-1===formationPicks.findIndex((function(p){return Math.abs(p.entryPick.md-d.exitPick.md)<.5}))})).map((function(p){return mapPick(p.exitPick,"strat-picks")})).filter((function(obj,i,array){return i===array.findIndex((function(v){return v.title===obj.title&&v.md===obj.md}))})):[]}(unitPicks));return picks.sort((function(a,b){return a.md-b.md})),picks},exports.getSeismicInfo=function(data,trajectory){if(data&&data.datapoints){var minX=trajectory.reduce((function(acc,val){return Math.min(acc,val[0])}),0),maxX=trajectory.reduce((function(acc,val){return Math.max(acc,val[0])}),0),minTvdMsl=data.yAxisValues&&data.yAxisValues[0],maxTvdMsl=data.yAxisValues&&data.yAxisValues[data.yAxisValues.length-1],dp=data.datapoints||[],min=-dp.reduce((function(val,array){return Math.min.apply(Math,__spreadArray(__spreadArray([],array),[val]))}),0),max=dp.reduce((function(val,array){return Math.max.apply(Math,__spreadArray(__spreadArray([],array),[val]))}),0),absMax=Math.max(Math.abs(min),Math.abs(max)),dmin=-absMax;return{minX:minX,maxX:maxX,minTvdMsl:minTvdMsl,maxTvdMsl:maxTvdMsl,domain:{min:dmin,max:absMax,difference:absMax-dmin}}}},exports.isOverlapping=isOverlapping,exports.isOverlappingHorizontally=function(r1,r2){var r1x2=r1.x+r1.width,r2x2=r2.x+r2.width;return!(r2.x>r1x2||r2x2<r1.x)},exports.pixelsPerUnit=pixelsPerUnit,exports.transformFormationData=function(picks,stratColumn){for(var _a=function(picks,stratColumn){var transformed=function(units,res){void 0===res&&(res=[]);for(var i=0;i<units.length;i+=1){var unit={unitName:(u=units[i]).identifier,topSurface:u.top,baseSurface:u.base,ageBase:u.baseAge,ageTop:u.topAge,color:{r:null===u.colorR?255:u.colorR,g:null===u.colorG?255:u.colorG,b:null===u.colorB?255:u.colorB},level:u.stratUnitLevel,lithType:u.lithologyType,parent:u.stratUnitParent};res.push(unit)}var u;return res}(stratColumn),nonUnitPicks=[],joined=[];return picks.forEach((function(p){var matches=transformed.filter((function(u){return-1!==p.pickIdentifier.search(new RegExp("("+u.topSurface+"|"+u.baseSurface+")","i"))}));matches.length>0?matches.forEach((function(u){return joined.push(__assign({md:p.md,tvd:p.tvd,identifier:p.pickIdentifier,confidence:p.confidence,mdUnit:p.mdUnit,depthReferencePoint:p.depthReferencePoint},u))})):nonUnitPicks.push(p)})),{joined:joined,nonUnitPicks:nonUnitPicks}}(picks,stratColumn),joined=_a.joined,nonUnitPicks=_a.nonUnitPicks,itemstack=function(joined){for(var pairs=[],current=null,sorted=joined.filter((function(d){return d.level})).sort((function(a,b){return a.unitName.localeCompare(b.unitName)||a.md-b.md||a.ageTop-b.ageTop})),_loop_1=function(){var _a,pairWithName,top_1,base,name_1=(current=sorted.shift()).identifier,isTop=name_1===current.topSurface,isBase=name_1===current.baseSurface;if(isTop)pairWithName=current.baseSurface;else{if(!isBase)return console.warn("Unable to match "+name_1+" with top or base surface, ignored"),"continue";pairWithName=current.topSurface}var pairWith=sorted.find((function(p){return p.identifier===pairWithName}));if(pairWith)base=isTop?pairWith:current,(top_1=isTop?current:pairWith).md>base.md&&(top_1=(_a=[base,top_1])[0],base=_a[1]),sorted.splice(sorted.indexOf(pairWith),1);else if(console.warn("Unable to find "+pairWithName+" pick for "+name_1),isTop){if(top_1=current,!(base=joined.filter((function(d){return d.level})).sort((function(a,b){return a.md-b.md})).find((function(p){return p.md>top_1.md}))))return console.warn("Unable to find a base pick for "+name_1+" pick at "+top_1.md+", ignored"),"continue";console.warn("Using "+base.identifier+" as base for "+name_1)}else{if(!isBase)return console.warn(name_1+" ignored"),"continue";if(base=current,!(top_1=joined.filter((function(d){return d.level})).sort((function(a,b){return b.md-a.md})).find((function(p){return p.md<base.md}))))return console.warn("Unable to find a top pick for "+name_1+" pick at "+base.md+", ignored"),"continue";console.warn("Using "+top_1.identifier+" as top for "+name_1)}pairs.push({name:top_1.unitName,mdEntry:top_1.md,tvdEntry:top_1.tvd,color:top_1.color,level:top_1.level,entryPick:top_1,mdExit:base.md,tvdExit:base.tvd,exitPick:base,confidenceEntry:top_1.confidence,confidenceExit:base.confidence})};sorted.length>0;)_loop_1();return pairs}(joined).filter((function(d){return d.mdEntry<d.mdExit})).sort((function(a,b){return a.mdEntry-b.mdEntry||a.level-b.level})).reverse(),unitPicks=[],_loop_2=function(){for(var first=itemstack.pop(),group=[];itemstack.length>0&&itemstack[itemstack.length-1].level>first.level;)group.push(itemstack.pop());group.reverse(),group.push(first);var arr=[];group.forEach((function(itm){var gaps=function(from,to,arr){if(0===arr.length)return[[from,to]];for(var gaps=[],d=from,i=0;d<to&&i<arr.length;){var itm=arr[i];itm.from>d&&gaps.push([d,Math.min(itm.from,to)]),d=Math.min(to,Math.max(from,itm.to)),i+=1}return d<to&&gaps.push([d,to]),gaps}(itm.mdEntry,itm.mdExit,arr);arr.push.apply(arr,gaps.map((function(g){return{from:g[0],to:g[1],itm:itm}}))),arr.sort((function(a,b){return a.from-b.from}))})),unitPicks.push.apply(unitPicks,arr.map((function(d){return __assign({from:d.from,to:d.to},d.itm)})))};itemstack.length>0;)_loop_2();return{unitPicks:unitPicks,nonUnitPicks:nonUnitPicks}},Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
414
|
+
var extendStatics$l=function(d,b){return(extendStatics$l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)},__assign$1=function(){return(__assign$1=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t}).apply(this,arguments)};function reduce(v,func,r){void 0===r&&(r=0);for(var i=0;i<v.length;i++)r=func(r,v[i],i);return r}var EPS=Math.pow(2,-42);function cuberoot(x){var y=Math.pow(Math.abs(x),1/3);return x<0?-y:y}function getQuadRoots(a,b,c){if(Math.abs(a)<EPS)return Math.abs(b)<EPS?[]:[-c/b];var D=b*b-4*a*c;return Math.abs(D)<EPS?[-b/(2*a)]:D>0?[(-b+Math.sqrt(D))/(2*a),(-b-Math.sqrt(D))/(2*a)]:[]}function getCoefficients(v0,v1,v2,v3,v,tension){void 0===v&&(v=0),void 0===tension&&(tension=.5);var c=(1-tension)*(v2-v0)*.5,x=(1-tension)*(v3-v1)*.5;return[2*v1-2*v2+c+x,-3*v1+3*v2-2*c-x,c,v1-v]}function solveForT(t,tension,v0,v1,v2,v3){if(Math.abs(t)<EPS)return v1;if(Math.abs(1-t)<EPS)return v2;var t2=t*t,t3=t*t2,_a=getCoefficients(v0,v1,v2,v3,0,tension);return _a[0]*t3+_a[1]*t2+_a[2]*t+_a[3]}function getDerivativeOfT(t,tension,v0,v1,v2,v3){var t2=t*t,_a=getCoefficients(v0,v1,v2,v3,0,tension);return 3*_a[0]*t2+2*_a[1]*t+_a[2]}function distance(p1,p2){return Math.sqrt(reduce(p2,(function(s,c,i){return s+Math.pow(c-p1[i],2)})))}function normalize$2(v){var squared=reduce(v,(function(s,c){return s+Math.pow(c,2)})),l=Math.sqrt(squared);return 0===l?function(v,val){for(var i=0;i<v.length;i++)v[i]=val;return v}(v,0):function(v,func){for(var i=0;i<v.length;i++)v[i]=func(v[i],i);return v}(v,(function(c){return c/l}))}function getControlPoints(idx,points,closed){var p0,p1,p2,p3,maxIndex=points.length-1;return closed?(p0=points[idx-1<0?maxIndex:idx-1],p1=points[idx%points.length],p2=points[(idx+1)%points.length],p3=points[(idx+2)%points.length]):(p0=points[Math.max(0,idx-1)],p1=points[idx],p2=points[Math.min(maxIndex,idx+1)],p3=points[Math.min(maxIndex,idx+2)]),[p0,p1,p2,p3]}function getPointAtT(t,points,options,target){void 0===options&&(options={});var tension=Number.isFinite(options.tension)?options.tension:.5,closed=!!options.closed,func=options.func||solveForT,nPoints=closed?points.length:points.length-1,p=nPoints*t,idx=Math.floor(p),weight=p-idx,_a=getControlPoints(idx,points,closed),p0=_a[0],p1=_a[1],p2=_a[2],p3=_a[3];target=target||new Array(p0.length);for(var i=0;i<p0.length;i++)target[i]=func(weight,tension,p0[i],p1[i],p2[i],p3[i]);return 3===nPoints&&target[1],target}function getTangentAtT(t,points,options,target){void 0===options&&(options={});var tension=Number.isFinite(options.tension)?options.tension:.5,closed=!!options.closed;return 1===tension&&0===t?t+=EPS:1===tension&&1===t&&(t-=EPS),getPointAtT(t,points,{tension:tension,closed:closed,func:getDerivativeOfT},target)}function getArcLengths(points,divisions,options){void 0===options&&(options={});var current,lengths=[],last=getPointAtT(0,points,options),sum=0;divisions=divisions||300,lengths.push(0);for(var p=1;p<=divisions;p++)sum+=distance(current=getPointAtT(p/divisions,points,options),last),lengths.push(sum),last=current;return lengths}function getUtoTmapping(u,arcLengths){for(var comparison,il=arcLengths.length,targetArcLength=u*arcLengths[il-1],low=0,high=il-1,i=0;low<=high;)if((comparison=arcLengths[i=Math.floor(low+(high-low)/2)]-targetArcLength)<0)low=i+1;else{if(!(comparison>0)){high=i;break}high=i-1}if(arcLengths[i=high]===targetArcLength)return i/(il-1);var lengthBefore=arcLengths[i];return(i+(targetArcLength-lengthBefore)/(arcLengths[i+1]-lengthBefore))/(il-1)}function getTtoUmapping(t,arcLengths){if(0===t)return 0;if(1===t)return 1;var al=arcLengths.length-1,totalLength=arcLengths[al],tIdx=t*al,subIdx=Math.floor(tIdx),l1=arcLengths[subIdx];return tIdx===subIdx?l1/totalLength:(l1+(tIdx-subIdx)*(arcLengths[subIdx+1]-l1))/totalLength}function getTAtValue(lookup,tension,v0,v1,v2,v3){var _a=getCoefficients(v0,v1,v2,v3,lookup,tension),a=_a[0],b=_a[1],c=_a[2],d=_a[3];return 0===a&&0===b&&0===c&&0===d?[0]:function(a,b,c,d){if(Math.abs(a)<EPS)return getQuadRoots(b,c,d);var roots,p=(3*a*c-b*b)/(3*a*a),q=(2*b*b*b-9*a*b*c+27*a*a*d)/(27*a*a*a);if(Math.abs(p)<EPS)roots=[cuberoot(-q)];else if(Math.abs(q)<EPS)roots=[0].concat(p<0?[Math.sqrt(-p),-Math.sqrt(-p)]:[]);else{var D=q*q/4+p*p*p/27;if(Math.abs(D)<EPS)roots=[-1.5*q/p,3*q/p];else if(D>0)roots=[(u=cuberoot(-q/2-Math.sqrt(D)))-p/(3*u)];else{var u=2*Math.sqrt(-p/3),t=Math.acos(3*q/p/u)/3,k=2*Math.PI/3;roots=[u*Math.cos(t),u*Math.cos(t-k),u*Math.cos(t-2*k)]}}for(var i=0;i<roots.length;i++)roots[i]-=b/(3*a);return roots}(a,b,c,d).filter((function(t){return t>-EPS&&t<=1+EPS})).map((function(t){return function(value,min,max){return void 0===min&&(min=0),void 0===max&&(max=1),value<min?min:value>max?max:value}(t,0,1)}))}var CurveInterpolator=function(){function CurveInterpolator(points,options){void 0===options&&(options={}),options=__assign$1({tension:.5,arcDivisions:300,closed:!1},options),this._cache={},this._tension=options.tension,this._arcDivisions=options.arcDivisions,this._lmargin=options.lmargin||1-this._tension,this._closed=options.closed,this.points=points}return CurveInterpolator.prototype.getT=function(position){return getUtoTmapping(position,this.arcLengths)},CurveInterpolator.prototype.getPointAt=function(position,target){var options={tension:this.tension,closed:this.closed};return getPointAtT(this.getT(position),this.points,options,target)},CurveInterpolator.prototype.getTangentAt=function(position,target){return void 0===target&&(target=null),normalize$2(getTangentAtT(this.getT(position),this.points,{tension:this.tension,closed:this.closed},target))},CurveInterpolator.prototype.getBoundingBox=function(from,to){if(void 0===from&&(from=0),void 0===to&&(to=1),0===from&&1===to&&this._cache.bbox)return this._cache.bbox;var bbox=function(points,options){void 0===options&&(options={});for(var _a=__assign$1({tension:.5,closed:!1,from:0,to:1,arcLengths:null,arcDivisions:300},options),tension=_a.tension,closed=_a.closed,u0=_a.from,u1=_a.to,arcLengths=_a.arcLengths,arcDivisions=_a.arcDivisions,nPoints=closed?points.length:points.length-1,t0=getUtoTmapping(u0,arcLengths=arcLengths||getArcLengths(points,arcDivisions,{tension:tension,closed:closed})),t1=getUtoTmapping(u1,arcLengths),i0=Math.floor(nPoints*t0),i1=Math.ceil(nPoints*t1),start=getPointAtT(t0,points,{tension:tension,closed:closed}),end=getPointAtT(t1,points,{tension:tension,closed:closed}),min=[],max=[],c=0;c<start.length;c++)min[c]=Math.min(start[c],end[c]),max[c]=Math.max(start[c],end[c]);for(var _loop_1=function(i){var _a=getControlPoints(i-1,points,closed),p0=_a[0],p1=_a[1],p2=_a[2],p3=_a[3];if(i<i1)for(var c=0;c<p2.length;c++)p2[c]<min[c]&&(min[c]=p2[c]),p2[c]>max[c]&&(max[c]=p2[c]);if(tension<1){var w0_1=nPoints*t0-(i-1),w1_1=nPoints*t1-(i-1),valid=function(t){return t>-EPS&&t<=1+EPS&&(i-1!==i0||t>w0_1)&&(i!==i1||t<w1_1)},_loop_2=function(c){var _a=getCoefficients(p0[c],p1[c],p2[c],p3[c],0,tension);getQuadRoots(3*_a[0],2*_a[1],_a[2]).filter(valid).forEach((function(t){var v=solveForT(t,tension,p0[c],p1[c],p2[c],p3[c]);v<min[c]&&(min[c]=v),v>max[c]&&(max[c]=v)}))};for(c=0;c<p0.length;c++)_loop_2(c)}},i=i0+1;i<=i1;i++)_loop_1(i);return{min:min,max:max}}(this.points,{from:from,to:to,tension:this.tension,closed:this.closed,arcLengths:this.arcLengths});return 0===from&&1===to&&(this._cache.bbox=bbox),bbox},CurveInterpolator.prototype.getPoints=function(samples,returnType,from,to){if(void 0===samples&&(samples=100),void 0===from&&(from=0),void 0===to&&(to=1),!samples||samples<=0)throw Error("Invalid arguments passed to getPoints(). You must specify at least 1 sample/segment.");if(!(from<0||to>1||to<from)){for(var pts=[],d=0;d<=samples;d++){var u=0===from&&1===to?d/samples:from+d/samples*(to-from);pts.push(this.getPointAt(u,returnType&&new returnType))}return pts}},CurveInterpolator.prototype.lookup=function(v,axis,max,margin){void 0===axis&&(axis=0),void 0===max&&(max=0),void 0===margin&&(margin=this._lmargin);var matches=function(lookup,points,options){for(var _a=__assign$1({axis:0,tension:.5,closed:!1,margin:.5,max:0,processRefAxis:!1,func:solveForT},options),func=_a.func,axis=_a.axis,tension=_a.tension,closed=_a.closed,margin=_a.margin,max=_a.max,processRefAxis=_a.processRefAxis,k=axis,solutions=[],nPoints=closed?points.length:points.length-1,i=0;i<nPoints;i+=1){var idx=max<0?nPoints-(i+1):i,_b=getControlPoints(idx,points,closed),p0=_b[0],p1=_b[1],p2=_b[2],p3=_b[3],vmin=void 0,vmax=void 0;if(p1[k]<p2[k]?(vmin=p1[k],vmax=p2[k]):(vmin=p2[k],vmax=p1[k]),lookup-margin<=vmax&&lookup+margin>=vmin){var ts=getTAtValue(lookup,tension,p0[k],p1[k],p2[k],p3[k]);max<0?ts.sort((function(a,b){return b-a})):max>=0&&ts.sort((function(a,b){return a-b}));for(var j=0;j<ts.length;j++)if(!(0===ts[j]&&i>0)){for(var coord=[],c=0;c<p0.length;c++){var v;v=c!==k||processRefAxis?func(ts[j],tension,p0[c],p1[c],p2[c],p3[c],idx-1):lookup,coord[c]=v}if(solutions.push(coord),solutions.length===Math.abs(max))return solutions}}}return solutions}(v,this.points,{axis:axis,tension:this.tension,closed:this.closed,max:max,margin:margin});return 1===Math.abs(max)&&1===matches.length?matches[0]:matches},CurveInterpolator.prototype.lookupPositions=function(v,axis,max,margin){return void 0===axis&&(axis=0),void 0===max&&(max=0),void 0===margin&&(margin=this._lmargin),function(lookup,points,options){for(var _a=__assign$1({axis:0,tension:.5,closed:!1,margin:.5,max:0},options),axis=_a.axis,tension=_a.tension,closed=_a.closed,margin=_a.margin,max=_a.max,k=axis,solutions=new Set,arcLengths=options.arcLengths||getArcLengths(points,options.arcDivisions||300,{tension:tension,closed:closed}),nPoints=closed?points.length:points.length-1,i=0;i<nPoints;i+=1){var idx=max<0?points.length-i:i,_b=getControlPoints(idx,points,closed),p0=_b[0],p1=_b[1],p2=_b[2],p3=_b[3],vmin=void 0,vmax=void 0;if(p1[k]<p2[k]?(vmin=p1[k],vmax=p2[k]):(vmin=p2[k],vmax=p1[k]),lookup-margin<=vmax&&lookup+margin>=vmin){var ts=getTAtValue(lookup,tension,p0[k],p1[k],p2[k],p3[k]);max<0?ts.sort((function(a,b){return b-a})):max>=0&&ts.sort((function(a,b){return a-b}));for(var j=0;j<ts.length;j++)if(!(0===ts[j]&&i>0)){var u=getTtoUmapping((ts[j]+idx)/nPoints,arcLengths);if(solutions.add(u),solutions.size===Math.abs(max))return Array.from(solutions)}}}return Array.from(solutions)}(v,this.points,{axis:axis,arcLengths:this.arcLengths,tension:this.tension,closed:this.closed,max:max,margin:margin})},CurveInterpolator.prototype.invalidateCache=function(){var _this=this;return Object.keys(this._cache).forEach((function(key){delete _this._cache[key]})),this},Object.defineProperty(CurveInterpolator.prototype,"points",{get:function(){return this._points},set:function(pts){this._points=pts,this.invalidateCache()},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"tension",{get:function(){return this._tension},set:function(t){t!==this._tension&&(this._tension=t,this.invalidateCache())},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"closed",{get:function(){return this._closed},set:function(isClosed){isClosed!==this._closed&&(this._closed=isClosed,this.invalidateCache())},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"arcDivisions",{get:function(){return this._arcDivisions},set:function(n){n!==this._arcDivisions&&(this._arcDivisions=n,this.invalidateCache())},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"arcLengths",{get:function(){if(this._cache.arcLengths)return this._cache.arcLengths;var arcLengths=getArcLengths(this.points,this.arcDivisions,{tension:this.tension,closed:this.closed});return this._cache.arcLengths=arcLengths,arcLengths},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"length",{get:function(){var lengths=this.arcLengths;return lengths[lengths.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"minX",{get:function(){return this.getBoundingBox().min[0]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"maxX",{get:function(){return this.getBoundingBox().max[0]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"minY",{get:function(){return this.getBoundingBox().min[1]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"maxY",{get:function(){return this.getBoundingBox().max[1]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"minZ",{get:function(){return this.getBoundingBox().min[2]},enumerable:!0,configurable:!0}),Object.defineProperty(CurveInterpolator.prototype,"maxZ",{get:function(){return this.getBoundingBox().max[2]},enumerable:!0,configurable:!0}),CurveInterpolator}();!function(_super){function CurveInterpolator2D(points,tension,arcDivisions,closed){return void 0===tension&&(tension=.5),void 0===arcDivisions&&(arcDivisions=300),void 0===closed&&(closed=!1),_super.call(this,points,{tension:tension,arcDivisions:arcDivisions,closed:closed})||this}(function(d,b){function __(){this.constructor=d}extendStatics$l(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)})(CurveInterpolator2D,_super),CurveInterpolator2D.prototype.x=function(y,max,margin){void 0===max&&(max=0),void 0===margin&&(margin=this._lmargin);var res=this.lookup(y,1,max,margin);return 1===Math.abs(max)?res[0]:res.map((function(d){return d[0]}))},CurveInterpolator2D.prototype.y=function(x,max,margin){void 0===max&&(max=0),void 0===margin&&(margin=this._lmargin);var res=this.lookup(x,0,max,margin);return 1===Math.abs(max)?res[1]:res.map((function(d){return d[1]}))},CurveInterpolator2D.prototype.getNormalAt=function(position,target){return normalize$2(function(v){if(v.length>2)throw Error("Only supported for 2d vectors");var x=-v[1];return v[1]=v[0],v[0]=x,v}(getTangentAtT(this.getT(position),this.points,{tension:this.tension,closed:this.closed},target)))},CurveInterpolator2D.prototype.getAngleAt=function(position){var tan=getTangentAtT(this.getT(position),this.points,{tension:this.tension,closed:this.closed});return Math.atan2(tan[1],tan[0])},CurveInterpolator2D.prototype.getBoundingBox=function(from,to){void 0===from&&(from=0),void 0===to&&(to=1);var bbox=_super.prototype.getBoundingBox.call(this,from,to);return{x1:bbox.min[0],x2:bbox.max[0],y1:bbox.min[1],y2:bbox.max[1],min:bbox.min,max:bbox.max}}}(CurveInterpolator),function(){function Point(x,y,z,w){void 0===x&&(x=0),void 0===y&&(y=0),void 0===z&&(z=null),void 0===w&&(w=null),this.x=x,this.y=y,this.z=z,this.w=w}Object.defineProperty(Point.prototype,0,{get:function(){return this.x},set:function(x){this.x=x},enumerable:!0,configurable:!0}),Object.defineProperty(Point.prototype,1,{get:function(){return this.y},set:function(y){this.y=y},enumerable:!0,configurable:!0}),Object.defineProperty(Point.prototype,2,{get:function(){return this.z},set:function(z){this.z=z},enumerable:!0,configurable:!0}),Object.defineProperty(Point.prototype,3,{get:function(){return this.w},set:function(w){this.w=w},enumerable:!0,configurable:!0}),Object.defineProperty(Point.prototype,"length",{get:function(){return Number.isFinite(this.w)?4:Number.isFinite(this.z)?3:2},enumerable:!0,configurable:!0})}();function simplify(inputArr,maxOffset,maxDistance){var _a;if(void 0===maxOffset&&(maxOffset=.001),void 0===maxDistance&&(maxDistance=10),inputArr.length<=4)return inputArr;for(var _b=inputArr[0],o0=_b[0],o1=_b[1],arr=inputArr.map((function(d){return[d[0]-o0,d[1]-o1]})),_c=arr[0],a0=_c[0],a1=_c[1],sim=[inputArr[0]],i=1;i+1<arr.length;i++){var _d=arr[i],t0=_d[0],t1=_d[1],_e=arr[i+1],b0=_e[0],b1=_e[1];if(b0-t0!=0||b1-t1!=0){var proximity=Math.abs(a0*b1-a1*b0+b0*t1-b1*t0+a1*t0-a0*t1)/Math.sqrt(Math.pow(b0-a0,2)+Math.pow(b1-a1,2)),dir=[a0-t0,a1-t1],len=Math.sqrt(Math.pow(dir[0],2)+Math.pow(dir[1],2));(proximity>maxOffset||len>=maxDistance)&&(sim.push([t0+o0,t1+o1]),a0=(_a=[t0,t1])[0],a1=_a[1])}}var last=arr[arr.length-1];return sim.push([last[0]+o0,last[1]+o1]),sim}function projectCurtain(points,origin,offset){void 0===origin&&(origin=null),void 0===offset&&(offset=0);var p0=origin||points[0],l=0;return points.map((function(p1){var dx=p1[0]-p0[0],dy=p1[1]-p0[1];return l+=Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2)),p0=p1,[offset>0?offset-l:l,p1[2]||0]}))}function findIndexOfSample(data,pos){for(var a=0,b=data.length-1,aPos=data[a][0],bPos=data[b][0];b-a>20;){var splitAt=Math.floor((b+a)/2),splitPos=data[splitAt][0];if(pos>=aPos&&pos<splitPos)bPos=data[b=splitAt][0];else if(pos>=splitPos&&pos<=bPos)aPos=data[a=splitAt][0];else if(pos<=aPos&&pos>splitPos)bPos=data[b=splitAt][0];else{if(!(pos<=splitPos&&pos>=bPos))return-1;aPos=data[a=splitAt][0]}}for(var index=-1,i=a;i<b;i++){var v1=data[i][0],v2=data[i+1][0];if(Math.min(v1,v2)<=pos&&pos<=Math.max(v1,v2)){index=i;break}}return index}function findSampleAtPos(data,pos,topLimit,bottomLimit){void 0===topLimit&&(topLimit=null),void 0===bottomLimit&&(bottomLimit=null);var y=null,index=findIndexOfSample(data,pos);if(-1!==index){var v1=data[index][1],v2=data[index+1][1];if(v2&&v2){var x1=data[index][0],f=(pos-x1)/(data[index+1][0]-x1);y=v1*(1-f)+v2*f,topLimit&&topLimit>y&&(y=topLimit),bottomLimit&&bottomLimit<y&&(y=bottomLimit)}}return y}function mapPick(p,groupName){return{title:p.pickIdentifier||p.identifier,group:groupName,label:p.md+" "+p.mdUnit+" "+p.depthReferencePoint,color:"strat-picks"===groupName?"#227":"rgba(0,0,0,0.8)",md:p.md}}var GeomodelLabelsLayer=function(_super){function GeomodelLabelsLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.defaultMargins=18,_this.defaultMinFontSize=8,_this.defaultMaxFontSize=13,_this.defaultTextColor="black",_this.defaultFont="Arial",_this.isLabelsOnLeftSide=!0,_this.maxFontSizeInWorldCoordinates=70,_this.isXFlipped=!1,_this.areasWithAvgTopDepth=null,_this.drawAreaLabel=function(surfaceArea,nextSurfaceArea,surfaces,i){var data=surfaceArea.data,_a=_this,ctx=_a.ctx,maxFontSizeInWorldCoordinates=_a.maxFontSizeInWorldCoordinates,isXFlipped=_a.isXFlipped,_b=_this.rescaleEvent,xScale=_b.xScale,yScale=_b.yScale,xRatio=_b.xRatio,yRatio=_b.yRatio,zFactor=_b.zFactor,isLabelsOnLeftSide=_this.checkDrawLabelsOnLeftSide(),marginsInWorldCoords=(_this.options.margins||_this.defaultMargins)*(isXFlipped?-1:1)/xRatio,minFontSize=_this.options.minFontSize||_this.defaultMinFontSize,fontSizeInWorldCoords=(_this.options.maxFontSize||_this.defaultMaxFontSize)/yRatio;fontSizeInWorldCoords>maxFontSizeInWorldCoordinates&&(fontSizeInWorldCoords=maxFontSizeInWorldCoordinates)*yRatio<minFontSize&&(fontSizeInWorldCoords=minFontSize/yRatio);var leftEdge=xScale.invert(xScale.range()[0])+marginsInWorldCoords,rightEdge=xScale.invert(xScale.range()[1])-marginsInWorldCoords,_c=_this.getSurfacesAreaEdges(),surfaceAreaLeftEdge=_c[0],surfaceAreaRightEdge=_c[1];ctx.save(),ctx.font=fontSizeInWorldCoords*yRatio+"px "+(_this.options.font||_this.defaultFont);var startPos,labelMetrics=ctx.measureText(surfaceArea.label),labelLengthInWorldCoords=labelMetrics.width/xRatio;if(isLabelsOnLeftSide){var labelRightEdge=leftEdge+(isXFlipped?-labelLengthInWorldCoords:labelLengthInWorldCoords);(!isXFlipped&&labelRightEdge>surfaceAreaRightEdge||isXFlipped&&labelRightEdge<surfaceAreaRightEdge)&&(isLabelsOnLeftSide=!1)}else{var labelLeftEdge=rightEdge+(isXFlipped?labelLengthInWorldCoords:-labelLengthInWorldCoords);(!isXFlipped&&labelLeftEdge<surfaceAreaLeftEdge||isXFlipped&&labelLeftEdge>surfaceAreaLeftEdge)&&(isLabelsOnLeftSide=!0)}startPos=isLabelsOnLeftSide?isXFlipped?Math.min(surfaceAreaLeftEdge,leftEdge):Math.max(surfaceAreaLeftEdge,leftEdge):isXFlipped?Math.max(surfaceAreaRightEdge,rightEdge):Math.min(surfaceAreaRightEdge,rightEdge);var topEdge=yScale.invert(yScale.range()[0]),bottomEdge=yScale.invert(yScale.range()[1]),posStep=labelLengthInWorldCoords/3*.07*(isLabelsOnLeftSide?1:-1)*(isXFlipped?-1:1),dirStep=labelLengthInWorldCoords/5*(isLabelsOnLeftSide?1:-1)*(isXFlipped?-1:1),topData=data.map((function(d){return[d[0],d[1]]})),topPos=_this.calcPos(topData,startPos,3,posStep,topEdge,bottomEdge);if(topPos){var bottomData=data.map((function(d){return[d[0],d[2]]})),bottomPos=_this.calcPos(bottomData,startPos,3,posStep,topEdge,bottomEdge,nextSurfaceArea?nextSurfaceArea.data.map((function(d){return[d[0],d[1]]})):null,surfaces,i);bottomPos||(bottomPos=new Vector2(topPos.x,bottomEdge));var thickness=bottomPos.y-topPos.y;if(thickness<fontSizeInWorldCoords){if(thickness*yRatio<minFontSize)return;fontSizeInWorldCoords=thickness,ctx.font=fontSizeInWorldCoords*yRatio+"px "+(_this.options.font||_this.defaultFont),labelLengthInWorldCoords=(labelMetrics=ctx.measureText(surfaceArea.label)).width/xRatio}var initialDirVec=isLabelsOnLeftSide!==isXFlipped?Vector2.right:Vector2.left,areaDir=_this.calcAreaDir(topData,bottomData,startPos,5,dirStep,initialDirVec,topEdge,bottomEdge,0,Math.PI/4,4,nextSurfaceArea?nextSurfaceArea.data.map((function(d){return[d[0],d[1]]})):null,surfaces,i),scaledAngle=Math.atan(Math.tan(areaDir)*zFactor),textX=startPos,textY=(topPos.y+bottomPos.y)/2,textAngle=isXFlipped?-scaledAngle:scaledAngle;ctx.textAlign=isLabelsOnLeftSide?"left":"right",ctx.translate(xScale(textX),yScale(textY)),ctx.rotate(textAngle),ctx.fillStyle=_this.options.textColor||_this.defaultTextColor,ctx.font=fontSizeInWorldCoords*yRatio+"px "+(_this.options.font||_this.defaultFont),ctx.textBaseline="middle",ctx.fillText(surfaceArea.label,0,0),ctx.restore()}},_this.drawLineLabel=function(s){var _a=_this,ctx=_a.ctx,isXFlipped=_a.isXFlipped,_b=_this.rescaleEvent,xScale=_b.xScale,yScale=_b.yScale,xRatio=_b.xRatio,yRatio=_b.yRatio,zFactor=_b.zFactor,isLabelsOnLeftSide=_this.checkDrawLabelsOnLeftSide(),marginsInWorldCoords=_this.getMarginsInWorldCoordinates(),fontSizeInWorldCoords=(_this.options.maxFontSize||_this.defaultMaxFontSize)/yRatio;ctx.save(),ctx.font=fontSizeInWorldCoords*yRatio+"px "+(_this.options.font||_this.defaultFont);var startPos,labelLengthInWorldCoords=ctx.measureText(s.label).width/xRatio,leftEdge=xScale.invert(xScale.range()[0])+marginsInWorldCoords,rightEdge=xScale.invert(xScale.range()[1])-marginsInWorldCoords,_c=_this.getSurfacesAreaEdges(),surfaceAreaLeftEdge=_c[0],surfaceAreaRightEdge=_c[1];startPos=isLabelsOnLeftSide?isXFlipped?Math.max(surfaceAreaRightEdge,rightEdge):Math.min(surfaceAreaRightEdge,rightEdge):isXFlipped?Math.min(surfaceAreaLeftEdge,leftEdge):Math.max(surfaceAreaLeftEdge,leftEdge);var step=labelLengthInWorldCoords/5*(isLabelsOnLeftSide?-1:1),data=s.data,pos=_this.calcPos(data,startPos,5,step),dir=_this.calcLineDir(data,startPos,5,step,zFactor,isLabelsOnLeftSide?Vector2.left:Vector2.right);if(pos&&dir){var textX=startPos,textY=pos.y-1-fontSizeInWorldCoords/2,textDir=Vector2.angleRight(dir)-(isLabelsOnLeftSide?Math.PI:0);ctx.textAlign=isLabelsOnLeftSide?"right":"left",ctx.translate(xScale(textX),yScale(textY)),ctx.rotate(textDir),ctx.fillStyle=_this.colorToCSSColor(s.color),ctx.textBaseline="middle",ctx.fillText(s.label,0,0),ctx.restore()}},_this.render=_this.render.bind(_this),_this.getMarginsInWorldCoordinates=_this.getMarginsInWorldCoordinates.bind(_this),_this.getSurfacesAreaEdges=_this.getSurfacesAreaEdges.bind(_this),_this.updateXFlipped=_this.updateXFlipped.bind(_this),_this.generateSurfacesWithAvgDepth=_this.generateSurfacesWithAvgDepth.bind(_this),_this}return __extends(GeomodelLabelsLayer,_super),Object.defineProperty(GeomodelLabelsLayer.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),GeomodelLabelsLayer.prototype.setData=function(data){_super.prototype.setData.call(this,data),this.areasWithAvgTopDepth=null},GeomodelLabelsLayer.prototype.generateSurfacesWithAvgDepth=function(){var areas=this.data.areas;this.areasWithAvgTopDepth=areas.reduce((function(acc,area){if(!area.label)return acc;var sumAndCount=area.data.reduce((function(a,d){return null!=d[1]&&(a.sum+=d[1],a.count++),a}),{sum:0,count:0});if(0===sumAndCount.count)return acc;var avgTopDepth=sumAndCount.sum/sumAndCount.count;return __spreadArray(__spreadArray([],acc),[__assign(__assign({},area),{avgTopDepth:avgTopDepth})])}),[])},GeomodelLabelsLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event)},GeomodelLabelsLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.render()},GeomodelLabelsLayer.prototype.onRescale=function(event){this.rescaleEvent=event,this.updateXFlipped(),this.resetTransform(),this.render()},GeomodelLabelsLayer.prototype.render=function(){var _this=this;this.rescaleEvent&&requestAnimationFrame((function(){_this.clearCanvas(),_this.data&&(_this.areasWithAvgTopDepth||_this.generateSurfacesWithAvgDepth(),_this.drawAreaLabels(),_this.drawLineLabels())}))},GeomodelLabelsLayer.prototype.drawAreaLabels=function(){var _this=this;this.areasWithAvgTopDepth.forEach((function(s,i,array){var topmostSurfaceNotDrawnYet=array.reduce((function(acc,v,index){return index>i&&(null==acc||v.avgTopDepth<acc.avgTopDepth)&&(acc=v),acc}),null);_this.drawAreaLabel(s,topmostSurfaceNotDrawnYet,array,i)}))},GeomodelLabelsLayer.prototype.drawLineLabels=function(){var _this=this;this.data.lines.filter((function(surfaceLine){return surfaceLine.label})).forEach((function(surfaceLine){return _this.drawLineLabel(surfaceLine)}))},GeomodelLabelsLayer.prototype.colorToCSSColor=function(color){if("string"==typeof color)return color;var hexString=color.toString(16);return"#"+(hexString="000000".substr(0,6-hexString.length)+hexString)},GeomodelLabelsLayer.prototype.calcPos=function(data,offset,count,step,topLimit,bottomLimit,alternativeSurfaceData,surfaces,currentSurfaceIndex){void 0===topLimit&&(topLimit=null),void 0===bottomLimit&&(bottomLimit=null),void 0===alternativeSurfaceData&&(alternativeSurfaceData=null),void 0===surfaces&&(surfaces=null),void 0===currentSurfaceIndex&&(currentSurfaceIndex=null);for(var pos=Vector2.zero.mutable,samples=0,i=0;i<count;i++){var x=offset+i*step,y=findSampleAtPos(data,x,topLimit,bottomLimit);if(y){var alternativeY=this.getAlternativeYValueIfAvailable(x,topLimit,bottomLimit,alternativeSurfaceData,surfaces,currentSurfaceIndex),usedY=alternativeY?Math.min(y,alternativeY):y;pos.add(x,usedY),samples++}}return 0===samples?null:Vector2.divide(pos,samples)},GeomodelLabelsLayer.prototype.getAlternativeYValueIfAvailable=function(x,topLimit,bottomLimit,alternativeSurfaceData,surfaces,currentSurfaceIndex){if(!alternativeSurfaceData)return null;var altY=findSampleAtPos(alternativeSurfaceData,x,topLimit,bottomLimit);if(null==altY&&surfaces&&null!=currentSurfaceIndex)for(var si=currentSurfaceIndex+1;null==altY&&si<surfaces.length;){altY=findSampleAtPos(surfaces[si++].data.map((function(d){return[d[0],d[1]]})),x,topLimit,bottomLimit)}return altY},GeomodelLabelsLayer.prototype.calcLineDir=function(data,offset,count,step,zFactor,initalVector,topLimit,bottomLimit){void 0===initalVector&&(initalVector=Vector2.left),void 0===topLimit&&(topLimit=null),void 0===bottomLimit&&(bottomLimit=null);var dir=initalVector.mutable,startY=findSampleAtPos(data,offset,topLimit,bottomLimit);if(null===startY)return dir;for(var vecAtEnd=new Vector2(offset,startY*zFactor),tmpVec=Vector2.zero.mutable,i=1;i<=count;i++){var x=offset+i*step,y=findSampleAtPos(data,offset,topLimit,bottomLimit);null!==y&&(tmpVec.set(x,y*zFactor),tmpVec.sub(vecAtEnd),dir.add(tmpVec))}return dir},GeomodelLabelsLayer.prototype.calcAreaDir=function(top,bottom,offset,count,step,initalVector,topLimit,bottomLimit,minReductionAngle,maxReductionAngle,angleReductionExponent,alternativeSurfaceBottomData,surfaces,currentSurfaceIndex){void 0===initalVector&&(initalVector=Vector2.left),void 0===topLimit&&(topLimit=null),void 0===bottomLimit&&(bottomLimit=null),void 0===minReductionAngle&&(minReductionAngle=0),void 0===maxReductionAngle&&(maxReductionAngle=Math.PI/4),void 0===angleReductionExponent&&(angleReductionExponent=4),void 0===alternativeSurfaceBottomData&&(alternativeSurfaceBottomData=null),void 0===surfaces&&(surfaces=null),void 0===currentSurfaceIndex&&(currentSurfaceIndex=null);for(var vecAtEnd,angles=[],tmpVec=Vector2.zero.mutable,i=0;i<=count;i++){var x=offset+i*step,topY=findSampleAtPos(top,x,topLimit,bottomLimit),bottomY=findSampleAtPos(bottom,x,topLimit,bottomLimit)||bottomLimit,alternativeBottomY=this.getAlternativeYValueIfAvailable(x,topLimit,bottomLimit,alternativeSurfaceBottomData,surfaces,currentSurfaceIndex),usedBottomY=alternativeBottomY?Math.min(bottomY,alternativeBottomY):bottomY;if(0===i){if(null===topY)return Vector2.angleRight(initalVector);vecAtEnd=new Vector2(offset,(topY+usedBottomY)/2)}else null!==topY?(tmpVec.set(x,(topY+usedBottomY)/2),tmpVec.sub(vecAtEnd),angles.push(Vector2.angleRight(tmpVec))):angles.push(Vector2.angleRight(initalVector))}var refAngle=angles[0],offsetAngles=angles.map((function(d){return d-refAngle})),factors=0;return offsetAngles.reduce((function(acc,v){var ratio=(Math.abs(v)-minReductionAngle)/maxReductionAngle,factor=Math.pow(1-clamp(ratio,0,1),angleReductionExponent);return factors+=factor,acc+v*factor}),0)/factors+refAngle},GeomodelLabelsLayer.prototype.updateXFlipped=function(){var xBounds=this.rescaleEvent.xBounds;this.isXFlipped=xBounds[0]>xBounds[1]},GeomodelLabelsLayer.prototype.getMarginsInWorldCoordinates=function(){var xRatio=this.rescaleEvent.xRatio;return(this.options.margins||this.defaultMargins)*(this.isXFlipped?-1:1)/xRatio},GeomodelLabelsLayer.prototype.getSurfacesAreaEdges=function(){var data=this.data.areas[0].data,maxX=Math.max(data[data.length-1][0],data[0][0]),minX=Math.min(data[0][0],data[data.length-1][0]),marginsInWorldCoords=this.getMarginsInWorldCoordinates(),isXFlipped=this.isXFlipped;return[isXFlipped?maxX+marginsInWorldCoords:minX+marginsInWorldCoords,isXFlipped?minX-marginsInWorldCoords:maxX-marginsInWorldCoords]},GeomodelLabelsLayer.prototype.checkDrawLabelsOnLeftSide=function(){var referenceSystem=this.referenceSystem,isXFlipped=this.isXFlipped;if(!referenceSystem)return!0;var _b=this.rescaleEvent,xScale=_b.xScale,yScale=_b.yScale,xRatio=_b.xRatio,_c=xScale.domain(),dx1=_c[0],dx2=_c[1],_d=yScale.domain(),dy1=_d[0],dy2=_d[1],top=referenceSystem.interpolators.curtain.lookup(dy1,1,0);0===top.length&&(top=[referenceSystem.interpolators.curtain.getPointAt(0)]);var bottom=referenceSystem.interpolators.curtain.lookup(dy2,1,0);0===bottom.length&&(bottom=[referenceSystem.interpolators.curtain.getPointAt(1)]);var maxX=Math.max(top[0][0],bottom[0][0]),minX=Math.min(top[0][0],bottom[0][0]),wbBBox_left=isXFlipped?maxX:minX,wbBBox_right=isXFlipped?minX:maxX,margin=this.getMarginsInWorldCoordinates(),screenLeftEdge=dx1+margin,screenRightEdge=dx2-margin,_e=this.getSurfacesAreaEdges(),surfaceAreaLeftEdge=_e[0],surfaceAreaRightEdge=_e[1],leftLimit=isXFlipped?Math.min(screenLeftEdge,surfaceAreaLeftEdge):Math.max(screenLeftEdge,surfaceAreaLeftEdge),rightLimit=isXFlipped?Math.max(screenRightEdge,surfaceAreaRightEdge):Math.min(screenRightEdge,surfaceAreaRightEdge),spaceOnLeftSide=Math.max(isXFlipped?leftLimit-wbBBox_left:wbBBox_left-leftLimit,0),spaceOnRightSide=Math.max(isXFlipped?wbBBox_right-rightLimit:rightLimit-wbBBox_right,0),spaceOnLeftSideInScreenCoordinates=spaceOnLeftSide*xRatio;return spaceOnLeftSide>spaceOnRightSide||spaceOnLeftSideInScreenCoordinates>200||spaceOnLeftSideInScreenCoordinates<200&&spaceOnRightSide*xRatio<200&&isXFlipped||bottom[1]<dy1},GeomodelLabelsLayer}(CanvasLayer);function pixelsPerUnit(x){var min=x.domain()[0];return Math.abs(x(min+1))}function calcSize(factor,min,max,x){return clamp(pixelsPerUnit(x)*factor,min,max)}function isOverlapping(r1,r2,horizontalPadding,verticalPadding){void 0===horizontalPadding&&(horizontalPadding=4),void 0===verticalPadding&&(verticalPadding=2);var r1x2=r1.x+r1.width+horizontalPadding,r2x2=r2.x+r2.width+horizontalPadding,r1y2=r1.y+r1.height+verticalPadding,r2y2=r2.y+r2.height+verticalPadding;return!(r2.x-horizontalPadding>r1x2||r2.y-verticalPadding>r1y2||r2x2+horizontalPadding<r1.x||r2y2+verticalPadding<r1.y)}function getOverlapOffset(r1,r2,horizontalPadding,verticalPadding){void 0===horizontalPadding&&(horizontalPadding=4),void 0===verticalPadding&&(verticalPadding=2);var r1x2=r1.x+r1.width,r2x2=r2.x+r2.width,r1y2=r1.y+r1.height,r2y2=r2.y+r2.height;return r2.x-horizontalPadding>r1x2||r2.y-verticalPadding>r1y2||r2x2+horizontalPadding<r1.x||r2y2+verticalPadding<r1.y?null:{dx:r1.x+r1.width-r2.x+horizontalPadding,dy:r1.y+r1.height-r2.y+verticalPadding}}var Location_topleft="topleft",Location_topright="topright",Location_bottomleft="bottomleft",Location_bottomright="bottomright",CalloutCanvasLayer=function(_super){function CalloutCanvasLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.groupFilter=null,_this.renderAnnotation=function(title,label,x,y,fontSize,color){_this.renderText(title,x,y-fontSize,fontSize,color,"arial","bold"),_this.renderText(label,x,y,fontSize,color)},_this.renderLine=function(x,y,width,dotX,dotY,color,placeLeft){void 0===placeLeft&&(placeLeft=!0);var ctx=_this.ctx,textX=placeLeft?x:x+width,inverseTextX=placeLeft?x+width:x,textY=y+2;ctx.strokeStyle=color,ctx.lineWidth=1,ctx.beginPath(),ctx.moveTo(dotX,dotY),ctx.lineTo(textX,textY),ctx.lineTo(inverseTextX,textY),ctx.stroke()},_this.minFontSize=options.minFontSize||7,_this.maxFontSize=options.maxFontSize||11,_this.fontSizeFactor=options.fontSizeFactor||7,_this.offsetMin=options.offsetMin||20,_this.offsetMax=options.offsetMax||120,_this.offsetFactor=options.offsetFactor||19,_this}return __extends(CalloutCanvasLayer,_super),CalloutCanvasLayer.prototype.setGroupFilter=function(filter){this.groupFilter=filter,this.callouts=void 0,this.render()},CalloutCanvasLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.callouts=void 0,this.render()},CalloutCanvasLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event);var isPanning=this.rescaleEvent&&this.rescaleEvent.xRatio===event.xRatio;this.rescaleEvent=event,this.render(isPanning)},CalloutCanvasLayer.prototype.render=function(isPanning){var _this=this;void 0===isPanning&&(isPanning=!1),requestAnimationFrame((function(){if(_this.clearCanvas(),_this.data&&_this.rescaleEvent&&_this.referenceSystem){var _a=_this.rescaleEvent,xScale=_a.xScale,yScale=_a.yScale,xBounds=_a.xBounds,fontSize=calcSize(_this.fontSizeFactor,_this.minFontSize,_this.maxFontSize,xScale);if(!isPanning||!_this.callouts){var _b=_this,data=_b.data,ctx=_b.ctx,groupFilter_1=_b.groupFilter,isLeftToRight=_this.referenceSystem.options.calculateDisplacementFromBottom?xBounds[0]<xBounds[1]:xBounds[0]>xBounds[1];ctx.font="bold "+fontSize+"px arial";var filtered=data.filter((function(d){return!groupFilter_1||groupFilter_1.includes(d.group)})),offset=calcSize(_this.offsetFactor,_this.offsetMin,_this.offsetMax,xScale);_this.callouts=_this.positionCallouts(filtered,isLeftToRight,xScale,yScale,0,fontSize,offset)}_this.callouts.forEach((function(callout){var pos=callout.pos,title=callout.title,color=callout.color,calloutBB={x:xScale(pos.x),y:yScale(pos.y),width:callout.boundingBox.width,height:fontSize,offsetX:callout.dx,offsetY:callout.dy};_this.renderCallout(title,callout.label,calloutBB,color,callout.alignment)}))}}))},CalloutCanvasLayer.prototype.renderText=function(title,x,y,fontSize,color,font,fontStyle){void 0===font&&(font="arial"),void 0===fontStyle&&(fontStyle="normal");var ctx=this.ctx;ctx.font=fontStyle+" "+fontSize+"px "+font,ctx.fillStyle=color,ctx.fillText(title,x,y)},CalloutCanvasLayer.prototype.renderPoint=function(x,y,radius){void 0===radius&&(radius=3);var ctx=this.ctx;ctx.beginPath(),ctx.moveTo(x,y),ctx.arc(x,y,radius,0,2*Math.PI),ctx.fill()},CalloutCanvasLayer.prototype.renderCallout=function(title,label,boundingBox,color,location){var pos=this.getPosition(boundingBox,location),x=pos.x,y=pos.y,height=boundingBox.height,width=boundingBox.width,dotX=boundingBox.x,dotY=boundingBox.y,placeLeft=location===Location_topright||location===Location_bottomright;this.renderAnnotation(title,label,x,y,height,color),this.renderPoint(dotX,dotY),this.renderLine(x,y,width,dotX,dotY,color,placeLeft)},CalloutCanvasLayer.prototype.getPosition=function(boundingBox,location){var x=boundingBox.x,y=boundingBox.y,offsetX=boundingBox.offsetX,offsetY=boundingBox.offsetY,width=boundingBox.width;switch(location){case Location_topleft:return{x:x-width-offsetX,y:y-offsetY};case Location_topright:return{x:x+offsetX,y:y-offsetY};case Location_bottomleft:return{x:x-width-offsetX,y:y+offsetY};case Location_bottomright:return{x:x+offsetX,y:y+offsetY};default:return{x:x,y:y}}},CalloutCanvasLayer.prototype.positionCallouts=function(annotations,isLeftToRight,xScale,yScale,scale,fontSize,offset){var _this=this;if(void 0===offset&&(offset=20),0===annotations.length)return[];var alignment=isLeftToRight?Location_topleft:Location_topright,nodes=annotations.map((function(a){var pos=a.pos?a.pos:_this.referenceSystem.project(a.md);return{title:a.title,label:a.label,color:a.color,pos:{x:pos[0],y:pos[1]},group:a.group,alignment:alignment,boundingBox:_this.getAnnotationBoundingBox(a.title,a.label,pos,xScale,yScale,fontSize),dx:offset,dy:offset}})),top=[nodes[nodes.length-1]],bottom=[];return this.chooseTopOrBottomPosition(nodes,bottom,top),this.adjustTopPositions(top),this.adjustBottomPositions(bottom),nodes},CalloutCanvasLayer.prototype.getAnnotationBoundingBox=function(title,label,pos,xScale,yScale,height){var ctx=this.ctx,ax1=xScale(pos[0]),ay1=yScale(pos[1]),labelWidth=ctx.measureText(label).width,titleWidth=ctx.measureText(title).width;return{x:ax1,y:ay1,width:Math.max(labelWidth,titleWidth),height:2*height+4}},CalloutCanvasLayer.prototype.chooseTopOrBottomPosition=function(nodes,bottom,top){for(var i=nodes.length-2;i>=0;--i){var node=nodes[i],prevNode=top[0];isOverlapping(node.boundingBox,prevNode.boundingBox)?(node.alignment=node.alignment===Location_topleft?Location_bottomright:Location_bottomleft,bottom.push(node),i>0&&top.unshift(nodes[--i])):top.unshift(node)}},CalloutCanvasLayer.prototype.adjustTopPositions=function(top){for(var i=top.length-2;i>=0;--i)for(var currentNode=top[i],j=top.length-1;j>i;--j){var prevNode=top[j],overlap=getOverlapOffset(currentNode.boundingBox,prevNode.boundingBox);overlap&&(currentNode.dy+=overlap.dy,currentNode.boundingBox.y-=overlap.dy)}},CalloutCanvasLayer.prototype.adjustBottomPositions=function(bottom){for(var i=bottom.length-2;i>=0;--i)for(var currentNode=bottom[i],j=bottom.length-1;j>i;--j){var overlap=getOverlapOffset(bottom[j].boundingBox,currentNode.boundingBox);overlap&&(currentNode.dy+=overlap.dy,currentNode.boundingBox.y+=overlap.dy)}},CalloutCanvasLayer}(CanvasLayer),ImageLayer=function(_super){function ImageLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(ImageLayer,_super),ImageLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event);var img=document.createElement("img");this.img=img,this.isLoading=!0},ImageLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.img.src=event.url,this.render(event)},ImageLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.setTransform(event),this.render(event)},ImageLayer.prototype.render=function(event){var _this=this,width=parseInt(this.elm.getAttribute("width"),10),height=parseInt(this.elm.getAttribute("height"),10),xScale=event.xScale,yScale=event.yScale,xRatio=event.xRatio,yRatio=event.yRatio,x=event.x,y=event.y,calcWidth=width*(xRatio||1),calcHeight=height*(yRatio||1);this.clearCanvas(),this.isLoading?this.img.onload=function(){_this.isLoading=!1,_this.ctx.drawImage(_this.img,xScale(x||0),yScale(y||0),calcWidth,calcHeight)}:this.ctx.drawImage(this.img,xScale(x||0),yScale(y||0),calcWidth,calcHeight)},ImageLayer}(CanvasLayer),WellboreBaseComponentLayer=function(_super){function WellboreBaseComponentLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.getMdPoint=function(md){return{point:_this.referenceSystem.project(md),md:md}},_this.getPathForPoints=function(start,end,interestPoints){var pathPoints=_this.referenceSystem.getCurtainPath(start,end),interestMdPoints=interestPoints.filter((function(ip){return!pathPoints.some((function(p){return p.md===ip}))})).map(_this.getMdPoint),points=__spreadArray(__spreadArray([],pathPoints),interestMdPoints);return points.sort((function(a,b){return a.md-b.md})),points},_this.getZFactorScaledPathForPoints=function(start,end,interestPoints){var y=function(y){return y*_this.rescaleEvent.zFactor};return _this.getPathForPoints(start,end,interestPoints).map((function(p){return{point:[p.point[0],y(p.point[1])],md:p.md}}))},_this.drawBigPolygon=function(coords,color){void 0===color&&(color=0);var polygon=new Graphics;return polygon.beginFill(color),polygon.drawPolygon(coords),polygon.endFill(),_this.ctx.stage.addChild(polygon),polygon},_this.drawBigTexturedPolygon=function(coords,t){var polygon=new Graphics;return polygon.beginTextureFill({texture:t}),polygon.drawPolygon(coords),polygon.endFill(),_this.ctx.stage.addChild(polygon),polygon},_this.options=__assign(__assign(__assign({},_this.options),{exaggerationFactor:2}),options),_this.render=_this.render.bind(_this),_this}return __extends(WellboreBaseComponentLayer,_super),WellboreBaseComponentLayer.prototype.onUnmount=function(event){_super.prototype.onUnmount.call(this,event),this._textureCache=null,this.rescaleEvent=null},WellboreBaseComponentLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.clear(),this.render()},WellboreBaseComponentLayer.prototype.onRescale=function(event){var _a,shouldRender=(null===(_a=this.rescaleEvent)||void 0===_a?void 0:_a.zFactor)!==event.zFactor;if(this.rescaleEvent=event,_super.prototype.optionsRescale.call(this,event),this.ctx){var yRatio=this.yRatio(),flippedX=event.xBounds[0]>event.xBounds[1],flippedY=event.yBounds[0]>event.yBounds[1];this.ctx.stage.position.set(event.xScale(0),event.yScale(0)),this.ctx.stage.scale.set(event.xRatio*(flippedX?-1:1),yRatio*(flippedY?-1:1)),shouldRender&&(this.clear(),this.render())}},WellboreBaseComponentLayer.prototype.clear=function(){this.ctx.stage.removeChildren().forEach((function(child){child.destroy()}))},WellboreBaseComponentLayer.prototype.yRatio=function(){var domain=this.rescaleEvent.yScale.domain(),baseYSpan=(domain[1]-domain[0])*this.rescaleEvent.zFactor,baseDomain=[domain[0],domain[0]+baseYSpan];return Math.abs(this.rescaleEvent.height/(baseDomain[1]-baseDomain[0]))},WellboreBaseComponentLayer.prototype.drawRopeWithMask=function(path,maskPolygon,texture){if(0===maskPolygon.length||0===path.length)return null;var rope=new SimpleRope(texture,path,1),mask=new Graphics;mask.beginFill(0),mask.drawPolygon(maskPolygon),mask.endFill(),this.ctx.stage.addChild(mask),rope.mask=mask,this.ctx.stage.addChild(rope)},WellboreBaseComponentLayer.prototype.drawRope=function(path,texture,tint){if(0===path.length)return null;var rope=new SimpleRope(texture,path,1);rope.tint=tint||rope.tint,this.ctx.stage.addChild(rope)},WellboreBaseComponentLayer.prototype.drawOutline=function(leftPath,rightPath,lineColor,lineWidth,close){void 0===lineWidth&&(lineWidth=1),void 0===close&&(close=!1);var leftPathReverse=leftPath.map((function(d){return d.clone()})).reverse(),startPointRight=rightPath[0],startPointLeft=leftPathReverse[0],line=new Graphics;line.lineStyle(lineWidth,lineColor,void 0,1),line.moveTo(startPointRight.x,startPointRight.y),rightPath.forEach((function(p){return line.lineTo(p.x,p.y)})),close||line.moveTo(startPointLeft.x,startPointLeft.y),leftPathReverse.forEach((function(p){return line.lineTo(p.x,p.y)})),close&&line.lineTo(startPointRight.x,startPointRight.y),this.ctx.stage.addChild(line)},WellboreBaseComponentLayer}(PixiLayer),makeTubularPolygon=function(rightPath,leftPath){return __spreadArray(__spreadArray([],leftPath),rightPath.map((function(d){return d.clone()})).reverse())},overlaps=function(top1,bottom1,top2,bottom2){return top1<=bottom2&&top2<=bottom1},cementDiameterChangeDepths=function(cement,bottomOfCement,diameterIntervals){var arrays,arr,topOfCement=cement.toc,diameterChangeDepths=(arrays=diameterIntervals.map((function(d){return[d.start-1e-4,d.start,d.end,d.end+1e-4]})),Array.from(function*(arrays){for(const array of arrays)yield*array}(arrays))).filter((function(d){return d>=topOfCement&&d<=bottomOfCement}));return diameterChangeDepths.push(topOfCement),diameterChangeDepths.push(bottomOfCement),(arr=diameterChangeDepths,Array.from(new Set(arr))).sort((function(a,b){return a-b}))},arrayToVector=function(a){return new Vector2(a[0],a[1])},createNormals=function(points){return points.length<2?[new Vector2(0)]:points.map((function(coord,i,list){if(i<list.length-1){var p=arrayToVector(list[i]),rotate=arrayToVector(list[i+1]).sub(p).rotate90();return n=rotate.normalized()}return n}));var n},offsetPoint=function(point,vector,offset){var v,p=arrayToVector(point);return v=p.add(vector.scale(offset)),new Point(v[0],v[1])},offsetPoints=function(points,vectors,offset){if(points.length!==vectors.length)throw new Error("Number of vectors does not match number of points");return points.map((function(point,index){var vector=vectors[index];return offsetPoint(point,vector,offset)}))},HoleSizeLayer=function(_super){function HoleSizeLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.drawHoleSize=function(holeObject){if(null!=holeObject){var _a=_this.options,exaggerationFactor=_a.exaggerationFactor,firstColor=_a.firstColor,lineColor=_a.lineColor,diameter=holeObject.diameter*exaggerationFactor,radius=diameter/2,pathPoints=_this.getZFactorScaledPathForPoints(holeObject.start,holeObject.end,[holeObject.start,holeObject.end]).map((function(p){return p.point})),normals=createNormals(pathPoints),rightPath=offsetPoints(pathPoints,normals,radius),leftPath=offsetPoints(pathPoints,normals,-radius);if(0!==pathPoints.length){if(_this.renderType()===RENDERER_TYPE.CANVAS){var polygonCoords=makeTubularPolygon(leftPath,rightPath);_this.drawBigPolygon(polygonCoords,convertColor(firstColor))}else{var texture=_this.createTexture(diameter);_this.drawRope(pathPoints.map((function(p){return new Point(p[0],p[1])})),texture)}_this.drawOutline(leftPath,rightPath,lineColor,1,!1)}}},_this.options=__assign(__assign(__assign({},_this.options),{firstColor:"rgb(140, 84, 29)",secondColor:"rgb(238, 227, 216)",lineColor:9127187}),options),_this}return __extends(HoleSizeLayer,_super),HoleSizeLayer.prototype.render=function(){var _this=this,data=this.data;data&&this.rescaleEvent&&this.referenceSystem&&(data.sort((function(a,b){return b.diameter-a.diameter})),this.maxDiameter=data.length>0?data[0].diameter:100,data.forEach((function(hole){return _this.drawHoleSize(hole)})))},HoleSizeLayer.prototype.createTexture=function(diameter){var exaggerationFactor=this.options.exaggerationFactor,height=this.maxDiameter*exaggerationFactor;this._textureCache||(this._textureCache=this.createBaseTexture(16,height));var baseTexture=this._textureCache.baseTexture,sidePadding=Math.floor((height-diameter)/2),frame=new Rectangle(0,sidePadding,16,diameter);return new Texture(baseTexture,frame)},HoleSizeLayer.prototype.createBaseTexture=function(width,height){var _a=this.options,firstColor=_a.firstColor,secondColor=_a.secondColor,canvas=document.createElement("canvas");canvas.width=width,canvas.height=height;var canvasCtx=canvas.getContext("2d");return canvasCtx.fillStyle=function(canvas,canvasCtx,firstColor,secondColor,startPctOffset){var gradient=canvasCtx.createLinearGradient(0,0,0,canvas.height);return gradient.addColorStop(0,firstColor),gradient.addColorStop(.5-startPctOffset,secondColor),gradient.addColorStop(.5+startPctOffset,secondColor),gradient.addColorStop(1,firstColor),gradient}(canvas,canvasCtx,firstColor,secondColor,0),canvasCtx.fillRect(0,0,canvas.width,canvas.height),Texture.from(canvas)},HoleSizeLayer}(WellboreBaseComponentLayer),CasingLayer=function(_super){function CasingLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.prepareCasingRenderObject=function(casing){if(null!=casing){var exaggerationFactor=_this.options.exaggerationFactor,diameter=casing.diameter*exaggerationFactor,radius=diameter/2,innerRadius=casing.innerDiameter*exaggerationFactor/2,pathPoints=_this.getZFactorScaledPathForPoints(casing.start,casing.end,[casing.start,casing.end]).map((function(p){return p.point})),normals=createNormals(pathPoints),rightPath=offsetPoints(pathPoints,normals,radius),leftPath=offsetPoints(pathPoints,normals,-radius);return{pathPoints:pathPoints,polygon:makeTubularPolygon(leftPath,rightPath),leftPath:leftPath,rightPath:rightPath,radius:radius,diameter:diameter,casingWallWidth:Math.abs(radius-innerRadius)}}},_this.drawCasing=function(zippedRenderObject){var _a=_this.options,lineColor=_a.lineColor,solidColor=_a.solidColor,casing=zippedRenderObject[0],_b=zippedRenderObject[1],pathPoints=_b.pathPoints,polygon=_b.polygon,leftPath=_b.leftPath,rightPath=_b.rightPath,radius=_b.radius,diameter=_b.diameter,casingWallWidth=_b.casingWallWidth;if(_this.renderType()===RENDERER_TYPE.CANVAS)_this.drawBigPolygon(polygon,solidColor);else{var texture=_this.createTexture(diameter);_this.drawRope(pathPoints.map((function(p){return new Point(p[0],p[1])})),texture,solidColor)}_this.drawOutline(leftPath,rightPath,lineColor,casingWallWidth,!0),casing.hasShoe&&_this.drawShoe(casing.end,radius)},_this.generateShoe=function(casingEnd,casingRadius,length,width){var start=casingEnd-length,end=casingEnd,points=_this.getZFactorScaledPathForPoints(start,end,[start,end]).map((function(p){return p.point})),normal=createNormals(points),shoeEdge=offsetPoints(points,normal,casingRadius*(width<0?-1:1)),shoeTipPoint=points[points.length-1],shoeTipNormal=normal[normal.length-1],shoeTip=offsetPoint(shoeTipPoint,shoeTipNormal,width);return __spreadArray(__spreadArray([],shoeEdge),[shoeTip])},_this.options=__assign(__assign(__assign({},_this.options),{solidColor:14474460,lineColor:5723991}),options),_this}return __extends(CasingLayer,_super),CasingLayer.prototype.render=function(){var _this=this,data=this.data;if(data&&this.rescaleEvent&&this.referenceSystem){var sortedCasings=data.sort((function(a,b){return b.diameter-a.diameter})),casingRenderObjects=sortedCasings.map((function(casing){return _this.prepareCasingRenderObject(casing)}));(function(){return transpose(arguments)})(sortedCasings,casingRenderObjects).forEach((function(zippedRenderObject){return _this.drawCasing(zippedRenderObject)}))}},CasingLayer.prototype.drawShoe=function(casingEnd,casingRadius){var exaggerationFactor=this.options.exaggerationFactor,shoeWidth=25*exaggerationFactor,shoeLength=12*exaggerationFactor,shoeCoords=this.generateShoe(casingEnd,casingRadius,shoeLength,shoeWidth),shoeCoords2=this.generateShoe(casingEnd,casingRadius,shoeLength,-shoeWidth);this.drawBigPolygon(shoeCoords2),this.drawBigPolygon(shoeCoords)},CasingLayer.prototype.createTexture=function(diameter){return new Texture(Texture.WHITE.baseTexture,null,new Rectangle(0,0,16,diameter))},CasingLayer}(WellboreBaseComponentLayer),CementLayer=function(_super){function CementLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.createCementShape=function(cement,casings,holes){var exaggerationFactor=_this.options.exaggerationFactor,attachedCasings=__spreadArray([cement.casingId],cement.casingIds||[]).filter((function(id){return id})).map((function(casingId){return casings.find((function(casing){return casing.casingId===casingId}))}));if(0===attachedCasings.length||attachedCasings.includes(void 0))throw new Error("Invalid cement data, cement is missing attached casing");attachedCasings.sort((function(a,b){return a.end-b.end}));for(var bottomOfCement=attachedCasings[attachedCasings.length-1].end,_a=function(cement,bottomOfCement,parentCasings,casings,holes){var start=cement.toc,end=bottomOfCement;return{holes:holes.filter((function(h){return overlaps(start,end,h.start,h.end)})),outerCasings:casings.filter((function(c){return!parentCasings.includes(c)})).filter((function(c){return overlaps(start,end,c.start,c.end)}))}}(cement,bottomOfCement,attachedCasings,casings,holes),outerCasings=_a.outerCasings,overlappingHoles=_a.holes,innerDiameterIntervals=attachedCasings,outerDiameterIntervals=__spreadArray(__spreadArray([],outerCasings),overlappingHoles).map((function(d){return{start:d.start,end:d.end}})),diameterAtChangeDepths=cementDiameterChangeDepths(cement,bottomOfCement,__spreadArray(__spreadArray([],innerDiameterIntervals),outerDiameterIntervals)).map(function(innerCasing,nonAttachedCasings,holes){return function(depth){var outerDiameter,innerCasingAtDepth=innerCasing.find((function(casing){return casing.start<=depth&&casing.end>=depth})),innerDiameter=innerCasingAtDepth?innerCasingAtDepth.diameter:0,outerCasings=nonAttachedCasings.filter((function(casing){return casing.innerDiameter>innerDiameter})),holeAtDepth=holes.find((function(hole){return hole.start<=depth&&hole.end>=depth&&hole.diameter>innerDiameter})),outerCasingAtDepth=outerCasings.filter((function(d){return d})).sort((function(a,b){return a.innerDiameter-b.innerDiameter})).find((function(casing){return casing.start<=depth&&casing.end>=depth&&casing.diameter>innerDiameter}));return outerDiameter=outerCasingAtDepth?outerCasingAtDepth.innerDiameter:holeAtDepth?holeAtDepth.diameter-1:100,{md:depth,innerDiameter:innerDiameter,outerDiameter:outerDiameter}}}(attachedCasings,outerCasings,overlappingHoles)),path=_this.getZFactorScaledPathForPoints(cement.toc,bottomOfCement,diameterAtChangeDepths.map((function(d){return d.md}))),normals=createNormals(path.map((function(p){return p.point}))),pathWithNormals=path.map((function(p,i){return __assign(__assign({},p),{normal:normals[i]})})),side1Left=[],side1Right=[],side2Left=[],side2Right=[],previousDepth=diameterAtChangeDepths.shift(),_loop_1=function(depth){var intervalMdPoints=pathWithNormals.filter((function(x){return x.md>=previousDepth.md&&x.md<=depth.md})),intervalPoints=intervalMdPoints.map((function(s){return s.point})),intervalPointNormals=intervalMdPoints.map((function(s){return s.normal})),outerRadius=previousDepth.outerDiameter/2*exaggerationFactor,innerRadius=previousDepth.innerDiameter/2*exaggerationFactor,intervalSide1Left=offsetPoints(intervalPoints,intervalPointNormals,outerRadius),intervalSide1Right=offsetPoints(intervalPoints,intervalPointNormals,innerRadius),intervalSide2Left=offsetPoints(intervalPoints,intervalPointNormals,-innerRadius),intervalSide2Right=offsetPoints(intervalPoints,intervalPointNormals,-outerRadius);side1Left.push.apply(side1Left,intervalSide1Left),side1Right.push.apply(side1Right,intervalSide1Right),side2Left.push.apply(side2Left,intervalSide2Left),side2Right.push.apply(side2Right,intervalSide2Right),previousDepth=depth},_i=0,diameterAtChangeDepths_1=diameterAtChangeDepths;_i<diameterAtChangeDepths_1.length;_i++){_loop_1(diameterAtChangeDepths_1[_i])}var pathPoints=pathWithNormals.map((function(p){return new Point(p.point[0],p.point[1])}));return{leftPolygon:makeTubularPolygon(side1Left,side1Right),rightPolygon:makeTubularPolygon(side2Left,side2Right),path:pathPoints}},_this.options=__assign(__assign(__assign({},_this.options),{firstColor:"#c7b9ab",secondColor:"#5b5b5b"}),options),_this}return __extends(CementLayer,_super),CementLayer.prototype.render=function(){var _this=this;if(this.data&&this.rescaleEvent&&this.referenceSystem){var _a=this.data,cement=_a.cement,casings=_a.casings,holes=_a.holes,cementShapes=cement.map((function(cement){return _this.createCementShape(cement,casings,holes)})),texture=this.createTexture();cementShapes.forEach((function(cementShape){_this.renderType()===RENDERER_TYPE.CANVAS?(_this.drawBigTexturedPolygon(cementShape.leftPolygon,texture),_this.drawBigTexturedPolygon(cementShape.rightPolygon,texture)):(_this.drawRopeWithMask(cementShape.path,cementShape.leftPolygon,texture),_this.drawRopeWithMask(cementShape.path,cementShape.rightPolygon,texture))}))}},CementLayer.prototype.createTexture=function(){if(this._textureCache)return this._textureCache;var _a=this.options,firstColor=_a.firstColor,secondColor=_a.secondColor,canvas=document.createElement("canvas");canvas.width=150,canvas.height=150;var canvasCtx=canvas.getContext("2d");canvasCtx.fillStyle=firstColor,canvasCtx.fillRect(0,0,canvas.width,canvas.height),canvasCtx.lineWidth=1,canvasCtx.fillStyle=secondColor,canvasCtx.beginPath(),canvasCtx.lineWidth=1;for(var i=-canvas.width;i<canvas.width;i++)canvasCtx.moveTo(-canvas.width+10*i,-canvas.height),canvasCtx.lineTo(canvas.width+10*i,canvas.height);return canvasCtx.stroke(),this._textureCache=Texture.from(canvas),this._textureCache},CementLayer}(WellboreBaseComponentLayer),SeismicCanvasLayer=function(_super){function SeismicCanvasLayer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(SeismicCanvasLayer,_super),SeismicCanvasLayer.prototype.onMount=function(event){_super.prototype.onMount.call(this,event)},SeismicCanvasLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.clearCanvas(),this.render()},SeismicCanvasLayer.prototype.onRescale=function(event){_super.prototype.onRescale.call(this,event),this.setTransform(event),this.render()},SeismicCanvasLayer.prototype.render=function(){if(this.data&&this.ctx&&this.data.image){var ctx=this.ctx,_a=this.data,options=_a.options,image=_a.image;this.clearCanvas(),ctx.drawImage(image,options.x,options.y,options.width,options.height)}},SeismicCanvasLayer}(CanvasLayer),CompletionLayer=function(_super){function CompletionLayer(id,options){var _this=_super.call(this,id,options)||this;return _this.options=__assign(__assign({},_this.options),options),_this.render=_this.render.bind(_this),_this}return __extends(CompletionLayer,_super),CompletionLayer.prototype.onUpdate=function(event){_super.prototype.onUpdate.call(this,event),this.render()},CompletionLayer.prototype.render=function(){var _a,_this=this,wellborePath=this.referenceSystem?this.referenceSystem.projectedPath:[];null!=wellborePath&&((null===(_a=this.data)||void 0===_a?void 0:_a.length)>0?this.data.map((function(d){return _this.generateCompletionItem(wellborePath,d)})):[]).map((function(s){return _this.drawCompletionItem(s)}))},CompletionLayer.prototype.getShape=function(type){var graphics=new Graphics;return graphics.beginFill(3421236),graphics.drawRect(-5,-5,10,10),graphics.endFill(),graphics},CompletionLayer.prototype.getScale=function(type,length,width){return{scaleX:1,scaleY:1}},CompletionLayer.prototype.generateCompletionItem=function(wbp,data){if(this.referenceSystem){var pointTop=this.referenceSystem.project(data.start),pointBottom=this.referenceSystem.project(data.end),rotation=Vector2.angle(pointTop,pointBottom),graphics=this.getShape(data.shape),_a=this.getScale(data.shape,data.start-data.end,data.diameter),scaleX=_a.scaleX,scaleY=_a.scaleY,x=pointTop[0],y=pointTop[1];return graphics.setTransform(x,y,scaleX,scaleY,rotation),{graphics:graphics}}},CompletionLayer.prototype.drawCompletionItem=function(item){this.ctx.stage.addChild(item.graphics)},CompletionLayer}(PixiLayer),noop$1={value:function(){}};function dispatch(){for(var t,i=0,n=arguments.length,_={};i<n;++i){if(!(t=arguments[i]+"")||t in _||/[\s.]/.test(t))throw new Error("illegal type: "+t);_[t]=[]}return new Dispatch(_)}function Dispatch(_){this._=_}function parseTypenames$1(typenames,types){return typenames.trim().split(/^|\s+/).map((function(t){var name="",i=t.indexOf(".");if(i>=0&&(name=t.slice(i+1),t=t.slice(0,i)),t&&!types.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:name}}))}function get(type,name){for(var c,i=0,n=type.length;i<n;++i)if((c=type[i]).name===name)return c.value}function set(type,name,callback){for(var i=0,n=type.length;i<n;++i)if(type[i].name===name){type[i]=noop$1,type=type.slice(0,i).concat(type.slice(i+1));break}return null!=callback&&type.push({name:name,value:callback}),type}function noevent(){event.preventDefault(),event.stopImmediatePropagation()}function dragDisable(view){var root=view.document.documentElement,selection=select(view).on("dragstart.drag",noevent,!0);"onselectstart"in root?selection.on("selectstart.drag",noevent,!0):(root.__noselect=root.style.MozUserSelect,root.style.MozUserSelect="none")}function yesdrag(view,noclick){var root=view.document.documentElement,selection=select(view).on("dragstart.drag",null);noclick&&(selection.on("click.drag",noevent,!0),setTimeout((function(){selection.on("click.drag",null)}),0)),"onselectstart"in root?selection.on("selectstart.drag",null):(root.style.MozUserSelect=root.__noselect,delete root.__noselect)}Dispatch.prototype=dispatch.prototype={constructor:Dispatch,on:function(typename,callback){var t,_=this._,T=parseTypenames$1(typename+"",_),i=-1,n=T.length;if(!(arguments.length<2)){if(null!=callback&&"function"!=typeof callback)throw new Error("invalid callback: "+callback);for(;++i<n;)if(t=(typename=T[i]).type)_[t]=set(_[t],typename.name,callback);else if(null==callback)for(t in _)_[t]=set(_[t],typename.name,null);return this}for(;++i<n;)if((t=(typename=T[i]).type)&&(t=get(_[t],typename.name)))return t},copy:function(){var copy={},_=this._;for(var t in _)copy[t]=_[t].slice();return new Dispatch(copy)},call:function(type,that){if((n=arguments.length-2)>0)for(var n,t,args=new Array(n),i=0;i<n;++i)args[i]=arguments[i+2];if(!this._.hasOwnProperty(type))throw new Error("unknown type: "+type);for(i=0,n=(t=this._[type]).length;i<n;++i)t[i].value.apply(that,args)},apply:function(type,that,args){if(!this._.hasOwnProperty(type))throw new Error("unknown type: "+type);for(var t=this._[type],i=0,n=t.length;i<n;++i)t[i].value.apply(that,args)}};var rho=Math.SQRT2;function cosh(x){return((x=Math.exp(x))+1/x)/2}function interpolateZoom(p0,p1){var i,S,ux0=p0[0],uy0=p0[1],w0=p0[2],ux1=p1[0],uy1=p1[1],w1=p1[2],dx=ux1-ux0,dy=uy1-uy0,d2=dx*dx+dy*dy;if(d2<1e-12)S=Math.log(w1/w0)/rho,i=function(t){return[ux0+t*dx,uy0+t*dy,w0*Math.exp(rho*t*S)]};else{var d1=Math.sqrt(d2),b0=(w1*w1-w0*w0+4*d2)/(2*w0*2*d1),b1=(w1*w1-w0*w0-4*d2)/(2*w1*2*d1),r0=Math.log(Math.sqrt(b0*b0+1)-b0),r1=Math.log(Math.sqrt(b1*b1+1)-b1);S=(r1-r0)/rho,i=function(t){var s=t*S,coshr0=cosh(r0),u=w0/(2*d1)*(coshr0*function(x){return((x=Math.exp(2*x))-1)/(x+1)}(rho*s+r0)-function(x){return((x=Math.exp(x))-1/x)/2}(r0));return[ux0+u*dx,uy0+u*dy,w0*coshr0/cosh(rho*s+r0)]}}return i.duration=1e3*S,i}var taskHead,taskTail,frame=0,timeout=0,interval=0,clockLast=0,clockNow=0,clockSkew=0,clock="object"==typeof performance&&performance.now?performance:Date,setFrame="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(f){setTimeout(f,17)};function now(){return clockNow||(setFrame(clearNow),clockNow=clock.now()+clockSkew)}function clearNow(){clockNow=0}function Timer(){this._call=this._time=this._next=null}function timer(callback,delay,time){var t=new Timer;return t.restart(callback,delay,time),t}function wake(){clockNow=(clockLast=clock.now())+clockSkew,frame=timeout=0;try{!function(){now(),++frame;for(var e,t=taskHead;t;)(e=clockNow-t._time)>=0&&t._call.call(null,e),t=t._next;--frame}()}finally{frame=0,function(){var t0,t2,t1=taskHead,time=1/0;for(;t1;)t1._call?(time>t1._time&&(time=t1._time),t0=t1,t1=t1._next):(t2=t1._next,t1._next=null,t1=t0?t0._next=t2:taskHead=t2);taskTail=t0,sleep(time)}(),clockNow=0}}function poke(){var now=clock.now(),delay=now-clockLast;delay>1e3&&(clockSkew-=delay,clockLast=now)}function sleep(time){frame||(timeout&&(timeout=clearTimeout(timeout)),time-clockNow>24?(time<1/0&&(timeout=setTimeout(wake,time-clock.now()-clockSkew)),interval&&(interval=clearInterval(interval))):(interval||(clockLast=clock.now(),interval=setInterval(poke,1e3)),frame=1,setFrame(wake)))}function timeout$1(callback,delay,time){var t=new Timer;return delay=null==delay?0:+delay,t.restart((function(elapsed){t.stop(),callback(elapsed+delay)}),delay,time),t}Timer.prototype=timer.prototype={constructor:Timer,restart:function(callback,delay,time){if("function"!=typeof callback)throw new TypeError("callback is not a function");time=(null==time?now():+time)+(null==delay?0:+delay),this._next||taskTail===this||(taskTail?taskTail._next=this:taskHead=this,taskTail=this),this._call=callback,this._time=time,sleep()},stop:function(){this._call&&(this._call=null,this._time=1/0,sleep())}};var emptyOn=dispatch("start","end","cancel","interrupt"),emptyTween=[];function schedule(node,name,id,index,group,timing){var schedules=node.__transition;if(schedules){if(id in schedules)return}else node.__transition={};!function(node,id,self){var tween,schedules=node.__transition;function schedule(elapsed){self.state=1,self.timer.restart(start,self.delay,self.time),self.delay<=elapsed&&start(elapsed-self.delay)}function start(elapsed){var i,j,n,o;if(1!==self.state)return stop();for(i in schedules)if((o=schedules[i]).name===self.name){if(3===o.state)return timeout$1(start);4===o.state?(o.state=6,o.timer.stop(),o.on.call("interrupt",node,node.__data__,o.index,o.group),delete schedules[i]):+i<id&&(o.state=6,o.timer.stop(),o.on.call("cancel",node,node.__data__,o.index,o.group),delete schedules[i])}if(timeout$1((function(){3===self.state&&(self.state=4,self.timer.restart(tick,self.delay,self.time),tick(elapsed))})),self.state=2,self.on.call("start",node,node.__data__,self.index,self.group),2===self.state){for(self.state=3,tween=new Array(n=self.tween.length),i=0,j=-1;i<n;++i)(o=self.tween[i].value.call(node,node.__data__,self.index,self.group))&&(tween[++j]=o);tween.length=j+1}}function tick(elapsed){for(var t=elapsed<self.duration?self.ease.call(null,elapsed/self.duration):(self.timer.restart(stop),self.state=5,1),i=-1,n=tween.length;++i<n;)tween[i].call(node,t);5===self.state&&(self.on.call("end",node,node.__data__,self.index,self.group),stop())}function stop(){for(var i in self.state=6,self.timer.stop(),delete schedules[id],schedules)return;delete node.__transition}schedules[id]=self,self.timer=timer(schedule,0,self.time)}(node,id,{name:name,index:index,group:group,on:emptyOn,tween:emptyTween,time:timing.time,delay:timing.delay,duration:timing.duration,ease:timing.ease,timer:null,state:0})}function init$1(node,id){var schedule=get$1(node,id);if(schedule.state>0)throw new Error("too late; already scheduled");return schedule}function set$1(node,id){var schedule=get$1(node,id);if(schedule.state>3)throw new Error("too late; already running");return schedule}function get$1(node,id){var schedule=node.__transition;if(!schedule||!(schedule=schedule[id]))throw new Error("transition not found");return schedule}function interrupt(node,name){var schedule,active,i,schedules=node.__transition,empty=!0;if(schedules){for(i in name=null==name?null:name+"",schedules)(schedule=schedules[i]).name===name?(active=schedule.state>2&&schedule.state<5,schedule.state=6,schedule.timer.stop(),schedule.on.call(active?"interrupt":"cancel",node,node.__data__,schedule.index,schedule.group),delete schedules[i]):empty=!1;empty&&delete node.__transition}}function define$1(constructor,factory,prototype){constructor.prototype=factory.prototype=prototype,prototype.constructor=constructor}function extend$1(parent,definition){var prototype=Object.create(parent.prototype);for(var key in definition)prototype[key]=definition[key];return prototype}function Color$1(){}var brighter$1=1/.7,reI$1="\\s*([+-]?\\d+)\\s*",reN$1="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",reP$1="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",reHex$1=/^#([0-9a-f]{3,8})$/,reRgbInteger$1=new RegExp("^rgb\\("+[reI$1,reI$1,reI$1]+"\\)$"),reRgbPercent$1=new RegExp("^rgb\\("+[reP$1,reP$1,reP$1]+"\\)$"),reRgbaInteger$1=new RegExp("^rgba\\("+[reI$1,reI$1,reI$1,reN$1]+"\\)$"),reRgbaPercent$1=new RegExp("^rgba\\("+[reP$1,reP$1,reP$1,reN$1]+"\\)$"),reHslPercent$1=new RegExp("^hsl\\("+[reN$1,reP$1,reP$1]+"\\)$"),reHslaPercent$1=new RegExp("^hsla\\("+[reN$1,reP$1,reP$1,reN$1]+"\\)$"),named$1={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function color_formatHex$1(){return this.rgb().formatHex()}function color_formatRgb$1(){return this.rgb().formatRgb()}function color$1(format){var m,l;return format=(format+"").trim().toLowerCase(),(m=reHex$1.exec(format))?(l=m[1].length,m=parseInt(m[1],16),6===l?rgbn$1(m):3===l?new Rgb$1(m>>8&15|m>>4&240,m>>4&15|240&m,(15&m)<<4|15&m,1):8===l?rgba$1(m>>24&255,m>>16&255,m>>8&255,(255&m)/255):4===l?rgba$1(m>>12&15|m>>8&240,m>>8&15|m>>4&240,m>>4&15|240&m,((15&m)<<4|15&m)/255):null):(m=reRgbInteger$1.exec(format))?new Rgb$1(m[1],m[2],m[3],1):(m=reRgbPercent$1.exec(format))?new Rgb$1(255*m[1]/100,255*m[2]/100,255*m[3]/100,1):(m=reRgbaInteger$1.exec(format))?rgba$1(m[1],m[2],m[3],m[4]):(m=reRgbaPercent$1.exec(format))?rgba$1(255*m[1]/100,255*m[2]/100,255*m[3]/100,m[4]):(m=reHslPercent$1.exec(format))?hsla$1(m[1],m[2]/100,m[3]/100,1):(m=reHslaPercent$1.exec(format))?hsla$1(m[1],m[2]/100,m[3]/100,m[4]):named$1.hasOwnProperty(format)?rgbn$1(named$1[format]):"transparent"===format?new Rgb$1(NaN,NaN,NaN,0):null}function rgbn$1(n){return new Rgb$1(n>>16&255,n>>8&255,255&n,1)}function rgba$1(r,g,b,a){return a<=0&&(r=g=b=NaN),new Rgb$1(r,g,b,a)}function rgbConvert$1(o){return o instanceof Color$1||(o=color$1(o)),o?new Rgb$1((o=o.rgb()).r,o.g,o.b,o.opacity):new Rgb$1}function rgb$1(r,g,b,opacity){return 1===arguments.length?rgbConvert$1(r):new Rgb$1(r,g,b,null==opacity?1:opacity)}function Rgb$1(r,g,b,opacity){this.r=+r,this.g=+g,this.b=+b,this.opacity=+opacity}function rgb_formatHex$1(){return"#"+hex$1(this.r)+hex$1(this.g)+hex$1(this.b)}function rgb_formatRgb$1(){var a=this.opacity;return(1===(a=isNaN(a)?1:Math.max(0,Math.min(1,a)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===a?")":", "+a+")")}function hex$1(value){return((value=Math.max(0,Math.min(255,Math.round(value)||0)))<16?"0":"")+value.toString(16)}function hsla$1(h,s,l,a){return a<=0?h=s=l=NaN:l<=0||l>=1?h=s=NaN:s<=0&&(h=NaN),new Hsl$1(h,s,l,a)}function hslConvert$1(o){if(o instanceof Hsl$1)return new Hsl$1(o.h,o.s,o.l,o.opacity);if(o instanceof Color$1||(o=color$1(o)),!o)return new Hsl$1;if(o instanceof Hsl$1)return o;var r=(o=o.rgb()).r/255,g=o.g/255,b=o.b/255,min=Math.min(r,g,b),max=Math.max(r,g,b),h=NaN,s=max-min,l=(max+min)/2;return s?(h=r===max?(g-b)/s+6*(g<b):g===max?(b-r)/s+2:(r-g)/s+4,s/=l<.5?max+min:2-max-min,h*=60):s=l>0&&l<1?0:h,new Hsl$1(h,s,l,o.opacity)}function Hsl$1(h,s,l,opacity){this.h=+h,this.s=+s,this.l=+l,this.opacity=+opacity}function hsl2rgb$1(h,m1,m2){return 255*(h<60?m1+(m2-m1)*h/60:h<180?m2:h<240?m1+(m2-m1)*(240-h)/60:m1)}function constant$3(x){return function(){return x}}function gamma$1(y){return 1==(y=+y)?nogamma$1:function(a,b){return b-a?function(a,b,y){return a=Math.pow(a,y),b=Math.pow(b,y)-a,y=1/y,function(t){return Math.pow(a+t*b,y)}}(a,b,y):constant$3(isNaN(a)?b:a)}}function nogamma$1(a,b){var d=b-a;return d?function(a,d){return function(t){return a+t*d}}(a,d):constant$3(isNaN(a)?b:a)}define$1(Color$1,color$1,{copy:function(channels){return Object.assign(new this.constructor,this,channels)},displayable:function(){return this.rgb().displayable()},hex:color_formatHex$1,formatHex:color_formatHex$1,formatHsl:function(){return hslConvert$1(this).formatHsl()},formatRgb:color_formatRgb$1,toString:color_formatRgb$1}),define$1(Rgb$1,rgb$1,extend$1(Color$1,{brighter:function(k){return k=null==k?brighter$1:Math.pow(brighter$1,k),new Rgb$1(this.r*k,this.g*k,this.b*k,this.opacity)},darker:function(k){return k=null==k?.7:Math.pow(.7,k),new Rgb$1(this.r*k,this.g*k,this.b*k,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rgb_formatHex$1,formatHex:rgb_formatHex$1,formatRgb:rgb_formatRgb$1,toString:rgb_formatRgb$1})),define$1(Hsl$1,(function(h,s,l,opacity){return 1===arguments.length?hslConvert$1(h):new Hsl$1(h,s,l,null==opacity?1:opacity)}),extend$1(Color$1,{brighter:function(k){return k=null==k?brighter$1:Math.pow(brighter$1,k),new Hsl$1(this.h,this.s,this.l*k,this.opacity)},darker:function(k){return k=null==k?.7:Math.pow(.7,k),new Hsl$1(this.h,this.s,this.l*k,this.opacity)},rgb:function(){var h=this.h%360+360*(this.h<0),s=isNaN(h)||isNaN(this.s)?0:this.s,l=this.l,m2=l+(l<.5?l:1-l)*s,m1=2*l-m2;return new Rgb$1(hsl2rgb$1(h>=240?h-240:h+120,m1,m2),hsl2rgb$1(h,m1,m2),hsl2rgb$1(h<120?h+240:h-120,m1,m2),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var a=this.opacity;return(1===(a=isNaN(a)?1:Math.max(0,Math.min(1,a)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===a?")":", "+a+")")}}));var interpolateRgb$1=function rgbGamma(y){var color=gamma$1(y);function rgb(start,end){var r=color((start=rgb$1(start)).r,(end=rgb$1(end)).r),g=color(start.g,end.g),b=color(start.b,end.b),opacity=nogamma$1(start.opacity,end.opacity);return function(t){return start.r=r(t),start.g=g(t),start.b=b(t),start.opacity=opacity(t),start+""}}return rgb.gamma=rgbGamma,rgb}(1);function interpolateNumber$1(a,b){return a=+a,b=+b,function(t){return a*(1-t)+b*t}}var reA$1=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,reB$1=new RegExp(reA$1.source,"g");function interpolateString(a,b){var am,bm,bs,bi=reA$1.lastIndex=reB$1.lastIndex=0,i=-1,s=[],q=[];for(a+="",b+="";(am=reA$1.exec(a))&&(bm=reB$1.exec(b));)(bs=bm.index)>bi&&(bs=b.slice(bi,bs),s[i]?s[i]+=bs:s[++i]=bs),(am=am[0])===(bm=bm[0])?s[i]?s[i]+=bm:s[++i]=bm:(s[++i]=null,q.push({i:i,x:interpolateNumber$1(am,bm)})),bi=reB$1.lastIndex;return bi<b.length&&(bs=b.slice(bi),s[i]?s[i]+=bs:s[++i]=bs),s.length<2?q[0]?function(b){return function(t){return b(t)+""}}(q[0].x):function(b){return function(){return b}}(b):(b=q.length,function(t){for(var o,i=0;i<b;++i)s[(o=q[i]).i]=o.x(t);return s.join("")})}var cssNode,cssRoot,cssView,svgNode,degrees=180/Math.PI,identity$2={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function decompose(a,b,c,d,e,f){var scaleX,scaleY,skewX;return(scaleX=Math.sqrt(a*a+b*b))&&(a/=scaleX,b/=scaleX),(skewX=a*c+b*d)&&(c-=a*skewX,d-=b*skewX),(scaleY=Math.sqrt(c*c+d*d))&&(c/=scaleY,d/=scaleY,skewX/=scaleY),a*d<b*c&&(a=-a,b=-b,skewX=-skewX,scaleX=-scaleX),{translateX:e,translateY:f,rotate:Math.atan2(b,a)*degrees,skewX:Math.atan(skewX)*degrees,scaleX:scaleX,scaleY:scaleY}}function interpolateTransform(parse,pxComma,pxParen,degParen){function pop(s){return s.length?s.pop()+" ":""}return function(a,b){var s=[],q=[];return a=parse(a),b=parse(b),function(xa,ya,xb,yb,s,q){if(xa!==xb||ya!==yb){var i=s.push("translate(",null,pxComma,null,pxParen);q.push({i:i-4,x:interpolateNumber$1(xa,xb)},{i:i-2,x:interpolateNumber$1(ya,yb)})}else(xb||yb)&&s.push("translate("+xb+pxComma+yb+pxParen)}(a.translateX,a.translateY,b.translateX,b.translateY,s,q),function(a,b,s,q){a!==b?(a-b>180?b+=360:b-a>180&&(a+=360),q.push({i:s.push(pop(s)+"rotate(",null,degParen)-2,x:interpolateNumber$1(a,b)})):b&&s.push(pop(s)+"rotate("+b+degParen)}(a.rotate,b.rotate,s,q),function(a,b,s,q){a!==b?q.push({i:s.push(pop(s)+"skewX(",null,degParen)-2,x:interpolateNumber$1(a,b)}):b&&s.push(pop(s)+"skewX("+b+degParen)}(a.skewX,b.skewX,s,q),function(xa,ya,xb,yb,s,q){if(xa!==xb||ya!==yb){var i=s.push(pop(s)+"scale(",null,",",null,")");q.push({i:i-4,x:interpolateNumber$1(xa,xb)},{i:i-2,x:interpolateNumber$1(ya,yb)})}else 1===xb&&1===yb||s.push(pop(s)+"scale("+xb+","+yb+")")}(a.scaleX,a.scaleY,b.scaleX,b.scaleY,s,q),a=b=null,function(t){for(var o,i=-1,n=q.length;++i<n;)s[(o=q[i]).i]=o.x(t);return s.join("")}}}var interpolateTransformCss=interpolateTransform((function(value){return"none"===value?identity$2:(cssNode||(cssNode=document.createElement("DIV"),cssRoot=document.documentElement,cssView=document.defaultView),cssNode.style.transform=value,value=cssView.getComputedStyle(cssRoot.appendChild(cssNode),null).getPropertyValue("transform"),cssRoot.removeChild(cssNode),decompose(+(value=value.slice(7,-1).split(","))[0],+value[1],+value[2],+value[3],+value[4],+value[5]))}),"px, ","px)","deg)"),interpolateTransformSvg=interpolateTransform((function(value){return null==value?identity$2:(svgNode||(svgNode=document.createElementNS("http://www.w3.org/2000/svg","g")),svgNode.setAttribute("transform",value),(value=svgNode.transform.baseVal.consolidate())?decompose((value=value.matrix).a,value.b,value.c,value.d,value.e,value.f):identity$2)}),", ",")",")");function tweenRemove(id,name){var tween0,tween1;return function(){var schedule=set$1(this,id),tween=schedule.tween;if(tween!==tween0)for(var i=0,n=(tween1=tween0=tween).length;i<n;++i)if(tween1[i].name===name){(tween1=tween1.slice()).splice(i,1);break}schedule.tween=tween1}}function tweenFunction(id,name,value){var tween0,tween1;if("function"!=typeof value)throw new Error;return function(){var schedule=set$1(this,id),tween=schedule.tween;if(tween!==tween0){tween1=(tween0=tween).slice();for(var t={name:name,value:value},i=0,n=tween1.length;i<n;++i)if(tween1[i].name===name){tween1[i]=t;break}i===n&&tween1.push(t)}schedule.tween=tween1}}function tweenValue(transition,name,value){var id=transition._id;return transition.each((function(){var schedule=set$1(this,id);(schedule.value||(schedule.value={}))[name]=value.apply(this,arguments)})),function(node){return get$1(node,id).value[name]}}function interpolate$1(a,b){var c;return("number"==typeof b?interpolateNumber$1:b instanceof color$1?interpolateRgb$1:(c=color$1(b))?(b=c,interpolateRgb$1):interpolateString)(a,b)}function attrRemove$1(name){return function(){this.removeAttribute(name)}}function attrRemoveNS$1(fullname){return function(){this.removeAttributeNS(fullname.space,fullname.local)}}function attrConstant$1(name,interpolate,value1){var string00,interpolate0,string1=value1+"";return function(){var string0=this.getAttribute(name);return string0===string1?null:string0===string00?interpolate0:interpolate0=interpolate(string00=string0,value1)}}function attrConstantNS$1(fullname,interpolate,value1){var string00,interpolate0,string1=value1+"";return function(){var string0=this.getAttributeNS(fullname.space,fullname.local);return string0===string1?null:string0===string00?interpolate0:interpolate0=interpolate(string00=string0,value1)}}function attrFunction$1(name,interpolate,value){var string00,string10,interpolate0;return function(){var string0,string1,value1=value(this);if(null!=value1)return(string0=this.getAttribute(name))===(string1=value1+"")?null:string0===string00&&string1===string10?interpolate0:(string10=string1,interpolate0=interpolate(string00=string0,value1));this.removeAttribute(name)}}function attrFunctionNS$1(fullname,interpolate,value){var string00,string10,interpolate0;return function(){var string0,string1,value1=value(this);if(null!=value1)return(string0=this.getAttributeNS(fullname.space,fullname.local))===(string1=value1+"")?null:string0===string00&&string1===string10?interpolate0:(string10=string1,interpolate0=interpolate(string00=string0,value1));this.removeAttributeNS(fullname.space,fullname.local)}}function attrInterpolate(name,i){return function(t){this.setAttribute(name,i.call(this,t))}}function attrInterpolateNS(fullname,i){return function(t){this.setAttributeNS(fullname.space,fullname.local,i.call(this,t))}}function attrTweenNS(fullname,value){var t0,i0;function tween(){var i=value.apply(this,arguments);return i!==i0&&(t0=(i0=i)&&attrInterpolateNS(fullname,i)),t0}return tween._value=value,tween}function attrTween(name,value){var t0,i0;function tween(){var i=value.apply(this,arguments);return i!==i0&&(t0=(i0=i)&&attrInterpolate(name,i)),t0}return tween._value=value,tween}function delayFunction(id,value){return function(){init$1(this,id).delay=+value.apply(this,arguments)}}function delayConstant(id,value){return value=+value,function(){init$1(this,id).delay=value}}function durationFunction(id,value){return function(){set$1(this,id).duration=+value.apply(this,arguments)}}function durationConstant(id,value){return value=+value,function(){set$1(this,id).duration=value}}function easeConstant(id,value){if("function"!=typeof value)throw new Error;return function(){set$1(this,id).ease=value}}function onFunction(id,name,listener){var on0,on1,sit=function(name){return(name+"").trim().split(/^|\s+/).every((function(t){var i=t.indexOf(".");return i>=0&&(t=t.slice(0,i)),!t||"start"===t}))}(name)?init$1:set$1;return function(){var schedule=sit(this,id),on=schedule.on;on!==on0&&(on1=(on0=on).copy()).on(name,listener),schedule.on=on1}}var Selection$1=selection.prototype.constructor;function styleRemove$1(name){return function(){this.style.removeProperty(name)}}function styleInterpolate(name,i,priority){return function(t){this.style.setProperty(name,i.call(this,t),priority)}}function styleTween(name,value,priority){var t,i0;function tween(){var i=value.apply(this,arguments);return i!==i0&&(t=(i0=i)&&styleInterpolate(name,i,priority)),t}return tween._value=value,tween}function textInterpolate(i){return function(t){this.textContent=i.call(this,t)}}function textTween(value){var t0,i0;function tween(){var i=value.apply(this,arguments);return i!==i0&&(t0=(i0=i)&&textInterpolate(i)),t0}return tween._value=value,tween}var id=0;function Transition(groups,parents,name,id){this._groups=groups,this._parents=parents,this._name=name,this._id=id}function newId(){return++id}var selection_prototype=selection.prototype;Transition.prototype={constructor:Transition,select:function(select){var name=this._name,id=this._id;"function"!=typeof select&&(select=selector(select));for(var groups=this._groups,m=groups.length,subgroups=new Array(m),j=0;j<m;++j)for(var node,subnode,group=groups[j],n=group.length,subgroup=subgroups[j]=new Array(n),i=0;i<n;++i)(node=group[i])&&(subnode=select.call(node,node.__data__,i,group))&&("__data__"in node&&(subnode.__data__=node.__data__),subgroup[i]=subnode,schedule(subgroup[i],name,id,i,subgroup,get$1(node,id)));return new Transition(subgroups,this._parents,name,id)},selectAll:function(select){var name=this._name,id=this._id;"function"!=typeof select&&(select=selectorAll(select));for(var groups=this._groups,m=groups.length,subgroups=[],parents=[],j=0;j<m;++j)for(var node,group=groups[j],n=group.length,i=0;i<n;++i)if(node=group[i]){for(var child,children=select.call(node,node.__data__,i,group),inherit=get$1(node,id),k=0,l=children.length;k<l;++k)(child=children[k])&&schedule(child,name,id,k,children,inherit);subgroups.push(children),parents.push(node)}return new Transition(subgroups,parents,name,id)},filter:function(match){"function"!=typeof match&&(match=matcher(match));for(var groups=this._groups,m=groups.length,subgroups=new Array(m),j=0;j<m;++j)for(var node,group=groups[j],n=group.length,subgroup=subgroups[j]=[],i=0;i<n;++i)(node=group[i])&&match.call(node,node.__data__,i,group)&&subgroup.push(node);return new Transition(subgroups,this._parents,this._name,this._id)},merge:function(transition){if(transition._id!==this._id)throw new Error;for(var groups0=this._groups,groups1=transition._groups,m0=groups0.length,m1=groups1.length,m=Math.min(m0,m1),merges=new Array(m0),j=0;j<m;++j)for(var node,group0=groups0[j],group1=groups1[j],n=group0.length,merge=merges[j]=new Array(n),i=0;i<n;++i)(node=group0[i]||group1[i])&&(merge[i]=node);for(;j<m0;++j)merges[j]=groups0[j];return new Transition(merges,this._parents,this._name,this._id)},selection:function(){return new Selection$1(this._groups,this._parents)},transition:function(){for(var name=this._name,id0=this._id,id1=newId(),groups=this._groups,m=groups.length,j=0;j<m;++j)for(var node,group=groups[j],n=group.length,i=0;i<n;++i)if(node=group[i]){var inherit=get$1(node,id0);schedule(node,name,id1,i,group,{time:inherit.time+inherit.delay+inherit.duration,delay:0,duration:inherit.duration,ease:inherit.ease})}return new Transition(groups,this._parents,name,id1)},call:selection_prototype.call,nodes:selection_prototype.nodes,node:selection_prototype.node,size:selection_prototype.size,empty:selection_prototype.empty,each:selection_prototype.each,on:function(name,listener){var id=this._id;return arguments.length<2?get$1(this.node(),id).on.on(name):this.each(onFunction(id,name,listener))},attr:function(name,value){var fullname=namespace(name),i="transform"===fullname?interpolateTransformSvg:interpolate$1;return this.attrTween(name,"function"==typeof value?(fullname.local?attrFunctionNS$1:attrFunction$1)(fullname,i,tweenValue(this,"attr."+name,value)):null==value?(fullname.local?attrRemoveNS$1:attrRemove$1)(fullname):(fullname.local?attrConstantNS$1:attrConstant$1)(fullname,i,value))},attrTween:function(name,value){var key="attr."+name;if(arguments.length<2)return(key=this.tween(key))&&key._value;if(null==value)return this.tween(key,null);if("function"!=typeof value)throw new Error;var fullname=namespace(name);return this.tween(key,(fullname.local?attrTweenNS:attrTween)(fullname,value))},style:function(name,value,priority){var i="transform"==(name+="")?interpolateTransformCss:interpolate$1;return null==value?this.styleTween(name,function(name,interpolate){var string00,string10,interpolate0;return function(){var string0=styleValue(this,name),string1=(this.style.removeProperty(name),styleValue(this,name));return string0===string1?null:string0===string00&&string1===string10?interpolate0:interpolate0=interpolate(string00=string0,string10=string1)}}(name,i)).on("end.style."+name,styleRemove$1(name)):"function"==typeof value?this.styleTween(name,function(name,interpolate,value){var string00,string10,interpolate0;return function(){var string0=styleValue(this,name),value1=value(this),string1=value1+"";return null==value1&&(this.style.removeProperty(name),string1=value1=styleValue(this,name)),string0===string1?null:string0===string00&&string1===string10?interpolate0:(string10=string1,interpolate0=interpolate(string00=string0,value1))}}(name,i,tweenValue(this,"style."+name,value))).each(function(id,name){var on0,on1,listener0,remove,key="style."+name,event="end."+key;return function(){var schedule=set$1(this,id),on=schedule.on,listener=null==schedule.value[key]?remove||(remove=styleRemove$1(name)):void 0;on===on0&&listener0===listener||(on1=(on0=on).copy()).on(event,listener0=listener),schedule.on=on1}}(this._id,name)):this.styleTween(name,function(name,interpolate,value1){var string00,interpolate0,string1=value1+"";return function(){var string0=styleValue(this,name);return string0===string1?null:string0===string00?interpolate0:interpolate0=interpolate(string00=string0,value1)}}(name,i,value),priority).on("end.style."+name,null)},styleTween:function(name,value,priority){var key="style."+(name+="");if(arguments.length<2)return(key=this.tween(key))&&key._value;if(null==value)return this.tween(key,null);if("function"!=typeof value)throw new Error;return this.tween(key,styleTween(name,value,null==priority?"":priority))},text:function(value){return this.tween("text","function"==typeof value?function(value){return function(){var value1=value(this);this.textContent=null==value1?"":value1}}(tweenValue(this,"text",value)):function(value){return function(){this.textContent=value}}(null==value?"":value+""))},textTween:function(value){var key="text";if(arguments.length<1)return(key=this.tween(key))&&key._value;if(null==value)return this.tween(key,null);if("function"!=typeof value)throw new Error;return this.tween(key,textTween(value))},remove:function(){return this.on("end.remove",function(id){return function(){var parent=this.parentNode;for(var i in this.__transition)if(+i!==id)return;parent&&parent.removeChild(this)}}(this._id))},tween:function(name,value){var id=this._id;if(name+="",arguments.length<2){for(var t,tween=get$1(this.node(),id).tween,i=0,n=tween.length;i<n;++i)if((t=tween[i]).name===name)return t.value;return null}return this.each((null==value?tweenRemove:tweenFunction)(id,name,value))},delay:function(value){var id=this._id;return arguments.length?this.each(("function"==typeof value?delayFunction:delayConstant)(id,value)):get$1(this.node(),id).delay},duration:function(value){var id=this._id;return arguments.length?this.each(("function"==typeof value?durationFunction:durationConstant)(id,value)):get$1(this.node(),id).duration},ease:function(value){var id=this._id;return arguments.length?this.each(easeConstant(id,value)):get$1(this.node(),id).ease},end:function(){var on0,on1,that=this,id=that._id,size=that.size();return new Promise((function(resolve,reject){var cancel={value:reject},end={value:function(){0==--size&&resolve()}};that.each((function(){var schedule=set$1(this,id),on=schedule.on;on!==on0&&((on1=(on0=on).copy())._.cancel.push(cancel),on1._.interrupt.push(cancel),on1._.end.push(end)),schedule.on=on1}))}))}};var defaultTiming={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function inherit(node,id){for(var timing;!(timing=node.__transition)||!(timing=timing[id]);)if(!(node=node.parentNode))return defaultTiming.time=now(),defaultTiming;return timing}function constant$4(x){return function(){return x}}function ZoomEvent(target,type,transform){this.target=target,this.type=type,this.transform=transform}function Transform$1(k,x,y){this.k=k,this.x=x,this.y=y}selection.prototype.interrupt=function(name){return this.each((function(){interrupt(this,name)}))},selection.prototype.transition=function(name){var id,timing;name instanceof Transition?(id=name._id,name=name._name):(id=newId(),(timing=defaultTiming).time=now(),name=null==name?null:name+"");for(var groups=this._groups,m=groups.length,j=0;j<m;++j)for(var node,group=groups[j],n=group.length,i=0;i<n;++i)(node=group[i])&&schedule(node,name,id,i,group,timing||inherit(node,id));return new Transition(groups,this._parents,name,id)},Transform$1.prototype={constructor:Transform$1,scale:function(k){return 1===k?this:new Transform$1(this.k*k,this.x,this.y)},translate:function(x,y){return 0===x&0===y?this:new Transform$1(this.k,this.x+this.k*x,this.y+this.k*y)},apply:function(point){return[point[0]*this.k+this.x,point[1]*this.k+this.y]},applyX:function(x){return x*this.k+this.x},applyY:function(y){return y*this.k+this.y},invert:function(location){return[(location[0]-this.x)/this.k,(location[1]-this.y)/this.k]},invertX:function(x){return(x-this.x)/this.k},invertY:function(y){return(y-this.y)/this.k},rescaleX:function(x){return x.copy().domain(x.range().map(this.invertX,this).map(x.invert,x))},rescaleY:function(y){return y.copy().domain(y.range().map(this.invertY,this).map(y.invert,y))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var identity$3=new Transform$1(1,0,0);function nopropagation(){event.stopImmediatePropagation()}function noevent$1(){event.preventDefault(),event.stopImmediatePropagation()}function defaultFilter$1(){return!event.ctrlKey&&!event.button}function defaultExtent(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function defaultTransform(){return this.__zoom||identity$3}function defaultWheelDelta(){return-event.deltaY*(1===event.deltaMode?.05:event.deltaMode?1:.002)}function defaultTouchable(){return navigator.maxTouchPoints||"ontouchstart"in this}function defaultConstrain(transform,extent,translateExtent){var dx0=transform.invertX(extent[0][0])-translateExtent[0][0],dx1=transform.invertX(extent[1][0])-translateExtent[1][0],dy0=transform.invertY(extent[0][1])-translateExtent[0][1],dy1=transform.invertY(extent[1][1])-translateExtent[1][1];return transform.translate(dx1>dx0?(dx0+dx1)/2:Math.min(0,dx0)||Math.max(0,dx1),dy1>dy0?(dy0+dy1)/2:Math.min(0,dy0)||Math.max(0,dy1))}function zoom(){var touchstarting,touchending,filter=defaultFilter$1,extent=defaultExtent,constrain=defaultConstrain,wheelDelta=defaultWheelDelta,touchable=defaultTouchable,scaleExtent=[0,1/0],translateExtent=[[-1/0,-1/0],[1/0,1/0]],duration=250,interpolate=interpolateZoom,listeners=dispatch("start","zoom","end"),clickDistance2=0;function zoom(selection){selection.property("__zoom",defaultTransform).on("wheel.zoom",wheeled).on("mousedown.zoom",mousedowned).on("dblclick.zoom",dblclicked).filter(touchable).on("touchstart.zoom",touchstarted).on("touchmove.zoom",touchmoved).on("touchend.zoom touchcancel.zoom",touchended).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function scale(transform,k){return(k=Math.max(scaleExtent[0],Math.min(scaleExtent[1],k)))===transform.k?transform:new Transform$1(k,transform.x,transform.y)}function translate(transform,p0,p1){var x=p0[0]-p1[0]*transform.k,y=p0[1]-p1[1]*transform.k;return x===transform.x&&y===transform.y?transform:new Transform$1(transform.k,x,y)}function centroid(extent){return[(+extent[0][0]+ +extent[1][0])/2,(+extent[0][1]+ +extent[1][1])/2]}function schedule(transition,transform,point){transition.on("start.zoom",(function(){gesture(this,arguments).start()})).on("interrupt.zoom end.zoom",(function(){gesture(this,arguments).end()})).tween("zoom",(function(){var that=this,args=arguments,g=gesture(that,args),e=extent.apply(that,args),p=null==point?centroid(e):"function"==typeof point?point.apply(that,args):point,w=Math.max(e[1][0]-e[0][0],e[1][1]-e[0][1]),a=that.__zoom,b="function"==typeof transform?transform.apply(that,args):transform,i=interpolate(a.invert(p).concat(w/a.k),b.invert(p).concat(w/b.k));return function(t){if(1===t)t=b;else{var l=i(t),k=w/l[2];t=new Transform$1(k,p[0]-l[0]*k,p[1]-l[1]*k)}g.zoom(null,t)}}))}function gesture(that,args,clean){return!clean&&that.__zooming||new Gesture(that,args)}function Gesture(that,args){this.that=that,this.args=args,this.active=0,this.extent=extent.apply(that,args),this.taps=0}function wheeled(){if(filter.apply(this,arguments)){var g=gesture(this,arguments),t=this.__zoom,k=Math.max(scaleExtent[0],Math.min(scaleExtent[1],t.k*Math.pow(2,wheelDelta.apply(this,arguments)))),p=mouse(this);if(g.wheel)g.mouse[0][0]===p[0]&&g.mouse[0][1]===p[1]||(g.mouse[1]=t.invert(g.mouse[0]=p)),clearTimeout(g.wheel);else{if(t.k===k)return;g.mouse=[p,t.invert(p)],interrupt(this),g.start()}noevent$1(),g.wheel=setTimeout(wheelidled,150),g.zoom("mouse",constrain(translate(scale(t,k),g.mouse[0],g.mouse[1]),g.extent,translateExtent))}function wheelidled(){g.wheel=null,g.end()}}function mousedowned(){if(!touchending&&filter.apply(this,arguments)){var g=gesture(this,arguments,!0),v=select(event.view).on("mousemove.zoom",mousemoved,!0).on("mouseup.zoom",mouseupped,!0),p=mouse(this),x0=event.clientX,y0=event.clientY;dragDisable(event.view),nopropagation(),g.mouse=[p,this.__zoom.invert(p)],interrupt(this),g.start()}function mousemoved(){if(noevent$1(),!g.moved){var dx=event.clientX-x0,dy=event.clientY-y0;g.moved=dx*dx+dy*dy>clickDistance2}g.zoom("mouse",constrain(translate(g.that.__zoom,g.mouse[0]=mouse(g.that),g.mouse[1]),g.extent,translateExtent))}function mouseupped(){v.on("mousemove.zoom mouseup.zoom",null),yesdrag(event.view,g.moved),noevent$1(),g.end()}}function dblclicked(){if(filter.apply(this,arguments)){var t0=this.__zoom,p0=mouse(this),p1=t0.invert(p0),k1=t0.k*(event.shiftKey?.5:2),t1=constrain(translate(scale(t0,k1),p0,p1),extent.apply(this,arguments),translateExtent);noevent$1(),duration>0?select(this).transition().duration(duration).call(schedule,t1,p0):select(this).call(zoom.transform,t1)}}function touchstarted(){if(filter.apply(this,arguments)){var started,i,t,p,touches=event.touches,n=touches.length,g=gesture(this,arguments,event.changedTouches.length===n);for(nopropagation(),i=0;i<n;++i)p=[p=touch(this,touches,(t=touches[i]).identifier),this.__zoom.invert(p),t.identifier],g.touch0?g.touch1||g.touch0[2]===p[2]||(g.touch1=p,g.taps=0):(g.touch0=p,started=!0,g.taps=1+!!touchstarting);touchstarting&&(touchstarting=clearTimeout(touchstarting)),started&&(g.taps<2&&(touchstarting=setTimeout((function(){touchstarting=null}),500)),interrupt(this),g.start())}}function touchmoved(){if(this.__zooming){var i,t,p,l,g=gesture(this,arguments),touches=event.changedTouches,n=touches.length;for(noevent$1(),touchstarting&&(touchstarting=clearTimeout(touchstarting)),g.taps=0,i=0;i<n;++i)p=touch(this,touches,(t=touches[i]).identifier),g.touch0&&g.touch0[2]===t.identifier?g.touch0[0]=p:g.touch1&&g.touch1[2]===t.identifier&&(g.touch1[0]=p);if(t=g.that.__zoom,g.touch1){var p0=g.touch0[0],l0=g.touch0[1],p1=g.touch1[0],l1=g.touch1[1],dp=(dp=p1[0]-p0[0])*dp+(dp=p1[1]-p0[1])*dp,dl=(dl=l1[0]-l0[0])*dl+(dl=l1[1]-l0[1])*dl;t=scale(t,Math.sqrt(dp/dl)),p=[(p0[0]+p1[0])/2,(p0[1]+p1[1])/2],l=[(l0[0]+l1[0])/2,(l0[1]+l1[1])/2]}else{if(!g.touch0)return;p=g.touch0[0],l=g.touch0[1]}g.zoom("touch",constrain(translate(t,p,l),g.extent,translateExtent))}}function touchended(){if(this.__zooming){var i,t,g=gesture(this,arguments),touches=event.changedTouches,n=touches.length;for(nopropagation(),touchending&&clearTimeout(touchending),touchending=setTimeout((function(){touchending=null}),500),i=0;i<n;++i)t=touches[i],g.touch0&&g.touch0[2]===t.identifier?delete g.touch0:g.touch1&&g.touch1[2]===t.identifier&&delete g.touch1;if(g.touch1&&!g.touch0&&(g.touch0=g.touch1,delete g.touch1),g.touch0)g.touch0[1]=this.__zoom.invert(g.touch0[0]);else if(g.end(),2===g.taps){var p=select(this).on("dblclick.zoom");p&&p.apply(this,arguments)}}}return zoom.transform=function(collection,transform,point){var selection=collection.selection?collection.selection():collection;selection.property("__zoom",defaultTransform),collection!==selection?schedule(collection,transform,point):selection.interrupt().each((function(){gesture(this,arguments).start().zoom(null,"function"==typeof transform?transform.apply(this,arguments):transform).end()}))},zoom.scaleBy=function(selection,k,p){zoom.scaleTo(selection,(function(){var k0=this.__zoom.k,k1="function"==typeof k?k.apply(this,arguments):k;return k0*k1}),p)},zoom.scaleTo=function(selection,k,p){zoom.transform(selection,(function(){var e=extent.apply(this,arguments),t0=this.__zoom,p0=null==p?centroid(e):"function"==typeof p?p.apply(this,arguments):p,p1=t0.invert(p0),k1="function"==typeof k?k.apply(this,arguments):k;return constrain(translate(scale(t0,k1),p0,p1),e,translateExtent)}),p)},zoom.translateBy=function(selection,x,y){zoom.transform(selection,(function(){return constrain(this.__zoom.translate("function"==typeof x?x.apply(this,arguments):x,"function"==typeof y?y.apply(this,arguments):y),extent.apply(this,arguments),translateExtent)}))},zoom.translateTo=function(selection,x,y,p){zoom.transform(selection,(function(){var e=extent.apply(this,arguments),t=this.__zoom,p0=null==p?centroid(e):"function"==typeof p?p.apply(this,arguments):p;return constrain(identity$3.translate(p0[0],p0[1]).scale(t.k).translate("function"==typeof x?-x.apply(this,arguments):-x,"function"==typeof y?-y.apply(this,arguments):-y),e,translateExtent)}),p)},Gesture.prototype={start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(key,transform){return this.mouse&&"mouse"!==key&&(this.mouse[1]=transform.invert(this.mouse[0])),this.touch0&&"touch"!==key&&(this.touch0[1]=transform.invert(this.touch0[0])),this.touch1&&"touch"!==key&&(this.touch1[1]=transform.invert(this.touch1[0])),this.that.__zoom=transform,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(type){!function(event1,listener,that,args){var event0=event;event1.sourceEvent=event,event=event1;try{listener.apply(that,args)}finally{event=event0}}(new ZoomEvent(zoom,type,this.that.__zoom),listeners.apply,listeners,[type,this.that,this.args])}},zoom.wheelDelta=function(_){return arguments.length?(wheelDelta="function"==typeof _?_:constant$4(+_),zoom):wheelDelta},zoom.filter=function(_){return arguments.length?(filter="function"==typeof _?_:constant$4(!!_),zoom):filter},zoom.touchable=function(_){return arguments.length?(touchable="function"==typeof _?_:constant$4(!!_),zoom):touchable},zoom.extent=function(_){return arguments.length?(extent="function"==typeof _?_:constant$4([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),zoom):extent},zoom.scaleExtent=function(_){return arguments.length?(scaleExtent[0]=+_[0],scaleExtent[1]=+_[1],zoom):[scaleExtent[0],scaleExtent[1]]},zoom.translateExtent=function(_){return arguments.length?(translateExtent[0][0]=+_[0][0],translateExtent[1][0]=+_[1][0],translateExtent[0][1]=+_[0][1],translateExtent[1][1]=+_[1][1],zoom):[[translateExtent[0][0],translateExtent[0][1]],[translateExtent[1][0],translateExtent[1][1]]]},zoom.constrain=function(_){return arguments.length?(constrain=_,zoom):constrain},zoom.duration=function(_){return arguments.length?(duration=+_,zoom):duration},zoom.interpolate=function(_){return arguments.length?(interpolate=_,zoom):interpolate},zoom.on=function(){var value=listeners.on.apply(listeners,arguments);return value===listeners?zoom:value},zoom.clickDistance=function(_){return arguments.length?(clickDistance2=(_=+_)*_,zoom):Math.sqrt(clickDistance2)},zoom}var ZoomPanHandler=function(){function ZoomPanHandler(elm,onRescale,options){void 0===options&&(options={maxZoomLevel:256,minZoomLevel:.1}),this.zoom=null,this.elm=null,this.container=null,this.onRescale=null,this.options=null,this.xBounds=[0,1],this.yBounds=[0,1],this.translateBoundsX=[0,1],this.translateBoundsY=[0,1],this.scaleX=null,this.scaleY=null,this._zFactor=1,this.onZoom=this.onZoom.bind(this),this.container=select(elm),this.options=options,this.onRescale=onRescale,this.onZoom=this.onZoom.bind(this),this.calculateTransform=this.calculateTransform.bind(this),this.applyTransform=this.applyTransform.bind(this),this.recalculateZoomTransform=this.recalculateZoomTransform.bind(this),this.rescale=this.rescale.bind(this),this.adjustToSize=this.adjustToSize.bind(this),this.setViewport=this.setViewport.bind(this),this.currentStateAsEvent=this.currentStateAsEvent.bind(this),this.updateTranslateExtent=this.updateTranslateExtent.bind(this),this.scaleX=linear$1().domain(this.xBounds).range([0,1]),this.scaleY=linear$1().domain(this.yBounds).range([0,1]),this.init()}return Object.defineProperty(ZoomPanHandler.prototype,"width",{get:function(){return this.scaleX.range()[1]},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"height",{get:function(){return this.scaleY.range()[1]},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"xSpan",{get:function(){var xBounds=this.xBounds;return Math.abs(xBounds[1]-xBounds[0])},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"ySpan",{get:function(){var yBounds=this.yBounds;return Math.abs(yBounds[1]-yBounds[0])},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"viewportRatio",{get:function(){return this.width/(this.height||1)},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"xRatio",{get:function(){var domain=this.scaleX.domain();return Math.abs(this.width/(domain[1]-domain[0]))},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"yRatio",{get:function(){var domain=this.scaleY.domain();return Math.abs(this.height/(domain[1]-domain[0]))},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"zFactor",{get:function(){return this._zFactor},set:function(factor){this._zFactor=factor,this.recalculateZoomTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"isXInverted",{get:function(){return this.xBounds[1]<this.xBounds[0]},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"isYInverted",{get:function(){return this.yBounds[1]<this.yBounds[0]},enumerable:!1,configurable:!0}),Object.defineProperty(ZoomPanHandler.prototype,"enableTranslateExtent",{get:function(){return this._enableTranslateExtent},set:function(enabled){this._enableTranslateExtent=enabled,this.updateTranslateExtent()},enumerable:!1,configurable:!0}),ZoomPanHandler.prototype.updateTranslateExtent=function(){var _a=this,width=_a.width,xSpan=_a.xSpan;_a.ySpan;var zFactor=_a.zFactor,enableTranslateExtent=_a.enableTranslateExtent,translateBoundsX=_a.translateBoundsX,translateBoundsY=_a.translateBoundsY,x1=-1/0,y1=-1/0,x2=1/0,y2=1/0;if(enableTranslateExtent){var ppu=width/xSpan;x1=translateBoundsX[0]*ppu,x2=translateBoundsX[1]*ppu,y1=translateBoundsY[0]*ppu*zFactor,y2=translateBoundsY[1]*ppu*zFactor}this.zoom.translateExtent([[x1,y1],[x2,y2]])},ZoomPanHandler.prototype.currentStateAsEvent=function(){var _a=this,scaleX=_a.scaleX,scaleY=_a.scaleY,xBounds=_a.xBounds,yBounds=_a.yBounds,zFactor=_a.zFactor,viewportRatio=_a.viewportRatio,currentTransform=_a.currentTransform,xRatio=_a.xRatio,yRatio=_a.yRatio,width=_a.width,height=_a.height;return{xScale:scaleX.copy(),yScale:scaleY.copy(),xBounds:xBounds,yBounds:yBounds,zFactor:zFactor,viewportRatio:viewportRatio,xRatio:xRatio,yRatio:yRatio,width:width,height:height,transform:__assign({},currentTransform)}},ZoomPanHandler.prototype.rescale=function(){var currentStateAsEvent=this.currentStateAsEvent;this.onRescale(currentStateAsEvent())},ZoomPanHandler.prototype.init=function(){this.zoom=zoom().scaleExtent([this.options.minZoomLevel,this.options.maxZoomLevel]).on("zoom",this.onZoom),this.container.call(this.zoom)},ZoomPanHandler.prototype.onZoom=function(){var transform=event.transform;transform&&(this.applyTransform(transform),this.rescale())},ZoomPanHandler.prototype.applyTransform=function(transform){var _a=this,width=_a.width,scaleX=_a.scaleX,scaleY=_a.scaleY,xSpan=_a.xSpan;_a.ySpan;var xBounds=_a.xBounds,yBounds=_a.yBounds,zFactor=_a.zFactor,ratio=this.viewportRatio,isXInverted=this.isXInverted,isYInverted=this.isYInverted,unitsPerPixels=xSpan/(width*transform.k),newXSpan=xSpan/transform.k,newYSpan=newXSpan/zFactor/ratio,shiftx=unitsPerPixels*transform.x,shifty=unitsPerPixels/zFactor*transform.y,dx0=xBounds[0]-(isXInverted?-shiftx:shiftx),dy0=yBounds[0]-(isYInverted?-shifty:shifty);scaleX.domain([dx0,dx0+(isXInverted?-newXSpan:newXSpan)]),scaleY.domain([dy0,dy0+(isYInverted?-newYSpan:newYSpan)]),this.currentTransform=transform},ZoomPanHandler.prototype.setViewport=function(cx,cy,displ,duration){void 0===cx&&(cx=null),void 0===cy&&(cy=null),void 0===displ&&(displ=null),void 0===duration&&(duration=null);var _a=this,zoom=_a.zoom,container=_a.container,calculateTransform=_a.calculateTransform;_a.viewportRatio;var scaleX=_a.scaleX,scaleY=_a.scaleY,isXInverted=_a.isXInverted;if(null===cx||null===displ){var xd=scaleX.domain(),dspan=xd[1]-xd[0];null===cx&&(cx=xd[0]+dspan/2||0),null===displ&&(displ=Math.abs(dspan)||1)}if(null===cy){var yd=scaleY.domain();cy=yd[0]+(yd[1]-yd[0])/2||0}var xdispl=isXInverted?-displ:displ,dx0=cx-xdispl/2,t=calculateTransform(dx0,dx0+xdispl,cy);Number.isFinite(duration)&&duration>0?zoom.transform(container.transition().duration(duration),t):zoom.transform(container,t)},ZoomPanHandler.prototype.setBounds=function(xBounds,yBounds){this.xBounds=xBounds,this.yBounds=yBounds,this.recalculateZoomTransform()},ZoomPanHandler.prototype.setTranslateBounds=function(xBounds,yBounds){this.translateBoundsX=xBounds,this.translateBoundsY=yBounds,this.updateTranslateExtent()},ZoomPanHandler.prototype.adjustToSize=function(width,height,force){void 0===force&&(force=!1);var _a=this,oldWidth=_a.width,oldHeight=_a.height,scaleX=_a.scaleX,scaleY=_a.scaleY,recalculateZoomTransform=_a.recalculateZoomTransform,w=0,h=0;if(void 0===width||"boolean"==typeof width){var _b=this.container.node().getBoundingClientRect();w=_b.containerWidth,h=_b.containerHeight}else w=width,h=height;var newWidth=Math.max(1,w),newHeight=Math.max(1,h);(force||oldWidth!==newWidth||oldHeight!==newHeight)&&(scaleX.range([0,newWidth]),scaleY.range([0,newHeight]),recalculateZoomTransform(),this.onRescale(this.currentStateAsEvent()))},ZoomPanHandler.prototype.calculateTransform=function(dx0,dx1,dy){var _a=this,scaleX=_a.scaleX,xSpan=_a.xSpan,xBounds=_a.xBounds,yBounds=_a.yBounds,zFactor=_a.zFactor,ratio=_a.viewportRatio,isXInverted=_a.isXInverted,isYInverted=_a.isYInverted,_b=scaleX.range(),rx1=_b[0],rx2=_b[1],displ=Math.abs(dx1-dx0),k=xSpan/displ,unitsPerPixels=displ/(rx2-rx1),dy0=dy-(isYInverted?-displ:displ)/zFactor/ratio/2,tx=(xBounds[0]-dx0)/(isXInverted?-unitsPerPixels:unitsPerPixels),ty=(yBounds[0]-dy0)/((isYInverted?-unitsPerPixels:unitsPerPixels)/zFactor);return identity$3.translate(tx,ty).scale(k)},ZoomPanHandler.prototype.recalculateZoomTransform=function(){var _a=this,scaleX=_a.scaleX,scaleY=_a.scaleY,container=_a.container,calculateTransform=_a.calculateTransform,updateTranslateExtent=_a.updateTranslateExtent,_b=scaleX.domain(),dx0=_b[0],dx1=_b[1],_c=scaleY.domain(),dy0=_c[0],transform=calculateTransform(dx0,dx1,dy0+(_c[1]-dy0)/2);updateTranslateExtent(),this.zoom.transform(container,transform)},ZoomPanHandler.prototype.setZoomLevelBoundary=function(zoomlevels){return this.zoom.scaleExtent(zoomlevels),this},ZoomPanHandler.prototype.setMaxZoomLevel=function(zoomlevel){var zoomLevels=this.zoom.scaleExtent();return this.zoom.scaleExtent([zoomLevels[0],zoomlevel]),this},ZoomPanHandler.prototype.setMinZoomLevel=function(zoomlevel){var zoomLevels=this.zoom.scaleExtent();return this.zoom.scaleExtent([zoomlevel,zoomLevels[1]]),this},ZoomPanHandler}(),slice=Array.prototype.slice;function identity$4(x){return x}function translateX(x){return"translate("+(x+.5)+",0)"}function translateY(y){return"translate(0,"+(y+.5)+")"}function number$2(scale){return function(d){return+scale(d)}}function center(scale){var offset=Math.max(0,scale.bandwidth()-1)/2;return scale.round()&&(offset=Math.round(offset)),function(d){return+scale(d)+offset}}function entering(){return!this.__axis}function axis(orient,scale){var tickArguments=[],tickValues=null,tickFormat=null,tickSizeInner=6,tickSizeOuter=6,tickPadding=3,k=1===orient||4===orient?-1:1,x=4===orient||2===orient?"x":"y",transform=1===orient||3===orient?translateX:translateY;function axis(context){var values=null==tickValues?scale.ticks?scale.ticks.apply(scale,tickArguments):scale.domain():tickValues,format=null==tickFormat?scale.tickFormat?scale.tickFormat.apply(scale,tickArguments):identity$4:tickFormat,spacing=Math.max(tickSizeInner,0)+tickPadding,range=scale.range(),range0=+range[0]+.5,range1=+range[range.length-1]+.5,position=(scale.bandwidth?center:number$2)(scale.copy()),selection=context.selection?context.selection():context,path=selection.selectAll(".domain").data([null]),tick=selection.selectAll(".tick").data(values,scale).order(),tickExit=tick.exit(),tickEnter=tick.enter().append("g").attr("class","tick"),line=tick.select("line"),text=tick.select("text");path=path.merge(path.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),tick=tick.merge(tickEnter),line=line.merge(tickEnter.append("line").attr("stroke","currentColor").attr(x+"2",k*tickSizeInner)),text=text.merge(tickEnter.append("text").attr("fill","currentColor").attr(x,k*spacing).attr("dy",1===orient?"0em":3===orient?"0.71em":"0.32em")),context!==selection&&(path=path.transition(context),tick=tick.transition(context),line=line.transition(context),text=text.transition(context),tickExit=tickExit.transition(context).attr("opacity",1e-6).attr("transform",(function(d){return isFinite(d=position(d))?transform(d):this.getAttribute("transform")})),tickEnter.attr("opacity",1e-6).attr("transform",(function(d){var p=this.parentNode.__axis;return transform(p&&isFinite(p=p(d))?p:position(d))}))),tickExit.remove(),path.attr("d",4===orient||2==orient?tickSizeOuter?"M"+k*tickSizeOuter+","+range0+"H0.5V"+range1+"H"+k*tickSizeOuter:"M0.5,"+range0+"V"+range1:tickSizeOuter?"M"+range0+","+k*tickSizeOuter+"V0.5H"+range1+"V"+k*tickSizeOuter:"M"+range0+",0.5H"+range1),tick.attr("opacity",1).attr("transform",(function(d){return transform(position(d))})),line.attr(x+"2",k*tickSizeInner),text.attr(x,k*spacing).text(format),selection.filter(entering).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===orient?"start":4===orient?"end":"middle"),selection.each((function(){this.__axis=position}))}return axis.scale=function(_){return arguments.length?(scale=_,axis):scale},axis.ticks=function(){return tickArguments=slice.call(arguments),axis},axis.tickArguments=function(_){return arguments.length?(tickArguments=null==_?[]:slice.call(_),axis):tickArguments.slice()},axis.tickValues=function(_){return arguments.length?(tickValues=null==_?null:slice.call(_),axis):tickValues&&tickValues.slice()},axis.tickFormat=function(_){return arguments.length?(tickFormat=_,axis):tickFormat},axis.tickSize=function(_){return arguments.length?(tickSizeInner=tickSizeOuter=+_,axis):tickSizeInner},axis.tickSizeInner=function(_){return arguments.length?(tickSizeInner=+_,axis):tickSizeInner},axis.tickSizeOuter=function(_){return arguments.length?(tickSizeOuter=+_,axis):tickSizeOuter},axis.tickPadding=function(_){return arguments.length?(tickPadding=+_,axis):tickPadding},axis}var Axis=function(){function Axis(mainGroup,showLabels,labelXDesc,labelYDesc,unitOfMeasure,options){var _this=this;void 0===showLabels&&(showLabels=!0),this._showLabels=!0,this._offsetX=0,this._offsetY=0,this._flipX=!1,this._flipY=!1,this.visible=!0,this.createOrGet=function(name){var mainGroup=_this.mainGroup,res=mainGroup.select("g."+name);return res.empty()&&(res=mainGroup.append("g").attr("class",name)),res},this.mainGroup=mainGroup,this._showLabels=showLabels,this._labelXDesc=labelXDesc,this._labelYDesc=labelYDesc,this._unitOfMeasure=unitOfMeasure,options&&options.offsetX&&(this._offsetX=options.offsetX),options&&options.offsetX&&(this._offsetY=options.offsetY),options&&options.visible&&(this.visible=options.visible),this.mainGroup.style("pointer-events","none"),this._scaleX=linear$1().domain([0,1]).range([0,1]),this._scaleY=linear$1().domain([0,1]).range([0,1])}return Axis.prototype.renderLabelx=function(){var labelXDesc=this._labelXDesc,unitOfMeasure=this._unitOfMeasure,_showLabels=this._showLabels,width=this._scaleX.range()[1],gx=this.renderGx(),labelx=gx.select("text.axis-labelx");return _showLabels?labelx.empty()&&(labelx=gx.append("text").attr("class","axis-labelx").attr("fill","rgba(0,0,0,0.3)").style("text-anchor","middle").style("font-weight","800").style("font-size","10px").text(labelXDesc+" ("+unitOfMeasure+")")):labelx.remove(),labelx.attr("transform","translate("+width/2+",-4)"),labelx},Axis.prototype.renderLabely=function(){var labelYDesc=this._labelYDesc,unitOfMeasure=this._unitOfMeasure,_showLabels=this._showLabels,height=this._scaleY.range()[1],gy=this.renderGy(),labely=gy.select("text.axis-labely");return _showLabels?(labely.empty()&&(labely=gy.append("text").attr("class","axis-labely").attr("fill","rgba(0,0,0,0.3)").style("text-anchor","middle").style("font-weight","800").style("font-size","10px").text(labelYDesc+" ("+unitOfMeasure+")")),labely.attr("transform","translate(-10,"+height/2+")rotate(90)")):labely.remove(),labely},Axis.prototype.renderGy=function(){var _scaleX=this._scaleX,yAxis=function(scale){return axis(2,scale)}(this._scaleY),width=_scaleX.range()[1],gy=this.createOrGet("y-axis");return gy.call(yAxis),gy.attr("transform","translate("+width+",0)"),gy},Axis.prototype.renderGx=function(){var _scaleX=this._scaleX,_scaleY=this._scaleY,xAxis=function(scale){return axis(3,scale)}(_scaleX),height=_scaleY.range()[1],gx=this.createOrGet("x-axis");return gx.attr("transform","translate(0 "+height+")"),gx.call(xAxis),gx},Axis.prototype.render=function(){this.renderLabelx(),this.renderLabely()},Axis.prototype.onResize=function(event){this.mainGroup.attr("height",event.height+"px").attr("width",event.width+"px")},Axis.prototype.onRescale=function(event){var _scaleX=this._scaleX,_scaleY=this._scaleY,offsetX=this.offsetX,offsetY=this.offsetY,xScale=event.xScale,yScale=event.yScale,xBounds=xScale.domain(),yBounds=yScale.domain(),xRange=xScale.range(),yRange=yScale.range();_scaleX.domain([xBounds[0]-offsetX,xBounds[1]-offsetX]).range(xRange),_scaleY.domain([yBounds[0]-offsetY,yBounds[1]-offsetY]).range(yRange),this.flipX(this._flipX),this.flipY(this._flipY),this.visible&&this.render()},Axis.prototype.show=function(){return this.visible=!0,this.mainGroup.attr("visibility","visible"),this.render(),this},Axis.prototype.hide=function(){return this.visible=!1,this.mainGroup.attr("visibility","hidden"),this},Axis.prototype.flipX=function(flipX){this._flipX=flipX;var domain=this._scaleX.domain(),flip=flipX?-1:1;return this._scaleX.domain([flip*domain[0],flip*domain[1]]),this},Axis.prototype.flipY=function(flipY){this._flipY=flipY;var domain=this._scaleY.domain(),flip=flipY?-1:1;return this._scaleY.domain([flip*domain[0],flip*domain[1]]),this},Axis.prototype.showLabels=function(){return this._showLabels=!0,this.render(),this},Axis.prototype.hideLabels=function(){return this._showLabels=!1,this.render(),this},Axis.prototype.setLabelX=function(label){return this._labelXDesc=label,this},Axis.prototype.setLabelY=function(label){return this._labelYDesc=label,this},Axis.prototype.setUnitOfMeasure=function(uom){return this._unitOfMeasure=uom,this},Axis.prototype.setLabels=function(labelX,labelY,unitOfMeasure){return this._labelXDesc=labelX,this._labelYDesc=labelY,this._unitOfMeasure=unitOfMeasure,this},Object.defineProperty(Axis.prototype,"offsetX",{get:function(){return this._offsetX},set:function(offset){this._offsetX=offset},enumerable:!1,configurable:!0}),Object.defineProperty(Axis.prototype,"offsetY",{get:function(){return this._offsetY},set:function(offset){this._offsetY=offset},enumerable:!1,configurable:!0}),Object.defineProperty(Axis.prototype,"scaleX",{get:function(){return this._scaleX.copy()},enumerable:!1,configurable:!0}),Object.defineProperty(Axis.prototype,"scaleY",{get:function(){return this._scaleY.copy()},enumerable:!1,configurable:!0}),Axis}(),LayerManager=function(){function LayerManager(container,scaleOptions,axisOptions){var _this=this;if(this.layers=[],this.createAxis=function(options){var container=_this.container;_this._svgContainer=select(container).append("div").attr("class","axis").style("position","absolute").style("z-index","10").style("pointer-events","none");var svg=_this._svgContainer.append("svg").attr("height",container.offsetHeight+"px").attr("width",container.offsetWidth+"px");return new Axis(svg,!0,options.xLabel,options.yLabel,options.unitOfMeasure)},this.container=container,this.layerContainer=document.createElement("div"),this.layerContainer.className="layer-container",this.container.appendChild(this.layerContainer),this.adjustToSize(+this.container.getAttribute("width"),+this.container.getAttribute("height")),this._zoomPanHandler=new ZoomPanHandler(container,(function(event){return _this.rescale(event)})),scaleOptions){var xMin=scaleOptions.xMin,xMax=scaleOptions.xMax,yMin=scaleOptions.yMin,yMax=scaleOptions.yMax,xBounds=scaleOptions.xBounds,yBounds=scaleOptions.yBounds;void 0!==xMin&&void 0!==xMax&&void 0!==yMin&&void 0!==yMax&&this._zoomPanHandler.setBounds([xMin,xMax],[yMin,yMax]),xBounds&&yBounds&&this._zoomPanHandler.setBounds(xBounds,yBounds)}else this._zoomPanHandler.setBounds([0,1],[0,1]);axisOptions&&(this._axis=this.createAxis(axisOptions)),this.rescale=this.rescale.bind(this)}return LayerManager.prototype.addLayers=function(layers){var _this=this;return layers.forEach((function(layer){return _this.addLayer(layer)})),this},LayerManager.prototype.getLayers=function(){return this.layers},LayerManager.prototype.clearAllData=function(includeReferenceSystem){return void 0===includeReferenceSystem&&(includeReferenceSystem=!0),this.layers.forEach((function(l){return l.clearData(includeReferenceSystem)})),this},LayerManager.prototype.addLayer=function(layer,params){return this.layers.push(layer),this.initLayer(layer,params),this},LayerManager.prototype.removeLayer=function(layerId){var layer=this.layers.find((function(l){return l.id===layerId}));return layer&&(layer.onUnmount(),this.layers=this.layers.filter((function(l){return l.id!==layerId}))),this},LayerManager.prototype.removeAllLayers=function(){var _this=this;return this.layers.forEach((function(layer){_this.removeLayer(layer.id)})),this},LayerManager.prototype.getLayer=function(layerId){return this.layers.find((function(l){return l.id===layerId}))},LayerManager.prototype.initLayer=function(layer,params){var event={elm:this.layerContainer};layer.onMount(event);var rescaleEvent=this.zoomPanHandler.currentStateAsEvent();if(layer.onUpdate(__assign(__assign({},rescaleEvent),params)),layer.onRescale(rescaleEvent),this._svgContainer){var highestZIndex=this.layers.length>0?this.layers.reduce((function(max,layers){return max.order>layers.order?max:layers})).order:1;this._svgContainer.style("z-index",""+(highestZIndex+1))}return this},LayerManager.prototype.showLayer=function(layerId){var layer=this.getLayer(layerId);return layer.setVisibility(!0),layer.onRescale(this.zoomPanHandler.currentStateAsEvent()),this},LayerManager.prototype.hideLayer=function(layerId){return this.getLayer(layerId).setVisibility(!1),this},LayerManager.prototype.adjustToSize=function(width,height){var layersWidth=Math.max(this._axis?width-40:width,0),layersHeight=Math.max(this._axis?height-30:height,0);if(this._axis){var resizeEvent={width:width,height:height};this._axis.onResize(resizeEvent)}if(this.layers){var resizeEvent_1={width:layersWidth,height:layersHeight};this.layers.forEach((function(layer){return layer.onResize(resizeEvent_1)}))}this._zoomPanHandler&&this._zoomPanHandler.adjustToSize(layersWidth,layersHeight,!0)},LayerManager.prototype.setReferenceSystem=function(irs){this.layers.forEach((function(layer){return layer.referenceSystem=irs}))},LayerManager.prototype.showAxis=function(){return this._axis.show(),this},LayerManager.prototype.hideAxis=function(){return this._axis.hide(),this},LayerManager.prototype.showAxisLabels=function(){return this._axis.showLabels(),this},LayerManager.prototype.hideAxisLabels=function(){return this._axis.hideLabels(),this},LayerManager.prototype.setAxisOffset=function(x,y){return this._axis.offsetX=x,this._axis.offsetY=y,this.layers.filter((function(l){return l instanceof GridLayer})).forEach((function(l){l.offsetX=x,l.offsetY=y})),this},LayerManager.prototype.setXAxisOffset=function(x){return this._axis.offsetX=x,this.layers.filter((function(l){return l instanceof GridLayer})).forEach((function(l){l.offsetX=x})),this},LayerManager.prototype.setYAxisOffset=function(y){return this._axis.offsetY=y,this.layers.filter((function(l){return l instanceof GridLayer})).forEach((function(l){l.offsetY=y})),this},LayerManager.prototype.setZoomLevelBoundary=function(zoomlevels){return this._zoomPanHandler.setZoomLevelBoundary(zoomlevels),this},LayerManager.prototype.setMaxZoomLevel=function(zoomlevel){return this._zoomPanHandler.setMaxZoomLevel(zoomlevel),this},LayerManager.prototype.setMinZoomLevel=function(zoomlevel){return this._zoomPanHandler.setMinZoomLevel(zoomlevel),this},LayerManager.prototype.destroy=function(){return this.removeAllLayers(),this.layerContainer.remove(),this.layerContainer=void 0,this.container=void 0,this.layers=void 0,this._zoomPanHandler=void 0,this._axis=void 0,this._svgContainer=void 0,this},Object.defineProperty(LayerManager.prototype,"zoomPanHandler",{get:function(){return this._zoomPanHandler},enumerable:!1,configurable:!0}),Object.defineProperty(LayerManager.prototype,"axis",{get:function(){return this._axis},enumerable:!1,configurable:!0}),LayerManager.prototype.rescale=function(event){this._axis&&this._axis.onRescale(event),this.layers&&this.layers.forEach((function(layer){return!0===layer.isVisible?layer.onRescale(event):{}}))},LayerManager}(),RootFinder=function(){function RootFinder(){}return RootFinder.newton=function(func,precision,maxIterations,start,minLimit,maxLimit){void 0===precision&&(precision=.01),void 0===maxIterations&&(maxIterations=1e3),void 0===start&&(start=.5),void 0===minLimit&&(minLimit=0),void 0===maxLimit&&(maxLimit=1);for(var h=1e-4,t=start,i=0;i<maxIterations;i++){var v=func(t);if(Math.abs(v)<precision)return clamp(t,minLimit,maxLimit);t-=v/((func(t+h)-v)/h)}return null},RootFinder.bisect=function(func,precision,maxIterations,start,minLimit,maxLimit){void 0===precision&&(precision=.01),void 0===maxIterations&&(maxIterations=1e3),void 0===start&&(start=.5),void 0===minLimit&&(minLimit=0),void 0===maxLimit&&(maxLimit=1);var v,i,tl=minLimit,th=maxLimit,t=start;for(i=0;i<maxIterations;i++){if(v=func(t),Math.abs(v)<precision)return t;v<0?th=t:tl=t,t=(th+tl)/2}return t},RootFinder.findRoot=function(func,precision,maxIterations,start,minLimit,maxLimit){void 0===precision&&(precision=.01),void 0===maxIterations&&(maxIterations=1e3),void 0===start&&(start=.5),void 0===minLimit&&(minLimit=0),void 0===maxLimit&&(maxLimit=1);var t=RootFinder.newton(func,precision,maxIterations,start);return null==t&&(t=RootFinder.bisect(func,precision,maxIterations,start,minLimit,maxLimit)),t},RootFinder}(),ArcLength=function(){function ArcLength(){}return ArcLength.bisect=function(func,minLimit,maxLimit,tolerance,minDepth,maxDepth){void 0===minLimit&&(minLimit=0),void 0===maxLimit&&(maxLimit=1),void 0===tolerance&&(tolerance=.005),void 0===minDepth&&(minDepth=4),void 0===maxDepth&&(maxDepth=10);var calcRec=function(a,b,aVal,bVal,span,tolerance,depth){void 0===depth&&(depth=0);var mid=(a+b)/2,midVal=func(mid),spanA=Vector2.distance(aVal,midVal),spanB=Vector2.distance(midVal,bVal),length=spanA+spanB;if(depth>=minDepth&&Math.abs(length-span)<tolerance||depth>=maxDepth)return length;var tol=tolerance/2,d=depth+1;return calcRec(a,mid,aVal,midVal,spanA,tol,d)+calcRec(mid,b,midVal,bVal,spanB,tol,d)},aVal=func(minLimit),bVal=func(maxLimit),span=Vector2.distance(aVal,bVal);return calcRec(minLimit,maxLimit,aVal,bVal,span,tolerance)},ArcLength.trapezoid=function(func,minLimit,maxLimit,segments){void 0===minLimit&&(minLimit=0),void 0===maxLimit&&(maxLimit=1),void 0===segments&&(segments=1e3);for(var length=0,lastPos=func(minLimit),step=(maxLimit-minLimit)/(segments-1),i=1;i<segments;i++){var pos=func(minLimit+i*step);length+=Vector2.distance(lastPos,pos),lastPos=pos}return length},ArcLength}(),BinarySearch=function(){function BinarySearch(){}return BinarySearch.search=function(values,searchValue){for(var il=0,ih=values.length-1,i=Math.floor(il+ih/2);i>il&&i<ih;){var v=values[i],v1=values[i+1];if(v<=searchValue&&v1>=searchValue)return i;searchValue<v?ih=i:il=i,i=Math.floor(il+ih/2)}return i},BinarySearch}(),ExtendedCurveInterpolator=function(_super){function ExtendedCurveInterpolator(points,options){var _this=_super.call(this,points,options)||this;return _this.arcLengthLookup=[],_this.findTForArcLength=_this.findTForArcLength.bind(_this),_this.findTByRootForArcLength=_this.findTByRootForArcLength.bind(_this),_this.findApproxTForArcLength=_this.findApproxTForArcLength.bind(_this),_this.findTQuickForArcLength=_this.findTQuickForArcLength.bind(_this),_this.generateArcLengthLookup=_this.generateArcLengthLookup.bind(_this),_this.getArcLength=_this.getArcLength.bind(_this),_this.getQuickArcLength=_this.getQuickArcLength.bind(_this),_this.getPointAtArcLength=_this.getPointAtArcLength.bind(_this),_this.getPointAt=_this.getPointAt.bind(_this),_this}return __extends(ExtendedCurveInterpolator,_super),ExtendedCurveInterpolator.prototype.findTForArcLength=function(arcLength,options){return(null==options?void 0:options.approxT)?this.findApproxTForArcLength(arcLength,null==options?void 0:options.normalizedLength):(null==options?void 0:options.quickT)?this.findTQuickForArcLength(arcLength):this.findTByRootForArcLength(arcLength)},ExtendedCurveInterpolator.prototype.findTByRootForArcLength=function(arcLength,tolerance,iterations){var _this=this;return void 0===tolerance&&(tolerance=.01),void 0===iterations&&(iterations=100),arcLength<=0?0:arcLength>=this.length?1:RootFinder.findRoot((function(x){return arcLength-_this.getQuickArcLength(0,x)}),tolerance,iterations,arcLength/this.length)},ExtendedCurveInterpolator.prototype.findApproxTForArcLength=function(arcLength,normalizedLength){return arcLength/(normalizedLength||this.length)},ExtendedCurveInterpolator.prototype.findTQuickForArcLength=function(arcLength){0===this.arcLengthLookup.length&&this.generateArcLengthLookup();var index=BinarySearch.search(this.arcLengthLookup,arcLength),v1=this.arcLengthLookup[index];return(index+(arcLength-v1)/(this.arcLengthLookup[index+1]-v1))/this.arcLengthLookup.length},ExtendedCurveInterpolator.prototype.generateArcLengthLookup=function(segments){void 0===segments&&(segments=1e3);for(var lastPos=this.getPointAt(0),length=0,i=0;i<segments;i++){var pos=this.getPointAt(i/(segments-1));length+=Vector2.distance(lastPos,pos),this.arcLengthLookup.push(length),lastPos=pos}},ExtendedCurveInterpolator.prototype.getArcLength=function(from,to){var _this=this;return void 0===from&&(from=0),void 0===to&&(to=1),0===from&&1===to?this.length:ArcLength.bisect((function(t){return _this.getPointAt(t)}),from,to,.002)},ExtendedCurveInterpolator.prototype.getQuickArcLength=function(from,to){void 0===from&&(from=0),void 0===to&&(to=1);var fromLength=0,toLength=this.length;if(0===this.arcLengthLookup.length&&this.generateArcLengthLookup(),0!==from){var fromIndex=Math.floor(from*this.arcLengthLookup.length),fromLl=this.arcLengthLookup[fromIndex],fromLh=this.arcLengthLookup[fromIndex+1];fromLength=fromLl+from*this.arcLengthLookup.length%this.arcLengthLookup.length*(fromLh-fromLl)}if(1!==to){var toIndex=Math.floor(to*this.arcLengthLookup.length),toLl=this.arcLengthLookup[toIndex],toLh=this.arcLengthLookup[toIndex+1];toLength=toLl+from*this.arcLengthLookup.length%this.arcLengthLookup.length*(toLh-toLl)}return toLength-fromLength},ExtendedCurveInterpolator.prototype.getPointAtArcLength=function(arcLength,options){var t=this.findTForArcLength(arcLength,options);return this.getPointAt(t)},ExtendedCurveInterpolator.prototype.getPointAt=function(t){var tl=clamp(t,0,1);return _super.prototype.getPointAt.call(this,tl)},ExtendedCurveInterpolator}(CurveInterpolator),defaultOptions$2={approxT:!0},IntersectionReferenceSystem=function(){function IntersectionReferenceSystem(path,options){if(this.path=[],this.projectedPath=[],this._offset=0,path.length<1)throw new Error("Missing coordinates");if(path[0]&&3!==path[0].length)throw new Error("Coordinates should be in 3d");this.setPath(path,options),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.getPosition=this.getPosition.bind(this),this.getProjectedLength=this.getProjectedLength.bind(this),this.getTrajectory=this.getTrajectory.bind(this)}return IntersectionReferenceSystem.prototype.setPath=function(path,options){void 0===options&&(options={}),this.options=__assign(__assign({},defaultOptions$2),options);var _a=this.options,arcDivisions=_a.arcDivisions,tension=_a.tension,calculateDisplacementFromBottom=_a.calculateDisplacementFromBottom;this.path=path,this.projectedPath=IntersectionReferenceSystem.toDisplacement(path);var displacement=this.projectedPath[this.projectedPath.length-1][0];this.displacement=displacement,this.interpolators={curve:options.curveInterpolator||new ExtendedCurveInterpolator(path),trajectory:options.trajectoryInterpolator||new ExtendedCurveInterpolator(path.map((function(d){return[d[0],d[1]]})),{tension:tension||.75,arcDivisions:arcDivisions||5e3}),curtain:options.curtainInterpolator||new ExtendedCurveInterpolator(this.projectedPath,{tension:tension||.75,arcDivisions:arcDivisions||5e3})};var trajVector=this.getTrajectoryVector(),negativeTrajVector=trajVector.map((function(d){return-1*d}));calculateDisplacementFromBottom?(this.endVector=negativeTrajVector,this.startVector=trajVector):(this.endVector=trajVector,this.startVector=negativeTrajVector),this._curtainPathCache=void 0},IntersectionReferenceSystem.prototype.project=function(length){var curtain=this.interpolators.curtain,cl=clamp(this.options.calculateDisplacementFromBottom?this.length-(length-this._offset):length-this._offset,0,this.length);return curtain.getPointAtArcLength(cl,this.options)},IntersectionReferenceSystem.prototype.curtainTangent=function(length){var curtain=this.interpolators.curtain,l=length-this._offset,t=curtain.findTForArcLength(l,this.options);return t&&curtain.getTangentAt(t)},IntersectionReferenceSystem.prototype.getCurtainPath=function(start,end){if(!this._curtainPathCache){for(var points=[],prevAngle=2*Math.PI,i=this._offset;i<=this.length+this._offset;i+=.1){var point=this.project(i),angle=Math.atan2(point[1],point[0]);Math.abs(angle-prevAngle)>5e-4&&(points.push({point:point,md:i}),prevAngle=angle)}this._curtainPathCache=points}return this._curtainPathCache.filter((function(p){return p.md>=start&&p.md<=end}))},IntersectionReferenceSystem.prototype.unproject=function(displacement){var _a=this.options,normalizedLength=_a.normalizedLength,displacementFromStart=_a.calculateDisplacementFromBottom?this.displacement-displacement:displacement,length=normalizedLength||this.length;if(displacementFromStart<0)return displacementFromStart;if(displacementFromStart>this.displacement)return length+(displacementFromStart-this.displacement);var ls=this.interpolators.curtain.lookupPositions(displacementFromStart,0,1);return ls&&ls.length?ls[0]*length+this._offset:null},IntersectionReferenceSystem.prototype.getProjectedLength=function(length){var curtain=this.interpolators.curtain,l=this.project(length)[0]/curtain.maxX;return Number.isFinite(l)?clamp(l,0,1):0},IntersectionReferenceSystem.prototype.getPosition=function(length){var trajectory=this.interpolators.trajectory,t=this.getProjectedLength(length);return trajectory.getPointAt(t)},IntersectionReferenceSystem.prototype.getTrajectory=function(steps,from,to){void 0===from&&(from=0),void 0===to&&(to=1);var p0,p3,extensionStart=from<0?-from:0,extensionEnd=to>1?to-1:0,refStart=this.interpolators.trajectory.getPointAt(0),refEnd=this.interpolators.trajectory.getPointAt(1),offset=0,t0=Math.max(0,from),t1=Math.min(1,to),p1=this.interpolators.trajectory.getPointAt(t0),p2=this.interpolators.trajectory.getPointAt(t1);extensionStart?(p0=[refStart[0]+this.startVector[0]*extensionStart*this.displacement,refStart[1]+this.startVector[1]*extensionStart*this.displacement],offset=-Vector2.distance(p0,refStart)):from>0&&(offset=Vector2.distance(p1,refStart)),extensionEnd&&(p3=[refEnd[0]+this.endVector[0]*extensionEnd*this.displacement,refEnd[1]+this.endVector[1]*extensionEnd*this.displacement]);var points=[],tl=to-from,preSteps=Math.floor(extensionStart/tl*steps),curveSteps=Math.ceil((t1-t0)/tl*steps),postSteps=steps-curveSteps-preSteps;if(p0){points.push(p0);for(var i=1;i<preSteps;i++){var f=i/preSteps*extensionStart*this.displacement;points.push([p0[0]-this.startVector[0]*f,p0[1]-this.startVector[1]*f])}}var cuvePoints=this.interpolators.trajectory.getPoints(curveSteps-1,null,t0,t1);if(points.push.apply(points,cuvePoints),p3){for(i=1;i<postSteps-1;i++){f=i/postSteps*extensionEnd*this.displacement;points.push([p2[0]+this.endVector[0]*f,p2[1]+this.endVector[1]*f])}points.push(p3)}return{points:points,offset:offset}},IntersectionReferenceSystem.prototype.getExtendedTrajectory=function(numPoints,startExtensionLength,endExtensionLength){if(void 0===startExtensionLength&&(startExtensionLength=1e3),void 0===endExtensionLength&&(endExtensionLength=1e3),!isFinite(startExtensionLength)||startExtensionLength<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive startExtensionLength parameter");if(!isFinite(endExtensionLength)||endExtensionLength<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive endExtensionLength parameter");for(var totalLength=this.displacement+startExtensionLength+endExtensionLength,startExtensionNumPoints=Math.floor(startExtensionLength/totalLength*numPoints),curveSteps=Math.max(Math.ceil(this.displacement/totalLength*numPoints),1),endExtensionNumPoints=numPoints-curveSteps-startExtensionNumPoints,points=[],refStart=new Vector2(this.interpolators.trajectory.getPointAt(0)),startVec=new Vector2(this.startVector),startExtensionStepLength=startExtensionLength/startExtensionNumPoints,i=startExtensionNumPoints;i>0;i--){var f=i*startExtensionStepLength,point=refStart.add(startVec.scale(f));points.push(point.toArray())}points.push.apply(points,this.interpolators.trajectory.getPoints(curveSteps,null,0,1));var refEnd=new Vector2(this.interpolators.trajectory.getPointAt(1)),endVec=new Vector2(this.endVector),endExtensionStepLength=endExtensionLength/(endExtensionNumPoints-1);for(i=1;i<endExtensionNumPoints;i++){f=i*endExtensionStepLength,point=refEnd.add(endVec.scale(f));points.push(point.toArray())}return{points:points,offset:-startExtensionLength}},IntersectionReferenceSystem.prototype.getTrajectoryVector=function(){var _a=this.options,trajectoryAngle=_a.trajectoryAngle,calculateDisplacementFromBottom=_a.calculateDisplacementFromBottom;if(isFinite(trajectoryAngle)){var angleInRad=trajectoryAngle*DEG2RAD;return new Vector2(Math.cos(angleInRad),Math.sin(angleInRad)).toArray()}return IntersectionReferenceSystem.getDirectionVector(this.interpolators.trajectory,calculateDisplacementFromBottom?.001:.999,calculateDisplacementFromBottom?0:1)},IntersectionReferenceSystem.toDisplacement=function(points,offset){void 0===offset&&(offset=0);var p0=points[0],l=0;return points.map((function(p1){var dx=p1[0]-p0[0],dy=p1[1]-p0[1];return l+=Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2)),p0=p1,[offset>0?offset-l:l,p1[2]||0]}))},IntersectionReferenceSystem.getDirectionVector=function(interpolator,from,to){var p1=interpolator.getPointAt(to),p2=interpolator.getPointAt(from);return normalize$2([p1[0]-p2[0],p1[1]-p2[1]])},Object.defineProperty(IntersectionReferenceSystem.prototype,"length",{get:function(){return this.interpolators.curve.length},enumerable:!1,configurable:!0}),Object.defineProperty(IntersectionReferenceSystem.prototype,"offset",{get:function(){return this._offset},set:function(offset){this._curtainPathCache=void 0,this._offset=offset},enumerable:!1,configurable:!0}),IntersectionReferenceSystem}(),Overlay=function(){function Overlay(caller,container){var _this=this;this.elements={},this.listeners={},this.enabled=!0;var con=select(container);this.elm=con.append("div").attr("id","overlay").style("z-index","11").style("position","absolute"),this.source=this.elm.node();var elm=this.elm;elm.on("resize",(function(){var _a=event.detail,width=_a.width,height=_a.height;elm.style("width",width+"px").style("height",height+"px"),_this.enabled&&Object.keys(_this.listeners).forEach((function(key){var target=_this.elements[key]||null,ops=_this.listeners[key];ops&&ops.onResize&&requestAnimationFrame((function(){return ops.onResize({target:target,source:_this.source,caller:caller,width:width,height:height})}))}))})),elm.on("mousemove",(function(){if(_this.enabled){var _a=mouse(_this.elm.node()),mx=_a[0],my=_a[1];Object.keys(_this.listeners).forEach((function(key){var target=_this.elements[key]||null,ops=_this.listeners[key];ops&&ops.onMouseMove&&requestAnimationFrame((function(){return ops.onMouseMove({x:mx,y:my,target:target,source:_this.source,caller:caller})}))}))}})),elm.on("mouseout",(function(){_this.enabled&&Object.keys(_this.listeners).forEach((function(key){var target=_this.elements[key]||null,ops=_this.listeners[key];ops&&ops.onMouseExit&&requestAnimationFrame((function(){return ops.onMouseExit({target:target,source:_this.source,caller:caller})}))}))}))}return Overlay.prototype.create=function(key,callbacks){var newElm=this.elm.append("div").style("position","relative").style("pointer-events","none").node();return this.elements[key]=newElm,callbacks&&(this.listeners[key]=callbacks),newElm},Overlay.prototype.register=function(key,callbacks){this.listeners[key]=callbacks},Overlay.prototype.remove=function(key){var el=this.elements[key];el&&(select(el).remove(),delete this.elements[key]),delete this.listeners[key]},Overlay.prototype.setZIndex=function(zIndex){this.elm.style("z-index",zIndex)},Overlay.prototype.destroy=function(){this.source.remove()},Overlay}(),Controller=function(){function Controller(options){var container=options.container,axisOptions=options.axisOptions,scaleOptions=options.scaleOptions,referenceSystem=options.referenceSystem,layers=options.layers,path=options.path;this._referenceSystem=referenceSystem||path&&new IntersectionReferenceSystem(path),this._overlay=function(caller,container){return new Overlay(caller,container)}(this,container),this.layerManager=new LayerManager(this._overlay.elm.node(),scaleOptions,axisOptions),layers&&(this.layerManager.addLayers(layers),this.setOverlayZIndex(layers))}return Controller.prototype.setReferenceSystem=function(referenceSystem){return this._referenceSystem=referenceSystem,this.layerManager.setReferenceSystem(referenceSystem),this},Controller.prototype.updatePath=function(path,options){return this.setReferenceSystem(new IntersectionReferenceSystem(path,options)),this},Controller.prototype.clearAllData=function(includeReferenceSystem){return void 0===includeReferenceSystem&&(includeReferenceSystem=!0),this.layerManager.clearAllData(includeReferenceSystem),this},Controller.prototype.addLayer=function(layer,params){return this.layerManager.addLayer(layer,params),this.setOverlayZIndex(this.layerManager.getLayers()),this},Controller.prototype.removeLayer=function(layerId){return this.layerManager.removeLayer(layerId),this},Controller.prototype.removeAllLayers=function(){return this.layerManager.removeAllLayers(),this},Controller.prototype.getLayer=function(layerId){return this.layerManager.getLayer(layerId)},Controller.prototype.showLayer=function(layerId){return this.layerManager.showLayer(layerId),this},Controller.prototype.hideLayer=function(layerId){return this.layerManager.hideLayer(layerId),this},Controller.prototype.adjustToSize=function(width,height){this.layerManager.adjustToSize(width,height);var dimensions={width:Math.max(width-40,0),height:Math.max(height-30,0)};return this.overlay.elm.dispatch("resize",{detail:dimensions,bubbles:!0,cancelable:!0}),this},Controller.prototype.setViewport=function(cx,cy,displacement,duration){return this.zoomPanHandler.setViewport(cx,cy,displacement,duration),this},Controller.prototype.setBounds=function(xBounds,yBounds){return this.zoomPanHandler.setBounds(xBounds,yBounds),this},Controller.prototype.showAxis=function(){return this.layerManager.showAxis(),this},Controller.prototype.hideAxis=function(){return this.layerManager.hideAxis(),this},Controller.prototype.showAxisLabels=function(){return this.layerManager.showAxisLabels(),this},Controller.prototype.hideAxisLabels=function(){return this.layerManager.hideAxisLabels(),this},Controller.prototype.setAxisOffset=function(x,y){return this.layerManager.setAxisOffset(x,y),this},Controller.prototype.setXAxisOffset=function(x){return this.layerManager.setXAxisOffset(x),this},Controller.prototype.setYAxisOffset=function(y){return this.layerManager.setYAxisOffset(y),this},Controller.prototype.setZoomLevelBoundary=function(zoomlevels){return this.zoomPanHandler.setZoomLevelBoundary(zoomlevels),this},Controller.prototype.setMaxZoomLevel=function(zoomlevel){return this.zoomPanHandler.setMaxZoomLevel(zoomlevel),this},Controller.prototype.setMinZoomLevel=function(zoomlevel){return this.zoomPanHandler.setMinZoomLevel(zoomlevel),this},Controller.prototype.destroy=function(){return this.layerManager.destroy(),this._overlay.destroy(),this._referenceSystem=void 0,this.layerManager=void 0,this._overlay=void 0,this},Controller.prototype.getHighestZIndex=function(layers){return layers.length>0?layers.reduce((function(max,layers){return max.order>layers.order?max:layers})).order:1},Controller.prototype.setOverlayZIndex=function(layers){var highestZIndex=this.getHighestZIndex(layers);this.overlay.setZIndex(highestZIndex+2)},Object.defineProperty(Controller.prototype,"overlay",{get:function(){return this._overlay},enumerable:!1,configurable:!0}),Object.defineProperty(Controller.prototype,"referenceSystem",{get:function(){return this._referenceSystem},enumerable:!1,configurable:!0}),Object.defineProperty(Controller.prototype,"zoomPanHandler",{get:function(){return this.layerManager.zoomPanHandler},enumerable:!1,configurable:!0}),Object.defineProperty(Controller.prototype,"axis",{get:function(){return this.layerManager.axis},enumerable:!1,configurable:!0}),Object.defineProperty(Controller.prototype,"currentStateAsEvent",{get:function(){return this.zoomPanHandler.currentStateAsEvent()},enumerable:!1,configurable:!0}),Controller}();exports.Axis=Axis,exports.CalloutCanvasLayer=CalloutCanvasLayer,exports.CanvasLayer=CanvasLayer,exports.CasingLayer=CasingLayer,exports.CementLayer=CementLayer,exports.CompletionLayer=CompletionLayer,exports.Controller=Controller,exports.GeomodelCanvasLayer=GeomodelCanvasLayer,exports.GeomodelLabelsLayer=GeomodelLabelsLayer,exports.GeomodelLayer=GeomodelLayer,exports.GeomodelLayerV2=GeomodelLayerV2,exports.GridLayer=GridLayer,exports.HTMLLayer=HTMLLayer,exports.HoleSizeLayer=HoleSizeLayer,exports.ImageLayer=ImageLayer,exports.IntersectionReferenceSystem=IntersectionReferenceSystem,exports.Layer=Layer,exports.LayerManager=LayerManager,exports.PixiLayer=PixiLayer,exports.SVGLayer=SVGLayer,exports.SeismicCanvasLayer=SeismicCanvasLayer,exports.WellborepathLayer=WellborepathLayer,exports.ZoomPanHandler=ZoomPanHandler,exports.calcSize=calcSize,exports.findIndexOfSample=findIndexOfSample,exports.findSampleAtPos=findSampleAtPos,exports.generateProjectedTrajectory=function(poslog,defaultIntersectionAngle){if(!poslog||0===poslog.length)return[];var points=poslog?poslog.map((function(p){return[p.easting,p.northing,p.tvd,p.md]})):[],interpolator=new CurveInterpolator(points,{tension:.75,arcDivisions:5e3}),displacement=interpolator.length,nPoints=Math.round(10*displacement),path=null,first=(path=nPoints>0?simplify(interpolator.getPoints(nPoints),5e-4,10):[[points[0][0],points[0][1]]])[0],last=path[path.length-1],relativeDist=Vector2.distance(first,last),v=null;if(relativeDist<150){var radCurtainDirection=defaultIntersectionAngle/180*Math.PI;v=new Vector2(Math.cos(radCurtainDirection),Math.sin(radCurtainDirection)).mutable}else v=function(path,threshold){for(var res=Vector2.zero.mutable,len=0,temp=Vector2.zero.mutable,i=0;i<path.length-1;i++){var index=path.length-1-i;if(temp.set(path[index]).sub(path[index-1]),res.add(temp),(len=res.magnitude)>threshold)break}return 0===len?new Vector2([0,0]):res.scale(1/len)}(path,30);var extensionLengthStart=Math.max(0,1e3-displacement),offset=extensionLengthStart+displacement,trajectory=[],firstPoints=[],initial=v.toArray();extensionLengthStart>0&&((firstPoints=seqI(Math.ceil(.1*extensionLengthStart)).map((function(t){return v.set(initial).scale(extensionLengthStart*(1-t)).subFrom(first).toArray()}))).pop(),trajectory.push.apply(trajectory,firstPoints)),trajectory.push.apply(trajectory,path);var endPoints=seqI(Math.ceil(100)).map((function(t){return v.set(initial).scale(1e3*t).add(last).toArray()})).splice(1);return trajectory.push.apply(trajectory,endPoints),Vector2.angleRight(initial),projectCurtain(trajectory,null,offset)},exports.generateProjectedWellborePath=function(poslog){if(!poslog||0===poslog.length)return[];var projection=simplify(projectCurtain(poslog?poslog.map((function(p){return[p.easting,p.northing,p.tvd,p.md]})):[])),offset=projection[projection.length-1][0];return projection.forEach((function(p,i){projection[i][0]=offset-p[0]})),projection},exports.generateSeismicSliceImage=function(data,trajectory,colormap,options){return __awaiter(this,void 0,void 0,(function(){var dp,min,max,absMax,dmin,dmax,domain,length,width,height,colorTable,d,offset,colorFactor,pos,step,val1,val2,i,col,black,opacity,x,index,x1,x2,ratio,y,imageData;return __generator(this,(function(_a){switch(_a.label){case 0:if(!(data&&data.datapoints&&data.datapoints.length>0))return[2];for(dp=data.datapoints,min=(null==options?void 0:options.seismicMin)||(null==options?void 0:options.seismicRange)||dp.reduce((function(val,array){return Math.min.apply(Math,__spreadArray(__spreadArray([],array),[val]))}),0),max=(null==options?void 0:options.seismicMax)||(null==options?void 0:options.seismicRange)||dp.reduce((function(val,array){return Math.max.apply(Math,__spreadArray(__spreadArray([],array),[val]))}),0),absMax=Math.max(Math.abs(min),Math.abs(max)),domain={min:dmin=-absMax,max:dmax=absMax,difference:dmax-dmin},length=trajectory[0][0]-trajectory[trajectory.length-1][0],width=Math.abs(Math.floor(length/5)),height=data.yAxisValues.length,1e3,size=1e3,colorDomain=(colorMap=colormap).map((function(v,i){return i*size/colorMap.length})),colorScale=linear$1().domain(colorDomain).range(colorMap),colorTable=Array.from(new Array(size).keys()).map((function(i){var rgb=color(colorScale(i)).rgb();return[rgb.r,rgb.g,rgb.b]})),d=new Uint8ClampedArray(width*height*4),offset=0,colorFactor=999/domain.difference,pos=(null==options?void 0:options.isLeftToRight)?trajectory[0][0]:trajectory[trajectory.length-1][0],step=length/width*((null==options?void 0:options.isLeftToRight)?-1:1),black=[0,0,0],x=0;x<width;x++){for(offset=4*x,index=findIndexOfSample(trajectory,pos),x1=trajectory[index][0],x2=trajectory[index+1][0],ratio=(pos-x1)/(x2-x1),y=0;y<height;y++)val1=dp[y][index],val2=dp[y][index+1],null==val1||null==val2?(col=black,opacity=0):(i=(val1*(1-ratio)+val2*ratio-domain.min)*colorFactor,i=clamp(Math.floor(i),0,999),col=colorTable[i],opacity=255),d.set([col[0],col[1],col[2],opacity],offset),offset+=4*width;pos+=step}return imageData=new ImageData(d,width,height),[4,createImageBitmap(imageData,0,0,width,height)];case 1:return[2,_a.sent()]}var colorMap,size,colorDomain,colorScale}))}))},exports.generateSurfaceData=function(trajectory,stratColumn,surfaceData){if(!(trajectory.length<0)){var filteredSurfaces=surfaceData.filter((function(s){return s.data.values})),mappedSurfaces=filteredSurfaces.map((function(s){var displayName=s.visualSettings.displayName;return{name:displayName.replace(/\s(Base|Top)/gi,""),isBase:displayName.toLowerCase().endsWith("base"),values:s.data.values,color:s.visualSettings.colors.crossSection,visualization:s.visualSettings.crossSection.toLowerCase()}})),stratGroups=new Map,stratigraphies=function(mappedSurfaces,stratColumn,stratGroups){var firstUnit=stratColumn&&stratColumn.find((function(d){return 1===d.stratUnitLevel})),defaultGroupName=firstUnit?firstUnit.identifier:"SEABED";return mappedSurfaces.filter((function(d){return"interval"===d.visualization||"none"===d.visualization})).map((function(s){var path=[],stratUnit=findStratcolumnUnit(stratColumn,s.name,path);stratUnit||console.warn("No match for "+s.name+" in strat column");var group=path[0]||stratUnit,groupName=group&&group.identifier||defaultGroupName;return group&&!stratGroups.has(groupName)&&stratGroups.set(groupName,{age:group.topAge,name:group.identifier}),__assign(__assign({},s),{unit:stratUnit,group:groupName})}))}(mappedSurfaces,stratColumn,stratGroups);stratigraphies.sort((function(a,b){if(!a.unit&&!b.unit)return 0;if(!a.unit)return-1;if(!b.unit)return 1;var aAge=a.isBase?a.unit.baseAge:a.unit.topAge,bAge=b.isBase?b.unit.baseAge:b.unit.topAge;return aAge!==bAge?aAge-bAge:a.isBase&&!b.isBase?1:!a.isBase&&b.isBase?-1:a.unit.stratUnitLevel-b.unit.stratUnitLevel}));var lines=function(mappedSurfaces,trajectory){return mappedSurfaces.filter((function(d){return"line"===d.visualization})).map((function(l){return{id:l.name,label:l.name,width:2,color:convertColor(l.color||"black"),data:trajectory.map((function(p,j){return[p[0],l.values[j]]}))}}))}(mappedSurfaces,trajectory),surfaceAreas=function(projection,surfaces,stratColumn){return surfaces.reduce((function(acc,surface,i){if(!surface.isBase){acc[surface.group]||(acc[surface.group]=[]);var baseIndex_1=function(top,index,surfaces,stratColumn){var nextIndex=index+1;if(!surfaces||nextIndex>=surfaces.length)return null;var baseSurfaceIndex=surfaces.findIndex((function(candidate){return candidate.isBase&&candidate.name===top.name}));if(-1!==baseSurfaceIndex)return baseSurfaceIndex;for(var i=nextIndex;i<surfaces.length;i++){var candidate=surfaces[i];if(!candidate.isBase)return i;if(isAnchestor(top,candidate,stratColumn))return i}return null}(surface,i,surfaces,stratColumn);acc[surface.group].push({id:surface.name,label:surface.name,color:surface.unit&&getColorFromUnit(surface.unit)||4294967295,exclude:"none"===surface.visualization||!surface.unit,data:projection.map((function(p,j){var baseValue=null!==surface.values[j]?function(index,surfaces,datapoint){if(!surfaces||!index||index>=surfaces.length)return null;for(var i=index;i<surfaces.length;i++)if(null!==surfaces[i].values[datapoint])return surfaces[i].values[datapoint];return null}(baseIndex_1,surfaces,j):null;return[p[0],surface.values[j],baseValue]}))})}return acc}),{})}(trajectory,stratigraphies,stratColumn);return{lines:lines,areas:__spreadArray(__spreadArray([],function(groups,trajectory){return groups.map((function(g,i){var next=i+1<groups.length?groups[i+1]:null;return{id:g.id,color:convertColor(g.color),data:trajectory.map((function(p,j){return[p[0],g.top[j],next?next.top[j]:null]}))}}))}(function(stratGroups,surfaceAreas){return Array.from(stratGroups.values()).sort((function(a,b){return a.age-b.age})).filter((function(g){var surfaces=surfaceAreas[g.name],isValid=surfaces&&surfaces.length>0;return isValid||console.warn("Intersection surface group '"+g.name+"' has no valid entries and will be discarded."),isValid})).map((function(g,i){var top=surfaceAreas[g.name][0];return{id:g.name,label:g.name,color:unassignedColorScale(i),top:top.data.map((function(d){return d[1]}))}}))}(stratGroups,surfaceAreas),trajectory)),Object.values(surfaceAreas).flat().filter((function(d){return!d.exclude})))}}},exports.getOverlap=function(r1,r2){var r1x2=r1.x+r1.width,r2x2=r2.x+r2.width,r1y2=r1.y+r1.height,r2y2=r2.y+r2.height;return r2.x>r1x2||r2.y>r1y2||r2x2<r1.x||r2y2<r1.y?null:{dx:Math.max(0,Math.min(r1.x+r1.width,r2.x+r2.width)-Math.max(r1.x,r2.x)),dy:Math.max(0,Math.min(r1.y+r1.height,r2.y+r2.height)-Math.max(r1.y,r2.y))}},exports.getOverlapOffset=getOverlapOffset,exports.getPicksData=function(picksData){var formationPicks,unitPicks=picksData.unitPicks,picks=__spreadArray(__spreadArray(__spreadArray([],function(picks){return picks?picks.map((function(p){return mapPick(p,"ref-picks")})):[]}(picksData.nonUnitPicks)),(formationPicks=unitPicks)?formationPicks.filter((function(d){return d.entryPick.md===d.from})).map((function(p){return mapPick(p.entryPick,"strat-picks")})):[]),function(formationPicks){return formationPicks?formationPicks.filter((function(d){return-1===formationPicks.findIndex((function(p){return Math.abs(p.entryPick.md-d.exitPick.md)<.5}))})).map((function(p){return mapPick(p.exitPick,"strat-picks")})).filter((function(obj,i,array){return i===array.findIndex((function(v){return v.title===obj.title&&v.md===obj.md}))})):[]}(unitPicks));return picks.sort((function(a,b){return a.md-b.md})),picks},exports.getSeismicInfo=function(data,trajectory){if(data&&data.datapoints){var minX=trajectory.reduce((function(acc,val){return Math.min(acc,val[0])}),0),maxX=trajectory.reduce((function(acc,val){return Math.max(acc,val[0])}),0),minTvdMsl=data.yAxisValues&&data.yAxisValues[0],maxTvdMsl=data.yAxisValues&&data.yAxisValues[data.yAxisValues.length-1],dp=data.datapoints||[],min=-dp.reduce((function(val,array){return Math.min.apply(Math,__spreadArray(__spreadArray([],array),[val]))}),0),max=dp.reduce((function(val,array){return Math.max.apply(Math,__spreadArray(__spreadArray([],array),[val]))}),0),absMax=Math.max(Math.abs(min),Math.abs(max)),dmin=-absMax;return{minX:minX,maxX:maxX,minTvdMsl:minTvdMsl,maxTvdMsl:maxTvdMsl,domain:{min:dmin,max:absMax,difference:absMax-dmin}}}},exports.isOverlapping=isOverlapping,exports.isOverlappingHorizontally=function(r1,r2){var r1x2=r1.x+r1.width,r2x2=r2.x+r2.width;return!(r2.x>r1x2||r2x2<r1.x)},exports.pixelsPerUnit=pixelsPerUnit,exports.transformFormationData=function(picks,stratColumn){for(var _a=function(picks,stratColumn){var transformed=function(units,res){void 0===res&&(res=[]);for(var i=0;i<units.length;i+=1){var unit={unitName:(u=units[i]).identifier,topSurface:u.top,baseSurface:u.base,ageBase:u.baseAge,ageTop:u.topAge,color:{r:null===u.colorR?255:u.colorR,g:null===u.colorG?255:u.colorG,b:null===u.colorB?255:u.colorB},level:u.stratUnitLevel,lithType:u.lithologyType,parent:u.stratUnitParent};res.push(unit)}var u;return res}(stratColumn),nonUnitPicks=[],joined=[];return picks.forEach((function(p){var matches=transformed.filter((function(u){return-1!==p.pickIdentifier.search(new RegExp("("+u.topSurface+"|"+u.baseSurface+")","i"))}));matches.length>0?matches.forEach((function(u){return joined.push(__assign({md:p.md,tvd:p.tvd,identifier:p.pickIdentifier,confidence:p.confidence,mdUnit:p.mdUnit,depthReferencePoint:p.depthReferencePoint},u))})):nonUnitPicks.push(p)})),{joined:joined,nonUnitPicks:nonUnitPicks}}(picks,stratColumn),joined=_a.joined,nonUnitPicks=_a.nonUnitPicks,itemstack=function(joined){for(var pairs=[],current=null,sorted=joined.filter((function(d){return d.level})).sort((function(a,b){return a.unitName.localeCompare(b.unitName)||a.md-b.md||a.ageTop-b.ageTop})),_loop_1=function(){var _a,pairWithName,top_1,base,name_1=(current=sorted.shift()).identifier,isTop=name_1===current.topSurface,isBase=name_1===current.baseSurface;if(isTop)pairWithName=current.baseSurface;else{if(!isBase)return console.warn("Unable to match "+name_1+" with top or base surface, ignored"),"continue";pairWithName=current.topSurface}var pairWith=sorted.find((function(p){return p.identifier===pairWithName}));if(pairWith)base=isTop?pairWith:current,(top_1=isTop?current:pairWith).md>base.md&&(top_1=(_a=[base,top_1])[0],base=_a[1]),sorted.splice(sorted.indexOf(pairWith),1);else if(console.warn("Unable to find "+pairWithName+" pick for "+name_1),isTop){if(top_1=current,!(base=joined.filter((function(d){return d.level})).sort((function(a,b){return a.md-b.md})).find((function(p){return p.md>top_1.md}))))return console.warn("Unable to find a base pick for "+name_1+" pick at "+top_1.md+", ignored"),"continue";console.warn("Using "+base.identifier+" as base for "+name_1)}else{if(!isBase)return console.warn(name_1+" ignored"),"continue";if(base=current,!(top_1=joined.filter((function(d){return d.level})).sort((function(a,b){return b.md-a.md})).find((function(p){return p.md<base.md}))))return console.warn("Unable to find a top pick for "+name_1+" pick at "+base.md+", ignored"),"continue";console.warn("Using "+top_1.identifier+" as top for "+name_1)}pairs.push({name:top_1.unitName,mdEntry:top_1.md,tvdEntry:top_1.tvd,color:top_1.color,level:top_1.level,entryPick:top_1,mdExit:base.md,tvdExit:base.tvd,exitPick:base,confidenceEntry:top_1.confidence,confidenceExit:base.confidence})};sorted.length>0;)_loop_1();return pairs}(joined).filter((function(d){return d.mdEntry<d.mdExit})).sort((function(a,b){return a.mdEntry-b.mdEntry||a.level-b.level})).reverse(),unitPicks=[],_loop_2=function(){for(var first=itemstack.pop(),group=[];itemstack.length>0&&itemstack[itemstack.length-1].level>first.level;)group.push(itemstack.pop());group.reverse(),group.push(first);var arr=[];group.forEach((function(itm){var gaps=function(from,to,arr){if(0===arr.length)return[[from,to]];for(var gaps=[],d=from,i=0;d<to&&i<arr.length;){var itm=arr[i];itm.from>d&&gaps.push([d,Math.min(itm.from,to)]),d=Math.min(to,Math.max(from,itm.to)),i+=1}return d<to&&gaps.push([d,to]),gaps}(itm.mdEntry,itm.mdExit,arr);arr.push.apply(arr,gaps.map((function(g){return{from:g[0],to:g[1],itm:itm}}))),arr.sort((function(a,b){return a.from-b.from}))})),unitPicks.push.apply(unitPicks,arr.map((function(d){return __assign({from:d.from,to:d.to},d.itm)})))};itemstack.length>0;)_loop_2();return{unitPicks:unitPicks,nonUnitPicks:nonUnitPicks}},Object.defineProperty(exports,"__esModule",{value:!0})}));
|