@equinor/esv-intersection 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(P,z){typeof exports=="object"&&typeof module<"u"?z(exports,require("pixi.js")):typeof define=="function"&&define.amd?define(["exports","pixi.js"],z):(P=typeof globalThis<"u"?globalThis:P||self,z(P.esvintersection={},P.PIXI))})(this,function(P,z){"use strict";function xs(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const st=xs(z);function vs(e){return e}var Be=1,te=2,Ie=3,ee=4,Xn=1e-6;function ws(e){return"translate("+e+",0)"}function bs(e){return"translate(0,"+e+")"}function Ss(e){return t=>+e(t)}function Ts(e,t){return t=Math.max(0,e.bandwidth()-t*2)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function Ms(){return!this.__axis}function jn(e,t){var n=[],i=null,r=null,s=6,o=6,a=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,h=e===Be||e===ee?-1:1,l=e===ee||e===te?"x":"y",u=e===Be||e===Ie?ws:bs;function f(g){var d=i??(t.ticks?t.ticks.apply(t,n):t.domain()),p=r??(t.tickFormat?t.tickFormat.apply(t,n):vs),y=Math.max(s,0)+a,_=t.range(),x=+_[0]+c,v=+_[_.length-1]+c,C=(t.bandwidth?Ts:Ss)(t.copy(),c),b=g.selection?g.selection():g,S=b.selectAll(".domain").data([null]),M=b.selectAll(".tick").data(d,t).order(),R=M.exit(),F=M.enter().append("g").attr("class","tick"),O=M.select("line"),A=M.select("text");S=S.merge(S.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),M=M.merge(F),O=O.merge(F.append("line").attr("stroke","currentColor").attr(l+"2",h*s)),A=A.merge(F.append("text").attr("fill","currentColor").attr(l,h*y).attr("dy",e===Be?"0em":e===Ie?"0.71em":"0.32em")),g!==b&&(S=S.transition(g),M=M.transition(g),O=O.transition(g),A=A.transition(g),R=R.transition(g).attr("opacity",Xn).attr("transform",function(E){return isFinite(E=C(E))?u(E+c):this.getAttribute("transform")}),F.attr("opacity",Xn).attr("transform",function(E){var I=this.parentNode.__axis;return u((I&&isFinite(I=I(E))?I:C(E))+c)})),R.remove(),S.attr("d",e===ee||e===te?o?"M"+h*o+","+x+"H"+c+"V"+v+"H"+h*o:"M"+c+","+x+"V"+v:o?"M"+x+","+h*o+"V"+c+"H"+v+"V"+h*o:"M"+x+","+c+"H"+v),M.attr("opacity",1).attr("transform",function(E){return u(C(E)+c)}),O.attr(l+"2",h*s),A.attr(l,h*y).text(p),b.filter(Ms).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",e===te?"start":e===ee?"end":"middle"),b.each(function(){this.__axis=C})}return f.scale=function(g){return arguments.length?(t=g,f):t},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(g){return arguments.length?(n=g==null?[]:Array.from(g),f):n.slice()},f.tickValues=function(g){return arguments.length?(i=g==null?null:Array.from(g),f):i&&i.slice()},f.tickFormat=function(g){return arguments.length?(r=g,f):r},f.tickSize=function(g){return arguments.length?(s=o=+g,f):s},f.tickSizeInner=function(g){return arguments.length?(s=+g,f):s},f.tickSizeOuter=function(g){return arguments.length?(o=+g,f):o},f.tickPadding=function(g){return arguments.length?(a=+g,f):a},f.offset=function(g){return arguments.length?(c=+g,f):c},f}function As(e){return jn(te,e)}function Ps(e){return jn(Ie,e)}function ne(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Cs(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function qn(e){let t,n,i;e.length!==2?(t=ne,n=(a,c)=>ne(e(a),c),i=(a,c)=>e(a)-c):(t=e===ne||e===Cs?e:Ls,n=e,i=e);function r(a,c,h=0,l=a.length){if(h<l){if(t(c,c)!==0)return l;do{const u=h+l>>>1;n(a[u],c)<0?h=u+1:l=u}while(h<l)}return h}function s(a,c,h=0,l=a.length){if(h<l){if(t(c,c)!==0)return l;do{const u=h+l>>>1;n(a[u],c)<=0?h=u+1:l=u}while(h<l)}return h}function o(a,c,h=0,l=a.length){const u=r(a,c,h,l-1);return u>h&&i(a[u-1],c)>-i(a[u],c)?u-1:u}return{left:r,center:o,right:s}}function Ls(){return 0}function ks(e){return e===null?NaN:+e}const Es=qn(ne).right;qn(ks).center;const Rs=Es;class Zn extends Map{constructor(t,n=Ds){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[i,r]of t)this.set(i,r)}get(t){return super.get(Kn(this,t))}has(t){return super.has(Kn(this,t))}set(t,n){return super.set(Fs(this,t),n)}delete(t){return super.delete(zs(this,t))}}function Kn({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):n}function Fs({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):(e.set(i,n),n)}function zs({_intern:e,_key:t},n){const i=t(n);return e.has(i)&&(n=e.get(n),e.delete(i)),n}function Ds(e){return e!==null&&typeof e=="object"?e.valueOf():e}var He=Math.sqrt(50),Ve=Math.sqrt(10),Ue=Math.sqrt(2);function Os(e,t,n){var i,r=-1,s,o,a;if(t=+t,e=+e,n=+n,e===t&&n>0)return[e];if((i=t<e)&&(s=e,e=t,t=s),(a=Qn(e,t,n))===0||!isFinite(a))return[];if(a>0){let c=Math.round(e/a),h=Math.round(t/a);for(c*a<e&&++c,h*a>t&&--h,o=new Array(s=h-c+1);++r<s;)o[r]=(c+r)*a}else{a=-a;let c=Math.round(e*a),h=Math.round(t*a);for(c/a<e&&++c,h/a>t&&--h,o=new Array(s=h-c+1);++r<s;)o[r]=(c+r)/a}return i&&o.reverse(),o}function Qn(e,t,n){var i=(t-e)/Math.max(0,n),r=Math.floor(Math.log(i)/Math.LN10),s=i/Math.pow(10,r);return r>=0?(s>=He?10:s>=Ve?5:s>=Ue?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(s>=He?10:s>=Ve?5:s>=Ue?2:1)}function Ns(e,t,n){var i=Math.abs(t-e)/Math.max(0,n),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),s=i/r;return s>=He?r*=10:s>=Ve?r*=5:s>=Ue&&(r*=2),t<e?-r:r}function We(e,t){let n;if(t===void 0)for(const i of e)i!=null&&(n<i||n===void 0&&i>=i)&&(n=i);else{let i=-1;for(let r of e)(r=t(r,++i,e))!=null&&(n<r||n===void 0&&r>=r)&&(n=r)}return n}function Ye(e,t){let n=0;if(t===void 0)for(let i of e)(i=+i)&&(n+=i);else{let i=-1;for(let r of e)(r=+t(r,++i,e))&&(n+=r)}return n}function Jn(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}const ti=Symbol("implicit");function ei(){var e=new Zn,t=[],n=[],i=ti;function r(s){let o=e.get(s);if(o===void 0){if(i!==ti)return i;e.set(s,o=t.push(s)-1)}return n[o%n.length]}return r.domain=function(s){if(!arguments.length)return t.slice();t=[],e=new Zn;for(const o of s)e.has(o)||e.set(o,t.push(o)-1);return r},r.range=function(s){return arguments.length?(n=Array.from(s),r):n.slice()},r.unknown=function(s){return arguments.length?(i=s,r):i},r.copy=function(){return ei(t,n).unknown(i)},Jn.apply(r,arguments),r}function Ge(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ni(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function Nt(){}var $t=.7,ie=1/$t,Ct="\\s*([+-]?\\d+)\\s*",Bt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ot="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",$s=/^#([0-9a-f]{3,8})$/,Bs=new RegExp(`^rgb\\(${Ct},${Ct},${Ct}\\)$`),Is=new RegExp(`^rgb\\(${ot},${ot},${ot}\\)$`),Hs=new RegExp(`^rgba\\(${Ct},${Ct},${Ct},${Bt}\\)$`),Vs=new RegExp(`^rgba\\(${ot},${ot},${ot},${Bt}\\)$`),Us=new RegExp(`^hsl\\(${Bt},${ot},${ot}\\)$`),Ws=new RegExp(`^hsla\\(${Bt},${ot},${ot},${Bt}\\)$`),ii={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};Ge(Nt,ht,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ri,formatHex:ri,formatHex8:Ys,formatHsl:Gs,formatRgb:si,toString:si});function ri(){return this.rgb().formatHex()}function Ys(){return this.rgb().formatHex8()}function Gs(){return li(this).formatHsl()}function si(){return this.rgb().formatRgb()}function ht(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=$s.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?oi(t):n===3?new G(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?re(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?re(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Bs.exec(e))?new G(t[1],t[2],t[3],1):(t=Is.exec(e))?new G(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Hs.exec(e))?re(t[1],t[2],t[3],t[4]):(t=Vs.exec(e))?re(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Us.exec(e))?hi(t[1],t[2]/100,t[3]/100,1):(t=Ws.exec(e))?hi(t[1],t[2]/100,t[3]/100,t[4]):ii.hasOwnProperty(e)?oi(ii[e]):e==="transparent"?new G(NaN,NaN,NaN,0):null}function oi(e){return new G(e>>16&255,e>>8&255,e&255,1)}function re(e,t,n,i){return i<=0&&(e=t=n=NaN),new G(e,t,n,i)}function Xs(e){return e instanceof Nt||(e=ht(e)),e?(e=e.rgb(),new G(e.r,e.g,e.b,e.opacity)):new G}function Xe(e,t,n,i){return arguments.length===1?Xs(e):new G(e,t,n,i??1)}function G(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}Ge(G,Xe,ni(Nt,{brighter(e){return e=e==null?ie:Math.pow(ie,e),new G(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?$t:Math.pow($t,e),new G(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new G(bt(this.r),bt(this.g),bt(this.b),se(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ai,formatHex:ai,formatHex8:js,formatRgb:ci,toString:ci}));function ai(){return`#${St(this.r)}${St(this.g)}${St(this.b)}`}function js(){return`#${St(this.r)}${St(this.g)}${St(this.b)}${St((isNaN(this.opacity)?1:this.opacity)*255)}`}function ci(){const e=se(this.opacity);return`${e===1?"rgb(":"rgba("}${bt(this.r)}, ${bt(this.g)}, ${bt(this.b)}${e===1?")":`, ${e})`}`}function se(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function bt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function St(e){return e=bt(e),(e<16?"0":"")+e.toString(16)}function hi(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new J(e,t,n,i)}function li(e){if(e instanceof J)return new J(e.h,e.s,e.l,e.opacity);if(e instanceof Nt||(e=ht(e)),!e)return new J;if(e instanceof J)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),s=Math.max(t,n,i),o=NaN,a=s-r,c=(s+r)/2;return a?(t===s?o=(n-i)/a+(n<i)*6:n===s?o=(i-t)/a+2:o=(t-n)/a+4,a/=c<.5?s+r:2-s-r,o*=60):a=c>0&&c<1?0:o,new J(o,a,c,e.opacity)}function qs(e,t,n,i){return arguments.length===1?li(e):new J(e,t,n,i??1)}function J(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}Ge(J,qs,ni(Nt,{brighter(e){return e=e==null?ie:Math.pow(ie,e),new J(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?$t:Math.pow($t,e),new J(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new G(je(e>=240?e-240:e+120,r,i),je(e,r,i),je(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new J(ui(this.h),oe(this.s),oe(this.l),se(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=se(this.opacity);return`${e===1?"hsl(":"hsla("}${ui(this.h)}, ${oe(this.s)*100}%, ${oe(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ui(e){return e=(e||0)%360,e<0?e+360:e}function oe(e){return Math.max(0,Math.min(1,e||0))}function je(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const qe=e=>()=>e;function Zs(e,t){return function(n){return e+n*t}}function Ks(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function Qs(e){return(e=+e)==1?fi:function(t,n){return n-t?Ks(t,n,e):qe(isNaN(t)?n:t)}}function fi(e,t){var n=t-e;return n?Zs(e,n):qe(isNaN(e)?t:e)}const It=function e(t){var n=Qs(t);function i(r,s){var o=n((r=Xe(r)).r,(s=Xe(s)).r),a=n(r.g,s.g),c=n(r.b,s.b),h=fi(r.opacity,s.opacity);return function(l){return r.r=o(l),r.g=a(l),r.b=c(l),r.opacity=h(l),r+""}}return i.gamma=e,i}(1);function Js(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(s){for(r=0;r<n;++r)i[r]=e[r]*(1-s)+t[r]*s;return i}}function to(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function eo(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,r=new Array(i),s=new Array(n),o;for(o=0;o<i;++o)r[o]=Qe(e[o],t[o]);for(;o<n;++o)s[o]=t[o];return function(a){for(o=0;o<i;++o)s[o]=r[o](a);return s}}function no(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function tt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function io(e,t){var n={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=Qe(e[r],t[r]):i[r]=t[r];return function(s){for(r in n)i[r]=n[r](s);return i}}var Ze=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ke=new RegExp(Ze.source,"g");function ro(e){return function(){return e}}function so(e){return function(t){return e(t)+""}}function di(e,t){var n=Ze.lastIndex=Ke.lastIndex=0,i,r,s,o=-1,a=[],c=[];for(e=e+"",t=t+"";(i=Ze.exec(e))&&(r=Ke.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:tt(i,r)})),n=Ke.lastIndex;return n<t.length&&(s=t.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?c[0]?so(c[0].x):ro(t):(t=c.length,function(h){for(var l=0,u;l<t;++l)a[(u=c[l]).i]=u.x(h);return a.join("")})}function Qe(e,t){var n=typeof t,i;return t==null||n==="boolean"?qe(t):(n==="number"?tt:n==="string"?(i=ht(t))?(t=i,It):di:t instanceof ht?It:t instanceof Date?no:to(t)?Js:Array.isArray(t)?eo:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?io:tt)(e,t)}function oo(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var gi=180/Math.PI,Je={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function pi(e,t,n,i,r,s){var o,a,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*i)&&(n-=e*c,i-=t*c),(a=Math.sqrt(n*n+i*i))&&(n/=a,i/=a,c/=a),e*i<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*gi,skewX:Math.atan(c)*gi,scaleX:o,scaleY:a}}var ae;function ao(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Je:pi(t.a,t.b,t.c,t.d,t.e,t.f)}function co(e){return e==null||(ae||(ae=document.createElementNS("http://www.w3.org/2000/svg","g")),ae.setAttribute("transform",e),!(e=ae.transform.baseVal.consolidate()))?Je:(e=e.matrix,pi(e.a,e.b,e.c,e.d,e.e,e.f))}function mi(e,t,n,i){function r(h){return h.length?h.pop()+" ":""}function s(h,l,u,f,g,d){if(h!==u||l!==f){var p=g.push("translate(",null,t,null,n);d.push({i:p-4,x:tt(h,u)},{i:p-2,x:tt(l,f)})}else(u||f)&&g.push("translate("+u+t+f+n)}function o(h,l,u,f){h!==l?(h-l>180?l+=360:l-h>180&&(h+=360),f.push({i:u.push(r(u)+"rotate(",null,i)-2,x:tt(h,l)})):l&&u.push(r(u)+"rotate("+l+i)}function a(h,l,u,f){h!==l?f.push({i:u.push(r(u)+"skewX(",null,i)-2,x:tt(h,l)}):l&&u.push(r(u)+"skewX("+l+i)}function c(h,l,u,f,g,d){if(h!==u||l!==f){var p=g.push(r(g)+"scale(",null,",",null,")");d.push({i:p-4,x:tt(h,u)},{i:p-2,x:tt(l,f)})}else(u!==1||f!==1)&&g.push(r(g)+"scale("+u+","+f+")")}return function(h,l){var u=[],f=[];return h=e(h),l=e(l),s(h.translateX,h.translateY,l.translateX,l.translateY,u,f),o(h.rotate,l.rotate,u,f),a(h.skewX,l.skewX,u,f),c(h.scaleX,h.scaleY,l.scaleX,l.scaleY,u,f),h=l=null,function(g){for(var d=-1,p=f.length,y;++d<p;)u[(y=f[d]).i]=y.x(g);return u.join("")}}}var ho=mi(ao,"px, ","px)","deg)"),lo=mi(co,", ",")",")"),uo=1e-12;function yi(e){return((e=Math.exp(e))+1/e)/2}function fo(e){return((e=Math.exp(e))-1/e)/2}function go(e){return((e=Math.exp(2*e))-1)/(e+1)}const po=function e(t,n,i){function r(s,o){var a=s[0],c=s[1],h=s[2],l=o[0],u=o[1],f=o[2],g=l-a,d=u-c,p=g*g+d*d,y,_;if(p<uo)_=Math.log(f/h)/t,y=function(M){return[a+M*g,c+M*d,h*Math.exp(t*M*_)]};else{var x=Math.sqrt(p),v=(f*f-h*h+i*p)/(2*h*n*x),C=(f*f-h*h-i*p)/(2*f*n*x),b=Math.log(Math.sqrt(v*v+1)-v),S=Math.log(Math.sqrt(C*C+1)-C);_=(S-b)/t,y=function(M){var R=M*_,F=yi(b),O=h/(n*x)*(F*go(t*R+b)-fo(b));return[a+O*g,c+O*d,h*F/yi(t*R+b)]}}return y.duration=_*1e3*t/Math.SQRT2,y}return r.rho=function(s){var o=Math.max(.001,+s),a=o*o,c=a*a;return e(o,a,c)},r}(Math.SQRT2,2,4);function mo(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e(i/(t-1));return n}function yo(e){return function(){return e}}function _o(e){return+e}var _i=[0,1];function Lt(e){return e}function tn(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:yo(isNaN(t)?NaN:.5)}function xo(e,t){var n;return e>t&&(n=e,e=t,t=n),function(i){return Math.max(e,Math.min(t,i))}}function vo(e,t,n){var i=e[0],r=e[1],s=t[0],o=t[1];return r<i?(i=tn(r,i),s=n(o,s)):(i=tn(i,r),s=n(s,o)),function(a){return s(i(a))}}function wo(e,t,n){var i=Math.min(e.length,t.length)-1,r=new Array(i),s=new Array(i),o=-1;for(e[i]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<i;)r[o]=tn(e[o],e[o+1]),s[o]=n(t[o],t[o+1]);return function(a){var c=Rs(e,a,1,i)-1;return s[c](r[c](a))}}function bo(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function So(){var e=_i,t=_i,n=Qe,i,r,s,o=Lt,a,c,h;function l(){var f=Math.min(e.length,t.length);return o!==Lt&&(o=xo(e[0],e[f-1])),a=f>2?wo:vo,c=h=null,u}function u(f){return f==null||isNaN(f=+f)?s:(c||(c=a(e.map(i),t,n)))(i(o(f)))}return u.invert=function(f){return o(r((h||(h=a(t,e.map(i),tt)))(f)))},u.domain=function(f){return arguments.length?(e=Array.from(f,_o),l()):e.slice()},u.range=function(f){return arguments.length?(t=Array.from(f),l()):t.slice()},u.rangeRound=function(f){return t=Array.from(f),n=oo,l()},u.clamp=function(f){return arguments.length?(o=f?!0:Lt,l()):o!==Lt},u.interpolate=function(f){return arguments.length?(n=f,l()):n},u.unknown=function(f){return arguments.length?(s=f,u):s},function(f,g){return i=f,r=g,l()}}function To(){return So()(Lt,Lt)}function Mo(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function ce(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,i=e.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+e.slice(n+1)]}function kt(e){return e=ce(Math.abs(e)),e?e[1]:NaN}function Ao(e,t){return function(n,i){for(var r=n.length,s=[],o=0,a=e[0],c=0;r>0&&a>0&&(c+a+1>i&&(a=Math.max(1,i-c)),s.push(n.substring(r-=a,r+a)),!((c+=a+1)>i));)a=e[o=(o+1)%e.length];return s.reverse().join(t)}}function Po(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var Co=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function he(e){if(!(t=Co.exec(e)))throw new Error("invalid format: "+e);var t;return new en({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}he.prototype=en.prototype;function en(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}en.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Lo(e){t:for(var t=e.length,n=1,i=-1,r;n<t;++n)switch(e[n]){case".":i=r=n;break;case"0":i===0&&(i=n),r=n;break;default:if(!+e[n])break t;i>0&&(i=0);break}return i>0?e.slice(0,i)+e.slice(r+1):e}var xi;function ko(e,t){var n=ce(e,t);if(!n)return e+"";var i=n[0],r=n[1],s=r-(xi=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+ce(e,Math.max(0,t+s-1))[0]}function vi(e,t){var n=ce(e,t);if(!n)return e+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const wi={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Mo,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>vi(e*100,t),r:vi,s:ko,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function bi(e){return e}var Si=Array.prototype.map,Ti=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Eo(e){var t=e.grouping===void 0||e.thousands===void 0?bi:Ao(Si.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",i=e.currency===void 0?"":e.currency[1]+"",r=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?bi:Po(Si.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",a=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function h(u){u=he(u);var f=u.fill,g=u.align,d=u.sign,p=u.symbol,y=u.zero,_=u.width,x=u.comma,v=u.precision,C=u.trim,b=u.type;b==="n"?(x=!0,b="g"):wi[b]||(v===void 0&&(v=12),C=!0,b="g"),(y||f==="0"&&g==="=")&&(y=!0,f="0",g="=");var S=p==="$"?n:p==="#"&&/[boxX]/.test(b)?"0"+b.toLowerCase():"",M=p==="$"?i:/[%p]/.test(b)?o:"",R=wi[b],F=/[defgprs%]/.test(b);v=v===void 0?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v));function O(A){var E=S,I=M,m,T,w;if(b==="c")I=R(A)+I,A="";else{A=+A;var k=A<0||1/A<0;if(A=isNaN(A)?c:R(Math.abs(A),v),C&&(A=Lo(A)),k&&+A==0&&d!=="+"&&(k=!1),E=(k?d==="("?d:a:d==="-"||d==="("?"":d)+E,I=(b==="s"?Ti[8+xi/3]:"")+I+(k&&d==="("?")":""),F){for(m=-1,T=A.length;++m<T;)if(w=A.charCodeAt(m),48>w||w>57){I=(w===46?r+A.slice(m+1):A.slice(m))+I,A=A.slice(0,m);break}}}x&&!y&&(A=t(A,1/0));var L=E.length+A.length+I.length,D=L<_?new Array(_-L+1).join(f):"";switch(x&&y&&(A=t(D+A,D.length?_-I.length:1/0),D=""),g){case"<":A=E+A+I+D;break;case"=":A=E+D+A+I;break;case"^":A=D.slice(0,L=D.length>>1)+E+A+I+D.slice(L);break;default:A=D+E+A+I;break}return s(A)}return O.toString=function(){return u+""},O}function l(u,f){var g=h((u=he(u),u.type="f",u)),d=Math.max(-8,Math.min(8,Math.floor(kt(f)/3)))*3,p=Math.pow(10,-d),y=Ti[8+d/3];return function(_){return g(p*_)+y}}return{format:h,formatPrefix:l}}var le,Mi,Ai;Ro({thousands:",",grouping:[3],currency:["$",""]});function Ro(e){return le=Eo(e),Mi=le.format,Ai=le.formatPrefix,le}function Fo(e){return Math.max(0,-kt(Math.abs(e)))}function zo(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(kt(t)/3)))*3-kt(Math.abs(e)))}function Do(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,kt(t)-kt(e))+1}function Oo(e,t,n,i){var r=Ns(e,t,n),s;switch(i=he(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return i.precision==null&&!isNaN(s=zo(r,o))&&(i.precision=s),Ai(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(s=Do(r,Math.max(Math.abs(e),Math.abs(t))))&&(i.precision=s-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(s=Fo(r))&&(i.precision=s-(i.type==="%")*2);break}}return Mi(i)}function No(e){var t=e.domain;return e.ticks=function(n){var i=t();return Os(i[0],i[i.length-1],n??10)},e.tickFormat=function(n,i){var r=t();return Oo(r[0],r[r.length-1],n??10,i)},e.nice=function(n){n==null&&(n=10);var i=t(),r=0,s=i.length-1,o=i[r],a=i[s],c,h,l=10;for(a<o&&(h=o,o=a,a=h,h=r,r=s,s=h);l-- >0;){if(h=Qn(o,a,n),h===c)return i[r]=o,i[s]=a,t(i);if(h>0)o=Math.floor(o/h)*h,a=Math.ceil(a/h)*h;else if(h<0)o=Math.ceil(o*h)/h,a=Math.floor(a*h)/h;else break;c=h}return e},e}function Tt(){var e=To();return e.copy=function(){return bo(e,Tt())},Jn.apply(e,arguments),No(e)}class Pi{constructor(t,n=!0,i,r,s,o){this._showLabels=!0,this._offsetX=0,this._offsetY=0,this._flipX=!1,this._flipY=!1,this.visible=!0,this.createOrGet=a=>{const{mainGroup:c}=this;let h=c.select(`g.${a}`);return h.empty()&&(h=c.append("g").attr("class",a)),h},this.mainGroup=t,this._showLabels=n,this._labelXDesc=i,this._labelYDesc=r,this._unitOfMeasure=s,o&&o.offsetX&&(this._offsetX=o.offsetX),o&&o.offsetX&&(this._offsetY=o.offsetY),o&&o.visible&&(this.visible=o.visible),this.mainGroup.style("pointer-events","none"),this._scaleX=Tt().domain([0,1]).range([0,1]),this._scaleY=Tt().domain([0,1]).range([0,1])}renderLabelx(){const{_labelXDesc:t,_unitOfMeasure:n,_showLabels:i,_scaleX:r}=this,[,s]=r.range(),o=this.renderGx();let a=o.select("text.axis-labelx");return i?a.empty()&&(a=o.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(`${t} (${n})`)):a.remove(),a.attr("transform",`translate(${s/2},-4)`),a}renderLabely(){const{_labelYDesc:t,_unitOfMeasure:n,_showLabels:i,_scaleY:r}=this,[,s]=r.range(),o=this.renderGy();let a=o.select("text.axis-labely");return i?(a.empty()&&(a=o.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(`${t} (${n})`)),a.attr("transform",`translate(-10,${s/2})rotate(90)`)):a.remove(),a}renderGy(){const{_scaleX:t,_scaleY:n}=this,i=As(n),[,r]=t.range(),s=this.createOrGet("y-axis");return s.call(i),s.attr("transform",`translate(${r},0)`),s}renderGx(){const{_scaleX:t,_scaleY:n}=this,i=Ps(t),[,r]=n.range(),s=this.createOrGet("x-axis");return s.attr("transform",`translate(0 ${r})`),s.call(i),s}render(){this.renderLabelx(),this.renderLabely()}onResize(t){this.mainGroup.attr("height",`${t.height}px`).attr("width",`${t.width}px`)}onRescale(t){const{_scaleX:n,_scaleY:i,offsetX:r,offsetY:s}=this,{xScale:o,yScale:a}=t,c=o.domain(),h=a.domain(),l=o.range(),u=a.range();n.domain([c[0]-r,c[1]-r]).range(l),i.domain([h[0]-s,h[1]-s]).range(u),this.flipX(this._flipX),this.flipY(this._flipY),this.visible&&this.render()}show(){return this.visible=!0,this.mainGroup.attr("visibility","visible"),this.render(),this}hide(){return this.visible=!1,this.mainGroup.attr("visibility","hidden"),this}flipX(t){this._flipX=t;const n=this._scaleX.domain(),i=t?-1:1;return this._scaleX.domain([i*n[0],i*n[1]]),this}flipY(t){this._flipY=t;const n=this._scaleY.domain(),i=t?-1:1;return this._scaleY.domain([i*n[0],i*n[1]]),this}showLabels(){return this._showLabels=!0,this.render(),this}hideLabels(){return this._showLabels=!1,this.render(),this}setLabelX(t){return this._labelXDesc=t,this}setLabelY(t){return this._labelYDesc=t,this}setUnitOfMeasure(t){return this._unitOfMeasure=t,this}setLabels(t,n,i){return this._labelXDesc=t,this._labelYDesc=n,this._unitOfMeasure=i,this}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t}get scaleX(){return this._scaleX.copy()}get scaleY(){return this._scaleY.copy()}}var $o=Math.PI/180;function gt(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e<t?t:e>n?n:e}function Bo(e){return e*$o}function Ci(e){var t=new Array(e),n=1/(e-1);t[0]=0;for(var i=1;i<e-1;i++)t[i]=i*n;return t[e-1]=1,t}function Ht(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]+t[i];return n}function Vt(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]-t[i];return n}function Mt(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]*t;return n}function Io(e){for(var t=0,n=0;n<e.length;n++)t+=Math.pow(e[n],2);return t}function Ut(e){var t=Io(e);return t===0?t:Math.sqrt(t)}function Li(e,t){t===void 0&&(t=e);var n=Ut(e);return n===0?Ho(0,t):Mt(e,1/n,t)}function Ho(e,t){for(var n=0;n<t.length;n++)t[n]=e;return t}function Vo(e,t){for(var n=0,i=0;i<e.length;i++)n+=Math.pow(t[i]-e[i],2);return n===0?n:Math.sqrt(n)}function Uo(e,t){for(var n=0,i=0;i<e.length;i++)n+=e[i]*t[i];return n}function Wo(e,t,n,i){i===void 0&&(i=e);for(var r=gt(n,0,1),s=1-r,o=0;o<e.length;o++)i[o]=e[o]*s+t[o]*r;return i}function Yo(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=t(e[i],i);return n}function ki(e,t){t===void 0&&(t=0),t===void 0&&(t=0);for(var n=0;n<e.length;n++)if(Math.abs(e[n])>t)return!1;return!0}var nn=180/Math.PI,Go=Math.PI/180;function rn(e,t,n){var i=Math.cos(t),r=Math.sin(t),s=e[0];return n[0]=i*s-r*e[1],n[1]=r*s+i*e[1],n}function Ei(e){return Math.atan2(e[1],e[0])}function Wt(e,t){var n=Math.atan2(t[1],t[0])-Math.atan2(e[1],e[0]);return n>Math.PI?n-=2*Math.PI:n<=-Math.PI&&(n+=2*Math.PI),n}var B=function(){function e(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.isMutating=!1,this.length=2,typeof t=="number"?typeof n[0]=="number"?(this[0]=t,this[1]=n[0]):(this[0]=t,this[1]=t):"x"in t&&"y"in t?(this[0]=t.x,this[1]=t.y):(this[0]=t[0],this[1]=t[1])}return Object.defineProperty(e.prototype,"x",{get:function(){return this[0]},set:function(t){this[0]=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this[1]},set:function(t){this[1]=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"magnitude",{get:function(){return Ut(this)},set:function(t){var n=Ut(this);Mt(this,t/n,this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mutable",{get:function(){return this.isMutating=!0,this},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"immutable",{get:function(){return this.isMutating=!1,this},enumerable:!0,configurable:!0}),e.prototype.set=function(t,n){return typeof t=="number"?typeof n=="number"?(this[0]=t,this[1]=n):(this[0]=t,this[1]=t):(this[0]=t[0],this[1]=t[1]),this},e.prototype.add=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?Ht(this,[t,n]):Ht(this.clone(),[t,n]):this.isMutating?Ht(this,t):Ht(this.clone(),t)},e.add=function(t,n){var i=new e(t);return Ht(i,n)},e.prototype.sub=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?Vt(this,[t,n]):Vt(this.clone(),[t,n]):this.isMutating?Vt(this,t):Vt(this.clone(),t)},e.sub=function(t,n){var i=new e(t);return Vt(i,n)},e.prototype.subFrom=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?(this[0]=t-this[0],this[1]=n-this[1],this):new e(t-this[0],n-this[1]):this.isMutating?(this[0]=t[0]-this[0],this[1]=t[1]-this[1],this):new e(t[0]-this[0],t[1]-this[1])},e.divide=function(t,n){var i=new e(t);return Mt(i,1/n)},e.multiply=function(t,n){var i=new e(t);return Mt(i,n)},e.prototype.scale=function(t){return Mt(this,t,this.isMutating?this:e.zero)},e.prototype.rescale=function(t){var n=Ut(this);return n<=0?this.isMutating?this:e.zero:Mt(this,t/n,this.isMutating?this:e.zero)},e.prototype.clampMagnitude=function(t){var n=Ut(this);return n>t?Mt(this,t/n,this.isMutating?this:e.zero):this.isMutating?this:this.clone()},e.prototype.rotate=function(t){return rn(this,t,this.isMutating?this:e.zero)},e.prototype.rotateDeg=function(t){return rn(this,t*Go,this.isMutating?this:e.zero)},e.prototype.rotate90=function(){return t=this,n=this.isMutating?this:e.zero,i=t[0],n[0]=-t[1],n[1]=i,n;var t,n,i},e.prototype.rotate180=function(){return t=this,(n=this.isMutating?this:e.zero)[0]=-t[0],n[1]=-t[1],n;var t,n},e.prototype.rotate270=function(){return t=this,n=this.isMutating?this:e.zero,i=t[0],n[0]=t[1],n[1]=-i,n;var t,n,i},e.prototype.normalize=function(){return Li(this)},e.prototype.normalized=function(){return Li(this,e.zero)},e.distance=function(t,n){return Vo(t,n)},e.dot=function(t,n){return Uo(t,n)},e.cross=function(t,n){return function(i,r){return i[0]*r[1]-i[1]*r[0]}(t,n)},e.angleRight=function(t){return Ei(t)},e.angleRightDeg=function(t){return Ei(t)*nn},e.angle=function(t,n){return Math.abs(Wt(t,n))},e.angleDeg=function(t,n){return Math.abs(Wt(t,n))*nn},e.signedAngle=function(t,n){return Wt(t,n)},e.signedAngleDeg=function(t,n){return Wt(t,n)*nn},e.lerp=function(t,n,i){var r=new e(t);return Wo(r,n,i)},e.lerpRot=function(t,n,i){return function(r,s,o,a){return a===void 0&&(a=r),rn(r,o*Wt(r,s),a)}(t,n,i,e.zero)},e.prototype.clone=function(){return new e(this[0],this[1])},e.equals=function(t,n,i){return i===void 0&&(i=0),!(Math.abs(t[0]-n[0])>i)&&!(Math.abs(t[1]-n[1])>i)},e.prototype.equals=function(t,n){return n===void 0&&(n=0),e.equals(this,t,n)},e.isZeroVector=function(t,n){return n===void 0&&(n=0),ki(t,n)},e.prototype.isZeroVector=function(t){return t===void 0&&(t=0),ki(this,t)},e.prototype.toArray=function(){return[this[0],this[1]]},e.prototype.modify=function(t){return Yo(this,t)},e.prototype[Symbol.iterator]=function(){var t=this,n=0;return{next:function(){switch(n++){case 0:return{value:t[0],done:!1};case 1:return{value:t[1],done:!1};default:return{value:-1,done:!0}}}}},Object.defineProperty(e,"zero",{get:function(){return new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"positiveInfinity",{get:function(){return new e(1/0,1/0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"negativeInfinity",{get:function(){return new e(-1/0,-1/0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"up",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"right",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"down",{get:function(){return new e(0,-1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"left",{get:function(){return new e(-1,0)},enumerable:!0,configurable:!0}),e}();/*! *****************************************************************************
1
+ (function(P,z){typeof exports=="object"&&typeof module<"u"?z(exports,require("pixi.js")):typeof define=="function"&&define.amd?define(["exports","pixi.js"],z):(P=typeof globalThis<"u"?globalThis:P||self,z(P.esvintersection={},P.PIXI))})(this,function(P,z){"use strict";function ys(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const st=ys(z);function _s(e){return e}var Ie=1,te=2,He=3,ee=4,Gn=1e-6;function xs(e){return"translate("+e+",0)"}function vs(e){return"translate(0,"+e+")"}function ws(e){return t=>+e(t)}function bs(e,t){return t=Math.max(0,e.bandwidth()-t*2)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function Ss(){return!this.__axis}function Xn(e,t){var n=[],i=null,r=null,s=6,o=6,a=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,h=e===Ie||e===ee?-1:1,l=e===ee||e===te?"x":"y",u=e===Ie||e===He?xs:vs;function f(g){var d=i??(t.ticks?t.ticks.apply(t,n):t.domain()),p=r??(t.tickFormat?t.tickFormat.apply(t,n):_s),y=Math.max(s,0)+a,_=t.range(),x=+_[0]+c,v=+_[_.length-1]+c,C=(t.bandwidth?bs:ws)(t.copy(),c),b=g.selection?g.selection():g,S=b.selectAll(".domain").data([null]),M=b.selectAll(".tick").data(d,t).order(),R=M.exit(),F=M.enter().append("g").attr("class","tick"),O=M.select("line"),A=M.select("text");S=S.merge(S.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),M=M.merge(F),O=O.merge(F.append("line").attr("stroke","currentColor").attr(l+"2",h*s)),A=A.merge(F.append("text").attr("fill","currentColor").attr(l,h*y).attr("dy",e===Ie?"0em":e===He?"0.71em":"0.32em")),g!==b&&(S=S.transition(g),M=M.transition(g),O=O.transition(g),A=A.transition(g),R=R.transition(g).attr("opacity",Gn).attr("transform",function(E){return isFinite(E=C(E))?u(E+c):this.getAttribute("transform")}),F.attr("opacity",Gn).attr("transform",function(E){var I=this.parentNode.__axis;return u((I&&isFinite(I=I(E))?I:C(E))+c)})),R.remove(),S.attr("d",e===ee||e===te?o?"M"+h*o+","+x+"H"+c+"V"+v+"H"+h*o:"M"+c+","+x+"V"+v:o?"M"+x+","+h*o+"V"+c+"H"+v+"V"+h*o:"M"+x+","+c+"H"+v),M.attr("opacity",1).attr("transform",function(E){return u(C(E)+c)}),O.attr(l+"2",h*s),A.attr(l,h*y).text(p),b.filter(Ss).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",e===te?"start":e===ee?"end":"middle"),b.each(function(){this.__axis=C})}return f.scale=function(g){return arguments.length?(t=g,f):t},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(g){return arguments.length?(n=g==null?[]:Array.from(g),f):n.slice()},f.tickValues=function(g){return arguments.length?(i=g==null?null:Array.from(g),f):i&&i.slice()},f.tickFormat=function(g){return arguments.length?(r=g,f):r},f.tickSize=function(g){return arguments.length?(s=o=+g,f):s},f.tickSizeInner=function(g){return arguments.length?(s=+g,f):s},f.tickSizeOuter=function(g){return arguments.length?(o=+g,f):o},f.tickPadding=function(g){return arguments.length?(a=+g,f):a},f.offset=function(g){return arguments.length?(c=+g,f):c},f}function Ts(e){return Xn(te,e)}function Ms(e){return Xn(He,e)}function ne(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function As(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function jn(e){let t,n,i;e.length!==2?(t=ne,n=(a,c)=>ne(e(a),c),i=(a,c)=>e(a)-c):(t=e===ne||e===As?e:Ps,n=e,i=e);function r(a,c,h=0,l=a.length){if(h<l){if(t(c,c)!==0)return l;do{const u=h+l>>>1;n(a[u],c)<0?h=u+1:l=u}while(h<l)}return h}function s(a,c,h=0,l=a.length){if(h<l){if(t(c,c)!==0)return l;do{const u=h+l>>>1;n(a[u],c)<=0?h=u+1:l=u}while(h<l)}return h}function o(a,c,h=0,l=a.length){const u=r(a,c,h,l-1);return u>h&&i(a[u-1],c)>-i(a[u],c)?u-1:u}return{left:r,center:o,right:s}}function Ps(){return 0}function Cs(e){return e===null?NaN:+e}const Ls=jn(ne).right;jn(Cs).center;const ks=Ls;class qn extends Map{constructor(t,n=Fs){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[i,r]of t)this.set(i,r)}get(t){return super.get(Zn(this,t))}has(t){return super.has(Zn(this,t))}set(t,n){return super.set(Es(this,t),n)}delete(t){return super.delete(Rs(this,t))}}function Zn({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):n}function Es({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):(e.set(i,n),n)}function Rs({_intern:e,_key:t},n){const i=t(n);return e.has(i)&&(n=e.get(n),e.delete(i)),n}function Fs(e){return e!==null&&typeof e=="object"?e.valueOf():e}const zs=Math.sqrt(50),Ds=Math.sqrt(10),Os=Math.sqrt(2);function ie(e,t,n){const i=(t-e)/Math.max(0,n),r=Math.floor(Math.log10(i)),s=i/Math.pow(10,r),o=s>=zs?10:s>=Ds?5:s>=Os?2:1;let a,c,h;return r<0?(h=Math.pow(10,-r)/o,a=Math.round(e*h),c=Math.round(t*h),a/h<e&&++a,c/h>t&&--c,h=-h):(h=Math.pow(10,r)*o,a=Math.round(e/h),c=Math.round(t/h),a*h<e&&++a,c*h>t&&--c),c<a&&.5<=n&&n<2?ie(e,t,n*2):[a,c,h]}function Ns(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];const i=t<e,[r,s,o]=i?ie(t,e,n):ie(e,t,n);if(!(s>=r))return[];const a=s-r+1,c=new Array(a);if(i)if(o<0)for(let h=0;h<a;++h)c[h]=(s-h)/-o;else for(let h=0;h<a;++h)c[h]=(s-h)*o;else if(o<0)for(let h=0;h<a;++h)c[h]=(r+h)/-o;else for(let h=0;h<a;++h)c[h]=(r+h)*o;return c}function Ve(e,t,n){return t=+t,e=+e,n=+n,ie(e,t,n)[2]}function $s(e,t,n){t=+t,e=+e,n=+n;const i=t<e,r=i?Ve(t,e,n):Ve(e,t,n);return(i?-1:1)*(r<0?1/-r:r)}function Ue(e,t){let n;if(t===void 0)for(const i of e)i!=null&&(n<i||n===void 0&&i>=i)&&(n=i);else{let i=-1;for(let r of e)(r=t(r,++i,e))!=null&&(n<r||n===void 0&&r>=r)&&(n=r)}return n}function We(e,t){let n=0;if(t===void 0)for(let i of e)(i=+i)&&(n+=i);else{let i=-1;for(let r of e)(r=+t(r,++i,e))&&(n+=r)}return n}function Kn(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}const Qn=Symbol("implicit");function Jn(){var e=new qn,t=[],n=[],i=Qn;function r(s){let o=e.get(s);if(o===void 0){if(i!==Qn)return i;e.set(s,o=t.push(s)-1)}return n[o%n.length]}return r.domain=function(s){if(!arguments.length)return t.slice();t=[],e=new qn;for(const o of s)e.has(o)||e.set(o,t.push(o)-1);return r},r.range=function(s){return arguments.length?(n=Array.from(s),r):n.slice()},r.unknown=function(s){return arguments.length?(i=s,r):i},r.copy=function(){return Jn(t,n).unknown(i)},Kn.apply(r,arguments),r}function Ye(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ti(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function Nt(){}var $t=.7,re=1/$t,Ct="\\s*([+-]?\\d+)\\s*",Bt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ot="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Bs=/^#([0-9a-f]{3,8})$/,Is=new RegExp(`^rgb\\(${Ct},${Ct},${Ct}\\)$`),Hs=new RegExp(`^rgb\\(${ot},${ot},${ot}\\)$`),Vs=new RegExp(`^rgba\\(${Ct},${Ct},${Ct},${Bt}\\)$`),Us=new RegExp(`^rgba\\(${ot},${ot},${ot},${Bt}\\)$`),Ws=new RegExp(`^hsl\\(${Bt},${ot},${ot}\\)$`),Ys=new RegExp(`^hsla\\(${Bt},${ot},${ot},${Bt}\\)$`),ei={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};Ye(Nt,ht,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ni,formatHex:ni,formatHex8:Gs,formatHsl:Xs,formatRgb:ii,toString:ii});function ni(){return this.rgb().formatHex()}function Gs(){return this.rgb().formatHex8()}function Xs(){return ci(this).formatHsl()}function ii(){return this.rgb().formatRgb()}function ht(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Bs.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ri(t):n===3?new G(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?se(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?se(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Is.exec(e))?new G(t[1],t[2],t[3],1):(t=Hs.exec(e))?new G(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Vs.exec(e))?se(t[1],t[2],t[3],t[4]):(t=Us.exec(e))?se(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Ws.exec(e))?ai(t[1],t[2]/100,t[3]/100,1):(t=Ys.exec(e))?ai(t[1],t[2]/100,t[3]/100,t[4]):ei.hasOwnProperty(e)?ri(ei[e]):e==="transparent"?new G(NaN,NaN,NaN,0):null}function ri(e){return new G(e>>16&255,e>>8&255,e&255,1)}function se(e,t,n,i){return i<=0&&(e=t=n=NaN),new G(e,t,n,i)}function js(e){return e instanceof Nt||(e=ht(e)),e?(e=e.rgb(),new G(e.r,e.g,e.b,e.opacity)):new G}function Ge(e,t,n,i){return arguments.length===1?js(e):new G(e,t,n,i??1)}function G(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}Ye(G,Ge,ti(Nt,{brighter(e){return e=e==null?re:Math.pow(re,e),new G(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?$t:Math.pow($t,e),new G(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new G(bt(this.r),bt(this.g),bt(this.b),oe(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:si,formatHex:si,formatHex8:qs,formatRgb:oi,toString:oi}));function si(){return`#${St(this.r)}${St(this.g)}${St(this.b)}`}function qs(){return`#${St(this.r)}${St(this.g)}${St(this.b)}${St((isNaN(this.opacity)?1:this.opacity)*255)}`}function oi(){const e=oe(this.opacity);return`${e===1?"rgb(":"rgba("}${bt(this.r)}, ${bt(this.g)}, ${bt(this.b)}${e===1?")":`, ${e})`}`}function oe(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function bt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function St(e){return e=bt(e),(e<16?"0":"")+e.toString(16)}function ai(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new J(e,t,n,i)}function ci(e){if(e instanceof J)return new J(e.h,e.s,e.l,e.opacity);if(e instanceof Nt||(e=ht(e)),!e)return new J;if(e instanceof J)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),s=Math.max(t,n,i),o=NaN,a=s-r,c=(s+r)/2;return a?(t===s?o=(n-i)/a+(n<i)*6:n===s?o=(i-t)/a+2:o=(t-n)/a+4,a/=c<.5?s+r:2-s-r,o*=60):a=c>0&&c<1?0:o,new J(o,a,c,e.opacity)}function Zs(e,t,n,i){return arguments.length===1?ci(e):new J(e,t,n,i??1)}function J(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}Ye(J,Zs,ti(Nt,{brighter(e){return e=e==null?re:Math.pow(re,e),new J(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?$t:Math.pow($t,e),new J(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new G(Xe(e>=240?e-240:e+120,r,i),Xe(e,r,i),Xe(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new J(hi(this.h),ae(this.s),ae(this.l),oe(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=oe(this.opacity);return`${e===1?"hsl(":"hsla("}${hi(this.h)}, ${ae(this.s)*100}%, ${ae(this.l)*100}%${e===1?")":`, ${e})`}`}}));function hi(e){return e=(e||0)%360,e<0?e+360:e}function ae(e){return Math.max(0,Math.min(1,e||0))}function Xe(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const je=e=>()=>e;function Ks(e,t){return function(n){return e+n*t}}function Qs(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function Js(e){return(e=+e)==1?li:function(t,n){return n-t?Qs(t,n,e):je(isNaN(t)?n:t)}}function li(e,t){var n=t-e;return n?Ks(e,n):je(isNaN(e)?t:e)}const It=function e(t){var n=Js(t);function i(r,s){var o=n((r=Ge(r)).r,(s=Ge(s)).r),a=n(r.g,s.g),c=n(r.b,s.b),h=li(r.opacity,s.opacity);return function(l){return r.r=o(l),r.g=a(l),r.b=c(l),r.opacity=h(l),r+""}}return i.gamma=e,i}(1);function to(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(s){for(r=0;r<n;++r)i[r]=e[r]*(1-s)+t[r]*s;return i}}function eo(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function no(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,r=new Array(i),s=new Array(n),o;for(o=0;o<i;++o)r[o]=Ke(e[o],t[o]);for(;o<n;++o)s[o]=t[o];return function(a){for(o=0;o<i;++o)s[o]=r[o](a);return s}}function io(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function tt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function ro(e,t){var n={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=Ke(e[r],t[r]):i[r]=t[r];return function(s){for(r in n)i[r]=n[r](s);return i}}var qe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ze=new RegExp(qe.source,"g");function so(e){return function(){return e}}function oo(e){return function(t){return e(t)+""}}function ui(e,t){var n=qe.lastIndex=Ze.lastIndex=0,i,r,s,o=-1,a=[],c=[];for(e=e+"",t=t+"";(i=qe.exec(e))&&(r=Ze.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:tt(i,r)})),n=Ze.lastIndex;return n<t.length&&(s=t.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?c[0]?oo(c[0].x):so(t):(t=c.length,function(h){for(var l=0,u;l<t;++l)a[(u=c[l]).i]=u.x(h);return a.join("")})}function Ke(e,t){var n=typeof t,i;return t==null||n==="boolean"?je(t):(n==="number"?tt:n==="string"?(i=ht(t))?(t=i,It):ui:t instanceof ht?It:t instanceof Date?io:eo(t)?to:Array.isArray(t)?no:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?ro:tt)(e,t)}function ao(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var fi=180/Math.PI,Qe={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function di(e,t,n,i,r,s){var o,a,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*i)&&(n-=e*c,i-=t*c),(a=Math.sqrt(n*n+i*i))&&(n/=a,i/=a,c/=a),e*i<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*fi,skewX:Math.atan(c)*fi,scaleX:o,scaleY:a}}var ce;function co(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Qe:di(t.a,t.b,t.c,t.d,t.e,t.f)}function ho(e){return e==null||(ce||(ce=document.createElementNS("http://www.w3.org/2000/svg","g")),ce.setAttribute("transform",e),!(e=ce.transform.baseVal.consolidate()))?Qe:(e=e.matrix,di(e.a,e.b,e.c,e.d,e.e,e.f))}function gi(e,t,n,i){function r(h){return h.length?h.pop()+" ":""}function s(h,l,u,f,g,d){if(h!==u||l!==f){var p=g.push("translate(",null,t,null,n);d.push({i:p-4,x:tt(h,u)},{i:p-2,x:tt(l,f)})}else(u||f)&&g.push("translate("+u+t+f+n)}function o(h,l,u,f){h!==l?(h-l>180?l+=360:l-h>180&&(h+=360),f.push({i:u.push(r(u)+"rotate(",null,i)-2,x:tt(h,l)})):l&&u.push(r(u)+"rotate("+l+i)}function a(h,l,u,f){h!==l?f.push({i:u.push(r(u)+"skewX(",null,i)-2,x:tt(h,l)}):l&&u.push(r(u)+"skewX("+l+i)}function c(h,l,u,f,g,d){if(h!==u||l!==f){var p=g.push(r(g)+"scale(",null,",",null,")");d.push({i:p-4,x:tt(h,u)},{i:p-2,x:tt(l,f)})}else(u!==1||f!==1)&&g.push(r(g)+"scale("+u+","+f+")")}return function(h,l){var u=[],f=[];return h=e(h),l=e(l),s(h.translateX,h.translateY,l.translateX,l.translateY,u,f),o(h.rotate,l.rotate,u,f),a(h.skewX,l.skewX,u,f),c(h.scaleX,h.scaleY,l.scaleX,l.scaleY,u,f),h=l=null,function(g){for(var d=-1,p=f.length,y;++d<p;)u[(y=f[d]).i]=y.x(g);return u.join("")}}}var lo=gi(co,"px, ","px)","deg)"),uo=gi(ho,", ",")",")"),fo=1e-12;function pi(e){return((e=Math.exp(e))+1/e)/2}function go(e){return((e=Math.exp(e))-1/e)/2}function po(e){return((e=Math.exp(2*e))-1)/(e+1)}const mo=function e(t,n,i){function r(s,o){var a=s[0],c=s[1],h=s[2],l=o[0],u=o[1],f=o[2],g=l-a,d=u-c,p=g*g+d*d,y,_;if(p<fo)_=Math.log(f/h)/t,y=function(M){return[a+M*g,c+M*d,h*Math.exp(t*M*_)]};else{var x=Math.sqrt(p),v=(f*f-h*h+i*p)/(2*h*n*x),C=(f*f-h*h-i*p)/(2*f*n*x),b=Math.log(Math.sqrt(v*v+1)-v),S=Math.log(Math.sqrt(C*C+1)-C);_=(S-b)/t,y=function(M){var R=M*_,F=pi(b),O=h/(n*x)*(F*po(t*R+b)-go(b));return[a+O*g,c+O*d,h*F/pi(t*R+b)]}}return y.duration=_*1e3*t/Math.SQRT2,y}return r.rho=function(s){var o=Math.max(.001,+s),a=o*o,c=a*a;return e(o,a,c)},r}(Math.SQRT2,2,4);function yo(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e(i/(t-1));return n}function _o(e){return function(){return e}}function xo(e){return+e}var mi=[0,1];function Lt(e){return e}function Je(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:_o(isNaN(t)?NaN:.5)}function vo(e,t){var n;return e>t&&(n=e,e=t,t=n),function(i){return Math.max(e,Math.min(t,i))}}function wo(e,t,n){var i=e[0],r=e[1],s=t[0],o=t[1];return r<i?(i=Je(r,i),s=n(o,s)):(i=Je(i,r),s=n(s,o)),function(a){return s(i(a))}}function bo(e,t,n){var i=Math.min(e.length,t.length)-1,r=new Array(i),s=new Array(i),o=-1;for(e[i]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<i;)r[o]=Je(e[o],e[o+1]),s[o]=n(t[o],t[o+1]);return function(a){var c=ks(e,a,1,i)-1;return s[c](r[c](a))}}function So(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function To(){var e=mi,t=mi,n=Ke,i,r,s,o=Lt,a,c,h;function l(){var f=Math.min(e.length,t.length);return o!==Lt&&(o=vo(e[0],e[f-1])),a=f>2?bo:wo,c=h=null,u}function u(f){return f==null||isNaN(f=+f)?s:(c||(c=a(e.map(i),t,n)))(i(o(f)))}return u.invert=function(f){return o(r((h||(h=a(t,e.map(i),tt)))(f)))},u.domain=function(f){return arguments.length?(e=Array.from(f,xo),l()):e.slice()},u.range=function(f){return arguments.length?(t=Array.from(f),l()):t.slice()},u.rangeRound=function(f){return t=Array.from(f),n=ao,l()},u.clamp=function(f){return arguments.length?(o=f?!0:Lt,l()):o!==Lt},u.interpolate=function(f){return arguments.length?(n=f,l()):n},u.unknown=function(f){return arguments.length?(s=f,u):s},function(f,g){return i=f,r=g,l()}}function Mo(){return To()(Lt,Lt)}function Ao(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function he(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,i=e.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+e.slice(n+1)]}function kt(e){return e=he(Math.abs(e)),e?e[1]:NaN}function Po(e,t){return function(n,i){for(var r=n.length,s=[],o=0,a=e[0],c=0;r>0&&a>0&&(c+a+1>i&&(a=Math.max(1,i-c)),s.push(n.substring(r-=a,r+a)),!((c+=a+1)>i));)a=e[o=(o+1)%e.length];return s.reverse().join(t)}}function Co(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var Lo=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function le(e){if(!(t=Lo.exec(e)))throw new Error("invalid format: "+e);var t;return new tn({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}le.prototype=tn.prototype;function tn(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}tn.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function ko(e){t:for(var t=e.length,n=1,i=-1,r;n<t;++n)switch(e[n]){case".":i=r=n;break;case"0":i===0&&(i=n),r=n;break;default:if(!+e[n])break t;i>0&&(i=0);break}return i>0?e.slice(0,i)+e.slice(r+1):e}var yi;function Eo(e,t){var n=he(e,t);if(!n)return e+"";var i=n[0],r=n[1],s=r-(yi=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+he(e,Math.max(0,t+s-1))[0]}function _i(e,t){var n=he(e,t);if(!n)return e+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const xi={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Ao,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>_i(e*100,t),r:_i,s:Eo,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function vi(e){return e}var wi=Array.prototype.map,bi=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Ro(e){var t=e.grouping===void 0||e.thousands===void 0?vi:Po(wi.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",i=e.currency===void 0?"":e.currency[1]+"",r=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?vi:Co(wi.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",a=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function h(u){u=le(u);var f=u.fill,g=u.align,d=u.sign,p=u.symbol,y=u.zero,_=u.width,x=u.comma,v=u.precision,C=u.trim,b=u.type;b==="n"?(x=!0,b="g"):xi[b]||(v===void 0&&(v=12),C=!0,b="g"),(y||f==="0"&&g==="=")&&(y=!0,f="0",g="=");var S=p==="$"?n:p==="#"&&/[boxX]/.test(b)?"0"+b.toLowerCase():"",M=p==="$"?i:/[%p]/.test(b)?o:"",R=xi[b],F=/[defgprs%]/.test(b);v=v===void 0?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v));function O(A){var E=S,I=M,m,T,w;if(b==="c")I=R(A)+I,A="";else{A=+A;var k=A<0||1/A<0;if(A=isNaN(A)?c:R(Math.abs(A),v),C&&(A=ko(A)),k&&+A==0&&d!=="+"&&(k=!1),E=(k?d==="("?d:a:d==="-"||d==="("?"":d)+E,I=(b==="s"?bi[8+yi/3]:"")+I+(k&&d==="("?")":""),F){for(m=-1,T=A.length;++m<T;)if(w=A.charCodeAt(m),48>w||w>57){I=(w===46?r+A.slice(m+1):A.slice(m))+I,A=A.slice(0,m);break}}}x&&!y&&(A=t(A,1/0));var L=E.length+A.length+I.length,D=L<_?new Array(_-L+1).join(f):"";switch(x&&y&&(A=t(D+A,D.length?_-I.length:1/0),D=""),g){case"<":A=E+A+I+D;break;case"=":A=E+D+A+I;break;case"^":A=D.slice(0,L=D.length>>1)+E+A+I+D.slice(L);break;default:A=D+E+A+I;break}return s(A)}return O.toString=function(){return u+""},O}function l(u,f){var g=h((u=le(u),u.type="f",u)),d=Math.max(-8,Math.min(8,Math.floor(kt(f)/3)))*3,p=Math.pow(10,-d),y=bi[8+d/3];return function(_){return g(p*_)+y}}return{format:h,formatPrefix:l}}var ue,Si,Ti;Fo({thousands:",",grouping:[3],currency:["$",""]});function Fo(e){return ue=Ro(e),Si=ue.format,Ti=ue.formatPrefix,ue}function zo(e){return Math.max(0,-kt(Math.abs(e)))}function Do(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(kt(t)/3)))*3-kt(Math.abs(e)))}function Oo(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,kt(t)-kt(e))+1}function No(e,t,n,i){var r=$s(e,t,n),s;switch(i=le(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return i.precision==null&&!isNaN(s=Do(r,o))&&(i.precision=s),Ti(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(s=Oo(r,Math.max(Math.abs(e),Math.abs(t))))&&(i.precision=s-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(s=zo(r))&&(i.precision=s-(i.type==="%")*2);break}}return Si(i)}function $o(e){var t=e.domain;return e.ticks=function(n){var i=t();return Ns(i[0],i[i.length-1],n??10)},e.tickFormat=function(n,i){var r=t();return No(r[0],r[r.length-1],n??10,i)},e.nice=function(n){n==null&&(n=10);var i=t(),r=0,s=i.length-1,o=i[r],a=i[s],c,h,l=10;for(a<o&&(h=o,o=a,a=h,h=r,r=s,s=h);l-- >0;){if(h=Ve(o,a,n),h===c)return i[r]=o,i[s]=a,t(i);if(h>0)o=Math.floor(o/h)*h,a=Math.ceil(a/h)*h;else if(h<0)o=Math.ceil(o*h)/h,a=Math.floor(a*h)/h;else break;c=h}return e},e}function Tt(){var e=Mo();return e.copy=function(){return So(e,Tt())},Kn.apply(e,arguments),$o(e)}class Mi{constructor(t,n=!0,i,r,s,o){this._showLabels=!0,this._offsetX=0,this._offsetY=0,this._flipX=!1,this._flipY=!1,this.visible=!0,this.createOrGet=a=>{const{mainGroup:c}=this;let h=c.select(`g.${a}`);return h.empty()&&(h=c.append("g").attr("class",a)),h},this.mainGroup=t,this._showLabels=n,this._labelXDesc=i,this._labelYDesc=r,this._unitOfMeasure=s,o&&o.offsetX&&(this._offsetX=o.offsetX),o&&o.offsetX&&(this._offsetY=o.offsetY),o&&o.visible&&(this.visible=o.visible),this.mainGroup.style("pointer-events","none"),this._scaleX=Tt().domain([0,1]).range([0,1]),this._scaleY=Tt().domain([0,1]).range([0,1])}renderLabelx(){const{_labelXDesc:t,_unitOfMeasure:n,_showLabels:i,_scaleX:r}=this,[,s]=r.range(),o=this.renderGx();let a=o.select("text.axis-labelx");return i?a.empty()&&(a=o.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(`${t} (${n})`)):a.remove(),a.attr("transform",`translate(${s/2},-4)`),a}renderLabely(){const{_labelYDesc:t,_unitOfMeasure:n,_showLabels:i,_scaleY:r}=this,[,s]=r.range(),o=this.renderGy();let a=o.select("text.axis-labely");return i?(a.empty()&&(a=o.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(`${t} (${n})`)),a.attr("transform",`translate(-10,${s/2})rotate(90)`)):a.remove(),a}renderGy(){const{_scaleX:t,_scaleY:n}=this,i=Ts(n),[,r]=t.range(),s=this.createOrGet("y-axis");return s.call(i),s.attr("transform",`translate(${r},0)`),s}renderGx(){const{_scaleX:t,_scaleY:n}=this,i=Ms(t),[,r]=n.range(),s=this.createOrGet("x-axis");return s.attr("transform",`translate(0 ${r})`),s.call(i),s}render(){this.renderLabelx(),this.renderLabely()}onResize(t){this.mainGroup.attr("height",`${t.height}px`).attr("width",`${t.width}px`)}onRescale(t){const{_scaleX:n,_scaleY:i,offsetX:r,offsetY:s}=this,{xScale:o,yScale:a}=t,c=o.domain(),h=a.domain(),l=o.range(),u=a.range();n.domain([c[0]-r,c[1]-r]).range(l),i.domain([h[0]-s,h[1]-s]).range(u),this.flipX(this._flipX),this.flipY(this._flipY),this.visible&&this.render()}show(){return this.visible=!0,this.mainGroup.attr("visibility","visible"),this.render(),this}hide(){return this.visible=!1,this.mainGroup.attr("visibility","hidden"),this}flipX(t){this._flipX=t;const n=this._scaleX.domain(),i=t?-1:1;return this._scaleX.domain([i*n[0],i*n[1]]),this}flipY(t){this._flipY=t;const n=this._scaleY.domain(),i=t?-1:1;return this._scaleY.domain([i*n[0],i*n[1]]),this}showLabels(){return this._showLabels=!0,this.render(),this}hideLabels(){return this._showLabels=!1,this.render(),this}setLabelX(t){return this._labelXDesc=t,this}setLabelY(t){return this._labelYDesc=t,this}setUnitOfMeasure(t){return this._unitOfMeasure=t,this}setLabels(t,n,i){return this._labelXDesc=t,this._labelYDesc=n,this._unitOfMeasure=i,this}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t}get scaleX(){return this._scaleX.copy()}get scaleY(){return this._scaleY.copy()}}var Bo=Math.PI/180;function gt(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e<t?t:e>n?n:e}function Io(e){return e*Bo}function Ai(e){var t=new Array(e),n=1/(e-1);t[0]=0;for(var i=1;i<e-1;i++)t[i]=i*n;return t[e-1]=1,t}function Ht(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]+t[i];return n}function Vt(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]-t[i];return n}function Mt(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=e[i]*t;return n}function Ho(e){for(var t=0,n=0;n<e.length;n++)t+=Math.pow(e[n],2);return t}function Ut(e){var t=Ho(e);return t===0?t:Math.sqrt(t)}function Pi(e,t){t===void 0&&(t=e);var n=Ut(e);return n===0?Vo(0,t):Mt(e,1/n,t)}function Vo(e,t){for(var n=0;n<t.length;n++)t[n]=e;return t}function Uo(e,t){for(var n=0,i=0;i<e.length;i++)n+=Math.pow(t[i]-e[i],2);return n===0?n:Math.sqrt(n)}function Wo(e,t){for(var n=0,i=0;i<e.length;i++)n+=e[i]*t[i];return n}function Yo(e,t,n,i){i===void 0&&(i=e);for(var r=gt(n,0,1),s=1-r,o=0;o<e.length;o++)i[o]=e[o]*s+t[o]*r;return i}function Go(e,t,n){n===void 0&&(n=e);for(var i=0;i<e.length;i++)n[i]=t(e[i],i);return n}function Ci(e,t){t===void 0&&(t=0),t===void 0&&(t=0);for(var n=0;n<e.length;n++)if(Math.abs(e[n])>t)return!1;return!0}var en=180/Math.PI,Xo=Math.PI/180;function nn(e,t,n){var i=Math.cos(t),r=Math.sin(t),s=e[0];return n[0]=i*s-r*e[1],n[1]=r*s+i*e[1],n}function Li(e){return Math.atan2(e[1],e[0])}function Wt(e,t){var n=Math.atan2(t[1],t[0])-Math.atan2(e[1],e[0]);return n>Math.PI?n-=2*Math.PI:n<=-Math.PI&&(n+=2*Math.PI),n}var B=function(){function e(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.isMutating=!1,this.length=2,typeof t=="number"?typeof n[0]=="number"?(this[0]=t,this[1]=n[0]):(this[0]=t,this[1]=t):"x"in t&&"y"in t?(this[0]=t.x,this[1]=t.y):(this[0]=t[0],this[1]=t[1])}return Object.defineProperty(e.prototype,"x",{get:function(){return this[0]},set:function(t){this[0]=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this[1]},set:function(t){this[1]=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"magnitude",{get:function(){return Ut(this)},set:function(t){var n=Ut(this);Mt(this,t/n,this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mutable",{get:function(){return this.isMutating=!0,this},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"immutable",{get:function(){return this.isMutating=!1,this},enumerable:!0,configurable:!0}),e.prototype.set=function(t,n){return typeof t=="number"?typeof n=="number"?(this[0]=t,this[1]=n):(this[0]=t,this[1]=t):(this[0]=t[0],this[1]=t[1]),this},e.prototype.add=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?Ht(this,[t,n]):Ht(this.clone(),[t,n]):this.isMutating?Ht(this,t):Ht(this.clone(),t)},e.add=function(t,n){var i=new e(t);return Ht(i,n)},e.prototype.sub=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?Vt(this,[t,n]):Vt(this.clone(),[t,n]):this.isMutating?Vt(this,t):Vt(this.clone(),t)},e.sub=function(t,n){var i=new e(t);return Vt(i,n)},e.prototype.subFrom=function(t,n){return n===void 0&&(n=0),typeof t=="number"?this.isMutating?(this[0]=t-this[0],this[1]=n-this[1],this):new e(t-this[0],n-this[1]):this.isMutating?(this[0]=t[0]-this[0],this[1]=t[1]-this[1],this):new e(t[0]-this[0],t[1]-this[1])},e.divide=function(t,n){var i=new e(t);return Mt(i,1/n)},e.multiply=function(t,n){var i=new e(t);return Mt(i,n)},e.prototype.scale=function(t){return Mt(this,t,this.isMutating?this:e.zero)},e.prototype.rescale=function(t){var n=Ut(this);return n<=0?this.isMutating?this:e.zero:Mt(this,t/n,this.isMutating?this:e.zero)},e.prototype.clampMagnitude=function(t){var n=Ut(this);return n>t?Mt(this,t/n,this.isMutating?this:e.zero):this.isMutating?this:this.clone()},e.prototype.rotate=function(t){return nn(this,t,this.isMutating?this:e.zero)},e.prototype.rotateDeg=function(t){return nn(this,t*Xo,this.isMutating?this:e.zero)},e.prototype.rotate90=function(){return t=this,n=this.isMutating?this:e.zero,i=t[0],n[0]=-t[1],n[1]=i,n;var t,n,i},e.prototype.rotate180=function(){return t=this,(n=this.isMutating?this:e.zero)[0]=-t[0],n[1]=-t[1],n;var t,n},e.prototype.rotate270=function(){return t=this,n=this.isMutating?this:e.zero,i=t[0],n[0]=t[1],n[1]=-i,n;var t,n,i},e.prototype.normalize=function(){return Pi(this)},e.prototype.normalized=function(){return Pi(this,e.zero)},e.distance=function(t,n){return Uo(t,n)},e.dot=function(t,n){return Wo(t,n)},e.cross=function(t,n){return function(i,r){return i[0]*r[1]-i[1]*r[0]}(t,n)},e.angleRight=function(t){return Li(t)},e.angleRightDeg=function(t){return Li(t)*en},e.angle=function(t,n){return Math.abs(Wt(t,n))},e.angleDeg=function(t,n){return Math.abs(Wt(t,n))*en},e.signedAngle=function(t,n){return Wt(t,n)},e.signedAngleDeg=function(t,n){return Wt(t,n)*en},e.lerp=function(t,n,i){var r=new e(t);return Yo(r,n,i)},e.lerpRot=function(t,n,i){return function(r,s,o,a){return a===void 0&&(a=r),nn(r,o*Wt(r,s),a)}(t,n,i,e.zero)},e.prototype.clone=function(){return new e(this[0],this[1])},e.equals=function(t,n,i){return i===void 0&&(i=0),!(Math.abs(t[0]-n[0])>i)&&!(Math.abs(t[1]-n[1])>i)},e.prototype.equals=function(t,n){return n===void 0&&(n=0),e.equals(this,t,n)},e.isZeroVector=function(t,n){return n===void 0&&(n=0),Ci(t,n)},e.prototype.isZeroVector=function(t){return t===void 0&&(t=0),Ci(this,t)},e.prototype.toArray=function(){return[this[0],this[1]]},e.prototype.modify=function(t){return Go(this,t)},e.prototype[Symbol.iterator]=function(){var t=this,n=0;return{next:function(){switch(n++){case 0:return{value:t[0],done:!1};case 1:return{value:t[1],done:!1};default:return{value:-1,done:!0}}}}},Object.defineProperty(e,"zero",{get:function(){return new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"positiveInfinity",{get:function(){return new e(1/0,1/0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"negativeInfinity",{get:function(){return new e(-1/0,-1/0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"up",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"right",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"down",{get:function(){return new e(0,-1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"left",{get:function(){return new e(-1,0)},enumerable:!0,configurable:!0}),e}();/*! *****************************************************************************
2
2
  Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
@@ -11,5 +11,5 @@
11
11
 
12
12
  See the Apache Version 2.0 License for specific language governing permissions
13
13
  and limitations under the License.
14
- ***************************************************************************** */var sn=function(e,t){return sn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var r in i)i.hasOwnProperty(r)&&(n[r]=i[r])},sn(e,t)},Et=function(){return Et=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Et.apply(this,arguments)};function Xo(e,t){for(var n=0;n<e.length;n++)e[n]=t;return e}function jo(e,t){for(var n=0;n<e.length;n++)e[n]=t(e[n],n);return e}function qo(e,t,n){n===void 0&&(n=0);for(var i=0;i<e.length;i++)n=t(n,e[i],i);return n}var W=Math.pow(2,-42);function Ri(e){var t=Math.pow(Math.abs(e),.3333333333333333);return e<0?-t:t}function Fi(e,t,n){if(Math.abs(e)<W)return Math.abs(t)<W?[]:[-n/t];var i=t*t-4*e*n;return Math.abs(i)<W?[-t/(2*e)]:i>0?[(-t+Math.sqrt(i))/(2*e),(-t-Math.sqrt(i))/(2*e)]:[]}function Zo(e,t,n,i){if(Math.abs(e)<W)return Fi(t,n,i);var r,s=(3*e*n-t*t)/(3*e*e),o=(2*t*t*t-9*e*t*n+27*e*e*i)/(27*e*e*e);if(Math.abs(s)<W)r=[Ri(-o)];else if(Math.abs(o)<W)r=[0].concat(s<0?[Math.sqrt(-s),-Math.sqrt(-s)]:[]);else{var a=o*o/4+s*s*s/27;if(Math.abs(a)<W)r=[-1.5*o/s,3*o/s];else if(a>0)r=[(c=Ri(-o/2-Math.sqrt(a)))-s/(3*c)];else{var c=2*Math.sqrt(-s/3),h=Math.acos(3*o/s/c)/3,l=2*Math.PI/3;r=[c*Math.cos(h),c*Math.cos(h-l),c*Math.cos(h-2*l)]}}for(var u=0;u<r.length;u++)r[u]-=t/(3*e);return r}function ue(e,t,n,i,r,s,o){r===void 0&&(r=0),s===void 0&&(s=.5),o===void 0&&(o=[0,1,2,3]);var a=o[0],c=o[1],h=o[2],l=o[3],u=0,f=0;return c-h!=0&&(a-c!=0&&a-h!=0&&(u=(1-s)*(h-c)*((e-t)/(a-c)-(e-n)/(a-h)+(t-n)/(c-h))),c-l!=0&&h-l!=0&&(f=(1-s)*(h-c)*((t-n)/(c-h)-(t-i)/(c-l)+(n-i)/(h-l)))),[2*t-2*n+u+f,-3*t+3*n-2*u-f,u,t-r]}function on(e,t,n,i,r,s,o){if(Math.abs(e)<W)return r;if(Math.abs(1-e)<W)return s;var a=e*e,c=e*a,h=ue(i,r,s,o,0,t,n);return h[0]*c+h[1]*a+h[2]*e+h[3]}function Ko(e,t,n,i,r,s,o){var a=e*e,c=ue(i,r,s,o,0,t,n);return 3*c[0]*a+2*c[1]*e+c[2]}function zi(e,t){for(var n=0,i=0;i<e.length;i++)n+=(e[i]-t[i])*(e[i]-t[i]);return n}function Qo(e,t){var n=zi(e,t);return n===0?0:Math.sqrt(n)}function an(e){var t=qo(e,function(i,r){return i+Math.pow(r,2)}),n=Math.sqrt(t);return n===0?Xo(e,0):jo(e,function(i){return i/n})}function Jo(e){if(e.length>2)throw Error("Only supported for 2d vectors");var t=-e[1];return e[1]=e[0],e[0]=t,e}function ta(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e<t?t:e>n?n:e}function Di(e,t){for(var n=new Array(e.length),i=0;i<e.length;i++)n[i]=2*e[i]+-1*t[i];return n}function fe(e,t,n){var i,r,s,o,a=t.length-1;return n?(i=t[e-1<0?a:e-1],r=t[e%t.length],s=t[(e+1)%t.length],o=t[(e+2)%t.length]):(r=t[e],s=t[Math.min(a,e+1)],i=e>0?t[e-1]:Di(r,s),o=e<a-1?t[e+2]:Di(s,r)),[i,r,s,o]}function de(e,t,n,i,r){if(r===void 0&&(r=0),r===0)return[0,1,2,3];var s=function(c,h){return Math.pow(zi(c,h),.5*r)},o=s(t,e),a=s(n,t)+o;return[0,o,a,s(i,n)+a]}function Rt(e,t,n,i){n===void 0&&(n={});var r=Number.isFinite(n.tension)?n.tension:.5,s=Number.isFinite(n.alpha)?n.alpha:0,o=!!n.closed,a=n.func||on,c=(o?t.length:t.length-1)*e,h=Math.floor(c),l=c-h,u=fe(h,t,o),f=u[0],g=u[1],d=u[2],p=u[3];i=i||new Array(f.length);for(var y=de(f,g,d,p,s),_=0;_<f.length;_++)i[_]=a(l,r,y,f[_],g[_],d[_],p[_]);return i}function cn(e,t,n,i){n===void 0&&(n={});var r=Number.isFinite(n.tension)?n.tension:.5,s=Number.isFinite(n.alpha)?n.alpha:0,o=!!n.closed;return r===1&&e===0?e+=W:(r===1||s>0)&&e===1&&(e-=W),Rt(e,t,{tension:r,alpha:s,closed:o,func:Ko},i)}function hn(e,t,n){n===void 0&&(n={});var i,r=[],s=Rt(0,e,n),o=0;t=t||300,r.push(0);for(var a=1;a<=t;a++)o+=Qo(i=Rt(a/t,e,n),s),r.push(o),s=i;return r}function ln(e,t){for(var n,i=t.length,r=e*t[i-1],s=0,o=i-1,a=0;s<=o;)if((n=t[a=Math.floor(s+(o-s)/2)]-r)<0)s=a+1;else{if(!(n>0)){o=a;break}o=a-1}if(t[a=o]===r)return a/(i-1);var c=t[a];return(a+(r-c)/(t[a+1]-c))/(i-1)}function ea(e,t){if(e===0)return 0;if(e===1)return 1;var n=t.length-1,i=t[n],r=e*n,s=Math.floor(r),o=t[s];return r===s?o/i:(o+(r-s)*(t[s+1]-o))/i}function Oi(e,t,n,i,r,s,o){var a=ue(i,r,s,o,e,t,n),c=a[0],h=a[1],l=a[2],u=a[3];return c===0&&h===0&&l===0&&u===0?[0]:Zo(c,h,l,u).filter(function(f){return f>-W&&f<=1+W}).map(function(f){return ta(f,0,1)})}function na(e,t,n){for(var i=Et({axis:0,tension:.5,alpha:0,closed:!1,margin:.5,max:0,processRefAxis:!1,func:on},n),r=i.func,s=i.axis,o=i.tension,a=i.alpha,c=i.closed,h=i.margin,l=i.max,u=i.processRefAxis,f=s,g=[],d=c?t.length:t.length-1,p=0;p<d;p+=1){var y=l<0?d-(p+1):p,_=fe(y,t,c),x=_[0],v=_[1],C=_[2],b=_[3],S=void 0,M=void 0;if(v[f]<C[f]?(S=v[f],M=C[f]):(S=C[f],M=v[f]),e-h<=M&&e+h>=S){var R=de(x,v,C,b,a),F=Oi(e,o,R,x[f],v[f],C[f],b[f]);l<0?F.sort(function(m,T){return T-m}):l>=0&&F.sort(function(m,T){return m-T});for(var O=0;O<F.length;O++)if(!(F[O]===0&&p>0)){for(var A=[],E=0;E<x.length;E++){var I=void 0;I=E!==f||u?r(F[O],o,R,x[E],v[E],C[E],b[E],y-1):e,A[E]=I}if(g.push(A),g.length===Math.abs(l))return g}}}return g}function ia(e,t,n){for(var i=Et({axis:0,tension:.5,alpha:0,closed:!1,margin:.5,max:0},n),r=i.axis,s=i.tension,o=i.alpha,a=i.closed,c=i.margin,h=i.max,l=r,u=new Set,f=n.arcLengths||hn(t,n.arcDivisions||300,{tension:s,alpha:o,closed:a}),g=a?t.length:t.length-1,d=0;d<g;d+=1){var p=h<0?t.length-d:d,y=fe(p,t,a),_=y[0],x=y[1],v=y[2],C=y[3],b=void 0,S=void 0;x[l]<v[l]?(b=x[l],S=v[l]):(b=v[l],S=x[l]);var M=de(_,x,v,C,o);if(e-c<=S&&e+c>=b){var R=Oi(e,s,M,_[l],x[l],v[l],C[l]);h<0?R.sort(function(A,E){return E-A}):h>=0&&R.sort(function(A,E){return A-E});for(var F=0;F<R.length;F++)if(!(R[F]===0&&d>0)){var O=ea((R[F]+p)/g,f);if(u.add(O),u.size===Math.abs(h))return Array.from(u)}}}return Array.from(u)}function ra(e,t){t===void 0&&(t={});for(var n=Et({tension:.5,alpha:0,closed:!1,from:0,to:1,arcDivisions:300},t),i=n.tension,r=n.alpha,s=n.closed,o=n.from,a=n.to,c=n.arcDivisions,h=s?e.length:e.length-1,l=t.arcLengths||hn(e,c,{tension:i,alpha:r,closed:s}),u=ln(o,l),f=ln(a,l),g=Math.floor(h*u),d=Math.ceil(h*f),p=Rt(u,e,{tension:i,alpha:r,closed:s}),y=Rt(f,e,{tension:i,alpha:r,closed:s}),_=[],x=[],v=0;v<p.length;v++)_[v]=Math.min(p[v],y[v]),x[v]=Math.max(p[v],y[v]);for(var C=function(S){var M=fe(S-1,e,s),R=M[0],F=M[1],O=M[2],A=M[3];if(S<d)for(var E=0;E<O.length;E++)O[E]<_[E]&&(_[E]=O[E]),O[E]>x[E]&&(x[E]=O[E]);if(i<1){var I=h*u-(S-1),m=h*f-(S-1),T=function(L){return L>-W&&L<=1+W&&(S-1!==g||L>I)&&(S!==d||L<m)},w=de(R,F,O,A,r),k=function(L){var D=ue(R[L],F[L],O[L],A[L],0,i,w);Fi(3*D[0],2*D[1],D[2]).filter(T).forEach(function(N){var $=on(N,i,w,R[L],F[L],O[L],A[L]);$<_[L]&&(_[L]=$),$>x[L]&&(x[L]=$)})};for(E=0;E<R.length;E++)k(E)}},b=g+1;b<=d;b++)C(b);return{min:_,max:x}}var un=function(){function e(t,n){n===void 0&&(n={}),n=Et({tension:.5,alpha:0,arcDivisions:300,closed:!1},n),this._cache={},this._tension=n.tension,this._alpha=n.alpha,this._arcDivisions=n.arcDivisions,this._lmargin=n.lmargin||1-this._tension,this._closed=n.closed,this.points=t}return e.prototype.getT=function(t){return ln(t,this.arcLengths)},e.prototype.getPointAt=function(t,n){var i={tension:this.tension,alpha:this.alpha,closed:this.closed};return Rt(this.getT(t),this.points,i,n)},e.prototype.getTangentAt=function(t,n){return n===void 0&&(n=null),an(cn(this.getT(t),this.points,{tension:this.tension,alpha:this.alpha,closed:this.closed},n))},e.prototype.getBoundingBox=function(t,n){if(t===void 0&&(t=0),n===void 0&&(n=1),t===0&&n===1&&this._cache.bbox)return this._cache.bbox;var i=ra(this.points,{from:t,to:n,tension:this.tension,alpha:this.alpha,closed:this.closed,arcLengths:this.arcLengths});return t===0&&n===1&&(this._cache.bbox=i),i},e.prototype.getPoints=function(t,n,i,r){if(t===void 0&&(t=100),i===void 0&&(i=0),r===void 0&&(r=1),!t||t<=0)throw Error("Invalid arguments passed to getPoints(). You must specify at least 1 sample/segment.");if(!(i<0||r>1||r<i)){for(var s=[],o=0;o<=t;o++){var a=i===0&&r===1?o/t:i+o/t*(r-i);s.push(this.getPointAt(a,n&&new n))}return s}},e.prototype.lookup=function(t,n,i,r){n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=na(t,this.points,{axis:n,tension:this.tension,alpha:this.alpha,closed:this.closed,max:i,margin:r});return Math.abs(i)===1&&s.length===1?s[0]:s},e.prototype.lookupPositions=function(t,n,i,r){return n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin),ia(t,this.points,{axis:n,arcLengths:this.arcLengths,tension:this.tension,alpha:this.alpha,closed:this.closed,max:i,margin:r})},e.prototype.invalidateCache=function(){var t=this;return Object.keys(this._cache).forEach(function(n){delete t._cache[n]}),this},Object.defineProperty(e.prototype,"points",{get:function(){return this._points},set:function(t){this._points=t,this.invalidateCache()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tension",{get:function(){return this._tension},set:function(t){t!==this._tension&&(this._tension=t,this.invalidateCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){t!==this._alpha&&(this._alpha=t,this.invalidateCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},set:function(t){t!==this._closed&&(this._closed=t,this.invalidateCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"arcDivisions",{get:function(){return this._arcDivisions},set:function(t){t!==this._arcDivisions&&(this._arcDivisions=t,this.invalidateCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"arcLengths",{get:function(){if(this._cache.arcLengths)return this._cache.arcLengths;var t=hn(this.points,this.arcDivisions,{tension:this.tension,alpha:this.alpha,closed:this.closed});return this._cache.arcLengths=t,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){var t=this.arcLengths;return t[t.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minX",{get:function(){return this.getBoundingBox().min[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxX",{get:function(){return this.getBoundingBox().max[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minY",{get:function(){return this.getBoundingBox().min[1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxY",{get:function(){return this.getBoundingBox().max[1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minZ",{get:function(){return this.getBoundingBox().min[2]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxZ",{get:function(){return this.getBoundingBox().max[2]},enumerable:!1,configurable:!0}),e}();(function(e){function t(n,i,r,s,o){return i===void 0&&(i=.5),r===void 0&&(r=300),s===void 0&&(s=!1),o===void 0&&(o=0),e.call(this,n,{tension:i,alpha:o,arcDivisions:r,closed:s})||this}return function(n,i){function r(){this.constructor=n}sn(n,i),n.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}(t,e),t.prototype.x=function(n,i,r){i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=this.lookup(n,1,i,r);return Math.abs(i)===1?s[0]:s.map(function(o){return o[0]})},t.prototype.y=function(n,i,r){i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=this.lookup(n,0,i,r);return Math.abs(i)===1?s[1]:s.map(function(o){return o[1]})},t.prototype.getNormalAt=function(n,i){return an(Jo(cn(this.getT(n),this.points,{tension:this.tension,alpha:this.alpha,closed:this.closed},i)))},t.prototype.getAngleAt=function(n){var i=cn(this.getT(n),this.points,{tension:this.tension,alpha:this.alpha,closed:this.closed});return Math.atan2(i[1],i[0])},t.prototype.getBoundingBox=function(n,i){n===void 0&&(n=0),i===void 0&&(i=1);var r=e.prototype.getBoundingBox.call(this,n,i);return{x1:r.min[0],x2:r.max[0],y1:r.min[1],y2:r.max[1],min:r.min,max:r.max}},t})(un);class ge{static newton(t,n=.01,i=1e3,r=.5,s=0,o=1){let c=r;for(let h=0;h<i;h++){const l=t(c);if(Math.abs(l)<n)return gt(c,s,o);const u=(t(c+1e-4)-l)/1e-4;c=c-l/u}return null}static bisect(t,n=.01,i=1e3,r=.5,s=0,o=1){let a=s,c=o,h=r,l,u;for(u=0;u<i;u++){if(l=t(h),Math.abs(l)<n)return h;l<0?c=h:a=h,h=(c+a)/2}return h}static findRoot(t,n=.01,i=1e3,r=.5,s=0,o=1){let a=ge.newton(t,n,i,r);return a==null&&(a=ge.bisect(t,n,i,r,s,o)),a}}class sa{static bisect(t,n=0,i=1,r=.005,s=4,o=10){const a=(f,g,d,p,y,_,x=0)=>{const v=(f+g)/2,C=t(v),b=B.distance(d,C),S=B.distance(C,p),M=b+S;if(x>=s&&Math.abs(M-y)<_||x>=o)return M;const R=_/2,F=x+1;return a(f,v,d,C,b,R,F)+a(v,g,C,p,S,R,F)},c=t(n),h=t(i),l=B.distance(c,h);return a(n,i,c,h,l,r)}static trapezoid(t,n=0,i=1,r=1e3){let s=0,o=t(n);const a=(i-n)/(r-1);for(let c=1;c<r;c++){const h=t(n+c*a),l=B.distance(o,h);s+=l,o=h}return s}}class oa{static search(t,n){let i=0,r=t.length-1,s=Math.floor(i+r/2);for(;s>i&&s<r;){const o=t[s],a=t[s+1];if(o<=n&&a>=n)return s;n<o?r=s:i=s,s=Math.floor(i+r/2)}return s}}class fn extends un{constructor(t,n){super(t,n),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)}findTForArcLength(t,n){let i;return n!=null&&n.approxT?i=this.findApproxTForArcLength(t,n==null?void 0:n.normalizedLength):n!=null&&n.quickT?i=this.findTQuickForArcLength(t):i=this.findTByRootForArcLength(t),i}findTByRootForArcLength(t,n=.01,i=100){return t<=0?0:t>=this.length?1:ge.findRoot(s=>t-this.getQuickArcLength(0,s),n,i,t/this.length)}findApproxTForArcLength(t,n){return t/(n||this.length)}findTQuickForArcLength(t){this.arcLengthLookup.length===0&&this.generateArcLengthLookup();const n=oa.search(this.arcLengthLookup,t),i=this.arcLengthLookup[n],r=this.arcLengthLookup[n+1];return(n+(t-i)/(r-i))/this.arcLengthLookup.length}generateArcLengthLookup(t=1e3){let n=this.getPointAt(0),i=0;for(let r=0;r<t;r++){const s=this.getPointAt(r/(t-1)),o=B.distance(n,s);i+=o,this.arcLengthLookup.push(i),n=s}}getArcLength(t=0,n=1){if(t===0&&n===1)return this.length;const i=.002;return sa.bisect(r=>this.getPointAt(r),t,n,i)}getQuickArcLength(t=0,n=1){let i=0,r=this.length;if(this.arcLengthLookup.length===0&&this.generateArcLengthLookup(),t!==0){const o=Math.floor(t*this.arcLengthLookup.length),a=this.arcLengthLookup[o],c=this.arcLengthLookup[o+1];i=a+t*this.arcLengthLookup.length%this.arcLengthLookup.length*(c-a)}if(n!==1){const o=Math.floor(n*this.arcLengthLookup.length),a=this.arcLengthLookup[o],c=this.arcLengthLookup[o+1];r=a+t*this.arcLengthLookup.length%this.arcLengthLookup.length*(c-a)}return r-i}getPointAtArcLength(t,n){const i=this.findTForArcLength(t,n);return this.getPointAt(i)}getPointAt(t){const n=gt(t,0,1);return super.getPointAt(n)}}const Ni=.75,$i=5e3,Bi=.001,aa=1e3,ca=1e3,ha=5e-4,la=.1,ua={approxT:!0};class Ft{constructor(t,n){if(this.path=[],this.projectedPath=[],this._offset=0,t.length<1)throw new Error("Missing coordinates");if(t[0]&&t[0].length!==3)throw new Error("Coordinates should be in 3d");this.setPath(t,n),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)}setPath(t,n={}){this.options={...ua,...n};const{arcDivisions:i,tension:r,calculateDisplacementFromBottom:s}=this.options;this.path=t,this.projectedPath=Ft.toDisplacement(t);const[o]=this.projectedPath[this.projectedPath.length-1];this.displacement=o,this.interpolators={curve:n.curveInterpolator||new fn(t),trajectory:n.trajectoryInterpolator||new fn(t.map(h=>[h[0],h[1]]),{tension:r||Ni,arcDivisions:i||$i}),curtain:n.curtainInterpolator||new fn(this.projectedPath,{tension:r||Ni,arcDivisions:i||$i})};const a=this.getTrajectoryVector(),c=a.map(h=>h*-1);s?(this.endVector=c,this.startVector=a):(this.endVector=a,this.startVector=c),this._curtainPathCache=void 0}project(t){const{curtain:n}=this.interpolators,{calculateDisplacementFromBottom:i}=this.options,r=gt(i?this.length-(t-this._offset):t-this._offset,0,this.length);return n.getPointAtArcLength(r,this.options)}curtainTangent(t){const{curtain:n}=this.interpolators,i=t-this._offset,r=n.findTForArcLength(i,this.options);return r&&n.getTangentAt(r)}getCurtainPath(t,n,i=!1){if(!this._curtainPathCache){const r=[];let s=Math.PI*2;for(let o=this._offset;o<=this.length+this._offset;o+=la){const a=this.project(o),c=Math.atan2(a[1],a[0]);Math.abs(c-s)>ha&&(r.push({point:a,md:o}),s=c)}this._curtainPathCache=r}if(i){const r={point:this.project(t),md:t},s=this._curtainPathCache.filter(a=>a.md>t&&a.md<n),o={point:this.project(n),md:n};return[r,...s,o]}return this._curtainPathCache.filter(r=>r.md>=t&&r.md<=n)}unproject(t){const{normalizedLength:n,calculateDisplacementFromBottom:i}=this.options,r=i?this.displacement-t:t,s=n||this.length;if(r<0)return r;if(r>this.displacement)return s+(r-this.displacement);const o=this.interpolators.curtain.lookupPositions(r,0,1);return o&&o.length?o[0]*s+this._offset:null}getProjectedLength(t){const{curtain:n}=this.interpolators,r=this.project(t)[0]/n.maxX;return Number.isFinite(r)?gt(r,0,1):0}getPosition(t){const{trajectory:n}=this.interpolators,i=this.getProjectedLength(t);return n.getPointAt(i)}getTrajectory(t,n=0,i=1){const r=n<0?-n:0,s=i>1?i-1:0,o=this.interpolators.trajectory.getPointAt(0),a=this.interpolators.trajectory.getPointAt(1);let c,h,l=0;const u=Math.max(0,n),f=Math.min(1,i),g=this.interpolators.trajectory.getPointAt(u),d=this.interpolators.trajectory.getPointAt(f);r?(c=[o[0]+this.startVector[0]*r*this.displacement,o[1]+this.startVector[1]*r*this.displacement],l=-B.distance(c,o)):n>0&&(l=B.distance(g,o)),s&&(h=[a[0]+this.endVector[0]*s*this.displacement,a[1]+this.endVector[1]*s*this.displacement]);const p=[],y=i-n,_=Math.floor(r/y*t),x=Math.ceil((f-u)/y*t),v=t-x-_;if(c){p.push(c);for(let b=1;b<_;b++){const S=b/_*r*this.displacement;p.push([c[0]-this.startVector[0]*S,c[1]-this.startVector[1]*S])}}const C=this.interpolators.trajectory.getPoints(x-1,null,u,f);if(p.push(...C),h){for(let b=1;b<v-1;b++){const S=b/v*s*this.displacement;p.push([d[0]+this.endVector[0]*S,d[1]+this.endVector[1]*S])}p.push(h)}return{points:p,offset:l}}getExtendedTrajectory(t,n=aa,i=ca){if(!isFinite(n)||n<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive startExtensionLength parameter");if(!isFinite(i)||i<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive endExtensionLength parameter");const r=this.displacement+n+i,s=Math.floor(n/r*t),o=Math.max(Math.ceil(this.displacement/r*t),1),a=t-o-s,c=[],h=new B(this.interpolators.trajectory.getPointAt(0)),l=new B(this.startVector),u=n/s;for(let x=s;x>0;x--){const v=x*u,C=h.add(l.scale(v));c.push(C.toArray())}const f=this.interpolators.trajectory.getPoints(o,null,0,1);c.push(...f);const g=new B(this.interpolators.trajectory.getPointAt(1)),d=new B(this.endVector),p=i/(a-1);for(let x=1;x<a;x++){const v=x*p,C=g.add(d.scale(v));c.push(C.toArray())}const y=-n;return{points:c,offset:y}}getTrajectoryVector(){const{trajectoryAngle:t,calculateDisplacementFromBottom:n}=this.options;if(isFinite(t)){const r=Bo(t);return new B(Math.cos(r),Math.sin(r)).toArray()}return Ft.getDirectionVector(this.interpolators.trajectory,n?Bi:1-Bi,n?0:1)}static toDisplacement(t,n=0){let i=t[0],r=0;return t.map(o=>{const a=o[0]-i[0],c=o[1]-i[1];return r+=Math.sqrt(a**2+c**2),i=o,[n>0?n-r:r,o[2]||0]})}static getDirectionVector(t,n,i){const r=t.getPointAt(i),s=t.getPointAt(n);return an([r[0]-s[0],r[1]-s[1]])}get length(){return this.interpolators.curve.length}get offset(){return this._offset}set offset(t){this._curtainPathCache=void 0,this._offset=t}}var dn="http://www.w3.org/1999/xhtml";const Ii={svg:"http://www.w3.org/2000/svg",xhtml:dn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function pe(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ii.hasOwnProperty(t)?{space:Ii[t],local:e}:e}function fa(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===dn&&t.documentElement.namespaceURI===dn?t.createElement(e):t.createElementNS(n,e)}}function da(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Hi(e){var t=pe(e);return(t.local?da:fa)(t)}function ga(){}function gn(e){return e==null?ga:function(){return this.querySelector(e)}}function pa(e){typeof e!="function"&&(e=gn(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=new Array(o),c,h,l=0;l<o;++l)(c=s[l])&&(h=e.call(c,c.__data__,l,s))&&("__data__"in c&&(h.__data__=c.__data__),a[l]=h);return new j(i,this._parents)}function ma(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ya(){return[]}function Vi(e){return e==null?ya:function(){return this.querySelectorAll(e)}}function _a(e){return function(){return ma(e.apply(this,arguments))}}function xa(e){typeof e=="function"?e=_a(e):e=Vi(e);for(var t=this._groups,n=t.length,i=[],r=[],s=0;s<n;++s)for(var o=t[s],a=o.length,c,h=0;h<a;++h)(c=o[h])&&(i.push(e.call(c,c.__data__,h,o)),r.push(c));return new j(i,r)}function Ui(e){return function(){return this.matches(e)}}function Wi(e){return function(t){return t.matches(e)}}var va=Array.prototype.find;function wa(e){return function(){return va.call(this.children,e)}}function ba(){return this.firstElementChild}function Sa(e){return this.select(e==null?ba:wa(typeof e=="function"?e:Wi(e)))}var Ta=Array.prototype.filter;function Ma(){return Array.from(this.children)}function Aa(e){return function(){return Ta.call(this.children,e)}}function Pa(e){return this.selectAll(e==null?Ma:Aa(typeof e=="function"?e:Wi(e)))}function Ca(e){typeof e!="function"&&(e=Ui(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,h=0;h<o;++h)(c=s[h])&&e.call(c,c.__data__,h,s)&&a.push(c);return new j(i,this._parents)}function Yi(e){return new Array(e.length)}function La(){return new j(this._enter||this._groups.map(Yi),this._parents)}function me(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}me.prototype={constructor:me,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function ka(e){return function(){return e}}function Ea(e,t,n,i,r,s){for(var o=0,a,c=t.length,h=s.length;o<h;++o)(a=t[o])?(a.__data__=s[o],i[o]=a):n[o]=new me(e,s[o]);for(;o<c;++o)(a=t[o])&&(r[o]=a)}function Ra(e,t,n,i,r,s,o){var a,c,h=new Map,l=t.length,u=s.length,f=new Array(l),g;for(a=0;a<l;++a)(c=t[a])&&(f[a]=g=o.call(c,c.__data__,a,t)+"",h.has(g)?r[a]=c:h.set(g,c));for(a=0;a<u;++a)g=o.call(e,s[a],a,s)+"",(c=h.get(g))?(i[a]=c,c.__data__=s[a],h.delete(g)):n[a]=new me(e,s[a]);for(a=0;a<l;++a)(c=t[a])&&h.get(f[a])===c&&(r[a]=c)}function Fa(e){return e.__data__}function za(e,t){if(!arguments.length)return Array.from(this,Fa);var n=t?Ra:Ea,i=this._parents,r=this._groups;typeof e!="function"&&(e=ka(e));for(var s=r.length,o=new Array(s),a=new Array(s),c=new Array(s),h=0;h<s;++h){var l=i[h],u=r[h],f=u.length,g=Da(e.call(l,l&&l.__data__,h,i)),d=g.length,p=a[h]=new Array(d),y=o[h]=new Array(d),_=c[h]=new Array(f);n(l,u,p,y,_,g,t);for(var x=0,v=0,C,b;x<d;++x)if(C=p[x]){for(x>=v&&(v=x+1);!(b=y[v])&&++v<d;);C._next=b||null}}return o=new j(o,i),o._enter=a,o._exit=c,o}function Da(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Oa(){return new j(this._exit||this._groups.map(Yi),this._parents)}function Na(e,t,n){var i=this.enter(),r=this,s=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),i&&r?i.merge(r).order():r}function $a(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,s=i.length,o=Math.min(r,s),a=new Array(r),c=0;c<o;++c)for(var h=n[c],l=i[c],u=h.length,f=a[c]=new Array(u),g,d=0;d<u;++d)(g=h[d]||l[d])&&(f[d]=g);for(;c<r;++c)a[c]=n[c];return new j(a,this._parents)}function Ba(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Ia(e){e||(e=Ha);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var o=n[s],a=o.length,c=r[s]=new Array(a),h,l=0;l<a;++l)(h=o[l])&&(c[l]=h);c.sort(t)}return new j(r,this._parents).order()}function Ha(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Va(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ua(){return Array.from(this)}function Wa(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function Ya(){let e=0;for(const t of this)++e;return e}function Ga(){return!this.node()}function Xa(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],s=0,o=r.length,a;s<o;++s)(a=r[s])&&e.call(a,a.__data__,s,r);return this}function ja(e){return function(){this.removeAttribute(e)}}function qa(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Za(e,t){return function(){this.setAttribute(e,t)}}function Ka(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Qa(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Ja(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function tc(e,t){var n=pe(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?qa:ja:typeof t=="function"?n.local?Ja:Qa:n.local?Ka:Za)(n,t))}function Gi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ec(e){return function(){this.style.removeProperty(e)}}function nc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ic(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function rc(e,t,n){return arguments.length>1?this.each((t==null?ec:typeof t=="function"?ic:nc)(e,t,n??"")):zt(this.node(),e)}function zt(e,t){return e.style.getPropertyValue(t)||Gi(e).getComputedStyle(e,null).getPropertyValue(t)}function sc(e){return function(){delete this[e]}}function oc(e,t){return function(){this[e]=t}}function ac(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function cc(e,t){return arguments.length>1?this.each((t==null?sc:typeof t=="function"?ac:oc)(e,t)):this.node()[e]}function Xi(e){return e.trim().split(/^|\s+/)}function pn(e){return e.classList||new ji(e)}function ji(e){this._node=e,this._names=Xi(e.getAttribute("class")||"")}ji.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function qi(e,t){for(var n=pn(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function Zi(e,t){for(var n=pn(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function hc(e){return function(){qi(this,e)}}function lc(e){return function(){Zi(this,e)}}function uc(e,t){return function(){(t.apply(this,arguments)?qi:Zi)(this,e)}}function fc(e,t){var n=Xi(e+"");if(arguments.length<2){for(var i=pn(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?uc:t?hc:lc)(n,t))}function dc(){this.textContent=""}function gc(e){return function(){this.textContent=e}}function pc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function mc(e){return arguments.length?this.each(e==null?dc:(typeof e=="function"?pc:gc)(e)):this.node().textContent}function yc(){this.innerHTML=""}function _c(e){return function(){this.innerHTML=e}}function xc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function vc(e){return arguments.length?this.each(e==null?yc:(typeof e=="function"?xc:_c)(e)):this.node().innerHTML}function wc(){this.nextSibling&&this.parentNode.appendChild(this)}function bc(){return this.each(wc)}function Sc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Tc(){return this.each(Sc)}function Mc(e){var t=typeof e=="function"?e:Hi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ac(){return null}function Pc(e,t){var n=typeof e=="function"?e:Hi(e),i=t==null?Ac:typeof t=="function"?t:gn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Cc(){var e=this.parentNode;e&&e.removeChild(this)}function Lc(){return this.each(Cc)}function kc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ec(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Rc(e){return this.select(e?Ec:kc)}function Fc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function zc(e){return function(t){e.call(this,t,this.__data__)}}function Dc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function Oc(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++i]=s;++i?t.length=i:delete this.__on}}}function Nc(e,t,n){return function(){var i=this.__on,r,s=zc(t);if(i){for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},i?i.push(r):this.__on=[r]}}function $c(e,t,n){var i=Dc(e+""),r,s=i.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,h=a.length,l;c<h;++c)for(r=0,l=a[c];r<s;++r)if((o=i[r]).type===l.type&&o.name===l.name)return l.value}return}for(a=t?Nc:Oc,r=0;r<s;++r)this.each(a(i[r],t,n));return this}function Ki(e,t,n){var i=Gi(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Bc(e,t){return function(){return Ki(this,e,t)}}function Ic(e,t){return function(){return Ki(this,e,t.apply(this,arguments))}}function Hc(e,t){return this.each((typeof t=="function"?Ic:Bc)(e,t))}function*Vc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var Qi=[null];function j(e,t){this._groups=e,this._parents=t}function Yt(){return new j([[document.documentElement]],Qi)}function Uc(){return this}j.prototype=Yt.prototype={constructor:j,select:pa,selectAll:xa,selectChild:Sa,selectChildren:Pa,filter:Ca,data:za,enter:La,exit:Oa,join:Na,merge:$a,selection:Uc,order:Ba,sort:Ia,call:Va,nodes:Ua,node:Wa,size:Ya,empty:Ga,each:Xa,attr:tc,style:rc,property:cc,classed:fc,text:mc,html:vc,raise:bc,lower:Tc,append:Mc,insert:Pc,remove:Lc,clone:Rc,datum:Fc,on:$c,dispatch:Hc,[Symbol.iterator]:Vc};function q(e){return typeof e=="string"?new j([[document.querySelector(e)]],[document.documentElement]):new j([[e]],Qi)}function Wc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function pt(e,t){if(e=Wc(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}var Yc={value:()=>{}};function mn(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new ye(n)}function ye(e){this._=e}function Gc(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}ye.prototype=mn.prototype={constructor:ye,on:function(e,t){var n=this._,i=Gc(e+"",n),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(e=i[s]).type)&&(r=Xc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<o;)if(r=(e=i[s]).type)n[r]=Ji(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Ji(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ye(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,s;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],i=0,r=s.length;i<r;++i)s[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)}};function Xc(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function Ji(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=Yc,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}const yn={capture:!0,passive:!1};function _n(e){e.preventDefault(),e.stopImmediatePropagation()}function jc(e){var t=e.document.documentElement,n=q(e).on("dragstart.drag",_n,yn);"onselectstart"in t?n.on("selectstart.drag",_n,yn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function qc(e,t){var n=e.document.documentElement,i=q(e).on("dragstart.drag",null);t&&(i.on("click.drag",_n,yn),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Dt=0,Gt=0,Xt=0,tr=1e3,_e,jt,xe=0,At=0,ve=0,qt=typeof performance=="object"&&performance.now?performance:Date,er=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function xn(){return At||(er(Zc),At=qt.now()+ve)}function Zc(){At=0}function we(){this._call=this._time=this._next=null}we.prototype=nr.prototype={constructor:we,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?xn():+n)+(t==null?0:+t),!this._next&&jt!==this&&(jt?jt._next=this:_e=this,jt=this),this._call=e,this._time=n,vn()},stop:function(){this._call&&(this._call=null,this._time=1/0,vn())}};function nr(e,t,n){var i=new we;return i.restart(e,t,n),i}function Kc(){xn(),++Dt;for(var e=_e,t;e;)(t=At-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Dt}function ir(){At=(xe=qt.now())+ve,Dt=Gt=0;try{Kc()}finally{Dt=0,Jc(),At=0}}function Qc(){var e=qt.now(),t=e-xe;t>tr&&(ve-=t,xe=e)}function Jc(){for(var e,t=_e,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:_e=n);jt=e,vn(i)}function vn(e){if(!Dt){Gt&&(Gt=clearTimeout(Gt));var t=e-At;t>24?(e<1/0&&(Gt=setTimeout(ir,e-qt.now()-ve)),Xt&&(Xt=clearInterval(Xt))):(Xt||(xe=qt.now(),Xt=setInterval(Qc,tr)),Dt=1,er(ir))}}function rr(e,t,n){var i=new we;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var th=mn("start","end","cancel","interrupt"),eh=[],sr=0,or=1,wn=2,be=3,ar=4,bn=5,Se=6;function Te(e,t,n,i,r,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;nh(e,n,{name:t,index:i,group:r,on:th,tween:eh,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:sr})}function Sn(e,t){var n=et(e,t);if(n.state>sr)throw new Error("too late; already scheduled");return n}function at(e,t){var n=et(e,t);if(n.state>be)throw new Error("too late; already running");return n}function et(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function nh(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=nr(s,0,n.time);function s(h){n.state=or,n.timer.restart(o,n.delay,n.time),n.delay<=h&&o(h-n.delay)}function o(h){var l,u,f,g;if(n.state!==or)return c();for(l in i)if(g=i[l],g.name===n.name){if(g.state===be)return rr(o);g.state===ar?(g.state=Se,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete i[l]):+l<t&&(g.state=Se,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete i[l])}if(rr(function(){n.state===be&&(n.state=ar,n.timer.restart(a,n.delay,n.time),a(h))}),n.state=wn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===wn){for(n.state=be,r=new Array(f=n.tween.length),l=0,u=-1;l<f;++l)(g=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=g);r.length=u+1}}function a(h){for(var l=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(c),n.state=bn,1),u=-1,f=r.length;++u<f;)r[u].call(e,l);n.state===bn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Se,n.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function Me(e,t){var n=e.__transition,i,r,s=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((i=n[o]).name!==t){s=!1;continue}r=i.state>wn&&i.state<bn,i.state=Se,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[o]}s&&delete e.__transition}}function ih(e){return this.each(function(){Me(this,e)})}function rh(e,t){var n,i;return function(){var r=at(this,e),s=r.tween;if(s!==n){i=n=s;for(var o=0,a=i.length;o<a;++o)if(i[o].name===t){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function sh(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=at(this,e),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:t,value:n},c=0,h=r.length;c<h;++c)if(r[c].name===t){r[c]=a;break}c===h&&r.push(a)}s.tween=r}}function oh(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=et(this.node(),n).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===e)return o.value;return null}return this.each((t==null?rh:sh)(n,e,t))}function Tn(e,t,n){var i=e._id;return e.each(function(){var r=at(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return et(r,i).value[t]}}function cr(e,t){var n;return(typeof t=="number"?tt:t instanceof ht?It:(n=ht(t))?(t=n,It):di)(e,t)}function ah(e){return function(){this.removeAttribute(e)}}function ch(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hh(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttribute(e);return o===r?null:o===i?s:s=t(i=o,n)}}function lh(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttributeNS(e.space,e.local);return o===r?null:o===i?s:s=t(i=o,n)}}function uh(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function fh(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function dh(e,t){var n=pe(e),i=n==="transform"?lo:cr;return this.attrTween(e,typeof t=="function"?(n.local?fh:uh)(n,i,Tn(this,"attr."+e,t)):t==null?(n.local?ch:ah)(n):(n.local?lh:hh)(n,i,t))}function gh(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ph(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function mh(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&ph(e,s)),n}return r._value=t,r}function yh(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&gh(e,s)),n}return r._value=t,r}function _h(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=pe(e);return this.tween(n,(i.local?mh:yh)(i,t))}function xh(e,t){return function(){Sn(this,e).delay=+t.apply(this,arguments)}}function vh(e,t){return t=+t,function(){Sn(this,e).delay=t}}function wh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xh:vh)(t,e)):et(this.node(),t).delay}function bh(e,t){return function(){at(this,e).duration=+t.apply(this,arguments)}}function Sh(e,t){return t=+t,function(){at(this,e).duration=t}}function Th(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?bh:Sh)(t,e)):et(this.node(),t).duration}function Mh(e,t){if(typeof t!="function")throw new Error;return function(){at(this,e).ease=t}}function Ah(e){var t=this._id;return arguments.length?this.each(Mh(t,e)):et(this.node(),t).ease}function Ph(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;at(this,e).ease=n}}function Ch(e){if(typeof e!="function")throw new Error;return this.each(Ph(this._id,e))}function Lh(e){typeof e!="function"&&(e=Ui(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,h=0;h<o;++h)(c=s[h])&&e.call(c,c.__data__,h,s)&&a.push(c);return new lt(i,this._parents,this._name,this._id)}function kh(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var c=t[a],h=n[a],l=c.length,u=o[a]=new Array(l),f,g=0;g<l;++g)(f=c[g]||h[g])&&(u[g]=f);for(;a<i;++a)o[a]=t[a];return new lt(o,this._parents,this._name,this._id)}function Eh(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Rh(e,t,n){var i,r,s=Eh(t)?Sn:at;return function(){var o=s(this,e),a=o.on;a!==i&&(r=(i=a).copy()).on(t,n),o.on=r}}function Fh(e,t){var n=this._id;return arguments.length<2?et(this.node(),n).on.on(e):this.each(Rh(n,e,t))}function zh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Dh(){return this.on("end.remove",zh(this._id))}function Oh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=gn(e));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a=i[o],c=a.length,h=s[o]=new Array(c),l,u,f=0;f<c;++f)(l=a[f])&&(u=e.call(l,l.__data__,f,a))&&("__data__"in l&&(u.__data__=l.__data__),h[f]=u,Te(h[f],t,n,f,h,et(l,n)));return new lt(s,this._parents,t,n)}function Nh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Vi(e));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var c=i[a],h=c.length,l,u=0;u<h;++u)if(l=c[u]){for(var f=e.call(l,l.__data__,u,c),g,d=et(l,n),p=0,y=f.length;p<y;++p)(g=f[p])&&Te(g,t,n,p,f,d);s.push(f),o.push(l)}return new lt(s,o,t,n)}var $h=Yt.prototype.constructor;function Bh(){return new $h(this._groups,this._parents)}function Ih(e,t){var n,i,r;return function(){var s=zt(this,e),o=(this.style.removeProperty(e),zt(this,e));return s===o?null:s===n&&o===i?r:r=t(n=s,i=o)}}function hr(e){return function(){this.style.removeProperty(e)}}function Hh(e,t,n){var i,r=n+"",s;return function(){var o=zt(this,e);return o===r?null:o===i?s:s=t(i=o,n)}}function Vh(e,t,n){var i,r,s;return function(){var o=zt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),zt(this,e))),o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a))}}function Uh(e,t){var n,i,r,s="style."+t,o="end."+s,a;return function(){var c=at(this,e),h=c.on,l=c.value[s]==null?a||(a=hr(t)):void 0;(h!==n||r!==l)&&(i=(n=h).copy()).on(o,r=l),c.on=i}}function Wh(e,t,n){var i=(e+="")=="transform"?ho:cr;return t==null?this.styleTween(e,Ih(e,i)).on("end.style."+e,hr(e)):typeof t=="function"?this.styleTween(e,Vh(e,i,Tn(this,"style."+e,t))).each(Uh(this._id,e)):this.styleTween(e,Hh(e,i,t),n).on("end.style."+e,null)}function Yh(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function Gh(e,t,n){var i,r;function s(){var o=t.apply(this,arguments);return o!==r&&(i=(r=o)&&Yh(e,o,n)),i}return s._value=t,s}function Xh(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,Gh(e,t,n??""))}function jh(e){return function(){this.textContent=e}}function qh(e){return function(){var t=e(this);this.textContent=t??""}}function Zh(e){return this.tween("text",typeof e=="function"?qh(Tn(this,"text",e)):jh(e==null?"":e+""))}function Kh(e){return function(t){this.textContent=e.call(this,t)}}function Qh(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Kh(r)),t}return i._value=e,i}function Jh(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Qh(e))}function tl(){for(var e=this._name,t=this._id,n=lr(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,h=0;h<a;++h)if(c=o[h]){var l=et(c,t);Te(c,e,n,h,o,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new lt(i,this._parents,e,n)}function el(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(s,o){var a={value:o},c={value:function(){--r===0&&s()}};n.each(function(){var h=at(this,i),l=h.on;l!==e&&(t=(e=l).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),h.on=t}),r===0&&s()})}var nl=0;function lt(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function lr(){return++nl}var ut=Yt.prototype;lt.prototype={constructor:lt,select:Oh,selectAll:Nh,selectChild:ut.selectChild,selectChildren:ut.selectChildren,filter:Lh,merge:kh,selection:Bh,transition:tl,call:ut.call,nodes:ut.nodes,node:ut.node,size:ut.size,empty:ut.empty,each:ut.each,on:Fh,attr:dh,attrTween:_h,style:Wh,styleTween:Xh,text:Zh,textTween:Jh,remove:Dh,tween:oh,delay:wh,duration:Th,ease:Ah,easeVarying:Ch,end:el,[Symbol.iterator]:ut[Symbol.iterator]};function il(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var rl={time:null,delay:0,duration:250,ease:il};function sl(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function ol(e){var t,n;e instanceof lt?(t=e._id,e=e._name):(t=lr(),(n=rl).time=xn(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,h=0;h<a;++h)(c=o[h])&&Te(c,e,t,h,o,n||sl(c,t));return new lt(i,this._parents,e,t)}Yt.prototype.interrupt=ih,Yt.prototype.transition=ol;const Ae=e=>()=>e;function al(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function ft(e,t,n){this.k=e,this.x=t,this.y=n}ft.prototype={constructor:ft,scale:function(e){return e===1?this:new ft(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ft(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Mn=new ft(1,0,0);ft.prototype;function An(e){e.stopImmediatePropagation()}function Zt(e){e.preventDefault(),e.stopImmediatePropagation()}function cl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function hl(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.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 ur(){return this.__zoom||Mn}function ll(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ul(){return navigator.maxTouchPoints||"ontouchstart"in this}function fl(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function dl(){var e=cl,t=hl,n=fl,i=ll,r=ul,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=po,h=mn("start","zoom","end"),l,u,f,g=500,d=150,p=0,y=10;function _(m){m.property("__zoom",ur).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",F).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",A).on("touchmove.zoom",E).on("touchend.zoom touchcancel.zoom",I).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(m,T,w,k){var L=m.selection?m.selection():m;L.property("__zoom",ur),m!==L?b(m,T,w,k):L.interrupt().each(function(){S(this,arguments).event(k).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},_.scaleBy=function(m,T,w,k){_.scaleTo(m,function(){var L=this.__zoom.k,D=typeof T=="function"?T.apply(this,arguments):T;return L*D},w,k)},_.scaleTo=function(m,T,w,k){_.transform(m,function(){var L=t.apply(this,arguments),D=this.__zoom,N=w==null?C(L):typeof w=="function"?w.apply(this,arguments):w,$=D.invert(N),H=typeof T=="function"?T.apply(this,arguments):T;return n(v(x(D,H),N,$),L,o)},w,k)},_.translateBy=function(m,T,w,k){_.transform(m,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof w=="function"?w.apply(this,arguments):w),t.apply(this,arguments),o)},null,k)},_.translateTo=function(m,T,w,k,L){_.transform(m,function(){var D=t.apply(this,arguments),N=this.__zoom,$=k==null?C(D):typeof k=="function"?k.apply(this,arguments):k;return n(Mn.translate($[0],$[1]).scale(N.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof w=="function"?-w.apply(this,arguments):-w),D,o)},k,L)};function x(m,T){return T=Math.max(s[0],Math.min(s[1],T)),T===m.k?m:new ft(T,m.x,m.y)}function v(m,T,w){var k=T[0]-w[0]*m.k,L=T[1]-w[1]*m.k;return k===m.x&&L===m.y?m:new ft(m.k,k,L)}function C(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function b(m,T,w,k){m.on("start.zoom",function(){S(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(k).end()}).tween("zoom",function(){var L=this,D=arguments,N=S(L,D).event(k),$=t.apply(L,D),H=w==null?C($):typeof w=="function"?w.apply(L,D):w,Y=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),V=L.__zoom,Q=typeof T=="function"?T.apply(L,D):T,it=c(V.invert(H).concat(Y/V.k),Q.invert(H).concat(Y/Q.k));return function(X){if(X===1)X=Q;else{var rt=it(X),Jt=Y/rt[2];X=new ft(Jt,H[0]-rt[0]*Jt,H[1]-rt[1]*Jt)}N.zoom(null,X)}})}function S(m,T,w){return!w&&m.__zooming||new M(m,T)}function M(m,T){this.that=m,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(m,T),this.taps=0}M.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,T){return this.mouse&&m!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var T=q(this.that).datum();h.call(m,this.that,new al(m,{sourceEvent:this.sourceEvent,target:_,type:m,transform:this.that.__zoom,dispatch:h}),T)}};function R(m,...T){if(!e.apply(this,arguments))return;var w=S(this,T).event(m),k=this.__zoom,L=Math.max(s[0],Math.min(s[1],k.k*Math.pow(2,i.apply(this,arguments)))),D=pt(m);if(w.wheel)(w.mouse[0][0]!==D[0]||w.mouse[0][1]!==D[1])&&(w.mouse[1]=k.invert(w.mouse[0]=D)),clearTimeout(w.wheel);else{if(k.k===L)return;w.mouse=[D,k.invert(D)],Me(this),w.start()}Zt(m),w.wheel=setTimeout(N,d),w.zoom("mouse",n(v(x(k,L),w.mouse[0],w.mouse[1]),w.extent,o));function N(){w.wheel=null,w.end()}}function F(m,...T){if(f||!e.apply(this,arguments))return;var w=m.currentTarget,k=S(this,T,!0).event(m),L=q(m.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",Y,!0),D=pt(m,w),N=m.clientX,$=m.clientY;jc(m.view),An(m),k.mouse=[D,this.__zoom.invert(D)],Me(this),k.start();function H(V){if(Zt(V),!k.moved){var Q=V.clientX-N,it=V.clientY-$;k.moved=Q*Q+it*it>p}k.event(V).zoom("mouse",n(v(k.that.__zoom,k.mouse[0]=pt(V,w),k.mouse[1]),k.extent,o))}function Y(V){L.on("mousemove.zoom mouseup.zoom",null),qc(V.view,k.moved),Zt(V),k.event(V).end()}}function O(m,...T){if(e.apply(this,arguments)){var w=this.__zoom,k=pt(m.changedTouches?m.changedTouches[0]:m,this),L=w.invert(k),D=w.k*(m.shiftKey?.5:2),N=n(v(x(w,D),k,L),t.apply(this,T),o);Zt(m),a>0?q(this).transition().duration(a).call(b,N,k,m):q(this).call(_.transform,N,k,m)}}function A(m,...T){if(e.apply(this,arguments)){var w=m.touches,k=w.length,L=S(this,T,m.changedTouches.length===k).event(m),D,N,$,H;for(An(m),N=0;N<k;++N)$=w[N],H=pt($,this),H=[H,this.__zoom.invert(H),$.identifier],L.touch0?!L.touch1&&L.touch0[2]!==H[2]&&(L.touch1=H,L.taps=0):(L.touch0=H,D=!0,L.taps=1+!!l);l&&(l=clearTimeout(l)),D&&(L.taps<2&&(u=H[0],l=setTimeout(function(){l=null},g)),Me(this),L.start())}}function E(m,...T){if(this.__zooming){var w=S(this,T).event(m),k=m.changedTouches,L=k.length,D,N,$,H;for(Zt(m),D=0;D<L;++D)N=k[D],$=pt(N,this),w.touch0&&w.touch0[2]===N.identifier?w.touch0[0]=$:w.touch1&&w.touch1[2]===N.identifier&&(w.touch1[0]=$);if(N=w.that.__zoom,w.touch1){var Y=w.touch0[0],V=w.touch0[1],Q=w.touch1[0],it=w.touch1[1],X=(X=Q[0]-Y[0])*X+(X=Q[1]-Y[1])*X,rt=(rt=it[0]-V[0])*rt+(rt=it[1]-V[1])*rt;N=x(N,Math.sqrt(X/rt)),$=[(Y[0]+Q[0])/2,(Y[1]+Q[1])/2],H=[(V[0]+it[0])/2,(V[1]+it[1])/2]}else if(w.touch0)$=w.touch0[0],H=w.touch0[1];else return;w.zoom("touch",n(v(N,$,H),w.extent,o))}}function I(m,...T){if(this.__zooming){var w=S(this,T).event(m),k=m.changedTouches,L=k.length,D,N;for(An(m),f&&clearTimeout(f),f=setTimeout(function(){f=null},g),D=0;D<L;++D)N=k[D],w.touch0&&w.touch0[2]===N.identifier?delete w.touch0:w.touch1&&w.touch1[2]===N.identifier&&delete w.touch1;if(w.touch1&&!w.touch0&&(w.touch0=w.touch1,delete w.touch1),w.touch0)w.touch0[1]=this.__zoom.invert(w.touch0[0]);else if(w.end(),w.taps===2&&(N=pt(N,this),Math.hypot(u[0]-N[0],u[1]-N[1])<y)){var $=q(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return _.wheelDelta=function(m){return arguments.length?(i=typeof m=="function"?m:Ae(+m),_):i},_.filter=function(m){return arguments.length?(e=typeof m=="function"?m:Ae(!!m),_):e},_.touchable=function(m){return arguments.length?(r=typeof m=="function"?m:Ae(!!m),_):r},_.extent=function(m){return arguments.length?(t=typeof m=="function"?m:Ae([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),_):t},_.scaleExtent=function(m){return arguments.length?(s[0]=+m[0],s[1]=+m[1],_):[s[0],s[1]]},_.translateExtent=function(m){return arguments.length?(o[0][0]=+m[0][0],o[1][0]=+m[1][0],o[0][1]=+m[0][1],o[1][1]=+m[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(m){return arguments.length?(n=m,_):n},_.duration=function(m){return arguments.length?(a=+m,_):a},_.interpolate=function(m){return arguments.length?(c=m,_):c},_.on=function(){var m=h.on.apply(h,arguments);return m===h?_:m},_.clickDistance=function(m){return arguments.length?(p=(m=+m)*m,_):Math.sqrt(p)},_.tapDistance=function(m){return arguments.length?(y=+m,_):y},_}const gl=.1,pl=256;class fr{constructor(t,n,i={maxZoomLevel:pl,minZoomLevel:gl}){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.container=q(t),this.options=i,this.onRescale=n,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=Tt().domain(this.xBounds).range([0,1]),this.scaleY=Tt().domain(this.yBounds).range([0,1]),this.init()}get width(){return this.scaleX.range()[1]}get height(){return this.scaleY.range()[1]}get xSpan(){const{xBounds:t}=this;return Math.abs(t[1]-t[0])}get ySpan(){const{yBounds:t}=this;return Math.abs(t[1]-t[0])}get viewportRatio(){return this.width/(this.height||1)}get xRatio(){const t=this.scaleX.domain();return Math.abs(this.width/(t[1]-t[0]))}get yRatio(){const t=this.scaleY.domain();return Math.abs(this.height/(t[1]-t[0]))}get zFactor(){return this._zFactor}set zFactor(t){this._zFactor=t,this.recalculateZoomTransform()}get isXInverted(){return this.xBounds[1]<this.xBounds[0]}get isYInverted(){return this.yBounds[1]<this.yBounds[0]}get enableTranslateExtent(){return this._enableTranslateExtent}set enableTranslateExtent(t){this._enableTranslateExtent=t,this.updateTranslateExtent()}updateTranslateExtent(){const{width:t,xSpan:n,zFactor:i,enableTranslateExtent:r,translateBoundsX:s,translateBoundsY:o}=this;let a=-1/0,c=-1/0,h=1/0,l=1/0;if(r){const u=t/n;a=s[0]*u,h=s[1]*u,c=o[0]*u*i,l=o[1]*u*i}this.zoom.translateExtent([[a,c],[h,l]])}currentStateAsEvent(){const{scaleX:t,scaleY:n,xBounds:i,yBounds:r,zFactor:s,viewportRatio:o,currentTransform:a,xRatio:c,yRatio:h,width:l,height:u}=this;return{xScale:t.copy(),yScale:n.copy(),xBounds:i,yBounds:r,zFactor:s,viewportRatio:o,xRatio:c,yRatio:h,width:l,height:u,transform:Object.assign({},a)}}rescale(){const{currentStateAsEvent:t}=this;this.onRescale(t())}init(){this.zoom=dl().scaleExtent([this.options.minZoomLevel,this.options.maxZoomLevel]).on("zoom",this.onZoom),this.container.call(this.zoom)}onZoom(t){const{transform:n}=t;n&&(this.applyTransform(n),this.rescale())}applyTransform(t){const{width:n,scaleX:i,scaleY:r,xSpan:s,xBounds:o,yBounds:a,zFactor:c}=this,{viewportRatio:h,isXInverted:l,isYInverted:u}=this,f=n*t.k,g=s/f,d=s/t.k,p=d/c/h,y=g*t.x,_=g/c*t.y,x=o[0]-(l?-y:y),v=a[0]-(u?-_:_);i.domain([x,x+(l?-d:d)]),r.domain([v,v+(u?-p:p)]),this.currentTransform=t}setViewport(t,n,i,r){const{zoom:s,container:o,calculateTransform:a,scaleX:c,scaleY:h,isXInverted:l}=this;if(isNaN(t)||isNaN(i)){const p=c.domain(),y=p[1]-p[0];isNaN(t)&&(t=p[0]+y/2||0),isNaN(i)&&(i=Math.abs(y)||1)}if(isNaN(n)){const p=h.domain();n=p[0]+(p[1]-p[0])/2||0}const u=l?-i:i,f=t-u/2,g=f+u,d=a(f,g,n);Number.isFinite(r)&&r>0?s.transform(o.transition().duration(r),d):s.transform(o,d)}setBounds(t,n){this.xBounds=t,this.yBounds=n,this.recalculateZoomTransform()}setTranslateBounds(t,n){this.translateBoundsX=t,this.translateBoundsY=n,this.updateTranslateExtent()}adjustToSize(t,n,i=!1){const{width:r,height:s,scaleX:o,scaleY:a,recalculateZoomTransform:c}=this;let h=0,l=0;if(typeof t>"u"||typeof t=="boolean"){const{width:g,height:d}=this.container.node().getBoundingClientRect();h=g,l=d}else h=t,l=n;const u=Math.max(1,h),f=Math.max(1,l);!i&&r===u&&s===f||(o.range([0,u]),a.range([0,f]),c(),this.onRescale(this.currentStateAsEvent()))}calculateTransform(t,n,i){const{scaleX:r,xSpan:s,xBounds:o,yBounds:a,zFactor:c,viewportRatio:h,isXInverted:l,isYInverted:u}=this,[f,g]=r.range(),d=Math.abs(n-t),p=s/d,y=d/(g-f),_=i-(u?-d:d)/c/h/2,x=(o[0]-t)/(l?-y:y),v=(a[0]-_)/((u?-y:y)/c);return Mn.translate(x,v).scale(p)}recalculateZoomTransform(){const{scaleX:t,scaleY:n,container:i,calculateTransform:r,updateTranslateExtent:s}=this,[o,a]=t.domain(),[c,h]=n.domain(),l=c+(h-c)/2,u=r(o,a,l);s(),this.zoom.transform(i,u)}setZoomLevelBoundary(t){return this.zoom.scaleExtent(t),this}setMaxZoomLevel(t){const n=this.zoom.scaleExtent();return this.zoom.scaleExtent([n[0],t]),this}setMinZoomLevel(t){const n=this.zoom.scaleExtent();return this.zoom.scaleExtent([t,n[1]]),this}}const ml={order:1,layerOpacity:1,interactive:!1};class Kt{constructor(t,n){this._referenceSystem=null,this._interactive=!1,this._id=t||`layer-${Math.floor(Math.random()*1e3)}`;const i=n||ml;this._order=i.order||1,this._options={...i},this.loading=!1,this._element=null,this._opacity=i.layerOpacity||1,this._visible=!0,this._interactive=i.interactive||!1,n&&n.data&&this.setData(n.data),this._referenceSystem=n&&n.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)}get id(){return this._id}get element(){return this._element}get options(){return this._options}set options(t){this._options=t}set isLoading(t){this.loading=t}get isLoading(){return this.loading}set opacity(t){this._opacity=t,this.onOpacityChanged(t)}get opacity(){return this._opacity}set order(t){this._order=t,this.onOrderChanged(t)}get order(){return this._order}set interactive(t){this._interactive=t,this.onInteractivityChanged(t)}get interactive(){return this._interactive}get referenceSystem(){return this._referenceSystem}set referenceSystem(t){this._referenceSystem=t}get data(){return this.getData()}set data(t){this.setData(t)}get isVisible(){return this._visible}getData(){return this._data}setData(t){this._data=t,this.element&&this.onUpdate({data:t})}clearData(t=!0){this._data=null,t&&(this.referenceSystem=null),this.onUpdate({})}setVisibility(t,n){this._visible=t}onMount(t){this._element=t.elm,this._options.onMount&&this._options.onMount(t,this)}onUnmount(t){this._options.onUnmount&&this._options.onUnmount(t,this)}onResize(t){this._options.onResize&&this._options.onResize(t,this)}onUpdate(t){t.data&&(this._data=t.data),this._options.onUpdate&&this._options.onUpdate(t,this)}onRescale(t){this.optionsRescale(t)}optionsRescale(t){this._options.onRescale&&this._options.onRescale(t,this)}getInternalLayerIds(){return[]}}const Pe=200,Ce=300,dr=40,gr=30,yl=100,_l=.6,xl=.3,vl=8,wl=16,mt=64,pr=1;class yt extends Kt{onOpacityChanged(t){this.canvas&&this.updateStyle()}onOrderChanged(t){this.canvas&&this.updateStyle()}onInteractivityChanged(t){this.canvas&&this.updateStyle()}setVisibility(t){super.setVisibility(t),this.canvas&&this.updateStyle(t)}updateStyle(t){const i=t||this.isVisible?"visible":"hidden",r=this.interactive?"auto":"none";this.canvas.setAttribute("style",`position:absolute;pointer-events:${r};z-index:${this.order};opacity:${this.opacity};visibility:${i}`)}onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Pe,r=t.height||parseInt(n.getAttribute("height"),10)||Ce;this.elm=n;let s;this.canvas||(s=document.createElement("canvas"),this.canvas=s,t.elm.appendChild(s)),this.canvas.setAttribute("id",`${this.id}`),this.canvas.setAttribute("width",`${i}px`),this.canvas.setAttribute("height",`${r}px`),this.canvas.setAttribute("class","canvas-layer"),this.updateStyle(),this.ctx=this.canvas.getContext("2d")}onUnmount(){super.onUnmount(),this.canvas.remove(),this.canvas=null}onResize(t){const{ctx:n}=this,{width:i,height:r}=t;n.canvas.setAttribute("width",`${i}px`),n.canvas.setAttribute("height",`${r}px`)}onUpdate(t){super.onUpdate(t)}resetTransform(){this.ctx.resetTransform()}setTransform(t){this.resetTransform();const n=t.xBounds[0]>t.xBounds[1],i=t.yBounds[0]>t.yBounds[1];this.ctx.translate(t.xScale(0),t.yScale(0)),this.ctx.scale(t.xRatio*(n?-1:1),t.yRatio*(i?-1:1))}clearCanvas(){const{ctx:t,canvas:n}=this;t.save(),t.resetTransform(),t.clearRect(0,0,n.width,n.height),t.restore()}}class bl extends Kt{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Pe,r=t.height||parseInt(n.getAttribute("height"),10)||Ce;this.elm||(this.elm=q(n).append("div"),this.elm.attr("id",`${this.id}`),this.elm.attr("class","html-layer"));const s=this.interactive?"auto":"none";this.elm.style("position","absolute").style("height",`${r}px`).style("width",`${i}px`).style("opacity",this.opacity).style("overflow","hidden").style("pointer-events",s).style("z-index",this.order)}onUnmount(){super.onUnmount(),this.elm.remove(),this.elm=null}onResize(t){this.elm&&(super.onResize(t),this.elm.style("height",`${t.height}px`).style("width",`${t.width}px`))}setVisibility(t){super.setVisibility(t),this.elm&&this.elm.attr("visibility",t?"visible":"hidden")}onOpacityChanged(t){this.elm&&this.elm.style("opacity",t)}onOrderChanged(t){this.elm&&this.elm.style("z-index",t)}onInteractivityChanged(t){if(this.elm){const n=t?"auto":"none";this.elm.style("pointer-events",n)}}}class mr extends Kt{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Pe,r=t.height||parseInt(n.getAttribute("height"),10)||Ce;this.elm||(this.elm=q(n).append("svg"),this.elm.attr("id",`${this.id}`),this.elm.attr("class","svg-layer")),this.elm.attr("height",r).attr("width",i);const s=this.interactive?"auto":"none";this.elm.style("position","absolute").style("pointer-events",s).style("opacity",this.opacity).style("z-index",this.order)}onUnmount(){super.onUnmount(),this.elm.remove(),this.elm=null}onResize(t){this.elm&&(super.onResize(t),this.elm.attr("height",t.height).attr("width",t.width))}setVisibility(t){super.setVisibility(t),this.elm&&this.elm.attr("visibility",t?"visible":"hidden")}onOpacityChanged(t){this.elm&&this.elm.style("opacity",t)}onOrderChanged(t){this.elm&&this.elm.style("z-index",t)}onInteractivityChanged(t){if(this.elm){const n=t?"auto":"none";this.elm.style("pointer-events",n)}}}class Sl{constructor(t){const n={width:Pe,height:Ce,antialias:!0,backgroundAlpha:0,clearBeforeRender:!0,preserveDrawingBuffer:!0,...t};this.renderer=z.autoDetectRenderer(n),this.stage=new z.Container}destroy(){var i,r;this.stage.destroy({children:!0,texture:!0,baseTexture:!0}),this.stage=null;const t=this.renderer.type,n=this.renderer instanceof z.Renderer?(i=this.renderer)==null?void 0:i.gl:void 0;t===z.RENDERER_TYPE.WEBGL&&n&&((r=n==null?void 0:n.getExtension("WEBGL_lose_context"))==null||r.loseContext()),this.renderer.destroy(!0),this.renderer=null}get view(){return this.renderer.view}render(){this.renderer.render(this.stage)}}class Pn extends Kt{constructor(t,n,i){super(n,i),this.ctx=t,this.container=new z.Container,this.ctx.stage.addChild(this.container)}render(){this.ctx.render()}addChild(t){this.container.addChild(t)}clearLayer(){this.container.removeChildren().forEach(n=>{n.destroy()})}onMount(t){super.onMount(t),this.pixiViewContainer=this.element.querySelector("#webgl-layer"),this.pixiViewContainer||(this.pixiViewContainer=document.createElement("div"),this.pixiViewContainer.setAttribute("id",`${this.id}`),this.pixiViewContainer.setAttribute("class","webgl-layer"),this.pixiViewContainer.appendChild(this.ctx.view),this.element.appendChild(this.pixiViewContainer),this.updateStyle())}onUnmount(t){super.onUnmount(t),this.clearLayer(),this.ctx.stage.removeChild(this.container),this.container.destroy(),this.pixiViewContainer.remove(),this.pixiViewContainer=void 0}onResize(t){super.onResize(t),this.ctx.renderer.resize(t.width,t.height)}onRescale(t){super.onRescale(t);const n=t.xBounds[0]>t.xBounds[1],i=t.yBounds[0]>t.yBounds[1];this.setContainerPosition(t.xScale(0),t.yScale(0)),this.setContainerScale(t.xRatio*(n?-1:1),t.yRatio*(i?-1:1))}setContainerPosition(t,n){this.container.position.set(t,n)}setContainerScale(t,n){this.container.scale.set(t,n)}updateStyle(t){const n=t||this.isVisible,i=this.interactive?"auto":"none";this.container.visible=n;const r=[["position","absolute"],["pointer-events",`${i}`],["z-index",`${this.order}`],["opacity",`${this.opacity}`]].map(s=>s.join(":")).join(";");this.pixiViewContainer.setAttribute("style",r)}setVisibility(t,n){super.setVisibility(t,n),this.pixiViewContainer&&this.updateStyle(t)}onOpacityChanged(t){this.pixiViewContainer&&this.updateStyle()}onOrderChanged(t){this.pixiViewContainer&&this.updateStyle()}onInteractivityChanged(t){this.pixiViewContainer&&this.updateStyle()}renderType(){return this.ctx.renderer.type}}function Qt(e){throw new Error(`Unexpected object: ${JSON.stringify(e)}`)}const yr=e=>e.kind==="pAndASymbol",_r=e=>e.kind==="cementSqueeze",xr=e=>e.kind==="cementPlug",vr=(e,t,n)=>i=>{switch(i.kind){case"screen":return e(i);case"tubing":return t(i);case"completionSymbol":return n(i);default:return Qt(i)}},Z=(e,t)=>{switch(t){case"Perforation":return e.Perforation(t);case"Open hole gravel pack":return e.OpenHoleGravelPack(t);case"Open hole frac pack":return e.OpenHoleFracPack(t);case"Cased hole fracturation":return e.CasedHoleFracturation(t);case"Cased hole frac pack":return e.CasedHoleFracPack(t);case"Cased hole gravel pack":return e.CasedHoleGravelPack(t);default:return Qt(t)}},Tl=e=>Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind),Ml=e=>Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind),wr=e=>Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind);function br(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function Sr(e){return Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function Tr(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!1},e.subKind)}function Al(e){return Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function Mr(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function Pl(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}const Cn=(e,t)=>e.start<t.end&&e.end>t.start,Ar=e=>({holeLayerId:`${e}-hole`,casingLayerId:`${e}-casing`,completionLayerId:`${e}-completion`,cementLayerId:`${e}-cement`,pAndALayerId:`${e}-pAndA`,perforationLayerId:`${e}-perforation`}),Pr={firstColor:"#8c541d",secondColor:"#eee3d8",lineColor:"#8b4513"},Cr={solidColor:"#dcdcdc",lineColor:"#575757",shoeSize:{width:vl,length:wl},windowOptions:{dashColor:"#dc0000",dashLength:5,spaceLength:3}},Lr={stroke:"rgba(0, 0, 0, 0.25)",yellow:"#FFFC00",grey:"gray",red:"#FF5050",outline:"black",transparent:"rgba(255, 255, 255, 0)",spikeWidth:50,spikeLength:50,packingOpacity:.5,fracLineCurve:10,fracLineLength:25,scalingFactor:25},kr={firstColor:"#c7b9ab",secondColor:"#5b5b5b",scalingFactor:4},Er={firstColor:"#8b6713",secondColor:"#000000",scalingFactor:4},Rr={scalingFactor:4,lineColor:"#63666a"},Fr={scalingFactor:1,innerColor:"#eeeeff",outerColor:"#777788"},zr={firstColor:"#c7b9ab",secondColor:"#000000",scalingFactor:4},Dr=4,Or=2;function Nr(e){const[t]=e.domain();return Math.abs(e(t+1))}function Le(e,t,n,i){return gt(Nr(i)*e,t,n)}function Cl(e,t){const n=e.x+e.width,i=t.x+t.width;return!(t.x>n||i<e.x)}function $r(e,t,n=Dr,i=Or){const r=e.x+e.width+n,s=t.x+t.width+n,o=e.y+e.height+i,a=t.y+t.height+i;return!(t.x-n>r||t.y-i>o||s+n<e.x||a+i<e.y)}function Ll(e,t){const n=e.x+e.width,i=t.x+t.width,r=e.y+e.height,s=t.y+t.height;if(t.x>n||t.y>r||i<e.x||s<e.y)return null;const o=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),a=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return{dx:o,dy:a}}function Ln(e,t,n=Dr,i=Or){const r=e.x+e.width,s=t.x+t.width,o=e.y+e.height,a=t.y+t.height;if(t.x-n>r||t.y-i>o||s+n<e.x||a+i<e.y)return null;const c=e.x+e.width-t.x+n,h=e.y+e.height-t.y+i;return{dx:c,dy:h}}const kl=7,El=11,Rl=7,Fl=20,zl=120,Dl=19,nt={topleft:"topleft",topright:"topright",bottomleft:"bottomleft",bottomright:"bottomright"};class Ol extends yt{constructor(t,n){super(t,n),this.groupFilter=null,this.renderAnnotation=(i,r,s,o,a,c)=>{this.renderText(i,s,o-a,a,c,"arial","bold"),this.renderText(r,s,o,a,c)},this.renderLine=(i,r,s,o,a,c,h=!0)=>{const{ctx:l}=this,u=h?i:i+s,f=h?i+s:i,g=r+2;l.strokeStyle=c,l.lineWidth=1,l.beginPath(),l.moveTo(o,a),l.lineTo(u,g),l.lineTo(f,g),l.stroke()},this.minFontSize=n.minFontSize||kl,this.maxFontSize=n.maxFontSize||El,this.fontSizeFactor=n.fontSizeFactor||Rl,this.offsetMin=n.offsetMin||Fl,this.offsetMax=n.offsetMax||zl,this.offsetFactor=n.offsetFactor||Dl}setGroupFilter(t){this.groupFilter=t,this.callouts=void 0,this.render()}onUpdate(t){super.onUpdate(t),this.callouts=void 0,this.render()}onRescale(t){super.onRescale(t);const n=this.rescaleEvent&&this.rescaleEvent.xRatio===t.xRatio;this.rescaleEvent=t,this.render(n)}render(t=!1){requestAnimationFrame(()=>{if(this.clearCanvas(),!this.data||!this.rescaleEvent||!this.referenceSystem)return;const{xScale:n,yScale:i,xBounds:r}=this.rescaleEvent,s=Le(this.fontSizeFactor,this.minFontSize,this.maxFontSize,n);if(!t||!this.callouts){const{data:o,ctx:a,groupFilter:c}=this,{calculateDisplacementFromBottom:h}=this.referenceSystem.options,l=h?r[0]<r[1]:r[0]>r[1],u=0;a.font=`bold ${s}px arial`;const f=o.filter(d=>!c||c.includes(d.group)),g=Le(this.offsetFactor,this.offsetMin,this.offsetMax,n);this.callouts=this.positionCallouts(f,l,n,i,u,s,g)}this.callouts.forEach(o=>{const{pos:a,title:c,color:h}=o,l=n(a.x),u=i(a.y),f={x:l,y:u,width:o.boundingBox.width,height:s,offsetX:o.dx,offsetY:o.dy};this.renderCallout(c,o.label,f,h,o.alignment)})})}renderText(t,n,i,r,s,o="arial",a="normal"){const{ctx:c}=this;c.font=`${a} ${r}px ${o}`,c.fillStyle=s,c.fillText(t,n,i)}renderPoint(t,n,i=3){const{ctx:r}=this;r.beginPath(),r.moveTo(t,n),r.arc(t,n,i,0,Math.PI*2),r.fill()}renderCallout(t,n,i,r,s){const o=this.getPosition(i,s),{x:a,y:c}=o,{height:h,width:l,x:u,y:f}=i,g=s===nt.topright||s===nt.bottomright;this.renderAnnotation(t,n,a,c,h,r),this.renderPoint(u,f),this.renderLine(a,c,l,u,f,r,g)}getPosition(t,n){const{x:i,y:r,offsetX:s,offsetY:o,width:a}=t;switch(n){case nt.topleft:return{x:i-a-s,y:r-o};case nt.topright:return{x:i+s,y:r-o};case nt.bottomleft:return{x:i-a-s,y:r+o};case nt.bottomright:return{x:i+s,y:r+o};default:return{x:i,y:r}}}positionCallouts(t,n,i,r,s,o,a=20){if(t.length===0)return[];const c=n?nt.topleft:nt.topright,h=t.map(f=>{const g=f.pos?f.pos:this.referenceSystem.project(f.md);return{title:f.title,label:f.label,color:f.color,pos:{x:g[0],y:g[1]},group:f.group,alignment:c,boundingBox:this.getAnnotationBoundingBox(f.title,f.label,g,i,r,o),dx:a,dy:a}}),l=[h[h.length-1]],u=[];return this.chooseTopOrBottomPosition(h,u,l),this.adjustTopPositions(l),this.adjustBottomPositions(u),h}getAnnotationBoundingBox(t,n,i,r,s,o){const{ctx:a}=this,c=r(i[0]),h=s(i[1]),l=a.measureText(n).width,u=a.measureText(t).width,f=Math.max(l,u);return{x:c,y:h,width:f,height:o*2+4}}chooseTopOrBottomPosition(t,n,i){for(let r=t.length-2;r>=0;--r){const s=t[r],o=i[0];$r(s.boundingBox,o.boundingBox)?(s.alignment=s.alignment===nt.topleft?nt.bottomright:nt.bottomleft,n.push(s),r>0&&i.unshift(t[--r])):i.unshift(s)}}adjustTopPositions(t){for(let n=t.length-2;n>=0;--n){const i=t[n];for(let r=t.length-1;r>n;--r){const s=t[r],o=Ln(i.boundingBox,s.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y-=o.dy)}}}adjustBottomPositions(t){for(let n=t.length-2;n>=0;--n){const i=t[n];for(let r=t.length-1;r>n;--r){const s=t[r],o=Ln(s.boundingBox,i.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y+=o.dy)}}}}const Nl=16,$l=6;function dt(e){const n=ht(e).formatHex();return parseInt(n.replace("#","0x"))}function Bl(e){return typeof e=="string"?e:`#${e.toString(Nl).padStart($l,"0")}`}const Il=1e4;class Hl extends yt{constructor(t,n){super(t,n),this.surfaceAreasPaths=[],this.surfaceLinesPaths=[],this.maxDepth=Il,this.drawPolygonPath=(i,r)=>{const{ctx:s}=this;s.fillStyle=i,s.fill(r)},this.drawLinePath=(i,r)=>{const{ctx:s}=this;s.strokeStyle=i,s.stroke(r)},this.createPolygons=i=>{const r=[];let s=null;for(let o=0;o<i.length;o++){const a=!!i[o][1];a&&(s===null&&(s=[]),s.push(i[o][0],i[o][1]));const c=o===i.length-1;if((!a||c)&&s){for(let h=a?o:o-1;h>=0&&i[h][1];h--)s.push(i[h][0],i[h][2]||this.maxDepth);r.push(s),s=null}}return r},this.generatePolygonPath=i=>{const r=new Path2D;r.moveTo(i[0],i[1]);for(let s=2;s<i.length;s+=2)r.lineTo(i[s],i[s+1]);return r.closePath(),r},this.generateLinePaths=i=>{const r=[],{data:s}=i;let o=!1,a=null;for(let c=0;c<s.length;c++)s[c][1]?o?a.lineTo(s[c][0],s[c][1]):(a=new Path2D,a.moveTo(s[c][0],s[c][1]),o=!0):o&&(r.push(a),o=!1);return o&&r.push(a),r},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)}onUpdate(t){super.onUpdate(t),this.updatePaths(),this.render()}onRescale(t){this.rescaleEvent=t,this.setTransform(this.rescaleEvent),this.render()}updatePaths(){this.data?(this.generateSurfaceAreasPaths(),this.generateSurfaceLinesPaths()):(this.surfaceAreasPaths=[],this.surfaceLinesPaths=[])}render(){!this.ctx||!this.rescaleEvent||requestAnimationFrame(()=>{this.clearCanvas(),this.surfaceAreasPaths.forEach(t=>this.drawPolygonPath(t.color,t.path)),this.surfaceLinesPaths.forEach(t=>this.drawLinePath(t.color,t.path))})}colorToCSSColor(t){return Bl(t)}generateSurfaceAreasPaths(){this.surfaceAreasPaths=this.data.areas.reduce((t,n)=>{const r=this.createPolygons(n.data).map(s=>({color:this.colorToCSSColor(n.color),path:this.generatePolygonPath(s)}));return t.push(...r),t},[])}generateSurfaceLinesPaths(){this.surfaceLinesPaths=this.data.lines.reduce((t,n)=>{const r=this.generateLinePaths(n).map(s=>({color:this.colorToCSSColor(n.color),path:s}));return t.push(...r),t},[])}}function kn(e,t){let n=0,i=e.length-1;const r=20;let s=e[n][0],o=e[i][0];for(;i-n>r;){const c=Math.floor((i+n)/2),h=e[c][0];if(t>=s&&t<h)i=c,o=e[i][0];else if(t>=h&&t<=o)n=c,s=e[n][0];else if(t<=s&&t>h)i=c,o=e[i][0];else if(t<=h&&t>=o)n=c,s=e[n][0];else return-1}let a=-1;for(let c=n;c<i;c++){const h=e[c][0],l=e[c+1][0];if(Math.min(h,l)<=t&&t<=Math.max(h,l)){a=c;break}}return a}function _t(e,t,n=null,i=null){let r=null;const s=kn(e,t);if(s!==-1){const o=e[s][1],a=e[s+1][1];if(a&&a){const c=e[s][0],l=e[s+1][0]-c,f=(t-c)/l;r=o*(1-f)+a*f,n&&n>r&&(r=n),i&&i<r&&(r=i)}}return r}const En=(e,t)=>({title:e.pickIdentifier||e.identifier,group:t,label:`${e.md} ${e.mdUnit} ${e.depthReferencePoint}`,color:t==="strat-picks"?"#227":"rgba(0,0,0,0.8)",md:e.md});function Vl(e){return e?e.map(t=>En(t,"ref-picks")):[]}function Ul(e){return e?e.filter(t=>t.entryPick.md===t.from).map(t=>En(t.entryPick,"strat-picks")):[]}function Wl(e){return e?e.filter(t=>e.findIndex(n=>Math.abs(n.entryPick.md-t.exitPick.md)<.5)===-1).map(t=>En(t.exitPick,"strat-picks")).filter((t,n,i)=>n===i.findIndex(r=>r.title===t.title&&r.md===t.md)):[]}const Yl=e=>[...Vl(e.nonUnitPicks),...Ul(e.unitPicks),...Wl(e.unitPicks)].sort((t,n)=>t.md-n.md),Gl=e=>({unitName:e.identifier,topSurface:e.top,baseSurface:e.base,ageBase:e.baseAge,ageTop:e.topAge,color:{r:e.colorR===null?255:e.colorR,g:e.colorG===null?255:e.colorG,b:e.colorB===null?255:e.colorB},level:e.stratUnitLevel,lithType:e.lithologyType,parent:e.stratUnitParent});function Xl(e,t,n){if(n.length===0)return[[e,t]];const i=[];let r=e,s=0;for(;r<t&&s<n.length;){const o=n[s];o.from>r&&i.push([r,Math.min(o.from,t)]),r=Math.min(t,Math.max(e,o.to)),s+=1}return r<t&&i.push([r,t]),i}const jl=e=>e.map(Gl);function ql(e,t){const n=jl(t),i=[],r=[];return e.forEach(s=>{const o=n.filter(a=>s.pickIdentifier.search(new RegExp(`(${a.topSurface}|${a.baseSurface})`,"i"))!==-1);o.length>0?o.forEach(a=>r.push({md:s.md,tvd:s.tvd,identifier:s.pickIdentifier,confidence:s.confidence,mdUnit:s.mdUnit,depthReferencePoint:s.depthReferencePoint,...a})):i.push({identifier:s.pickIdentifier,...s})}),{joined:r,nonUnitPicks:i}}function Zl(e){const t=[];let n=null;const i=e.filter(r=>r.level).sort((r,s)=>r.unitName.localeCompare(s.unitName)||r.md-s.md||r.ageTop-s.ageTop);for(;i.length>0;){n=i.shift();const r=n.identifier;let s;const o=r===n.topSurface,a=r===n.baseSurface;if(o)s=n.baseSurface;else if(a)s=n.topSurface;else{console.warn(`Unable to match ${r} with top or base surface, ignored`);continue}let c,h;const l=i.find(u=>u.identifier===s);if(l)c=o?n:l,h=o?l:n,c.md>h.md&&([c,h]=[h,c]),i.splice(i.indexOf(l),1);else if(console.warn(`Unable to find ${s} pick for ${r}`),o)if(c=n,h=e.filter(u=>u.level).sort((u,f)=>u.md-f.md).find(u=>u.md>c.md),h)console.warn(`Using ${h.identifier} as base for ${r}`);else{console.warn(`Unable to find a base pick for ${r} pick at ${c.md}, ignored`);continue}else if(a)if(h=n,c=e.filter(u=>u.level).sort((u,f)=>f.md-u.md).find(u=>u.md<h.md),c)console.warn(`Using ${c.identifier} as top for ${r}`);else{console.warn(`Unable to find a top pick for ${r} pick at ${h.md}, ignored`);continue}else{console.warn(`${r} ignored`);continue}t.push({name:c.unitName,mdEntry:c.md,tvdEntry:c.tvd,color:c.color,level:c.level,entryPick:c,mdExit:h.md,tvdExit:h.tvd,exitPick:h,confidenceEntry:c.confidence,confidenceExit:h.confidence})}return t}function Kl(e,t){const{joined:n,nonUnitPicks:i}=ql(e,t),s=Zl(n).filter(a=>a.mdEntry<a.mdExit).sort((a,c)=>a.mdEntry-c.mdEntry||a.level-c.level).reverse(),o=[];for(;s.length>0;){const a=s.pop(),c=[];for(;s.length>0&&s[s.length-1].level>a.level;)c.push(s.pop());c.reverse(),c.push(a);const h=[];c.forEach(l=>{const u=Xl(l.mdEntry,l.mdExit,h);h.push(...u.map(f=>({from:f[0],to:f[1],itm:l})))}),h.sort((l,u)=>l.from-u.from),o.push(...h.map(l=>({from:l.from,to:l.to,...l.itm})))}return{unitPicks:o,nonUnitPicks:i}}function Ql(e,t){const n=e.map((s,o)=>o*t/e.length),i=Tt().domain(n).range(e);return Array.from(new Array(t).keys()).map(s=>{const o=ht(i(s)).rgb();return[o.r,o.g,o.b]})}const Jl=e=>e?{x:e.minX,y:e.minTvdMsl,width:e.maxX-e.minX,height:e.maxTvdMsl-e.minTvdMsl}:{x:0,y:0,width:0,height:0};function tu(e,t){if(!(e&&e.datapoints))return null;const n=t.reduce((g,d)=>Math.min(g,d[0]),0),i=t.reduce((g,d)=>Math.max(g,d[0]),0),r=e.yAxisValues&&e.yAxisValues[0],s=e.yAxisValues&&e.yAxisValues[e.yAxisValues.length-1],o=e.datapoints||[],a=-o.reduce((g,d)=>Math.min(...d,g),0),c=o.reduce((g,d)=>Math.max(...d,g),0),h=Math.max(Math.abs(a),Math.abs(c)),l=-h,u=h;return{minX:n,maxX:i,minTvdMsl:r,maxTvdMsl:s,domain:{min:l,max:u,difference:u-l}}}async function eu(e,t,n,i){if(!(e&&e.datapoints&&e.datapoints.length>0))return;const{datapoints:r}=e,s=(i==null?void 0:i.seismicMin)||(i==null?void 0:i.seismicRange)||r.reduce((m,T)=>Math.min(...T,m),0),o=(i==null?void 0:i.seismicMax)||(i==null?void 0:i.seismicRange)||r.reduce((m,T)=>Math.max(...T,m),0),a=Math.max(Math.abs(s),Math.abs(o)),c=-a,h=a,l={min:c,max:h,difference:h-c},u=t[0][0]-t[t.length-1][0],f=Math.abs(Math.floor(u/5)),g=e.yAxisValues.length,d=1e3,p=Ql(n,d),y=new Uint8ClampedArray(f*g*4);let _=0;const x=(d-1)/l.difference;let v=i!=null&&i.isLeftToRight?t[0][0]:t[t.length-1][0];const C=u/f*(i!=null&&i.isLeftToRight?-1:1);let b,S,M,R,F;const O=[0,0,0];let A;for(let m=0;m<f;m++){_=m*4;const T=kn(t,v),w=t[T][0],L=t[T+1][0]-w,N=(v-w)/L;for(let $=0;$<g;$++)b=r[$][T],S=r[$][T+1],b==null||S==null?(F=O,A=0):(M=b*(1-N)+S*N,R=(M-l.min)*x,R=gt(~~R,0,d-1),F=p[R],A=255),y.set([F[0],F[1],F[2],A],_),_+=f*4;v+=C}const E=new ImageData(y,f,g);return await createImageBitmap(E,0,0,f,g)}const nu=2147483648,iu=4294967295;function ru(e,t,n){const i=n.filter(g=>g.data.values),r=lu(i),s=new Map,o=cu(r,t,s);hu(o);const a=su(r,e),c=pu(e,o,t),h=au(s,c),u=[...ou(h,e),...Object.values(c).flat().filter(g=>!g.exclude)];return{lines:a,areas:u}}function su(e,t){return e.filter(i=>i.visualization==="line").map(i=>({id:i.name,label:i.name,width:2,color:dt(i.color||"black"),data:t.map((r,s)=>[r[0],i.values[s]])}))}function ou(e,t){return e.map((i,r)=>{const s=r+1<e.length?e[r+1]:null;return{id:i.id,label:i.label,color:dt(i.color),data:t.map((o,a)=>[o[0],i.top[a],s?s.top[a]:null])}})}function au(e,t){return Array.from(e.values()).sort((i,r)=>i.age-r.age).filter(i=>{const r=t[i.name],s=r&&r.length>0;return s||console.warn(`Intersection surface group '${i.name}' has no valid entries and will be discarded.`),s}).map((i,r)=>{const o=t[i.name][0];return{id:i.name,label:i.name,color:fu(r),top:o.data.map(a=>a[1])}})}function cu(e,t,n){const i=t&&t.find(o=>o.stratUnitLevel===1),r=i?i.identifier:"SEABED";return e.filter(o=>o.visualization==="interval"||o.visualization==="none").map(o=>{const a=[],c=Br(t,o.name,a);c||console.warn(`No match for ${o.name} in strat column`);const h=a[0]||c,l=h&&h.identifier||r;return h&&!n.has(l)&&n.set(l,{age:h.topAge,name:h.identifier}),{...o,unit:c,group:l}})}function hu(e){e.sort((t,n)=>{if(!t.unit&&!n.unit)return 0;if(!t.unit)return-1;if(!n.unit)return 1;const i=t.isBase?t.unit.baseAge:t.unit.topAge,r=n.isBase?n.unit.baseAge:n.unit.topAge;return i!==r?i-r:t.isBase&&!n.isBase?1:!t.isBase&&n.isBase?-1:t.unit.stratUnitLevel-n.unit.stratUnitLevel})}function Br(e,t,n=[]){const i=e.find(r=>r.identifier.toLowerCase()===t.toLowerCase());if(i){let r=i;do n.unshift(r),r=e.find(s=>s.identifier===r.stratUnitParent);while(r);return i}return null}function lu(e){return e.map(t=>{const n=t.visualSettings.displayName,i=n.replace(/\s(Base|Top)/gi,""),r=n.toLowerCase().endsWith("base");return{name:i,isBase:r,values:t.data.values,color:t.visualSettings.colors.crossSection,visualization:t.visualSettings.crossSection.toLowerCase()}})}function uu(e){return e.colorR===null||e.colorG===null||e.colorB===null?nu:e.colorR<<16|e.colorG<<8|e.colorB}const fu=ei().domain([0,100]).range(mo(It("#e6f1cf","#85906d"),10));function du(e,t,n,i){const r=t+1;if(!n||r>=n.length)return null;const s=n.findIndex(o=>o.isBase&&o.name===e.name);if(s!==-1)return s;for(let o=r;o<n.length;o++){const a=n[o];if(!a.isBase||gu(e,a,i))return o}return null}function gu(e,t,n){const i=[];return Br(n,e.name,i),i.some(r=>t.name===r.identifier)}function pu(e,t,n){return t.reduce((r,s,o)=>{if(!s.isBase){r[s.group]||(r[s.group]=[]);const a=du(s,o,t,n);r[s.group].push({id:s.name,label:s.name,color:s.unit&&uu(s.unit)||iu,exclude:s.visualization==="none"||!s.unit,data:e.map((c,h)=>{const l=s.values[h]!==null?mu(a,t,h):null;return[c[0],s.values[h],l]})})}return r},{})}function mu(e,t,n){if(!t||!e||e>=t.length)return null;for(let i=e;i<t.length;i++)if(t[i].values[n]!==null)return t[i].values[n];return null}const Ir=.1,Rn=1e3,yu=150,_u=30,xu=10;function vu(e){if(!e||e.length===0)return[];const t=e?e.map(r=>[r.easting,r.northing,r.tvd,r.md]):[],n=Hr(Vr(t)),i=n[n.length-1][0];return n.forEach((r,s)=>{n[s][0]=i-r[0]}),n}function wu(e,t){if(!e||e.length===0)return[];const n=e?e.map(x=>[x.easting,x.northing,x.tvd,x.md]):[],i=new un(n,{tension:.75,arcDivisions:5e3}),r=i.length,s=Math.round(r*xu);let o=null;s>0?o=Hr(i.getPoints(s),5e-4,10):o=[[n[0][0],n[0][1]]];const a=o[0],c=o[o.length-1],h=B.distance(a,c);let l=null;if(h<yu){const v=t/180*Math.PI;l=new B(Math.cos(v),Math.sin(v)).mutable}else l=bu(o,_u);const u=Math.max(0,Rn-r),f=u+r,g=[];let d=[];const p=l.toArray();u>0&&(d=Ci(Math.ceil(u*Ir)).map(x=>l.set(p).scale(u*(1-x)).subFrom(a).toArray()),d.pop(),g.push(...d)),g.push(...o);const y=Ci(Math.ceil(Rn*Ir)).map(x=>l.set(p).scale(Rn*x).add(c).toArray()).splice(1);return g.push(...y),Vr(g,null,f)}function bu(e,t){const n=B.zero.mutable;let i=0;const r=B.zero.mutable;for(let s=0;s<e.length-1;s++){const o=e.length-1-s;if(r.set(e[o]).sub(e[o-1]),n.add(r),i=n.magnitude,i>t)break}return i===0?new B([0,0]):n.scale(1/i)}function Hr(e,t=.001,n=10){if(e.length<=4)return e;const[i,r]=e[0],s=e.map(l=>[l[0]-i,l[1]-r]);let[o,a]=s[0];const c=[e[0]];for(let l=1;l+1<s.length;l++){const[u,f]=s[l],[g,d]=s[l+1];if(g-u!==0||d-f!==0){const p=Math.abs(o*d-a*g+g*f-d*u+a*u-o*f)/Math.sqrt((g-o)**2+(d-a)**2),y=[o-u,a-f],_=Math.sqrt(y[0]**2+y[1]**2);(p>t||_>=n)&&(c.push([u+i,f+r]),[o,a]=[u,f])}}const h=s[s.length-1];return c.push([h[0]+i,h[1]+r]),c}function Vr(e,t=null,n=0){let i=t||e[0],r=0;return e.map(o=>{const a=o[0]-i[0],c=o[1]-i[1];return r+=Math.sqrt(a**2+c**2),i=o,[n>0?n-r:r,o[2]||0]})}const Su=18,Tu=8,Mu=13,Au="black",Pu="Arial",Cu=70;class Lu extends yt{constructor(t,n){super(t,n),this.defaultMargins=Su,this.defaultMinFontSize=Tu,this.defaultMaxFontSize=Mu,this.defaultTextColor=Au,this.defaultFont=Pu,this.isLabelsOnLeftSide=!0,this.maxFontSizeInWorldCoordinates=Cu,this.isXFlipped=!1,this.areasWithAvgTopDepth=null,this.drawAreaLabel=(i,r,s,o)=>{const{data:a}=i,{ctx:c,maxFontSizeInWorldCoordinates:h,isXFlipped:l}=this,{xScale:u,yScale:f,xRatio:g,yRatio:d,zFactor:p}=this.rescaleEvent;let y=this.checkDrawLabelsOnLeftSide();const x=(this.options.margins||this.defaultMargins)*(l?-1:1)/g,v=this.options.minFontSize||this.defaultMinFontSize;let b=(this.options.maxFontSize||this.defaultMaxFontSize)/d;b>h&&(b=h,b*d<v&&(b=v/d));const S=u.invert(u.range()[0])+x,M=u.invert(u.range()[1])-x,[R,F]=this.getSurfacesAreaEdges();c.save(),c.font=`${b*d}px ${this.options.font||this.defaultFont}`;let O=c.measureText(i.label),A=O.width/g;if(y){const U=S+(l?-A:A);(!l&&U>F||l&&U<F)&&(y=!1)}else{const U=M+(l?A:-A);(!l&&U<R||l&&U>R)&&(y=!0)}let E;const I=.07;y?E=l?Math.min(R,S):Math.max(R,S):E=l?Math.max(F,M):Math.min(F,M);const m=f.invert(f.range()[0]),T=f.invert(f.range()[1]),w=5,k=3,L=I*(A/k)*(y?1:-1)*(l?-1:1),D=A/w*(y?1:-1)*(l?-1:1),N=a.map(U=>[U[0],U[1]]),$=this.calcPos(N,E,k,L,m,T);if(!$)return;const H=a.map(U=>[U[0],U[2]]);let Y=this.calcPos(H,E,k,L,m,T,r?r.data.map(U=>[U[0],U[1]]):null,s,o);Y||(Y=new B($.x,T));const V=Y.y-$.y;if(V<b){if(V*d<v)return;b=V,c.font=`${b*d}px ${this.options.font||this.defaultFont}`,O=c.measureText(i.label),A=O.width/g}const Q=y!==l?B.right:B.left,it=this.calcAreaDir(N,H,E,w,D,Q,m,T,0,Math.PI/4,4,r?r.data.map(U=>[U[0],U[1]]):null,s,o),X=Math.atan(Math.tan(it)*p),rt=E,Jt=($.y+Y.y)/2,Vf=l?-X:X;c.textAlign=y?"left":"right",c.translate(u(rt),f(Jt)),c.rotate(Vf),c.fillStyle=this.options.textColor||this.defaultTextColor,c.font=`${b*d}px ${this.options.font||this.defaultFont}`,c.textBaseline="middle",c.fillText(i.label,0,0),c.restore()},this.drawLineLabel=i=>{const{ctx:r,isXFlipped:s}=this,{xScale:o,yScale:a,xRatio:c,yRatio:h,zFactor:l}=this.rescaleEvent,u=this.checkDrawLabelsOnLeftSide(),f=this.getMarginsInWorldCoordinates(),d=(this.options.maxFontSize||this.defaultMaxFontSize)/h;r.save(),r.font=`${d*h}px ${this.options.font||this.defaultFont}`;const y=r.measureText(i.label).width/c,_=o.invert(o.range()[0])+f,x=o.invert(o.range()[1])-f,[v,C]=this.getSurfacesAreaEdges();let b;const S=5;u?b=s?Math.max(C,x):Math.min(C,x):b=s?Math.min(v,_):Math.max(v,_);const M=y/S*(u?-1:1),{data:R}=i,F=this.calcPos(R,b,S,M),O=this.calcLineDir(R,b,S,M,l,u?B.left:B.right);if(!F||!O)return;const A=b,E=F.y-pr-d/2,I=B.angleRight(O)-(u?Math.PI:0);r.textAlign=u?"right":"left",r.translate(o(A),a(E)),r.rotate(I),r.fillStyle=this.colorToCSSColor(i.color),r.textBaseline="middle",r.fillText(i.label,0,0),r.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)}get options(){return this._options}setData(t){super.setData(t),this.areasWithAvgTopDepth=null}generateSurfacesWithAvgDepth(){const{areas:t}=this.data;this.areasWithAvgTopDepth=t.reduce((n,i)=>{if(!i.label)return n;const r=i.data.reduce((o,a)=>(a[1]!=null&&(o.sum+=a[1],o.count++),o),{sum:0,count:0});if(r.count===0)return n;const s=r.sum/r.count;return n.push({...i,avgTopDepth:s}),n},[])}onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.render()}onRescale(t){this.rescaleEvent=t,this.updateXFlipped(),this.resetTransform(),this.render()}render(){this.rescaleEvent&&requestAnimationFrame(()=>{this.clearCanvas(),this.data&&(this.areasWithAvgTopDepth||this.generateSurfacesWithAvgDepth(),this.drawAreaLabels(),this.drawLineLabels())})}drawAreaLabels(){this.areasWithAvgTopDepth.forEach((t,n,i)=>{const r=i.reduce((s,o,a)=>(a>n&&(s==null||o.avgTopDepth<s.avgTopDepth)&&(s=o),s),null);r&&this.drawAreaLabel(t,r,i,n)})}drawLineLabels(){this.data.lines.filter(t=>t.label).forEach(t=>this.drawLineLabel(t))}colorToCSSColor(t){if(typeof t=="string")return t;let n=t.toString(16);return n="000000".substr(0,6-n.length)+n,`#${n}`}calcPos(t,n,i,r,s=null,o=null,a=null,c=null,h=null){const l=B.zero.mutable;let u=0;for(let f=0;f<i;f++){const g=n+f*r,d=_t(t,g,s,o);if(d){const p=this.getAlternativeYValueIfAvailable(g,s,o,a,c,h),y=p?Math.min(d,p):d;l.add(g,y),u++}}return u===0?null:B.divide(l,u)}getAlternativeYValueIfAvailable(t,n,i,r,s,o){if(!r)return null;let a=_t(r,t,n,i);if(a==null&&s&&o!=null){let c=o+1;for(;a==null&&c<s.length;){const h=s[c++];a=_t(h.data.map(l=>[l[0],l[1]]),t,n,i)}}return a}calcLineDir(t,n,i,r,s,o=B.left,a=null,c=null){const h=o.mutable,l=_t(t,n,a,c);if(l===null)return h;const u=new B(n,l*s),f=B.zero.mutable;for(let g=1;g<=i;g++){const d=n+g*r,p=_t(t,n,a,c);p!==null&&(f.set(d,p*s),f.sub(u),h.add(f))}return h}calcAreaDir(t,n,i,r,s,o=B.left,a=null,c=null,h=0,l=Math.PI/4,u=4,f=null,g=null,d=null){const p=[],y=B.zero.mutable;let _;for(let M=0;M<=r;M++){const R=i+M*s,F=_t(t,R,a,c),O=_t(n,R,a,c)||c,A=this.getAlternativeYValueIfAvailable(R,a,c,f,g,d),E=A?Math.min(O,A):O;if(M===0){if(F===null)return B.angleRight(o);const I=(F+E)/2;_=new B(i,I)}else F!==null?(y.set(R,(F+E)/2),y.sub(_),p.push(B.angleRight(y))):p.push(B.angleRight(o))}const x=p[0],v=p.map(M=>M-x);let C=0;return v.reduce((M,R)=>{const F=(Math.abs(R)-h)/l,O=Math.pow(1-gt(F,0,1),u);return C+=O,M+R*O},0)/C+x}updateXFlipped(){const{xBounds:t}=this.rescaleEvent;this.isXFlipped=t[0]>t[1]}getMarginsInWorldCoordinates(){const{xRatio:t}=this.rescaleEvent;return(this.options.margins||this.defaultMargins)*(this.isXFlipped?-1:1)/t}getSurfacesAreaEdges(){const t=this.data.areas.reduce((c,h)=>{const{data:l}=h,u=l.find(f=>f[1]!=null);u&&c.push(u[0]);for(let f=l.length-1;f>=0;f--)if(l[f][1]!=null){c.push(l[f][0]);break}return c},[]);t.push(...this.data.lines.reduce((c,h)=>{const{data:l}=h,u=l.find(f=>f[1]!=null);u&&c.push(u[0]);for(let f=l.length-1;f>=0;f--)if(l[f][1]!=null){c.push(l[f][0]);break}return c},[]));const n=Math.min(...t),i=Math.max(...t),r=this.getMarginsInWorldCoordinates(),{isXFlipped:s}=this,o=s?i+r:n+r,a=s?n-r:i-r;return[o,a]}checkDrawLabelsOnLeftSide(){const{referenceSystem:t,isXFlipped:n}=this;if(!t)return!0;const{xScale:i,yScale:r,xRatio:s}=this.rescaleEvent,o=200,[a,c]=i.domain(),[h,l]=r.domain();let u=t.interpolators.curtain.lookup(h,1,0);u.length===0&&(u=[t.interpolators.curtain.getPointAt(0)]);let f=t.interpolators.curtain.lookup(l,1,0);f.length===0&&(f=[t.interpolators.curtain.getPointAt(1)]);const g=Math.max(u[0][0],f[0][0]),d=Math.min(u[0][0],f[0][0]),p={left:n?g:d,right:n?d:g},y=this.getMarginsInWorldCoordinates(),_=a+y,x=c-y,[v,C]=this.getSurfacesAreaEdges(),b=n?Math.min(_,v):Math.max(_,v),S=n?Math.max(x,C):Math.min(x,C),M=Math.max(n?b-p.left:p.left-b,0),R=Math.max(n?p.right-S:S-p.right,0),F=M*s,O=R*s;return M>R||F>o||F<o&&O<o&&n||f[0][1]<h}}const ku=1e4;class Eu extends Pn{constructor(){super(...arguments),this.isPreRendered=!1,this.createPolygons=t=>{const n=[];let i=null;for(let r=0;r<t.length;r++){const s=!!t[r][1];s&&(i===null&&(i=[]),i.push(t[r][0],t[r][1]));const o=r===t.length-1;if((!s||o)&&i){for(let a=s?r:r-1;a>=0&&t[a][1];a--)i.push(t[a][0],t[a][2]||ku);n.push(i),i=null}}return n},this.generateAreaPolygon=t=>{const n=new z.Graphics;n.lineStyle(1,t.color,1),n.beginFill(t.color),this.createPolygons(t.data).forEach(r=>n.drawPolygon(r)),n.endFill(),this.addChild(n)},this.generateSurfaceLine=t=>{const n=new z.Graphics,{data:i}=t,r=.5;n.lineStyle(pr,t.color,1,r,!0);let s=!1;for(let o=0;o<i.length;o++)i[o][1]?s?n.lineTo(i[o][0],i[o][1]):(n.moveTo(i[o][0],i[o][1]),s=!0):s=!1;this.addChild(n)}}onRescale(t){super.onRescale(t),this.isPreRendered||(this.clearLayer(),this.preRender()),this.render()}onUpdate(t){super.onUpdate(t),this.isPreRendered=!1,this.clearLayer(),this.preRender(),this.render()}preRender(){const{data:t}=this;t&&(t.areas.forEach(n=>this.generateAreaPolygon(n)),t.lines.forEach(n=>this.generateSurfaceLine(n)),this.isPreRendered=!0)}}const Ur="lightgray",Wr="gray",Yr=.25,Gr=.75,Ru={minorColor:Ur,majorColor:Wr,minorWidth:Yr,majorWidth:Gr};class ke extends yt{constructor(t,n){super(t,n),this._offsetX=0,this._offsetY=0,this.options={...this.options,...n||Ru},this.render=this.render.bind(this)}onUpdate(t){super.onUpdate(t),this.render(t)}onRescale(t){super.onRescale(t),this.render(t)}render(t){const{ctx:n}=this,{minorWidth:i,minorColor:r,majorWidth:s,majorColor:o}=this.options;if(!n||(this.clearCanvas(),!(t.xScale||t.yScale)))return;const a=t.xScale.copy(),c=t.yScale.copy(),h=a.domain(),l=c.domain(),u=this.offsetX,f=this.offsetY;a.domain([h[0]-u,h[1]-u]),c.domain([l[0]-f,l[1]-f]);const[g,d]=a.range(),[p,y]=c.range();n.lineWidth=i||Yr,n.strokeStyle=r||Ur;const _=this.mapMinorTicks(a.ticks()),x=this.mapMinorTicks(c.ticks());this.renderTicksX(a,_,p,y),this.renderTicksY(c,x,g,d),n.lineWidth=s||Gr,n.strokeStyle=o||Wr,this.renderTicksX(a,a.ticks(),p,y),this.renderTicksY(c,c.ticks(),g,d),n.restore()}renderTicksX(t,n,i,r){n.forEach(s=>{const o=t(s);this.ctx.beginPath(),this.ctx.moveTo(o,i),this.ctx.lineTo(o,r),this.ctx.stroke()})}renderTicksY(t,n,i,r){n.forEach(s=>{const o=t(s);this.ctx.beginPath(),this.ctx.moveTo(i,o),this.ctx.lineTo(r,o),this.ctx.stroke()})}mapMinorTicks(t){let n=[];return t.length>=2&&(n=t.map(i=>i+(t[1]-t[0])/2),n.pop()),n}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t}}class Fu extends yt{onMount(t){super.onMount(t);const n=document.createElement("img");this.img=n,this.isLoading=!0}onUpdate(t){super.onUpdate(t),this.img.src=t.url,this.render(t)}onRescale(t){super.onRescale(t),this.setTransform(t),this.render(t)}render(t){const n=parseInt(this.elm.getAttribute("width"),10),i=parseInt(this.elm.getAttribute("height"),10),{xScale:r,yScale:s,xRatio:o,yRatio:a,x:c,y:h}=t,l=n*(o||1),u=i*(a||1);this.clearCanvas(),this.isLoading?this.img.onload=()=>{this.isLoading=!1,this.ctx.drawImage(this.img,r(c||0),s(h||0),l,u)}:this.ctx.drawImage(this.img,r(c||0),s(h||0),l,u)}}const zu={dash:[10,5],width:1,color:16777215,alpha:1,scale:1,useTexture:!1,alignment:.5},xt=class{constructor(e,t={}){this.cursor=new st.Point,this.scale=1,this.graphics=e,t={...zu,...t},this.dash=t.dash,this.dashSize=this.dash.reduce((n,i)=>n+i),this.useTexture=t.useTexture,this.options=t,this.setLineStyle()}setLineStyle(){const e=this.options;if(this.useTexture){const t=xt.getTexture(e,this.dashSize);this.graphics.lineTextureStyle({width:e.width*e.scale,color:e.color,alpha:e.alpha,texture:t,alignment:e.alignment}),this.activeTexture=t}else this.graphics.lineStyle({width:e.width*e.scale,color:e.color,alpha:e.alpha,cap:e.cap,join:e.join,alignment:e.alignment});this.scale=e.scale}static distance(e,t,n,i){return Math.sqrt(Math.pow(n-e,2)+Math.pow(i-t,2))}moveTo(e,t){return this.lineLength=0,this.cursor.set(e,t),this.start=new st.Point(e,t),this.graphics.moveTo(this.cursor.x,this.cursor.y),this}lineTo(e,t,n){typeof this.lineLength===void 0&&this.moveTo(0,0);const i=xt.distance(this.cursor.x,this.cursor.y,e,t),r=Math.atan2(t-this.cursor.y,e-this.cursor.x),s=n&&e===this.start.x&&t===this.start.y;if(this.useTexture)if(this.graphics.moveTo(this.cursor.x,this.cursor.y),this.adjustLineStyle(r),s&&this.dash.length%2===0){const o=Math.min(this.dash[this.dash.length-1],i);this.graphics.lineTo(e-Math.cos(r)*o,t-Math.sin(r)*o),this.graphics.closePath()}else this.graphics.lineTo(e,t);else{const o=Math.cos(r),a=Math.sin(r);let c=this.cursor.x,h=this.cursor.y;const l=this.lineLength%(this.dashSize*this.scale);let u=0,f=0,g=0;for(let p=0;p<this.dash.length;p++){const y=this.dash[p]*this.scale;if(l<g+y){u=p,f=l-g;break}else g+=y}let d=i;for(;d>0;){const p=this.dash[u]*this.scale-f,y=d>p?p:d;if(s&&xt.distance(c+o*y,h+a*y,this.start.x,this.start.y)<=y){if(u%2===0){const x=xt.distance(c,h,this.start.x,this.start.y)-this.dash[this.dash.length-1]*this.scale;c+=o*x,h+=a*x,this.graphics.lineTo(c,h)}break}c+=o*y,h+=a*y,u%2?this.graphics.moveTo(c,h):this.graphics.lineTo(c,h),d-=y,u++,u=u===this.dash.length?0:u,f=0}}return this.lineLength+=i,this.cursor.set(e,t),this}closePath(){this.lineTo(this.start.x,this.start.y,!0)}drawCircle(e,t,n,i=80,r){const s=Math.PI*2/i;let o=0,a;r?(a=new st.Point(e+Math.cos(o)*n,t+Math.sin(o)*n),r.apply(a,a),this.moveTo(a[0],a[1])):(a=new st.Point(e+Math.cos(o)*n,t+Math.sin(o)*n),this.moveTo(a.x,a.y)),o+=s;for(let c=1;c<i+1;c++){const h=c===i?a:[e+Math.cos(o)*n,t+Math.sin(o)*n];this.lineTo(h[0],h[1]),o+=s}return this}drawEllipse(e,t,n,i,r=80,s){const o=Math.PI*2/r;let a;const c=new st.Point;for(let h=0;h<Math.PI*2;h+=o){let l=e-n*Math.sin(h),u=t-i*Math.cos(h);s&&(c.set(l,u),s.apply(c,c),l=c.x,u=c.y),h===0?(this.moveTo(l,u),a={x:l,y:u}):this.lineTo(l,u)}return this.lineTo(a.x,a.y,!0),this}drawPolygon(e,t){const n=new st.Point;if(typeof e[0]=="number")if(t){n.set(e[0],e[1]),t.apply(n,n),this.moveTo(n.x,n.y);for(let i=2;i<e.length;i+=2)n.set(e[i],e[i+1]),t.apply(n,n),this.lineTo(n.x,n.y,i===e.length-2)}else{this.moveTo(e[0],e[1]);for(let i=2;i<e.length;i+=2)this.lineTo(e[i],e[i+1],i===e.length-2)}else if(t){const i=e[0];n.copyFrom(i),t.apply(n,n),this.moveTo(n.x,n.y);for(let r=1;r<e.length;r++){const s=e[r];n.copyFrom(s),t.apply(n,n),this.lineTo(n.x,n.y,r===e.length-1)}}else{const i=e[0];this.moveTo(i.x,i.y);for(let r=1;r<e.length;r++){const s=e[r];this.lineTo(s.x,s.y,r===e.length-1)}}return this}drawRect(e,t,n,i,r){if(r){const s=new st.Point;s.set(e,t),r.apply(s,s),this.moveTo(s.x,s.y),s.set(e+n,t),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e+n,t+i),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e,t+i),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e,t),r.apply(s,s),this.lineTo(s.x,s.y,!0)}else this.moveTo(e,t).lineTo(e+n,t).lineTo(e+n,t+i).lineTo(e,t+i).lineTo(e,t,!0);return this}adjustLineStyle(e){const t=this.graphics.line;t.matrix=new st.Matrix,e&&t.matrix.rotate(e),this.scale!==1&&t.matrix.scale(this.scale,this.scale);const n=-this.lineLength;t.matrix.translate(this.cursor.x+n*Math.cos(e),this.cursor.y+n*Math.sin(e)),this.graphics.lineStyle(t)}static getTexture(e,t){const n=e.dash.toString();if(xt.dashTextureCache[n])return xt.dashTextureCache[n];const i=document.createElement("canvas");i.width=t,i.height=Math.ceil(e.width);const r=i.getContext("2d");if(!r){console.warn("Did not get context from canvas");return}r.strokeStyle="white",r.globalAlpha=e.alpha,r.lineWidth=e.width;let s=0;const o=e.width/2;r.moveTo(s,o);for(let c=0;c<e.dash.length;c+=2)s+=e.dash[c],r.lineTo(s,o),e.dash.length!==c+1&&(s+=e.dash[c+1],r.moveTo(s,o));r.stroke();const a=xt.dashTextureCache[n]=st.Texture.from(i);return a.baseTexture.scaleMode=st.SCALE_MODES.NEAREST,a}};let Xr=xt;Xr.dashTextureCache={};const Fn=e=>new B(e.x,e.y),Du=e=>new z.Point(e[0],e[1]),jr=e=>{if(e.length<2)return[new B(0)];let t;return e.map((n,i,r)=>{if(i<r.length-1){const s=Fn(r[i]);return t=Fn(r[i+1]).sub(s).rotate90().normalized(),t}return t})},qr=(e,t,n)=>{const i=Fn(e);return Du(i.add(t.scale(n)))},zn=(e,t,n)=>{if(e.length!==t.length)throw new Error("Number of vectors does not match number of points");return e.map((i,r)=>{const s=t[r];return qr(i,s,n)})},Zr=(e,t,n,i)=>e<=i&&n<=t,Ou=(e,t,n,i)=>e<i&&n<t,Nu=e=>Array.from(new Set(e)),Ee=(e,t,n,i)=>{const r=i.filter(o=>Zr(e,t,o.start,o.end)),s=n.filter(o=>Zr(e,t,o.start,o.end));return{overlappingHoles:r,overlappingOuterStrings:s}},Re=([e,t],n)=>{const s=n.flatMap(a=>[a.start-1e-4,a.start,a.end,a.end+1e-4]).filter(a=>a>=e&&a<=t);return s.push(e),s.push(t),Nu(s).sort((a,c)=>a-c)},K=e=>e.kind==="casing"?e.innerDiameter:e.diameter,Kr=(e,t,n,i)=>{const s=e.find(h=>h.start<=i&&h.end>=i),o=s?s.diameter:0,a=t.filter(h=>K(h)>o).sort((h,l)=>K(h)-K(l)).find(h=>h.start<=i&&h.end>=i),c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter>o);return a?K(a):c?c.diameter:100},$u=(e,t,n,i)=>{const s=e.sort((a,c)=>c.diameter-a.diameter).find(a=>a.start<=n&&a.end>=n),o=t.find(a=>a.start<=n&&a.end>=n);return s&&i!=="Open hole frac pack"&&i!=="Open hole gravel pack"?K(s):o?o.diameter:100},Bu=(e,t,n,i)=>{const s=e.sort((h,l)=>K(h)-K(l)).find(h=>h.start<=i&&h.end>=i);if(s)return K(s);const o=e.length?Math.min(...e.map(h=>K(h))):0,a=t.sort((h,l)=>K(h)-K(l)).find(h=>h.start<=i&&h.end>=i&&o<=K(h));if(a)return K(a);const c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter);return c?c.diameter:100},Iu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Dn(e.referenceIds,t,n);if(o.length===0)throw new Error(`Invalid cement data, can't find referenced casing/completion string for cement with id '${e.id}'`);o.sort((p,y)=>p.end-y.end);const c=o[o.length-1].end,{overlappingOuterStrings:h,overlappingHoles:l}=Ee(e.toc,c,a,i),u=[...h,...l].map(p=>({start:p.start,end:p.end}));return Re([e.toc,c],u).flatMap((p,y,_)=>{if(y===_.length-1)return[];const x=_[y+1],v=Kr(o,h,l,p);return[{top:p,bottom:x,diameter:v*r}]}).map(p=>({diameter:p.diameter,points:s(p.top,p.bottom)}))},Dn=(e,t,n)=>[...t,...n].reduce((i,r)=>e.includes(r.id)?{...i,attachedStrings:[...i.attachedStrings,r]}:{...i,nonAttachedStrings:[...i.nonAttachedStrings,r]},{attachedStrings:[],nonAttachedStrings:[]}),Hu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Dn(e.referenceIds,t,n);if(o.length===0)throw new Error(`Invalid cement squeeze data, can't find referenced casing/completion for squeeze with id '${e.id}'`);const{overlappingOuterStrings:c,overlappingHoles:h}=Ee(e.start,e.end,a,i),l=[...c,...h].map(d=>({start:d.start,end:d.end}));return Re([e.start,e.end],l).flatMap((d,p,y)=>{if(p===y.length-1)return[];const _=y[p+1],x=Kr(o,c,h,d);return[{top:d,bottom:_,diameter:x*r}]}).map(d=>({diameter:d.diameter,points:s(d.top,d.bottom)}))},Vu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=Dn(e.referenceIds,t,n),{overlappingHoles:c,overlappingOuterStrings:h}=Ee(e.start,e.end,a,i),l=[...o,...c,...h].map(d=>({start:d.start,end:d.end}));return Re([e.start,e.end],l).flatMap((d,p,y)=>{if(p===y.length-1)return[];const _=y[p+1],x=Bu(o,h,c,d);return[{top:d,bottom:_,diameter:x*r}]}).map(d=>({diameter:d.diameter,points:s(d.top,d.bottom)}))},Uu=(e,t,n,i,r)=>{const o=t.createLinearGradient(0,0,0,e.height);return o.addColorStop(0,n),o.addColorStop(.5-r,i),o.addColorStop(.5+r,i),o.addColorStop(1,n),o},Wu=({firstColor:e,secondColor:t},n,i)=>{const r=document.createElement("canvas");r.width=n,r.height=i;const s=r.getContext("2d");return s.fillStyle=Uu(r,s,e,t,0),s.fillRect(0,0,r.width,r.height),z.Texture.from(r)},Yu=({scalingFactor:e})=>{const t=document.createElement("canvas"),n=mt*e;t.width=n,t.height=n;const i=t.getContext("2d");i.fillStyle="white",i.fillRect(0,0,t.width,t.height);const r=n/10;i.strokeStyle="#AAAAAA",i.lineWidth=r,i.beginPath();const s=n/3;for(let o=-t.width;o<t.width;o++)i.moveTo(-t.width+s*o,-t.height),i.lineTo(t.width+s*o,t.height*2);return i.stroke(),z.Texture.from(t)},Gu=({innerColor:e,outerColor:t,scalingFactor:n})=>{const i=mt*n,r=document.createElement("canvas");r.width=i,r.height=i;const s=r.getContext("2d"),o=s.createLinearGradient(0,0,0,i),a=.3,c=.7;return o.addColorStop(0,t),o.addColorStop(a,e),o.addColorStop(c,e),o.addColorStop(1,t),s.fillStyle=o,s.fillRect(0,0,r.width,r.height),z.Texture.from(r)},Xu=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=mt*n,s=n;i.width=r,i.height=r;const o=i.getContext("2d");o.fillStyle=e,o.fillRect(0,0,i.width,i.height),o.lineWidth=s,o.fillStyle=t,o.beginPath();const a=r/12;for(let c=-i.width;c<i.width;c++)o.moveTo(-i.width+a*c,-i.height),o.lineTo(i.width+a*c,i.height);return o.stroke(),z.Texture.from(i)},ju=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=mt*n;i.width=r,i.height=r;const s=i.getContext("2d");s.fillStyle=e,s.fillRect(0,0,i.width,i.height),s.lineWidth=n,s.strokeStyle=t,s.beginPath(),s.setLineDash([20,10]);const o=r/12;for(let a=-i.width;a<i.width;a++)s.moveTo(-i.width+o*a,-i.height),s.lineTo(i.width+o*a,i.height*2);return s.stroke(),z.Texture.from(i)},qu=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=mt*n,s=n;i.width=r,i.height=r;const o=i.getContext("2d");o.lineWidth=s,o.fillStyle=e,o.strokeStyle=t,o.fillRect(0,0,i.width,i.height),o.beginPath(),o.setLineDash([20,10]);const a=r/12;for(let c=-i.width;c<i.width;c++)o.moveTo(-i.width+a*c,-i.height),o.lineTo(i.width+a*c,i.height*2);return o.stroke(),z.Texture.from(i)},Fe=(e,t)=>{const n=jr(t),i=zn(t,n,e);return{leftPath:zn(t,n,-e),rightPath:i}},On=(e,t)=>({kind:"casing",start:e,end:t}),Zu=(e,t)=>({kind:"casing-window",start:e,end:t}),Ku=e=>{const t=(e.windows||[]).filter(n=>Ou(e.start,e.end,n.start,n.end)).reduce(({intervals:n,lastBottom:i},r,s,o)=>{const a=i<r.start?On(i,r.start):null,c=a?a.end:i,h=Math.max(c,r.start),l=Math.min(e.end,r.end),u=Zu(h,l),f=l,d=s===o.length-1&&f<e.end?On(f,e.end):null,p=[a,u,d].filter(y=>y);return{intervals:[...n,...p],lastBottom:f}},{intervals:[],lastBottom:e.start});return t.intervals.length?t.intervals:[On(e.start,e.end)]},Qu=(e,t,n)=>{const i=t.diameter*e,r=i/2,o=t.innerDiameter*e/2,a=r-o,c=Ku(t).map(h=>{const l=n(h.start,h.end),{leftPath:u,rightPath:f}=Fe(r,l);return{kind:h.kind,leftPath:u,rightPath:f,pathPoints:l}});return{kind:"casing",id:t.id,referenceDiameter:i,referenceRadius:r,sections:c,casingWallWidth:a,hasShoe:t.hasShoe,bottom:t.end}},Ju=(e,t,n,i,r)=>{const{overlappingOuterStrings:s,overlappingHoles:o}=Ee(e.start,e.end,t,n),a=[...s,...o].map(u=>({start:u.start,end:u.end}));return Re([e.start,e.end],a).flatMap((u,f,g)=>{if(f===g.length-1)return[];const d=g[f+1],p=$u(s,o,u,e.subKind);return[{top:u,bottom:d,diameter:p*i}]}).map(u=>{const f=r(u.top,u.bottom);return{diameter:u.diameter,points:f}})},ze=(e,t,n)=>{const{packingOpacity:i,yellow:r}=n;t.fillStyle=r,t.strokeStyle=r;const s=[0,0],o=[e.width,e.height];t.save(),t.globalAlpha=i,t.fillRect(...s,...o),t.restore()},Nn=(e,t,n,i,r)=>{const{fracLineCurve:s}=i,o=10,a=e.width/o,c=n/3*i.scalingFactor,h=c/4,l=c/2,u=0,f=r==="diameter"?0:l,g=()=>{for(let d=-1;d<o;d++){const p=[d*a+u+a/2,e.height/2-h-f-h];t.beginPath();const y=[...p],_=[p[0]-s*2,p[1]-h/4],x=[p[0],p[1]-h/2],v=[p[0]+s*2,p[1]-h/2-h/4],C=[p[0],p[1]-h];t.bezierCurveTo(...y,..._,...x),t.bezierCurveTo(...x,...v,...C),t.stroke()}for(let d=-1;d<o;d++){const p=[d*a+a+u+a/2,e.height/2+c/2+f];t.beginPath();const y=[...p],_=[p[0]-s*2,p[1]+h/4],x=[p[0],p[1]+h/2],v=[p[0]+s*2,p[1]+h/2+h/4],C=[p[0],p[1]+h];t.bezierCurveTo(...y,..._,...x),t.bezierCurveTo(...x,...v,...C),t.stroke()}};t.strokeStyle=i.yellow,t.lineWidth=6,t.save(),t.globalAlpha=i.packingOpacity,g(),t.restore(),t.lineWidth=1,t.strokeStyle=i.outline,g(),t.closePath()},tf=(e,t,n,i)=>{const s=e.width/10;t.strokeStyle=i.outline;const o=n/3*i.scalingFactor;t.lineWidth=1;const a=o/2,c=0;for(let h=0;h<=10;h++){const l=[h*s+c,e.height/2-o/2],u=[l[0]-s/2,l[1]-a],f=[l[0]-s,l[1]];t.beginPath(),t.moveTo(...l),t.lineTo(...u),t.lineTo(...f),t.fill(),t.lineWidth=1,t.stroke()}for(let h=0;h<=10;h++){const l=[h*s+c,e.height/2+o/2],u=[l[0]-s/2,l[1]+a],f=[l[0]-s,l[1]];t.beginPath(),t.moveTo(...l),t.lineTo(...u),t.lineTo(...f),t.fill(),t.lineWidth=1,t.stroke()}t.closePath()},ct=(e="Error!",t)=>{console.error(`${e}`);const n=(t==null?void 0:t.canvas)||document.createElement("canvas"),i=mt;n.width=i/2,n.height=i;const r=(t==null?void 0:t.canvasCtx)||n.getContext("2d"),s=[0,0],o=[n.width,n.height];return r.fillStyle="#ff00ff",r.fillRect(...s,...o),new z.Texture(z.Texture.from(n,{wrapMode:z.WRAP_MODES.CLAMP}).baseTexture,null,new z.Rectangle(0,0,n.width,n.height),null,z.groupD8.MIRROR_HORIZONTAL)},vt=(e,t)=>{const n=document.createElement("canvas"),r=e.diameter*t.scalingFactor;n.width=r/2,n.height=r;const s=n.getContext("2d");return{canvas:n,ctx:s}},wt=e=>new z.Texture(z.Texture.from(e,{wrapMode:z.WRAP_MODES.CLAMP}).baseTexture,null,new z.Rectangle(0,0,e.width,e.height),null,z.groupD8.MIRROR_HORIZONTAL),$n={packing:()=>ct(),fracLines:()=>ct(),spikes:(e,t,n,i)=>{const{canvas:r,ctx:s}=vt(t,i),o=n.some(h=>Tr(h)&&Cn(e,h)),a=n.some(h=>Mr(h)&&Cn(e,h));return o||a?e.isOpen?(s.fillStyle=i.yellow,s.strokeStyle=i.yellow):(s.fillStyle=i.grey,s.strokeStyle=i.grey):e.isOpen?(s.fillStyle=i.red,s.strokeStyle=i.red):(s.fillStyle=i.grey,s.strokeStyle=i.grey),tf(r,s,t.diameter,i),a&&Nn(r,s,t.diameter,i,"spike"),wt(r)}},Qr={packing:()=>ct(),fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return Nn(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>ct()},De={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return ze(n,i,t),wt(n)},fracLines:(e,t)=>{const{canvas:n}=vt(e,t);return wt(n)},spikes:()=>ct()},Bn={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return ze(n,i,t),wt(n)},fracLines:()=>ct(),spikes:()=>ct()},In={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return ze(n,i,t),wt(n)},fracLines:()=>ct(),spikes:()=>ct()},Hn={packing:(e,t,n)=>{const{canvas:i,ctx:r}=vt(t,n);return ze(i,r,n),wt(i)},fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return Nn(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>ct()},ef=(e,t,n)=>Z({Perforation:()=>$n.packing(),CasedHoleFracturation:()=>De.packing(t,n),CasedHoleFracPack:()=>De.packing(t,n),OpenHoleGravelPack:()=>In.packing(t,n),OpenHoleFracPack:()=>Hn.packing(e,t,n),CasedHoleGravelPack:()=>Bn.packing(t,n)},e.subKind),nf=(e,t,n)=>Z({Perforation:()=>$n.fracLines(),OpenHoleGravelPack:()=>In.fracLines(),OpenHoleFracPack:()=>Hn.fracLines(t,n),CasedHoleFracturation:()=>Qr.fracLines(t,n),CasedHoleGravelPack:()=>Bn.fracLines(),CasedHoleFracPack:()=>De.fracLines(t,n)},e.subKind),rf=(e,t,n,i)=>Z({Perforation:()=>$n.spikes(e,n,t,i),OpenHoleGravelPack:()=>In.spikes(),OpenHoleFracPack:()=>Hn.spikes(),CasedHoleFracturation:()=>Qr.spikes(),CasedHoleGravelPack:()=>Bn.spikes(),CasedHoleFracPack:()=>De.spikes()},e.subKind);class sf extends z.MeshGeometry{constructor(t,n=0){const i=Ye(t,r=>r.points.length);super(new Float32Array(i*4),new Float32Array(i*4),new Uint16Array((i-1)*6)),this.segments=t,this.textureScale=n,this.build()}get width(){return We(this.segments,t=>t.diameter)}build(){const t=this.segments;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex(),s=Ye(t,d=>d.points.length);if(s<1)return;n.data.length/4!==s&&(n.data=new Float32Array(s*4),i.data=new Float32Array(s*4),r.data=new Uint16Array((s-1)*6));const o=i.data,a=r.data;o[0]=0,o[1]=0,o[2]=0,o[3]=1;const c=t.length,h=We(t,d=>d.diameter);let l=0,u=0,f=0,g=0;for(let d=0;d<c;d++){let p=t[d].points[0];const y=h,_=t[d].diameter/h/2,x=t[d].points.length;for(let v=0;v<x;v++){const C=p.x-t[d].points[v].x,b=p.y-t[d].points[v].y,S=Math.sqrt(C*C+b*b);p=t[d].points[v],l+=S/y,o[u]=l,o[u+1]=.5-_,o[u+2]=l,o[u+3]=.5+_,u+=4}for(let v=0;v<x-1;v++)a[g++]=f,a[g++]=f+1,a[g++]=f+2,a[g++]=f+2,a[g++]=f+1,a[g++]=f+3,f+=2;f+=2}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.segments;if(Ye(t,s=>s.points.length)<1)return;const i=t.length;let r=0;for(let s=0;s<i;s++){let o=t[s].points[0],a,c=0,h=0;const l=this.buffers[0].data,u=t[s].points.length;let f=0;for(let g=0;g<u;g++){const d=t[s].points[g];f=r+g*4,g<t[s].points.length-1?a=t[s].points[g+1]:a=d,h=-(a.x-o.x),c=a.y-o.y;const p=Math.sqrt(c*c+h*h),y=t[s].diameter/2;c/=p,h/=p,c*=y,h*=y,l[f]=d.x+c,l[f+1]=d.y+h,l[f+2]=d.x-c,l[f+3]=d.y-h,o=d}r=f+4}this.buffers[0].update()}update(){this.build()}}class of extends z.Mesh{constructor(t,n,i=0){const r=new sf(n,i),s=new z.MeshMaterial(t);t.baseTexture.wrapMode=z.WRAP_MODES.REPEAT,super(r,s),this.autoUpdate=!0}_render(t){const n=this.geometry;this.autoUpdate&&n.update(),super._render(t)}}class af extends z.MeshGeometry{constructor(t,n=200){super(new Float32Array(t.length*4),new Float32Array(t.length*4),new Uint16Array((t.length-1)*6)),this.points=t,this._width=n,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex();if(t.length<1)return;n.data.length/4!==t.length&&(n.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const s=i.data,o=r.data;s[0]=0,s[1]=0,s[2]=0,s[3]=1;let a=0,c=t[0];const h=t.length;for(let u=0;u<h;u++){const f=u*4,g=c.x-t[u].x,d=c.y-t[u].y,p=Math.sqrt(g*g+d*d);c=t[u],a+=p/this._width,s[f]=a,s[f+1]=0,s[f+2]=a,s[f+3]=1}let l=0;for(let u=0;u<h-1;u++){const f=u*2;o[l++]=f,o[l++]=f+1,o[l++]=f+2,o[l++]=f+2,o[l++]=f+1,o[l++]=f+3}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let n=t[0],i,r=0,s=0;const o=this.buffers[0].data,a=t.length;for(let c=0;c<a;c++){const h=t[c],l=c*4;c<t.length-1?i=t[c+1]:i=h,s=-(i.x-n.x),r=i.y-n.y;const u=Math.sqrt(r*r+s*s),f=this._width/2;r/=u,s/=u,r*=f,s*=f,o[l]=h.x+r,o[l+1]=h.y+s,o[l+2]=h.x-r,o[l+3]=h.y-s,n=h}this.buffers[0].update()}update(){this.build()}}class cf extends z.Mesh{constructor(t,n,i){const r=new af(n,i),s=new z.MeshMaterial(t);t.baseTexture.wrapMode=z.WRAP_MODES.REPEAT,super(r,s),this.autoUpdate=!0}_render(t){const n=this.geometry;this.autoUpdate&&n.update(),super._render(t)}}class hf extends z.MeshGeometry{constructor(t,n=200){super(new Float32Array(t.length*4),new Float32Array(t.length*4),new Uint16Array((t.length-1)*6)),this.points=t,this._width=n,this.build()}build(){const t=this.points;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex();if(t.length<1)return;n.data.length/4!==t.length&&(n.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const s=t.length;let o=0,a=t[0];for(let g=0;g<s;g++){const d=a.x-t[g].x,p=a.y-t[g].y,y=Math.sqrt(d*d+p*p);a=t[g],o+=y}const c=i.data,h=r.data;c[0]=0,c[1]=0,c[2]=0,c[3]=1;let l=0,u=t[0];for(let g=0;g<s;g++){const d=g*4,p=u.x-t[g].x,y=u.y-t[g].y,_=Math.sqrt(p*p+y*y);u=t[g],l+=_/o,c[d]=l,c[d+1]=0,c[d+2]=l,c[d+3]=1}let f=0;for(let g=0;g<s-1;g++){const d=g*2;h[f++]=d,h[f++]=d+1,h[f++]=d+2,h[f++]=d+2,h[f++]=d+1,h[f++]=d+3}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let n=t[0],i,r=0,s=0;const o=this.buffers[0].data,a=t.length;for(let c=0;c<a;c++){const h=t[c],l=c*4;c<t.length-1?i=t[c+1]:i=h,s=-(i.x-n.x),r=i.y-n.y;const u=Math.sqrt(r*r+s*s),f=this._width/2;r/=u,s/=u,r*=f,s*=f,o[l]=h.x+r,o[l+1]=h.y+s,o[l+2]=h.x-r,o[l+3]=h.y-s,n=h}this.buffers[0].update()}update(){this.updateVertices()}}class lf extends z.Mesh{constructor(t,n){const i=new hf(n,t.height),r=new z.MeshMaterial(t);super(i,r),this.autoUpdate=!0}_render(t){const n=this.geometry;(this.autoUpdate||n._width!==this.shader.texture.height)&&(n._width=this.shader.texture.height,n.update()),super._render(t)}}const uf=(e,t,n)=>i=>{switch(i.kind){case"casing":return e(i);case"cement":return t(i);case"cementSqueeze":return n(i);default:return Qt(i)}},ff=e=>({exaggerationFactor:2,internalLayerOptions:Ar(e),holeOptions:Pr,casingOptions:Cr,cementOptions:kr,cementSqueezeOptions:Er,screenOptions:Rr,tubingOptions:Fr,cementPlugOptions:zr,perforationOptions:Lr}),Jr=class extends Pn{constructor(e,t,n){super(e,t,n),this.internalLayerVisibility={holeLayerId:!0,casingLayerId:!0,completionLayerId:!0,cementLayerId:!0,pAndALayerId:!0,perforationLayerId:!0},this.scalingFactors={height:600,zFactor:1,yScale:Tt()},this.getZFactorScaledPathForPoints=(i,r)=>{const s=a=>a*this.scalingFactors.zFactor;return this.referenceSystem.getCurtainPath(i,r,!0).map(a=>new z.Point(a.point[0],s(a.point[1])))},this.drawBigPolygon=(i,r=0)=>{const s=new z.Graphics;s.beginFill(r),s.drawPolygon(i),s.endFill(),this.addChild(s)},this.perforationRopeAndTextureReferences=[],this.prepareSymbolRenderObject=i=>{const{exaggerationFactor:r}=this.options,s=i.diameter*r;return{pathPoints:this.getZFactorScaledPathForPoints(i.start,i.end),referenceDiameter:s,symbolKey:i.symbolKey}},this.drawSymbolComponent=({pathPoints:i,referenceDiameter:r,symbolKey:s})=>{const o=this.getSymbolTexture(s,r);this.drawSVGRope(i,o)},this.drawHoleSize=(i,r)=>{if(r==null)return;const s=this.getZFactorScaledPathForPoints(r.start,r.end);if(s.length===0)return;const{exaggerationFactor:o,holeOptions:a}=this.options,c=r.diameter*o,{rightPath:h,leftPath:l}=Fe(c/2,s),u=this.getHoleTexture(a,c,i);this.drawHoleRope(s,u,i),this.drawOutline(l,h,dt(a.lineColor),_l*o,"TopAndBottom",0)},this.drawCasing=i=>{const{casingOptions:r}=this.options,s=dt(r.solidColor),o=dt(r.lineColor);i.sections.forEach((a,c,h)=>{const l=Jr.getOutlineClosureType(c,h.length-1),u=this.createCasingTexture(i.referenceDiameter);this.drawRope(a.pathPoints,u,s),a.kind==="casing-window"?this.drawCasingWindowOutline(a.leftPath,a.rightPath,r,i.casingWallWidth):this.drawOutline(a.leftPath,a.rightPath,o,i.casingWallWidth,l)})},this.generateShoe=(i,r,s,o)=>{const a=i-s,c=i,h=this.getZFactorScaledPathForPoints(a,c),l=jr(h),u=zn(h,l,r*(o<0?-1:1)),f=h[h.length-1],g=l[l.length-1],d=qr(f,g,o+r*(o<0?-1:1));return[...u,d]},this.createCementSqueezeShape=(i,r,s,o)=>{const{exaggerationFactor:a}=this.options;return Hu(i,r,s,o,a,this.getZFactorScaledPathForPoints)},this.createPerforationShape=(i,r,s)=>{const{exaggerationFactor:o}=this.options;return Ju(i,r,s,o,this.getZFactorScaledPathForPoints)},this.options={...this.options,...ff(this.id),...n}}onUnmount(e){super.onUnmount(e),this.scalingFactors=null,this.cementTextureCache=null,this.cementSqueezeTextureCache=null,this.holeTextureCache=null,this.screenTextureCache=null,this.tubingTextureCache=null,this.textureSymbolCacheArray=null,this.internalLayerVisibility=null}onUpdate(e){super.onUpdate(e),this.clearLayer(),this.preRender(),this.render()}onRescale(e){const t=this.scalingFactors.zFactor!==e.zFactor;this.scalingFactors={height:e.height,zFactor:e.zFactor,yScale:e.yScale},super.optionsRescale(e);const n=this.yRatio(),i=e.xBounds[0]>e.xBounds[1],r=e.yBounds[0]>e.yBounds[1];this.setContainerPosition(e.xScale(0),e.yScale(0)),this.setContainerScale(e.xRatio*(i?-1:1),n*(r?-1:1)),t&&(this.clearLayer(),this.preRender()),this.render()}setVisibility(e,t){if(t===this.id){super.setVisibility(e,t);return}const{internalLayerOptions:n}=this.options,[i]=Object.entries(n).find(([r,s])=>s===t);i&&(this.internalLayerVisibility[i]=e,this.clearLayer(),this.preRender(),this.render())}getInternalLayerIds(){const{internalLayerOptions:e}=this.options;return Object.values(e)}yRatio(){const e=this.scalingFactors.yScale.domain(),n=(e[1]-e[0])*this.scalingFactors.zFactor,i=[e[0],e[0]+n];return Math.abs(this.scalingFactors.height/(i[1]-i[0]))}drawRope(e,t,n){if(e.length===0)return null;const i=new z.SimpleRope(t,e,1);i.tint=n||i.tint,this.addChild(i)}drawOutline(e,t,n,i=1,r="None",s=1){const o=e.map(l=>l.clone()).reverse(),a=t[0],c=o[0],h=new z.Graphics;h.lineStyle(i,n,void 0,s),h.moveTo(a.x,a.y),t.forEach(l=>h.lineTo(l.x,l.y)),(r==="None"||r==="Top")&&h.moveTo(c.x,c.y),o.forEach(l=>h.lineTo(l.x,l.y)),(r==="TopAndBottom"||r==="Top")&&h.lineTo(a.x,a.y),this.addChild(h)}drawCasingWindowOutline(e,t,{lineColor:n,windowOptions:i},r=1){var d,p;const s=!!((p=(d=this.referenceSystem)==null?void 0:d.options)!=null&&p.calculateDisplacementFromBottom),[o,a]=s?[e,t]:[t,e],[c,h]=s?[1,0]:[0,1],l=new z.Graphics;l.lineStyle(r,dt(n),void 0,h);const u=o[0];l.moveTo(u.x,u.y),o.forEach(y=>l.lineTo(y.x,y.y));const f=new Xr(l,{dash:[i.dashLength,i.spaceLength],color:dt(i.dashColor),width:r,alignment:c}),g=a[0];f.moveTo(g.x,g.y),a.forEach(y=>{f.lineTo(y.x,y.y)}),this.addChild(l)}preRender(){if(!this.data||!this.referenceSystem)return;const{exaggerationFactor:e}=this.options,{holeSizes:t,casings:n,cements:i,completion:r,symbols:s,pAndA:o,perforations:a}=this.data;this.updateSymbolCache(s),t.sort((d,p)=>p.diameter-d.diameter);const c=t.length>0?We(t,d=>d.diameter)*e:yl*e;this.internalLayerVisibility.holeLayerId&&t.forEach(d=>this.drawHoleSize(c,d)),n.sort((d,p)=>p.diameter-d.diameter);const h=n.map(d=>this.createCasingRenderObject(d)),l=i.map(d=>({kind:"cement",segments:Iu(d,n,r,t,e,this.getZFactorScaledPathForPoints),casingIds:(d.referenceIds||[]).filter(p=>p)})),[u,f]=o.reduce(([d,p],y)=>_r(y)?[[y,...d],p]:[d,[y,...p]],[[],[]]),g=u.map(d=>({kind:"cementSqueeze",segments:this.createCementSqueezeShape(d,n,r,t),casingIds:d.referenceIds}));if(this.sortCementAndCasingRenderObjects(h,l,g).forEach(uf(d=>{this.internalLayerVisibility.casingLayerId&&(this.drawCasing(d),d.hasShoe&&this.drawShoe(d.bottom,d.referenceRadius))},d=>{this.internalLayerVisibility.cementLayerId&&this.drawComplexRope(d.segments,this.getCementTexture())},d=>{this.internalLayerVisibility.pAndALayerId&&this.drawComplexRope(d.segments,this.getCementSqueezeTexture())})),this.perforationRopeAndTextureReferences.forEach(({rope:d,texture:p})=>{d.destroy({children:!0,texture:!0,baseTexture:!0}),p.destroy(!0)}),this.perforationRopeAndTextureReferences=[],this.internalLayerVisibility.perforationLayerId){const{perforationOptions:d}=this.options,p=a.filter(wr),y=a.filter(br),_=a.filter(Sr);p.forEach(x=>{const C=this.createPerforationShape(x,n,t).reduce((b,S)=>(b[S.diameter]||(b[S.diameter]=[]),b[S.diameter]=[...b[S.diameter],S],b),{});Object.values(C).forEach(b=>{const S=ef(x,b[0],d),M=this.drawComplexRope(b,S);this.perforationRopeAndTextureReferences.push({rope:M,texture:S})})}),y.forEach(x=>{const b=this.createPerforationShape(x,n,t).map(S=>({...S,diameter:S.diameter*3})).reduce((S,M)=>(S[M.diameter]||(S[M.diameter]=[]),S[M.diameter]=[...S[M.diameter],M],S),{});Object.values(b).forEach(S=>{S.forEach(M=>{const R=nf(x,M,d),F=this.drawComplexRope([M],R);this.perforationRopeAndTextureReferences.push({rope:F,texture:R})})})}),_.forEach(x=>{const b=this.createPerforationShape(x,n,t).map(S=>({...S,diameter:S.diameter*3})).reduce((S,M)=>(S[M.diameter]||(S[M.diameter]=[]),S[M.diameter]=[...S[M.diameter],M],S),{});Object.values(b).forEach(S=>{S.forEach(M=>{const R=rf(x,a,M,d),F=this.drawComplexRope([M],R);this.perforationRopeAndTextureReferences.push({rope:F,texture:R})})})})}this.internalLayerVisibility.completionLayerId&&r.forEach(vr(d=>this.drawScreen(d),d=>this.drawTubing(d),d=>{const p=this.prepareSymbolRenderObject(d);this.drawSymbolComponent(p)})),this.internalLayerVisibility.pAndALayerId&&f.forEach(d=>{if(yr(d)){const p=this.prepareSymbolRenderObject(d);this.drawSymbolComponent(p)}xr(d)&&this.drawCementPlug(d,n,r,t)})}updateSymbolCache(e){if(this.textureSymbolCacheArray||(this.textureSymbolCacheArray={}),!e)return;const t=Object.keys(this.textureSymbolCacheArray);Object.entries(e).forEach(([n,i])=>{t.includes(n)||(this.textureSymbolCacheArray[n]=z.Texture.from(i))})}drawCementPlug(e,t,n,i){const{exaggerationFactor:r,cementPlugOptions:s}=this.options,o=Vu(e,t,n,i,r,this.getZFactorScaledPathForPoints);this.drawComplexRope(o,this.getCementPlugTexture(s));const{rightPath:a,leftPath:c}=o.reduce((h,l)=>{const{leftPath:u,rightPath:f}=Fe(l.diameter/2,l.points);return{rightPath:[...h.rightPath,...f],leftPath:[...h.leftPath,...u]}},{rightPath:[],leftPath:[]});this.drawOutline(c,a,dt("black"),.25,"TopAndBottom")}createCasingRenderObject(e){const{exaggerationFactor:t}=this.options;return Qu(t,e,this.getZFactorScaledPathForPoints)}getCementPlugTexture(e){return this.cementPlugTextureCache||(this.cementPlugTextureCache=ju(e)),this.cementPlugTextureCache}drawSVGRope(e,t){if(e.length===0)return null;const n=new lf(t,e);this.addChild(n)}getSymbolTexture(e,t){return new z.Texture(this.textureSymbolCacheArray[e].baseTexture,null,new z.Rectangle(0,0,0,t),null,z.groupD8.MAIN_DIAGONAL)}drawHoleRope(e,t,n){if(e.length===0)return null;const i=new z.SimpleRope(t,e,n/mt);this.addChild(i)}getHoleTexture(e,t,n){const i=mt,r=i,s=i,o=t/n*i;this.holeTextureCache||(this.holeTextureCache=Wu(e,s,r));const a=this.holeTextureCache.baseTexture,c=(r-o)/2,h=new z.Rectangle(0,c,s,o);return new z.Texture(a,h)}sortCementAndCasingRenderObjects(e,t,n){let i=0;const{result:r}=e.reduce((s,o)=>{const a=s.remainingCement.find(h=>h.casingIds.includes(o.id)),c=s.remainingCementSqueezes.filter(h=>h.casingIds.includes(o.id));return a&&(a.zIndex=i++),c.forEach(h=>h.zIndex=i++),o.zIndex=i++,{result:[...s.result,a,o,...c],remainingCement:s.remainingCement.filter(h=>h!==a),remainingCementSqueezes:s.remainingCementSqueezes.filter(h=>!c.includes(h))}},{result:[],remainingCement:t,remainingCementSqueezes:n});return r.filter(s=>s!==void 0).sort((s,o)=>s.zIndex-o.zIndex)}drawComplexRope(e,t){if(e.length===0)return null;const{exaggerationFactor:n}=this.options,i=new of(t,e,n);return this.addChild(i),i}createCasingTexture(e){return new z.Texture(z.Texture.WHITE.baseTexture,null,new z.Rectangle(0,0,16,e))}drawShoe(e,t){const{exaggerationFactor:n,casingOptions:i}=this.options,r=i.shoeSize.width*n,s=i.shoeSize.length*n,o=this.generateShoe(e,t,s,r),a=this.generateShoe(e,t,s,-r);this.drawBigPolygon(a),this.drawBigPolygon(o)}getCementTexture(){if(!this.cementTextureCache){const{cementOptions:e}=this.options;this.cementTextureCache=Xu(e)}return this.cementTextureCache}getCementSqueezeTexture(){if(!this.cementSqueezeTextureCache){const{cementSqueezeOptions:e}=this.options;this.cementSqueezeTextureCache=qu(e)}return this.cementSqueezeTextureCache}drawScreen({start:e,end:t,diameter:n}){const{exaggerationFactor:i,screenOptions:r}=this.options,s=i*n,o=this.getZFactorScaledPathForPoints(e,t),{leftPath:a,rightPath:c}=Fe(s/2,o),h=this.getScreenTexture();this.drawCompletionRope(o,h,s),this.drawOutline(a,c,dt(r.lineColor),xl*i,"TopAndBottom")}drawTubing({diameter:e,start:t,end:n}){const{exaggerationFactor:i,tubingOptions:r}=this.options,s=i*e,o=this.getZFactorScaledPathForPoints(t,n),a=this.getTubingTexture(r);this.drawCompletionRope(o,a,s)}getTubingTexture(e){return this.tubingTextureCache||(this.tubingTextureCache=Gu(e)),this.tubingTextureCache}getScreenTexture(){if(!this.screenTextureCache){const{screenOptions:e}=this.options;this.screenTextureCache=Yu(e)}return this.screenTextureCache}drawCompletionRope(e,t,n){if(e.length===0)return;const i=new cf(t,e,n);this.addChild(i)}};let ts=Jr;ts.getOutlineClosureType=(e,t)=>e===0?e===t?"TopAndBottom":"Top":e===t?"Bottom":"None";class df extends yt{onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.clearCanvas(),this.render()}onRescale(t){super.onRescale(t),this.setTransform(t),this.render()}render(){if(!this.data||!this.ctx||!this.data.image)return;const{ctx:t}=this,{options:n,image:i}=this.data;this.clearCanvas(),t.drawImage(i,n.x,n.y,n.width,n.height)}}function Ot(e){return function(){return e}}const es=1e-12,Vn=Math.PI,Un=2*Vn,Pt=1e-6,gf=Un-Pt;function ns(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function pf(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return ns;const n=10**t;return function(i){this._+=i[0];for(let r=1,s=i.length;r<s;++r)this._+=Math.round(arguments[r]*n)/n+i[r]}}class mf{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?ns:pf(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,i,r){this._append`Q${+t},${+n},${this._x1=+i},${this._y1=+r}`}bezierCurveTo(t,n,i,r,s,o){this._append`C${+t},${+n},${+i},${+r},${this._x1=+s},${this._y1=+o}`}arcTo(t,n,i,r,s){if(t=+t,n=+n,i=+i,r=+r,s=+s,s<0)throw new Error(`negative radius: ${s}`);let o=this._x1,a=this._y1,c=i-t,h=r-n,l=o-t,u=a-n,f=l*l+u*u;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(f>Pt)if(!(Math.abs(u*c-h*l)>Pt)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let g=i-o,d=r-a,p=c*c+h*h,y=g*g+d*d,_=Math.sqrt(p),x=Math.sqrt(f),v=s*Math.tan((Vn-Math.acos((p+f-y)/(2*_*x)))/2),C=v/x,b=v/_;Math.abs(C-1)>Pt&&this._append`L${t+C*l},${n+C*u}`,this._append`A${s},${s},0,0,${+(u*g>l*d)},${this._x1=t+b*c},${this._y1=n+b*h}`}}arc(t,n,i,r,s,o){if(t=+t,n=+n,i=+i,o=!!o,i<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(r),c=i*Math.sin(r),h=t+a,l=n+c,u=1^o,f=o?r-s:s-r;this._x1===null?this._append`M${h},${l}`:(Math.abs(this._x1-h)>Pt||Math.abs(this._y1-l)>Pt)&&this._append`L${h},${l}`,i&&(f<0&&(f=f%Un+Un),f>gf?this._append`A${i},${i},0,1,${u},${t-a},${n-c}A${i},${i},0,1,${u},${this._x1=h},${this._y1=l}`:f>Pt&&this._append`A${i},${i},0,${+(f>=Vn)},${u},${this._x1=t+i*Math.cos(s)},${this._y1=n+i*Math.sin(s)}`)}rect(t,n,i,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}}function yf(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const i=Math.floor(n);if(!(i>=0))throw new RangeError(`invalid digits: ${n}`);t=i}return e},()=>new mf(t)}function _f(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function is(e){this._context=e}is.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function rs(e){return new is(e)}function xf(e){return e[0]}function vf(e){return e[1]}function wf(e,t){var n=Ot(!0),i=null,r=rs,s=null,o=yf(a);e=typeof e=="function"?e:e===void 0?xf:Ot(e),t=typeof t=="function"?t:t===void 0?vf:Ot(t);function a(c){var h,l=(c=_f(c)).length,u,f=!1,g;for(i==null&&(s=r(g=o())),h=0;h<=l;++h)!(h<l&&n(u=c[h],h,c))===f&&((f=!f)?s.lineStart():s.lineEnd()),f&&s.point(+e(u,h,c),+t(u,h,c));if(g)return s=null,g+""||null}return a.x=function(c){return arguments.length?(e=typeof c=="function"?c:Ot(+c),a):e},a.y=function(c){return arguments.length?(t=typeof c=="function"?c:Ot(+c),a):t},a.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Ot(!!c),a):n},a.curve=function(c){return arguments.length?(r=c,i!=null&&(s=r(i)),a):r},a.context=function(c){return arguments.length?(c==null?i=s=null:s=r(i=c),a):i},a}function ss(){}function Wn(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Oe(e){this._context=e}Oe.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:Wn(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);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:Wn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function bf(e){return new Oe(e)}function os(e){this._context=e}os.prototype={areaStart:ss,areaEnd:ss,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);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Wn(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Sf(e){return new os(e)}function as(e,t){this._basis=new Oe(e),this._beta=t}as.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var i=e[0],r=t[0],s=e[n]-i,o=t[n]-r,a=-1,c;++a<=n;)c=a/n,this._basis.point(this._beta*e[a]+(1-this._beta)*(i+c*s),this._beta*t[a]+(1-this._beta)*(r+c*o));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}};const Tf=function e(t){function n(i){return t===1?new Oe(i):new as(i,t)}return n.beta=function(i){return e(+i)},n}(.85);function cs(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function Yn(e,t){this._context=e,this._k=(1-t)/6}Yn.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:cs(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:cs(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const Mf=function e(t){function n(i){return new Yn(i,t)}return n.tension=function(i){return e(+i)},n}(0);function Af(e,t,n){var i=e._x1,r=e._y1,s=e._x2,o=e._y2;if(e._l01_a>es){var a=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,c=3*e._l01_a*(e._l01_a+e._l12_a);i=(i*a-e._x0*e._l12_2a+e._x2*e._l01_2a)/c,r=(r*a-e._y0*e._l12_2a+e._y2*e._l01_2a)/c}if(e._l23_a>es){var h=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,l=3*e._l23_a*(e._l23_a+e._l12_a);s=(s*h+e._x1*e._l23_2a-t*e._l12_2a)/l,o=(o*h+e._y1*e._l23_2a-n*e._l12_2a)/l}e._context.bezierCurveTo(i,r,s,o,e._x2,e._y2)}function hs(e,t){this._context=e,this._alpha=t}hs.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);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:Af(this,e,t);break}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=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const Pf=function e(t){function n(i){return t?new hs(i,t):new Yn(i,0)}return n.alpha=function(i){return e(+i)},n}(.5);function ls(e){return e<0?-1:1}function us(e,t,n){var i=e._x1-e._x0,r=t-e._x1,s=(e._y1-e._y0)/(i||r<0&&-0),o=(n-e._y1)/(r||i<0&&-0),a=(s*r+o*i)/(i+r);return(ls(s)+ls(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(a))||0}function fs(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Gn(e,t,n){var i=e._x0,r=e._y0,s=e._x1,o=e._y1,a=(s-i)/3;e._context.bezierCurveTo(i+a,r+a*t,s-a,o-a*n,s,o)}function Ne(e){this._context=e}Ne.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:Gn(this,this._t0,fs(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Gn(this,fs(this,n=us(this,e,t)),n);break;default:Gn(this,this._t0,n=us(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function ds(e){this._context=new gs(e)}(ds.prototype=Object.create(Ne.prototype)).point=function(e,t){Ne.prototype.point.call(this,t,e)};function gs(e){this._context=e}gs.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,i,r,s){this._context.bezierCurveTo(t,e,i,n,s,r)}};function Cf(e){return new Ne(e)}function Lf(e){return new ds(e)}function ps(e){this._context=e}ps.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var i=ms(e),r=ms(t),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(i[0][s],r[0][s],i[1][s],r[1][s],e[o],t[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function ms(e){var t,n=e.length-1,i,r=new Array(n),s=new Array(n),o=new Array(n);for(r[0]=0,s[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)r[t]=1,s[t]=4,o[t]=4*e[t]+2*e[t+1];for(r[n-1]=2,s[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)i=r[t]/s[t-1],s[t]-=i,o[t]-=i*o[t-1];for(r[n-1]=o[n-1]/s[n-1],t=n-2;t>=0;--t)r[t]=(o[t]-r[t+1])/s[t];for(s[n-1]=(e[n]+r[n-1])/2,t=0;t<n-1;++t)s[t]=2*e[t+1]-r[t+1];return[r,s]}function kf(e){return new ps(e)}function $e(e,t){this._context=e,this._t=t}$e.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&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function Ef(e){return new $e(e,.5)}function Rf(e){return new $e(e,0)}function Ff(e){return new $e(e,1)}const zf=.7,Df=.9,Of=1;class Nf extends mr{constructor(t,n){super(t,n),this.options={...this.options,...n},this.render=this.render.bind(this)}onUpdate(t){super.onUpdate(t),this.render()}onRescale(t){super.onRescale(t),this.elm&&(this.rescaleEvent=t,this.render())}render(){const{strokeWidth:t,stroke:n}=this.options;if(!this.elm)return;this.elm.select("g").remove();const i=this.data||this.referenceSystem&&this.referenceSystem.projectedPath;!i||!this.rescaleEvent||this.elm.append("g").attr("class","well-path").append("path").attr("d",this.renderWellborePath(i)).attr("stroke-width",t||"2px").attr("stroke",n||"red").attr("fill","none")}renderWellborePath(t){const{xScale:n,yScale:i}=this.rescaleEvent,r=t.map(c=>[n(c[0]),i(c[1])]);let s;const{curveType:o,tension:a}=this.options;switch(o){default:case"curveCatmullRom":s=Pf.alpha(a||zf);break;case"curveLinear":s=rs;break;case"curveBasis":s=bf;break;case"curveBasisClosed":s=Sf;break;case"curveBundle":s=Tf.beta(a||Of);break;case"curveCardinal":s=Mf.tension(a||Df);break;case"curveMonotoneX":s=Cf;break;case"curveMonotoneY":s=Lf;break;case"curveNatural":s=kf;break;case"curveStep":s=Ef;break;case"curveStepAfter":s=Ff;break;case"curveStepBefore":s=Rf;break}return wf().curve(s)(r)}}const ys=(e,t)=>{switch(t.lineType){case"wavy":return e.wavy(t);case"dashed":return e.dashed(t);case"solid":return e.solid(t);default:return Qt(t.lineType)}};class $f extends yt{constructor(){super(...arguments),this.yScale=null,this.xScale=null}onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.clearCanvas(),this.render()}onRescale(t){super.onRescale(t),this.yScale=t.yScale,this.xScale=t.xScale,this.resetTransform(),this.render()}drawDashed(t){const{ctx:n}=this,{canvas:i}=this,r=this.yScale(t.depth);n.save(),n.strokeStyle=t.color,this.setCtxLineStyle(n,t),this.setCtxLineWidth(n,t),n.beginPath(),n.moveTo(0,r),n.lineTo(i.width,r),n.stroke(),n.restore(),t.text&&this.drawText(n,t,n.canvas.width,r)}drawSolid(t){const{ctx:n}=this,{canvas:i}=this,r=this.yScale(t.depth);n.save(),n.strokeStyle=t.color,this.setCtxLineStyle(n,t),this.setCtxLineWidth(n,t),n.beginPath(),n.moveTo(0,r),n.lineTo(i.width,r),n.stroke(),n.restore(),t.text&&this.drawText(n,t,n.canvas.width,r)}drawWavy(t){const{ctx:s}=this,{canvas:o}=this,a=Le(4,2.5,500,this.yScale),c=a*2,h=this.yScale(t.depth)-a,l=Math.ceil(o.width/c)+1,u=this.xScale(0)%c;s.save(),s.strokeStyle=t.color,this.setCtxLineStyle(s,t),this.setCtxLineWidth(s,t);for(let f=-1;f<l;f++)s.beginPath(),s.arc(f*c+u+a,h,a,0,Math.PI),s.stroke();s.restore(),t.text&&this.drawText(s,t,s.canvas.width,h)}drawText(t,n,i,r){const s=n.textColor||"#000",o=n.fontSize||"10px sans-serif",a=10;t.save(),t.strokeStyle=s,t.font=o,t.textAlign="end",t.textBaseline="bottom",t.fillText(n.text,i-a,r),t.restore()}setCtxLineStyle(t,n){ys({solid:()=>{t.setLineDash([])},dashed:()=>{t.setLineDash([8,10])},wavy:()=>{t.setLineDash([])}},n)}setCtxLineWidth(t,n){t.lineWidth=n.lineWidth||1}render(){!this.ctx||!this.yScale||!this.xScale||requestAnimationFrame(()=>{var t;this.clearCanvas(),(t=this.data)==null||t.forEach(n=>{ys({solid:i=>this.drawSolid(i),dashed:i=>this.drawDashed(i),wavy:i=>this.drawWavy(i)},n)})})}}class _s{constructor(t,n,i){if(this.layers=[],this.createAxis=r=>{const{container:s}=this;this._svgContainer=q(s).append("div").attr("class","axis").style("position","absolute").style("z-index","10").style("pointer-events","none");const o=this._svgContainer.append("svg").attr("height",`${s.offsetHeight}px`).attr("width",`${s.offsetWidth}px`),a=!0;return new Pi(o,a,r.xLabel,r.yLabel,r.unitOfMeasure)},this.container=t,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 fr(t,r=>this.rescale(r)),n){const{xMin:r,xMax:s,yMin:o,yMax:a,xBounds:c,yBounds:h}=n;r!==void 0&&s!==void 0&&o!==void 0&&a!==void 0&&this._zoomPanHandler.setBounds([r,s],[o,a]),c&&h&&this._zoomPanHandler.setBounds(c,h)}else this._zoomPanHandler.setBounds([0,1],[0,1]);i&&(this._axis=this.createAxis(i)),this.rescale=this.rescale.bind(this)}addLayers(t){return t.forEach(n=>this.addLayer(n)),this}getLayers(){return this.layers}clearAllData(t=!0){return this.layers.forEach(n=>n.clearData(t)),this}addLayer(t,n){return this.layers.push(t),this.initLayer(t,n),this}removeLayer(t){const n=this.layers.find(i=>i.id===t);return n&&(n.onUnmount(),this.layers=this.layers.filter(i=>i.id!==t)),this}removeAllLayers(){const{layers:t}=this;return t.forEach(n=>{this.removeLayer(n.id)}),this}getLayer(t){return this.layers.find(n=>n.id===t||n.getInternalLayerIds().includes(t))}initLayer(t,n){const i={elm:this.layerContainer};t.onMount(i);const r=this.zoomPanHandler.currentStateAsEvent();if(t.onUpdate({...r,...n}),t.onRescale(r),this._svgContainer){const s=this.layers.length>0?this.layers.reduce((o,a)=>o.order>a.order?o:a).order:1;this._svgContainer.style("z-index",`${s+1}`)}return this}showLayer(t){const n=this.getLayer(t);return n?(n.setVisibility(!0,t),n.onRescale(this.zoomPanHandler.currentStateAsEvent()),this):this}hideLayer(t){const n=this.getLayer(t);return n?(n.setVisibility(!1,t),n.onRescale(this.zoomPanHandler.currentStateAsEvent()),this):this}adjustToSize(t,n){const i=Math.max(this._axis?t-dr:t,0),r=Math.max(this._axis?n-gr:n,0);if(this._axis){const s={width:t,height:n};this._axis.onResize(s)}if(this.layers){const s={width:i,height:r};this.layers.forEach(o=>o.onResize(s))}this._zoomPanHandler&&this._zoomPanHandler.adjustToSize(i,r,!0)}setReferenceSystem(t){this.layers.forEach(n=>n.referenceSystem=t)}showAxis(){return this._axis.show(),this}hideAxis(){return this._axis.hide(),this}showAxisLabels(){return this._axis.showLabels(),this}hideAxisLabels(){return this._axis.hideLabels(),this}setAxisOffset(t,n){return this._axis.offsetX=t,this._axis.offsetY=n,this.layers.filter(r=>r instanceof ke).forEach(r=>{r.offsetX=t,r.offsetY=n}),this}setXAxisOffset(t){return this._axis.offsetX=t,this.layers.filter(i=>i instanceof ke).forEach(i=>{i.offsetX=t}),this}setYAxisOffset(t){return this._axis.offsetY=t,this.layers.filter(i=>i instanceof ke).forEach(i=>{i.offsetY=t}),this}setZoomLevelBoundary(t){return this._zoomPanHandler.setZoomLevelBoundary(t),this}setMaxZoomLevel(t){return this._zoomPanHandler.setMaxZoomLevel(t),this}setMinZoomLevel(t){return this._zoomPanHandler.setMinZoomLevel(t),this}destroy(){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}get zoomPanHandler(){return this._zoomPanHandler}get axis(){return this._axis}rescale(t){this._axis&&this._axis.onRescale(t),this.layers&&this.layers.forEach(n=>n.isVisible===!0?n.onRescale(t):{})}}class Bf{constructor(t,n){this.elements={},this.listeners={},this.enabled=!0;const i=q(n);this.elm=i.append("div").attr("id","overlay").style("z-index","11").style("position","absolute"),this.source=this.elm.node();const{elm:r}=this;r.on("resize",s=>{const{width:o,height:a}=s.detail;r.style("width",`${o}px`).style("height",`${a}px`),this.enabled&&Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]||null,l=this.listeners[c];l&&l.onResize&&requestAnimationFrame(()=>l.onResize({target:h,source:this.source,caller:t,width:o,height:a}))})}),r.on("mousemove",s=>{if(!this.enabled)return;const[o,a]=pt(s,this.elm.node());Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]||null,l=this.listeners[c];l&&l.onMouseMove&&requestAnimationFrame(()=>l.onMouseMove({x:o,y:a,target:h,source:this.source,caller:t}))})}),r.on("mouseout",()=>{this.enabled&&Object.keys(this.listeners).forEach(s=>{const o=this.elements[s]||null,a=this.listeners[s];a&&a.onMouseExit&&requestAnimationFrame(()=>a.onMouseExit({target:o,source:this.source,caller:t}))})})}create(t,n){const i=this.elm.append("div").style("position","relative").style("pointer-events","none").node();return this.elements[t]=i,n&&(this.listeners[t]=n),i}register(t,n){this.listeners[t]=n}remove(t){const n=this.elements[t];n&&(q(n).remove(),delete this.elements[t]),delete this.listeners[t]}setZIndex(t){this.elm.style("z-index",t)}destroy(){this.source.remove()}}const If=(e,t)=>new Bf(e,t);class Hf{constructor(t){const{container:n,axisOptions:i,scaleOptions:r,referenceSystem:s,layers:o,path:a}=t;this._referenceSystem=s||a&&new Ft(a),this._overlay=If(this,n),this.layerManager=new _s(this._overlay.elm.node(),r,i),o&&(this.layerManager.addLayers(o),this.setOverlayZIndex(o))}setReferenceSystem(t){return this._referenceSystem=t,this.layerManager.setReferenceSystem(t),this}updatePath(t,n){return this.setReferenceSystem(new Ft(t,n)),this}clearAllData(t=!0){return this.layerManager.clearAllData(t),this}addLayer(t,n){return this.layerManager.addLayer(t,n),this.setOverlayZIndex(this.layerManager.getLayers()),this}removeLayer(t){return this.layerManager.removeLayer(t),this}removeAllLayers(){return this.layerManager.removeAllLayers(),this}getLayer(t){return this.layerManager.getLayer(t)}showLayer(t){return this.layerManager.showLayer(t),this}hideLayer(t){return this.layerManager.hideLayer(t),this}adjustToSize(t,n){this.layerManager.adjustToSize(t,n);const i={width:Math.max(t-dr,0),height:Math.max(n-gr,0)};return this.overlay.elm.dispatch("resize",{detail:i,bubbles:!0,cancelable:!0}),this}setViewport(t,n,i,r){return this.zoomPanHandler.setViewport(t,n,i,r),this}setBounds(t,n){return this.zoomPanHandler.setBounds(t,n),this}showAxis(){return this.layerManager.showAxis(),this}hideAxis(){return this.layerManager.hideAxis(),this}showAxisLabels(){return this.layerManager.showAxisLabels(),this}hideAxisLabels(){return this.layerManager.hideAxisLabels(),this}setAxisOffset(t,n){return this.layerManager.setAxisOffset(t,n),this}setXAxisOffset(t){return this.layerManager.setXAxisOffset(t),this}setYAxisOffset(t){return this.layerManager.setYAxisOffset(t),this}setZoomLevelBoundary(t){return this.zoomPanHandler.setZoomLevelBoundary(t),this}setMaxZoomLevel(t){return this.zoomPanHandler.setMaxZoomLevel(t),this}setMinZoomLevel(t){return this.zoomPanHandler.setMinZoomLevel(t),this}destroy(){return this.layerManager.destroy(),this._overlay.destroy(),this._referenceSystem=void 0,this.layerManager=void 0,this._overlay=void 0,this}getHighestZIndex(t){return t.length>0?t.reduce((i,r)=>i.order>r.order?i:r).order:1}setOverlayZIndex(t){const n=this.getHighestZIndex(t);this.overlay.setZIndex(n+2)}get overlay(){return this._overlay}get referenceSystem(){return this._referenceSystem}get zoomPanHandler(){return this.layerManager.zoomPanHandler}get axis(){return this.layerManager.axis}get currentStateAsEvent(){return this.zoomPanHandler.currentStateAsEvent()}}P.Axis=Pi,P.CalloutCanvasLayer=Ol,P.CanvasLayer=yt,P.Controller=Hf,P.GeomodelCanvasLayer=Hl,P.GeomodelLabelsLayer=Lu,P.GeomodelLayerV2=Eu,P.GridLayer=ke,P.HTMLLayer=bl,P.ImageLayer=Fu,P.IntersectionReferenceSystem=Ft,P.Layer=Kt,P.LayerManager=_s,P.PixiLayer=Pn,P.PixiRenderApplication=Sl,P.ReferenceLineLayer=$f,P.SVGLayer=mr,P.SchematicLayer=ts,P.SeismicCanvasLayer=df,P.WellborepathLayer=Nf,P.ZoomPanHandler=fr,P.assertNever=Qt,P.calcSize=Le,P.defaultCasingOptions=Cr,P.defaultCementOptions=kr,P.defaultCementPlugOptions=zr,P.defaultCementSqueezeOptions=Er,P.defaultHoleOptions=Pr,P.defaultInternalLayerOptions=Ar,P.defaultPerforationOptions=Lr,P.defaultScreenOptions=Rr,P.defaultTubingOptions=Fr,P.findIndexOfSample=kn,P.findSampleAtPos=_t,P.foldCompletion=vr,P.foldPerforationSubKind=Z,P.generateProjectedTrajectory=wu,P.generateProjectedWellborePath=vu,P.generateSeismicSliceImage=eu,P.generateSurfaceData=ru,P.getOverlap=Ll,P.getOverlapOffset=Ln,P.getPicksData=Yl,P.getSeismicInfo=tu,P.getSeismicOptions=Jl,P.hasFracLines=br,P.hasPacking=wr,P.hasSpikes=Sr,P.intersect=Cn,P.isCementPlug=xr,P.isCementSqueeze=_r,P.isOpenHoleFracPack=Pl,P.isOverlapping=$r,P.isOverlappingHorizontally=Cl,P.isPAndASymbol=yr,P.isSubKindCasedHoleFracPack=Mr,P.isSubKindPerforation=Al,P.isSubkindCasedHoleGravelPack=Tr,P.pixelsPerUnit=Nr,P.shouldPerforationStartAtCasingDiameter=Ml,P.shouldPerforationStartAtHoleDiameter=Tl,P.transformFormationData=Kl,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
14
+ ***************************************************************************** */var rn=function(e,t){return rn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var r in i)i.hasOwnProperty(r)&&(n[r]=i[r])},rn(e,t)},Et=function(){return Et=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Et.apply(this,arguments)};function jo(e,t){for(var n=0;n<e.length;n++)e[n]=t;return e}function qo(e,t){for(var n=0;n<e.length;n++)e[n]=t(e[n],n);return e}function Zo(e,t,n){n===void 0&&(n=0);for(var i=0;i<e.length;i++)n=t(n,e[i],i);return n}var W=Math.pow(2,-42);function ki(e){var t=Math.pow(Math.abs(e),.3333333333333333);return e<0?-t:t}function Ei(e,t,n){if(Math.abs(e)<W)return Math.abs(t)<W?[]:[-n/t];var i=t*t-4*e*n;return Math.abs(i)<W?[-t/(2*e)]:i>0?[(-t+Math.sqrt(i))/(2*e),(-t-Math.sqrt(i))/(2*e)]:[]}function Ko(e,t,n,i){if(Math.abs(e)<W)return Ei(t,n,i);var r,s=(3*e*n-t*t)/(3*e*e),o=(2*t*t*t-9*e*t*n+27*e*e*i)/(27*e*e*e);if(Math.abs(s)<W)r=[ki(-o)];else if(Math.abs(o)<W)r=[0].concat(s<0?[Math.sqrt(-s),-Math.sqrt(-s)]:[]);else{var a=o*o/4+s*s*s/27;if(Math.abs(a)<W)r=[-1.5*o/s,3*o/s];else if(a>0)r=[(c=ki(-o/2-Math.sqrt(a)))-s/(3*c)];else{var c=2*Math.sqrt(-s/3),h=Math.acos(3*o/s/c)/3,l=2*Math.PI/3;r=[c*Math.cos(h),c*Math.cos(h-l),c*Math.cos(h-2*l)]}}for(var u=0;u<r.length;u++)r[u]-=t/(3*e);return r}function fe(e,t,n,i,r,s,o){r===void 0&&(r=0),s===void 0&&(s=.5),o===void 0&&(o=[0,1,2,3]);var a=o[0],c=o[1],h=o[2],l=o[3],u=0,f=0;return c-h!=0&&(a-c!=0&&a-h!=0&&(u=(1-s)*(h-c)*((e-t)/(a-c)-(e-n)/(a-h)+(t-n)/(c-h))),c-l!=0&&h-l!=0&&(f=(1-s)*(h-c)*((t-n)/(c-h)-(t-i)/(c-l)+(n-i)/(h-l)))),[2*t-2*n+u+f,-3*t+3*n-2*u-f,u,t-r]}function sn(e,t,n,i,r,s,o){if(Math.abs(e)<W)return r;if(Math.abs(1-e)<W)return s;var a=e*e,c=e*a,h=fe(i,r,s,o,0,t,n);return h[0]*c+h[1]*a+h[2]*e+h[3]}function Qo(e,t,n,i,r,s,o){var a=e*e,c=fe(i,r,s,o,0,t,n);return 3*c[0]*a+2*c[1]*e+c[2]}function Ri(e,t){for(var n=0,i=0;i<e.length;i++)n+=(e[i]-t[i])*(e[i]-t[i]);return n}function Jo(e,t){var n=Ri(e,t);return n===0?0:Math.sqrt(n)}function on(e){var t=Zo(e,function(i,r){return i+Math.pow(r,2)}),n=Math.sqrt(t);return n===0?jo(e,0):qo(e,function(i){return i/n})}function ta(e){if(e.length>2)throw Error("Only supported for 2d vectors");var t=-e[1];return e[1]=e[0],e[0]=t,e}function ea(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e<t?t:e>n?n:e}function Fi(e,t){for(var n=new Array(e.length),i=0;i<e.length;i++)n[i]=2*e[i]+-1*t[i];return n}function de(e,t,n){var i,r,s,o,a=t.length-1;return n?(i=t[e-1<0?a:e-1],r=t[e%t.length],s=t[(e+1)%t.length],o=t[(e+2)%t.length]):(r=t[e],s=t[Math.min(a,e+1)],i=e>0?t[e-1]:Fi(r,s),o=e<a-1?t[e+2]:Fi(s,r)),[i,r,s,o]}function ge(e,t,n,i,r){if(r===void 0&&(r=0),r===0)return[0,1,2,3];var s=function(c,h){return Math.pow(Ri(c,h),.5*r)},o=s(t,e),a=s(n,t)+o;return[0,o,a,s(i,n)+a]}function Rt(e,t,n,i){n===void 0&&(n={});var r=Number.isFinite(n.tension)?n.tension:.5,s=Number.isFinite(n.alpha)?n.alpha:0,o=!!n.closed,a=n.func||sn,c=(o?t.length:t.length-1)*e,h=Math.floor(c),l=c-h,u=de(h,t,o),f=u[0],g=u[1],d=u[2],p=u[3];i=i||new Array(f.length);for(var y=ge(f,g,d,p,s),_=0;_<f.length;_++)i[_]=a(l,r,y,f[_],g[_],d[_],p[_]);return i}function an(e,t,n,i){n===void 0&&(n={});var r=Number.isFinite(n.tension)?n.tension:.5,s=Number.isFinite(n.alpha)?n.alpha:0,o=!!n.closed;return r===1&&e===0?e+=W:(r===1||s>0)&&e===1&&(e-=W),Rt(e,t,{tension:r,alpha:s,closed:o,func:Qo},i)}function cn(e,t,n){n===void 0&&(n={});var i,r=[],s=Rt(0,e,n),o=0;t=t||300,r.push(0);for(var a=1;a<=t;a++)o+=Jo(i=Rt(a/t,e,n),s),r.push(o),s=i;return r}function hn(e,t){for(var n,i=t.length,r=e*t[i-1],s=0,o=i-1,a=0;s<=o;)if((n=t[a=Math.floor(s+(o-s)/2)]-r)<0)s=a+1;else{if(!(n>0)){o=a;break}o=a-1}if(t[a=o]===r)return a/(i-1);var c=t[a];return(a+(r-c)/(t[a+1]-c))/(i-1)}function na(e,t){if(e===0)return 0;if(e===1)return 1;var n=t.length-1,i=t[n],r=e*n,s=Math.floor(r),o=t[s];return r===s?o/i:(o+(r-s)*(t[s+1]-o))/i}function zi(e,t,n,i,r,s,o){var a=fe(i,r,s,o,e,t,n),c=a[0],h=a[1],l=a[2],u=a[3];return c===0&&h===0&&l===0&&u===0?[0]:Ko(c,h,l,u).filter(function(f){return f>-W&&f<=1+W}).map(function(f){return ea(f,0,1)})}function ia(e,t,n){for(var i=Et({axis:0,tension:.5,alpha:0,closed:!1,margin:.5,max:0,processRefAxis:!1,func:sn},n),r=i.func,s=i.axis,o=i.tension,a=i.alpha,c=i.closed,h=i.margin,l=i.max,u=i.processRefAxis,f=s,g=[],d=c?t.length:t.length-1,p=0;p<d;p+=1){var y=l<0?d-(p+1):p,_=de(y,t,c),x=_[0],v=_[1],C=_[2],b=_[3],S=void 0,M=void 0;if(v[f]<C[f]?(S=v[f],M=C[f]):(S=C[f],M=v[f]),e-h<=M&&e+h>=S){var R=ge(x,v,C,b,a),F=zi(e,o,R,x[f],v[f],C[f],b[f]);l<0?F.sort(function(m,T){return T-m}):l>=0&&F.sort(function(m,T){return m-T});for(var O=0;O<F.length;O++)if(!(F[O]===0&&p>0)){for(var A=[],E=0;E<x.length;E++){var I=void 0;I=E!==f||u?r(F[O],o,R,x[E],v[E],C[E],b[E],y-1):e,A[E]=I}if(g.push(A),g.length===Math.abs(l))return g}}}return g}function ra(e,t,n){for(var i=Et({axis:0,tension:.5,alpha:0,closed:!1,margin:.5,max:0},n),r=i.axis,s=i.tension,o=i.alpha,a=i.closed,c=i.margin,h=i.max,l=r,u=new Set,f=n.arcLengths||cn(t,n.arcDivisions||300,{tension:s,alpha:o,closed:a}),g=a?t.length:t.length-1,d=0;d<g;d+=1){var p=h<0?t.length-d:d,y=de(p,t,a),_=y[0],x=y[1],v=y[2],C=y[3],b=void 0,S=void 0;x[l]<v[l]?(b=x[l],S=v[l]):(b=v[l],S=x[l]);var M=ge(_,x,v,C,o);if(e-c<=S&&e+c>=b){var R=zi(e,s,M,_[l],x[l],v[l],C[l]);h<0?R.sort(function(A,E){return E-A}):h>=0&&R.sort(function(A,E){return A-E});for(var F=0;F<R.length;F++)if(!(R[F]===0&&d>0)){var O=na((R[F]+p)/g,f);if(u.add(O),u.size===Math.abs(h))return Array.from(u)}}}return Array.from(u)}function sa(e,t){t===void 0&&(t={});for(var n=Et({tension:.5,alpha:0,closed:!1,from:0,to:1,arcDivisions:300},t),i=n.tension,r=n.alpha,s=n.closed,o=n.from,a=n.to,c=n.arcDivisions,h=s?e.length:e.length-1,l=t.arcLengths||cn(e,c,{tension:i,alpha:r,closed:s}),u=hn(o,l),f=hn(a,l),g=Math.floor(h*u),d=Math.ceil(h*f),p=Rt(u,e,{tension:i,alpha:r,closed:s}),y=Rt(f,e,{tension:i,alpha:r,closed:s}),_=[],x=[],v=0;v<p.length;v++)_[v]=Math.min(p[v],y[v]),x[v]=Math.max(p[v],y[v]);for(var C=function(S){var M=de(S-1,e,s),R=M[0],F=M[1],O=M[2],A=M[3];if(S<d)for(var E=0;E<O.length;E++)O[E]<_[E]&&(_[E]=O[E]),O[E]>x[E]&&(x[E]=O[E]);if(i<1){var I=h*u-(S-1),m=h*f-(S-1),T=function(L){return L>-W&&L<=1+W&&(S-1!==g||L>I)&&(S!==d||L<m)},w=ge(R,F,O,A,r),k=function(L){var D=fe(R[L],F[L],O[L],A[L],0,i,w);Ei(3*D[0],2*D[1],D[2]).filter(T).forEach(function(N){var $=sn(N,i,w,R[L],F[L],O[L],A[L]);$<_[L]&&(_[L]=$),$>x[L]&&(x[L]=$)})};for(E=0;E<R.length;E++)k(E)}},b=g+1;b<=d;b++)C(b);return{min:_,max:x}}var ln=function(){function e(t,n){n===void 0&&(n={}),n=Et({tension:.5,alpha:0,arcDivisions:300,closed:!1},n),this._cache={},this._tension=n.tension,this._alpha=n.alpha,this._arcDivisions=n.arcDivisions,this._lmargin=n.lmargin||1-this._tension,this._closed=n.closed,this.points=t}return e.prototype.getT=function(t){return hn(t,this.arcLengths)},e.prototype.getPointAt=function(t,n){var i={tension:this.tension,alpha:this.alpha,closed:this.closed};return Rt(this.getT(t),this.points,i,n)},e.prototype.getTangentAt=function(t,n){return n===void 0&&(n=null),on(an(this.getT(t),this.points,{tension:this.tension,alpha:this.alpha,closed:this.closed},n))},e.prototype.getBoundingBox=function(t,n){if(t===void 0&&(t=0),n===void 0&&(n=1),t===0&&n===1&&this._cache.bbox)return this._cache.bbox;var i=sa(this.points,{from:t,to:n,tension:this.tension,alpha:this.alpha,closed:this.closed,arcLengths:this.arcLengths});return t===0&&n===1&&(this._cache.bbox=i),i},e.prototype.getPoints=function(t,n,i,r){if(t===void 0&&(t=100),i===void 0&&(i=0),r===void 0&&(r=1),!t||t<=0)throw Error("Invalid arguments passed to getPoints(). You must specify at least 1 sample/segment.");if(!(i<0||r>1||r<i)){for(var s=[],o=0;o<=t;o++){var a=i===0&&r===1?o/t:i+o/t*(r-i);s.push(this.getPointAt(a,n&&new n))}return s}},e.prototype.lookup=function(t,n,i,r){n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=ia(t,this.points,{axis:n,tension:this.tension,alpha:this.alpha,closed:this.closed,max:i,margin:r});return Math.abs(i)===1&&s.length===1?s[0]:s},e.prototype.lookupPositions=function(t,n,i,r){return n===void 0&&(n=0),i===void 0&&(i=0),r===void 0&&(r=this._lmargin),ra(t,this.points,{axis:n,arcLengths:this.arcLengths,tension:this.tension,alpha:this.alpha,closed:this.closed,max:i,margin:r})},e.prototype.invalidateCache=function(){var t=this;return Object.keys(this._cache).forEach(function(n){delete t._cache[n]}),this},Object.defineProperty(e.prototype,"points",{get:function(){return this._points},set:function(t){this._points=t,this.invalidateCache()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tension",{get:function(){return this._tension},set:function(t){t!==this._tension&&(this._tension=t,this.invalidateCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){t!==this._alpha&&(this._alpha=t,this.invalidateCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},set:function(t){t!==this._closed&&(this._closed=t,this.invalidateCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"arcDivisions",{get:function(){return this._arcDivisions},set:function(t){t!==this._arcDivisions&&(this._arcDivisions=t,this.invalidateCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"arcLengths",{get:function(){if(this._cache.arcLengths)return this._cache.arcLengths;var t=cn(this.points,this.arcDivisions,{tension:this.tension,alpha:this.alpha,closed:this.closed});return this._cache.arcLengths=t,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){var t=this.arcLengths;return t[t.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minX",{get:function(){return this.getBoundingBox().min[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxX",{get:function(){return this.getBoundingBox().max[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minY",{get:function(){return this.getBoundingBox().min[1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxY",{get:function(){return this.getBoundingBox().max[1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minZ",{get:function(){return this.getBoundingBox().min[2]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxZ",{get:function(){return this.getBoundingBox().max[2]},enumerable:!1,configurable:!0}),e}();(function(e){function t(n,i,r,s,o){return i===void 0&&(i=.5),r===void 0&&(r=300),s===void 0&&(s=!1),o===void 0&&(o=0),e.call(this,n,{tension:i,alpha:o,arcDivisions:r,closed:s})||this}return function(n,i){function r(){this.constructor=n}rn(n,i),n.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}(t,e),t.prototype.x=function(n,i,r){i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=this.lookup(n,1,i,r);return Math.abs(i)===1?s[0]:s.map(function(o){return o[0]})},t.prototype.y=function(n,i,r){i===void 0&&(i=0),r===void 0&&(r=this._lmargin);var s=this.lookup(n,0,i,r);return Math.abs(i)===1?s[1]:s.map(function(o){return o[1]})},t.prototype.getNormalAt=function(n,i){return on(ta(an(this.getT(n),this.points,{tension:this.tension,alpha:this.alpha,closed:this.closed},i)))},t.prototype.getAngleAt=function(n){var i=an(this.getT(n),this.points,{tension:this.tension,alpha:this.alpha,closed:this.closed});return Math.atan2(i[1],i[0])},t.prototype.getBoundingBox=function(n,i){n===void 0&&(n=0),i===void 0&&(i=1);var r=e.prototype.getBoundingBox.call(this,n,i);return{x1:r.min[0],x2:r.max[0],y1:r.min[1],y2:r.max[1],min:r.min,max:r.max}},t})(ln);class pe{static newton(t,n=.01,i=1e3,r=.5,s=0,o=1){let c=r;for(let h=0;h<i;h++){const l=t(c);if(Math.abs(l)<n)return gt(c,s,o);const u=(t(c+1e-4)-l)/1e-4;c=c-l/u}return null}static bisect(t,n=.01,i=1e3,r=.5,s=0,o=1){let a=s,c=o,h=r,l,u;for(u=0;u<i;u++){if(l=t(h),Math.abs(l)<n)return h;l<0?c=h:a=h,h=(c+a)/2}return h}static findRoot(t,n=.01,i=1e3,r=.5,s=0,o=1){let a=pe.newton(t,n,i,r);return a==null&&(a=pe.bisect(t,n,i,r,s,o)),a}}class oa{static bisect(t,n=0,i=1,r=.005,s=4,o=10){const a=(f,g,d,p,y,_,x=0)=>{const v=(f+g)/2,C=t(v),b=B.distance(d,C),S=B.distance(C,p),M=b+S;if(x>=s&&Math.abs(M-y)<_||x>=o)return M;const R=_/2,F=x+1;return a(f,v,d,C,b,R,F)+a(v,g,C,p,S,R,F)},c=t(n),h=t(i),l=B.distance(c,h);return a(n,i,c,h,l,r)}static trapezoid(t,n=0,i=1,r=1e3){let s=0,o=t(n);const a=(i-n)/(r-1);for(let c=1;c<r;c++){const h=t(n+c*a),l=B.distance(o,h);s+=l,o=h}return s}}class aa{static search(t,n){let i=0,r=t.length-1,s=Math.floor(i+r/2);for(;s>i&&s<r;){const o=t[s],a=t[s+1];if(o<=n&&a>=n)return s;n<o?r=s:i=s,s=Math.floor(i+r/2)}return s}}class un extends ln{constructor(t,n){super(t,n),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)}findTForArcLength(t,n){let i;return n!=null&&n.approxT?i=this.findApproxTForArcLength(t,n==null?void 0:n.normalizedLength):n!=null&&n.quickT?i=this.findTQuickForArcLength(t):i=this.findTByRootForArcLength(t),i}findTByRootForArcLength(t,n=.01,i=100){return t<=0?0:t>=this.length?1:pe.findRoot(s=>t-this.getQuickArcLength(0,s),n,i,t/this.length)}findApproxTForArcLength(t,n){return t/(n||this.length)}findTQuickForArcLength(t){this.arcLengthLookup.length===0&&this.generateArcLengthLookup();const n=aa.search(this.arcLengthLookup,t),i=this.arcLengthLookup[n],r=this.arcLengthLookup[n+1];return(n+(t-i)/(r-i))/this.arcLengthLookup.length}generateArcLengthLookup(t=1e3){let n=this.getPointAt(0),i=0;for(let r=0;r<t;r++){const s=this.getPointAt(r/(t-1)),o=B.distance(n,s);i+=o,this.arcLengthLookup.push(i),n=s}}getArcLength(t=0,n=1){if(t===0&&n===1)return this.length;const i=.002;return oa.bisect(r=>this.getPointAt(r),t,n,i)}getQuickArcLength(t=0,n=1){let i=0,r=this.length;if(this.arcLengthLookup.length===0&&this.generateArcLengthLookup(),t!==0){const o=Math.floor(t*this.arcLengthLookup.length),a=this.arcLengthLookup[o],c=this.arcLengthLookup[o+1];i=a+t*this.arcLengthLookup.length%this.arcLengthLookup.length*(c-a)}if(n!==1){const o=Math.floor(n*this.arcLengthLookup.length),a=this.arcLengthLookup[o],c=this.arcLengthLookup[o+1];r=a+t*this.arcLengthLookup.length%this.arcLengthLookup.length*(c-a)}return r-i}getPointAtArcLength(t,n){const i=this.findTForArcLength(t,n);return this.getPointAt(i)}getPointAt(t){const n=gt(t,0,1);return super.getPointAt(n)}}const Di=.75,Oi=5e3,Ni=.001,ca=1e3,ha=1e3,la=5e-4,ua=.1,fa={approxT:!0};class Ft{constructor(t,n){if(this.path=[],this.projectedPath=[],this._offset=0,t.length<1)throw new Error("Missing coordinates");if(t[0]&&t[0].length!==3)throw new Error("Coordinates should be in 3d");this.setPath(t,n),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)}setPath(t,n={}){this.options={...fa,...n};const{arcDivisions:i,tension:r,calculateDisplacementFromBottom:s}=this.options;this.path=t,this.projectedPath=Ft.toDisplacement(t);const[o]=this.projectedPath[this.projectedPath.length-1];this.displacement=o,this.interpolators={curve:n.curveInterpolator||new un(t),trajectory:n.trajectoryInterpolator||new un(t.map(h=>[h[0],h[1]]),{tension:r||Di,arcDivisions:i||Oi}),curtain:n.curtainInterpolator||new un(this.projectedPath,{tension:r||Di,arcDivisions:i||Oi})};const a=this.getTrajectoryVector(),c=a.map(h=>h*-1);s?(this.endVector=c,this.startVector=a):(this.endVector=a,this.startVector=c),this._curtainPathCache=void 0}project(t){const{curtain:n}=this.interpolators,{calculateDisplacementFromBottom:i}=this.options,r=gt(i?this.length-(t-this._offset):t-this._offset,0,this.length);return n.getPointAtArcLength(r,this.options)}curtainTangent(t){const{curtain:n}=this.interpolators,i=t-this._offset,r=n.findTForArcLength(i,this.options);return r&&n.getTangentAt(r)}getCurtainPath(t,n,i=!1){if(!this._curtainPathCache){const r=[];let s=Math.PI*2;for(let o=this._offset;o<=this.length+this._offset;o+=ua){const a=this.project(o),c=Math.atan2(a[1],a[0]);Math.abs(c-s)>la&&(r.push({point:a,md:o}),s=c)}this._curtainPathCache=r}if(i){const r={point:this.project(t),md:t},s=this._curtainPathCache.filter(a=>a.md>t&&a.md<n),o={point:this.project(n),md:n};return[r,...s,o]}return this._curtainPathCache.filter(r=>r.md>=t&&r.md<=n)}unproject(t){const{normalizedLength:n,calculateDisplacementFromBottom:i}=this.options,r=i?this.displacement-t:t,s=n||this.length;if(r<0)return r;if(r>this.displacement)return s+(r-this.displacement);const o=this.interpolators.curtain.lookupPositions(r,0,1);return o&&o.length?o[0]*s+this._offset:null}getProjectedLength(t){const{curtain:n}=this.interpolators,r=this.project(t)[0]/n.maxX;return Number.isFinite(r)?gt(r,0,1):0}getPosition(t){const{trajectory:n}=this.interpolators,i=this.getProjectedLength(t);return n.getPointAt(i)}getTrajectory(t,n=0,i=1){const r=n<0?-n:0,s=i>1?i-1:0,o=this.interpolators.trajectory.getPointAt(0),a=this.interpolators.trajectory.getPointAt(1);let c,h,l=0;const u=Math.max(0,n),f=Math.min(1,i),g=this.interpolators.trajectory.getPointAt(u),d=this.interpolators.trajectory.getPointAt(f);r?(c=[o[0]+this.startVector[0]*r*this.displacement,o[1]+this.startVector[1]*r*this.displacement],l=-B.distance(c,o)):n>0&&(l=B.distance(g,o)),s&&(h=[a[0]+this.endVector[0]*s*this.displacement,a[1]+this.endVector[1]*s*this.displacement]);const p=[],y=i-n,_=Math.floor(r/y*t),x=Math.ceil((f-u)/y*t),v=t-x-_;if(c){p.push(c);for(let b=1;b<_;b++){const S=b/_*r*this.displacement;p.push([c[0]-this.startVector[0]*S,c[1]-this.startVector[1]*S])}}const C=this.interpolators.trajectory.getPoints(x-1,null,u,f);if(p.push(...C),h){for(let b=1;b<v-1;b++){const S=b/v*s*this.displacement;p.push([d[0]+this.endVector[0]*S,d[1]+this.endVector[1]*S])}p.push(h)}return{points:p,offset:l}}getExtendedTrajectory(t,n=ca,i=ha){if(!isFinite(n)||n<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive startExtensionLength parameter");if(!isFinite(i)||i<0)throw new Error("Invalid parameter, getExtendedTrajectory() must be called with a valid and positive endExtensionLength parameter");const r=this.displacement+n+i,s=Math.floor(n/r*t),o=Math.max(Math.ceil(this.displacement/r*t),1),a=t-o-s,c=[],h=new B(this.interpolators.trajectory.getPointAt(0)),l=new B(this.startVector),u=n/s;for(let x=s;x>0;x--){const v=x*u,C=h.add(l.scale(v));c.push(C.toArray())}const f=this.interpolators.trajectory.getPoints(o,null,0,1);c.push(...f);const g=new B(this.interpolators.trajectory.getPointAt(1)),d=new B(this.endVector),p=i/(a-1);for(let x=1;x<a;x++){const v=x*p,C=g.add(d.scale(v));c.push(C.toArray())}const y=-n;return{points:c,offset:y}}getTrajectoryVector(){const{trajectoryAngle:t,calculateDisplacementFromBottom:n}=this.options;if(isFinite(t)){const r=Io(t);return new B(Math.cos(r),Math.sin(r)).toArray()}return Ft.getDirectionVector(this.interpolators.trajectory,n?Ni:1-Ni,n?0:1)}static toDisplacement(t,n=0){let i=t[0],r=0;return t.map(o=>{const a=o[0]-i[0],c=o[1]-i[1];return r+=Math.sqrt(a**2+c**2),i=o,[n>0?n-r:r,o[2]||0]})}static getDirectionVector(t,n,i){const r=t.getPointAt(i),s=t.getPointAt(n);return on([r[0]-s[0],r[1]-s[1]])}get length(){return this.interpolators.curve.length}get offset(){return this._offset}set offset(t){this._curtainPathCache=void 0,this._offset=t}}var fn="http://www.w3.org/1999/xhtml";const $i={svg:"http://www.w3.org/2000/svg",xhtml:fn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function me(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),$i.hasOwnProperty(t)?{space:$i[t],local:e}:e}function da(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===fn&&t.documentElement.namespaceURI===fn?t.createElement(e):t.createElementNS(n,e)}}function ga(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Bi(e){var t=me(e);return(t.local?ga:da)(t)}function pa(){}function dn(e){return e==null?pa:function(){return this.querySelector(e)}}function ma(e){typeof e!="function"&&(e=dn(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=new Array(o),c,h,l=0;l<o;++l)(c=s[l])&&(h=e.call(c,c.__data__,l,s))&&("__data__"in c&&(h.__data__=c.__data__),a[l]=h);return new j(i,this._parents)}function ya(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function _a(){return[]}function Ii(e){return e==null?_a:function(){return this.querySelectorAll(e)}}function xa(e){return function(){return ya(e.apply(this,arguments))}}function va(e){typeof e=="function"?e=xa(e):e=Ii(e);for(var t=this._groups,n=t.length,i=[],r=[],s=0;s<n;++s)for(var o=t[s],a=o.length,c,h=0;h<a;++h)(c=o[h])&&(i.push(e.call(c,c.__data__,h,o)),r.push(c));return new j(i,r)}function Hi(e){return function(){return this.matches(e)}}function Vi(e){return function(t){return t.matches(e)}}var wa=Array.prototype.find;function ba(e){return function(){return wa.call(this.children,e)}}function Sa(){return this.firstElementChild}function Ta(e){return this.select(e==null?Sa:ba(typeof e=="function"?e:Vi(e)))}var Ma=Array.prototype.filter;function Aa(){return Array.from(this.children)}function Pa(e){return function(){return Ma.call(this.children,e)}}function Ca(e){return this.selectAll(e==null?Aa:Pa(typeof e=="function"?e:Vi(e)))}function La(e){typeof e!="function"&&(e=Hi(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,h=0;h<o;++h)(c=s[h])&&e.call(c,c.__data__,h,s)&&a.push(c);return new j(i,this._parents)}function Ui(e){return new Array(e.length)}function ka(){return new j(this._enter||this._groups.map(Ui),this._parents)}function ye(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ye.prototype={constructor:ye,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Ea(e){return function(){return e}}function Ra(e,t,n,i,r,s){for(var o=0,a,c=t.length,h=s.length;o<h;++o)(a=t[o])?(a.__data__=s[o],i[o]=a):n[o]=new ye(e,s[o]);for(;o<c;++o)(a=t[o])&&(r[o]=a)}function Fa(e,t,n,i,r,s,o){var a,c,h=new Map,l=t.length,u=s.length,f=new Array(l),g;for(a=0;a<l;++a)(c=t[a])&&(f[a]=g=o.call(c,c.__data__,a,t)+"",h.has(g)?r[a]=c:h.set(g,c));for(a=0;a<u;++a)g=o.call(e,s[a],a,s)+"",(c=h.get(g))?(i[a]=c,c.__data__=s[a],h.delete(g)):n[a]=new ye(e,s[a]);for(a=0;a<l;++a)(c=t[a])&&h.get(f[a])===c&&(r[a]=c)}function za(e){return e.__data__}function Da(e,t){if(!arguments.length)return Array.from(this,za);var n=t?Fa:Ra,i=this._parents,r=this._groups;typeof e!="function"&&(e=Ea(e));for(var s=r.length,o=new Array(s),a=new Array(s),c=new Array(s),h=0;h<s;++h){var l=i[h],u=r[h],f=u.length,g=Oa(e.call(l,l&&l.__data__,h,i)),d=g.length,p=a[h]=new Array(d),y=o[h]=new Array(d),_=c[h]=new Array(f);n(l,u,p,y,_,g,t);for(var x=0,v=0,C,b;x<d;++x)if(C=p[x]){for(x>=v&&(v=x+1);!(b=y[v])&&++v<d;);C._next=b||null}}return o=new j(o,i),o._enter=a,o._exit=c,o}function Oa(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Na(){return new j(this._exit||this._groups.map(Ui),this._parents)}function $a(e,t,n){var i=this.enter(),r=this,s=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),i&&r?i.merge(r).order():r}function Ba(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,s=i.length,o=Math.min(r,s),a=new Array(r),c=0;c<o;++c)for(var h=n[c],l=i[c],u=h.length,f=a[c]=new Array(u),g,d=0;d<u;++d)(g=h[d]||l[d])&&(f[d]=g);for(;c<r;++c)a[c]=n[c];return new j(a,this._parents)}function Ia(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Ha(e){e||(e=Va);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var o=n[s],a=o.length,c=r[s]=new Array(a),h,l=0;l<a;++l)(h=o[l])&&(c[l]=h);c.sort(t)}return new j(r,this._parents).order()}function Va(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ua(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Wa(){return Array.from(this)}function Ya(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function Ga(){let e=0;for(const t of this)++e;return e}function Xa(){return!this.node()}function ja(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],s=0,o=r.length,a;s<o;++s)(a=r[s])&&e.call(a,a.__data__,s,r);return this}function qa(e){return function(){this.removeAttribute(e)}}function Za(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ka(e,t){return function(){this.setAttribute(e,t)}}function Qa(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Ja(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function ec(e,t){var n=me(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?Za:qa:typeof t=="function"?n.local?tc:Ja:n.local?Qa:Ka)(n,t))}function Wi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function nc(e){return function(){this.style.removeProperty(e)}}function ic(e,t,n){return function(){this.style.setProperty(e,t,n)}}function rc(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function sc(e,t,n){return arguments.length>1?this.each((t==null?nc:typeof t=="function"?rc:ic)(e,t,n??"")):zt(this.node(),e)}function zt(e,t){return e.style.getPropertyValue(t)||Wi(e).getComputedStyle(e,null).getPropertyValue(t)}function oc(e){return function(){delete this[e]}}function ac(e,t){return function(){this[e]=t}}function cc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function hc(e,t){return arguments.length>1?this.each((t==null?oc:typeof t=="function"?cc:ac)(e,t)):this.node()[e]}function Yi(e){return e.trim().split(/^|\s+/)}function gn(e){return e.classList||new Gi(e)}function Gi(e){this._node=e,this._names=Yi(e.getAttribute("class")||"")}Gi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Xi(e,t){for(var n=gn(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function ji(e,t){for(var n=gn(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function lc(e){return function(){Xi(this,e)}}function uc(e){return function(){ji(this,e)}}function fc(e,t){return function(){(t.apply(this,arguments)?Xi:ji)(this,e)}}function dc(e,t){var n=Yi(e+"");if(arguments.length<2){for(var i=gn(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?fc:t?lc:uc)(n,t))}function gc(){this.textContent=""}function pc(e){return function(){this.textContent=e}}function mc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function yc(e){return arguments.length?this.each(e==null?gc:(typeof e=="function"?mc:pc)(e)):this.node().textContent}function _c(){this.innerHTML=""}function xc(e){return function(){this.innerHTML=e}}function vc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function wc(e){return arguments.length?this.each(e==null?_c:(typeof e=="function"?vc:xc)(e)):this.node().innerHTML}function bc(){this.nextSibling&&this.parentNode.appendChild(this)}function Sc(){return this.each(bc)}function Tc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Mc(){return this.each(Tc)}function Ac(e){var t=typeof e=="function"?e:Bi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Pc(){return null}function Cc(e,t){var n=typeof e=="function"?e:Bi(e),i=t==null?Pc:typeof t=="function"?t:dn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Lc(){var e=this.parentNode;e&&e.removeChild(this)}function kc(){return this.each(Lc)}function Ec(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Rc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fc(e){return this.select(e?Rc:Ec)}function zc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Dc(e){return function(t){e.call(this,t,this.__data__)}}function Oc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function Nc(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++i]=s;++i?t.length=i:delete this.__on}}}function $c(e,t,n){return function(){var i=this.__on,r,s=Dc(t);if(i){for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},i?i.push(r):this.__on=[r]}}function Bc(e,t,n){var i=Oc(e+""),r,s=i.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,h=a.length,l;c<h;++c)for(r=0,l=a[c];r<s;++r)if((o=i[r]).type===l.type&&o.name===l.name)return l.value}return}for(a=t?$c:Nc,r=0;r<s;++r)this.each(a(i[r],t,n));return this}function qi(e,t,n){var i=Wi(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Ic(e,t){return function(){return qi(this,e,t)}}function Hc(e,t){return function(){return qi(this,e,t.apply(this,arguments))}}function Vc(e,t){return this.each((typeof t=="function"?Hc:Ic)(e,t))}function*Uc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var Zi=[null];function j(e,t){this._groups=e,this._parents=t}function Yt(){return new j([[document.documentElement]],Zi)}function Wc(){return this}j.prototype=Yt.prototype={constructor:j,select:ma,selectAll:va,selectChild:Ta,selectChildren:Ca,filter:La,data:Da,enter:ka,exit:Na,join:$a,merge:Ba,selection:Wc,order:Ia,sort:Ha,call:Ua,nodes:Wa,node:Ya,size:Ga,empty:Xa,each:ja,attr:ec,style:sc,property:hc,classed:dc,text:yc,html:wc,raise:Sc,lower:Mc,append:Ac,insert:Cc,remove:kc,clone:Fc,datum:zc,on:Bc,dispatch:Vc,[Symbol.iterator]:Uc};function q(e){return typeof e=="string"?new j([[document.querySelector(e)]],[document.documentElement]):new j([[e]],Zi)}function Yc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function pt(e,t){if(e=Yc(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}var Gc={value:()=>{}};function pn(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new _e(n)}function _e(e){this._=e}function Xc(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}_e.prototype=pn.prototype={constructor:_e,on:function(e,t){var n=this._,i=Xc(e+"",n),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(e=i[s]).type)&&(r=jc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<o;)if(r=(e=i[s]).type)n[r]=Ki(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Ki(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new _e(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,s;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],i=0,r=s.length;i<r;++i)s[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)}};function jc(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function Ki(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=Gc,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}const mn={capture:!0,passive:!1};function yn(e){e.preventDefault(),e.stopImmediatePropagation()}function qc(e){var t=e.document.documentElement,n=q(e).on("dragstart.drag",yn,mn);"onselectstart"in t?n.on("selectstart.drag",yn,mn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Zc(e,t){var n=e.document.documentElement,i=q(e).on("dragstart.drag",null);t&&(i.on("click.drag",yn,mn),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Dt=0,Gt=0,Xt=0,Qi=1e3,xe,jt,ve=0,At=0,we=0,qt=typeof performance=="object"&&performance.now?performance:Date,Ji=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _n(){return At||(Ji(Kc),At=qt.now()+we)}function Kc(){At=0}function be(){this._call=this._time=this._next=null}be.prototype=tr.prototype={constructor:be,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?_n():+n)+(t==null?0:+t),!this._next&&jt!==this&&(jt?jt._next=this:xe=this,jt=this),this._call=e,this._time=n,xn()},stop:function(){this._call&&(this._call=null,this._time=1/0,xn())}};function tr(e,t,n){var i=new be;return i.restart(e,t,n),i}function Qc(){_n(),++Dt;for(var e=xe,t;e;)(t=At-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Dt}function er(){At=(ve=qt.now())+we,Dt=Gt=0;try{Qc()}finally{Dt=0,th(),At=0}}function Jc(){var e=qt.now(),t=e-ve;t>Qi&&(we-=t,ve=e)}function th(){for(var e,t=xe,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:xe=n);jt=e,xn(i)}function xn(e){if(!Dt){Gt&&(Gt=clearTimeout(Gt));var t=e-At;t>24?(e<1/0&&(Gt=setTimeout(er,e-qt.now()-we)),Xt&&(Xt=clearInterval(Xt))):(Xt||(ve=qt.now(),Xt=setInterval(Jc,Qi)),Dt=1,Ji(er))}}function nr(e,t,n){var i=new be;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var eh=pn("start","end","cancel","interrupt"),nh=[],ir=0,rr=1,vn=2,Se=3,sr=4,wn=5,Te=6;function Me(e,t,n,i,r,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;ih(e,n,{name:t,index:i,group:r,on:eh,tween:nh,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:ir})}function bn(e,t){var n=et(e,t);if(n.state>ir)throw new Error("too late; already scheduled");return n}function at(e,t){var n=et(e,t);if(n.state>Se)throw new Error("too late; already running");return n}function et(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function ih(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=tr(s,0,n.time);function s(h){n.state=rr,n.timer.restart(o,n.delay,n.time),n.delay<=h&&o(h-n.delay)}function o(h){var l,u,f,g;if(n.state!==rr)return c();for(l in i)if(g=i[l],g.name===n.name){if(g.state===Se)return nr(o);g.state===sr?(g.state=Te,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete i[l]):+l<t&&(g.state=Te,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete i[l])}if(nr(function(){n.state===Se&&(n.state=sr,n.timer.restart(a,n.delay,n.time),a(h))}),n.state=vn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===vn){for(n.state=Se,r=new Array(f=n.tween.length),l=0,u=-1;l<f;++l)(g=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=g);r.length=u+1}}function a(h){for(var l=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(c),n.state=wn,1),u=-1,f=r.length;++u<f;)r[u].call(e,l);n.state===wn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Te,n.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function Ae(e,t){var n=e.__transition,i,r,s=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((i=n[o]).name!==t){s=!1;continue}r=i.state>vn&&i.state<wn,i.state=Te,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[o]}s&&delete e.__transition}}function rh(e){return this.each(function(){Ae(this,e)})}function sh(e,t){var n,i;return function(){var r=at(this,e),s=r.tween;if(s!==n){i=n=s;for(var o=0,a=i.length;o<a;++o)if(i[o].name===t){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function oh(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=at(this,e),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:t,value:n},c=0,h=r.length;c<h;++c)if(r[c].name===t){r[c]=a;break}c===h&&r.push(a)}s.tween=r}}function ah(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=et(this.node(),n).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===e)return o.value;return null}return this.each((t==null?sh:oh)(n,e,t))}function Sn(e,t,n){var i=e._id;return e.each(function(){var r=at(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return et(r,i).value[t]}}function or(e,t){var n;return(typeof t=="number"?tt:t instanceof ht?It:(n=ht(t))?(t=n,It):ui)(e,t)}function ch(e){return function(){this.removeAttribute(e)}}function hh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lh(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttribute(e);return o===r?null:o===i?s:s=t(i=o,n)}}function uh(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttributeNS(e.space,e.local);return o===r?null:o===i?s:s=t(i=o,n)}}function fh(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function dh(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function gh(e,t){var n=me(e),i=n==="transform"?uo:or;return this.attrTween(e,typeof t=="function"?(n.local?dh:fh)(n,i,Sn(this,"attr."+e,t)):t==null?(n.local?hh:ch)(n):(n.local?uh:lh)(n,i,t))}function ph(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function mh(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function yh(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&mh(e,s)),n}return r._value=t,r}function _h(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&ph(e,s)),n}return r._value=t,r}function xh(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=me(e);return this.tween(n,(i.local?yh:_h)(i,t))}function vh(e,t){return function(){bn(this,e).delay=+t.apply(this,arguments)}}function wh(e,t){return t=+t,function(){bn(this,e).delay=t}}function bh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vh:wh)(t,e)):et(this.node(),t).delay}function Sh(e,t){return function(){at(this,e).duration=+t.apply(this,arguments)}}function Th(e,t){return t=+t,function(){at(this,e).duration=t}}function Mh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Sh:Th)(t,e)):et(this.node(),t).duration}function Ah(e,t){if(typeof t!="function")throw new Error;return function(){at(this,e).ease=t}}function Ph(e){var t=this._id;return arguments.length?this.each(Ah(t,e)):et(this.node(),t).ease}function Ch(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;at(this,e).ease=n}}function Lh(e){if(typeof e!="function")throw new Error;return this.each(Ch(this._id,e))}function kh(e){typeof e!="function"&&(e=Hi(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,h=0;h<o;++h)(c=s[h])&&e.call(c,c.__data__,h,s)&&a.push(c);return new lt(i,this._parents,this._name,this._id)}function Eh(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var c=t[a],h=n[a],l=c.length,u=o[a]=new Array(l),f,g=0;g<l;++g)(f=c[g]||h[g])&&(u[g]=f);for(;a<i;++a)o[a]=t[a];return new lt(o,this._parents,this._name,this._id)}function Rh(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Fh(e,t,n){var i,r,s=Rh(t)?bn:at;return function(){var o=s(this,e),a=o.on;a!==i&&(r=(i=a).copy()).on(t,n),o.on=r}}function zh(e,t){var n=this._id;return arguments.length<2?et(this.node(),n).on.on(e):this.each(Fh(n,e,t))}function Dh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Oh(){return this.on("end.remove",Dh(this._id))}function Nh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=dn(e));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a=i[o],c=a.length,h=s[o]=new Array(c),l,u,f=0;f<c;++f)(l=a[f])&&(u=e.call(l,l.__data__,f,a))&&("__data__"in l&&(u.__data__=l.__data__),h[f]=u,Me(h[f],t,n,f,h,et(l,n)));return new lt(s,this._parents,t,n)}function $h(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ii(e));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var c=i[a],h=c.length,l,u=0;u<h;++u)if(l=c[u]){for(var f=e.call(l,l.__data__,u,c),g,d=et(l,n),p=0,y=f.length;p<y;++p)(g=f[p])&&Me(g,t,n,p,f,d);s.push(f),o.push(l)}return new lt(s,o,t,n)}var Bh=Yt.prototype.constructor;function Ih(){return new Bh(this._groups,this._parents)}function Hh(e,t){var n,i,r;return function(){var s=zt(this,e),o=(this.style.removeProperty(e),zt(this,e));return s===o?null:s===n&&o===i?r:r=t(n=s,i=o)}}function ar(e){return function(){this.style.removeProperty(e)}}function Vh(e,t,n){var i,r=n+"",s;return function(){var o=zt(this,e);return o===r?null:o===i?s:s=t(i=o,n)}}function Uh(e,t,n){var i,r,s;return function(){var o=zt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),zt(this,e))),o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a))}}function Wh(e,t){var n,i,r,s="style."+t,o="end."+s,a;return function(){var c=at(this,e),h=c.on,l=c.value[s]==null?a||(a=ar(t)):void 0;(h!==n||r!==l)&&(i=(n=h).copy()).on(o,r=l),c.on=i}}function Yh(e,t,n){var i=(e+="")=="transform"?lo:or;return t==null?this.styleTween(e,Hh(e,i)).on("end.style."+e,ar(e)):typeof t=="function"?this.styleTween(e,Uh(e,i,Sn(this,"style."+e,t))).each(Wh(this._id,e)):this.styleTween(e,Vh(e,i,t),n).on("end.style."+e,null)}function Gh(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function Xh(e,t,n){var i,r;function s(){var o=t.apply(this,arguments);return o!==r&&(i=(r=o)&&Gh(e,o,n)),i}return s._value=t,s}function jh(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,Xh(e,t,n??""))}function qh(e){return function(){this.textContent=e}}function Zh(e){return function(){var t=e(this);this.textContent=t??""}}function Kh(e){return this.tween("text",typeof e=="function"?Zh(Sn(this,"text",e)):qh(e==null?"":e+""))}function Qh(e){return function(t){this.textContent=e.call(this,t)}}function Jh(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Qh(r)),t}return i._value=e,i}function tl(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Jh(e))}function el(){for(var e=this._name,t=this._id,n=cr(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,h=0;h<a;++h)if(c=o[h]){var l=et(c,t);Me(c,e,n,h,o,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new lt(i,this._parents,e,n)}function nl(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(s,o){var a={value:o},c={value:function(){--r===0&&s()}};n.each(function(){var h=at(this,i),l=h.on;l!==e&&(t=(e=l).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),h.on=t}),r===0&&s()})}var il=0;function lt(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function cr(){return++il}var ut=Yt.prototype;lt.prototype={constructor:lt,select:Nh,selectAll:$h,selectChild:ut.selectChild,selectChildren:ut.selectChildren,filter:kh,merge:Eh,selection:Ih,transition:el,call:ut.call,nodes:ut.nodes,node:ut.node,size:ut.size,empty:ut.empty,each:ut.each,on:zh,attr:gh,attrTween:xh,style:Yh,styleTween:jh,text:Kh,textTween:tl,remove:Oh,tween:ah,delay:bh,duration:Mh,ease:Ph,easeVarying:Lh,end:nl,[Symbol.iterator]:ut[Symbol.iterator]};function rl(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var sl={time:null,delay:0,duration:250,ease:rl};function ol(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function al(e){var t,n;e instanceof lt?(t=e._id,e=e._name):(t=cr(),(n=sl).time=_n(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,h=0;h<a;++h)(c=o[h])&&Me(c,e,t,h,o,n||ol(c,t));return new lt(i,this._parents,e,t)}Yt.prototype.interrupt=rh,Yt.prototype.transition=al;const Pe=e=>()=>e;function cl(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function ft(e,t,n){this.k=e,this.x=t,this.y=n}ft.prototype={constructor:ft,scale:function(e){return e===1?this:new ft(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ft(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Tn=new ft(1,0,0);ft.prototype;function Mn(e){e.stopImmediatePropagation()}function Zt(e){e.preventDefault(),e.stopImmediatePropagation()}function hl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function ll(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.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 hr(){return this.__zoom||Tn}function ul(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function fl(){return navigator.maxTouchPoints||"ontouchstart"in this}function dl(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function gl(){var e=hl,t=ll,n=dl,i=ul,r=fl,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=mo,h=pn("start","zoom","end"),l,u,f,g=500,d=150,p=0,y=10;function _(m){m.property("__zoom",hr).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",F).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",A).on("touchmove.zoom",E).on("touchend.zoom touchcancel.zoom",I).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(m,T,w,k){var L=m.selection?m.selection():m;L.property("__zoom",hr),m!==L?b(m,T,w,k):L.interrupt().each(function(){S(this,arguments).event(k).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},_.scaleBy=function(m,T,w,k){_.scaleTo(m,function(){var L=this.__zoom.k,D=typeof T=="function"?T.apply(this,arguments):T;return L*D},w,k)},_.scaleTo=function(m,T,w,k){_.transform(m,function(){var L=t.apply(this,arguments),D=this.__zoom,N=w==null?C(L):typeof w=="function"?w.apply(this,arguments):w,$=D.invert(N),H=typeof T=="function"?T.apply(this,arguments):T;return n(v(x(D,H),N,$),L,o)},w,k)},_.translateBy=function(m,T,w,k){_.transform(m,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof w=="function"?w.apply(this,arguments):w),t.apply(this,arguments),o)},null,k)},_.translateTo=function(m,T,w,k,L){_.transform(m,function(){var D=t.apply(this,arguments),N=this.__zoom,$=k==null?C(D):typeof k=="function"?k.apply(this,arguments):k;return n(Tn.translate($[0],$[1]).scale(N.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof w=="function"?-w.apply(this,arguments):-w),D,o)},k,L)};function x(m,T){return T=Math.max(s[0],Math.min(s[1],T)),T===m.k?m:new ft(T,m.x,m.y)}function v(m,T,w){var k=T[0]-w[0]*m.k,L=T[1]-w[1]*m.k;return k===m.x&&L===m.y?m:new ft(m.k,k,L)}function C(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function b(m,T,w,k){m.on("start.zoom",function(){S(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(k).end()}).tween("zoom",function(){var L=this,D=arguments,N=S(L,D).event(k),$=t.apply(L,D),H=w==null?C($):typeof w=="function"?w.apply(L,D):w,Y=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),V=L.__zoom,Q=typeof T=="function"?T.apply(L,D):T,it=c(V.invert(H).concat(Y/V.k),Q.invert(H).concat(Y/Q.k));return function(X){if(X===1)X=Q;else{var rt=it(X),Jt=Y/rt[2];X=new ft(Jt,H[0]-rt[0]*Jt,H[1]-rt[1]*Jt)}N.zoom(null,X)}})}function S(m,T,w){return!w&&m.__zooming||new M(m,T)}function M(m,T){this.that=m,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(m,T),this.taps=0}M.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,T){return this.mouse&&m!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var T=q(this.that).datum();h.call(m,this.that,new cl(m,{sourceEvent:this.sourceEvent,target:_,type:m,transform:this.that.__zoom,dispatch:h}),T)}};function R(m,...T){if(!e.apply(this,arguments))return;var w=S(this,T).event(m),k=this.__zoom,L=Math.max(s[0],Math.min(s[1],k.k*Math.pow(2,i.apply(this,arguments)))),D=pt(m);if(w.wheel)(w.mouse[0][0]!==D[0]||w.mouse[0][1]!==D[1])&&(w.mouse[1]=k.invert(w.mouse[0]=D)),clearTimeout(w.wheel);else{if(k.k===L)return;w.mouse=[D,k.invert(D)],Ae(this),w.start()}Zt(m),w.wheel=setTimeout(N,d),w.zoom("mouse",n(v(x(k,L),w.mouse[0],w.mouse[1]),w.extent,o));function N(){w.wheel=null,w.end()}}function F(m,...T){if(f||!e.apply(this,arguments))return;var w=m.currentTarget,k=S(this,T,!0).event(m),L=q(m.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",Y,!0),D=pt(m,w),N=m.clientX,$=m.clientY;qc(m.view),Mn(m),k.mouse=[D,this.__zoom.invert(D)],Ae(this),k.start();function H(V){if(Zt(V),!k.moved){var Q=V.clientX-N,it=V.clientY-$;k.moved=Q*Q+it*it>p}k.event(V).zoom("mouse",n(v(k.that.__zoom,k.mouse[0]=pt(V,w),k.mouse[1]),k.extent,o))}function Y(V){L.on("mousemove.zoom mouseup.zoom",null),Zc(V.view,k.moved),Zt(V),k.event(V).end()}}function O(m,...T){if(e.apply(this,arguments)){var w=this.__zoom,k=pt(m.changedTouches?m.changedTouches[0]:m,this),L=w.invert(k),D=w.k*(m.shiftKey?.5:2),N=n(v(x(w,D),k,L),t.apply(this,T),o);Zt(m),a>0?q(this).transition().duration(a).call(b,N,k,m):q(this).call(_.transform,N,k,m)}}function A(m,...T){if(e.apply(this,arguments)){var w=m.touches,k=w.length,L=S(this,T,m.changedTouches.length===k).event(m),D,N,$,H;for(Mn(m),N=0;N<k;++N)$=w[N],H=pt($,this),H=[H,this.__zoom.invert(H),$.identifier],L.touch0?!L.touch1&&L.touch0[2]!==H[2]&&(L.touch1=H,L.taps=0):(L.touch0=H,D=!0,L.taps=1+!!l);l&&(l=clearTimeout(l)),D&&(L.taps<2&&(u=H[0],l=setTimeout(function(){l=null},g)),Ae(this),L.start())}}function E(m,...T){if(this.__zooming){var w=S(this,T).event(m),k=m.changedTouches,L=k.length,D,N,$,H;for(Zt(m),D=0;D<L;++D)N=k[D],$=pt(N,this),w.touch0&&w.touch0[2]===N.identifier?w.touch0[0]=$:w.touch1&&w.touch1[2]===N.identifier&&(w.touch1[0]=$);if(N=w.that.__zoom,w.touch1){var Y=w.touch0[0],V=w.touch0[1],Q=w.touch1[0],it=w.touch1[1],X=(X=Q[0]-Y[0])*X+(X=Q[1]-Y[1])*X,rt=(rt=it[0]-V[0])*rt+(rt=it[1]-V[1])*rt;N=x(N,Math.sqrt(X/rt)),$=[(Y[0]+Q[0])/2,(Y[1]+Q[1])/2],H=[(V[0]+it[0])/2,(V[1]+it[1])/2]}else if(w.touch0)$=w.touch0[0],H=w.touch0[1];else return;w.zoom("touch",n(v(N,$,H),w.extent,o))}}function I(m,...T){if(this.__zooming){var w=S(this,T).event(m),k=m.changedTouches,L=k.length,D,N;for(Mn(m),f&&clearTimeout(f),f=setTimeout(function(){f=null},g),D=0;D<L;++D)N=k[D],w.touch0&&w.touch0[2]===N.identifier?delete w.touch0:w.touch1&&w.touch1[2]===N.identifier&&delete w.touch1;if(w.touch1&&!w.touch0&&(w.touch0=w.touch1,delete w.touch1),w.touch0)w.touch0[1]=this.__zoom.invert(w.touch0[0]);else if(w.end(),w.taps===2&&(N=pt(N,this),Math.hypot(u[0]-N[0],u[1]-N[1])<y)){var $=q(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return _.wheelDelta=function(m){return arguments.length?(i=typeof m=="function"?m:Pe(+m),_):i},_.filter=function(m){return arguments.length?(e=typeof m=="function"?m:Pe(!!m),_):e},_.touchable=function(m){return arguments.length?(r=typeof m=="function"?m:Pe(!!m),_):r},_.extent=function(m){return arguments.length?(t=typeof m=="function"?m:Pe([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),_):t},_.scaleExtent=function(m){return arguments.length?(s[0]=+m[0],s[1]=+m[1],_):[s[0],s[1]]},_.translateExtent=function(m){return arguments.length?(o[0][0]=+m[0][0],o[1][0]=+m[1][0],o[0][1]=+m[0][1],o[1][1]=+m[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(m){return arguments.length?(n=m,_):n},_.duration=function(m){return arguments.length?(a=+m,_):a},_.interpolate=function(m){return arguments.length?(c=m,_):c},_.on=function(){var m=h.on.apply(h,arguments);return m===h?_:m},_.clickDistance=function(m){return arguments.length?(p=(m=+m)*m,_):Math.sqrt(p)},_.tapDistance=function(m){return arguments.length?(y=+m,_):y},_}const pl=.1,ml=256;class lr{constructor(t,n,i={maxZoomLevel:ml,minZoomLevel:pl}){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.container=q(t),this.options=i,this.onRescale=n,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=Tt().domain(this.xBounds).range([0,1]),this.scaleY=Tt().domain(this.yBounds).range([0,1]),this.init()}get width(){return this.scaleX.range()[1]}get height(){return this.scaleY.range()[1]}get xSpan(){const{xBounds:t}=this;return Math.abs(t[1]-t[0])}get ySpan(){const{yBounds:t}=this;return Math.abs(t[1]-t[0])}get viewportRatio(){return this.width/(this.height||1)}get xRatio(){const t=this.scaleX.domain();return Math.abs(this.width/(t[1]-t[0]))}get yRatio(){const t=this.scaleY.domain();return Math.abs(this.height/(t[1]-t[0]))}get zFactor(){return this._zFactor}set zFactor(t){this._zFactor=t,this.recalculateZoomTransform()}get isXInverted(){return this.xBounds[1]<this.xBounds[0]}get isYInverted(){return this.yBounds[1]<this.yBounds[0]}get enableTranslateExtent(){return this._enableTranslateExtent}set enableTranslateExtent(t){this._enableTranslateExtent=t,this.updateTranslateExtent()}updateTranslateExtent(){const{width:t,xSpan:n,zFactor:i,enableTranslateExtent:r,translateBoundsX:s,translateBoundsY:o}=this;let a=-1/0,c=-1/0,h=1/0,l=1/0;if(r){const u=t/n;a=s[0]*u,h=s[1]*u,c=o[0]*u*i,l=o[1]*u*i}this.zoom.translateExtent([[a,c],[h,l]])}currentStateAsEvent(){const{scaleX:t,scaleY:n,xBounds:i,yBounds:r,zFactor:s,viewportRatio:o,currentTransform:a,xRatio:c,yRatio:h,width:l,height:u}=this;return{xScale:t.copy(),yScale:n.copy(),xBounds:i,yBounds:r,zFactor:s,viewportRatio:o,xRatio:c,yRatio:h,width:l,height:u,transform:Object.assign({},a)}}rescale(){const{currentStateAsEvent:t}=this;this.onRescale(t())}init(){this.zoom=gl().scaleExtent([this.options.minZoomLevel,this.options.maxZoomLevel]).on("zoom",this.onZoom),this.container.call(this.zoom)}onZoom(t){const{transform:n}=t;n&&(this.applyTransform(n),this.rescale())}applyTransform(t){const{width:n,scaleX:i,scaleY:r,xSpan:s,xBounds:o,yBounds:a,zFactor:c}=this,{viewportRatio:h,isXInverted:l,isYInverted:u}=this,f=n*t.k,g=s/f,d=s/t.k,p=d/c/h,y=g*t.x,_=g/c*t.y,x=o[0]-(l?-y:y),v=a[0]-(u?-_:_);i.domain([x,x+(l?-d:d)]),r.domain([v,v+(u?-p:p)]),this.currentTransform=t}setViewport(t,n,i,r){const{zoom:s,container:o,calculateTransform:a,scaleX:c,scaleY:h,isXInverted:l}=this;if(isNaN(t)||isNaN(i)){const p=c.domain(),y=p[1]-p[0];isNaN(t)&&(t=p[0]+y/2||0),isNaN(i)&&(i=Math.abs(y)||1)}if(isNaN(n)){const p=h.domain();n=p[0]+(p[1]-p[0])/2||0}const u=l?-i:i,f=t-u/2,g=f+u,d=a(f,g,n);Number.isFinite(r)&&r>0?s.transform(o.transition().duration(r),d):s.transform(o,d)}setBounds(t,n){this.xBounds=t,this.yBounds=n,this.recalculateZoomTransform()}setTranslateBounds(t,n){this.translateBoundsX=t,this.translateBoundsY=n,this.updateTranslateExtent()}adjustToSize(t,n,i=!1){const{width:r,height:s,scaleX:o,scaleY:a,recalculateZoomTransform:c}=this;let h=0,l=0;if(typeof t>"u"||typeof t=="boolean"){const{width:g,height:d}=this.container.node().getBoundingClientRect();h=g,l=d}else h=t,l=n;const u=Math.max(1,h),f=Math.max(1,l);!i&&r===u&&s===f||(o.range([0,u]),a.range([0,f]),c(),this.onRescale(this.currentStateAsEvent()))}calculateTransform(t,n,i){const{scaleX:r,xSpan:s,xBounds:o,yBounds:a,zFactor:c,viewportRatio:h,isXInverted:l,isYInverted:u}=this,[f,g]=r.range(),d=Math.abs(n-t),p=s/d,y=d/(g-f),_=i-(u?-d:d)/c/h/2,x=(o[0]-t)/(l?-y:y),v=(a[0]-_)/((u?-y:y)/c);return Tn.translate(x,v).scale(p)}recalculateZoomTransform(){const{scaleX:t,scaleY:n,container:i,calculateTransform:r,updateTranslateExtent:s}=this,[o,a]=t.domain(),[c,h]=n.domain(),l=c+(h-c)/2,u=r(o,a,l);s(),this.zoom.transform(i,u)}setZoomLevelBoundary(t){return this.zoom.scaleExtent(t),this}setMaxZoomLevel(t){const n=this.zoom.scaleExtent();return this.zoom.scaleExtent([n[0],t]),this}setMinZoomLevel(t){const n=this.zoom.scaleExtent();return this.zoom.scaleExtent([t,n[1]]),this}}const yl={order:1,layerOpacity:1,interactive:!1};class Kt{constructor(t,n){this._referenceSystem=null,this._interactive=!1,this._id=t||`layer-${Math.floor(Math.random()*1e3)}`;const i=n||yl;this._order=i.order||1,this._options={...i},this.loading=!1,this._element=null,this._opacity=i.layerOpacity||1,this._visible=!0,this._interactive=i.interactive||!1,n&&n.data&&this.setData(n.data),this._referenceSystem=n&&n.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)}get id(){return this._id}get element(){return this._element}get options(){return this._options}set options(t){this._options=t}set isLoading(t){this.loading=t}get isLoading(){return this.loading}set opacity(t){this._opacity=t,this.onOpacityChanged(t)}get opacity(){return this._opacity}set order(t){this._order=t,this.onOrderChanged(t)}get order(){return this._order}set interactive(t){this._interactive=t,this.onInteractivityChanged(t)}get interactive(){return this._interactive}get referenceSystem(){return this._referenceSystem}set referenceSystem(t){this._referenceSystem=t}get data(){return this.getData()}set data(t){this.setData(t)}get isVisible(){return this._visible}getData(){return this._data}setData(t){this._data=t,this.element&&this.onUpdate({data:t})}clearData(t=!0){this._data=null,t&&(this.referenceSystem=null),this.onUpdate({})}setVisibility(t,n){this._visible=t}onMount(t){this._element=t.elm,this._options.onMount&&this._options.onMount(t,this)}onUnmount(t){this._options.onUnmount&&this._options.onUnmount(t,this)}onResize(t){this._options.onResize&&this._options.onResize(t,this)}onUpdate(t){t.data&&(this._data=t.data),this._options.onUpdate&&this._options.onUpdate(t,this)}onRescale(t){this.optionsRescale(t)}optionsRescale(t){this._options.onRescale&&this._options.onRescale(t,this)}getInternalLayerIds(){return[]}}const Ce=200,Le=300,ur=40,fr=30,_l=100,xl=.6,vl=.3,wl=8,bl=16,mt=64,dr=1;class yt extends Kt{onOpacityChanged(t){this.canvas&&this.updateStyle()}onOrderChanged(t){this.canvas&&this.updateStyle()}onInteractivityChanged(t){this.canvas&&this.updateStyle()}setVisibility(t){super.setVisibility(t),this.canvas&&this.updateStyle(t)}updateStyle(t){const i=t||this.isVisible?"visible":"hidden",r=this.interactive?"auto":"none";this.canvas.setAttribute("style",`position:absolute;pointer-events:${r};z-index:${this.order};opacity:${this.opacity};visibility:${i}`)}onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Ce,r=t.height||parseInt(n.getAttribute("height"),10)||Le;this.elm=n;let s;this.canvas||(s=document.createElement("canvas"),this.canvas=s,t.elm.appendChild(s)),this.canvas.setAttribute("id",`${this.id}`),this.canvas.setAttribute("width",`${i}px`),this.canvas.setAttribute("height",`${r}px`),this.canvas.setAttribute("class","canvas-layer"),this.updateStyle(),this.ctx=this.canvas.getContext("2d")}onUnmount(){super.onUnmount(),this.canvas.remove(),this.canvas=null}onResize(t){const{ctx:n}=this,{width:i,height:r}=t;n.canvas.setAttribute("width",`${i}px`),n.canvas.setAttribute("height",`${r}px`)}onUpdate(t){super.onUpdate(t)}resetTransform(){this.ctx.resetTransform()}setTransform(t){this.resetTransform();const n=t.xBounds[0]>t.xBounds[1],i=t.yBounds[0]>t.yBounds[1];this.ctx.translate(t.xScale(0),t.yScale(0)),this.ctx.scale(t.xRatio*(n?-1:1),t.yRatio*(i?-1:1))}clearCanvas(){const{ctx:t,canvas:n}=this;t.save(),t.resetTransform(),t.clearRect(0,0,n.width,n.height),t.restore()}}class Sl extends Kt{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Ce,r=t.height||parseInt(n.getAttribute("height"),10)||Le;this.elm||(this.elm=q(n).append("div"),this.elm.attr("id",`${this.id}`),this.elm.attr("class","html-layer"));const s=this.interactive?"auto":"none";this.elm.style("position","absolute").style("height",`${r}px`).style("width",`${i}px`).style("opacity",this.opacity).style("overflow","hidden").style("pointer-events",s).style("z-index",this.order)}onUnmount(){super.onUnmount(),this.elm.remove(),this.elm=null}onResize(t){this.elm&&(super.onResize(t),this.elm.style("height",`${t.height}px`).style("width",`${t.width}px`))}setVisibility(t){super.setVisibility(t),this.elm&&this.elm.attr("visibility",t?"visible":"hidden")}onOpacityChanged(t){this.elm&&this.elm.style("opacity",t)}onOrderChanged(t){this.elm&&this.elm.style("z-index",t)}onInteractivityChanged(t){if(this.elm){const n=t?"auto":"none";this.elm.style("pointer-events",n)}}}class gr extends Kt{onMount(t){super.onMount(t);const{elm:n}=t,i=t.width||parseInt(n.getAttribute("width"),10)||Ce,r=t.height||parseInt(n.getAttribute("height"),10)||Le;this.elm||(this.elm=q(n).append("svg"),this.elm.attr("id",`${this.id}`),this.elm.attr("class","svg-layer")),this.elm.attr("height",r).attr("width",i);const s=this.interactive?"auto":"none";this.elm.style("position","absolute").style("pointer-events",s).style("opacity",this.opacity).style("z-index",this.order)}onUnmount(){super.onUnmount(),this.elm.remove(),this.elm=null}onResize(t){this.elm&&(super.onResize(t),this.elm.attr("height",t.height).attr("width",t.width))}setVisibility(t){super.setVisibility(t),this.elm&&this.elm.attr("visibility",t?"visible":"hidden")}onOpacityChanged(t){this.elm&&this.elm.style("opacity",t)}onOrderChanged(t){this.elm&&this.elm.style("z-index",t)}onInteractivityChanged(t){if(this.elm){const n=t?"auto":"none";this.elm.style("pointer-events",n)}}}class Tl{constructor(t){const n={width:Ce,height:Le,antialias:!0,backgroundAlpha:0,clearBeforeRender:!0,preserveDrawingBuffer:!0,...t};this.renderer=z.autoDetectRenderer(n),this.stage=new z.Container}destroy(){var i,r;this.stage.destroy({children:!0,texture:!0,baseTexture:!0}),this.stage=null;const t=this.renderer.type,n=this.renderer instanceof z.Renderer?(i=this.renderer)==null?void 0:i.gl:void 0;t===z.RENDERER_TYPE.WEBGL&&n&&((r=n==null?void 0:n.getExtension("WEBGL_lose_context"))==null||r.loseContext()),this.renderer.destroy(!0),this.renderer=null}get view(){return this.renderer.view}render(){this.renderer.render(this.stage)}}class An extends Kt{constructor(t,n,i){super(n,i),this.ctx=t,this.container=new z.Container,this.ctx.stage.addChild(this.container)}render(){this.ctx.render()}addChild(t){this.container.addChild(t)}clearLayer(){this.container.removeChildren().forEach(n=>{n.destroy()})}onMount(t){super.onMount(t),this.pixiViewContainer=this.element.querySelector("#webgl-layer"),this.pixiViewContainer||(this.pixiViewContainer=document.createElement("div"),this.pixiViewContainer.setAttribute("id",`${this.id}`),this.pixiViewContainer.setAttribute("class","webgl-layer"),this.pixiViewContainer.appendChild(this.ctx.view),this.element.appendChild(this.pixiViewContainer),this.updateStyle())}onUnmount(t){super.onUnmount(t),this.clearLayer(),this.ctx.stage.removeChild(this.container),this.container.destroy(),this.pixiViewContainer.remove(),this.pixiViewContainer=void 0}onResize(t){super.onResize(t),this.ctx.renderer.resize(t.width,t.height)}onRescale(t){super.onRescale(t);const n=t.xBounds[0]>t.xBounds[1],i=t.yBounds[0]>t.yBounds[1];this.setContainerPosition(t.xScale(0),t.yScale(0)),this.setContainerScale(t.xRatio*(n?-1:1),t.yRatio*(i?-1:1))}setContainerPosition(t,n){this.container.position.set(t,n)}setContainerScale(t,n){this.container.scale.set(t,n)}updateStyle(t){const n=t||this.isVisible,i=this.interactive?"auto":"none";this.container.visible=n;const r=[["position","absolute"],["pointer-events",`${i}`],["z-index",`${this.order}`],["opacity",`${this.opacity}`]].map(s=>s.join(":")).join(";");this.pixiViewContainer.setAttribute("style",r)}setVisibility(t,n){super.setVisibility(t,n),this.pixiViewContainer&&this.updateStyle(t)}onOpacityChanged(t){this.pixiViewContainer&&this.updateStyle()}onOrderChanged(t){this.pixiViewContainer&&this.updateStyle()}onInteractivityChanged(t){this.pixiViewContainer&&this.updateStyle()}renderType(){return this.ctx.renderer.type}}function Qt(e){throw new Error(`Unexpected object: ${JSON.stringify(e)}`)}const pr=e=>e.kind==="pAndASymbol",mr=e=>e.kind==="cementSqueeze",yr=e=>e.kind==="cementPlug",_r=(e,t,n)=>i=>{switch(i.kind){case"screen":return e(i);case"tubing":return t(i);case"completionSymbol":return n(i);default:return Qt(i)}},Z=(e,t)=>{switch(t){case"Perforation":return e.Perforation(t);case"Open hole gravel pack":return e.OpenHoleGravelPack(t);case"Open hole frac pack":return e.OpenHoleFracPack(t);case"Cased hole fracturation":return e.CasedHoleFracturation(t);case"Cased hole frac pack":return e.CasedHoleFracPack(t);case"Cased hole gravel pack":return e.CasedHoleGravelPack(t);default:return Qt(t)}},Ml=e=>Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind),Al=e=>Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind),xr=e=>Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!0,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!0},e.subKind);function vr(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!0,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function wr(e){return Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function br(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!0,CasedHoleFracPack:()=>!1},e.subKind)}function Pl(e){return Z({Perforation:()=>!0,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}function Sr(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!1,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!0},e.subKind)}function Cl(e){return Z({Perforation:()=>!1,OpenHoleGravelPack:()=>!1,OpenHoleFracPack:()=>!0,CasedHoleFracturation:()=>!1,CasedHoleGravelPack:()=>!1,CasedHoleFracPack:()=>!1},e.subKind)}const Pn=(e,t)=>e.start<t.end&&e.end>t.start,Tr=e=>({holeLayerId:`${e}-hole`,casingLayerId:`${e}-casing`,completionLayerId:`${e}-completion`,cementLayerId:`${e}-cement`,pAndALayerId:`${e}-pAndA`,perforationLayerId:`${e}-perforation`}),Mr={firstColor:"#8c541d",secondColor:"#eee3d8",lineColor:"#8b4513"},Ar={solidColor:"#dcdcdc",lineColor:"#575757",shoeSize:{width:wl,length:bl},windowOptions:{dashColor:"#dc0000",dashLength:5,spaceLength:3}},Pr={stroke:"rgba(0, 0, 0, 0.25)",yellow:"#FFFC00",grey:"gray",red:"#FF5050",outline:"black",transparent:"rgba(255, 255, 255, 0)",spikeWidth:50,spikeLength:50,packingOpacity:.5,fracLineCurve:10,fracLineLength:25,scalingFactor:25},Cr={firstColor:"#c7b9ab",secondColor:"#5b5b5b",scalingFactor:4},Lr={firstColor:"#8b6713",secondColor:"#000000",scalingFactor:4},kr={scalingFactor:4,lineColor:"#63666a"},Er={scalingFactor:1,innerColor:"#eeeeff",outerColor:"#777788"},Rr={firstColor:"#c7b9ab",secondColor:"#000000",scalingFactor:4},Fr=4,zr=2;function Dr(e){const[t]=e.domain();return Math.abs(e(t+1))}function ke(e,t,n,i){return gt(Dr(i)*e,t,n)}function Ll(e,t){const n=e.x+e.width,i=t.x+t.width;return!(t.x>n||i<e.x)}function Or(e,t,n=Fr,i=zr){const r=e.x+e.width+n,s=t.x+t.width+n,o=e.y+e.height+i,a=t.y+t.height+i;return!(t.x-n>r||t.y-i>o||s+n<e.x||a+i<e.y)}function kl(e,t){const n=e.x+e.width,i=t.x+t.width,r=e.y+e.height,s=t.y+t.height;if(t.x>n||t.y>r||i<e.x||s<e.y)return null;const o=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),a=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return{dx:o,dy:a}}function Cn(e,t,n=Fr,i=zr){const r=e.x+e.width,s=t.x+t.width,o=e.y+e.height,a=t.y+t.height;if(t.x-n>r||t.y-i>o||s+n<e.x||a+i<e.y)return null;const c=e.x+e.width-t.x+n,h=e.y+e.height-t.y+i;return{dx:c,dy:h}}const El=7,Rl=11,Fl=7,zl=20,Dl=120,Ol=19,nt={topleft:"topleft",topright:"topright",bottomleft:"bottomleft",bottomright:"bottomright"};class Nl extends yt{constructor(t,n){super(t,n),this.groupFilter=null,this.renderAnnotation=(i,r,s,o,a,c)=>{this.renderText(i,s,o-a,a,c,"arial","bold"),this.renderText(r,s,o,a,c)},this.renderLine=(i,r,s,o,a,c,h=!0)=>{const{ctx:l}=this,u=h?i:i+s,f=h?i+s:i,g=r+2;l.strokeStyle=c,l.lineWidth=1,l.beginPath(),l.moveTo(o,a),l.lineTo(u,g),l.lineTo(f,g),l.stroke()},this.minFontSize=n.minFontSize||El,this.maxFontSize=n.maxFontSize||Rl,this.fontSizeFactor=n.fontSizeFactor||Fl,this.offsetMin=n.offsetMin||zl,this.offsetMax=n.offsetMax||Dl,this.offsetFactor=n.offsetFactor||Ol}setGroupFilter(t){this.groupFilter=t,this.callouts=void 0,this.render()}onUpdate(t){super.onUpdate(t),this.callouts=void 0,this.render()}onRescale(t){super.onRescale(t);const n=this.rescaleEvent&&this.rescaleEvent.xRatio===t.xRatio;this.rescaleEvent=t,this.render(n)}render(t=!1){requestAnimationFrame(()=>{if(this.clearCanvas(),!this.data||!this.rescaleEvent||!this.referenceSystem)return;const{xScale:n,yScale:i,xBounds:r}=this.rescaleEvent,s=ke(this.fontSizeFactor,this.minFontSize,this.maxFontSize,n);if(!t||!this.callouts){const{data:o,ctx:a,groupFilter:c}=this,{calculateDisplacementFromBottom:h}=this.referenceSystem.options,l=h?r[0]<r[1]:r[0]>r[1],u=0;a.font=`bold ${s}px arial`;const f=o.filter(d=>!c||c.includes(d.group)),g=ke(this.offsetFactor,this.offsetMin,this.offsetMax,n);this.callouts=this.positionCallouts(f,l,n,i,u,s,g)}this.callouts.forEach(o=>{const{pos:a,title:c,color:h}=o,l=n(a.x),u=i(a.y),f={x:l,y:u,width:o.boundingBox.width,height:s,offsetX:o.dx,offsetY:o.dy};this.renderCallout(c,o.label,f,h,o.alignment)})})}renderText(t,n,i,r,s,o="arial",a="normal"){const{ctx:c}=this;c.font=`${a} ${r}px ${o}`,c.fillStyle=s,c.fillText(t,n,i)}renderPoint(t,n,i=3){const{ctx:r}=this;r.beginPath(),r.moveTo(t,n),r.arc(t,n,i,0,Math.PI*2),r.fill()}renderCallout(t,n,i,r,s){const o=this.getPosition(i,s),{x:a,y:c}=o,{height:h,width:l,x:u,y:f}=i,g=s===nt.topright||s===nt.bottomright;this.renderAnnotation(t,n,a,c,h,r),this.renderPoint(u,f),this.renderLine(a,c,l,u,f,r,g)}getPosition(t,n){const{x:i,y:r,offsetX:s,offsetY:o,width:a}=t;switch(n){case nt.topleft:return{x:i-a-s,y:r-o};case nt.topright:return{x:i+s,y:r-o};case nt.bottomleft:return{x:i-a-s,y:r+o};case nt.bottomright:return{x:i+s,y:r+o};default:return{x:i,y:r}}}positionCallouts(t,n,i,r,s,o,a=20){if(t.length===0)return[];const c=n?nt.topleft:nt.topright,h=t.map(f=>{const g=f.pos?f.pos:this.referenceSystem.project(f.md);return{title:f.title,label:f.label,color:f.color,pos:{x:g[0],y:g[1]},group:f.group,alignment:c,boundingBox:this.getAnnotationBoundingBox(f.title,f.label,g,i,r,o),dx:a,dy:a}}),l=[h[h.length-1]],u=[];return this.chooseTopOrBottomPosition(h,u,l),this.adjustTopPositions(l),this.adjustBottomPositions(u),h}getAnnotationBoundingBox(t,n,i,r,s,o){const{ctx:a}=this,c=r(i[0]),h=s(i[1]),l=a.measureText(n).width,u=a.measureText(t).width,f=Math.max(l,u);return{x:c,y:h,width:f,height:o*2+4}}chooseTopOrBottomPosition(t,n,i){for(let r=t.length-2;r>=0;--r){const s=t[r],o=i[0];Or(s.boundingBox,o.boundingBox)?(s.alignment=s.alignment===nt.topleft?nt.bottomright:nt.bottomleft,n.push(s),r>0&&i.unshift(t[--r])):i.unshift(s)}}adjustTopPositions(t){for(let n=t.length-2;n>=0;--n){const i=t[n];for(let r=t.length-1;r>n;--r){const s=t[r],o=Cn(i.boundingBox,s.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y-=o.dy)}}}adjustBottomPositions(t){for(let n=t.length-2;n>=0;--n){const i=t[n];for(let r=t.length-1;r>n;--r){const s=t[r],o=Cn(s.boundingBox,i.boundingBox);o&&(i.dy+=o.dy,i.boundingBox.y+=o.dy)}}}}const $l=16,Bl=6;function dt(e){const n=ht(e).formatHex();return parseInt(n.replace("#","0x"))}function Il(e){return typeof e=="string"?e:`#${e.toString($l).padStart(Bl,"0")}`}const Hl=1e4;class Vl extends yt{constructor(t,n){super(t,n),this.surfaceAreasPaths=[],this.surfaceLinesPaths=[],this.maxDepth=Hl,this.drawPolygonPath=(i,r)=>{const{ctx:s}=this;s.fillStyle=i,s.fill(r)},this.drawLinePath=(i,r)=>{const{ctx:s}=this;s.strokeStyle=i,s.stroke(r)},this.createPolygons=i=>{const r=[];let s=null;for(let o=0;o<i.length;o++){const a=!!i[o][1];a&&(s===null&&(s=[]),s.push(i[o][0],i[o][1]));const c=o===i.length-1;if((!a||c)&&s){for(let h=a?o:o-1;h>=0&&i[h][1];h--)s.push(i[h][0],i[h][2]||this.maxDepth);r.push(s),s=null}}return r},this.generatePolygonPath=i=>{const r=new Path2D;r.moveTo(i[0],i[1]);for(let s=2;s<i.length;s+=2)r.lineTo(i[s],i[s+1]);return r.closePath(),r},this.generateLinePaths=i=>{const r=[],{data:s}=i;let o=!1,a=null;for(let c=0;c<s.length;c++)s[c][1]?o?a.lineTo(s[c][0],s[c][1]):(a=new Path2D,a.moveTo(s[c][0],s[c][1]),o=!0):o&&(r.push(a),o=!1);return o&&r.push(a),r},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)}onUpdate(t){super.onUpdate(t),this.updatePaths(),this.render()}onRescale(t){this.rescaleEvent=t,this.setTransform(this.rescaleEvent),this.render()}updatePaths(){this.data?(this.generateSurfaceAreasPaths(),this.generateSurfaceLinesPaths()):(this.surfaceAreasPaths=[],this.surfaceLinesPaths=[])}render(){!this.ctx||!this.rescaleEvent||requestAnimationFrame(()=>{this.clearCanvas(),this.surfaceAreasPaths.forEach(t=>this.drawPolygonPath(t.color,t.path)),this.surfaceLinesPaths.forEach(t=>this.drawLinePath(t.color,t.path))})}colorToCSSColor(t){return Il(t)}generateSurfaceAreasPaths(){this.surfaceAreasPaths=this.data.areas.reduce((t,n)=>{const r=this.createPolygons(n.data).map(s=>({color:this.colorToCSSColor(n.color),path:this.generatePolygonPath(s)}));return t.push(...r),t},[])}generateSurfaceLinesPaths(){this.surfaceLinesPaths=this.data.lines.reduce((t,n)=>{const r=this.generateLinePaths(n).map(s=>({color:this.colorToCSSColor(n.color),path:s}));return t.push(...r),t},[])}}function Ln(e,t){let n=0,i=e.length-1;const r=20;let s=e[n][0],o=e[i][0];for(;i-n>r;){const c=Math.floor((i+n)/2),h=e[c][0];if(t>=s&&t<h)i=c,o=e[i][0];else if(t>=h&&t<=o)n=c,s=e[n][0];else if(t<=s&&t>h)i=c,o=e[i][0];else if(t<=h&&t>=o)n=c,s=e[n][0];else return-1}let a=-1;for(let c=n;c<i;c++){const h=e[c][0],l=e[c+1][0];if(Math.min(h,l)<=t&&t<=Math.max(h,l)){a=c;break}}return a}function _t(e,t,n=null,i=null){let r=null;const s=Ln(e,t);if(s!==-1){const o=e[s][1],a=e[s+1][1];if(a&&a){const c=e[s][0],l=e[s+1][0]-c,f=(t-c)/l;r=o*(1-f)+a*f,n&&n>r&&(r=n),i&&i<r&&(r=i)}}return r}const kn=(e,t)=>({title:e.pickIdentifier||e.identifier,group:t,label:`${e.md} ${e.mdUnit} ${e.depthReferencePoint}`,color:t==="strat-picks"?"#227":"rgba(0,0,0,0.8)",md:e.md});function Ul(e){return e?e.map(t=>kn(t,"ref-picks")):[]}function Wl(e){return e?e.filter(t=>t.entryPick.md===t.from).map(t=>kn(t.entryPick,"strat-picks")):[]}function Yl(e){return e?e.filter(t=>e.findIndex(n=>Math.abs(n.entryPick.md-t.exitPick.md)<.5)===-1).map(t=>kn(t.exitPick,"strat-picks")).filter((t,n,i)=>n===i.findIndex(r=>r.title===t.title&&r.md===t.md)):[]}const Gl=e=>[...Ul(e.nonUnitPicks),...Wl(e.unitPicks),...Yl(e.unitPicks)].sort((t,n)=>t.md-n.md),Xl=e=>({unitName:e.identifier,topSurface:e.top,baseSurface:e.base,ageBase:e.baseAge,ageTop:e.topAge,color:{r:e.colorR===null?255:e.colorR,g:e.colorG===null?255:e.colorG,b:e.colorB===null?255:e.colorB},level:e.stratUnitLevel,lithType:e.lithologyType,parent:e.stratUnitParent});function jl(e,t,n){if(n.length===0)return[[e,t]];const i=[];let r=e,s=0;for(;r<t&&s<n.length;){const o=n[s];o.from>r&&i.push([r,Math.min(o.from,t)]),r=Math.min(t,Math.max(e,o.to)),s+=1}return r<t&&i.push([r,t]),i}const ql=e=>e.map(Xl);function Zl(e,t){const n=ql(t),i=[],r=[];return e.forEach(s=>{const o=n.filter(a=>s.pickIdentifier.search(new RegExp(`(${a.topSurface}|${a.baseSurface})`,"i"))!==-1);o.length>0?o.forEach(a=>r.push({md:s.md,tvd:s.tvd,identifier:s.pickIdentifier,confidence:s.confidence,mdUnit:s.mdUnit,depthReferencePoint:s.depthReferencePoint,...a})):i.push({identifier:s.pickIdentifier,...s})}),{joined:r,nonUnitPicks:i}}function Kl(e){const t=[];let n=null;const i=e.filter(r=>r.level).sort((r,s)=>r.unitName.localeCompare(s.unitName)||r.md-s.md||r.ageTop-s.ageTop);for(;i.length>0;){n=i.shift();const r=n.identifier;let s;const o=r===n.topSurface,a=r===n.baseSurface;if(o)s=n.baseSurface;else if(a)s=n.topSurface;else{console.warn(`Unable to match ${r} with top or base surface, ignored`);continue}let c,h;const l=i.find(u=>u.identifier===s);if(l)c=o?n:l,h=o?l:n,c.md>h.md&&([c,h]=[h,c]),i.splice(i.indexOf(l),1);else if(console.warn(`Unable to find ${s} pick for ${r}`),o)if(c=n,h=e.filter(u=>u.level).sort((u,f)=>u.md-f.md).find(u=>u.md>c.md),h)console.warn(`Using ${h.identifier} as base for ${r}`);else{console.warn(`Unable to find a base pick for ${r} pick at ${c.md}, ignored`);continue}else if(a)if(h=n,c=e.filter(u=>u.level).sort((u,f)=>f.md-u.md).find(u=>u.md<h.md),c)console.warn(`Using ${c.identifier} as top for ${r}`);else{console.warn(`Unable to find a top pick for ${r} pick at ${h.md}, ignored`);continue}else{console.warn(`${r} ignored`);continue}t.push({name:c.unitName,mdEntry:c.md,tvdEntry:c.tvd,color:c.color,level:c.level,entryPick:c,mdExit:h.md,tvdExit:h.tvd,exitPick:h,confidenceEntry:c.confidence,confidenceExit:h.confidence})}return t}function Ql(e,t){const{joined:n,nonUnitPicks:i}=Zl(e,t),s=Kl(n).filter(a=>a.mdEntry<a.mdExit).sort((a,c)=>a.mdEntry-c.mdEntry||a.level-c.level).reverse(),o=[];for(;s.length>0;){const a=s.pop(),c=[];for(;s.length>0&&s[s.length-1].level>a.level;)c.push(s.pop());c.reverse(),c.push(a);const h=[];c.forEach(l=>{const u=jl(l.mdEntry,l.mdExit,h);h.push(...u.map(f=>({from:f[0],to:f[1],itm:l})))}),h.sort((l,u)=>l.from-u.from),o.push(...h.map(l=>({from:l.from,to:l.to,...l.itm})))}return{unitPicks:o,nonUnitPicks:i}}function Jl(e,t){const n=e.map((s,o)=>o*t/e.length),i=Tt().domain(n).range(e);return Array.from(new Array(t).keys()).map(s=>{const o=ht(i(s)).rgb();return[o.r,o.g,o.b]})}const tu=e=>e?{x:e.minX,y:e.minTvdMsl,width:e.maxX-e.minX,height:e.maxTvdMsl-e.minTvdMsl}:{x:0,y:0,width:0,height:0};function eu(e,t){if(!(e&&e.datapoints))return null;const n=t.reduce((g,d)=>Math.min(g,d[0]),0),i=t.reduce((g,d)=>Math.max(g,d[0]),0),r=e.yAxisValues&&e.yAxisValues[0],s=e.yAxisValues&&e.yAxisValues[e.yAxisValues.length-1],o=e.datapoints||[],a=-o.reduce((g,d)=>Math.min(...d,g),0),c=o.reduce((g,d)=>Math.max(...d,g),0),h=Math.max(Math.abs(a),Math.abs(c)),l=-h,u=h;return{minX:n,maxX:i,minTvdMsl:r,maxTvdMsl:s,domain:{min:l,max:u,difference:u-l}}}async function nu(e,t,n,i){if(!(e&&e.datapoints&&e.datapoints.length>0))return;const{datapoints:r}=e,s=(i==null?void 0:i.seismicMin)||(i==null?void 0:i.seismicRange)||r.reduce((m,T)=>Math.min(...T,m),0),o=(i==null?void 0:i.seismicMax)||(i==null?void 0:i.seismicRange)||r.reduce((m,T)=>Math.max(...T,m),0),a=Math.max(Math.abs(s),Math.abs(o)),c=-a,h=a,l={min:c,max:h,difference:h-c},u=t[0][0]-t[t.length-1][0],f=Math.abs(Math.floor(u/5)),g=e.yAxisValues.length,d=1e3,p=Jl(n,d),y=new Uint8ClampedArray(f*g*4);let _=0;const x=(d-1)/l.difference;let v=i!=null&&i.isLeftToRight?t[0][0]:t[t.length-1][0];const C=u/f*(i!=null&&i.isLeftToRight?-1:1);let b,S,M,R,F;const O=[0,0,0];let A;for(let m=0;m<f;m++){_=m*4;const T=Ln(t,v),w=t[T][0],L=t[T+1][0]-w,N=(v-w)/L;for(let $=0;$<g;$++)b=r[$][T],S=r[$][T+1],b==null||S==null?(F=O,A=0):(M=b*(1-N)+S*N,R=(M-l.min)*x,R=gt(~~R,0,d-1),F=p[R],A=255),y.set([F[0],F[1],F[2],A],_),_+=f*4;v+=C}const E=new ImageData(y,f,g);return await createImageBitmap(E,0,0,f,g)}const iu=2147483648,ru=4294967295;function su(e,t,n){const i=n.filter(g=>g.data.values),r=uu(i),s=new Map,o=hu(r,t,s);lu(o);const a=ou(r,e),c=mu(e,o,t),h=cu(s,c),u=[...au(h,e),...Object.values(c).flat().filter(g=>!g.exclude)];return{lines:a,areas:u}}function ou(e,t){return e.filter(i=>i.visualization==="line").map(i=>({id:i.name,label:i.name,width:2,color:dt(i.color||"black"),data:t.map((r,s)=>[r[0],i.values[s]])}))}function au(e,t){return e.map((i,r)=>{const s=r+1<e.length?e[r+1]:null;return{id:i.id,label:i.label,color:dt(i.color),data:t.map((o,a)=>[o[0],i.top[a],s?s.top[a]:null])}})}function cu(e,t){return Array.from(e.values()).sort((i,r)=>i.age-r.age).filter(i=>{const r=t[i.name],s=r&&r.length>0;return s||console.warn(`Intersection surface group '${i.name}' has no valid entries and will be discarded.`),s}).map((i,r)=>{const o=t[i.name][0];return{id:i.name,label:i.name,color:du(r),top:o.data.map(a=>a[1])}})}function hu(e,t,n){const i=t&&t.find(o=>o.stratUnitLevel===1),r=i?i.identifier:"SEABED";return e.filter(o=>o.visualization==="interval"||o.visualization==="none").map(o=>{const a=[],c=Nr(t,o.name,a);c||console.warn(`No match for ${o.name} in strat column`);const h=a[0]||c,l=h&&h.identifier||r;return h&&!n.has(l)&&n.set(l,{age:h.topAge,name:h.identifier}),{...o,unit:c,group:l}})}function lu(e){e.sort((t,n)=>{if(!t.unit&&!n.unit)return 0;if(!t.unit)return-1;if(!n.unit)return 1;const i=t.isBase?t.unit.baseAge:t.unit.topAge,r=n.isBase?n.unit.baseAge:n.unit.topAge;return i!==r?i-r:t.isBase&&!n.isBase?1:!t.isBase&&n.isBase?-1:t.unit.stratUnitLevel-n.unit.stratUnitLevel})}function Nr(e,t,n=[]){const i=e.find(r=>r.identifier.toLowerCase()===t.toLowerCase());if(i){let r=i;do n.unshift(r),r=e.find(s=>s.identifier===r.stratUnitParent);while(r);return i}return null}function uu(e){return e.map(t=>{const n=t.visualSettings.displayName,i=n.replace(/\s(Base|Top)/gi,""),r=n.toLowerCase().endsWith("base");return{name:i,isBase:r,values:t.data.values,color:t.visualSettings.colors.crossSection,visualization:t.visualSettings.crossSection.toLowerCase()}})}function fu(e){return e.colorR===null||e.colorG===null||e.colorB===null?iu:e.colorR<<16|e.colorG<<8|e.colorB}const du=Jn().domain([0,100]).range(yo(It("#e6f1cf","#85906d"),10));function gu(e,t,n,i){const r=t+1;if(!n||r>=n.length)return null;const s=n.findIndex(o=>o.isBase&&o.name===e.name);if(s!==-1)return s;for(let o=r;o<n.length;o++){const a=n[o];if(!a.isBase||pu(e,a,i))return o}return null}function pu(e,t,n){const i=[];return Nr(n,e.name,i),i.some(r=>t.name===r.identifier)}function mu(e,t,n){return t.reduce((r,s,o)=>{if(!s.isBase){r[s.group]||(r[s.group]=[]);const a=gu(s,o,t,n);r[s.group].push({id:s.name,label:s.name,color:s.unit&&fu(s.unit)||ru,exclude:s.visualization==="none"||!s.unit,data:e.map((c,h)=>{const l=s.values[h]!==null?yu(a,t,h):null;return[c[0],s.values[h],l]})})}return r},{})}function yu(e,t,n){if(!t||!e||e>=t.length)return null;for(let i=e;i<t.length;i++)if(t[i].values[n]!==null)return t[i].values[n];return null}const $r=.1,En=1e3,_u=150,xu=30,vu=10;function wu(e){if(!e||e.length===0)return[];const t=e?e.map(r=>[r.easting,r.northing,r.tvd,r.md]):[],n=Br(Ir(t)),i=n[n.length-1][0];return n.forEach((r,s)=>{n[s][0]=i-r[0]}),n}function bu(e,t){if(!e||e.length===0)return[];const n=e?e.map(x=>[x.easting,x.northing,x.tvd,x.md]):[],i=new ln(n,{tension:.75,arcDivisions:5e3}),r=i.length,s=Math.round(r*vu);let o=null;s>0?o=Br(i.getPoints(s),5e-4,10):o=[[n[0][0],n[0][1]]];const a=o[0],c=o[o.length-1],h=B.distance(a,c);let l=null;if(h<_u){const v=t/180*Math.PI;l=new B(Math.cos(v),Math.sin(v)).mutable}else l=Su(o,xu);const u=Math.max(0,En-r),f=u+r,g=[];let d=[];const p=l.toArray();u>0&&(d=Ai(Math.ceil(u*$r)).map(x=>l.set(p).scale(u*(1-x)).subFrom(a).toArray()),d.pop(),g.push(...d)),g.push(...o);const y=Ai(Math.ceil(En*$r)).map(x=>l.set(p).scale(En*x).add(c).toArray()).splice(1);return g.push(...y),Ir(g,null,f)}function Su(e,t){const n=B.zero.mutable;let i=0;const r=B.zero.mutable;for(let s=0;s<e.length-1;s++){const o=e.length-1-s;if(r.set(e[o]).sub(e[o-1]),n.add(r),i=n.magnitude,i>t)break}return i===0?new B([0,0]):n.scale(1/i)}function Br(e,t=.001,n=10){if(e.length<=4)return e;const[i,r]=e[0],s=e.map(l=>[l[0]-i,l[1]-r]);let[o,a]=s[0];const c=[e[0]];for(let l=1;l+1<s.length;l++){const[u,f]=s[l],[g,d]=s[l+1];if(g-u!==0||d-f!==0){const p=Math.abs(o*d-a*g+g*f-d*u+a*u-o*f)/Math.sqrt((g-o)**2+(d-a)**2),y=[o-u,a-f],_=Math.sqrt(y[0]**2+y[1]**2);(p>t||_>=n)&&(c.push([u+i,f+r]),[o,a]=[u,f])}}const h=s[s.length-1];return c.push([h[0]+i,h[1]+r]),c}function Ir(e,t=null,n=0){let i=t||e[0],r=0;return e.map(o=>{const a=o[0]-i[0],c=o[1]-i[1];return r+=Math.sqrt(a**2+c**2),i=o,[n>0?n-r:r,o[2]||0]})}const Tu=18,Mu=8,Au=13,Pu="black",Cu="Arial",Lu=70;class ku extends yt{constructor(t,n){super(t,n),this.defaultMargins=Tu,this.defaultMinFontSize=Mu,this.defaultMaxFontSize=Au,this.defaultTextColor=Pu,this.defaultFont=Cu,this.isLabelsOnLeftSide=!0,this.maxFontSizeInWorldCoordinates=Lu,this.isXFlipped=!1,this.areasWithAvgTopDepth=null,this.drawAreaLabel=(i,r,s,o)=>{const{data:a}=i,{ctx:c,maxFontSizeInWorldCoordinates:h,isXFlipped:l}=this,{xScale:u,yScale:f,xRatio:g,yRatio:d,zFactor:p}=this.rescaleEvent;let y=this.checkDrawLabelsOnLeftSide();const x=(this.options.margins||this.defaultMargins)*(l?-1:1)/g,v=this.options.minFontSize||this.defaultMinFontSize;let b=(this.options.maxFontSize||this.defaultMaxFontSize)/d;b>h&&(b=h,b*d<v&&(b=v/d));const S=u.invert(u.range()[0])+x,M=u.invert(u.range()[1])-x,[R,F]=this.getSurfacesAreaEdges();c.save(),c.font=`${b*d}px ${this.options.font||this.defaultFont}`;let O=c.measureText(i.label),A=O.width/g;if(y){const U=S+(l?-A:A);(!l&&U>F||l&&U<F)&&(y=!1)}else{const U=M+(l?A:-A);(!l&&U<R||l&&U>R)&&(y=!0)}let E;const I=.07;y?E=l?Math.min(R,S):Math.max(R,S):E=l?Math.max(F,M):Math.min(F,M);const m=f.invert(f.range()[0]),T=f.invert(f.range()[1]),w=5,k=3,L=I*(A/k)*(y?1:-1)*(l?-1:1),D=A/w*(y?1:-1)*(l?-1:1),N=a.map(U=>[U[0],U[1]]),$=this.calcPos(N,E,k,L,m,T);if(!$)return;const H=a.map(U=>[U[0],U[2]]);let Y=this.calcPos(H,E,k,L,m,T,r?r.data.map(U=>[U[0],U[1]]):null,s,o);Y||(Y=new B($.x,T));const V=Y.y-$.y;if(V<b){if(V*d<v)return;b=V,c.font=`${b*d}px ${this.options.font||this.defaultFont}`,O=c.measureText(i.label),A=O.width/g}const Q=y!==l?B.right:B.left,it=this.calcAreaDir(N,H,E,w,D,Q,m,T,0,Math.PI/4,4,r?r.data.map(U=>[U[0],U[1]]):null,s,o),X=Math.atan(Math.tan(it)*p),rt=E,Jt=($.y+Y.y)/2,Uf=l?-X:X;c.textAlign=y?"left":"right",c.translate(u(rt),f(Jt)),c.rotate(Uf),c.fillStyle=this.options.textColor||this.defaultTextColor,c.font=`${b*d}px ${this.options.font||this.defaultFont}`,c.textBaseline="middle",c.fillText(i.label,0,0),c.restore()},this.drawLineLabel=i=>{const{ctx:r,isXFlipped:s}=this,{xScale:o,yScale:a,xRatio:c,yRatio:h,zFactor:l}=this.rescaleEvent,u=this.checkDrawLabelsOnLeftSide(),f=this.getMarginsInWorldCoordinates(),d=(this.options.maxFontSize||this.defaultMaxFontSize)/h;r.save(),r.font=`${d*h}px ${this.options.font||this.defaultFont}`;const y=r.measureText(i.label).width/c,_=o.invert(o.range()[0])+f,x=o.invert(o.range()[1])-f,[v,C]=this.getSurfacesAreaEdges();let b;const S=5;u?b=s?Math.max(C,x):Math.min(C,x):b=s?Math.min(v,_):Math.max(v,_);const M=y/S*(u?-1:1),{data:R}=i,F=this.calcPos(R,b,S,M),O=this.calcLineDir(R,b,S,M,l,u?B.left:B.right);if(!F||!O)return;const A=b,E=F.y-dr-d/2,I=B.angleRight(O)-(u?Math.PI:0);r.textAlign=u?"right":"left",r.translate(o(A),a(E)),r.rotate(I),r.fillStyle=this.colorToCSSColor(i.color),r.textBaseline="middle",r.fillText(i.label,0,0),r.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)}get options(){return this._options}setData(t){super.setData(t),this.areasWithAvgTopDepth=null}generateSurfacesWithAvgDepth(){const{areas:t}=this.data;this.areasWithAvgTopDepth=t.reduce((n,i)=>{if(!i.label)return n;const r=i.data.reduce((o,a)=>(a[1]!=null&&(o.sum+=a[1],o.count++),o),{sum:0,count:0});if(r.count===0)return n;const s=r.sum/r.count;return n.push({...i,avgTopDepth:s}),n},[])}onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.render()}onRescale(t){this.rescaleEvent=t,this.updateXFlipped(),this.resetTransform(),this.render()}render(){this.rescaleEvent&&requestAnimationFrame(()=>{this.clearCanvas(),this.data&&(this.areasWithAvgTopDepth||this.generateSurfacesWithAvgDepth(),this.drawAreaLabels(),this.drawLineLabels())})}drawAreaLabels(){this.areasWithAvgTopDepth.forEach((t,n,i)=>{const r=i.reduce((s,o,a)=>(a>n&&(s==null||o.avgTopDepth<s.avgTopDepth)&&(s=o),s),null);r&&this.drawAreaLabel(t,r,i,n)})}drawLineLabels(){this.data.lines.filter(t=>t.label).forEach(t=>this.drawLineLabel(t))}colorToCSSColor(t){if(typeof t=="string")return t;let n=t.toString(16);return n="000000".substr(0,6-n.length)+n,`#${n}`}calcPos(t,n,i,r,s=null,o=null,a=null,c=null,h=null){const l=B.zero.mutable;let u=0;for(let f=0;f<i;f++){const g=n+f*r,d=_t(t,g,s,o);if(d){const p=this.getAlternativeYValueIfAvailable(g,s,o,a,c,h),y=p?Math.min(d,p):d;l.add(g,y),u++}}return u===0?null:B.divide(l,u)}getAlternativeYValueIfAvailable(t,n,i,r,s,o){if(!r)return null;let a=_t(r,t,n,i);if(a==null&&s&&o!=null){let c=o+1;for(;a==null&&c<s.length;){const h=s[c++];a=_t(h.data.map(l=>[l[0],l[1]]),t,n,i)}}return a}calcLineDir(t,n,i,r,s,o=B.left,a=null,c=null){const h=o.mutable,l=_t(t,n,a,c);if(l===null)return h;const u=new B(n,l*s),f=B.zero.mutable;for(let g=1;g<=i;g++){const d=n+g*r,p=_t(t,n,a,c);p!==null&&(f.set(d,p*s),f.sub(u),h.add(f))}return h}calcAreaDir(t,n,i,r,s,o=B.left,a=null,c=null,h=0,l=Math.PI/4,u=4,f=null,g=null,d=null){const p=[],y=B.zero.mutable;let _;for(let M=0;M<=r;M++){const R=i+M*s,F=_t(t,R,a,c),O=_t(n,R,a,c)||c,A=this.getAlternativeYValueIfAvailable(R,a,c,f,g,d),E=A?Math.min(O,A):O;if(M===0){if(F===null)return B.angleRight(o);const I=(F+E)/2;_=new B(i,I)}else F!==null?(y.set(R,(F+E)/2),y.sub(_),p.push(B.angleRight(y))):p.push(B.angleRight(o))}const x=p[0],v=p.map(M=>M-x);let C=0;return v.reduce((M,R)=>{const F=(Math.abs(R)-h)/l,O=Math.pow(1-gt(F,0,1),u);return C+=O,M+R*O},0)/C+x}updateXFlipped(){const{xBounds:t}=this.rescaleEvent;this.isXFlipped=t[0]>t[1]}getMarginsInWorldCoordinates(){const{xRatio:t}=this.rescaleEvent;return(this.options.margins||this.defaultMargins)*(this.isXFlipped?-1:1)/t}getSurfacesAreaEdges(){const t=this.data.areas.reduce((c,h)=>{const{data:l}=h,u=l.find(f=>f[1]!=null);u&&c.push(u[0]);for(let f=l.length-1;f>=0;f--)if(l[f][1]!=null){c.push(l[f][0]);break}return c},[]);t.push(...this.data.lines.reduce((c,h)=>{const{data:l}=h,u=l.find(f=>f[1]!=null);u&&c.push(u[0]);for(let f=l.length-1;f>=0;f--)if(l[f][1]!=null){c.push(l[f][0]);break}return c},[]));const n=Math.min(...t),i=Math.max(...t),r=this.getMarginsInWorldCoordinates(),{isXFlipped:s}=this,o=s?i+r:n+r,a=s?n-r:i-r;return[o,a]}checkDrawLabelsOnLeftSide(){const{referenceSystem:t,isXFlipped:n}=this;if(!t)return!0;const{xScale:i,yScale:r,xRatio:s}=this.rescaleEvent,o=200,[a,c]=i.domain(),[h,l]=r.domain();let u=t.interpolators.curtain.lookup(h,1,0);u.length===0&&(u=[t.interpolators.curtain.getPointAt(0)]);let f=t.interpolators.curtain.lookup(l,1,0);f.length===0&&(f=[t.interpolators.curtain.getPointAt(1)]);const g=Math.max(u[0][0],f[0][0]),d=Math.min(u[0][0],f[0][0]),p={left:n?g:d,right:n?d:g},y=this.getMarginsInWorldCoordinates(),_=a+y,x=c-y,[v,C]=this.getSurfacesAreaEdges(),b=n?Math.min(_,v):Math.max(_,v),S=n?Math.max(x,C):Math.min(x,C),M=Math.max(n?b-p.left:p.left-b,0),R=Math.max(n?p.right-S:S-p.right,0),F=M*s,O=R*s;return M>R||F>o||F<o&&O<o&&n||f[0][1]<h}}const Eu=1e4;class Ru extends An{constructor(){super(...arguments),this.isPreRendered=!1,this.createPolygons=t=>{const n=[];let i=null;for(let r=0;r<t.length;r++){const s=!!t[r][1];s&&(i===null&&(i=[]),i.push(t[r][0],t[r][1]));const o=r===t.length-1;if((!s||o)&&i){for(let a=s?r:r-1;a>=0&&t[a][1];a--)i.push(t[a][0],t[a][2]||Eu);n.push(i),i=null}}return n},this.generateAreaPolygon=t=>{const n=new z.Graphics;n.lineStyle(1,t.color,1),n.beginFill(t.color),this.createPolygons(t.data).forEach(r=>n.drawPolygon(r)),n.endFill(),this.addChild(n)},this.generateSurfaceLine=t=>{const n=new z.Graphics,{data:i}=t,r=.5;n.lineStyle(dr,t.color,1,r,!0);let s=!1;for(let o=0;o<i.length;o++)i[o][1]?s?n.lineTo(i[o][0],i[o][1]):(n.moveTo(i[o][0],i[o][1]),s=!0):s=!1;this.addChild(n)}}onRescale(t){super.onRescale(t),this.isPreRendered||(this.clearLayer(),this.preRender()),this.render()}onUpdate(t){super.onUpdate(t),this.isPreRendered=!1,this.clearLayer(),this.preRender(),this.render()}preRender(){const{data:t}=this;t&&(t.areas.forEach(n=>this.generateAreaPolygon(n)),t.lines.forEach(n=>this.generateSurfaceLine(n)),this.isPreRendered=!0)}}const Hr="lightgray",Vr="gray",Ur=.25,Wr=.75,Fu={minorColor:Hr,majorColor:Vr,minorWidth:Ur,majorWidth:Wr};class Ee extends yt{constructor(t,n){super(t,n),this._offsetX=0,this._offsetY=0,this.options={...this.options,...n||Fu},this.render=this.render.bind(this)}onUpdate(t){super.onUpdate(t),this.render(t)}onRescale(t){super.onRescale(t),this.render(t)}render(t){const{ctx:n}=this,{minorWidth:i,minorColor:r,majorWidth:s,majorColor:o}=this.options;if(!n||(this.clearCanvas(),!(t.xScale||t.yScale)))return;const a=t.xScale.copy(),c=t.yScale.copy(),h=a.domain(),l=c.domain(),u=this.offsetX,f=this.offsetY;a.domain([h[0]-u,h[1]-u]),c.domain([l[0]-f,l[1]-f]);const[g,d]=a.range(),[p,y]=c.range();n.lineWidth=i||Ur,n.strokeStyle=r||Hr;const _=this.mapMinorTicks(a.ticks()),x=this.mapMinorTicks(c.ticks());this.renderTicksX(a,_,p,y),this.renderTicksY(c,x,g,d),n.lineWidth=s||Wr,n.strokeStyle=o||Vr,this.renderTicksX(a,a.ticks(),p,y),this.renderTicksY(c,c.ticks(),g,d),n.restore()}renderTicksX(t,n,i,r){n.forEach(s=>{const o=t(s);this.ctx.beginPath(),this.ctx.moveTo(o,i),this.ctx.lineTo(o,r),this.ctx.stroke()})}renderTicksY(t,n,i,r){n.forEach(s=>{const o=t(s);this.ctx.beginPath(),this.ctx.moveTo(i,o),this.ctx.lineTo(r,o),this.ctx.stroke()})}mapMinorTicks(t){let n=[];return t.length>=2&&(n=t.map(i=>i+(t[1]-t[0])/2),n.pop()),n}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t}}class zu extends yt{onMount(t){super.onMount(t);const n=document.createElement("img");this.img=n,this.isLoading=!0}onUpdate(t){super.onUpdate(t),this.img.src=t.url,this.render(t)}onRescale(t){super.onRescale(t),this.setTransform(t),this.render(t)}render(t){const n=parseInt(this.elm.getAttribute("width"),10),i=parseInt(this.elm.getAttribute("height"),10),{xScale:r,yScale:s,xRatio:o,yRatio:a,x:c,y:h}=t,l=n*(o||1),u=i*(a||1);this.clearCanvas(),this.isLoading?this.img.onload=()=>{this.isLoading=!1,this.ctx.drawImage(this.img,r(c||0),s(h||0),l,u)}:this.ctx.drawImage(this.img,r(c||0),s(h||0),l,u)}}const Du={dash:[10,5],width:1,color:16777215,alpha:1,scale:1,useTexture:!1,alignment:.5},xt=class{constructor(e,t={}){this.cursor=new st.Point,this.scale=1,this.graphics=e,t={...Du,...t},this.dash=t.dash,this.dashSize=this.dash.reduce((n,i)=>n+i),this.useTexture=t.useTexture,this.options=t,this.setLineStyle()}setLineStyle(){const e=this.options;if(this.useTexture){const t=xt.getTexture(e,this.dashSize);this.graphics.lineTextureStyle({width:e.width*e.scale,color:e.color,alpha:e.alpha,texture:t,alignment:e.alignment}),this.activeTexture=t}else this.graphics.lineStyle({width:e.width*e.scale,color:e.color,alpha:e.alpha,cap:e.cap,join:e.join,alignment:e.alignment});this.scale=e.scale}static distance(e,t,n,i){return Math.sqrt(Math.pow(n-e,2)+Math.pow(i-t,2))}moveTo(e,t){return this.lineLength=0,this.cursor.set(e,t),this.start=new st.Point(e,t),this.graphics.moveTo(this.cursor.x,this.cursor.y),this}lineTo(e,t,n){typeof this.lineLength===void 0&&this.moveTo(0,0);const i=xt.distance(this.cursor.x,this.cursor.y,e,t),r=Math.atan2(t-this.cursor.y,e-this.cursor.x),s=n&&e===this.start.x&&t===this.start.y;if(this.useTexture)if(this.graphics.moveTo(this.cursor.x,this.cursor.y),this.adjustLineStyle(r),s&&this.dash.length%2===0){const o=Math.min(this.dash[this.dash.length-1],i);this.graphics.lineTo(e-Math.cos(r)*o,t-Math.sin(r)*o),this.graphics.closePath()}else this.graphics.lineTo(e,t);else{const o=Math.cos(r),a=Math.sin(r);let c=this.cursor.x,h=this.cursor.y;const l=this.lineLength%(this.dashSize*this.scale);let u=0,f=0,g=0;for(let p=0;p<this.dash.length;p++){const y=this.dash[p]*this.scale;if(l<g+y){u=p,f=l-g;break}else g+=y}let d=i;for(;d>0;){const p=this.dash[u]*this.scale-f,y=d>p?p:d;if(s&&xt.distance(c+o*y,h+a*y,this.start.x,this.start.y)<=y){if(u%2===0){const x=xt.distance(c,h,this.start.x,this.start.y)-this.dash[this.dash.length-1]*this.scale;c+=o*x,h+=a*x,this.graphics.lineTo(c,h)}break}c+=o*y,h+=a*y,u%2?this.graphics.moveTo(c,h):this.graphics.lineTo(c,h),d-=y,u++,u=u===this.dash.length?0:u,f=0}}return this.lineLength+=i,this.cursor.set(e,t),this}closePath(){this.lineTo(this.start.x,this.start.y,!0)}drawCircle(e,t,n,i=80,r){const s=Math.PI*2/i;let o=0,a;r?(a=new st.Point(e+Math.cos(o)*n,t+Math.sin(o)*n),r.apply(a,a),this.moveTo(a[0],a[1])):(a=new st.Point(e+Math.cos(o)*n,t+Math.sin(o)*n),this.moveTo(a.x,a.y)),o+=s;for(let c=1;c<i+1;c++){const h=c===i?a:[e+Math.cos(o)*n,t+Math.sin(o)*n];this.lineTo(h[0],h[1]),o+=s}return this}drawEllipse(e,t,n,i,r=80,s){const o=Math.PI*2/r;let a;const c=new st.Point;for(let h=0;h<Math.PI*2;h+=o){let l=e-n*Math.sin(h),u=t-i*Math.cos(h);s&&(c.set(l,u),s.apply(c,c),l=c.x,u=c.y),h===0?(this.moveTo(l,u),a={x:l,y:u}):this.lineTo(l,u)}return this.lineTo(a.x,a.y,!0),this}drawPolygon(e,t){const n=new st.Point;if(typeof e[0]=="number")if(t){n.set(e[0],e[1]),t.apply(n,n),this.moveTo(n.x,n.y);for(let i=2;i<e.length;i+=2)n.set(e[i],e[i+1]),t.apply(n,n),this.lineTo(n.x,n.y,i===e.length-2)}else{this.moveTo(e[0],e[1]);for(let i=2;i<e.length;i+=2)this.lineTo(e[i],e[i+1],i===e.length-2)}else if(t){const i=e[0];n.copyFrom(i),t.apply(n,n),this.moveTo(n.x,n.y);for(let r=1;r<e.length;r++){const s=e[r];n.copyFrom(s),t.apply(n,n),this.lineTo(n.x,n.y,r===e.length-1)}}else{const i=e[0];this.moveTo(i.x,i.y);for(let r=1;r<e.length;r++){const s=e[r];this.lineTo(s.x,s.y,r===e.length-1)}}return this}drawRect(e,t,n,i,r){if(r){const s=new st.Point;s.set(e,t),r.apply(s,s),this.moveTo(s.x,s.y),s.set(e+n,t),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e+n,t+i),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e,t+i),r.apply(s,s),this.lineTo(s.x,s.y),s.set(e,t),r.apply(s,s),this.lineTo(s.x,s.y,!0)}else this.moveTo(e,t).lineTo(e+n,t).lineTo(e+n,t+i).lineTo(e,t+i).lineTo(e,t,!0);return this}adjustLineStyle(e){const t=this.graphics.line;t.matrix=new st.Matrix,e&&t.matrix.rotate(e),this.scale!==1&&t.matrix.scale(this.scale,this.scale);const n=-this.lineLength;t.matrix.translate(this.cursor.x+n*Math.cos(e),this.cursor.y+n*Math.sin(e)),this.graphics.lineStyle(t)}static getTexture(e,t){const n=e.dash.toString();if(xt.dashTextureCache[n])return xt.dashTextureCache[n];const i=document.createElement("canvas");i.width=t,i.height=Math.ceil(e.width);const r=i.getContext("2d");if(!r){console.warn("Did not get context from canvas");return}r.strokeStyle="white",r.globalAlpha=e.alpha,r.lineWidth=e.width;let s=0;const o=e.width/2;r.moveTo(s,o);for(let c=0;c<e.dash.length;c+=2)s+=e.dash[c],r.lineTo(s,o),e.dash.length!==c+1&&(s+=e.dash[c+1],r.moveTo(s,o));r.stroke();const a=xt.dashTextureCache[n]=st.Texture.from(i);return a.baseTexture.scaleMode=st.SCALE_MODES.NEAREST,a}};let Yr=xt;Yr.dashTextureCache={};const Rn=e=>new B(e.x,e.y),Ou=e=>new z.Point(e[0],e[1]),Gr=e=>{if(e.length<2)return[new B(0)];let t;return e.map((n,i,r)=>{if(i<r.length-1){const s=Rn(r[i]);return t=Rn(r[i+1]).sub(s).rotate90().normalized(),t}return t})},Xr=(e,t,n)=>{const i=Rn(e);return Ou(i.add(t.scale(n)))},Fn=(e,t,n)=>{if(e.length!==t.length)throw new Error("Number of vectors does not match number of points");return e.map((i,r)=>{const s=t[r];return Xr(i,s,n)})},jr=(e,t,n,i)=>e<=i&&n<=t,Nu=(e,t,n,i)=>e<i&&n<t,$u=e=>Array.from(new Set(e)),Re=(e,t,n,i)=>{const r=i.filter(o=>jr(e,t,o.start,o.end)),s=n.filter(o=>jr(e,t,o.start,o.end));return{overlappingHoles:r,overlappingOuterStrings:s}},Fe=([e,t],n)=>{const s=n.flatMap(a=>[a.start-1e-4,a.start,a.end,a.end+1e-4]).filter(a=>a>=e&&a<=t);return s.push(e),s.push(t),$u(s).sort((a,c)=>a-c)},K=e=>e.kind==="casing"?e.innerDiameter:e.diameter,qr=(e,t,n,i)=>{const s=e.find(h=>h.start<=i&&h.end>=i),o=s?s.diameter:0,a=t.filter(h=>K(h)>o).sort((h,l)=>K(h)-K(l)).find(h=>h.start<=i&&h.end>=i),c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter>o);return a?K(a):c?c.diameter:100},Bu=(e,t,n,i)=>{const s=e.sort((a,c)=>c.diameter-a.diameter).find(a=>a.start<=n&&a.end>=n),o=t.find(a=>a.start<=n&&a.end>=n);return s&&i!=="Open hole frac pack"&&i!=="Open hole gravel pack"?K(s):o?o.diameter:100},Iu=(e,t,n,i)=>{const s=e.sort((h,l)=>K(h)-K(l)).find(h=>h.start<=i&&h.end>=i);if(s)return K(s);const o=e.length?Math.min(...e.map(h=>K(h))):0,a=t.sort((h,l)=>K(h)-K(l)).find(h=>h.start<=i&&h.end>=i&&o<=K(h));if(a)return K(a);const c=n.find(h=>h.start<=i&&h.end>=i&&h.diameter);return c?c.diameter:100},Hu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=zn(e.referenceIds,t,n);if(o.length===0)throw new Error(`Invalid cement data, can't find referenced casing/completion string for cement with id '${e.id}'`);o.sort((p,y)=>p.end-y.end);const c=o[o.length-1].end,{overlappingOuterStrings:h,overlappingHoles:l}=Re(e.toc,c,a,i),u=[...h,...l].map(p=>({start:p.start,end:p.end}));return Fe([e.toc,c],u).flatMap((p,y,_)=>{if(y===_.length-1)return[];const x=_[y+1],v=qr(o,h,l,p);return[{top:p,bottom:x,diameter:v*r}]}).map(p=>({diameter:p.diameter,points:s(p.top,p.bottom)}))},zn=(e,t,n)=>[...t,...n].reduce((i,r)=>e.includes(r.id)?{...i,attachedStrings:[...i.attachedStrings,r]}:{...i,nonAttachedStrings:[...i.nonAttachedStrings,r]},{attachedStrings:[],nonAttachedStrings:[]}),Vu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=zn(e.referenceIds,t,n);if(o.length===0)throw new Error(`Invalid cement squeeze data, can't find referenced casing/completion for squeeze with id '${e.id}'`);const{overlappingOuterStrings:c,overlappingHoles:h}=Re(e.start,e.end,a,i),l=[...c,...h].map(d=>({start:d.start,end:d.end}));return Fe([e.start,e.end],l).flatMap((d,p,y)=>{if(p===y.length-1)return[];const _=y[p+1],x=qr(o,c,h,d);return[{top:d,bottom:_,diameter:x*r}]}).map(d=>({diameter:d.diameter,points:s(d.top,d.bottom)}))},Uu=(e,t,n,i,r,s)=>{const{attachedStrings:o,nonAttachedStrings:a}=zn(e.referenceIds,t,n),{overlappingHoles:c,overlappingOuterStrings:h}=Re(e.start,e.end,a,i),l=[...o,...c,...h].map(d=>({start:d.start,end:d.end}));return Fe([e.start,e.end],l).flatMap((d,p,y)=>{if(p===y.length-1)return[];const _=y[p+1],x=Iu(o,h,c,d);return[{top:d,bottom:_,diameter:x*r}]}).map(d=>({diameter:d.diameter,points:s(d.top,d.bottom)}))},Wu=(e,t,n,i,r)=>{const o=t.createLinearGradient(0,0,0,e.height);return o.addColorStop(0,n),o.addColorStop(.5-r,i),o.addColorStop(.5+r,i),o.addColorStop(1,n),o},Yu=({firstColor:e,secondColor:t},n,i)=>{const r=document.createElement("canvas");r.width=n,r.height=i;const s=r.getContext("2d");return s.fillStyle=Wu(r,s,e,t,0),s.fillRect(0,0,r.width,r.height),z.Texture.from(r)},Gu=({scalingFactor:e})=>{const t=document.createElement("canvas"),n=mt*e;t.width=n,t.height=n;const i=t.getContext("2d");i.fillStyle="white",i.fillRect(0,0,t.width,t.height);const r=n/10;i.strokeStyle="#AAAAAA",i.lineWidth=r,i.beginPath();const s=n/3;for(let o=-t.width;o<t.width;o++)i.moveTo(-t.width+s*o,-t.height),i.lineTo(t.width+s*o,t.height*2);return i.stroke(),z.Texture.from(t)},Xu=({innerColor:e,outerColor:t,scalingFactor:n})=>{const i=mt*n,r=document.createElement("canvas");r.width=i,r.height=i;const s=r.getContext("2d"),o=s.createLinearGradient(0,0,0,i),a=.3,c=.7;return o.addColorStop(0,t),o.addColorStop(a,e),o.addColorStop(c,e),o.addColorStop(1,t),s.fillStyle=o,s.fillRect(0,0,r.width,r.height),z.Texture.from(r)},ju=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=mt*n,s=n;i.width=r,i.height=r;const o=i.getContext("2d");o.fillStyle=e,o.fillRect(0,0,i.width,i.height),o.lineWidth=s,o.fillStyle=t,o.beginPath();const a=r/12;for(let c=-i.width;c<i.width;c++)o.moveTo(-i.width+a*c,-i.height),o.lineTo(i.width+a*c,i.height);return o.stroke(),z.Texture.from(i)},qu=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=mt*n;i.width=r,i.height=r;const s=i.getContext("2d");s.fillStyle=e,s.fillRect(0,0,i.width,i.height),s.lineWidth=n,s.strokeStyle=t,s.beginPath(),s.setLineDash([20,10]);const o=r/12;for(let a=-i.width;a<i.width;a++)s.moveTo(-i.width+o*a,-i.height),s.lineTo(i.width+o*a,i.height*2);return s.stroke(),z.Texture.from(i)},Zu=({firstColor:e,secondColor:t,scalingFactor:n})=>{const i=document.createElement("canvas"),r=mt*n,s=n;i.width=r,i.height=r;const o=i.getContext("2d");o.lineWidth=s,o.fillStyle=e,o.strokeStyle=t,o.fillRect(0,0,i.width,i.height),o.beginPath(),o.setLineDash([20,10]);const a=r/12;for(let c=-i.width;c<i.width;c++)o.moveTo(-i.width+a*c,-i.height),o.lineTo(i.width+a*c,i.height*2);return o.stroke(),z.Texture.from(i)},ze=(e,t)=>{const n=Gr(t),i=Fn(t,n,e);return{leftPath:Fn(t,n,-e),rightPath:i}},Dn=(e,t)=>({kind:"casing",start:e,end:t}),Ku=(e,t)=>({kind:"casing-window",start:e,end:t}),Qu=e=>{const t=(e.windows||[]).filter(n=>Nu(e.start,e.end,n.start,n.end)).reduce(({intervals:n,lastBottom:i},r,s,o)=>{const a=i<r.start?Dn(i,r.start):null,c=a?a.end:i,h=Math.max(c,r.start),l=Math.min(e.end,r.end),u=Ku(h,l),f=l,d=s===o.length-1&&f<e.end?Dn(f,e.end):null,p=[a,u,d].filter(y=>y);return{intervals:[...n,...p],lastBottom:f}},{intervals:[],lastBottom:e.start});return t.intervals.length?t.intervals:[Dn(e.start,e.end)]},Ju=(e,t,n)=>{const i=t.diameter*e,r=i/2,o=t.innerDiameter*e/2,a=r-o,c=Qu(t).map(h=>{const l=n(h.start,h.end),{leftPath:u,rightPath:f}=ze(r,l);return{kind:h.kind,leftPath:u,rightPath:f,pathPoints:l}});return{kind:"casing",id:t.id,referenceDiameter:i,referenceRadius:r,sections:c,casingWallWidth:a,hasShoe:t.hasShoe,bottom:t.end}},tf=(e,t,n,i,r)=>{const{overlappingOuterStrings:s,overlappingHoles:o}=Re(e.start,e.end,t,n),a=[...s,...o].map(u=>({start:u.start,end:u.end}));return Fe([e.start,e.end],a).flatMap((u,f,g)=>{if(f===g.length-1)return[];const d=g[f+1],p=Bu(s,o,u,e.subKind);return[{top:u,bottom:d,diameter:p*i}]}).map(u=>{const f=r(u.top,u.bottom);return{diameter:u.diameter,points:f}})},De=(e,t,n)=>{const{packingOpacity:i,yellow:r}=n;t.fillStyle=r,t.strokeStyle=r;const s=[0,0],o=[e.width,e.height];t.save(),t.globalAlpha=i,t.fillRect(...s,...o),t.restore()},On=(e,t,n,i,r)=>{const{fracLineCurve:s}=i,o=10,a=e.width/o,c=n/3*i.scalingFactor,h=c/4,l=c/2,u=0,f=r==="diameter"?0:l,g=()=>{for(let d=-1;d<o;d++){const p=[d*a+u+a/2,e.height/2-h-f-h];t.beginPath();const y=[...p],_=[p[0]-s*2,p[1]-h/4],x=[p[0],p[1]-h/2],v=[p[0]+s*2,p[1]-h/2-h/4],C=[p[0],p[1]-h];t.bezierCurveTo(...y,..._,...x),t.bezierCurveTo(...x,...v,...C),t.stroke()}for(let d=-1;d<o;d++){const p=[d*a+a+u+a/2,e.height/2+c/2+f];t.beginPath();const y=[...p],_=[p[0]-s*2,p[1]+h/4],x=[p[0],p[1]+h/2],v=[p[0]+s*2,p[1]+h/2+h/4],C=[p[0],p[1]+h];t.bezierCurveTo(...y,..._,...x),t.bezierCurveTo(...x,...v,...C),t.stroke()}};t.strokeStyle=i.yellow,t.lineWidth=6,t.save(),t.globalAlpha=i.packingOpacity,g(),t.restore(),t.lineWidth=1,t.strokeStyle=i.outline,g(),t.closePath()},ef=(e,t,n,i)=>{const s=e.width/10;t.strokeStyle=i.outline;const o=n/3*i.scalingFactor;t.lineWidth=1;const a=o/2,c=0;for(let h=0;h<=10;h++){const l=[h*s+c,e.height/2-o/2],u=[l[0]-s/2,l[1]-a],f=[l[0]-s,l[1]];t.beginPath(),t.moveTo(...l),t.lineTo(...u),t.lineTo(...f),t.fill(),t.lineWidth=1,t.stroke()}for(let h=0;h<=10;h++){const l=[h*s+c,e.height/2+o/2],u=[l[0]-s/2,l[1]+a],f=[l[0]-s,l[1]];t.beginPath(),t.moveTo(...l),t.lineTo(...u),t.lineTo(...f),t.fill(),t.lineWidth=1,t.stroke()}t.closePath()},ct=(e="Error!",t)=>{console.error(`${e}`);const n=(t==null?void 0:t.canvas)||document.createElement("canvas"),i=mt;n.width=i/2,n.height=i;const r=(t==null?void 0:t.canvasCtx)||n.getContext("2d"),s=[0,0],o=[n.width,n.height];return r.fillStyle="#ff00ff",r.fillRect(...s,...o),new z.Texture(z.Texture.from(n,{wrapMode:z.WRAP_MODES.CLAMP}).baseTexture,null,new z.Rectangle(0,0,n.width,n.height),null,z.groupD8.MIRROR_HORIZONTAL)},vt=(e,t)=>{const n=document.createElement("canvas"),r=e.diameter*t.scalingFactor;n.width=r/2,n.height=r;const s=n.getContext("2d");return{canvas:n,ctx:s}},wt=e=>new z.Texture(z.Texture.from(e,{wrapMode:z.WRAP_MODES.CLAMP}).baseTexture,null,new z.Rectangle(0,0,e.width,e.height),null,z.groupD8.MIRROR_HORIZONTAL),Nn={packing:()=>ct(),fracLines:()=>ct(),spikes:(e,t,n,i)=>{const{canvas:r,ctx:s}=vt(t,i),o=n.some(h=>br(h)&&Pn(e,h)),a=n.some(h=>Sr(h)&&Pn(e,h));return o||a?e.isOpen?(s.fillStyle=i.yellow,s.strokeStyle=i.yellow):(s.fillStyle=i.grey,s.strokeStyle=i.grey):e.isOpen?(s.fillStyle=i.red,s.strokeStyle=i.red):(s.fillStyle=i.grey,s.strokeStyle=i.grey),ef(r,s,t.diameter,i),a&&On(r,s,t.diameter,i,"spike"),wt(r)}},Zr={packing:()=>ct(),fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return On(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>ct()},Oe={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return De(n,i,t),wt(n)},fracLines:(e,t)=>{const{canvas:n}=vt(e,t);return wt(n)},spikes:()=>ct()},$n={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return De(n,i,t),wt(n)},fracLines:()=>ct(),spikes:()=>ct()},Bn={packing:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return De(n,i,t),wt(n)},fracLines:()=>ct(),spikes:()=>ct()},In={packing:(e,t,n)=>{const{canvas:i,ctx:r}=vt(t,n);return De(i,r,n),wt(i)},fracLines:(e,t)=>{const{canvas:n,ctx:i}=vt(e,t);return On(n,i,e.diameter,t,"diameter"),wt(n)},spikes:()=>ct()},nf=(e,t,n)=>Z({Perforation:()=>Nn.packing(),CasedHoleFracturation:()=>Oe.packing(t,n),CasedHoleFracPack:()=>Oe.packing(t,n),OpenHoleGravelPack:()=>Bn.packing(t,n),OpenHoleFracPack:()=>In.packing(e,t,n),CasedHoleGravelPack:()=>$n.packing(t,n)},e.subKind),rf=(e,t,n)=>Z({Perforation:()=>Nn.fracLines(),OpenHoleGravelPack:()=>Bn.fracLines(),OpenHoleFracPack:()=>In.fracLines(t,n),CasedHoleFracturation:()=>Zr.fracLines(t,n),CasedHoleGravelPack:()=>$n.fracLines(),CasedHoleFracPack:()=>Oe.fracLines(t,n)},e.subKind),sf=(e,t,n,i)=>Z({Perforation:()=>Nn.spikes(e,n,t,i),OpenHoleGravelPack:()=>Bn.spikes(),OpenHoleFracPack:()=>In.spikes(),CasedHoleFracturation:()=>Zr.spikes(),CasedHoleGravelPack:()=>$n.spikes(),CasedHoleFracPack:()=>Oe.spikes()},e.subKind);class of extends z.MeshGeometry{constructor(t,n=0){const i=We(t,r=>r.points.length);super(new Float32Array(i*4),new Float32Array(i*4),new Uint16Array((i-1)*6)),this.segments=t,this.textureScale=n,this.build()}get width(){return Ue(this.segments,t=>t.diameter)}build(){const t=this.segments;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex(),s=We(t,d=>d.points.length);if(s<1)return;n.data.length/4!==s&&(n.data=new Float32Array(s*4),i.data=new Float32Array(s*4),r.data=new Uint16Array((s-1)*6));const o=i.data,a=r.data;o[0]=0,o[1]=0,o[2]=0,o[3]=1;const c=t.length,h=Ue(t,d=>d.diameter);let l=0,u=0,f=0,g=0;for(let d=0;d<c;d++){let p=t[d].points[0];const y=h,_=t[d].diameter/h/2,x=t[d].points.length;for(let v=0;v<x;v++){const C=p.x-t[d].points[v].x,b=p.y-t[d].points[v].y,S=Math.sqrt(C*C+b*b);p=t[d].points[v],l+=S/y,o[u]=l,o[u+1]=.5-_,o[u+2]=l,o[u+3]=.5+_,u+=4}for(let v=0;v<x-1;v++)a[g++]=f,a[g++]=f+1,a[g++]=f+2,a[g++]=f+2,a[g++]=f+1,a[g++]=f+3,f+=2;f+=2}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.segments;if(We(t,s=>s.points.length)<1)return;const i=t.length;let r=0;for(let s=0;s<i;s++){let o=t[s].points[0],a,c=0,h=0;const l=this.buffers[0].data,u=t[s].points.length;let f=0;for(let g=0;g<u;g++){const d=t[s].points[g];f=r+g*4,g<t[s].points.length-1?a=t[s].points[g+1]:a=d,h=-(a.x-o.x),c=a.y-o.y;const p=Math.sqrt(c*c+h*h),y=t[s].diameter/2;c/=p,h/=p,c*=y,h*=y,l[f]=d.x+c,l[f+1]=d.y+h,l[f+2]=d.x-c,l[f+3]=d.y-h,o=d}r=f+4}this.buffers[0].update()}update(){this.build()}}class af extends z.Mesh{constructor(t,n,i=0){const r=new of(n,i),s=new z.MeshMaterial(t);t.baseTexture.wrapMode=z.WRAP_MODES.REPEAT,super(r,s),this.autoUpdate=!0}_render(t){const n=this.geometry;this.autoUpdate&&n.update(),super._render(t)}}class cf extends z.MeshGeometry{constructor(t,n=200){super(new Float32Array(t.length*4),new Float32Array(t.length*4),new Uint16Array((t.length-1)*6)),this.points=t,this._width=n,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex();if(t.length<1)return;n.data.length/4!==t.length&&(n.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const s=i.data,o=r.data;s[0]=0,s[1]=0,s[2]=0,s[3]=1;let a=0,c=t[0];const h=t.length;for(let u=0;u<h;u++){const f=u*4,g=c.x-t[u].x,d=c.y-t[u].y,p=Math.sqrt(g*g+d*d);c=t[u],a+=p/this._width,s[f]=a,s[f+1]=0,s[f+2]=a,s[f+3]=1}let l=0;for(let u=0;u<h-1;u++){const f=u*2;o[l++]=f,o[l++]=f+1,o[l++]=f+2,o[l++]=f+2,o[l++]=f+1,o[l++]=f+3}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let n=t[0],i,r=0,s=0;const o=this.buffers[0].data,a=t.length;for(let c=0;c<a;c++){const h=t[c],l=c*4;c<t.length-1?i=t[c+1]:i=h,s=-(i.x-n.x),r=i.y-n.y;const u=Math.sqrt(r*r+s*s),f=this._width/2;r/=u,s/=u,r*=f,s*=f,o[l]=h.x+r,o[l+1]=h.y+s,o[l+2]=h.x-r,o[l+3]=h.y-s,n=h}this.buffers[0].update()}update(){this.build()}}class hf extends z.Mesh{constructor(t,n,i){const r=new cf(n,i),s=new z.MeshMaterial(t);t.baseTexture.wrapMode=z.WRAP_MODES.REPEAT,super(r,s),this.autoUpdate=!0}_render(t){const n=this.geometry;this.autoUpdate&&n.update(),super._render(t)}}class lf extends z.MeshGeometry{constructor(t,n=200){super(new Float32Array(t.length*4),new Float32Array(t.length*4),new Uint16Array((t.length-1)*6)),this.points=t,this._width=n,this.build()}build(){const t=this.points;if(!t)return;const n=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex();if(t.length<1)return;n.data.length/4!==t.length&&(n.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const s=t.length;let o=0,a=t[0];for(let g=0;g<s;g++){const d=a.x-t[g].x,p=a.y-t[g].y,y=Math.sqrt(d*d+p*p);a=t[g],o+=y}const c=i.data,h=r.data;c[0]=0,c[1]=0,c[2]=0,c[3]=1;let l=0,u=t[0];for(let g=0;g<s;g++){const d=g*4,p=u.x-t[g].x,y=u.y-t[g].y,_=Math.sqrt(p*p+y*y);u=t[g],l+=_/o,c[d]=l,c[d+1]=0,c[d+2]=l,c[d+3]=1}let f=0;for(let g=0;g<s-1;g++){const d=g*2;h[f++]=d,h[f++]=d+1,h[f++]=d+2,h[f++]=d+2,h[f++]=d+1,h[f++]=d+3}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let n=t[0],i,r=0,s=0;const o=this.buffers[0].data,a=t.length;for(let c=0;c<a;c++){const h=t[c],l=c*4;c<t.length-1?i=t[c+1]:i=h,s=-(i.x-n.x),r=i.y-n.y;const u=Math.sqrt(r*r+s*s),f=this._width/2;r/=u,s/=u,r*=f,s*=f,o[l]=h.x+r,o[l+1]=h.y+s,o[l+2]=h.x-r,o[l+3]=h.y-s,n=h}this.buffers[0].update()}update(){this.updateVertices()}}class uf extends z.Mesh{constructor(t,n){const i=new lf(n,t.height),r=new z.MeshMaterial(t);super(i,r),this.autoUpdate=!0}_render(t){const n=this.geometry;(this.autoUpdate||n._width!==this.shader.texture.height)&&(n._width=this.shader.texture.height,n.update()),super._render(t)}}const ff=(e,t,n)=>i=>{switch(i.kind){case"casing":return e(i);case"cement":return t(i);case"cementSqueeze":return n(i);default:return Qt(i)}},df=e=>({exaggerationFactor:2,internalLayerOptions:Tr(e),holeOptions:Mr,casingOptions:Ar,cementOptions:Cr,cementSqueezeOptions:Lr,screenOptions:kr,tubingOptions:Er,cementPlugOptions:Rr,perforationOptions:Pr}),Kr=class extends An{constructor(e,t,n){super(e,t,n),this.internalLayerVisibility={holeLayerId:!0,casingLayerId:!0,completionLayerId:!0,cementLayerId:!0,pAndALayerId:!0,perforationLayerId:!0},this.scalingFactors={height:600,zFactor:1,yScale:Tt()},this.getZFactorScaledPathForPoints=(i,r)=>{const s=a=>a*this.scalingFactors.zFactor;return this.referenceSystem.getCurtainPath(i,r,!0).map(a=>new z.Point(a.point[0],s(a.point[1])))},this.drawBigPolygon=(i,r=0)=>{const s=new z.Graphics;s.beginFill(r),s.drawPolygon(i),s.endFill(),this.addChild(s)},this.perforationRopeAndTextureReferences=[],this.prepareSymbolRenderObject=i=>{const{exaggerationFactor:r}=this.options,s=i.diameter*r;return{pathPoints:this.getZFactorScaledPathForPoints(i.start,i.end),referenceDiameter:s,symbolKey:i.symbolKey}},this.drawSymbolComponent=({pathPoints:i,referenceDiameter:r,symbolKey:s})=>{const o=this.getSymbolTexture(s,r);this.drawSVGRope(i,o)},this.drawHoleSize=(i,r)=>{if(r==null)return;const s=this.getZFactorScaledPathForPoints(r.start,r.end);if(s.length===0)return;const{exaggerationFactor:o,holeOptions:a}=this.options,c=r.diameter*o,{rightPath:h,leftPath:l}=ze(c/2,s),u=this.getHoleTexture(a,c,i);this.drawHoleRope(s,u,i),this.drawOutline(l,h,dt(a.lineColor),xl*o,"TopAndBottom",0)},this.drawCasing=i=>{const{casingOptions:r}=this.options,s=dt(r.solidColor),o=dt(r.lineColor);i.sections.forEach((a,c,h)=>{const l=Kr.getOutlineClosureType(c,h.length-1),u=this.createCasingTexture(i.referenceDiameter);this.drawRope(a.pathPoints,u,s),a.kind==="casing-window"?this.drawCasingWindowOutline(a.leftPath,a.rightPath,r,i.casingWallWidth):this.drawOutline(a.leftPath,a.rightPath,o,i.casingWallWidth,l)})},this.generateShoe=(i,r,s,o)=>{const a=i-s,c=i,h=this.getZFactorScaledPathForPoints(a,c),l=Gr(h),u=Fn(h,l,r*(o<0?-1:1)),f=h[h.length-1],g=l[l.length-1],d=Xr(f,g,o+r*(o<0?-1:1));return[...u,d]},this.createCementSqueezeShape=(i,r,s,o)=>{const{exaggerationFactor:a}=this.options;return Vu(i,r,s,o,a,this.getZFactorScaledPathForPoints)},this.createPerforationShape=(i,r,s)=>{const{exaggerationFactor:o}=this.options;return tf(i,r,s,o,this.getZFactorScaledPathForPoints)},this.options={...this.options,...df(this.id),...n}}onUnmount(e){super.onUnmount(e),this.scalingFactors=null,this.cementTextureCache=null,this.cementSqueezeTextureCache=null,this.holeTextureCache=null,this.screenTextureCache=null,this.tubingTextureCache=null,this.textureSymbolCacheArray=null,this.internalLayerVisibility=null}onUpdate(e){super.onUpdate(e),this.clearLayer(),this.preRender(),this.render()}onRescale(e){const t=this.scalingFactors.zFactor!==e.zFactor;this.scalingFactors={height:e.height,zFactor:e.zFactor,yScale:e.yScale},super.optionsRescale(e);const n=this.yRatio(),i=e.xBounds[0]>e.xBounds[1],r=e.yBounds[0]>e.yBounds[1];this.setContainerPosition(e.xScale(0),e.yScale(0)),this.setContainerScale(e.xRatio*(i?-1:1),n*(r?-1:1)),t&&(this.clearLayer(),this.preRender()),this.render()}setVisibility(e,t){if(t===this.id){super.setVisibility(e,t);return}const{internalLayerOptions:n}=this.options,[i]=Object.entries(n).find(([r,s])=>s===t);i&&(this.internalLayerVisibility[i]=e,this.clearLayer(),this.preRender(),this.render())}getInternalLayerIds(){const{internalLayerOptions:e}=this.options;return Object.values(e)}yRatio(){const e=this.scalingFactors.yScale.domain(),n=(e[1]-e[0])*this.scalingFactors.zFactor,i=[e[0],e[0]+n];return Math.abs(this.scalingFactors.height/(i[1]-i[0]))}drawRope(e,t,n){if(e.length===0)return null;const i=new z.SimpleRope(t,e,1);i.tint=n||i.tint,this.addChild(i)}drawOutline(e,t,n,i=1,r="None",s=1){const o=e.map(l=>l.clone()).reverse(),a=t[0],c=o[0],h=new z.Graphics;h.lineStyle(i,n,void 0,s),h.moveTo(a.x,a.y),t.forEach(l=>h.lineTo(l.x,l.y)),(r==="None"||r==="Top")&&h.moveTo(c.x,c.y),o.forEach(l=>h.lineTo(l.x,l.y)),(r==="TopAndBottom"||r==="Top")&&h.lineTo(a.x,a.y),this.addChild(h)}drawCasingWindowOutline(e,t,{lineColor:n,windowOptions:i},r=1){var d,p;const s=!!((p=(d=this.referenceSystem)==null?void 0:d.options)!=null&&p.calculateDisplacementFromBottom),[o,a]=s?[e,t]:[t,e],[c,h]=s?[1,0]:[0,1],l=new z.Graphics;l.lineStyle(r,dt(n),void 0,h);const u=o[0];l.moveTo(u.x,u.y),o.forEach(y=>l.lineTo(y.x,y.y));const f=new Yr(l,{dash:[i.dashLength,i.spaceLength],color:dt(i.dashColor),width:r,alignment:c}),g=a[0];f.moveTo(g.x,g.y),a.forEach(y=>{f.lineTo(y.x,y.y)}),this.addChild(l)}preRender(){if(!this.data||!this.referenceSystem)return;const{exaggerationFactor:e}=this.options,{holeSizes:t,casings:n,cements:i,completion:r,symbols:s,pAndA:o,perforations:a}=this.data;this.updateSymbolCache(s),t.sort((d,p)=>p.diameter-d.diameter);const c=t.length>0?Ue(t,d=>d.diameter)*e:_l*e;this.internalLayerVisibility.holeLayerId&&t.forEach(d=>this.drawHoleSize(c,d)),n.sort((d,p)=>p.diameter-d.diameter);const h=n.map(d=>this.createCasingRenderObject(d)),l=i.map(d=>({kind:"cement",segments:Hu(d,n,r,t,e,this.getZFactorScaledPathForPoints),casingIds:(d.referenceIds||[]).filter(p=>p)})),[u,f]=o.reduce(([d,p],y)=>mr(y)?[[y,...d],p]:[d,[y,...p]],[[],[]]),g=u.map(d=>({kind:"cementSqueeze",segments:this.createCementSqueezeShape(d,n,r,t),casingIds:d.referenceIds}));if(this.sortCementAndCasingRenderObjects(h,l,g).forEach(ff(d=>{this.internalLayerVisibility.casingLayerId&&(this.drawCasing(d),d.hasShoe&&this.drawShoe(d.bottom,d.referenceRadius))},d=>{this.internalLayerVisibility.cementLayerId&&this.drawComplexRope(d.segments,this.getCementTexture())},d=>{this.internalLayerVisibility.pAndALayerId&&this.drawComplexRope(d.segments,this.getCementSqueezeTexture())})),this.perforationRopeAndTextureReferences.forEach(({rope:d,texture:p})=>{d.destroy({children:!0,texture:!0,baseTexture:!0}),p.destroy(!0)}),this.perforationRopeAndTextureReferences=[],this.internalLayerVisibility.perforationLayerId){const{perforationOptions:d}=this.options,p=a.filter(xr),y=a.filter(vr),_=a.filter(wr);p.forEach(x=>{const C=this.createPerforationShape(x,n,t).reduce((b,S)=>(b[S.diameter]||(b[S.diameter]=[]),b[S.diameter]=[...b[S.diameter],S],b),{});Object.values(C).forEach(b=>{const S=nf(x,b[0],d),M=this.drawComplexRope(b,S);this.perforationRopeAndTextureReferences.push({rope:M,texture:S})})}),y.forEach(x=>{const b=this.createPerforationShape(x,n,t).map(S=>({...S,diameter:S.diameter*3})).reduce((S,M)=>(S[M.diameter]||(S[M.diameter]=[]),S[M.diameter]=[...S[M.diameter],M],S),{});Object.values(b).forEach(S=>{S.forEach(M=>{const R=rf(x,M,d),F=this.drawComplexRope([M],R);this.perforationRopeAndTextureReferences.push({rope:F,texture:R})})})}),_.forEach(x=>{const b=this.createPerforationShape(x,n,t).map(S=>({...S,diameter:S.diameter*3})).reduce((S,M)=>(S[M.diameter]||(S[M.diameter]=[]),S[M.diameter]=[...S[M.diameter],M],S),{});Object.values(b).forEach(S=>{S.forEach(M=>{const R=sf(x,a,M,d),F=this.drawComplexRope([M],R);this.perforationRopeAndTextureReferences.push({rope:F,texture:R})})})})}this.internalLayerVisibility.completionLayerId&&r.forEach(_r(d=>this.drawScreen(d),d=>this.drawTubing(d),d=>{const p=this.prepareSymbolRenderObject(d);this.drawSymbolComponent(p)})),this.internalLayerVisibility.pAndALayerId&&f.forEach(d=>{if(pr(d)){const p=this.prepareSymbolRenderObject(d);this.drawSymbolComponent(p)}yr(d)&&this.drawCementPlug(d,n,r,t)})}updateSymbolCache(e){if(this.textureSymbolCacheArray||(this.textureSymbolCacheArray={}),!e)return;const t=Object.keys(this.textureSymbolCacheArray);Object.entries(e).forEach(([n,i])=>{t.includes(n)||(this.textureSymbolCacheArray[n]=z.Texture.from(i))})}drawCementPlug(e,t,n,i){const{exaggerationFactor:r,cementPlugOptions:s}=this.options,o=Uu(e,t,n,i,r,this.getZFactorScaledPathForPoints);this.drawComplexRope(o,this.getCementPlugTexture(s));const{rightPath:a,leftPath:c}=o.reduce((h,l)=>{const{leftPath:u,rightPath:f}=ze(l.diameter/2,l.points);return{rightPath:[...h.rightPath,...f],leftPath:[...h.leftPath,...u]}},{rightPath:[],leftPath:[]});this.drawOutline(c,a,dt("black"),.25,"TopAndBottom")}createCasingRenderObject(e){const{exaggerationFactor:t}=this.options;return Ju(t,e,this.getZFactorScaledPathForPoints)}getCementPlugTexture(e){return this.cementPlugTextureCache||(this.cementPlugTextureCache=qu(e)),this.cementPlugTextureCache}drawSVGRope(e,t){if(e.length===0)return null;const n=new uf(t,e);this.addChild(n)}getSymbolTexture(e,t){return new z.Texture(this.textureSymbolCacheArray[e].baseTexture,null,new z.Rectangle(0,0,0,t),null,z.groupD8.MAIN_DIAGONAL)}drawHoleRope(e,t,n){if(e.length===0)return null;const i=new z.SimpleRope(t,e,n/mt);this.addChild(i)}getHoleTexture(e,t,n){const i=mt,r=i,s=i,o=t/n*i;this.holeTextureCache||(this.holeTextureCache=Yu(e,s,r));const a=this.holeTextureCache.baseTexture,c=(r-o)/2,h=new z.Rectangle(0,c,s,o);return new z.Texture(a,h)}sortCementAndCasingRenderObjects(e,t,n){let i=0;const{result:r}=e.reduce((s,o)=>{const a=s.remainingCement.find(h=>h.casingIds.includes(o.id)),c=s.remainingCementSqueezes.filter(h=>h.casingIds.includes(o.id));return a&&(a.zIndex=i++),c.forEach(h=>h.zIndex=i++),o.zIndex=i++,{result:[...s.result,a,o,...c],remainingCement:s.remainingCement.filter(h=>h!==a),remainingCementSqueezes:s.remainingCementSqueezes.filter(h=>!c.includes(h))}},{result:[],remainingCement:t,remainingCementSqueezes:n});return r.filter(s=>s!==void 0).sort((s,o)=>s.zIndex-o.zIndex)}drawComplexRope(e,t){if(e.length===0)return null;const{exaggerationFactor:n}=this.options,i=new af(t,e,n);return this.addChild(i),i}createCasingTexture(e){return new z.Texture(z.Texture.WHITE.baseTexture,null,new z.Rectangle(0,0,16,e))}drawShoe(e,t){const{exaggerationFactor:n,casingOptions:i}=this.options,r=i.shoeSize.width*n,s=i.shoeSize.length*n,o=this.generateShoe(e,t,s,r),a=this.generateShoe(e,t,s,-r);this.drawBigPolygon(a),this.drawBigPolygon(o)}getCementTexture(){if(!this.cementTextureCache){const{cementOptions:e}=this.options;this.cementTextureCache=ju(e)}return this.cementTextureCache}getCementSqueezeTexture(){if(!this.cementSqueezeTextureCache){const{cementSqueezeOptions:e}=this.options;this.cementSqueezeTextureCache=Zu(e)}return this.cementSqueezeTextureCache}drawScreen({start:e,end:t,diameter:n}){const{exaggerationFactor:i,screenOptions:r}=this.options,s=i*n,o=this.getZFactorScaledPathForPoints(e,t),{leftPath:a,rightPath:c}=ze(s/2,o),h=this.getScreenTexture();this.drawCompletionRope(o,h,s),this.drawOutline(a,c,dt(r.lineColor),vl*i,"TopAndBottom")}drawTubing({diameter:e,start:t,end:n}){const{exaggerationFactor:i,tubingOptions:r}=this.options,s=i*e,o=this.getZFactorScaledPathForPoints(t,n),a=this.getTubingTexture(r);this.drawCompletionRope(o,a,s)}getTubingTexture(e){return this.tubingTextureCache||(this.tubingTextureCache=Xu(e)),this.tubingTextureCache}getScreenTexture(){if(!this.screenTextureCache){const{screenOptions:e}=this.options;this.screenTextureCache=Gu(e)}return this.screenTextureCache}drawCompletionRope(e,t,n){if(e.length===0)return;const i=new hf(t,e,n);this.addChild(i)}};let Qr=Kr;Qr.getOutlineClosureType=(e,t)=>e===0?e===t?"TopAndBottom":"Top":e===t?"Bottom":"None";class gf extends yt{onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.clearCanvas(),this.render()}onRescale(t){super.onRescale(t),this.setTransform(t),this.render()}render(){if(!this.data||!this.ctx||!this.data.image)return;const{ctx:t}=this,{options:n,image:i}=this.data;this.clearCanvas(),t.drawImage(i,n.x,n.y,n.width,n.height)}}function Ot(e){return function(){return e}}const Jr=1e-12,Hn=Math.PI,Vn=2*Hn,Pt=1e-6,pf=Vn-Pt;function ts(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function mf(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return ts;const n=10**t;return function(i){this._+=i[0];for(let r=1,s=i.length;r<s;++r)this._+=Math.round(arguments[r]*n)/n+i[r]}}class yf{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?ts:mf(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,i,r){this._append`Q${+t},${+n},${this._x1=+i},${this._y1=+r}`}bezierCurveTo(t,n,i,r,s,o){this._append`C${+t},${+n},${+i},${+r},${this._x1=+s},${this._y1=+o}`}arcTo(t,n,i,r,s){if(t=+t,n=+n,i=+i,r=+r,s=+s,s<0)throw new Error(`negative radius: ${s}`);let o=this._x1,a=this._y1,c=i-t,h=r-n,l=o-t,u=a-n,f=l*l+u*u;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(f>Pt)if(!(Math.abs(u*c-h*l)>Pt)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let g=i-o,d=r-a,p=c*c+h*h,y=g*g+d*d,_=Math.sqrt(p),x=Math.sqrt(f),v=s*Math.tan((Hn-Math.acos((p+f-y)/(2*_*x)))/2),C=v/x,b=v/_;Math.abs(C-1)>Pt&&this._append`L${t+C*l},${n+C*u}`,this._append`A${s},${s},0,0,${+(u*g>l*d)},${this._x1=t+b*c},${this._y1=n+b*h}`}}arc(t,n,i,r,s,o){if(t=+t,n=+n,i=+i,o=!!o,i<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(r),c=i*Math.sin(r),h=t+a,l=n+c,u=1^o,f=o?r-s:s-r;this._x1===null?this._append`M${h},${l}`:(Math.abs(this._x1-h)>Pt||Math.abs(this._y1-l)>Pt)&&this._append`L${h},${l}`,i&&(f<0&&(f=f%Vn+Vn),f>pf?this._append`A${i},${i},0,1,${u},${t-a},${n-c}A${i},${i},0,1,${u},${this._x1=h},${this._y1=l}`:f>Pt&&this._append`A${i},${i},0,${+(f>=Hn)},${u},${this._x1=t+i*Math.cos(s)},${this._y1=n+i*Math.sin(s)}`)}rect(t,n,i,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}}function _f(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const i=Math.floor(n);if(!(i>=0))throw new RangeError(`invalid digits: ${n}`);t=i}return e},()=>new yf(t)}function xf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function es(e){this._context=e}es.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function ns(e){return new es(e)}function vf(e){return e[0]}function wf(e){return e[1]}function bf(e,t){var n=Ot(!0),i=null,r=ns,s=null,o=_f(a);e=typeof e=="function"?e:e===void 0?vf:Ot(e),t=typeof t=="function"?t:t===void 0?wf:Ot(t);function a(c){var h,l=(c=xf(c)).length,u,f=!1,g;for(i==null&&(s=r(g=o())),h=0;h<=l;++h)!(h<l&&n(u=c[h],h,c))===f&&((f=!f)?s.lineStart():s.lineEnd()),f&&s.point(+e(u,h,c),+t(u,h,c));if(g)return s=null,g+""||null}return a.x=function(c){return arguments.length?(e=typeof c=="function"?c:Ot(+c),a):e},a.y=function(c){return arguments.length?(t=typeof c=="function"?c:Ot(+c),a):t},a.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Ot(!!c),a):n},a.curve=function(c){return arguments.length?(r=c,i!=null&&(s=r(i)),a):r},a.context=function(c){return arguments.length?(c==null?i=s=null:s=r(i=c),a):i},a}function is(){}function Un(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Ne(e){this._context=e}Ne.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:Un(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);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:Un(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Sf(e){return new Ne(e)}function rs(e){this._context=e}rs.prototype={areaStart:is,areaEnd:is,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);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Un(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Tf(e){return new rs(e)}function ss(e,t){this._basis=new Ne(e),this._beta=t}ss.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var i=e[0],r=t[0],s=e[n]-i,o=t[n]-r,a=-1,c;++a<=n;)c=a/n,this._basis.point(this._beta*e[a]+(1-this._beta)*(i+c*s),this._beta*t[a]+(1-this._beta)*(r+c*o));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}};const Mf=function e(t){function n(i){return t===1?new Ne(i):new ss(i,t)}return n.beta=function(i){return e(+i)},n}(.85);function os(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function Wn(e,t){this._context=e,this._k=(1-t)/6}Wn.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:os(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:os(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const Af=function e(t){function n(i){return new Wn(i,t)}return n.tension=function(i){return e(+i)},n}(0);function Pf(e,t,n){var i=e._x1,r=e._y1,s=e._x2,o=e._y2;if(e._l01_a>Jr){var a=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,c=3*e._l01_a*(e._l01_a+e._l12_a);i=(i*a-e._x0*e._l12_2a+e._x2*e._l01_2a)/c,r=(r*a-e._y0*e._l12_2a+e._y2*e._l01_2a)/c}if(e._l23_a>Jr){var h=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,l=3*e._l23_a*(e._l23_a+e._l12_a);s=(s*h+e._x1*e._l23_2a-t*e._l12_2a)/l,o=(o*h+e._y1*e._l23_2a-n*e._l12_2a)/l}e._context.bezierCurveTo(i,r,s,o,e._x2,e._y2)}function as(e,t){this._context=e,this._alpha=t}as.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);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:Pf(this,e,t);break}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=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const Cf=function e(t){function n(i){return t?new as(i,t):new Wn(i,0)}return n.alpha=function(i){return e(+i)},n}(.5);function cs(e){return e<0?-1:1}function hs(e,t,n){var i=e._x1-e._x0,r=t-e._x1,s=(e._y1-e._y0)/(i||r<0&&-0),o=(n-e._y1)/(r||i<0&&-0),a=(s*r+o*i)/(i+r);return(cs(s)+cs(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(a))||0}function ls(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Yn(e,t,n){var i=e._x0,r=e._y0,s=e._x1,o=e._y1,a=(s-i)/3;e._context.bezierCurveTo(i+a,r+a*t,s-a,o-a*n,s,o)}function $e(e){this._context=e}$e.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:Yn(this,this._t0,ls(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Yn(this,ls(this,n=hs(this,e,t)),n);break;default:Yn(this,this._t0,n=hs(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function us(e){this._context=new fs(e)}(us.prototype=Object.create($e.prototype)).point=function(e,t){$e.prototype.point.call(this,t,e)};function fs(e){this._context=e}fs.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,i,r,s){this._context.bezierCurveTo(t,e,i,n,s,r)}};function Lf(e){return new $e(e)}function kf(e){return new us(e)}function ds(e){this._context=e}ds.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var i=gs(e),r=gs(t),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(i[0][s],r[0][s],i[1][s],r[1][s],e[o],t[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function gs(e){var t,n=e.length-1,i,r=new Array(n),s=new Array(n),o=new Array(n);for(r[0]=0,s[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)r[t]=1,s[t]=4,o[t]=4*e[t]+2*e[t+1];for(r[n-1]=2,s[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)i=r[t]/s[t-1],s[t]-=i,o[t]-=i*o[t-1];for(r[n-1]=o[n-1]/s[n-1],t=n-2;t>=0;--t)r[t]=(o[t]-r[t+1])/s[t];for(s[n-1]=(e[n]+r[n-1])/2,t=0;t<n-1;++t)s[t]=2*e[t+1]-r[t+1];return[r,s]}function Ef(e){return new ds(e)}function Be(e,t){this._context=e,this._t=t}Be.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&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function Rf(e){return new Be(e,.5)}function Ff(e){return new Be(e,0)}function zf(e){return new Be(e,1)}const Df=.7,Of=.9,Nf=1;class $f extends gr{constructor(t,n){super(t,n),this.options={...this.options,...n},this.render=this.render.bind(this)}onUpdate(t){super.onUpdate(t),this.render()}onRescale(t){super.onRescale(t),this.elm&&(this.rescaleEvent=t,this.render())}render(){const{strokeWidth:t,stroke:n}=this.options;if(!this.elm)return;this.elm.select("g").remove();const i=this.data||this.referenceSystem&&this.referenceSystem.projectedPath;!i||!this.rescaleEvent||this.elm.append("g").attr("class","well-path").append("path").attr("d",this.renderWellborePath(i)).attr("stroke-width",t||"2px").attr("stroke",n||"red").attr("fill","none")}renderWellborePath(t){const{xScale:n,yScale:i}=this.rescaleEvent,r=t.map(c=>[n(c[0]),i(c[1])]);let s;const{curveType:o,tension:a}=this.options;switch(o){default:case"curveCatmullRom":s=Cf.alpha(a||Df);break;case"curveLinear":s=ns;break;case"curveBasis":s=Sf;break;case"curveBasisClosed":s=Tf;break;case"curveBundle":s=Mf.beta(a||Nf);break;case"curveCardinal":s=Af.tension(a||Of);break;case"curveMonotoneX":s=Lf;break;case"curveMonotoneY":s=kf;break;case"curveNatural":s=Ef;break;case"curveStep":s=Rf;break;case"curveStepAfter":s=zf;break;case"curveStepBefore":s=Ff;break}return bf().curve(s)(r)}}const ps=(e,t)=>{switch(t.lineType){case"wavy":return e.wavy(t);case"dashed":return e.dashed(t);case"solid":return e.solid(t);default:return Qt(t.lineType)}};class Bf extends yt{constructor(){super(...arguments),this.yScale=null,this.xScale=null}onMount(t){super.onMount(t)}onUpdate(t){super.onUpdate(t),this.clearCanvas(),this.render()}onRescale(t){super.onRescale(t),this.yScale=t.yScale,this.xScale=t.xScale,this.resetTransform(),this.render()}drawDashed(t){const{ctx:n}=this,{canvas:i}=this,r=this.yScale(t.depth);n.save(),n.strokeStyle=t.color,this.setCtxLineStyle(n,t),this.setCtxLineWidth(n,t),n.beginPath(),n.moveTo(0,r),n.lineTo(i.width,r),n.stroke(),n.restore(),t.text&&this.drawText(n,t,n.canvas.width,r)}drawSolid(t){const{ctx:n}=this,{canvas:i}=this,r=this.yScale(t.depth);n.save(),n.strokeStyle=t.color,this.setCtxLineStyle(n,t),this.setCtxLineWidth(n,t),n.beginPath(),n.moveTo(0,r),n.lineTo(i.width,r),n.stroke(),n.restore(),t.text&&this.drawText(n,t,n.canvas.width,r)}drawWavy(t){const{ctx:s}=this,{canvas:o}=this,a=ke(4,2.5,500,this.yScale),c=a*2,h=this.yScale(t.depth)-a,l=Math.ceil(o.width/c)+1,u=this.xScale(0)%c;s.save(),s.strokeStyle=t.color,this.setCtxLineStyle(s,t),this.setCtxLineWidth(s,t);for(let f=-1;f<l;f++)s.beginPath(),s.arc(f*c+u+a,h,a,0,Math.PI),s.stroke();s.restore(),t.text&&this.drawText(s,t,s.canvas.width,h)}drawText(t,n,i,r){const s=n.textColor||"#000",o=n.fontSize||"10px sans-serif",a=10;t.save(),t.strokeStyle=s,t.font=o,t.textAlign="end",t.textBaseline="bottom",t.fillText(n.text,i-a,r),t.restore()}setCtxLineStyle(t,n){ps({solid:()=>{t.setLineDash([])},dashed:()=>{t.setLineDash([8,10])},wavy:()=>{t.setLineDash([])}},n)}setCtxLineWidth(t,n){t.lineWidth=n.lineWidth||1}render(){!this.ctx||!this.yScale||!this.xScale||requestAnimationFrame(()=>{var t;this.clearCanvas(),(t=this.data)==null||t.forEach(n=>{ps({solid:i=>this.drawSolid(i),dashed:i=>this.drawDashed(i),wavy:i=>this.drawWavy(i)},n)})})}}class ms{constructor(t,n,i){if(this.layers=[],this.createAxis=r=>{const{container:s}=this;this._svgContainer=q(s).append("div").attr("class","axis").style("position","absolute").style("z-index","10").style("pointer-events","none");const o=this._svgContainer.append("svg").attr("height",`${s.offsetHeight}px`).attr("width",`${s.offsetWidth}px`),a=!0;return new Mi(o,a,r.xLabel,r.yLabel,r.unitOfMeasure)},this.container=t,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 lr(t,r=>this.rescale(r)),n){const{xMin:r,xMax:s,yMin:o,yMax:a,xBounds:c,yBounds:h}=n;r!==void 0&&s!==void 0&&o!==void 0&&a!==void 0&&this._zoomPanHandler.setBounds([r,s],[o,a]),c&&h&&this._zoomPanHandler.setBounds(c,h)}else this._zoomPanHandler.setBounds([0,1],[0,1]);i&&(this._axis=this.createAxis(i)),this.rescale=this.rescale.bind(this)}addLayers(t){return t.forEach(n=>this.addLayer(n)),this}getLayers(){return this.layers}clearAllData(t=!0){return this.layers.forEach(n=>n.clearData(t)),this}addLayer(t,n){return this.layers.push(t),this.initLayer(t,n),this}removeLayer(t){const n=this.layers.find(i=>i.id===t);return n&&(n.onUnmount(),this.layers=this.layers.filter(i=>i.id!==t)),this}removeAllLayers(){const{layers:t}=this;return t.forEach(n=>{this.removeLayer(n.id)}),this}getLayer(t){return this.layers.find(n=>n.id===t||n.getInternalLayerIds().includes(t))}initLayer(t,n){const i={elm:this.layerContainer};t.onMount(i);const r=this.zoomPanHandler.currentStateAsEvent();if(t.onUpdate({...r,...n}),t.onRescale(r),this._svgContainer){const s=this.layers.length>0?this.layers.reduce((o,a)=>o.order>a.order?o:a).order:1;this._svgContainer.style("z-index",`${s+1}`)}return this}showLayer(t){const n=this.getLayer(t);return n?(n.setVisibility(!0,t),n.onRescale(this.zoomPanHandler.currentStateAsEvent()),this):this}hideLayer(t){const n=this.getLayer(t);return n?(n.setVisibility(!1,t),n.onRescale(this.zoomPanHandler.currentStateAsEvent()),this):this}adjustToSize(t,n){const i=Math.max(this._axis?t-ur:t,0),r=Math.max(this._axis?n-fr:n,0);if(this._axis){const s={width:t,height:n};this._axis.onResize(s)}if(this.layers){const s={width:i,height:r};this.layers.forEach(o=>o.onResize(s))}this._zoomPanHandler&&this._zoomPanHandler.adjustToSize(i,r,!0)}setReferenceSystem(t){this.layers.forEach(n=>n.referenceSystem=t)}showAxis(){return this._axis.show(),this}hideAxis(){return this._axis.hide(),this}showAxisLabels(){return this._axis.showLabels(),this}hideAxisLabels(){return this._axis.hideLabels(),this}setAxisOffset(t,n){return this._axis.offsetX=t,this._axis.offsetY=n,this.layers.filter(r=>r instanceof Ee).forEach(r=>{r.offsetX=t,r.offsetY=n}),this}setXAxisOffset(t){return this._axis.offsetX=t,this.layers.filter(i=>i instanceof Ee).forEach(i=>{i.offsetX=t}),this}setYAxisOffset(t){return this._axis.offsetY=t,this.layers.filter(i=>i instanceof Ee).forEach(i=>{i.offsetY=t}),this}setZoomLevelBoundary(t){return this._zoomPanHandler.setZoomLevelBoundary(t),this}setMaxZoomLevel(t){return this._zoomPanHandler.setMaxZoomLevel(t),this}setMinZoomLevel(t){return this._zoomPanHandler.setMinZoomLevel(t),this}destroy(){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}get zoomPanHandler(){return this._zoomPanHandler}get axis(){return this._axis}rescale(t){this._axis&&this._axis.onRescale(t),this.layers&&this.layers.forEach(n=>n.isVisible===!0?n.onRescale(t):{})}}class If{constructor(t,n){this.elements={},this.listeners={},this.enabled=!0;const i=q(n);this.elm=i.append("div").attr("id","overlay").style("z-index","11").style("position","absolute"),this.source=this.elm.node();const{elm:r}=this;r.on("resize",s=>{const{width:o,height:a}=s.detail;r.style("width",`${o}px`).style("height",`${a}px`),this.enabled&&Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]||null,l=this.listeners[c];l&&l.onResize&&requestAnimationFrame(()=>l.onResize({target:h,source:this.source,caller:t,width:o,height:a}))})}),r.on("mousemove",s=>{if(!this.enabled)return;const[o,a]=pt(s,this.elm.node());Object.keys(this.listeners).forEach(c=>{const h=this.elements[c]||null,l=this.listeners[c];l&&l.onMouseMove&&requestAnimationFrame(()=>l.onMouseMove({x:o,y:a,target:h,source:this.source,caller:t}))})}),r.on("mouseout",()=>{this.enabled&&Object.keys(this.listeners).forEach(s=>{const o=this.elements[s]||null,a=this.listeners[s];a&&a.onMouseExit&&requestAnimationFrame(()=>a.onMouseExit({target:o,source:this.source,caller:t}))})})}create(t,n){const i=this.elm.append("div").style("position","relative").style("pointer-events","none").node();return this.elements[t]=i,n&&(this.listeners[t]=n),i}register(t,n){this.listeners[t]=n}remove(t){const n=this.elements[t];n&&(q(n).remove(),delete this.elements[t]),delete this.listeners[t]}setZIndex(t){this.elm.style("z-index",t)}destroy(){this.source.remove()}}const Hf=(e,t)=>new If(e,t);class Vf{constructor(t){const{container:n,axisOptions:i,scaleOptions:r,referenceSystem:s,layers:o,path:a}=t;this._referenceSystem=s||a&&new Ft(a),this._overlay=Hf(this,n),this.layerManager=new ms(this._overlay.elm.node(),r,i),o&&(this.layerManager.addLayers(o),this.setOverlayZIndex(o))}setReferenceSystem(t){return this._referenceSystem=t,this.layerManager.setReferenceSystem(t),this}updatePath(t,n){return this.setReferenceSystem(new Ft(t,n)),this}clearAllData(t=!0){return this.layerManager.clearAllData(t),this}addLayer(t,n){return this.layerManager.addLayer(t,n),this.setOverlayZIndex(this.layerManager.getLayers()),this}removeLayer(t){return this.layerManager.removeLayer(t),this}removeAllLayers(){return this.layerManager.removeAllLayers(),this}getLayer(t){return this.layerManager.getLayer(t)}showLayer(t){return this.layerManager.showLayer(t),this}hideLayer(t){return this.layerManager.hideLayer(t),this}adjustToSize(t,n){this.layerManager.adjustToSize(t,n);const i={width:Math.max(t-ur,0),height:Math.max(n-fr,0)};return this.overlay.elm.dispatch("resize",{detail:i,bubbles:!0,cancelable:!0}),this}setViewport(t,n,i,r){return this.zoomPanHandler.setViewport(t,n,i,r),this}setBounds(t,n){return this.zoomPanHandler.setBounds(t,n),this}showAxis(){return this.layerManager.showAxis(),this}hideAxis(){return this.layerManager.hideAxis(),this}showAxisLabels(){return this.layerManager.showAxisLabels(),this}hideAxisLabels(){return this.layerManager.hideAxisLabels(),this}setAxisOffset(t,n){return this.layerManager.setAxisOffset(t,n),this}setXAxisOffset(t){return this.layerManager.setXAxisOffset(t),this}setYAxisOffset(t){return this.layerManager.setYAxisOffset(t),this}setZoomLevelBoundary(t){return this.zoomPanHandler.setZoomLevelBoundary(t),this}setMaxZoomLevel(t){return this.zoomPanHandler.setMaxZoomLevel(t),this}setMinZoomLevel(t){return this.zoomPanHandler.setMinZoomLevel(t),this}destroy(){return this.layerManager.destroy(),this._overlay.destroy(),this._referenceSystem=void 0,this.layerManager=void 0,this._overlay=void 0,this}getHighestZIndex(t){return t.length>0?t.reduce((i,r)=>i.order>r.order?i:r).order:1}setOverlayZIndex(t){const n=this.getHighestZIndex(t);this.overlay.setZIndex(n+2)}get overlay(){return this._overlay}get referenceSystem(){return this._referenceSystem}get zoomPanHandler(){return this.layerManager.zoomPanHandler}get axis(){return this.layerManager.axis}get currentStateAsEvent(){return this.zoomPanHandler.currentStateAsEvent()}}P.Axis=Mi,P.CalloutCanvasLayer=Nl,P.CanvasLayer=yt,P.Controller=Vf,P.GeomodelCanvasLayer=Vl,P.GeomodelLabelsLayer=ku,P.GeomodelLayerV2=Ru,P.GridLayer=Ee,P.HTMLLayer=Sl,P.ImageLayer=zu,P.IntersectionReferenceSystem=Ft,P.Layer=Kt,P.LayerManager=ms,P.PixiLayer=An,P.PixiRenderApplication=Tl,P.ReferenceLineLayer=Bf,P.SVGLayer=gr,P.SchematicLayer=Qr,P.SeismicCanvasLayer=gf,P.WellborepathLayer=$f,P.ZoomPanHandler=lr,P.assertNever=Qt,P.calcSize=ke,P.defaultCasingOptions=Ar,P.defaultCementOptions=Cr,P.defaultCementPlugOptions=Rr,P.defaultCementSqueezeOptions=Lr,P.defaultHoleOptions=Mr,P.defaultInternalLayerOptions=Tr,P.defaultPerforationOptions=Pr,P.defaultScreenOptions=kr,P.defaultTubingOptions=Er,P.findIndexOfSample=Ln,P.findSampleAtPos=_t,P.foldCompletion=_r,P.foldPerforationSubKind=Z,P.generateProjectedTrajectory=bu,P.generateProjectedWellborePath=wu,P.generateSeismicSliceImage=nu,P.generateSurfaceData=su,P.getOverlap=kl,P.getOverlapOffset=Cn,P.getPicksData=Gl,P.getSeismicInfo=eu,P.getSeismicOptions=tu,P.hasFracLines=vr,P.hasPacking=xr,P.hasSpikes=wr,P.intersect=Pn,P.isCementPlug=yr,P.isCementSqueeze=mr,P.isOpenHoleFracPack=Cl,P.isOverlapping=Or,P.isOverlappingHorizontally=Ll,P.isPAndASymbol=pr,P.isSubKindCasedHoleFracPack=Sr,P.isSubKindPerforation=Pl,P.isSubkindCasedHoleGravelPack=br,P.pixelsPerUnit=Dr,P.shouldPerforationStartAtCasingDiameter=Al,P.shouldPerforationStartAtHoleDiameter=Ml,P.transformFormationData=Ql,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
15
15
  //# sourceMappingURL=index.umd.js.map