UNPKG

auspice

Version:

Web app for visualizing pathogen evolution

1 lines 25.9 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]:m;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,v(this,t))}},{key:"has",value:function(t){return c(p(u.prototype),"has",this).call(this,v(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 v(t,e){var r=t._intern,n=(0,t._key)(e);return r.has(n)?r.get(n):e}function m(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),v=r(4124),m=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:v.vS.panel.fontFamily,fontSize:14,lineHeight:1,fontWeight:v.vS.panel.fontWeight,color:v.vS.panel.color,backgroundColor:v.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:v.vS.tooltip},l.createElement("div",{style:v.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(m.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 B(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)||R(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 R(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 H={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};H.overallMeanYValue=H.subplotHeight/2;var T={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",T.mean).attr("transform",function(t){return"translate(".concat(o(t.mean),", ").concat(a,")")}).attr("d",(0,j.A)().type(P.A).size(H.diamondSize)).attr("fill",n.color),void 0!==i.standardDeviation&&l.append("line").attr("class",T.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",H.standardDeviationStroke).attr("stroke",n.color)},F=function(t,e,r){var n=r?null:"none";(0,E.A)(t).selectAll(".".concat(T[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()),v=p.treeStrainVisibility,m=p.treeStrainColors,g=(0,u.d4)(function(t){return t.controls.colorScale.legendValues.map(String)},i()),b=(0,u.d4)(function(t){if(!t.metadata.loaded)throw new Error("[INTERNAL ERROR] metadata state not loaded");return t.metadata.colorings}),S=(0,u.d4)(function(t){return t.controls.colorBy}),k=(0,u.d4)(function(t){return t.controls.defaults.colorBy}),j=(0,u.d4)(function(t){return t.controls.measurementsColorGrouping}),P=(0,u.d4)(function(t){return t.controls.measurementsGroupBy}),D=(0,u.d4)(function(t){return t.controls.measurementsFilters}),Q=(0,u.d4)(function(t){return t.controls.measurementsDisplay}),Z=(0,u.d4)(function(t){return t.controls.measurementsShowOverallMean}),J=(0,u.d4)(function(t){return t.controls.measurementsShowThreshold}),q=(0,u.d4)(function(t){return t.measurements.collectionToDisplay},i()),tt=q.title,et=q.x_axis_label,rt=q.thresholds,nt=q.fields,ot=q.measurements,at=q.groupings,it=(0,l.useRef)(null),lt=(0,l.useRef)(null),ut=(0,l.useRef)(null),ct=U((0,l.useState)(null),2),st=ct[0],ft=ct[1],dt=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)})}}(ot,v,D),yt=dt.activeFilters,pt=dt.filteredMeasurements,ht=at.get(P).values,vt=ht;yt[P]&&yt[P].length&&(vt=yt[P]);var mt=function(t,e,r){return o()((0,x.TN)(t,function(t){return t[e]}),function(t){var e=B(t,1)[0];return r.indexOf(e)},"asc")}(pt,P,vt),gt=(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=B(r,2),a=o[0],i=o[1],l=(i-a)*n/2,[a-l,i+l])).range([H.leftPadding,t-H.rightPadding]).nice()}(r,pt)},[r,pt].map(K)),bt=K({containerHeight:e,xScale:gt,yScale:(0,l.useMemo)(function(){return t=H.yMin-2*H.circleRadius,e=H.yMax+2*H.circleRadius,(0,M.m4)().domain([t,e]).range([H.subplotHeight,0]).nice();var t,e},[]),x_axis_label:et,thresholds:rt,groupingOrderedValues:ht,groupedMeasurements:mt}),At=(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)(b,S)," : ").concat(i):null,c=new Map;if((0,z.vw)(t)){var f=Object.keys(t).filter(function(t){return nt.has(t)}),d=function(t){if(Array.isArray(t))return $(t)}(a=nt.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(nt.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}}ft(l)},[nt,b,S]),wt=(0,l.useRef)((0,Y.DM)(S)?k:S);(0,l.useEffect)(function(){(0,Y.DM)(S)||(wt.current=S)},[S]);var xt=(0,l.useCallback)(function(t){t===j&&(0,Y.DM)(S)?t===j&&(0,Y.DM)(S)&&y((0,N.p)(wt.current)):y((0,Y._k)(t))},[y,j,S]);(0,l.useEffect)(function(){a("".concat(tt||"Measurements"," (grouped by ").concat(nt.get(P).title,")"))},[a,tt,nt,P]),(0,l.useEffect)(function(){var t,e;it.current.scrollTop=0,t=lt.current,e=ut.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=H.subplotHeight*s.length+H.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-H.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",T.xAxis).call((0,O.l7)(n)).call(function(t){return t.attr("font-family",null)}).append("text").attr("x",H.leftPadding+(l-H.leftPadding-H.rightPadding)/2).attr("y",2*H.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=R(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 v=a(h);d.append("line").attr("class",T.threshold).attr("x1",v).attr("x2",v).attr("y1",H.topPadding).attr("y2",f).attr("stroke-width",H.thresholdStrokeWidth).attr("stroke",H.thresholdStroke).attr("display","none")}}}catch(t){p.e(t)}finally{p.f()}}var m=H.topPadding;s.forEach(function(t,e){var r=B(t,2),o=r[0],l=r[1],u=d.append("svg").attr("class",T.subplot).attr("id",_(c.indexOf(o))).attr("width","100%").attr("height",H.subplotHeight).attr("y",m);m+=H.subplotHeight,u.append("rect").attr("class",T.subplotBackground).attr("x",0).attr("y",0).attr("height","100%").attr("width","100%").attr("fill",e%2?H.subplotFill:"none").attr("fill-opacity",H.subplotFillOpacity),u.append("g").attr("class",T.yAxis).attr("transform","translate(".concat(H.leftPadding,", 0)")).attr("cursor","pointer").call((0,O.V4)(i).tickValues([i((H.yMax-H.yMin)/2)]).tickSize(H.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",T.groupingValue).attr("transform",function(t,e,r){var n=(0,E.A)(r[e]).node().getBoundingClientRect().width,o=H.leftPadding-2*H.yAxisTickSize;return n>o?"scale(".concat(o/n,")"):null})}).on("click",function(){return n(o)}),u.append("g").attr("class",T.rawMeasurementsGroup).attr("display","none").selectAll("dot").data(l).enter().append("circle").attr("class",T.rawMeasurements).attr("id",function(t){return V(t)}).attr("cx",function(t){return a(t.value)}).attr("r",H.circleRadius).attr("fill-opacity",H.circleFillOpacity).attr("stroke-opacity",H.circleStrokeOpacity).on("mouseover.radius",function(t,e,r){(0,E.A)(r[e]).transition().duration("100").attr("r",H.circleHoverRadius)}).on("mouseout.radius",function(t,e,r){(0,E.A)(r[e]).transition().duration("200").attr("r",H.circleRadius)}),L(l.map(function(t){return t.value}),u,T.overallMean,{attribute:null,color:H.overallMeanColor},a,H.overallMeanYValue)})}}(lt.current,ut.current,bt,xt)},[bt,xt]),(0,l.useEffect)(function(){!function(t,e){var r=(0,E.A)(t);r.selectAll(".".concat(T.yAxisColorByLabel)).remove(),r.selectAll(".".concat(T.yAxis)).select(".tick").each(function(t,r,n){var o=(0,E.A)(n[r]),a=o.select(".".concat(T.groupingValue)).text(),i=e[a];if(i){var l=o.node().getBoundingClientRect().width;o.append("line").attr("class",T.yAxisColorByLabel).attr("x1",-H.yAxisTickSize).attr("x2",-l).attr("y1",H.yAxisColorByLineHeight).attr("y2",H.yAxisColorByLineHeight).attr("stroke-width",H.yAxisColorByLineStrokeWidth).attr("stroke",i.color),o.append("text").attr("class",T.yAxisColorByLabel).attr("x",-.5*l).attr("dy",2*H.yAxisColorByLineHeight+H.yAxisColorByLineStrokeWidth).attr("text-anchor","middle").attr("fill","currentColor").text("(".concat(i.attribute,")"))}})}(lt.current,m),function(t,e){(0,E.A)(t).selectAll(".".concat(T.rawMeasurements)).style("stroke",function(t){return e[t.strain].color}).style("stroke-width",H.circleStrokeWidth).style("fill",function(t){return(0,s.rQ)(e[t.strain].color)})}(lt.current,m),function(t,e,r,n){var o=e.groupedMeasurements,a=(0,E.A)(t);o.forEach(function(t){var e=B(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)*H.circleRadius,u=H.subplotHeight-2*H.subplotPadding-l,c=H.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*H.circleRadius})})}(lt.current,bt,m,g),function(t,e,r,n){var a=e.xScale,i=e.groupingOrderedValues,l=e.groupedMeasurements,u=(0,E.A)(t);u.selectAll(".".concat(T.colorMean)).remove(),l.forEach(function(t){var e=B(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=(H.subplotHeight-4*H.subplotPadding)/(d-1),p=H.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,T.colorMean,{attribute:t,color:r},a,p),(p+=y)>H.overallMeanYValue-H.subplotPadding&&p<H.overallMeanYValue+H.subplotPadding&&(p=H.overallMeanYValue+H.subplotPadding)})})}(lt.current,bt,m,g),function(t,e,r){(0,E.A)(t).selectAll(".".concat(T.rawMeasurements,",.").concat(T.mean,",.").concat(T.standardDeviation)).on("mouseover.hoverPanel",function(t,n,o){var a,i=C.f0.clientX,l=C.f0.clientY,u=o[n].getAttribute("class")===T.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)})}(lt.current,At,m)},[bt,m,g,At]),(0,l.useEffect)(function(){!function(t,e){var r=(0,E.A)(t),n={raw:T.rawMeasurementsGroup,mean:T.colorMean};Object.entries(n).forEach(function(t){var n=B(t,2),o=n[0],a=n[1];r.selectAll(".".concat(a)).attr("display",e===o?null:"none")})}(lt.current,Q)},[bt,m,g,At,Q]),(0,l.useEffect)(function(){F(lt.current,"overallMean",Z)},[bt,Z]),(0,l.useEffect)(function(){F(lt.current,"threshold",J)},[bt,J]),(0,l.useEffect)(function(){var t,e;(0,Y.DM)(S)?(t=lt.current,e=j,G(t),(0,E.A)(t).selectAll(".".concat(T.yAxis)).select(".tick").each(function(t,r,n){var o=(0,E.A)(n[r]),a=o.select(".".concat(T.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*H.yAxisColorByLineHeight).attr("width",2*H.yAxisColorByLineHeight).attr("x",-i-2*H.yAxisColorByLineHeight).attr("y",-H.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(lt.current)},[bt,S,j]);var St=function(){return{width:"100%",height:H.xAxisHeight,position:"sticky",zIndex:99}};return l.createElement(l.Fragment,null,n&&l.createElement(d.A,null,l.createElement(h.A,{right:!0,width:r})),l.createElement("div",{id:I,ref:it,style:{overflowY:"auto",position:"relative",height:e,width:r}},st&&l.createElement(A,{hoverData:st}),l.createElement("svg",{id:"d3MeasurementsXAxisSVG",ref:ut,style:St()}),l.createElement("svg",{id:"d3MeasurementsSVG",ref:lt,style:{width:"100%",position:"relative",bottom:"".concat(St().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")))}}}]);