killinchu / static /vendor /regl-scatterplot.min.js
betterwithage's picture
batch2 vendor: d3-sankey, observable-plot, regl, pub-sub-es, regl-scatterplot (MIT/ISC) — sovereign, 0 CDN
1e6d6c2 verified
Raw
History Blame Contribute Delete
93.7 kB
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pub-sub-es"),require("regl")):"function"==typeof define&&define.amd?define(["exports","pub-sub-es","regl"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).createScatterplot={},e.createPubSub,e.createREGL)}(this,(function(e,n,t){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(n),i=o(t);function a(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,o=Array(n);t<n;t++)o[t]=e[t];return o}function c(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,f(o.key),o)}}function l(e,n,t){return(n=f(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function s(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function u(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var o,r,i,a,c=[],l=!0,s=!1;try{if(i=(t=t.call(e)).next,0===n){if(Object(t)!==t)return;l=!1}else for(;!(l=(o=i.call(t)).done)&&(c.push(o.value),c.length!==n);l=!0);}catch(e){s=!0,r=e}finally{try{if(!l&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(s)throw r}}return c}}(e,n)||v(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||v(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){var n=function(e,n){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,n||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:n+""}function v(e,n){if(e){if("string"==typeof e)return a(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?a(e,n):void 0}}var p,h="undefined"!=typeof Float32Array?Float32Array:Array;function m(){var e=new h(16);return h!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function y(e){var n=new h(16);return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function g(e,n){var t=n[0],o=n[1],r=n[2],i=n[3],a=n[4],c=n[5],l=n[6],s=n[7],u=n[8],d=n[9],f=n[10],v=n[11],p=n[12],h=n[13],m=n[14],y=n[15],g=t*c-o*a,w=t*l-r*a,x=t*s-i*a,b=o*l-r*c,S=o*s-i*c,E=r*s-i*l,P=u*h-d*p,A=u*m-f*p,M=u*y-v*p,C=d*m-f*h,I=d*y-v*h,T=f*y-v*m,R=g*T-w*I+x*C+b*M-S*A+E*P;return R?(R=1/R,e[0]=(c*T-l*I+s*C)*R,e[1]=(r*I-o*T-i*C)*R,e[2]=(h*E-m*S+y*b)*R,e[3]=(f*S-d*E-v*b)*R,e[4]=(l*M-a*T-s*A)*R,e[5]=(t*T-r*M+i*A)*R,e[6]=(m*x-p*E-y*w)*R,e[7]=(u*E-f*x+v*w)*R,e[8]=(a*I-c*M+s*P)*R,e[9]=(o*M-t*I-i*P)*R,e[10]=(p*S-h*x+y*g)*R,e[11]=(d*x-u*S-v*g)*R,e[12]=(c*A-a*C-l*P)*R,e[13]=(t*C-o*A+r*P)*R,e[14]=(h*w-p*b-m*g)*R,e[15]=(u*b-d*w+f*g)*R,e):null}function w(e,n,t){var o=n[0],r=n[1],i=n[2],a=n[3],c=n[4],l=n[5],s=n[6],u=n[7],d=n[8],f=n[9],v=n[10],p=n[11],h=n[12],m=n[13],y=n[14],g=n[15],w=t[0],x=t[1],b=t[2],S=t[3];return e[0]=w*o+x*c+b*d+S*h,e[1]=w*r+x*l+b*f+S*m,e[2]=w*i+x*s+b*v+S*y,e[3]=w*a+x*u+b*p+S*g,w=t[4],x=t[5],b=t[6],S=t[7],e[4]=w*o+x*c+b*d+S*h,e[5]=w*r+x*l+b*f+S*m,e[6]=w*i+x*s+b*v+S*y,e[7]=w*a+x*u+b*p+S*g,w=t[8],x=t[9],b=t[10],S=t[11],e[8]=w*o+x*c+b*d+S*h,e[9]=w*r+x*l+b*f+S*m,e[10]=w*i+x*s+b*v+S*y,e[11]=w*a+x*u+b*p+S*g,w=t[12],x=t[13],b=t[14],S=t[15],e[12]=w*o+x*c+b*d+S*h,e[13]=w*r+x*l+b*f+S*m,e[14]=w*i+x*s+b*v+S*y,e[15]=w*a+x*u+b*p+S*g,e}function x(e,n){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function b(e,n){return e[0]=n[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=n[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function S(e,n,t){var o=n[0],r=n[1],i=n[2],a=n[3];return e[0]=t[0]*o+t[4]*r+t[8]*i+t[12]*a,e[1]=t[1]*o+t[5]*r+t[9]*i+t[13]*a,e[2]=t[2]*o+t[6]*r+t[10]*i+t[14]*a,e[3]=t[3]*o+t[7]*r+t[11]*i+t[15]*a,e}Math.hypot||(Math.hypot=function(){for(var e=0,n=arguments.length;n--;)e+=arguments[n]*arguments[n];return Math.sqrt(e)}),p=new h(4),h!=Float32Array&&(p[0]=0,p[1]=0,p[2]=0,p[3]=0),function(){var e=function(){var e=new h(2);return h!=Float32Array&&(e[0]=0,e[1]=0),e}()}();const E=(e=[0,0],n=1,t=0,o=[0,0],r=[[0,1/0],[0,1/0]],i=[[-1/0,1/0],[-1/0,1/0]])=>{const a=new Float32Array(16),c=new Float32Array(16),l=new Float32Array(16);let s=m(),u=[...o.slice(0,2),0,1];const d=Array.isArray(r[0])?[...r[0]]:[...r],f=Array.isArray(r[0])?[...r[1]]:[...r],v=Array.isArray(i[0])?[...i[0]]:[...i],p=Array.isArray(i[0])?[...i[1]]:[...i],h=()=>function(e,n){var t=n[0],o=n[1],r=n[2],i=n[4],a=n[5],c=n[6],l=n[8],s=n[9],u=n[10];return e[0]=Math.hypot(t,o,r),e[1]=Math.hypot(i,a,c),e[2]=Math.hypot(l,s,u),e}(a,s).slice(0,2),y=()=>{const e=h();return Math.min(e[0],e[1])},E=()=>{const e=h();return Math.max(e[0],e[1])},P=([e=0,n=0]=[],t=1,o=0)=>{s=m(),A([-e,-n]),C(o),M(1/t)},A=([e=0,n=0]=[])=>{a[0]=e,a[1]=n,a[2]=0;const t=x(c,a);w(s,t,s)},M=(e,n)=>{const t=Array.isArray(e);let o=t?e[0]:e,r=t?e[1]:e;if(o<=0||r<=0||1===o&&1===r)return;const i=h(),v=i[0]*o,p=i[1]*r;if(o=Math.max(d[0],Math.min(v,d[1]))/i[0],r=Math.max(f[0],Math.min(p,f[1]))/i[1],1===o&&1===r)return;a[0]=o,a[1]=r,a[2]=1;const m=b(c,a),y=n?[...n,0]:u,S=x(a,y);w(s,S,w(s,m,w(s,g(l,S),s)))},C=e=>{const n=m();!function(e,n,t){var o,r,i,a=t[0],c=t[1],l=t[2],s=Math.hypot(a,c,l);s<1e-6||(a*=s=1/s,c*=s,l*=s,o=Math.sin(n),i=1-(r=Math.cos(n)),e[0]=a*a*i+r,e[1]=c*a*i+l*o,e[2]=l*a*i-c*o,e[3]=0,e[4]=a*c*i-l*o,e[5]=c*c*i+r,e[6]=l*c*i+a*o,e[7]=0,e[8]=a*l*i+c*o,e[9]=c*l*i-a*o,e[10]=l*l*i+r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1)}(n,e,[0,0,1]),w(s,n,s)},I=e=>{!e||e.length<16||(s=e)};return P(e,n,t),{get translation(){return function(e,n){return e[0]=n[12],e[1]=n[13],e[2]=n[14],e}(a,s).slice(0,2)},get target(){return S(a,u,g(l,s)).slice(0,2)},get scaling(){return h()},get minScaling(){return y()},get maxScaling(){return E()},get scaleBounds(){return[[...d],[...f]]},get translationBounds(){return[[...v],[...p]]},get distance(){return(()=>{const e=h();return[1/e[0],1/e[1]]})()},get minDistance(){return 1/y()},get maxDistance(){return 1/E()},get rotation(){return Math.acos(s[0]/E())},get view(){return s},get viewCenter(){return u.slice(0,2)},lookAt:P,translate:A,pan:A,rotate:C,scale:M,zoom:M,reset:()=>{P(e,n,t)},set:(...e)=>(console.warn("`set()` is deprecated. Please use `setView()` instead."),I(...e)),setScaleBounds:e=>{const n=Array.isArray(e[0]);d[0]=n?e[0][0]:e[0],d[1]=n?e[0][1]:e[1],f[0]=n?e[1][0]:e[0],f[1]=n?e[1][1]:e[1]},setTranslationBounds:e=>{const n=Array.isArray(e[0]);v[0]=n?e[0][0]:e[0],v[1]=n?e[0][1]:e[1],p[0]=n?e[1][0]:e[0],p[1]=n?e[1][1]:e[1]},setView:I,setViewCenter:e=>{u=[...e.slice(0,2),0,1]}}},P=["pan","rotate"],A={alt:"altKey",cmd:"metaKey",ctrl:"ctrlKey",meta:"metaKey",shift:"shiftKey"},M=(e,{distance:n=1,target:t=[0,0],rotation:o=0,isNdc:r=!0,isFixed:i=!1,isPan:a=!0,isPanInverted:c=[!1,!0],panSpeed:l=1,isRotate:s=!0,rotateSpeed:u=1,defaultMouseDownMoveAction:d="pan",mouseDownMoveModKey:f="alt",isZoom:v=!0,zoomSpeed:p=1,viewCenter:h,scaleBounds:m,translationBounds:y,onKeyDown:g=(()=>{}),onKeyUp:w=(()=>{}),onMouseDown:x=(()=>{}),onMouseUp:b=(()=>{}),onMouseMove:S=(()=>{}),onWheel:M=(()=>{})}={})=>{let C=E(t,n,o,h,m,y),I=0,T=0,R=0,O=0,L=0,D=0,B=!1,z=0,k=1,j=1,F=1,N=!1,_=!1,W=!1,V="pan"===d,Z=a,U=a,q=c,G=c,H=v,K=v;const Y=()=>{Z=Array.isArray(a)?Boolean(a[0]):a,U=Array.isArray(a)?Boolean(a[1]):a,q=Array.isArray(c)?Boolean(c[0]):c,G=Array.isArray(c)?Boolean(c[1]):c,H=Array.isArray(v)?Boolean(v[0]):v,K=Array.isArray(v)?Boolean(v[1]):v};Y();const X=r?e=>e/k*2*F:e=>e,$=r?e=>e/j*2:e=>-e,J=r?e=>(e/k*2-1)*F:e=>e,Q=r?e=>1-e/j*2:e=>e,ee=()=>{const n=e.getBoundingClientRect();k=n.width,j=n.height,F=k/j},ne=e=>{W=!1,w(e)},te=e=>{W=e[A[f]],g(e)},oe=e=>{B=!1,b(e)},re=e=>{B=1===e.buttons,x(e)},ie=void 0!==document.createEvent("MouseEvent").offsetX?e=>{R=e.offsetX,O=e.offsetY}:n=>{const t=e.getBoundingClientRect();R=n.clientX-t.left,O=n.clientY-t.top},ae=e=>{I=e.clientX,T=e.clientY},ce=e=>{ae(e),S(e)},le=e=>{if(H||K){e.preventDefault(),ae(e),ie(e);const n=1===e.deltaMode?12:1;z+=n*(e.deltaY||e.deltaX||0)}M(e)};window.addEventListener("keydown",te,{passive:!0}),window.addEventListener("keyup",ne,{passive:!0}),e.addEventListener("mousedown",re,{passive:!0}),window.addEventListener("mouseup",oe,{passive:!0}),window.addEventListener("mousemove",ce,{passive:!0}),e.addEventListener("wheel",le,{passive:!1}),C.config=({defaultMouseDownMoveAction:e=null,isFixed:n=null,isPan:t=null,isPanInverted:o=null,isRotate:r=null,isZoom:h=null,panSpeed:m=null,rotateSpeed:y=null,zoomSpeed:g=null,mouseDownMoveModKey:w=null}={})=>{d=null!==e&&P.includes(e)?e:d,V="pan"===d,i=null!==n?n:i,a=null!==t?t:a,c=null!==o?o:c,s=null!==r?r:s,v=null!==h?h:v,l=+m>0?m:l,u=+y>0?y:u,p=+g>0?g:p,Y(),f=null!==w&&Object.keys(A).includes(w)?w:f},C.dispose=()=>{C=void 0,window.removeEventListener("keydown",te),window.removeEventListener("keyup",ne),e.removeEventListener("mousedown",re),window.removeEventListener("mouseup",oe),window.removeEventListener("mousemove",ce),e.removeEventListener("wheel",le)},C.refresh=ee,C.tick=()=>{if(i){const e=_;return _=!1,e}N=!1;const e=I,n=T;if((Z||U)&&B&&(V&&!W||!V&&W)){const t=Z?X(l*(q?L-e:e-L)):0,o=U?$(l*(G?D-n:n-D)):0;0===t&&0===o||(C.pan([t,o]),N=!0)}if((H||K)&&z){const e=p*Math.exp(z/j),n=J(R),t=Q(O);C.scale([H?1/e:1,K?1/e:1],[n,t]),N=!0}if(s&&B&&(V&&W||!V&&!W)&&Math.abs(L-e)+Math.abs(D-n)>0){const t=k/2,o=j/2,r=L-t,i=o-D,a=e-t,c=o-n,l=function(e,n){var t=e[0],o=e[1],r=n[0],i=n[1],a=Math.sqrt(t*t+o*o)*Math.sqrt(r*r+i*i),c=a&&(t*r+o*i)/a;return Math.acos(Math.min(Math.max(c,-1),1))}([r,i],[a,c]),s=r*c-a*i;C.rotate(u*l*Math.sign(s)),N=!0}z=0,L=e,D=n;const t=N||_;return _=!1,t};const se=e=>function(){e.apply(null,arguments),_=!0};return C.lookAt=se(C.lookAt),C.translate=se(C.translate),C.pan=se(C.pan),C.rotate=se(C.rotate),C.scale=se(C.scale),C.zoom=se(C.zoom),C.reset=se(C.reset),C.set=se(C.set),C.setScaleBounds=se(C.setScaleBounds),C.setTranslationBounds=se(C.setTranslationBounds),C.setView=se(C.setView),C.setViewCenter=se(C.setViewCenter),ee(),C},C=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),I=Float32Array.BYTES_PER_ELEMENT,T=e=>e.length>0&&Array.isArray(e[0]),{push:R,splice:O}=Array.prototype;function L(e,n=1,t=1){const o=[],r=new Array(2*n);for(let i=0,a=e.length/n;i<a;i++){const a=i*n;for(let o=0;o<n;o++){const i=e[a+o];r[o]=i,r[o+n]=i*t}R.apply(o,r)}return o}function D(e,n,t,o){const r=new Array(o),i=n*o;for(let n=0;n<o;n++)r[n]=e[i+n];return O.call(e,t*o,0,...r),e}var B=(e,{projection:n=C,model:t=C,view:o=C,points:r=[],colorIndices:i=[],color:a=[.8,.5,0,1],opacity:c=null,opacities:l=[],width:s=1,widths:u=[],miter:d=!0,is2d:f=!1,zPos2d:v=0}={})=>{if(!e)return void console.error("Regl instance is undefined.");const p=new Float32Array(16);let h,m,y,g,x,b,S,E,P,A,M,O,B,z,k,j,F,N,_=f?2:3;const W=()=>+(l.length===m||null!==c),V=()=>{A=e.buffer(),M=e.buffer(),O=e.buffer(),k=e.buffer(),j={prevPosition:{buffer:()=>A,offset:0,stride:3*I},currPosition:{buffer:()=>A,offset:3*I*2,stride:3*I},nextPosition:{buffer:()=>A,offset:3*I*4,stride:3*I},opacity:{buffer:()=>M,offset:2*I,stride:I},offsetScale:{buffer:()=>O,offset:2*I,stride:I},colorIndex:{buffer:()=>k,offset:2*I,stride:I}},F=e.elements(),N=e({attributes:j,depth:{enable:!f},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"}},uniforms:{projectionViewModel:(e,n)=>{const t=e.projection||n.projection,o=e.model||n.model,r=e.view||n.view;return w(p,t,w(p,r,o))},aspectRatio:({viewportWidth:e,viewportHeight:n})=>e/n,colorTex:()=>B,colorTexRes:()=>z,colorTexEps:()=>.5/z,pixelRatio:({pixelRatio:e})=>e,width:({pixelRatio:e,viewportHeight:n})=>s/n*e,useOpacity:W,useColorOpacity:()=>Number(!W()),miter:Number(Boolean(d))},elements:()=>F,vert:"\nuniform mat4 projectionViewModel;\nuniform float aspectRatio;\n\nuniform sampler2D colorTex;\nuniform float colorTexRes;\nuniform float colorTexEps;\nuniform float width;\nuniform float useOpacity;\nuniform float useColorOpacity;\nuniform int miter;\n\nattribute vec3 prevPosition;\nattribute vec3 currPosition;\nattribute vec3 nextPosition;\nattribute float opacity;\nattribute float offsetScale;\nattribute float colorIndex;\n\nvarying vec4 color;\n\nvoid main() {\n vec2 aspectVec = vec2(aspectRatio, 1.0);\n vec4 prevProjected = projectionViewModel * vec4(prevPosition, 1.0);\n vec4 currProjected = projectionViewModel * vec4(currPosition, 1.0);\n vec4 nextProjected = projectionViewModel * vec4(nextPosition, 1.0);\n\n // get 2D screen space with W divide and aspect correction\n vec2 prevScreen = prevProjected.xy / prevProjected.w * aspectVec;\n vec2 currScreen = currProjected.xy / currProjected.w * aspectVec;\n vec2 nextScreen = nextProjected.xy / nextProjected.w * aspectVec;\n\n float len = width;\n\n // starting point uses (next - current)\n vec2 dir = vec2(0.0);\n if (currScreen == prevScreen) {\n dir = normalize(nextScreen - currScreen);\n }\n // ending point uses (current - previous)\n else if (currScreen == nextScreen) {\n dir = normalize(currScreen - prevScreen);\n }\n // somewhere in middle, needs a join\n else {\n // get directions from (C - B) and (B - A)\n vec2 dirA = normalize((currScreen - prevScreen));\n if (miter == 1) {\n vec2 dirB = normalize((nextScreen - currScreen));\n // now compute the miter join normal and length\n vec2 tangent = normalize(dirA + dirB);\n vec2 perp = vec2(-dirA.y, dirA.x);\n vec2 miter = vec2(-tangent.y, tangent.x);\n len = width / dot(miter, perp);\n dir = tangent;\n } else {\n dir = dirA;\n }\n }\n\n vec2 normal = vec2(-dir.y, dir.x) * len;\n normal.x /= aspectRatio;\n vec4 offset = vec4(normal * offsetScale, 0.0, 0.0);\n gl_Position = currProjected + offset;\n\n // Get color from texture\n float colorRowIndex = floor((colorIndex + colorTexEps) / colorTexRes);\n vec2 colorTexIndex = vec2(\n (colorIndex / colorTexRes) - colorRowIndex + colorTexEps,\n colorRowIndex / colorTexRes + colorTexEps\n );\n\n color = texture2D(colorTex, colorTexIndex);\n color.a = useColorOpacity * color.a + useOpacity * opacity;\n}",frag:"\nprecision mediump float;\nvarying vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"})},Z=()=>{1===h&&r.length%_>0&&console.warn(`The length of points (${m}) does not match the dimensions (${_}). Incomplete points are ignored.`),g=r.flat().slice(0,m*_),f&&(g=function(e,n,t,o=0){const r=[],i=new Array(t).fill(o);for(let t=0,o=e.length/n;t<o;t++){const o=t*n;for(let t=0;t<n;t++)i[t]=e[o+t];R.apply(r,i)}return r}(g,2,3,v)),i.length!==m&&(i=new Array(m).fill(0)),u.length!==m&&(u=new Array(m).fill(1));const e=i.slice(),n=l.length===m?l.slice():new Array(m).fill(null===c?1:c),t=u.slice();let o=0;for(const r of y){const i=o+r-1;D(g,i,i,3),D(g,o,o,3),D(e,i,i,1),D(e,o,o,1),D(n,i,i,1),D(n,o,o,1),D(t,i,i,1),D(t,o,o,1),o+=r+2}x=new Float32Array(L(g,3)),b=L(e),S=L(n),E=L(t,1,-1),P=((e,n=[])=>{let t=0;for(const o of e){for(let e=0;e<o-1;e++){const o=t+2*e,r=o+1,i=o+2,a=o+3;n.push(o,r,i,i,r,a)}t+=2*(o+2)}return n})(y),A({usage:"dynamic",type:"float",length:x.length*I,data:x}),M({usage:"dynamic",type:"float",length:S.length*I,data:S}),O({usage:"dynamic",type:"float",length:E.length*I,data:E}),k({usage:"dynamic",type:"float",length:b.length*I,data:b}),F({primitive:"triangles",usage:"dynamic",type:P.length>65536?"uint32":"uint16",data:P})},U=()=>{q(),V()},q=()=>{r=[],g=[],x=new Float32Array,E=[],P=[],A.destroy(),O.destroy(),F.destroy()},G=(e,n)=>{const t=n.flat(2);return t.length===m?t:t.length===h?y.flatMap(((e,n)=>Array(e).fill(t[n]))):e},H=(e=[],{colorIndices:n=i,opacities:t=l,widths:o=u,is2d:a=f}={})=>{_=(f=a)?2:3,h=T(r=e)?r.length:1,y=T(r)?r.map((e=>Math.floor(e.length/_))):[Math.floor(r.length/_)],m=y.reduce(((e,n)=>e+n),0),i=G(i,n),l=G(l,t),u=G(u,o),r&&m>1?Z():U()},K=()=>{const n=T(a)?a:[a];z=Math.max(2,Math.ceil(Math.sqrt(n.length)));const t=new Uint8Array(z**2*4);n.forEach(((e,n)=>{t[4*n]=Math.min(255,Math.max(0,Math.round(255*e[0]))),t[4*n+1]=Math.min(255,Math.max(0,Math.round(255*e[1]))),t[4*n+2]=Math.min(255,Math.max(0,Math.round(255*e[2]))),t[4*n+3]=Number.isNaN(+e[3])?255:Math.min(255,Math.max(0,Math.round(255*e[3])))})),B=e.texture({data:t,shape:[z,z,4]})};return V(),K(),r&&r.length>1&&H(r),{clear:U,destroy:q,draw:({projection:e,model:i,view:a}={})=>{e&&(n=e),i&&(t=i),a&&(o=a),r&&r.length>1&&N({projection:n,model:t,view:o})},getPoints:()=>r,setPoints:H,getData:()=>({points:x,widths:E,opacities:S,colorIndices:b}),getBuffer:()=>({points:A,widths:O,opacities:M,colorIndices:k}),getStyle:()=>({color:a,miter:d,width:s}),setStyle:({color:e,opacity:n,miter:t,width:o}={})=>{var r;e&&((e,n=c)=>{a=e,c=n,B&&B.destroy(),K()})(e,n||c),t&&(d=Boolean(t)),void 0!==(r=o)&&Number.isFinite(r)&&(s=o)}}};const z=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,k=e=>e,j=(e,n=(e=>e))=>{const t=[];for(let o=0;o<e;o++)t.push(n(o,e));return t},F=(e,...n)=>(n.forEach((n=>{const t=Object.keys(n).reduce(((e,t)=>(e[t]=Object.getOwnPropertyDescriptor(n,t),e)),{});Object.getOwnPropertySymbols(n).forEach((e=>{const o=Object.getOwnPropertyDescriptor(n,e);o.enumerable&&(t[e]=o)})),Object.defineProperties(e,t)})),e),N=(e,n)=>t=>F(t,{get[e](){return n}}),_=(e=1)=>new Promise((n=>{let t=0;const o=()=>requestAnimationFrame((()=>{t++,t<e?o():n()}));o()})),W=(e,n,t=null)=>{let o,r=0;t=null===t?n:t;const i=(...n)=>{clearTimeout(o),o=setTimeout((()=>{r>0&&(e(...n),r=0)}),t)};let a=!1;const c=(...t)=>{a?(r++,i(...t)):(e(...t),i(...t),a=!0,r=0,setTimeout((()=>{a=!1}),n))};return c.reset=()=>{a=!1},c.cancel=()=>{clearTimeout(o)},c.now=(...n)=>e(...n),c};
/**
* KDBush - A fast static index for 2D points
* @license ISC License
* @copyright Vladimir Agafonkin 2018
* @version 4.0.2
* @see https://github.com/mourner/kdbush/
*/
var V,Z=function(){var e=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],n=function(){function n(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Float64Array,i=arguments.length>3?arguments[3]:void 0;if(function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),isNaN(t)||t<0)throw new Error("Unexpected numItems value: ".concat(t,"."));this.numItems=+t,this.nodeSize=Math.min(Math.max(+o,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;var a=e.indexOf(this.ArrayType),c=2*t*this.ArrayType.BYTES_PER_ELEMENT,l=t*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-l%8)%8;if(a<0)throw new Error("Unexpected typed array class: ".concat(r,"."));i&&i instanceof ArrayBuffer?(this.data=i,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+l+s,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+c+l+s),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+l+s,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+a]),new Uint16Array(this.data,2,1)[0]=o,new Uint32Array(this.data,4,1)[0]=t)}return o=n,i=[{key:"from",value:function(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");var o=u(new Uint8Array(t,0,2),2),r=o[0],i=o[1];if(219!==r)throw new Error("Data does not appear to be in a KDBush format.");var a=i>>4;if(1!==a)throw new Error("Got v".concat(a," data when expected v").concat(1,"."));var c=e[15&i];if(!c)throw new Error("Unrecognized array type.");var l=u(new Uint16Array(t,2,1),1)[0];return new n(u(new Uint32Array(t,4,1),1)[0],l,c,t)}}],(r=[{key:"add",value:function(e,n){var t=this._pos>>1;return this.ids[t]=t,this.coords[this._pos++]=e,this.coords[this._pos++]=n,t}},{key:"finish",value:function(){var e=this._pos>>1;if(e!==this.numItems)throw new Error("Added ".concat(e," items when expected ").concat(this.numItems,"."));return t(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}},{key:"range",value:function(e,n,t,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");for(var r=this.ids,i=this.coords,a=this.nodeSize,c=[0,r.length-1,0],l=[];c.length;){var s=c.pop()||0,u=c.pop()||0,d=c.pop()||0;if(u-d<=a)for(var f=d;f<=u;f++){var v=i[2*f],p=i[2*f+1];v>=e&&v<=t&&p>=n&&p<=o&&l.push(r[f])}else{var h=d+u>>1,m=i[2*h],y=i[2*h+1];m>=e&&m<=t&&y>=n&&y<=o&&l.push(r[h]),(0===s?e<=m:n<=y)&&(c.push(d),c.push(h-1),c.push(1-s)),(0===s?t>=m:o>=y)&&(c.push(h+1),c.push(u),c.push(1-s))}}return l}},{key:"within",value:function(e,n,t){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");for(var o=this.ids,r=this.coords,i=this.nodeSize,c=[0,o.length-1,0],l=[],s=t*t;c.length;){var u=c.pop()||0,d=c.pop()||0,f=c.pop()||0;if(d-f<=i)for(var v=f;v<=d;v++)a(r[2*v],r[2*v+1],e,n)<=s&&l.push(o[v]);else{var p=f+d>>1,h=r[2*p],m=r[2*p+1];a(h,m,e,n)<=s&&l.push(o[p]),(0===u?e-t<=h:n-t<=m)&&(c.push(f),c.push(p-1),c.push(1-u)),(0===u?e+t>=h:n+t>=m)&&(c.push(p+1),c.push(d),c.push(1-u))}}return l}}])&&c(o.prototype,r),i&&c(o,i),Object.defineProperty(o,"prototype",{writable:!1}),o;var o,r,i}();function t(e,n,r,i,a,c){if(!(a-i<=r)){var l=i+a>>1;o(e,n,l,i,a,c),t(e,n,r,i,l-1,1-c),t(e,n,r,l+1,a,1-c)}}function o(e,n,t,i,a,c){for(;a>i;){if(a-i>600){var l=a-i+1,s=t-i+1,u=Math.log(l),d=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*d*(l-d)/l)*(s-l/2<0?-1:1);o(e,n,t,Math.max(i,Math.floor(t-s*d/l+f)),Math.min(a,Math.floor(t+(l-s)*d/l+f)),c)}var v=n[2*t+c],p=i,h=a;for(r(e,n,i,t),n[2*a+c]>v&&r(e,n,i,a);p<h;){for(r(e,n,p,h),p++,h--;n[2*p+c]<v;)p++;for(;n[2*h+c]>v;)h--}n[2*i+c]===v?r(e,n,i,h):r(e,n,++h,a),h<=t&&(i=h+1),t<=h&&(a=h-1)}}function r(e,n,t,o){i(e,t,o),i(n,2*t,2*o),i(n,2*t+1,2*o+1)}function i(e,n,t){var o=e[n];e[n]=e[t],e[t]=o}function a(e,n,t,o){var r=e-t,i=n-o;return r*r+i*i}return n},U=function(){addEventListener("message",(function(e){var n=e.data.points;n.length||self.postMessage({error:new Error("Invalid point data")});for(var t=new KDBush(n.length,e.data.nodeSize),o=0;o<n.length;++o)t.add(n[o][0],n[o][1]);t.finish(),postMessage(t.data,[t.data])}))},q=Z(),G=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{nodeSize:16,useWorker:void 0};return new Promise((function(t,o){if(e instanceof ArrayBuffer)t(q.from(e));else if((e.length<1e6||!1===n.useWorker)&&!0!==n.useWorker){for(var r=new q(e.length,n.nodeSize),i=0;i<e.length;++i)r.add(e[i][0],e[i][1]);r.finish(),t(r)}else{var a=function(e){var n=Z.toString();n=n.substring(10,n.length-18);var t=e.toString();return t=t.substring(10,t.length-2),new Worker(window.URL.createObjectURL(new Blob(["".concat(n,";").concat(t)],{type:"text/javascript"})))}(U);a.onmessage=function(e){e.data.error?o(e.data.error):t(q.from(e.data)),a.terminate()},a.postMessage({points:e,nodeSize:n.nodeSize})}}))},H="auto",K=Float32Array.BYTES_PER_ELEMENT,Y=["OES_texture_float","OES_element_index_uint","WEBGL_color_buffer_float","EXT_float_blend"],X={color:[0,0,0,0],depth:1},$="panZoom",J="lasso",Q="rotate",ee=[$,J,Q],ne=$,te={cubicIn:e=>e*e*e,cubicInOut:z,cubicOut:e=>--e*e*e+1,linear:e=>e,quadIn:e=>e*e,quadInOut:e=>e<.5?2*e*e:(4-2*e)*e-1,quadOut:e=>e*(2-e)},oe=z,re="continuous",ie="categorical",ae=[re,ie],ce="deselect",le="lassoEnd",se=[ce,le],ue=[0,.666666667,1,1],de=le,fe=750,ve=500,pe=100,he=250,me="lasso",ye="rotate",ge="merge",we=[me,ye,ge],xe="alt",be="cmd",Se="ctrl",Ee="meta",Pe="shift",Ae=[xe,be,Se,Ee,Pe],Me=l(l(l({},xe,ye),Pe,me),be,ge),Ce=H,Ie=H,Te=null,Re=null,Oe=null,Le=null,De=null,Be=[.66,.66,.66,1],ze=[0,.55,1,1],ke=[1,1,1,1],je=[0,0,0,1],Fe=null,Ne=[.66,.66,.66,.2],_e=[0,.55,1,1],We=[1,1,1,1],Ve=[1,1,1,.5],Ze=[0,0],Ue=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),qe=[1,1,1,.5],Ge=new Set(["z","valueZ","valueA","value1","category"]),He=new Set(["w","valueW","valueB","value2","value"]),Ke=15e3,Ye="Points have not been drawn",Xe=function(e,n){return!!e&&Y.reduce((function(t,o){return e.hasExtension(o)?t:(n||console.warn("WebGL: ".concat(o," extension not supported. Scatterplot might not render properly")),!1)}),!0)},$e=function(e){var n=e.getContext("webgl",{antialias:!0,preserveDrawingBuffer:!0}),t=[];return Y.forEach((function(e){n.getExtension(e)?t.push(e):console.warn("WebGL: ".concat(e," extension not supported. Scatterplot might not render properly"))})),i.default({gl:n,extensions:t})},Je=function(e,n,t,o){return Math.sqrt(Math.pow(e-t,2)+Math.pow(n-o,2))},Qe=function(e,n){var t=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).minLength,o=void 0===t?0:t;return Array.isArray(e)&&e.length>=o&&e.every(n)},en=function(e){return!Number.isNaN(+e)&&+e>=0},nn=function(e){return!Number.isNaN(+e)&&+e>0},tn=function(e,n){return function(t){return e.indexOf(t)>=0?t:n}},on=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ke;return new Promise((function(o,r){(function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ke;return new Promise((function(o,r){var i=new Image;n&&(i.crossOrigin="anonymous"),i.src=e,i.onload=function(){o(i)};var a=function(){r(new Error("IMAGE_LOAD_ERROR"))};i.onerror=a,setTimeout(a,t)}))})(n,0!==n.indexOf(window.location.origin)&&-1===n.indexOf("base64"),t).then((function(n){o(e.texture(n))})).catch((function(e){r(e)}))}))},rn=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return[].concat(d(function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,n,t,o){return"#".concat(n).concat(n).concat(t).concat(t).concat(o).concat(o)})).substring(1).match(/.{2}/g).map((function(e){return parseInt(e,16)/Math.pow(255,n)}))}(e,n)),[Math.pow(255,!n)])},an=function(e){return e>=0&&e<=1},cn=function(e){return Array.isArray(e)&&e.every(an)},ln=function(e){return"string"==typeof e||e instanceof String},sn=function(e){return Number.isInteger(e)&&e>=0&&e<=255},un=function(e){return Array.isArray(e)&&e.every(sn)},dn=function(e){return Array.isArray(e)&&e.length&&(Array.isArray(e[0])||ln(e[0]))},fn=function(e,n){return e>n?e:n},vn=function(e,n){return e<n?e:n},pn=function(e,n){if(4===(o=e).length&&(cn(o)||un(o))){var t=cn(e);return n&&t||!n&&!t?e:n&&!t?e.map((function(e){return e/255})):e.map((function(e){return 255*e}))}var o,r;if(3===(r=e).length&&(cn(r)||un(r))){var i=Math.pow(255,!n),a=cn(e);return[].concat(n&&a||!n&&!a?d(e):d(n&&!a?e.map((function(e){return e/255})):e.map((function(e){return 255*e}))),[i])}return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)?rn(e,n):(console.warn("Only HEX, RGB, and RGBA are handled by this function. Returning white instead."),n?[1,1,1,1]:[255,255,255,255])},hn=function(e){return Object.entries(e).reduce((function(e,n){var t=u(n,2),o=t[0],r=t[1];return e[r]?e[r]=[].concat(d(e[r]),[o]):e[r]=o,e}),{})},mn=function(e){return.21*e[0]+.72*e[1]+.07*e[2]},yn=function(e){return new Promise((function(n,t){if(!e||Array.isArray(e))n(e);else{var o=Array.isArray(e.x)||ArrayBuffer.isView(e.x)?e.x.length:0,r=(Array.isArray(e.x)||ArrayBuffer.isView(e.x))&&function(n){return e.x[n]},i=(Array.isArray(e.y)||ArrayBuffer.isView(e.y))&&function(n){return e.y[n]},a=(Array.isArray(e.line)||ArrayBuffer.isView(e.line))&&function(n){return e.line[n]},c=(Array.isArray(e.lineOrder)||ArrayBuffer.isView(e.lineOrder))&&function(n){return e.lineOrder[n]},l=Object.keys(e),s=(f=l.find((function(e){return Ge.has(e)})))&&(Array.isArray(e[f])||ArrayBuffer.isView(e[f]))&&function(n){return e[f][n]},u=(d=l.find((function(e){return He.has(e)})))&&(Array.isArray(e[d])||ArrayBuffer.isView(e[d]))&&function(n){return e[d][n]};r&&i&&s&&u&&a&&c?n(e.x.map((function(e,n){return[e,i(n),s(n),u(n),a(n),c(n)]}))):r&&i&&s&&u&&a?n(Array.from({length:o},(function(e,n){return[r(n),i(n),s(n),u(n),a(n)]}))):r&&i&&s&&u?n(Array.from({length:o},(function(e,n){return[r(n),i(n),s(n),u(n)]}))):r&&i&&s?n(Array.from({length:o},(function(e,n){return[r(n),i(n),s(n)]}))):r&&i?n(Array.from({length:o},(function(e,n){return[r(n),i(n)]}))):t(new Error("You need to specify at least x and y"))}var d,f}))},gn=function(e){return Number.isFinite(e.y)&&!("x"in e)},wn=function(e){return Number.isFinite(e.x)&&!("y"in e)},xn=function(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height)},bn=function(e){return Number.isFinite(e.x1)&&Number.isFinite(e.y1)&&Number.isFinite(e.x2)&&Number.isFinite(e.x2)},Sn=function(e){return"vertices"in e&&e.vertices.length>1},En=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.regl,t=e.canvas,o=void 0===t?document.createElement("canvas"):t,r=e.gamma,i=void 0===r?1:r,a=!1;n||(n=$e(o));var c=Xe(n),l=[o.width,o.height],s=n.framebuffer({width:l[0],height:l[1],colorFormat:"rgba",colorType:"float"}),u=n({vert:"\n precision highp float;\n attribute vec2 xy;\n void main () {\n gl_Position = vec4(xy, 0, 1);\n }",frag:"\n precision highp float;\n uniform vec2 srcRes;\n uniform sampler2D src;\n uniform float gamma;\n\n vec3 approxLinearToSRGB (vec3 rgb, float gamma) {\n return pow(clamp(rgb, vec3(0), vec3(1)), vec3(1.0 / gamma));\n }\n\n void main () {\n vec4 color = texture2D(src, gl_FragCoord.xy / srcRes);\n gl_FragColor = vec4(approxLinearToSRGB(color.rgb, gamma), color.a);\n }",attributes:{xy:[-4,-4,4,-4,0,4]},uniforms:{src:function(){return s},srcRes:function(){return l},gamma:function(){return i}},count:3,depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"one",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"}}}),d=new Set,f=n.frame((function(){for(var e=d.values(),n=e.next();!n.done;)n.value(),n=e.next()})),v=function(){o.width=window.innerWidth*window.devicePixelRatio,o.height=window.innerHeight*window.devicePixelRatio,l[0]=o.width,l[1]=o.height,s.resize.apply(s,l)};e.canvas||(window.addEventListener("resize",v),window.addEventListener("orientationchange",v),v());return{get canvas(){return o},get regl(){return n},get gamma(){return i},set gamma(e){i=+e},get isSupported(){return c},get isDestroyed(){return a},render:function(e,t){n.clear(X),s.use((function(){n.clear(X),e()})),u(),function(e){var n=e.getContext("2d");n.clearRect(0,0,e.width,e.height),n.drawImage(o,(o.width-e.width)/2,(o.height-e.height)/2,e.width,e.height,0,0,e.width,e.height)}(t)},onFrame:function(e){return d.add(e),function(){d.delete(e)}},refresh:function(){n.poll()},destroy:function(){a=!0,window.removeEventListener("resize",v),window.removeEventListener("orientationchange",v),f.cancel(),o=void 0,n.destroy(),n=void 0}}},Pn=function(e,n){return"".concat(e,"ms ease-out effectIn ").concat(n,"ms 1 normal forwards")},An=function(e,n){return"".concat(e,"ms linear leftSpinIn ").concat(n,"ms 1 normal forwards")},Mn=function(e,n){return"".concat(e,"ms linear rightSpinIn ").concat(n,"ms 1 normal forwards")},Cn=function(e,n){return"".concat(e,"ms linear circleIn ").concat(n,"ms 1 normal forwards")},In=function(e,n,t){return"\n @keyframes mainIn {\n 0% {\n color: ".concat(n,";\n opacity: 0;\n }\n 0%, ").concat(e,"% {\n color: ").concat(n,";\n opacity: 1;\n }\n 100% {\n color: ").concat(t,";\n opacity: 0.8;\n }\n }\n")},Tn=function(e,n,t,o){return"\n @keyframes effectIn {\n 0%, ".concat(e,"% {\n opacity: ").concat(t,";\n transform: scale(").concat(o,");\n }\n ").concat(n,"% {\n opacity: 0.66;\n transform: scale(1.5);\n }\n 99% {\n opacity: 0;\n transform: scale(2);\n }\n 100% {\n opacity: 0;\n transform: scale(0);\n }\n }\n")},Rn=function(e,n){return"\n @keyframes leftSpinIn {\n 0% {\n transform: rotate(".concat(n,"deg);\n }\n ").concat(e,"%, 100% {\n transform: rotate(360deg);\n }\n }\n")},On=function(e,n){return"\n @keyframes rightSpinIn {\n 0% {\n transform: rotate(".concat(n,"deg);\n }\n ").concat(e,"%, 100% {\n transform: rotate(180deg);\n }\n }\n")},Ln=function(e){return"".concat(e,"ms linear effectOut 0s 1 normal forwards")},Dn=function(e){return"".concat(e,"ms linear leftSpinOut 0s 1 normal forwards")},Bn=function(e){return"".concat(e,"ms linear rightSpinOut 0s 1 normal forwards")},zn=function(e){return"".concat(e,"ms linear circleOut 0s 1 normal forwards")},kn=function(e,n){return"\n @keyframes mainOut {\n 0% {\n color: ".concat(e,";\n }\n 100% {\n color: ").concat(n,";\n }\n }\n")},jn=function(e,n){return"\n @keyframes rightSpinOut {\n 0%, ".concat(e,"% {\n transform: rotate(").concat(n,"deg);\n }\n 100% {\n transform: rotate(0deg);\n }\n")},Fn=function(e){return"\n @keyframes leftSpinOut {\n 0% {\n transform: rotate(".concat(e,"deg);\n }\n 100% {\n transform: rotate(0deg);\n }\n }\n")},Nn=function(e,n,t){return"\n @keyframes circleOut {\n 0%, ".concat(e,"% {\n clip-path: ").concat(n,";\n opacity: ").concat(t,";\n }\n ").concat(e+.01,"% {\n clip-path: inset(0 0 0 50%);\n opacity: ").concat(t,";\n }\n 100% {\n clip-path: inset(0 0 0 50%);\n opacity: 0;\n }\n }\n")},_n=function(e){return null===e?arguments.length>1&&void 0!==arguments[1]?arguments[1]:null:e},Wn=function(){if(!V){var e=document.createElement("style");document.head.appendChild(e),V=e.sheet}return V},Vn=function(e){var n=Wn(),t=n.rules.length;return n.insertRule(e,t),t},Zn=function(e){Wn().deleteRule(e)},Un="".concat(2500,"ms ease scaleInFadeOut 0s 1 normal backwards"),qn=null,Gn="".concat(250,"ms ease fadeScaleOut 0s 1 normal backwards"),Hn=null,Kn=function e(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.onDraw,r=void 0===o?k:o,i=t.onStart,a=void 0===i?k:i,c=t.onEnd,l=void 0===c?k:c,s=t.enableInitiator,u=void 0===s||s,f=t.initiatorParentElement,v=void 0===f?document.body:f,p=t.longPressIndicatorParentElement,h=void 0===p?document.body:p;t.minDelay,t.minDist;var m=t.pointNorm,y=u,g=v,w=h,x=r,b=a,S=l,E=void 0===m?k:m,P=document.createElement("div"),A=Math.random().toString(36).substring(2,5)+Math.random().toString(36).substring(2,5);P.id="lasso-initiator-".concat(A),P.style.position="fixed",P.style.display="flex",P.style.justifyContent="center",P.style.alignItems="center",P.style.zIndex=99,P.style.width="4rem",P.style.height="4rem",P.style.borderRadius="4rem",P.style.opacity=.5,P.style.transform="translate(-50%,-50%) scale(0) rotate(0deg)";var M,C=function(){var e=document.createElement("div"),n=Math.random().toString(36).substring(2,5)+Math.random().toString(36).substring(2,5);e.id="lasso-long-press-".concat(n),e.style.position="fixed",e.style.width="1.25rem",e.style.height="1.25rem",e.style.pointerEvents="none",e.style.transform="translate(-50%,-50%)";var t=document.createElement("div");t.style.position="absolute",t.style.top=0,t.style.left=0,t.style.width="1.25rem",t.style.height="1.25rem",t.style.clipPath="inset(0px 0px 0px 50%)",t.style.opacity=0,e.appendChild(t);var o=document.createElement("div");o.style.position="absolute",o.style.top=0,o.style.left=0,o.style.width="0.8rem",o.style.height="0.8rem",o.style.border="0.2rem solid currentcolor",o.style.borderRadius="0.8rem",o.style.clipPath="inset(0px 50% 0px 0px)",o.style.transform="rotate(0deg)",t.appendChild(o);var r=document.createElement("div");r.style.position="absolute",r.style.top=0,r.style.left=0,r.style.width="0.8rem",r.style.height="0.8rem",r.style.border="0.2rem solid currentcolor",r.style.borderRadius="0.8rem",r.style.clipPath="inset(0px 50% 0px 0px)",r.style.transform="rotate(0deg)",t.appendChild(r);var i=document.createElement("div");return i.style.position="absolute",i.style.top=0,i.style.left=0,i.style.width="1.25rem",i.style.height="1.25rem",i.style.borderRadius="1.25rem",i.style.background="currentcolor",i.style.transform="scale(0)",i.style.opacity=0,e.appendChild(i),{longPress:e,longPressCircle:t,longPressCircleLeft:o,longPressCircleRight:r,longPressEffect:i}}(),I=C.longPress,T=C.longPressCircle,R=C.longPressCircleLeft,O=C.longPressCircleRight,L=C.longPressEffect,D=!1,B=!1,z=[],j=[],V=!1,Z=null,U=null,q=null,G=null,H=null,K=null,Y=null,X=null,$=null,J=null,Q=function(){D=!1};window.addEventListener("mouseup",Q);var ee,ne=function(){P.style.opacity=.5,P.style.transform="translate(-50%,-50%) scale(0) rotate(0deg)"},te=function(e,n){var t=getComputedStyle(e),o=+t.opacity,r=t.transform.match(/([0-9.-]+)+/g),i=+r[0],a=+r[1],c=Math.sqrt(i*i+a*a),l=Math.atan2(a,i)*(180/Math.PI);return{opacity:o,scale:c,rotate:l=n&&l<=0?360+l:l}},oe=function(e){if(y&&!D){var n=e.clientX,t=e.clientY;P.style.top="".concat(t,"px"),P.style.left="".concat(n,"px");var o=te(P),r=o.opacity,i=o.scale,a=o.rotate;P.style.opacity=r,P.style.transform="translate(-50%,-50%) scale(".concat(i,") rotate(").concat(a,"deg)"),P.style.animation="none",_().then((function(){null!==qn&&Zn(qn),qn=Vn(function(e,n,t){return"\n@keyframes scaleInFadeOut {\n 0% {\n opacity: ".concat(e,";\n transform: translate(-50%,-50%) scale(").concat(n,") rotate(").concat(t,"deg);\n }\n 10% {\n opacity: 1;\n transform: translate(-50%,-50%) scale(1) rotate(").concat(t+20,"deg);\n }\n 100% {\n opacity: 0;\n transform: translate(-50%,-50%) scale(0.9) rotate(").concat(t+60,"deg);\n }\n}\n")}(r,i,a)),P.style.animation=Un,_().then((function(){ne()}))}))}},re=function(){var e=te(P),n=e.opacity,t=e.scale,o=e.rotate;P.style.opacity=n,P.style.transform="translate(-50%,-50%) scale(".concat(t,") rotate(").concat(o,"deg)"),P.style.animation="none",_(2).then((function(){null!==Hn&&Zn(Hn),Hn=Vn(function(e,n,t){return"\n@keyframes fadeScaleOut {\n 0% {\n opacity: ".concat(e,";\n transform: translate(-50%,-50%) scale(").concat(n,") rotate(").concat(t,"deg);\n }\n 100% {\n opacity: 0;\n transform: translate(-50%,-50%) scale(0) rotate(").concat(t,"deg);\n }\n}\n")}(n,t,o)),P.style.animation=Gn,_().then((function(){ne()}))}))},ie=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{time:fe,extraTime:ve,delay:pe},o=t.time,r=void 0===o?fe:o,i=t.extraTime,a=void 0===i?ve:i,c=t.delay,l=void 0===c?pe:c;V=!0;var s=getComputedStyle(I);I.style.color=s.color,I.style.top="".concat(n,"px"),I.style.left="".concat(e,"px"),I.style.animation="none";var u=getComputedStyle(T);T.style.clipPath=u.clipPath,T.style.opacity=u.opacity,T.style.animation="none";var d=te(L);L.style.opacity=d.opacity,L.style.transform="scale(".concat(d.scale,")"),L.style.animation="none";var f=te(R);R.style.transform="rotate(".concat(f.rotate,"deg)"),R.style.animation="none";var v=te(O);O.style.transform="rotate(".concat(v.rotate,"deg)"),O.style.animation="none",_().then((function(){if(V){null!==H&&Zn(H),null!==G&&Zn(G),null!==q&&Zn(q),null!==U&&Zn(U),null!==Z&&Zn(Z);var e=function(e){var n,t,o,r,i,a=e.time,c=void 0===a?fe:a,l=e.extraTime,s=void 0===l?ve:l,u=e.delay,d=void 0===u?pe:u,f=e.currentColor,v=e.targetColor,p=e.effectOpacity,h=e.effectScale,m=e.circleLeftRotation,y=e.circleRightRotation,g=e.circleClipPath,w=e.circleOpacity,x=m/360,b=function(e,n,t){return(1-e)*n+t}(x,c,s),S=Math.round((1-x)*c/b*100),E=Math.round(S/2),P=S+(100-S)/4;return{rules:{main:In(S,f,v),effect:Tn(S,P,p,h),circleRight:On(E,y),circleLeft:Rn(S,m),circle:(o=E,r=g,i=w,"\n @keyframes circleIn {\n 0% {\n clip-path: ".concat(r,";\n opacity: ").concat(i,";\n }\n ").concat(o,"% {\n clip-path: ").concat(r,";\n opacity: 1;\n }\n ").concat(o+.01,"%, 100% {\n clip-path: inset(0);\n opacity: 1;\n }\n }\n"))},names:{main:(n=b,t=d,"".concat(n,"ms ease-out mainIn ").concat(t,"ms 1 normal forwards")),effect:Pn(b,d),circleLeft:An(b,d),circleRight:Mn(b,d),circle:Cn(b,d)}}}({time:r,extraTime:a,delay:l,currentColor:s.color||"currentcolor",targetColor:I.dataset.activeColor,effectOpacity:d.opacity||0,effectScale:d.scale||0,circleLeftRotation:f.rotate||0,circleRightRotation:v.rotate||0,circleClipPath:u.clipPath||"inset(0 0 0 50%)",circleOpacity:u.opacity||0}),n=e.rules,t=e.names;Z=Vn(n.main),U=Vn(n.effect),q=Vn(n.circleLeft),G=Vn(n.circleRight),H=Vn(n.circle),I.style.animation=t.main,L.style.animation=t.effect,R.style.animation=t.circleLeft,O.style.animation=t.circleRight,T.style.animation=t.circle}}))},ae=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{time:he}).time,n=void 0===e?he:e;if(V){V=!1;var t=getComputedStyle(I);I.style.color=t.color,I.style.animation="none";var o=getComputedStyle(T);T.style.clipPath=o.clipPath,T.style.opacity=o.opacity,T.style.animation="none";var r=te(L);L.style.opacity=r.opacity,L.style.transform="scale(".concat(r.scale,")"),L.style.animation="none";var i="x"===o.clipPath.slice(-2,-1),a=te(R,i);R.style.transform="rotate(".concat(a.rotate,"deg)"),R.style.animation="none";var c=te(O);O.style.transform="rotate(".concat(c.rotate,"deg)"),O.style.animation="none",_().then((function(){null!==J&&Zn(J),null!==$&&Zn($),null!==X&&Zn(X),null!==Y&&Zn(Y),null!==K&&Zn(K);var e=function(e){var n,t,o,r=e.time,i=void 0===r?he:r,a=e.currentColor,c=e.targetColor,l=e.effectOpacity,s=e.effectScale,u=e.circleLeftRotation,d=e.circleRightRotation,f=e.circleClipPath,v=e.circleOpacity,p=u/360,h=p*i,m=Math.min(100,100*p),y=m>50?Math.round(100*(1-50/m)):0;return{rules:{main:kn(a,c),effect:(t=l,o=s,"\n @keyframes effectOut {\n 0% {\n opacity: ".concat(t,";\n transform: scale(").concat(o,");\n }\n 99% {\n opacity: 0;\n transform: scale(").concat(o+.5,");\n }\n 100% {\n opacity: 0;\n transform: scale(0);\n }\n }\n")),circleRight:jn(y,d),circleLeft:Fn(u),circle:Nn(y,f,v)},names:{main:(n=h,"".concat(n,"ms linear mainOut 0s 1 normal forwards")),effect:Ln(h),circleRight:Dn(h),circleLeft:Bn(h),circle:zn(h)}}}({time:n,currentColor:t.color||"currentcolor",targetColor:I.dataset.color,effectOpacity:r.opacity||0,effectScale:r.scale||0,circleLeftRotation:a.rotate||0,circleRightRotation:c.rotate||0,circleClipPath:o.clipPath||"inset(0px)",circleOpacity:o.opacity||1}),i=e.rules,l=e.names;K=Vn(i.main),Y=Vn(i.effect),X=Vn(i.circleLeft),$=Vn(i.circleRight),J=Vn(i.circle),I.style.animation=l.main,L.style.animation=l.effect,R.style.animation=l.circleLeft,O.style.animation=l.circleRight,T.style.animation=l.circle}))}},ce=function(){x(z,j)},le=function(e){if(M){if((o=e[0],r=e[1],i=M[0],a=M[1],Math.sqrt((o-i)**2+(r-a)**2))>2){M=e;var n=E(e);z.push(n),j.push(n[0],n[1]),z.length>1&&ce()}}else{B||(B=!0,b()),M=e;var t=E(e);z=[t],j=[t[0],t[1]]}var o,r,i,a},se=W(le,8,8),ue=function(e,t){var o=function(e){var t=n.getBoundingClientRect(),o=t.left,r=t.top;return[e.clientX-o,e.clientY-r]}(e);return t?se(o):le(o)},de=function(){z=[],j=[],M=void 0,ce()},me=function(e){oe(e)},ye=function(){D=!0,B=!0,de(),b()},ge=function(){re()},we=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).merge,n=void 0!==e&&e;B=!1;var t=d(z),o=d(j);return se.cancel(),de(),t.length&&S(t,o,{merge:n}),t},xe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.onDraw,t=void 0===n?null:n,o=e.onStart,r=void 0===o?null:o,i=e.onEnd,a=void 0===i?null:i,c=e.enableInitiator,l=void 0===c?null:c,s=e.initiatorParentElement,u=void 0===s?null:s,d=e.longPressIndicatorParentElement,f=void 0===d?null:d;e.minDelay,e.minDist;var v=e.pointNorm,p=void 0===v?null:v;x=_n(t,x),b=_n(r,b),S=_n(a,S),y=_n(l,y),E=_n(p,E),null!==u&&u!==g&&(g.removeChild(P),u.appendChild(P),g=u),null!==f&&f!==w&&(w.removeChild(I),f.appendChild(I),w=f),y?(P.addEventListener("click",me),P.addEventListener("mousedown",ye),P.addEventListener("mouseleave",ge)):(P.removeEventListener("mousedown",ye),P.removeEventListener("mouseleave",ge))},be=function(){g.removeChild(P),w.removeChild(I),window.removeEventListener("mouseup",Q),P.removeEventListener("click",me),P.removeEventListener("mousedown",ye),P.removeEventListener("mouseleave",ge)};return g.appendChild(P),w.appendChild(I),xe({onDraw:x,onStart:b,onEnd:S,enableInitiator:y,initiatorParentElement:g}),((...e)=>n=>e.reduce(((e,n)=>n(e)),n))(N("initiator",P),N("longPressIndicator",I),(function(e){return F(e,{clear:de,destroy:be,end:we,extend:ue,set:xe,showInitiator:oe,hideInitiator:re,showLongPressIndicator:ie,hideLongPressIndicator:ae})}),(ee=e,e=>F({__proto__:{constructor:ee}},e)))({})};const Yn=e=>`\nprecision highp float;\n\nuniform sampler2D colorTex;\nuniform float colorTexRes;\nuniform float colorTexEps;\nuniform sampler2D stateTex;\nuniform float stateTexRes;\nuniform float stateTexEps;\nuniform float devicePixelRatio;\nuniform sampler2D encodingTex;\nuniform float encodingTexRes;\nuniform float encodingTexEps;\nuniform float pointSizeExtra;\nuniform float pointOpacityMax;\nuniform float pointOpacityScale;\nuniform float numPoints;\nuniform float globalState;\nuniform float isColoredByZ;\nuniform float isColoredByW;\nuniform float isOpacityByZ;\nuniform float isOpacityByW;\nuniform float isOpacityByDensity;\nuniform float isSizedByZ;\nuniform float isSizedByW;\nuniform float colorMultiplicator;\nuniform float opacityMultiplicator;\nuniform float opacityDensity;\nuniform float sizeMultiplicator;\nuniform float numColorStates;\nuniform float pointScale;\nuniform mat4 modelViewProjection;\n\nattribute vec2 stateIndex;\n\nvarying vec4 color;\nvarying float finalPointSize;\n\nvoid main() {\n vec4 state = texture2D(stateTex, stateIndex);\n\n gl_Position = modelViewProjection * vec4(state.x, state.y, 0.0, 1.0);\n\n // Determine color index\n float colorIndexZ = isColoredByZ * floor(state.z * colorMultiplicator);\n float colorIndexW = isColoredByW * floor(state.w * colorMultiplicator);\n\n // Multiply by the number of color states per color\n // I.e., normal, active, hover, background, etc.\n float colorIndex = (colorIndexZ + colorIndexW) * numColorStates;\n\n // Half a "pixel" or "texel" in texture coordinates\n float colorLinearIndex = colorIndex + globalState;\n\n // Need to add cEps here to avoid floating point issue that can lead to\n // dramatic changes in which color is loaded as floor(3/2.9999) = 1 but\n // floor(3/3.0001) = 0!\n float colorRowIndex = floor((colorLinearIndex + colorTexEps) / colorTexRes);\n\n vec2 colorTexIndex = vec2(\n (colorLinearIndex / colorTexRes) - colorRowIndex + colorTexEps,\n colorRowIndex / colorTexRes + colorTexEps\n );\n\n color = texture2D(colorTex, colorTexIndex);\n\n // Retrieve point size\n float pointSizeIndexZ = isSizedByZ * floor(state.z * sizeMultiplicator);\n float pointSizeIndexW = isSizedByW * floor(state.w * sizeMultiplicator);\n float pointSizeIndex = pointSizeIndexZ + pointSizeIndexW;\n\n float pointSizeRowIndex = floor((pointSizeIndex + encodingTexEps) / encodingTexRes);\n vec2 pointSizeTexIndex = vec2(\n (pointSizeIndex / encodingTexRes) - pointSizeRowIndex + encodingTexEps,\n pointSizeRowIndex / encodingTexRes + encodingTexEps\n );\n float pointSize = texture2D(encodingTex, pointSizeTexIndex).x;\n\n // Retrieve opacity\n ${3===e?"":`\n if (isOpacityByDensity < 0.5) {\n float opacityIndexZ = isOpacityByZ * floor(state.z * opacityMultiplicator);\n float opacityIndexW = isOpacityByW * floor(state.w * opacityMultiplicator);\n float opacityIndex = opacityIndexZ + opacityIndexW;\n\n float opacityRowIndex = floor((opacityIndex + encodingTexEps) / encodingTexRes);\n vec2 opacityTexIndex = vec2(\n (opacityIndex / encodingTexRes) - opacityRowIndex + encodingTexEps,\n opacityRowIndex / encodingTexRes + encodingTexEps\n );\n color.a = texture2D(encodingTex, opacityTexIndex)[${1+e}];\n } else {\n color.a = min(1.0, opacityDensity + globalState);\n }\n `}\n\n color.a = min(pointOpacityMax, color.a) * pointOpacityScale;\n finalPointSize = (pointSize * pointScale) + pointSizeExtra;\n gl_PointSize = finalPointSize;\n}\n`;var Xn=function(){var e=function(e,n,t,o,r){var i=.5*(o-n),a=.5*(r-t);return(2*t-2*o+i+a)*e*e*e+(-3*t+3*o-2*i-a)*e*e+i*e+t},n=function(n,t,o){var r=o*n,i=Math.floor(r),a=r-i,c=t[Math.max(0,i-1)],l=t[i],s=t[Math.min(o,i+1)],u=t[Math.min(o,i+2)];return[e(a,c[0],l[0],s[0],u[0]),e(a,c[1],l[1],s[1],u[1])]},t=function(e,n,t){var o=n[0],r=n[1],i=t[0]-o,a=t[1]-r;if(0!==i||0!==a){var c=((e[0]-o)*i+(e[1]-r)*a)/(i*i+a*a);c>1?(o=t[0],r=t[1]):c>0&&(o+=i*c,r+=a*c)}return(i=e[0]-o)*i+(a=e[1]-r)*a},o=function e(n,o,r,i,a){for(var c,l=i,s=o+1;s<r;s++){var u=t(n[s],n[o],n[r]);u>l&&(c=s,l=u)}l>i&&(c-o>1&&e(n,o,c,i,a),a.push(n[c]),r-c>1&&e(n,c,r,i,a))},r=function(e,n){var t=e.length-1,r=[e[0]];return o(e,0,t,n,r),r.push(e[t]),r};self.onmessage=function(e){(e.data.points?+e.data.points.length:0)||self.postMessage({error:new Error("No points provided")}),e.data.points;var t=function(e){var n={},t=!Number.isNaN(+e[0][5]);return e.forEach((function(e){var o=e[4];n[o]||(n[o]=[]),t?n[o][e[5]]=e:n[o].push(e)})),Object.entries(n).forEach((function(e){n[e[0]]=e[1].filter((function(e){return e})),n[e[0]].reference=e[1][0]})),n}(e.data.points);self.postMessage({points:Object.entries(t).reduce((function(t,o){return t[o[0]]=function(e){for(var t,o,i,a,c,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=l.maxIntPointsPerSegment,u=void 0===s?100:s,d=l.tolerance,f=void 0===d?.002:d,v=e.length,p=v-1,h=p*u+1,m=Math.pow(f,2),y=[],g=0;g<v-1;g++){var w=[e[g].slice(0,2)];t=e[g];for(var x=1;x<u;x++){var b=n((g*u+x)/h,e,p);o=t[0],i=t[1],a=b[0],c=b[1],Math.pow(o-a,2)+Math.pow(i-c,2)>m&&(w.push(b),t=b)}w.push(e[g+1]),w=r(w,m),y=y.concat(w.slice(0,w.length-1))}return y.push(e[e.length-1].slice(0,2)),y.flat()}(o[1],e.data.options),t[o[0]].reference=o[1].reference,t}),{})})}},$n=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{tolerance:.002,maxIntPointsPerSegment:100};return new Promise((function(t,o){var r,i=(r=Xn,new Worker(window.URL.createObjectURL(new Blob([`(${r.toString()})()`],{type:"text/javascript"}))));i.onmessage=function(e){e.data.error?o(e.data.error):t(e.data.points),i.terminate()},i.postMessage({points:e,options:n})}))},Jn={showRecticle:"showReticle",recticleColor:"reticleColor"},Qn=function(e){Object.keys(e).filter((function(e){return Jn[e]})).forEach((function(n){console.warn('regl-scatterplot: the "'.concat(n,'" property is deprecated. Please use "').concat(Jn[n],'" instead.')),e[Jn[n]]=e[n],delete e[n]}))},et=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=t.allowSegment,r=void 0!==o&&o,i=t.allowDensity,a=void 0!==i&&i,c=t.allowInherit,l=void 0!==c&&c;return Ge.has(e)?"valueZ":He.has(e)?"valueW":"segment"===e?r?"segment":n:"density"===e?a?"density":n:"inherit"===e&&l?"inherit":n},nt=function(e){switch(e){case"valueZ":return 2;case"valueW":return 3;default:return null}};e.checkSupport=Xe,e.createRegl=$e,e.createRenderer=En,e.createSpatialIndex=function(e,n){return yn(e).then((function(e){return G(e,{useWorker:n})})).then((function(e){return e.data}))},e.createTextureFromUrl=on,e.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.default({async:!e.syncEvents,caseInsensitive:!0}),t=new Float32Array(16),o=new Float32Array(16),i=[0,0];Qn(e);var a=e.renderer,c=e.backgroundColor,f=void 0===c?je:c,p=e.backgroundImage,h=void 0===p?null:p,m=e.canvas,x=void 0===m?document.createElement("canvas"):m,E=e.colorBy,P=void 0===E?De:E,A=e.deselectOnDblClick,C=void 0===A||A,I=e.deselectOnEscape,T=void 0===I||I,R=e.lassoColor,O=void 0===R?ue:R,L=e.lassoLineWidth,D=void 0===L?2:L,z=e.lassoMinDelay,F=void 0===z?10:z,N=e.lassoMinDist,_=void 0===N?3:N,V=e.lassoClearEvent,Z=void 0===V?de:V,U=e.lassoInitiator,q=void 0!==U&&U,Y=e.lassoInitiatorParentElement,X=void 0===Y?document.body:Y,Ge=e.lassoOnLongPress,He=void 0!==Ge&&Ge,Xe=e.lassoLongPressTime,$e=void 0===Xe?fe:Xe,rn=e.lassoLongPressAfterEffectTime,an=void 0===rn?ve:rn,cn=e.lassoLongPressEffectDelay,sn=void 0===cn?pe:cn,un=e.lassoLongPressRevertEffectTime,Pn=void 0===un?he:un,An=e.keyMap,Mn=void 0===An?Me:An,Cn=e.mouseMode,In=void 0===Cn?ne:Cn,Tn=e.showReticle,Rn=void 0!==Tn&&Tn,On=e.reticleColor,Ln=void 0===On?qe:On,Dn=e.pointColor,Bn=void 0===Dn?Be:Dn,zn=e.pointColorActive,kn=void 0===zn?ze:zn,jn=e.pointColorHover,Fn=void 0===jn?ke:jn,Nn=e.showPointConnections,_n=void 0!==Nn&&Nn,Wn=e.pointConnectionColor,Vn=void 0===Wn?Ne:Wn,Zn=e.pointConnectionColorActive,Un=void 0===Zn?_e:Zn,qn=e.pointConnectionColorHover,Gn=void 0===qn?We:qn,Hn=e.pointConnectionColorBy,Xn=void 0===Hn?Fe:Hn,Jn=e.pointConnectionOpacity,tt=void 0===Jn?null:Jn,ot=e.pointConnectionOpacityBy,rt=void 0===ot?Oe:ot,it=e.pointConnectionOpacityActive,at=void 0===it?.66:it,ct=e.pointConnectionSize,lt=void 0===ct?2:ct,st=e.pointConnectionSizeActive,ut=void 0===st?2:st,dt=e.pointConnectionSizeBy,ft=void 0===dt?Re:dt,vt=e.pointConnectionMaxIntPointsPerSegment,pt=void 0===vt?100:vt,ht=e.pointConnectionTolerance,mt=void 0===ht?.002:ht,yt=e.pointSize,gt=void 0===yt?6:yt,wt=e.pointSizeSelected,xt=void 0===wt?2:wt,bt=e.pointSizeMouseDetection,St=void 0===bt?"auto":bt,Et=e.pointOutlineWidth,Pt=void 0===Et?2:Et,At=e.opacity,Mt=void 0===At?H:At,Ct=e.opacityBy,It=void 0===Ct?Le:Ct,Tt=e.opacityByDensityFill,Rt=void 0===Tt?.15:Tt,Ot=e.opacityInactiveMax,Lt=void 0===Ot?1:Ot,Dt=e.opacityInactiveScale,Bt=void 0===Dt?1:Dt,zt=e.sizeBy,kt=void 0===zt?Te:zt,jt=e.height,Ft=void 0===jt?Ie:jt,Nt=e.width,_t=void 0===Nt?Ce:Nt,Wt=e.annotationLineColor,Vt=void 0===Wt?Ve:Wt,Zt=e.annotationLineWidth,Ut=void 0===Zt?1:Zt,qt=e.annotationHVLineLimit,Gt=void 0===qt?1e3:qt,Ht=_t===H?1:_t,Kt=Ft===H?1:Ft,Yt=e.performanceMode,Xt=void 0!==Yt&&Yt,$t=e.opacityByDensityDebounceTime,Jt=void 0===$t?25:$t,Qt=e.spatialIndexUseWorker,eo=void 0===Qt?undefined:Qt;a||(a=En({regl:e.regl,gamma:e.gamma})),f=pn(f,!0),O=pn(O,!0),Ln=pn(Ln,!0);var no,to,oo,ro,io,ao,co,lo,so,uo,fo,vo,po,ho,mo,yo,go,wo,xo=!1,bo=mn(f),So=!1,Eo=null,Po=[0,0],Ao=-1,Mo=[],Co=new Set,Io=new Set,To=!1,Ro=new Set,Oo=[],Lo=0,Do=0,Bo=!1,zo=[],ko=e.aspectRatio||1,jo=hn(Mn),Fo=!1,No=!0,_o=!1;Bn=dn(Bn)?d(Bn):[Bn],kn=dn(kn)?d(kn):[kn],Fn=dn(Fn)?d(Fn):[Fn],Bn=Bn.map((function(e){return pn(e,!0)})),kn=kn.map((function(e){return pn(e,!0)})),Fn=Fn.map((function(e){return pn(e,!0)})),Mt=!Array.isArray(Mt)&&Number.isNaN(+Mt)?Bn[0][3]:Mt,Mt=Qe(Mt,en,{minLength:1})?d(Mt):[Mt];var Wo,Vo,Zo,Uo,qo=1/(gt=Qe(gt,en,{minLength:1})?d(gt):[gt])[0];Vn="inherit"===Vn?d(Bn):(Vn=dn(Vn)?d(Vn):[Vn]).map((function(e){return pn(e,!0)})),Un="inherit"===Un?d(kn):(Un=dn(Un)?d(Un):[Un]).map((function(e){return pn(e,!0)})),Gn="inherit"===Gn?d(Fn):(Gn=dn(Gn)?d(Gn):[Gn]).map((function(e){return pn(e,!0)})),tt="inherit"===tt?d(Mt):Qe(tt,en,{minLength:1})?d(tt):[tt],lt="inherit"===lt?d(gt):Qe(lt,en,{minLength:1})?d(lt):[lt],P=et(P,De),It=et(It,Le,{allowDensity:!0}),kt=et(kt,Te),Xn=et(Xn,Fe,{allowSegment:!0,allowInherit:!0}),rt=et(rt,Oe,{allowSegment:!0}),ft=et(ft,Re,{allowSegment:!0});var Go,Ho,Ko,Yo,Xo,$o,Jo,Qo,er,nr,tr,or,rr=0,ir=0,ar=!1,cr=null,lr=Rn,sr=0,ur=0,dr=!1,fr=!1,vr=!1,pr=!1,hr=ie,mr=ie,yr=!1,gr=e.xScale||null,wr=e.yScale||null,xr=0,br=0,Sr=0,Er=0;gr&&(xr=gr.domain()[0],br=gr.domain()[1]-gr.domain()[0],gr.range([0,Ht])),wr&&(Sr=wr.domain()[0],Er=wr.domain()[1]-wr.domain()[0],wr.range([Kt,0]));var Pr=function(e){return e/Ht*2-1},Ar=function(e){return 1+e/Kt*-2},Mr=function(e,n){var o=[e,n,1,1];return S(o,o,g(t,w(t,ao,w(t,no.view,lo)))),o.slice(0,2)},Cr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=Mi(),t=(yo[1]-go[1])/x.height;return(ho*n+e)*t},Ir=function(){return To?Oo.filter((function(e,n){return Ro.has(n)})):Oo},Tr=function(e,n,t,o){var r=ro.range(e,n,t,o);return To?r.filter((function(e){return Ro.has(e)})):r},Rr=function(){var e=u([Pr(i[0]),Ar(i[1])],2),n=e[0],t=e[1],o=u(Mr(n,t),2),r=o[0],a=o[1],c=Cr(4),l=Tr(r-c,a-c,r+c,a+c),s=c,d=-1;return l.forEach((function(e){var n=u(Oo[e],2),t=n[0],o=n[1],i=Je(t,o,r,a);i<s&&(s=i,d=e)})),d},Or=function(e){var n,t,o,r,i,a=function(e){for(var n=1/0,t=-1/0,o=1/0,r=-1/0,i=0;i<e.length;i+=2)n=e[i]<n?e[i]:n,t=e[i]>t?e[i]:t,o=e[i+1]<o?e[i+1]:o,r=e[i+1]>r?e[i+1]:r;return[n,o,t,r]}(e);if(n=u(a,4),t=n[0],o=n[1],r=n[2],i=n[3],!(Number.isFinite(t)&&Number.isFinite(o)&&Number.isFinite(r)&&Number.isFinite(i)&&r-t>0&&i-o>0))return[];var c=Tr.apply(void 0,d(a)),l=[];return c.forEach((function(n){(function(e){for(var n,t,o,r,i=u(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),a=i[0],c=i[1],l=!1,s=0,d=e.length-2;s<e.length;s+=2)n=e[s],t=e[s+1],o=e[d],t>c!=(r=e[d+1])>c&&a<(o-n)*(c-t)/(r-t)+n&&(l=!l),d=s;return l})(e,Oo[n])&&l.push(n)})),l},Lr=function(){zo=[],to&&to.clear()},Dr=function(e){return e&&e.length>4},Br=function(e,n){if(!fo&&_n&&Dr(Oo[e[0]])){var t=0===n,o=1===n?function(e){return Io.add(e)}:k,r=Object.keys(e.reduce((function(e,n){var t=Oo[n];return e[Array.isArray(t[4])?t[4][0]:t[4]]=!0,e}),{})),i=so.getData().opacities;r.filter((function(e){return!Io.has(+e)})).forEach((function(e){var n=uo[e][0],r=uo[e][2],a=4*n+2*uo[e][3],c=a+2*r+4;void 0===i.__original__&&(i.__original__=i.slice());for(var l=a;l<c;l++)i[l]=t?i.__original__[l]:at;o(e)})),so.getBuffer().opacities.subdata(i,0)}},zr=function(e){return[e%rr/rr+ir,Math.floor(e/rr)/rr+ir]},kr=function(e){return To&&!Ro.has(e)},jr=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).preventEvent,t=void 0!==e&&e;Z===ce&&Lr(),Mo.length&&(t||n.publish("deselect"),Io.clear(),Br(Mo,0),Mo=[],Co.clear(),No=!0)},Fr=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.merge,r=void 0!==o&&o,i=t.preventEvent,a=void 0!==i&&i,c=Array.isArray(e)?e:[e],l=d(Mo);if(r){if(Mo=((e,n)=>{const t=[];return e.forEach((e=>{t[e]=!0})),n.forEach((e=>{t[e]=!0})),t.reduce(((e,n,t)=>(n&&e.push(t),e)),[])})(Mo,c),l.length===Mo.length)return void(No=!0)}else{if(Mo&&Mo.length&&Br(Mo,0),l.length>0&&0===c.length)return void jr({preventEvent:a});Mo=c}if(((e,n)=>{if(e===n)return!0;if(e.length!==n.length)return!1;const t=new Set(e),o=new Set(n);return t.size===o.size&&n.every((e=>t.has(e)))})(l,Mo))No=!0;else{var s=[];Co.clear(),Io.clear();for(var u=Mo.length-1;u>=0;u--){var f=Mo[u];f<0||f>=Lo||kr(f)?Mo.splice(u,1):(Co.add(f),s.push.apply(s,zr(f)))}Ho({usage:"dynamic",type:"float",data:s}),Br(Mo,1),a||n.publish("select",{points:Mo}),No=!0}},Nr=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.showReticleOnce,r=void 0!==o&&o,i=t.preventEvent,a=void 0!==i&&i,c=!1;if(!(To&&!Ro.has(e))&&e>=0&&e<Lo){c=!0;var l=or,s=e!==or;+l>=0&&s&&!Co.has(l)&&Br([l],0),or=e,Ko.subdata(zr(e)),Co.has(e)||Br([e],2),s&&!a&&n.publish("pointover",or)}else(c=+or>=0)&&(Co.has(or)||Br([or],0),a||n.publish("pointout",or)),or=void 0;c&&(No=!0,_o=r)},_r=function(e){var n=x.getBoundingClientRect();return i[0]=e.clientX-n.left,i[1]=e.clientY-n.top,[].concat(i)},Wr=Kn(x,{onStart:function(){no.config({isFixed:!0}),So=!0,Bo=!0,Lr(),Ao>=0&&(clearTimeout(Ao),Ao=-1),n.publish("lassoStart")},onDraw:function(e,t){zo=e,to.setPoints(t),n.publish("lassoExtend",{coordinates:e})},onEnd:function(e,t){var o=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).merge,r=void 0!==o&&o;no.config({isFixed:!1}),zo=d(e);var i=Or(t);Fr(i,{merge:r}),n.publish("lassoEnd",{coordinates:zo}),Z===le&&Lr()},enableInitiator:q,initiatorParentElement:X,pointNorm:function(e){var n=u(e,2),t=n[0],o=n[1];return Mr(Pr(t),Ar(o))}}),Vr=function(e,n){switch(jo[n]){case xe:return e.altKey;case be:return e.metaKey;case Se:return e.ctrlKey;case Ee:return e.metaKey;case Pe:return e.shiftKey;default:return!1}},Zr=function(e){fr&&1===e.buttons&&(So=!0,Eo=performance.now(),Po=_r(e),!(Bo=In===J||Vr(e,me))&&He&&(Wr.showLongPressIndicator(e.clientX,e.clientY,{time:$e,extraTime:an,delay:sn}),Ao=setTimeout((function(){Ao=-1,Bo=!0}),$e)))},Ur=function(e){fr&&(So=!1,Ao>=0&&(clearTimeout(Ao),Ao=-1),Bo&&(e.preventDefault(),Bo=!1,Wr.end({merge:Vr(e,ge)})),He&&Wr.hideLongPressIndicator({time:Pn}))},qr=function(e){if(fr){e.preventDefault();var n=_r(e);if(!(Je.apply(void 0,d(n).concat(d(Po)))>=_)){var t=performance.now()-Eo;if(!q||t<500){var o=Rr();o>=0?(Mo.length&&Z===ce&&Lr(),Fr([o],{merge:Vr(e,ge)})):mo||(mo=setTimeout((function(){mo=null,Wr.showInitiator(e)}),200))}}}},Gr=function(e){Wr.hideInitiator(),mo&&(clearTimeout(mo),mo=null),C&&(e.preventDefault(),jr())},Hr=function(e){if(pr||(yr=function(e){return document.elementsFromPoint(e.clientX,e.clientY).some((function(e){return e===x}))}(e),pr=!0),fr&&(yr||So)){var n=_r(e),t=Je.apply(void 0,d(n).concat(d(Po)))>=_;yr&&!Bo&&Nr(Rr()),Bo?(e.preventDefault(),Wr.extend(e,!0)):So&&He&&t&&Wr.hideLongPressIndicator({time:Pn}),Ao>=0&&t&&(clearTimeout(Ao),Ao=-1),So&&(No=!0)}},Kr=function(){or=void 0,yr=!1,pr=!1,fr&&(+or>=0&&!Co.has(or)&&Br([or],0),Ur(),No=!0)},Yr=function(){var e=Math.max(gt.length,Mt.length);ur=Math.max(2,Math.ceil(Math.sqrt(e)));for(var n=new Float32Array(4*Math.pow(ur,2)),t=0;t<e;t++){n[4*t]=gt[t]||0,n[4*t+1]=Math.min(1,Mt[t]||0);var o=Number((kn[t]||kn[0])[3]);n[4*t+2]=Math.min(1,Number.isNaN(o)?1:o);var r=Number((Fn[t]||Fn[0])[3]);n[4*t+3]=Math.min(1,Number.isNaN(r)?1:r)}return a.regl.texture({data:n,shape:[ur,ur,4],type:"float"})},Xr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Bn,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:kn,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Fn,o=e.length,r=n.length,i=t.length,a=[];if(o===r&&r===i)for(var c=0;c<o;c++)a.push(e[c],n[c],t[c],f);else for(var l=0;l<o;l++){var s=[e[l][0],e[l][1],e[l][2],1],u=P===De?n[0]:s,d=P===De?t[0]:s;a.push(e[l],u,d,f)}return a},$r=function(){var e=Xr(),n=e.length;sr=Math.max(2,Math.ceil(Math.sqrt(n)));var t=new Float32Array(4*Math.pow(sr,2));return e.forEach((function(e,n){t[4*n]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]})),a.regl.texture({data:t,shape:[sr,sr,4],type:"float"})},Jr=function(){ao=b([],[1/(io=Ht/Kt),1,1]),co=b([],[1/io,1,1]),lo=b([],[ko,1,1])},Qr=function(e,n){return function(t){if(t&&t.length){var o=d(e()),r=dn(t)?t:[t];r=r.map((function(e){return pn(e,!0)})),nr&&nr.destroy();try{n(r),nr=$r()}catch(e){console.error("Invalid colors. Switching back to default colors."),n(o),nr=$r()}}}},ei=Qr((function(){return Bn}),(function(e){Bn=e})),ni=Qr((function(){return kn}),(function(e){kn=e})),ti=Qr((function(){return Fn}),(function(e){Fn=e})),oi=function(){if(gr||wr){var e,n,t,o,r,i,a=u((e=Mr(-1,-1),n=Mr(1,1),t=(e[0]+1)/2,o=(n[0]+1)/2,r=(e[1]+1)/2,i=(n[1]+1)/2,[[xr+t*br,xr+o*br],[Sr+r*Er,Sr+i*Er]]),2),c=a[0],l=a[1];gr&&gr.domain(c),wr&&wr.domain(l)}},ri=function(e){Kt=Math.max(1,e),x.height=Math.floor(Kt*window.devicePixelRatio),wr&&(wr.range([Kt,0]),oi())},ii=function(){ho=St,St===H&&(ho=Array.isArray(gt)?gt.reduce(((e,n)=>n>e?n:e),-1/0):gt)},ai=function(e){Ht=Math.max(1,e),x.width=Math.floor(Ht*window.devicePixelRatio),gr&&(gr.range([0,Ht]),oi())},ci=function(e){switch(e){case"valueZ":return hr;case"valueW":return mr;default:return null}},li=function(e,n){return e===re?function(e){return Math.round(e*(n.length-1))}:k},si=function(){return[x.width,x.height]},ui=function(){return nr},di=function(){return sr},fi=function(){return.5/sr},vi=function(){return window.devicePixelRatio},pi=function(){return Ho},hi=function(){return tr},mi=function(){return ur},yi=function(){return.5/ur},gi=function(){return 0},wi=function(){return Zo||Wo},xi=function(){return rr},bi=function(){return.5/rr},Si=function(){return co},Ei=function(){return no.view},Pi=function(){return lo},Ai=function(){return w(o,co,w(o,no.view,lo))},Mi=function(){return no.scaling[0]>1?Math.asinh(fn(1,no.scaling[0]))/Math.asinh(1)*window.devicePixelRatio:fn(qo,no.scaling[0])*window.devicePixelRatio},Ci=function(){return Mo.length},Ii=function(){return Ci()>0?Lt:1},Ti=function(){return Ci()>0?Bt:1},Ri=function(){return+("valueZ"===P)},Oi=function(){return+("valueW"===P)},Li=function(){return+("valueZ"===It)},Di=function(){return+("valueW"===It)},Bi=function(){return+("density"===It)},zi=function(){return+("valueZ"===kt)},ki=function(){return+("valueW"===kt)},ji=function(){return"valueZ"===P?hr===re?Bn.length-1:1:mr===re?Bn.length-1:1},Fi=function(){return"valueZ"===It?hr===re?Mt.length-1:1:mr===re?Mt.length-1:1},Ni=function(){return"valueZ"===kt?hr===re?gt.length-1:1:mr===re?gt.length-1:1},_i=function(e){if("density"!==It)return 1;var n=Mi(),t=gt[0]*n,o=2/(2/no.view[0])*(2/(2/no.view[5])),r=e.viewportHeight,i=e.viewportWidth,a=Rt*i*r/(Do*t*t)*vn(1,o);a*=Xt?1:1/(.25*Math.PI);var c=fn(1,t)+.5;return a*=Math.pow(t/c,2),vn(1,fn(0,a))},Wi=a.regl({framebuffer:function(){return Uo},vert:"precision highp float;\n\nattribute vec2 position;\nvarying vec2 particleTextureIndex;\n\nvoid main() {\n // map normalized device coords to texture coords\n particleTextureIndex = 0.5 * (1.0 + position);\n\n gl_Position = vec4(position, 0, 1);\n}",frag:"precision highp float;\n\nuniform sampler2D startStateTex;\nuniform sampler2D endStateTex;\nuniform float t;\n\nvarying vec2 particleTextureIndex;\n\nvoid main() {\n // Interpolate x, y, and value\n vec3 start = texture2D(startStateTex, particleTextureIndex).xyw;\n vec3 end = texture2D(endStateTex, particleTextureIndex).xyw;\n vec3 curr = start * (1.0 - t) + end * t;\n\n // The category cannot be interpolated\n float endCategory = texture2D(endStateTex, particleTextureIndex).z;\n\n gl_FragColor = vec4(curr.xy, endCategory, curr.z);\n}",attributes:{position:[-4,0,4,4,4,-4]},uniforms:{startStateTex:function(){return Vo},endStateTex:function(){return Wo},t:function(e,n){return n.t}},count:3}),Vi=function(e,n,t){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Ii,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:Ti;return a.regl({frag:Xt?"precision highp float;\n\nvarying vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n":"\nprecision highp float;\n\nvarying vec4 color;\nvarying float finalPointSize;\n\nfloat linearstep(float edge0, float edge1, float x) {\n return clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n}\n\nvoid main() {\n vec2 c = gl_PointCoord * 2.0 - 1.0;\n float sdf = length(c) * finalPointSize;\n float alpha = linearstep(finalPointSize + 0.5, finalPointSize - 0.5, sdf);\n\n gl_FragColor = vec4(color.rgb, alpha * color.a);\n}\n",vert:Yn(o),blend:{enable:!Xt,func:{srcRGB:"src alpha",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"}},depth:{enable:!1},attributes:{stateIndex:{buffer:t,size:2}},uniforms:{resolution:si,modelViewProjection:Ai,devicePixelRatio:vi,pointScale:Mi,encodingTex:hi,encodingTexRes:mi,encodingTexEps:yi,pointOpacityMax:r,pointOpacityScale:i,pointSizeExtra:e,globalState:o,colorTex:ui,colorTexRes:di,colorTexEps:fi,stateTex:wi,stateTexRes:xi,stateTexEps:bi,isColoredByZ:Ri,isColoredByW:Oi,isOpacityByZ:Li,isOpacityByW:Di,isOpacityByDensity:Bi,isSizedByZ:zi,isSizedByW:ki,colorMultiplicator:ji,opacityMultiplicator:Fi,opacityDensity:_i,sizeMultiplicator:Ni,numColorStates:4},count:n,primitive:"points"})},Zi=Vi(gi,(function(){return To?Ro.size:Lo}),(function(){return Go})),Ui=Vi(gi,(function(){return 1}),(function(){return Ko}),2,(function(){return 1}),(function(){return 1})),qi=Vi((function(){return(xt+2*Pt)*window.devicePixelRatio}),Ci,pi,1,(function(){return 1}),(function(){return 1})),Gi=Vi((function(){return(xt+Pt)*window.devicePixelRatio}),Ci,pi,3,(function(){return 1}),(function(){return 1})),Hi=Vi((function(){return xt*window.devicePixelRatio}),Ci,pi,1,(function(){return 1}),(function(){return 1})),Ki=a.regl({frag:"\nprecision mediump float;\n\nuniform sampler2D texture;\n\nvarying vec2 uv;\n\nvoid main () {\n gl_FragColor = texture2D(texture, uv);\n}\n",vert:"\nprecision mediump float;\n\nuniform mat4 modelViewProjection;\n\nattribute vec2 position;\n\nvarying vec2 uv;\n\nvoid main () {\n uv = position;\n gl_Position = modelViewProjection * vec4(-1.0 + 2.0 * uv.x, 1.0 - 2.0 * uv.y, 0, 1);\n}\n",attributes:{position:[0,1,0,0,1,0,0,1,1,1,1,0]},uniforms:{modelViewProjection:Ai,texture:function(){return h}},count:6}),Yi=a.regl({vert:"\n precision mediump float;\n uniform mat4 modelViewProjection;\n attribute vec2 position;\n void main () {\n gl_Position = modelViewProjection * vec4(position, 0, 1);\n }",frag:"\n precision mediump float;\n uniform vec4 color;\n void main () {\n gl_FragColor = vec4(color.rgb, 0.2);\n }",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"}},attributes:{position:function(){return zo}},uniforms:{modelViewProjection:Ai,color:function(){return O}},elements:function(){return Array.from({length:zo.length-2},(function(e,n){return[0,n+1,n+2]}))}}),Xi=function(e){for(var n=new Float32Array(2*e),t=0,o=0;o<e;++o){var r=zr(o);n[t]=r[0],n[t+1]=r[1],t+=2}return n},$i=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.length;rr=Math.max(2,Math.ceil(Math.sqrt(t))),ir=.5/rr;for(var o=new Float32Array(4*Math.pow(rr,2)),r=!0,i=!0,c=0,l=0,s=0,u=0;u<t;++u)o[c=4*u]=e[u][0],o[c+1]=e[u][1],l=e[u][2]||0,s=e[u][3]||0,o[c+2]=l,o[c+3]=s,r&&(r=Number.isInteger(l)),i&&(i=Number.isInteger(s));return hr=n.z&&ae.includes(n.z)?n.z:r?ie:re,mr=n.w&&ae.includes(n.w)?n.w:i?ie:re,a.regl.texture({data:o,shape:[rr,rr,4],type:"float"})},Ji=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(t){fr=!1;var o=(null==n?void 0:n.preventFilterReset)&&e.length===Lo;Lo=e.length,Do=Lo,Wo&&Wo.destroy(),Wo=$i(e,{z:n.zDataType,w:n.wDataType}),o||Go({usage:"static",type:"float",data:Xi(Lo)}),G(n.spatialIndex||e,{useWorker:eo}).then((function(n){ro=n,Oo=e,fr=!0})).then(t)}))},Qi=function(e,n){Yo=no.target,Xo=e,$o=no.distance[0],Jo=n},ea=function(e){var n="inherit"===Xn?P:Xn;if("segment"===n){var t=Vn.length-1;return t<1?[]:e.reduce((function(e,n,o){for(var r=0,i=[],a=2;a<n.length;a+=2){var c=Math.sqrt(Math.pow(n[a-2]-n[a],2)+Math.pow(n[a-1]-n[a+1],2));i.push(c),r+=c}e[o]=[0];for(var l=0,s=0;s<n.length/2-1;s++)l+=i[s],e[o].push(4*Math.floor(l/r*t));return e}),[])}if(n){var o=nt(n),r=li(ci(n),"inherit"===Xn?Bn:Vn);return uo.reduce((function(e,n){var t=u(n,2),i=t[0],a=t[1];return e[i]=4*r(a[o]),e}),[])}return Array(uo.length).fill(0)},na=function(){var e="inherit"===rt?It:rt;if("segment"===e){var n=tt.length-1;return n<1?[]:uo.reduce((function(e,t){var o=u(t,3),r=o[0];o[1];var i=o[2];return e[r]=j(i,(function(e){return tt[Math.floor(e/(i-1)*n)]})),e}),[])}if(e){var t=nt(e),o="inherit"===rt?Mt:tt,r=li(ci(e),o);return uo.reduce((function(e,n){var i=u(n,2),a=i[0],c=i[1];return e[a]=o[r(c[t])],e}),[])}},ta=function(){var e="inherit"===ft?kt:ft;if("segment"===e){var n=lt.length-1;return n<1?[]:uo.reduce((function(e,t){var o=u(t,3),r=o[0];o[1];var i=o[2];return e[r]=j(i,(function(e){return lt[Math.floor(e/(i-1)*n)]})),e}),[])}if(e){var t=nt(e),o="inherit"===ft?gt:lt,r=li(ci(e),o);return uo.reduce((function(e,n){var i=u(n,2),a=i[0],c=i[1];return e[a]=o[r(c[t])],e}),[])}},oa=function(e){return new Promise((function(n){so.setPoints([]),e&&e.length?(fo=!0,$n(e,{maxIntPointsPerSegment:pt,tolerance:mt}).then((function(e){!function(e){uo=[];var n=0;Object.keys(e).forEach((function(t,o){uo[t]=[o,e[t].reference,e[t].length/2,n],n+=e[t].length/2}))}(e);var t=Object.values(e);so.setPoints(1===t.length?t[0]:t,{colorIndices:ea(t),opacities:na(),widths:ta()}),fo=!1,n()}))):n()}))},ra=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).preventEvent,o=void 0!==t&&t,r=Array.isArray(e)?e:[e];To=!0,Ro.clear();for(var i=[],a=[],c=r.length-1;c>=0;c--){var l=r[c];l<0||l>=Lo?r.splice(c,1):(Ro.add(l),i.push.apply(i,zr(l)),Co.has(l)&&a.push(l))}return Go.subdata(i),Fr(a,{preventEvent:o}),Ro.has(or)||Nr(-1,{preventEvent:o}),new Promise((function(e){var t=function(){n.subscribe("draw",(function(){o||n.publish("filter",{points:r}),e()}),1),No=!0};_n||Dr(Oo[0])?oa(Ir()).then((function(){o||n.publish("pointConnectionsDraw"),Fr(a,{preventEvent:o}),t()})):t()}))},ia=function(){return Tr(go[0],go[1],yo[0],yo[1])},aa=W((function(){Do=ia().length}),Jt),ca=function(){return Boolean(Vo&&Zo)},la=function(){return Boolean(void 0!==Yo&&void 0!==Xo&&void 0!==$o&&void 0!==Jo)},sa=function(e,n){cr||(cr=performance.now());var t,o,r,i=performance.now()-cr,a=(t=n(i/e),o=0,r=1,Math.min(r,Math.max(o,t)));return ca()&&Wi({t:a}),la()&&function(e){var n=u(Yo,2),t=n[0],o=n[1],r=u(Xo,2),i=1-e,a=t*i+r[0]*e,c=o*i+r[1]*e,l=$o*i+Jo*e;no.lookAt([a,c],l)}(a),i<e},ua=function(){ar=!1,cr=null,Qo=void 0,er=void 0,Rn=lr,Vo&&(Vo.destroy(),Vo=void 0),Zo&&(Zo.destroy(),Zo=void 0),Yo=void 0,Xo=void 0,$o=void 0,Jo=void 0,n.publish("transitionEnd")},da=function(e){var t=e.duration,o=void 0===t?500:t,r=e.easing,i=void 0===r?oe:r;ar&&n.publish("transitionEnd"),ar=!0,cr=null,Qo=o,er=ln(i)?te[i]||oe:i,lr=Rn,Rn=!1,n.publish("transitionStart")},fa=function(e){return xo?Promise.reject(new Error("The instance was already destroyed")):(vr=!1,0===e.length?new Promise((function(e){oo.clear(),n.subscribe("draw",e,1),vr=!0,No=!0})):new Promise((function(t){var o,r=[],i=new Map,a=[],c=[],l=-1,s=function(e){c.push(e.lineWidth||Ut);var n=pn(e.lineColor||Vt,!0),t="[".concat(n.join(","),"]");if(i.has(t)){var o=i.get(t).idx;a.push(o)}else{var r=++l;i.set(t,{idx:r,color:n}),a.push(r)}},u=function(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=v(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw i}}}}(e);try{for(u.s();!(o=u.n()).done;){var d=o.value;gn(d)?(r.push([-Gt,d.y,Gt,d.y]),s(d)):wn(d)?(r.push([d.x,-Gt,d.x,Gt]),s(d)):bn(d)?(r.push([d.x1,d.y1,d.x2,d.y1,d.x2,d.y2,d.x1,d.y2,d.x1,d.y1]),s(d)):xn(d)?(r.push([d.x,d.y,d.x+d.width,d.y,d.x+d.width,d.y+d.height,d.x,d.y+d.height,d.x,d.y]),s(d)):Sn(d)&&(r.push(d.vertices.flatMap(k)),s(d))}}catch(e){u.e(e)}finally{u.f()}oo.setStyle({color:Array.from(i.values()).sort((function(e,n){return e.idx>n.idx?1:-1})).map((function(e){return e.color}))}),oo.setPoints(r,{colorIndices:a,widths:c}),n.subscribe("draw",t,1),vr=!0,No=!0})))},va=function(e){return function(){var t=e.apply(void 0,arguments);return No=!0,new Promise((function(e){n.subscribe("draw",(function(){return e(t)}),1)}))}},pa=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(o){var r=S([],[e.x+e.width/2,e.y+e.height/2,0,0],lo).slice(0,2),i=2*Math.atan(1),a=io/ko,c=e.height*a>=e.width?e.height/2/Math.tan(i/2):e.width/2/Math.tan(i/2)/a;t.transition?(no.config({isFixed:!0}),Qi(r,c),n.subscribe("transitionEnd",(function(){o(),no.config({isFixed:!1})}),1),da({duration:t.transitionDuration,easing:t.transitionEasing})):(no.lookAt(r,c),n.subscribe("draw",o,1),No=!0)}))},ha=function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(r){o.transition?(no.config({isFixed:!0}),Qi(e,t),n.subscribe("transitionEnd",(function(){r(),no.config({isFixed:!1})}),1),da({duration:o.transitionDuration,easing:o.transitionEasing})):(no.lookAt(e,t),n.subscribe("draw",r,1),No=!0)}))},ma=function(){so.setStyle({color:Xr(Vn,Un,Gn),opacity:null===tt?null:tt[0],width:lt[0]})},ya=function(){var e=Math.round(bo)>.5?0:255;Wr.initiator.style.border="1px dashed rgba(".concat(e,", ").concat(e,", ").concat(e,", 0.33)"),Wr.initiator.style.background="rgba(".concat(e,", ").concat(e,", ").concat(e,", 0.1)")},ga=function(){var e=Math.round(bo)>.5?0:255;Wr.longPressIndicator.style.color="rgb(".concat(e,", ").concat(e,", ").concat(e,")"),Wr.longPressIndicator.dataset.color="rgb(".concat(e,", ").concat(e,", ").concat(e,")");var n=O.map((function(e){return Math.round(255*e)}));Wr.longPressIndicator.dataset.activeColor="rgb(".concat(n[0],", ").concat(n[1],", ").concat(n[2],")")},wa=function(e){e&&no.setView(e)},xa=function(e,n){return function(t){if("inherit"===t)e(d(n()));else{var o=dn(t)?t:[t];e(o.map((function(e){return pn(e,!0)})))}ma()}},ba=xa((function(e){Vn=e}),(function(){return Bn})),Sa=xa((function(e){Un=e}),(function(){return kn})),Ea=xa((function(e){Gn=e}),(function(){return Fn})),Pa=function(){var e,t,o,r,i,c,l,s,v,p,m,y,g,w,b,S,E,A,M,I,R,L,B,z,k,j,N,W,V,U,G,K,Y,J,ne,te,oe,re,ie,ae,ce,le,ue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Qn(ue),void 0===ue.backgroundColor&&void 0===ue.background||(e=ue.backgroundColor||ue.background)&&(f=pn(e,!0),bo=mn(f),ya(),ga()),void 0!==ue.backgroundImage&&((t=ue.backgroundImage)?ln(t)?on(a.regl,t).then((function(e){h=e,No=!0,n.publish("backgroundImageReady")})).catch((function(){console.error("Count not create texture from ".concat(t)),h=null})):h="texture2d"===t._reglType?t:null:h=null),void 0!==ue.cameraTarget&&(o=ue.cameraTarget)&&no.lookAt(o,no.distance[0],no.rotation),void 0!==ue.cameraDistance&&(r=ue.cameraDistance)>0&&no.lookAt(no.target,r,no.rotation),void 0!==ue.cameraRotation&&null!==(i=ue.cameraRotation)&&no.lookAt(no.target,no.distance[0],i),void 0!==ue.cameraView&&wa(ue.cameraView),void 0!==ue.colorBy&&(c=ue.colorBy,P=et(c,De)),void 0!==ue.pointColor&&ei(ue.pointColor),void 0!==ue.pointColorActive&&ni(ue.pointColorActive),void 0!==ue.pointColorHover&&ti(ue.pointColorHover),void 0!==ue.pointSize&&(l=ue.pointSize,Qe(l,en,{minLength:1})&&(gt=d(l)),nn(+l)&&(gt=[+l]),qo=1/gt[0],tr=Yr(),ii()),void 0!==ue.pointSizeSelected&&(!+(s=ue.pointSizeSelected)||+s<0||(xt=+s)),void 0!==ue.pointSizeMouseDetection&&(v=ue.pointSizeMouseDetection,St=v,ii()),void 0!==ue.sizeBy&&function(e){kt=et(e,Te)}(ue.sizeBy),void 0!==ue.opacity&&(p=ue.opacity,Qe(p,en,{minLength:1})&&(Mt=d(p)),nn(+p)&&(Mt=[+p]),tr=Yr()),void 0!==ue.showPointConnections&&(m=ue.showPointConnections,(_n=!!m)?fr&&Dr(Oo[0])&&oa(Ir()).then((function(){n.publish("pointConnectionsDraw"),No=!0})):oa()),void 0!==ue.pointConnectionColor&&ba(ue.pointConnectionColor),void 0!==ue.pointConnectionColorActive&&Sa(ue.pointConnectionColorActive),void 0!==ue.pointConnectionColorHover&&Ea(ue.pointConnectionColorHover),void 0!==ue.pointConnectionColorBy&&function(e){Xn=et(e,Fe,{allowSegment:!0,allowInherit:!0})}(ue.pointConnectionColorBy),void 0!==ue.pointConnectionOpacityBy&&function(e){rt=et(e,Oe,{allowSegment:!0})}(ue.pointConnectionOpacityBy),void 0!==ue.pointConnectionOpacity&&function(e){Qe(e,en,{minLength:1})&&(tt=d(e)),nn(+e)&&(tt=[+e]),Vn=Vn.map((function(e){return e[3]=Number.isNaN(+tt[0])?e[3]:+tt[0],e})),ma()}(ue.pointConnectionOpacity),void 0!==ue.pointConnectionOpacityActive&&function(e){!Number.isNaN(+e)&&+e&&(at=+e)}(ue.pointConnectionOpacityActive),void 0!==ue.pointConnectionSize&&(y=ue.pointConnectionSize,Qe(y,en,{minLength:1})&&(lt=d(y)),nn(+y)&&(lt=[+y]),ma()),void 0!==ue.pointConnectionSizeActive&&(g=ue.pointConnectionSizeActive,!Number.isNaN(+g)&&+g&&(ut=Math.max(0,g))),void 0!==ue.pointConnectionSizeBy&&function(e){ft=et(e,Re,{allowSegment:!0})}(ue.pointConnectionSizeBy),void 0!==ue.pointConnectionMaxIntPointsPerSegment&&(w=ue.pointConnectionMaxIntPointsPerSegment,pt=Math.max(0,w)),void 0!==ue.pointConnectionTolerance&&(b=ue.pointConnectionTolerance,mt=Math.max(0,b)),void 0!==ue.opacityBy&&function(e){It=et(e,Le,{allowDensity:!0})}(ue.opacityBy),void 0!==ue.lassoColor&&function(e){if(e){O=pn(e,!0),to.setStyle({color:O});var n=O.map((function(e){return Math.round(255*e)}));Wr.longPressIndicator.dataset.activeColor="rgb(".concat(n[0],", ").concat(n[1],", ").concat(n[2],")")}}(ue.lassoColor),void 0!==ue.lassoLineWidth&&(S=ue.lassoLineWidth,Number.isNaN(+S)||+S<1||(D=+S,to.setStyle({width:D}))),void 0!==ue.lassoMinDelay&&+(E=ue.lassoMinDelay)&&(F=+E,Wr.set({minDelay:F})),void 0!==ue.lassoMinDist&&+(A=ue.lassoMinDist)&&(_=+A,Wr.set({minDist:_})),void 0!==ue.lassoClearEvent&&(M=ue.lassoClearEvent,Z=tn(se,Z)(M)),void 0!==ue.lassoInitiator&&(I=ue.lassoInitiator,q=Boolean(I),Wr.set({enableInitiator:q})),void 0!==ue.lassoInitiatorParentElement&&(R=ue.lassoInitiatorParentElement,X=R,Wr.set({startInitiatorParentElement:X})),void 0!==ue.lassoOnLongPress&&(L=ue.lassoOnLongPress,He=Boolean(L)),void 0!==ue.lassoLongPressTime&&(B=ue.lassoLongPressTime,$e=Number(B)),void 0!==ue.lassoLongPressAfterEffectTime&&(z=ue.lassoLongPressAfterEffectTime,an=Number(z)),void 0!==ue.lassoLongPressEffectDelay&&(k=ue.lassoLongPressEffectDelay,sn=Number(k)),void 0!==ue.lassoLongPressRevertEffectTime&&function(e){Pn=Number(e)}(ue.lassoLongPressRevertEffectTime),void 0!==ue.keyMap&&(j=ue.keyMap,Mn=Object.entries(j).reduce((function(e,n){var t=u(n,2),o=t[0],r=t[1];return Ae.includes(o)&&we.includes(r)&&(e[o]=r),e}),{}),(jo=hn(Mn))[ye]?no.config({isRotate:!0,mouseDownMoveModKey:jo[ye]}):no.config({isRotate:!1})),void 0!==ue.mouseMode&&(N=ue.mouseMode,In=tn(ee,$)(N),no.config({defaultMouseDownMoveAction:In===Q?"rotate":"pan"})),void 0!==ue.showReticle&&null!==(W=ue.showReticle)&&(Rn=W),void 0!==ue.reticleColor&&(V=ue.reticleColor)&&(Ln=pn(V,!0),vo.setStyle({color:Ln}),po.setStyle({color:Ln})),void 0!==ue.pointOutlineWidth&&(!+(U=ue.pointOutlineWidth)||+U<0||(Pt=+U)),void 0!==ue.height&&function(e){if(e===H)return Ft=e,x.style.height="100%",void window.requestAnimationFrame((function(){x&&ri(x.getBoundingClientRect().height)}));!+e||+e<=0||(ri(Ft=+e),x.style.height="".concat(Ft,"px"))}(ue.height),void 0!==ue.width&&function(e){if(e===H)return _t=e,x.style.width="100%",void window.requestAnimationFrame((function(){x&&ai(x.getBoundingClientRect().width)}));!+e||+e<=0||(ai(_t=+e),x.style.width="".concat(Ht,"px"))}(ue.width),void 0!==ue.aspectRatio&&(+(G=ue.aspectRatio)<=0||(ko=G)),void 0!==ue.xScale&&(K=ue.xScale)&&(gr=K,xr=K.domain()[0],br=K?K.domain()[1]-K.domain()[0]:0,gr.range([0,Ht]),oi()),void 0!==ue.yScale&&(Y=ue.yScale)&&(Sr=(wr=Y).domain()[0],Er=wr?wr.domain()[1]-wr.domain()[0]:0,wr.range([Kt,0]),oi()),void 0!==ue.deselectOnDblClick&&(J=ue.deselectOnDblClick,C=!!J),void 0!==ue.deselectOnEscape&&(ne=ue.deselectOnEscape,T=!!ne),void 0!==ue.opacityByDensityFill&&(te=ue.opacityByDensityFill,Rt=+te),void 0!==ue.opacityInactiveMax&&(oe=ue.opacityInactiveMax,Lt=+oe),void 0!==ue.opacityInactiveScale&&(re=ue.opacityInactiveScale,Bt=+re),void 0!==ue.gamma&&(ie=ue.gamma,a.gamma=ie),void 0!==ue.annotationLineColor&&(ae=ue.annotationLineColor,Vt=pn(ae)),void 0!==ue.annotationLineWidth&&(ce=ue.annotationLineWidth,Ut=+ce),void 0!==ue.annotationHVLineLimit&&(le=ue.annotationHVLineLimit,Gt=+le),new Promise((function(e){window.requestAnimationFrame((function(){x&&(Jr(),no.refresh(),a.refresh(),No=!0,e())}))}))},Aa=function(){no||(no=M(x,{isPanInverted:[!1,!0]})),e.cameraView?no.setView(y(e.cameraView)):e.cameraTarget||e.cameraDistance||e.cameraRotation?no.lookAt(d(e.cameraTarget||Ze),e.cameraDistance||1,e.cameraRotation||0):no.setView(y(Ue)),yo=Mr(1,1),go=Mr(-1,-1)},Ma=function(e){if("Escape"===e.key)T&&jr()},Ca=function(){yr=!0,pr=!0},Ia=function(){Nr(),yr=!1,pr=!0,No=!0},Ta=function(){No=!0},Ra=function(){Ji([]),so.clear()},Oa=function(){fa([])},La=function(){no.refresh();var e=_t===H,n=Ft===H;if(e||n){var t=x.getBoundingClientRect(),o=t.width,r=t.height;e&&ai(o),n&&ri(r),Jr(),No=!0}},Da=a.onFrame((function(){if(dr=no.tick(),(fr||vr)&&(No||ar)){ar&&!sa(Qo,er)&&ua(),dr&&(yo=Mr(1,1),go=Mr(-1,-1),"density"===It&&aa()),a.render((function(){!function(e,n){co[0]=e/io,co[5]=n}(x.width/a.canvas.width,x.height/a.canvas.height),h&&h._reglType&&Ki(),zo.length>2&&Yi(),ar||so.draw({projection:Si(),model:Pi(),view:Ei()}),fr&&Zi(),So||!Rn&&!_o||function(){if(or>=0){var e=u(Oo[or].slice(0,2),2),n=[e[0],e[1],0,1];w(t,co,w(t,no.view,lo)),S(n,n,t),vo.setPoints([-1,n[1],1,n[1]]),po.setPoints([n[0],1,n[0],-1]),vo.draw(),po.draw(),Vi((function(){return(xt+2*Pt)*window.devicePixelRatio}),(function(){return 1}),Ko,1)(),Vi((function(){return(xt+Pt)*window.devicePixelRatio}),(function(){return 1}),Ko,3)()}}(),or>=0&&Ui(),Mo.length&&(qi(),Gi(),Hi()),oo.draw({projection:Si(),model:Pi(),view:Ei()}),to.draw({projection:Si(),model:Pi(),view:Ei()})}),x);var e={view:no.view,camera:no,xScale:gr,yScale:wr};dr&&(oi(),Fo?Fo=!1:n.publish("view",e)),No=!1,_o=!1,n.publish("drawing",e,{async:!1}),n.publish("draw",e)}}));return function(){Jr(),Aa(),oi(),to=B(a.regl,{color:O,width:D,is2d:!0}),so=B(a.regl,{color:Xr(Vn,Un,Gn),opacity:null===tt?null:tt[0],width:lt[0],widthActive:ut,is2d:!0}),vo=B(a.regl,{color:Ln,width:1,is2d:!0}),po=B(a.regl,{color:Ln,width:1,is2d:!0}),oo=B(a.regl,{color:Vt,width:Ut,is2d:!0}),ii(),x.addEventListener("wheel",Ta),Go=a.regl.buffer(),Ho=a.regl.buffer(),Ko=a.regl.buffer({usage:"dynamic",type:"float",length:2*K}),nr=$r(),tr=Yr();var e=Pa({backgroundImage:h,width:_t,height:Ft,keyMap:Mn});ya(),ga(),window.addEventListener("keyup",Ma,!1),window.addEventListener("blur",Kr,!1),window.addEventListener("mouseup",Ur,!1),window.addEventListener("mousemove",Hr,!1),x.addEventListener("mousedown",Zr,!1),x.addEventListener("mouseenter",Ca,!1),x.addEventListener("mouseleave",Ia,!1),x.addEventListener("click",qr,!1),x.addEventListener("dblclick",Gr,!1),"ResizeObserver"in window?(wo=new ResizeObserver(La)).observe(x):(window.addEventListener("resize",La),window.addEventListener("orientationchange",La)),e.then((function(){n.publish("init")}))}(),{get isSupported(){return a.isSupported},clear:va((function(){Ra(),Oa()})),clearPoints:va(Ra),clearPointConnections:va((function(){so.clear()})),clearAnnotations:va(Oa),createTextureFromUrl:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ke;return on(a.regl,e,n)},deselect:jr,destroy:function(){fr=!1,vr=!1,xo=!0,Da(),window.removeEventListener("keyup",Ma,!1),window.removeEventListener("blur",Kr,!1),window.removeEventListener("mouseup",Ur,!1),window.removeEventListener("mousemove",Hr,!1),x.removeEventListener("mousedown",Zr,!1),x.removeEventListener("mouseenter",Ca,!1),x.removeEventListener("mouseleave",Ia,!1),x.removeEventListener("click",qr,!1),x.removeEventListener("dblclick",Gr,!1),x.removeEventListener("wheel",Ta,!1),wo?wo.disconnect():(window.removeEventListener("resize",La),window.removeEventListener("orientationchange",La)),x=void 0,no.dispose(),no=void 0,to.destroy(),Wr.destroy(),so.destroy(),vo.destroy(),po.destroy(),e.renderer||a.isDestroyed||a.destroy(),n.publish("destroy"),n.clear()},draw:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return xo?Promise.reject(new Error("The instance was already destroyed")):yn(e).then((function(e){return new Promise((function(o){if(xo)o();else{var r=!1;t.preventFilterReset&&(null==e?void 0:e.length)===Lo||(To=!1,Ro.clear());var i=e&&Dr(e[0])&&(_n||t.showPointConnectionsOnce),c=t.zDataType,l=t.wDataType;new Promise((function(s){e?(t.transition&&(e.length===Lo?r=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Wo)return!1;if(ar){var t=Vo;Vo=Zo,t.destroy()}else Vo=Wo;return Zo=$i(e,n),Uo=a.regl.framebuffer({color:Zo,depth:!1,stencil:!1}),Wo=void 0,!0}(e,{z:c,w:l}):console.warn("Cannot transition! The number of points between the previous and current draw call must be identical.")),Ji(e,{zDataType:c,wDataType:l,preventFilterReset:t.preventFilterReset,spatialIndex:t.spatialIndex}).then((function(){void 0!==t.hover&&Nr(t.hover,{preventEvent:!0}),void 0!==t.select&&Fr(t.select,{preventEvent:!0}),void 0!==t.filter&&ra(t.filter,{preventEvent:!0}),i?oa(e).then((function(){n.publish("pointConnectionsDraw"),No=!0,_o=t.showReticleOnce})).then(o):s()}))):s()})).then((function(){t.transition&&r?(i?Promise.all([new Promise((function(e){n.subscribe("transitionEnd",(function(){No=!0,_o=t.showReticleOnce,e()}),1)})),new Promise((function(e){n.subscribe("pointConnectionsDraw",e,1)}))]).then(o):n.subscribe("transitionEnd",(function(){No=!0,_o=t.showReticleOnce,o()}),1),da({duration:t.transitionDuration,easing:t.transitionEasing})):(i?Promise.all([new Promise((function(e){n.subscribe("draw",e,1)})),new Promise((function(e){n.subscribe("pointConnectionsDraw",e,1)}))]).then(o):n.subscribe("draw",o,1),No=!0,_o=t.showReticleOnce)}))}}))}))},drawAnnotations:fa,filter:ra,get:function(e){var n;return Qn({property:!0}),"aspectRatio"===e?ko:"background"===e||"backgroundColor"===e?f:"backgroundImage"===e?h:"camera"===e?no:"cameraTarget"===e?no.target:"cameraDistance"===e?no.distance[0]:"cameraRotation"===e?no.rotation:"cameraView"===e?no.view:"canvas"===e?x:"colorBy"===e?P:"sizeBy"===e?kt:"deselectOnDblClick"===e?C:"deselectOnEscape"===e?T:"height"===e?Ft:"lassoColor"===e?O:"lassoLineWidth"===e?D:"lassoMinDelay"===e?F:"lassoMinDist"===e?_:"lassoClearEvent"===e?Z:"lassoInitiator"===e?q:"lassoInitiatorElement"===e?Wr.initiator:"lassoInitiatorParentElement"===e?X:"keyMap"===e?function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?s(Object(t),!0).forEach((function(n){l(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},Mn):"mouseMode"===e?In:"opacity"===e?1===Mt.length?Mt[0]:Mt:"opacityBy"===e?It:"opacityByDensityFill"===e?Rt:"opacityByDensityDebounceTime"===e?Jt:"opacityInactiveMax"===e?Lt:"opacityInactiveScale"===e?Bt:"points"===e?Oo:"hoveredPoint"===e?or:"selectedPoints"===e?d(Mo):"filteredPoints"===e?To?Array.from(Ro):Array.from({length:Oo.length},(function(e,n){return n})):"pointsInView"===e?ia():"pointColor"===e?1===Bn.length?Bn[0]:Bn:"pointColorActive"===e?1===kn.length?kn[0]:kn:"pointColorHover"===e?1===Fn.length?Fn[0]:Fn:"pointOutlineWidth"===e?Pt:"pointSize"===e?1===gt.length?gt[0]:gt:"pointSizeSelected"===e?xt:"pointSizeMouseDetection"===e?St:"showPointConnections"===e?_n:"pointConnectionColor"===e?1===Vn.length?Vn[0]:Vn:"pointConnectionColorActive"===e?1===Un.length?Un[0]:Un:"pointConnectionColorHover"===e?1===Gn.length?Gn[0]:Gn:"pointConnectionColorBy"===e?Xn:"pointConnectionOpacity"===e?1===tt.length?tt[0]:tt:"pointConnectionOpacityBy"===e?rt:"pointConnectionOpacityActive"===e?at:"pointConnectionSize"===e?1===lt.length?lt[0]:lt:"pointConnectionSizeActive"===e?ut:"pointConnectionSizeBy"===e?ft:"pointConnectionMaxIntPointsPerSegment"===e?pt:"pointConnectionTolerance"===e?mt:"reticleColor"===e?Ln:"regl"===e?a.regl:"showReticle"===e?Rn:"version"===e?"1.10.0":"width"===e?_t:"xScale"===e?gr:"yScale"===e?wr:"performanceMode"===e?Xt:"gamma"===e?a.gamma:"renderer"===e?a:"isDestroyed"===e?xo:"isPointsDrawn"===e?fr:"isPointsFiltered"===e?To:"isAnnotationsDrawn"===e?vr:"zDataType"===e?hr:"wDataType"===e?mr:"spatialIndex"===e?null===(n=ro)||void 0===n?void 0:n.data:"annotationLineColor"===e?Vt:"annotationLineWidth"===e?Ut:"annotationHVLineLimit"===e?Gt:void 0},getScreenPosition:function(e){if(!fr)throw new Error(Ye);var n=Oo[e];if(n){var o=[n[0],n[1],0,1];return w(t,ao,w(t,no.view,lo)),S(o,o,t),[Ht*(o[0]+1)/2,Kt*(.5-o[1]/2)]}},hover:Nr,redraw:function(){No=!0},refresh:a.refresh,reset:va((function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).preventEvent,t=void 0!==e&&e;Aa(),oi(),t||n.publish("view",{view:no.view,camera:no,xScale:gr,yScale:wr})})),select:Fr,set:Pa,export:function(){return x.getContext("2d").getImageData(0,0,x.width,x.height)},subscribe:n.subscribe,unfilter:function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).preventEvent,t=void 0!==e&&e;return To=!1,Ro.clear(),Go.subdata(Xi(Lo)),new Promise((function(e){var o=function(){n.subscribe("draw",(function(){t||n.publish("unfilter"),e()}),1),No=!0};_n||Dr(Oo[0])?oa(Ir()).then((function(){t||n.publish("pointConnectionsDraw"),o()})):o()}))},unsubscribe:n.unsubscribe,view:function(e){var n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).preventEvent,t=void 0!==n&&n;wa(e),No=!0,Fo=t},zoomToLocation:ha,zoomToArea:pa,zoomToPoints:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!fr)return Promise.reject(new Error(Ye));var t=function(e){for(var n=1/0,t=-1/0,o=1/0,r=-1/0,i=0;i<e.length;i++){var a=u(Oo[e[i]],2),c=a[0],l=a[1];n=Math.min(n,c),t=Math.max(t,c),o=Math.min(o,l),r=Math.max(r,l)}return{x:n,y:o,width:t-n,height:r-o}}(e),o=t.x+t.width/2,r=t.y+t.height/2,i=Cr(),a=1+(n.padding||0),c=Math.max(t.width,i)*a,l=Math.max(t.height,i)*a;return pa({x:o-c/2,y:r-l/2,width:c,height:l},n)},zoomToOrigin:function(){return ha([0,0],1,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}}},Object.defineProperty(e,"__esModule",{value:!0})}));