UNPKG

auspice

Version:

Web app for visualizing pathogen evolution

1 lines 26.1 kB
"use strict";(self.webpackChunkauspice=self.webpackChunkauspice||[]).push([[833],{46945(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,l=[],u=!0,c=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(t,e)||a(t,e)||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 a(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function l(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,u(n.key),n)}}function u(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}function c(){return c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=p(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:r):o.value}},c.apply(null,arguments)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(d())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&y(o,r.prototype),o}(t,arguments,p(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,t)},f(t)}function d(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(d=function(){return!!t})()}function y(t,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},y(t,e)}function p(t){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},p(t)}r.d(e,{B:()=>h});var h=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&y(t,e)}(u,t);var e,r,i=(e=u,r=d(),function(){var t,o=p(e);if(r){var a=p(this).constructor;t=Reflect.construct(o,arguments,a)}else t=o.apply(this,arguments);return function(t,e){if(e&&("object"==n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}(this,t)});function u(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),e=i.call(this),Object.defineProperties(s(e),{_intern:{value:new Map},_key:{value:r}}),null!=t){var n,l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=a(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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,l=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return l=t.done,t},e:function(t){u=!0,i=t},f:function(){try{l||null==r.return||r.return()}finally{if(u)throw i}}}}(t);try{for(l.s();!(n=l.n()).done;){var c=o(n.value,2),f=c[0],d=c[1];e.set(f,d)}}catch(t){l.e(t)}finally{l.f()}}return e}return function(t,e,r){e&&l(t.prototype,e),r&&l(t,r),Object.defineProperty(t,"prototype",{writable:!1})}(u,[{key:"get",value:function(t){return c(p(u.prototype),"get",this).call(this,m(this,t))}},{key:"has",value:function(t){return c(p(u.prototype),"has",this).call(this,m(this,t))}},{key:"set",value:function(t,e){return c(p(u.prototype),"set",this).call(this,function(t,e){var r=t._intern,n=(0,t._key)(e);return r.has(n)?r.get(n):(r.set(n,e),e)}(this,t),e)}},{key:"delete",value:function(t){return c(p(u.prototype),"delete",this).call(this,function(t,e){var r=t._intern,n=(0,t._key)(e);return r.has(n)&&(e=r.get(e),r.delete(n)),e}(this,t))}}]),u}(f(Map));function m(t,e){var r=t._intern,n=(0,t._key)(e);return r.has(n)?r.get(n):e}function v(t){return null!==t&&"object"===n(t)?t.valueOf():t}},10897(t,e,r){r.r(e),r.d(e,{default:()=>Z});var n=r(510),o=r.n(n),a=r(15031),i=r.n(a),l=r(78281),u=r(49633),c=r(40952),s=r(57758),f=r(24528),d=r(41916),y=r(60516),p=r(26225),h=r(80755),m=r(4124),v=r(5699);function g(t,e){if(t){if("string"==typeof t)return b(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}const A=function(t){var e=t.hoverData;if(null===e)return null;var r=e.hoverTitle,n=e.mouseX,o=e.mouseY,a=e.containerId,i=e.data,u={position:"absolute",minWidth:200,padding:"5px",borderRadius:10,zIndex:1e3,pointerEvents:"none",fontFamily:m.vS.panel.fontFamily,fontSize:14,lineHeight:1,fontWeight:m.vS.panel.fontWeight,color:m.vS.panel.color,backgroundColor:m.vS.panel.backgroundColor,wordWrap:"break-word",wordBreak:"break-word"},c=document.getElementById(a),s=c.getBoundingClientRect();u.maxWidth=.5*s.width;var f,d=o-s.top+c.scrollTop,y=n-s.left;return y<.5*s.width?u.left=y+5:u.right=s.width-y+5,d-c.scrollTop<.5*s.height?u.top=d+5:u.bottom=s.height-d+5,l.createElement("div",{style:u},l.createElement("div",{className:"tooltip",style:m.vS.tooltip},l.createElement("div",{style:m.vS.tooltipHeading},r),(f=i.entries(),function(t){if(Array.isArray(t))return b(t)}(f)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(f)||g(f)||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.")}()).map(function(t){var e=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,l=[],u=!0,c=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(t,e)||g(t,e)||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.")}()}(t,2),r=e[0],n=e[1];return l.createElement(v.d,{key:r,name:"".concat(r,":"),value:n})})))};var w=r(91880),x=r(69555),S=r(78705),k=r(88327),O=r(62865),M=r(51682),E=r(59773),C=r(97195),j=r(57534),P=r(58347);function R(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,l=[],u=!0,c=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(t,e)||B(t,e)||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 B(t,e){if(t){if("string"==typeof t)return D(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?D(t,e):void 0}}function D(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var T={yMin:0,yMax:100,leftPadding:180,rightPadding:30,topPadding:20,xAxisHeight:50,subplotHeight:100,subplotPadding:10,circleRadius:3,circleHoverRadius:5,circleStrokeWidth:1,circleFillOpacity:.5,circleStrokeOpacity:.75,thresholdStrokeWidth:2,thresholdStroke:"#DDD",subplotFill:"#adb1b3",subplotFillOpacity:"0.15",diamondSize:50,standardDeviationStroke:3,overallMeanColor:"#000",yAxisTickSize:6,yAxisColorByLineHeight:9,yAxisColorByLineStrokeWidth:4};T.overallMeanYValue=T.subplotHeight/2;var H={xAxis:"measurementXAxis",yAxis:"measurementYAxis",groupingValue:"measurementGroupingValue",yAxisColorByLabel:"measurementYAxisColorByLabel",threshold:"measurementThreshold",subplot:"measurementSubplot",subplotBackground:"measurementSubplotBackground",rawMeasurements:"rawMeasurements",rawMeasurementsGroup:"rawMeasurementsGroup",overallMean:"measurementsOverallMean",colorMean:"measurementsColorMean",mean:"mean",standardDeviation:"standardDeviation"},I="measurementsSVGContainer",V=function(t){return"meaurement_".concat(t[c.kK])},_=function(t){return"measurement_subplot_".concat(t)},L=function(t,e,r,n,o,a){var i={colorByAttr:n.attribute,mean:(0,S.A)(t),standardDeviation:(0,k.A)(t)},l=e.append("g").attr("class",r).attr("display","none").selectAll("meanAndStandardDeviation").data([i]).enter();l.append("path").attr("class",H.mean).attr("transform",function(t){return"translate(".concat(o(t.mean),", ").concat(a,")")}).attr("d",(0,j.A)().type(P.A).size(T.diamondSize)).attr("fill",n.color),void 0!==i.standardDeviation&&l.append("line").attr("class",H.standardDeviation).attr("x1",function(t){return o(t.mean-t.standardDeviation)}).attr("x2",function(t){return o(t.mean+t.standardDeviation)}).attr("y1",a).attr("y2",a).attr("stroke-width",T.standardDeviationStroke).attr("stroke",n.color)},F=function(t,e,r){var n=r?null:"none";(0,E.A)(t).selectAll(".".concat(H[e])).attr("display",n)},W="measurementsColorGroupingCrosshair",G=function(t){(0,E.A)(t).select("#".concat(W)).remove()},z=r(30520),Y=r(86068),N=r(68087);function U(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,l=[],u=!0,c=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(t,e)||X(t,e)||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 X(t,e){if(t){if("string"==typeof t)return $(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$(t,e):void 0}}function $(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function K(t){var e=(0,l.useRef)();return i()(t,e.current)||(e.current=t),e.current}var Q=function(t){var e=t.height,r=t.width,n=t.showLegend,a=t.setPanelTitle,y=(0,u.wA)(),p=(0,u.d4)(function(t){return function(t){var e=t.tree,r=t.controls.colorScale;return e.nodes.reduce(function(t,n,o){var a=t.treeStrainVisibility,i=t.treeStrainColors;if(!n.hasChildren){a[n.name]=e.visibility[o];var l=(0,s.RQ)(n,r);if(r.continuous){var u=r.visibleLegendValues.find(function(t){return(0,f.A)(t,n,r)});void 0!==u&&(l=u)}i[n.name]={attribute:l,color:e.nodeColors[o]}}return t},{treeStrainVisibility:{},treeStrainColors:{}})}(t)},i()),m=p.treeStrainVisibility,v=p.treeStrainColors,g=(0,u.d4)(function(t){if(!t.metadata.loaded)throw new Error("[INTERNAL ERROR] metadata state not loaded");return t.metadata.legendPlacements.measurements}),b=(0,u.d4)(function(t){return t.controls.colorScale.legendValues.map(String)},i()),S=(0,u.d4)(function(t){if(!t.metadata.loaded)throw new Error("[INTERNAL ERROR] metadata state not loaded");return t.metadata.colorings}),k=(0,u.d4)(function(t){return t.controls.colorBy}),j=(0,u.d4)(function(t){return t.controls.defaults.colorBy}),P=(0,u.d4)(function(t){return t.controls.measurementsColorGrouping}),D=(0,u.d4)(function(t){return t.controls.measurementsGroupBy}),Q=(0,u.d4)(function(t){return t.controls.measurementsFilters}),Z=(0,u.d4)(function(t){return t.controls.measurementsDisplay}),J=(0,u.d4)(function(t){return t.controls.measurementsShowOverallMean}),q=(0,u.d4)(function(t){return t.controls.measurementsShowThreshold}),tt=(0,u.d4)(function(t){return t.measurements.collectionToDisplay},i()),et=tt.title,rt=tt.x_axis_label,nt=tt.thresholds,ot=tt.fields,at=tt.measurements,it=tt.groupings,lt=(0,l.useRef)(null),ut=(0,l.useRef)(null),ct=(0,l.useRef)(null),st=U((0,l.useState)(null),2),ft=st[0],dt=st[1],yt=function(t,e,r){var n=(0,Y.GF)(r);return{activeFilters:n,filteredMeasurements:t.filter(function(t){return e[t.strain]===c.uU&&(0,Y.K9)(t,n)})}}(at,m,Q),pt=yt.activeFilters,ht=yt.filteredMeasurements,mt=it.get(D).values,vt=mt;pt[D]&&pt[D].length&&(vt=pt[D]);var gt=function(t,e,r){return o()((0,x.TN)(t,function(t){return t[e]}),function(t){var e=R(t,1)[0];return r.indexOf(e)},"asc")}(ht,D,vt),bt=(0,l.useMemo)(function(){return function(t,e){var r,n,o,a,i,l,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1;return(0,M.m4)().domain((r=(0,w.A)(e,function(t){return t.value}),n=u,o=R(r,2),a=o[0],i=o[1],l=(i-a)*n/2,[a-l,i+l])).range([T.leftPadding,t-T.rightPadding]).nice()}(r,ht)},[r,ht].map(K)),At=K({containerHeight:e,xScale:bt,yScale:(0,l.useMemo)(function(){return t=T.yMin-2*T.circleRadius,e=T.yMax+2*T.circleRadius,(0,M.m4)().domain([t,e]).range([T.subplotHeight,0]).nice();var t,e},[]),x_axis_label:rt,thresholds:nt,groupingOrderedValues:mt,groupedMeasurements:gt}),wt=(0,l.useCallback)(function(t,e,r){var n,a,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=null;if(null!==t){var u=null!==i?"Color by ".concat((0,s.De)(S,k)," : ").concat(i):null,c=new Map;if((0,z.vw)(t)){var f=Object.keys(t).filter(function(t){return ot.has(t)}),d=function(t){if(Array.isArray(t))return $(t)}(a=ot.keys())||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(a)||X(a)||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.")}();o()(f,function(t){return d.indexOf(t)}).forEach(function(e){c.set(ot.get(e).title,t[e])})}else"number"!=typeof(n=t).mean||"number"!=typeof n.standardDeviation&&void 0!==n.standardDeviation?(console.error('"Unknown data type for hover panel: '.concat(JSON.stringify(t))),Object.entries(t).forEach(function(t){var e=U(t,2),r=e[0],n=e[1];return c.set(r,n)})):(c.set("mean",t.mean.toFixed(2)),c.set("standard deviation",t.standardDeviation?t.standardDeviation.toFixed(2):"N/A"));l={hoverTitle:u,mouseX:e,mouseY:r,containerId:I,data:c}}dt(l)},[ot,S,k]),xt=(0,l.useRef)((0,Y.DM)(k)?j:k);(0,l.useEffect)(function(){(0,Y.DM)(k)||(xt.current=k)},[k]);var St=(0,l.useCallback)(function(t){t===P&&(0,Y.DM)(k)?t===P&&(0,Y.DM)(k)&&y((0,N.p)(xt.current)):y((0,Y._k)(t))},[y,P,k]);(0,l.useEffect)(function(){a("".concat(et||"Measurements"," (grouped by ").concat(ot.get(D).title,")"))},[a,et,ot,D]),(0,l.useEffect)(function(){var t,e;lt.current.scrollTop=0,t=ut.current,e=ct.current,(0,E.A)(t).attr("height",null).selectAll("*").remove(),(0,E.A)(e).selectAll("*").remove(),function(t,e,r,n){var o=r.containerHeight,a=r.xScale,i=r.yScale,l=r.x_axis_label,u=r.thresholds,c=r.groupingOrderedValues,s=r.groupedMeasurements;if(!s||0!==s.length){var f=T.subplotHeight*s.length+T.topPadding,d=(0,E.A)(t).attr("height",f).append("g").append("g").append("g").append("g");if(function(t,e,r,n,o){var a=(0,E.A)(t),i=Math.min(e-T.xAxisHeight,r);a.style("top","".concat(i,"px")),a.append("rect").attr("x",0).attr("y",0).attr("height","100%").attr("width","100%").attr("fill","white").attr("fill-opacity",1);var l=a.node().getBoundingClientRect().width;a.append("g").attr("class",H.xAxis).call((0,O.l7)(n)).call(function(t){return t.attr("font-family",null)}).append("text").attr("x",T.leftPadding+(l-T.leftPadding-T.rightPadding)/2).attr("y",2*T.xAxisHeight/3).attr("text-anchor","middle").attr("fill","currentColor").text(o)}(e,o,f,a,l),Array.isArray(u)){var y,p=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=B(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}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 o,a=!0,i=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){i=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(i)throw o}}}}(u);try{for(p.s();!(y=p.n()).done;){var h=y.value;if("number"==typeof h){var m=a(h);d.append("line").attr("class",H.threshold).attr("x1",m).attr("x2",m).attr("y1",T.topPadding).attr("y2",f).attr("stroke-width",T.thresholdStrokeWidth).attr("stroke",T.thresholdStroke).attr("display","none")}}}catch(t){p.e(t)}finally{p.f()}}var v=T.topPadding;s.forEach(function(t,e){var r=R(t,2),o=r[0],l=r[1],u=d.append("svg").attr("class",H.subplot).attr("id",_(c.indexOf(o))).attr("width","100%").attr("height",T.subplotHeight).attr("y",v);v+=T.subplotHeight,u.append("rect").attr("class",H.subplotBackground).attr("x",0).attr("y",0).attr("height","100%").attr("width","100%").attr("fill",e%2?T.subplotFill:"none").attr("fill-opacity",T.subplotFillOpacity),u.append("g").attr("class",H.yAxis).attr("transform","translate(".concat(T.leftPadding,", 0)")).attr("cursor","pointer").call((0,O.V4)(i).tickValues([i((T.yMax-T.yMin)/2)]).tickSize(T.yAxisTickSize).tickFormat(o)).call(function(t){t.selectAll(".tick").append("title").text("Click to color by an average of all measurement values per test strain in this group"),t.attr("font-family",null),t.selectAll("text").attr("class",H.groupingValue).attr("transform",function(t,e,r){var n=(0,E.A)(r[e]).node().getBoundingClientRect().width,o=T.leftPadding-2*T.yAxisTickSize;return n>o?"scale(".concat(o/n,")"):null})}).on("click",function(){return n(o)}),u.append("g").attr("class",H.rawMeasurementsGroup).attr("display","none").selectAll("dot").data(l).enter().append("circle").attr("class",H.rawMeasurements).attr("id",function(t){return V(t)}).attr("cx",function(t){return a(t.value)}).attr("r",T.circleRadius).attr("fill-opacity",T.circleFillOpacity).attr("stroke-opacity",T.circleStrokeOpacity).on("mouseover.radius",function(t,e,r){(0,E.A)(r[e]).transition().duration("100").attr("r",T.circleHoverRadius)}).on("mouseout.radius",function(t,e,r){(0,E.A)(r[e]).transition().duration("200").attr("r",T.circleRadius)}),L(l.map(function(t){return t.value}),u,H.overallMean,{attribute:null,color:T.overallMeanColor},a,T.overallMeanYValue)})}}(ut.current,ct.current,At,St)},[At,St]),(0,l.useEffect)(function(){!function(t,e){var r=(0,E.A)(t);r.selectAll(".".concat(H.yAxisColorByLabel)).remove(),r.selectAll(".".concat(H.yAxis)).select(".tick").each(function(t,r,n){var o=(0,E.A)(n[r]),a=o.select(".".concat(H.groupingValue)).text(),i=e[a];if(i){var l=o.node().getBoundingClientRect().width;o.append("line").attr("class",H.yAxisColorByLabel).attr("x1",-T.yAxisTickSize).attr("x2",-l).attr("y1",T.yAxisColorByLineHeight).attr("y2",T.yAxisColorByLineHeight).attr("stroke-width",T.yAxisColorByLineStrokeWidth).attr("stroke",i.color),o.append("text").attr("class",H.yAxisColorByLabel).attr("x",-.5*l).attr("dy",2*T.yAxisColorByLineHeight+T.yAxisColorByLineStrokeWidth).attr("text-anchor","middle").attr("fill","currentColor").text("(".concat(i.attribute,")"))}})}(ut.current,v),function(t,e){(0,E.A)(t).selectAll(".".concat(H.rawMeasurements)).style("stroke",function(t){return e[t.strain].color}).style("stroke-width",T.circleStrokeWidth).style("fill",function(t){return(0,s.rQ)(e[t.strain].color)})}(ut.current,v),function(t,e,r,n){var o=e.groupedMeasurements,a=(0,E.A)(t);o.forEach(function(t){var e=R(t,2),o=(e[0],e[1]),i={};o.forEach(function(t){var e=r[t.strain].attribute;i[e]=i[e]||[],i[e].push(V(t))});var l=2*(Object.keys(i).length-1)*T.circleRadius,u=T.subplotHeight-2*T.subplotPadding-l,c=T.subplotPadding;Object.keys(i).sort(function(t,e){return n.indexOf(t)-n.indexOf(e)}).forEach(function(t){var e=i[t],r=e.length/o.length,n=c+r*u;e.forEach(function(t){var e=Math.random()*(n-c)+c;a.select("#".concat(t)).attr("cy",e)}),c=n+2*T.circleRadius})})}(ut.current,At,v,b),function(t,e,r,n){var a=e.xScale,i=e.groupingOrderedValues,l=e.groupedMeasurements,u=(0,E.A)(t);u.selectAll(".".concat(H.colorMean)).remove(),l.forEach(function(t){var e=R(t,2),l=e[0],c=e[1],s={};c.forEach(function(t){var e=r[t.strain],n=e.attribute,o=e.color;s[n]=s[n]||{color:null,values:[]},s[n].values.push(t.value),s[n].color||(s[n].color=o)});var f=u.select("#".concat(_(i.indexOf(l)))),d=Object.keys(s).length,y=(T.subplotHeight-4*T.subplotPadding)/(d-1),p=T.subplotPadding;o()(Object.keys(s),function(t){return n.indexOf(t)},"asc").forEach(function(t){var e=s[t],r=e.color,n=e.values;L(n,f,H.colorMean,{attribute:t,color:r},a,p),(p+=y)>T.overallMeanYValue-T.subplotPadding&&p<T.overallMeanYValue+T.subplotPadding&&(p=T.overallMeanYValue+T.subplotPadding)})})}(ut.current,At,v,b),function(t,e,r){(0,E.A)(t).selectAll(".".concat(H.rawMeasurements,",.").concat(H.mean,",.").concat(H.standardDeviation)).on("mouseover.hoverPanel",function(t,n,o){var a,i=C.f0.clientX,l=C.f0.clientY,u=o[n].getAttribute("class")===H.rawMeasurements?"measurement":"mean",c=t.colorByAttr;"measurement"===u&&(c=(null===(a=r[t.strain])||void 0===a?void 0:a.attribute)||"undefined"),e(t,i,l,c)}).on("mouseout.hoverPanel",function(){return e(null)})}(ut.current,wt,v)},[At,v,b,wt]),(0,l.useEffect)(function(){!function(t,e){var r=(0,E.A)(t),n={raw:H.rawMeasurementsGroup,mean:H.colorMean};Object.entries(n).forEach(function(t){var n=R(t,2),o=n[0],a=n[1];r.selectAll(".".concat(a)).attr("display",e===o?null:"none")})}(ut.current,Z)},[At,v,b,wt,Z]),(0,l.useEffect)(function(){F(ut.current,"overallMean",J)},[At,J]),(0,l.useEffect)(function(){F(ut.current,"threshold",q)},[At,q]),(0,l.useEffect)(function(){var t,e;(0,Y.DM)(k)?(t=ut.current,e=P,G(t),(0,E.A)(t).selectAll(".".concat(H.yAxis)).select(".tick").each(function(t,r,n){var o=(0,E.A)(n[r]),a=o.select(".".concat(H.groupingValue)).text();if(e===a){var i=o.node().getBoundingClientRect().width;o.append("svg").attr("id",W).attr("stroke","currentColor").attr("fill","currentColor").attr("strokeWidth","0").attr("viewBox","0 0 256 256").attr("height",2*T.yAxisColorByLineHeight).attr("width",2*T.yAxisColorByLineHeight).attr("x",-i-2*T.yAxisColorByLineHeight).attr("y",-T.yAxisColorByLineHeight).append("path").attr("d","M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm12,191.13V184a12,12,0,0,0-24,0v27.13A84.18,84.18,0,0,1,44.87,140H72a12,12,0,0,0,0-24H44.87A84.18,84.18,0,0,1,116,44.87V72a12,12,0,0,0,24,0V44.87A84.18,84.18,0,0,1,211.13,116H184a12,12,0,0,0,0,24h27.13A84.18,84.18,0,0,1,140,211.13Z")}})):G(ut.current)},[At,k,P]);var kt=function(){return{width:"100%",height:T.xAxisHeight,position:"sticky",zIndex:99}};return l.createElement(l.Fragment,null,n&&l.createElement(d.A,null,l.createElement(h.A,{legendPlacement:g,width:r})),l.createElement("div",{id:I,ref:lt,style:{overflowY:"auto",position:"relative",height:e,width:r}},ft&&l.createElement(A,{hoverData:ft}),l.createElement("svg",{id:"d3MeasurementsXAxisSVG",ref:ct,style:kt()}),l.createElement("svg",{id:"d3MeasurementsSVG",ref:ut,style:{width:"100%",position:"relative",bottom:"".concat(kt().height,"px")}})))};const Z=function(t){var e=t.height,r=t.width,n=t.showLegend,o=(0,u.d4)(function(t){return t.measurements.loaded}),a=(0,u.d4)(function(t){return t.measurements.error}),i=(0,u.d4)(function(t){return t.controls.showOnlyPanels}),c=U((0,l.useState)("Measurements"),2),s=c[0],f=c[1];return l.createElement(p.A,{infocard:i,title:s,titleStyles:{width:r,display:"block",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}},o?l.createElement(Q,{height:e,width:r,showLegend:n,setPanelTitle:f}):l.createElement(y.A,{style:{height:e,width:r},direction:"column",justifyContent:"center"},l.createElement("p",{style:{textAlign:"center"}},a||"Failed to fetch/load measurements due to unknown error")))}}}]);