{"version":3,"sources":["webpack:///../src/sum.js","webpack:///../src/mean.js","webpack:///../src/sum_nth_power_deviations.js","webpack:///../src/variance.js","webpack:///../src/standard_deviation.js","webpack:///../src/mode_sorted.js","webpack:///../src/numeric_sort.js","webpack:///../src/min.js","webpack:///../src/max.js","webpack:///../src/quantile_sorted.js","webpack:///../src/quickselect.js","webpack:///../src/quantile.js","webpack:///../src/quantile_rank_sorted.js","webpack:///../src/interquartile_range.js","webpack:///../src/median.js","webpack:///../src/median_absolute_deviation.js","webpack:///../src/shuffle_in_place.js","webpack:///../src/shuffle.js","webpack:///../src/unique_count_sorted.js","webpack:///../src/ckmeans.js","webpack:///../src/sample_covariance.js","webpack:///../src/sample_variance.js","webpack:///../src/sample_standard_deviation.js","webpack:///../src/combine_means.js","webpack:///../src/root_mean_square.js","webpack:///../src/bayesian_classifier.js","webpack:///../src/perceptron.js","webpack:///../src/factorial.js","webpack:///../src/gammaln.js","webpack:///../src/chi_squared_distribution_table.js","webpack:///../src/kernel_density_estimation.js","webpack:///../src/standard_normal_table.js","webpack:///../src/error_function.js","webpack:///../src/inverse_error_function.js","webpack:///../src/sign.js","webpack:///../src/add_to_mean.js","webpack:///../src/bernoulli_distribution.js","webpack:///../src/binomial_distribution.js","webpack:///../src/bisect.js","webpack:///../src/chi_squared_goodness_of_fit.js","webpack:///../src/chunk.js","webpack:///../src/combinations.js","webpack:///../src/combinations_replacement.js","webpack:///../src/combine_variances.js","webpack:///../src/cumulative_std_normal_probability.js","webpack:///../src/epsilon.js","webpack:///../src/equal_interval_breaks.js","webpack:///../src/extent.js","webpack:///../src/extent_sorted.js","webpack:///../src/gamma.js","webpack:///../src/geometric_mean.js","webpack:///../src/harmonic_mean.js","webpack:///../src/linear_regression.js","webpack:///../src/linear_regression_line.js","webpack:///../src/max_sorted.js","webpack:///../src/median_sorted.js","webpack:///../src/min_sorted.js","webpack:///../src/mode.js","webpack:///../src/mode_fast.js","webpack:///../src/permutation_test.js","webpack:///../src/permutations_heap.js","webpack:///../src/poisson_distribution.js","webpack:///../src/probit.js","webpack:///../src/product.js","webpack:///../src/quantile_rank.js","webpack:///../src/r_squared.js","webpack:///../src/sample.js","webpack:///../src/sample_correlation.js","webpack:///../src/sample_kurtosis.js","webpack:///../src/sample_skewness.js","webpack:///../src/sample_with_replacement.js","webpack:///../src/subtract_from_mean.js","webpack:///../src/sum_simple.js","webpack:///../src/t_test.js","webpack:///../src/t_test_two_sample.js","webpack:///../src/z_score.js","webpack:///./node_modules/topojson-client/src/identity.js","webpack:///./node_modules/topojson-client/src/transform.js","webpack:///./node_modules/topojson-client/src/feature.js","webpack:///./node_modules/topojson-client/src/reverse.js","webpack:///./node_modules/topojson-client/src/stitch.js","webpack:///./node_modules/topojson-client/src/merge.js","webpack:///./app/scripts/utils/map-utils.js","webpack:///./app/scripts/utils/clamp.js","webpack:///./app/scripts/packs/new-deaths.js","webpack:///./app/scripts/packs/new-tests.js","webpack:///./app/scripts/packs/new-cases.js","webpack:///./app/scripts/packs/positive-rate.js","webpack:///./app/scripts/packs/rate-map.js","webpack:///./config/modern-polyfills.js","webpack:///./app/scripts/utils/load-asset-url.js","webpack:///./app/scripts/utils/charts-utils.js","webpack:///./node_modules/moment/locale sync ^\\.\\/.*$","webpack:///./app/scripts/kickstart.js","webpack:///./app/scripts/packs/main.js","webpack:///./node_modules/d3-jetpack/src/translate-selection.js","webpack:///./node_modules/d3-jetpack/src/parseAttributes.js","webpack:///./node_modules/d3-jetpack/src/insert.js","webpack:///./node_modules/d3-jetpack/src/at.js","webpack:///./node_modules/d3-jetpack/src/f.js","webpack:///./node_modules/d3-jetpack/src/st.js","webpack:///./node_modules/d3-jetpack/src/wordwrap.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/array.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/time.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/colors.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/category10.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/category20b.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/category20c.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/category20.js","webpack:///./node_modules/d3-color/src/math.js","webpack:///./node_modules/d3-color/src/cubehelix.js","webpack:///./node_modules/d3-interpolate/src/cubehelix.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/cubehelix.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/rainbow.js","webpack:///./node_modules/d3-jetpack/node_modules/d3-scale/src/viridis.js","webpack:///./node_modules/d3-jetpack/src/conventions.js","webpack:///./node_modules/d3-queue/src/array.js","webpack:///./node_modules/d3-queue/src/queue.js","webpack:///./node_modules/d3-request/src/request.js","webpack:///./node_modules/d3-request/src/type.js","webpack:///./node_modules/d3-request/src/dsv.js","webpack:///./node_modules/d3-request/src/html.js","webpack:///./node_modules/d3-request/src/json.js","webpack:///./node_modules/d3-request/src/text.js","webpack:///./node_modules/d3-request/src/xml.js","webpack:///./node_modules/d3-request/src/csv.js","webpack:///./node_modules/d3-request/src/tsv.js","webpack:///./node_modules/d3-jetpack/index.js","webpack:///./node_modules/d3-jetpack/src/append.js","webpack:///./node_modules/d3-jetpack/src/parent.js","webpack:///./node_modules/d3-jetpack/src/selectAppend.js","webpack:///./node_modules/d3-jetpack/src/tspans.js","webpack:///./node_modules/d3-jetpack/src/appendMany.js","webpack:///./app/scripts/packs/daily-hospitalization.js","webpack:///./app/scripts/utils/d3-base.js","webpack:///./app/scripts/packs/collapsible-table-rows.js","webpack:///../src/vnode.js","webpack:///../src/options.js","webpack:///../src/h.js","webpack:///../src/util.js","webpack:///../src/constants.js","webpack:///../src/render-queue.js","webpack:///../src/vdom/index.js","webpack:///../src/dom/index.js","webpack:///../src/vdom/diff.js","webpack:///../src/vdom/component.js","webpack:///../src/vdom/component-recycler.js","webpack:///../src/component.js","webpack:///./app/scripts/packs/hospitals-map.js"],"names":["sum","x","length","let","transition","correction","i","Math","abs","mean","Error","sumNthPowerDeviations","n","const","tempValue","meanValue","pow","variance","standardDeviation","v","sqrt","modeSorted","sorted","last","value","NaN","maxSeen","seenThis","numericSort","slice","sort","a","b","min","max","quantileSorted","p","idx","ceil","quickselect","arr","k","left","right","m","z","log","s","exp","sd","floor","t","j","swap","tmp","quantile","copy","Array","isArray","indices","push","quantileIndex","compare","stack","r","pop","l","quantileSelect","results","len","quantileRankSorted","mid","lo","hi","u","interquartileRange","q1","q2","median","medianAbsoluteDeviation","medianValue","medianAbsoluteDeviations","shuffleInPlace","randomSource","random","temporary","index","shuffle","uniqueCountSorted","lastSeenValue","uniqueValueCount","makeMatrix","columns","rows","matrix","column","ssq","sums","sumsOfSquares","sji","muji","fillMatrixColumn","iMin","iMax","cluster","backtrackMatrix","jlow","ssqjlow","ssqj","jhigh","sampleCovariance","y","xmean","ymean","sampleVariance","sampleStandardDeviation","sampleVarianceX","combineMeans","mean1","n1","mean2","n2","rootMeanSquare","sumOfSquares","BayesianClassifier","this","totalCount","data","train","item","category","score","odds","oddsSums","combination","PerceptronModel","weights","bias","factorial","accumulator","predict","features","label","prediction","gradient","COEFFICIENTS","LOGSQRT2PI","PI","chiSquaredDistributionTable","1","0.995","0.99","0.975","0.95","0.9","0.5","0.1","0.05","0.025","0.01","0.005","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","40","50","60","70","80","90","100","SQRT_2PI","kernels","gaussian","bandwidthMethods","nrd","stddev","iqr","kernelDensityEstimation","X","kernel","bandwidthMethod","kernelFn","bandwidth","cumulativeDistribution","round","standardNormalTable","errorFunction","tau","inverseErrorFunction","inv","sign","TypeError","newValue","trials","probability","cumulativeProbability","cells","binomialCoefficient","func","start","end","maxIterations","errorTolerance","output","distributionType","significance","chiSquared","hypothesizedDistribution","observedFrequencies","expectedFrequencies","degreesOfFreedom","chunkSize","nClusters","nValues","shift","shiftedValue","clusters","clusterRight","clusterLeft","combinations","subI","subsetCombinations","next","combinationList","unshift","combinationsReplacement","concat","variance1","variance2","newMean","absZ","toFixed","nClasses","theMin","theMax","breaks","breakSize","gamma","Number","isInteger","sin","seriesDenom","E","Infinity","g","reciprocalSum","dataLength","point","sumX","sumY","sumXX","sumXY","mb","mode","Map","modeCount","newCount","get","set","sampleX","sampleY","alternative","testStatistic","testStatDsn","allData","midIndex","permLeft","permRight","permTestStatistic","numExtremeTStats","elements","indexes","permutations","swapFrom","temp","lambda","factorialX","average","err","secondCentralMoment","fourthCentralMoment","sumSquaredDeviations","sumCubedDeviations","besselsCorrection","theSampleStandardDeviation","sample","expectedValue","difference","meanX","meanY","sampleVarianceY","weightedVariance","transform","identity","x0","y0","kx","scale","ky","dx","translate","dy","input","topology","o","objects","type","geometries","map","feature","id","bbox","properties","geometry","object","transformPoint","arcs","arc","points","array","reverse","line","ring","polygon","coordinates","stitchedArcs","fragmentByStart","fragmentByEnd","fragments","emptyIndex","flush","f","forEach","e","p1","p0","dp","ends","fg","gf","mergeArcs","apply","arguments","polygonsByArc","polygons","groups","extract","area","planarRingArea","_","group","neighbors","stitch","ki","filter","rate_perResidents","num","rate","cities","svg","path","citylabels","append","attr","selectAll","enter","d","centroid","anchor","text","name","highways","level","add_legend_for_gray","legend","isMobile","legend_for_gray","range","relocateTooltip","tooltip","screenY","height","width","node","getBoundingClientRect","innerWidth","window","innerHeight","top","style","container","d3","margin","bottom","dataTotals","Object","keys","death_dif","statewide_data","moment","isBefore","incomplete","unformatted_date","new_deaths","date","dataArray","dataMovingAvg","movingAvg","undefined","mergeArrays","dateRange","totalsMax","domain","nice","labels_g","xAxis","yAxis","defined","isNaN","moving_avg","bars","includes","colors","bar_neutral","bar_highlight","bar_default","pathOutline","line_moving_avg","day_for_label","moving_avg_g","moving_avgText","labelElements","getLabeledData","labelText","month","apmonth","Date","day","format","casesLabel","intcomma","pluralize","resize","frameHeight","frameWidth","offsetWidth","chartWidth","chartHeight","barWidth","call","ticks","tickFormat","customMobileDateFormat","customDateFormat","tickSize","customNumFormat","addEventListener","debounce","cases_latest_date","yesterday","subtract","yesterday_incomplete","total_tests","new_tests","total_tests_diff","viral_tests","viral_tests_diff","antibody_tests","antibody_tests_diff","missedDates","movingAvgSubtractMethod","diagonalStripePattern","start_date","dataTotals2","dataTotals3","viral_bars","bar_viral","antibody_bars","bar_antibody","missed_day_bars","dataTotalsNoMovingAvg","eventGroups","event_desktop","event_mobile","rate_threshold","eventText","eventLines","customMobileDateFormatFour","case_dif","new_cases","dateReopening","dateMaskOrder","reopeningGroup","reopeningLine","reopeningText","maskorderGroup","maskorderLine","maskorderText","tspans","wordwrap","positive_rate","specimen_positivity_rate","latest_date","missedDatesArea","dataTotalsNoMovingAvgSubtract","customPercFormat","isPartners","location","search","TT_logo_present","loadAssetURL","geoPath","geoIdentity","reflectY","color","cases","casesData","rateData","deathData","population","deaths","key","renderRateMap","html","createBase","promises","Promise","all","then","shapefiles","state","topojson","counties","texas_highways","roads","major_cities","places","numberOfClasses","ckmeansBreaks","ss","dataRange","x_legend","rangeRound","projection","fitExtent","counties_shape","on","datum","classed","tooltip_div","pageX","pageY","remove","rate_legend","legend_rect_width","invertExtent","tickValues","select","partners_img_width","partners_img_height","require","elementId","element","document","getElementById","getAttribute","JSON","parse","textContent","asset_url","count","qualifier","propertyName","val","avg","result","resultObject","leastSquares","xSeries","ySeries","reduceSumFunc","prev","cur","xBar","reduce","yBar","ssXX","ssYY","ssXY","slope","interval","short_month","a1","a2","itm","find","dates","labeledData","foundData","isSame","webpackContext","req","webpackContextResolve","__webpack_require__","code","resolve","module","exports","ttData","relatedContentContainer","gutenTag","default","RelatedContent","render","title","ribbonContainer","Ribbon","AdLoader","init","renderHospitalMap","xy","dim","getBBox","parts","split","tag","constantNull","camelCaseAttrs","test","replace","toLowerCase","functions","str","not","run","objToFn","obj","defaultVal","addStyle","sel","indexOf","wrapPx","addPx","match","fn","CHAR_W","A","B","C","c","D","F","G","H","h","I","J","K","L","M","N","O","P","Q","q","R","S","T","U","V","W","w","Y","Z","maxCharactersPerLine","minCharactersPerLine","monospace","w1","maxChars","minChars","maxLineW","minLineW","lines","words","w2","lw","ww","char_w","join","prototype","deg2rad","rad2deg","ED","EB","BC_DA","cubehelixConvert","Cubehelix","opacity","Rgb","rgbConvert","bl","atan2","cubehelix","define","extend","Color","brighter","darker","rgb","cosh","cos","sinh","hue","cubehelixGamma","colorCubehelix","cubehelixLong","interpolateCubehelixLong","ramp","noabort","Queue","size","_size","_call","_error","_tasks","_data","_waiting","_active","_ended","_start","poke","abort","maybeNotify","queue","concurrency","constructor","defer","callback","await","error","awaitAll","url","request","mimeType","response","responseType","event","dispatch","headers","xhr","XMLHttpRequest","user","password","timeout","respond","status","responseText","hasResponse","XDomainRequest","onload","onerror","ontimeout","onreadystatechange","readyState","onprogress","header","send","post","method","open","has","setRequestHeader","each","overrideMimeType","fixCallback","defaultMimeType","createRange","createContextualFragment","xml","responseXML","row","responseOf","dsv","csvParse","tsvParse","selection","translateSelection","create","parseAttributes","creator","appendChild","insert","before","selector","insertBefore","parent","parents","parentNode","selectAppend","lh","appendMany","console","warn","at","st","prop","property","new_hospitalizations","hospitalizations","axisBottom","axisLeft","xAxisGap","assign","containerWidth","containerHeight","offsetHeight","xScale","scaleLinear","yScale","drawAxis","collapseElement","c_id","onclick","collapsible","getElementsByClassName","classList","toggle","VNode","options","EMPTY_CHILDREN","nodeName","attributes","children","child","simple","String","props","applyRef","ref","SYNC_RENDER","IS_NON_DIMENSIONAL","items","isSameNodeType","_componentConstructor","isNamedNode","normalizedNodeName","createElementNS","removeNode","old","useCapture","_listeners","ns","mounts","diffLevel","hydrating","flushMounts","ret","dom","prevSvgMode","vnode","previousProps","component","_renderCallbacks","isChild","originalComponent","oldDom","isOwner","createComponent","ATTR_KEY","out","buildComponentFromVNode","vnodeName","firstChild","nodeValue","vchildren","originalChildren","childrenLen","vlen","vchild","keyedLen","keyed","previousSibling","attrs","unmountOnly","recyclerComponents","Ctor","nextBase","setComponentProps","componentWillReceiveProps","context","prevContext","_disable","renderMode","syncComponentUpdates","isUpdate","initialBase","snapshot","rendered","inst","cbase","FORCE_RENDER","prevProps","childComponent","base","childProps","initialChildComponent","diff","baseParent","replaceChild","_component","toUnmount","componentRef","beforeUnmount","popData","totalBedsData","bedsAvailData","icuBedsData","ventsAvailData","covidPatientsData","staffedInpatientBeds","trauma_service_area","covid_patients","total_beds","beds_avail","icu_beds_avail","vent_avail","staffed_inpatient_beds","topology_hsa","hsas","tsa","newDomain","hsas_shape","hospital_beds_in_use","TSA","domain_reverse","icu_beds","RAC","legendText","tickOne","tickTwo"],"mappings":"+GAkBA,SAASA,EAAIC,GAET,GAAiB,IAAbA,EAAEC,OACF,OAAO,EAWX,IAPAC,IAKIC,EALAJ,EAAMC,EAAE,GAGRI,EAAa,EAIRC,EAAI,EAAGA,EAAIL,EAAEC,OAAQI,IAC1BF,EAAaJ,EAAMC,EAAEK,GAIjBC,KAAKC,IAAIR,IAAQO,KAAKC,IAAIP,EAAEK,IAC5BD,GAAcL,EAAMI,EAAaH,EAAEK,GAEnCD,GAAcJ,EAAEK,GAAKF,EAAaJ,EAGtCA,EAAMI,EAIV,OAAOJ,EAAMK,EC/BjB,SAASI,EAAKR,GAEV,GAAiB,IAAbA,EAAEC,OACF,MAAM,IAAIQ,MAAM,yCAGpB,OAAOV,EAAIC,GAAKA,EAAEC,OCLtB,SAASS,EAAsBV,EAAGW,GAC9BC,IAEIC,EACAR,EAHES,EAAYN,EAAKR,GACnBD,EAAM,EAOV,GAAU,IAANY,EACA,IAAKN,EAAI,EAAGA,EAAIL,EAAEC,OAAQI,IAEtBN,IADAc,EAAYb,EAAEK,GAAKS,GACAD,OAGvB,IAAKR,EAAI,EAAGA,EAAIL,EAAEC,OAAQI,IACtBN,GAAOO,KAAKS,IAAIf,EAAEK,GAAKS,EAAWH,GAI1C,OAAOZ,ECrBX,SAASiB,EAAShB,GAEd,GAAiB,IAAbA,EAAEC,OACF,MAAM,IAAIQ,MAAM,6CAKpB,OAAO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B,OAAO,QACPC,KAAK,SAAU,SACfA,KAAK,eAAgB,UACrBA,KAAK,KAAM,GACXA,KAAK,KAAM,GACXA,KAAK,KAAM,GACXA,KAAK,KAAM,IAEdgkB,EACGjkB,OAAO,QACPO,KAAKijB,EAAUA,EAAU37B,OAAS,GAAGgQ,QAAQ,GAAK,MAClDoI,KAAK,IAAK,GACVA,KAAK,IAAK,IACVA,KAAK,cAAe,aAoBzB,IAAMmM,EAAqB1P,EAAI0E,OAASP,EAAW,EAAI,IACjDwL,EAAsBD,EAAqB,KAE7CpD,GACmBnJ,EAClBG,OAAO,KACPC,KAAK,aAAc,iCACnBA,KAAK,SAAU,WACfA,KAAK,MAAO,uBAGZD,OAAO,aACPC,KAAK,MAAO,sDACZA,KAAK,KAAM,IACXA,KAAK,IAAKvD,EAAIyE,OAASkL,EAAsB,GAC7CpM,KACC,QACAiF,EAAa,IAA2B,GAArBkH,EAA2BA,GAE/CnM,KAAK,SAAUoM,GACfpM,KAAK,aAAckJ,M","file":"main.1388aad346.mjs","sourcesContent":["/**\n * Our default sum is the [Kahan-Babuska algorithm](https://pdfs.semanticscholar.org/1760/7d467cda1d0277ad272deb2113533131dc09.pdf).\n * This method is an improvement over the classical\n * [Kahan summation algorithm](https://en.wikipedia.org/wiki/Kahan_summation_algorithm).\n * It aims at computing the sum of a list of numbers while correcting for\n * floating-point errors. Traditionally, sums are calculated as many\n * successive additions, each one with its own floating-point roundoff. These\n * losses in precision add up as the number of numbers increases. This alternative\n * algorithm is more accurate than the simple way of calculating sums by simple\n * addition.\n *\n * This runs on `O(n)`, linear time in respect to the array.\n *\n * @param {Array<number>} x input\n * @return {number} sum of all input numbers\n * @example\n * sum([1, 2, 3]); // => 6\n */\nfunction sum(x) {\n    // If the array is empty, we needn't bother computing its sum\n    if (x.length === 0) {\n        return 0;\n    }\n\n    // Initializing the sum as the first number in the array\n    let sum = x[0];\n\n    // Keeping track of the floating-point error correction\n    let correction = 0;\n\n    let transition;\n\n    for (let i = 1; i < x.length; i++) {\n        transition = sum + x[i];\n\n        // Here we need to update the correction in a different fashion\n        // if the new absolute value is greater than the absolute sum\n        if (Math.abs(sum) >= Math.abs(x[i])) {\n            correction += sum - transition + x[i];\n        } else {\n            correction += x[i] - transition + sum;\n        }\n\n        sum = transition;\n    }\n\n    // Returning the corrected sum\n    return sum + correction;\n}\n\nexport default sum;\n","import sum from \"./sum\";\n\n/**\n * The mean, _also known as average_,\n * is the sum of all values over the number of values.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs on `O(n)`, linear time in respect to the array\n *\n * @param {Array<number>} x sample of one or more data points\n * @throws {Error} if the the length of x is less than one\n * @returns {number} mean\n * @example\n * mean([0, 10]); // => 5\n */\nfunction mean(x) {\n    // The mean of no numbers is null\n    if (x.length === 0) {\n        throw new Error(\"mean requires at least one data point\");\n    }\n\n    return sum(x) / x.length;\n}\n\nexport default mean;\n","import mean from \"./mean\";\n\n/**\n * The sum of deviations to the Nth power.\n * When n=2 it's the sum of squared deviations.\n * When n=3 it's the sum of cubed deviations.\n *\n * @param {Array<number>} x\n * @param {number} n power\n * @returns {number} sum of nth power deviations\n *\n * @example\n * var input = [1, 2, 3];\n * // since the variance of a set is the mean squared\n * // deviations, we can calculate that with sumNthPowerDeviations:\n * sumNthPowerDeviations(input, 2) / input.length;\n */\nfunction sumNthPowerDeviations(x, n) {\n    const meanValue = mean(x);\n    let sum = 0;\n    let tempValue;\n    let i;\n\n    // This is an optimization: when n is 2 (we're computing a number squared),\n    // multiplying the number by itself is significantly faster than using\n    // the Math.pow method.\n    if (n === 2) {\n        for (i = 0; i < x.length; i++) {\n            tempValue = x[i] - meanValue;\n            sum += tempValue * tempValue;\n        }\n    } else {\n        for (i = 0; i < x.length; i++) {\n            sum += Math.pow(x[i] - meanValue, n);\n        }\n    }\n\n    return sum;\n}\n\nexport default sumNthPowerDeviations;\n","import sumNthPowerDeviations from \"./sum_nth_power_deviations\";\n\n/**\n * The [variance](http://en.wikipedia.org/wiki/Variance)\n * is the sum of squared deviations from the mean.\n *\n * This is an implementation of variance, not sample variance:\n * see the `sampleVariance` method if you want a sample measure.\n *\n * @param {Array<number>} x a population of one or more data points\n * @returns {number} variance: a value greater than or equal to zero.\n * zero indicates that all values are identical.\n * @throws {Error} if x's length is 0\n * @example\n * variance([1, 2, 3, 4, 5, 6]); // => 2.9166666666666665\n */\nfunction variance(x) {\n    // The variance of no numbers is null\n    if (x.length === 0) {\n        throw new Error(\"variance requires at least one data point\");\n    }\n\n    // Find the mean of squared deviations between the\n    // mean value and each value.\n    return sumNthPowerDeviations(x, 2) / x.length;\n}\n\nexport default variance;\n","import variance from \"./variance\";\n\n/**\n * The [standard deviation](http://en.wikipedia.org/wiki/Standard_deviation)\n * is the square root of the variance. This is also known as the population\n * standard deviation. It's useful for measuring the amount\n * of variation or dispersion in a set of values.\n *\n * Standard deviation is only appropriate for full-population knowledge: for\n * samples of a population, {@link sampleStandardDeviation} is\n * more appropriate.\n *\n * @param {Array<number>} x input\n * @returns {number} standard deviation\n * @example\n * variance([2, 4, 4, 4, 5, 5, 7, 9]); // => 4\n * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // => 2\n */\nfunction standardDeviation(x) {\n    if (x.length === 1) {\n        return 0;\n    }\n    const v = variance(x);\n    return Math.sqrt(v);\n}\n\nexport default standardDeviation;\n","/**\n * The [mode](http://bit.ly/W5K4Yt) is the number that appears in a list the highest number of times.\n * There can be multiple modes in a list: in the event of a tie, this\n * algorithm will return the most recently seen mode.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs in `O(n)` because the input is sorted.\n *\n * @param {Array<number>} sorted a sample of one or more data points\n * @returns {number} mode\n * @throws {Error} if sorted is empty\n * @example\n * modeSorted([0, 0, 1]); // => 0\n */\nfunction modeSorted(sorted) {\n    // Handle edge cases:\n    // The mode of an empty list is undefined\n    if (sorted.length === 0) {\n        throw new Error(\"mode requires at least one data point\");\n    } else if (sorted.length === 1) {\n        return sorted[0];\n    }\n\n    // This assumes it is dealing with an array of size > 1, since size\n    // 0 and 1 are handled immediately. Hence it starts at index 1 in the\n    // array.\n    let last = sorted[0],\n        // store the mode as we find new modes\n        value = NaN,\n        // store how many times we've seen the mode\n        maxSeen = 0,\n        // how many times the current candidate for the mode\n        // has been seen\n        seenThis = 1;\n\n    // end at sorted.length + 1 to fix the case in which the mode is\n    // the highest number that occurs in the sequence. the last iteration\n    // compares sorted[i], which is undefined, to the highest number\n    // in the series\n    for (let i = 1; i < sorted.length + 1; i++) {\n        // we're seeing a new number pass by\n        if (sorted[i] !== last) {\n            // the last number is the new mode since we saw it more\n            // often than the old one\n            if (seenThis > maxSeen) {\n                maxSeen = seenThis;\n                value = last;\n            }\n            seenThis = 1;\n            last = sorted[i];\n            // if this isn't a new number, it's one more occurrence of\n            // the potential mode\n        } else {\n            seenThis++;\n        }\n    }\n    return value;\n}\n\nexport default modeSorted;\n","/**\n * Sort an array of numbers by their numeric value, ensuring that the\n * array is not changed in place.\n *\n * This is necessary because the default behavior of .sort\n * in JavaScript is to sort arrays as string values\n *\n *     [1, 10, 12, 102, 20].sort()\n *     // output\n *     [1, 10, 102, 12, 20]\n *\n * @param {Array<number>} x input array\n * @return {Array<number>} sorted array\n * @private\n * @example\n * numericSort([3, 2, 1]) // => [1, 2, 3]\n */\nfunction numericSort(x) {\n    return (\n        x\n            // ensure the array is not changed in-place\n            .slice()\n            // comparator function that treats input as numeric\n            .sort(function(a, b) {\n                return a - b;\n            })\n    );\n}\n\nexport default numericSort;\n","/**\n * The min is the lowest number in the array. This runs on `O(n)`, linear time in respect to the array\n *\n * @param {Array<number>} x sample of one or more data points\n * @throws {Error} if the the length of x is less than one\n * @returns {number} minimum value\n * @example\n * min([1, 5, -10, 100, 2]); // => -10\n */\nfunction min(x) {\n    if (x.length === 0) {\n        throw new Error(\"min requires at least one data point\");\n    }\n\n    let value = x[0];\n    for (let i = 1; i < x.length; i++) {\n        // On the first iteration of this loop, min is\n        // undefined and is thus made the minimum element in the array\n        if (x[i] < value) {\n            value = x[i];\n        }\n    }\n    return value;\n}\n\nexport default min;\n","/**\n * This computes the maximum number in an array.\n *\n * This runs on `O(n)`, linear time in respect to the array\n *\n * @param {Array<number>} x sample of one or more data points\n * @returns {number} maximum value\n * @throws {Error} if the the length of x is less than one\n * @example\n * max([1, 2, 3, 4]);\n * // => 4\n */\nfunction max(x) {\n    if (x.length === 0) {\n        throw new Error(\"max requires at least one data point\");\n    }\n\n    let value = x[0];\n    for (let i = 1; i < x.length; i++) {\n        // On the first iteration of this loop, max is\n        // undefined and is thus made the maximum element in the array\n        if (x[i] > value) {\n            value = x[i];\n        }\n    }\n    return value;\n}\n\nexport default max;\n","/**\n * This is the internal implementation of quantiles: when you know\n * that the order is sorted, you don't need to re-sort it, and the computations\n * are faster.\n *\n * @param {Array<number>} x sample of one or more data points\n * @param {number} p desired quantile: a number between 0 to 1, inclusive\n * @returns {number} quantile value\n * @throws {Error} if p ix outside of the range from 0 to 1\n * @throws {Error} if x is empty\n * @example\n * quantileSorted([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9\n */\nfunction quantileSorted(x, p) {\n    const idx = x.length * p;\n    if (x.length === 0) {\n        throw new Error(\"quantile requires at least one data point.\");\n    } else if (p < 0 || p > 1) {\n        throw new Error(\"quantiles must be between 0 and 1\");\n    } else if (p === 1) {\n        // If p is 1, directly return the last element\n        return x[x.length - 1];\n    } else if (p === 0) {\n        // If p is 0, directly return the first element\n        return x[0];\n    } else if (idx % 1 !== 0) {\n        // If p is not integer, return the next element in array\n        return x[Math.ceil(idx) - 1];\n    } else if (x.length % 2 === 0) {\n        // If the list has even-length, we'll take the average of this number\n        // and the next value, if there is one\n        return (x[idx - 1] + x[idx]) / 2;\n    } else {\n        // Finally, in the simple case of an integer value\n        // with an odd-length list, return the x value at the index.\n        return x[idx];\n    }\n}\n\nexport default quantileSorted;\n","/**\n * Rearrange items in `arr` so that all items in `[left, k]` range are the smallest.\n * The `k`-th element will have the `(k - left + 1)`-th smallest value in `[left, right]`.\n *\n * Implements Floyd-Rivest selection algorithm https://en.wikipedia.org/wiki/Floyd-Rivest_algorithm\n *\n * @param {Array<number>} arr input array\n * @param {number} k pivot index\n * @param {number} [left] left index\n * @param {number} [right] right index\n * @returns {void} mutates input array\n * @example\n * var arr = [65, 28, 59, 33, 21, 56, 22, 95, 50, 12, 90, 53, 28, 77, 39];\n * quickselect(arr, 8);\n * // = [39, 28, 28, 33, 21, 12, 22, 50, 53, 56, 59, 65, 90, 77, 95]\n */\nfunction quickselect(arr, k, left, right) {\n    left = left || 0;\n    right = right || arr.length - 1;\n\n    while (right > left) {\n        // 600 and 0.5 are arbitrary constants chosen in the original paper to minimize execution time\n        if (right - left > 600) {\n            const n = right - left + 1;\n            const m = k - left + 1;\n            const z = Math.log(n);\n            const s = 0.5 * Math.exp((2 * z) / 3);\n            let sd = 0.5 * Math.sqrt((z * s * (n - s)) / n);\n            if (m - n / 2 < 0) sd *= -1;\n            const newLeft = Math.max(left, Math.floor(k - (m * s) / n + sd));\n            const newRight = Math.min(\n                right,\n                Math.floor(k + ((n - m) * s) / n + sd)\n            );\n            quickselect(arr, k, newLeft, newRight);\n        }\n\n        const t = arr[k];\n        let i = left;\n        let j = right;\n\n        swap(arr, left, k);\n        if (arr[right] > t) swap(arr, left, right);\n\n        while (i < j) {\n            swap(arr, i, j);\n            i++;\n            j--;\n            while (arr[i] < t) i++;\n            while (arr[j] > t) j--;\n        }\n\n        if (arr[left] === t) swap(arr, left, j);\n        else {\n            j++;\n            swap(arr, j, right);\n        }\n\n        if (j <= k) left = j + 1;\n        if (k <= j) right = j - 1;\n    }\n}\n\nfunction swap(arr, i, j) {\n    const tmp = arr[i];\n    arr[i] = arr[j];\n    arr[j] = tmp;\n}\n\nexport default quickselect;\n","import quantileSorted from \"./quantile_sorted\";\nimport quickselect from \"./quickselect\";\n\n/**\n * The [quantile](https://en.wikipedia.org/wiki/Quantile):\n * this is a population quantile, since we assume to know the entire\n * dataset in this library. This is an implementation of the\n * [Quantiles of a Population](http://en.wikipedia.org/wiki/Quantile#Quantiles_of_a_population)\n * algorithm from wikipedia.\n *\n * Sample is a one-dimensional array of numbers,\n * and p is either a decimal number from 0 to 1 or an array of decimal\n * numbers from 0 to 1.\n * In terms of a k/q quantile, p = k/q - it's just dealing with fractions or dealing\n * with decimal values.\n * When p is an array, the result of the function is also an array containing the appropriate\n * quantiles in input order\n *\n * @param {Array<number>} x sample of one or more numbers\n * @param {Array<number> | number} p the desired quantile, as a number between 0 and 1\n * @returns {number} quantile\n * @example\n * quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9\n */\nfunction quantile(x, p) {\n    const copy = x.slice();\n\n    if (Array.isArray(p)) {\n        // rearrange elements so that each element corresponding to a requested\n        // quantile is on a place it would be if the array was fully sorted\n        multiQuantileSelect(copy, p);\n        // Initialize the result array\n        const results = [];\n        // For each requested quantile\n        for (let i = 0; i < p.length; i++) {\n            results[i] = quantileSorted(copy, p[i]);\n        }\n        return results;\n    } else {\n        const idx = quantileIndex(copy.length, p);\n        quantileSelect(copy, idx, 0, copy.length - 1);\n        return quantileSorted(copy, p);\n    }\n}\n\nfunction quantileSelect(arr, k, left, right) {\n    if (k % 1 === 0) {\n        quickselect(arr, k, left, right);\n    } else {\n        k = Math.floor(k);\n        quickselect(arr, k, left, right);\n        quickselect(arr, k + 1, k + 1, right);\n    }\n}\n\nfunction multiQuantileSelect(arr, p) {\n    const indices = [0];\n    for (let i = 0; i < p.length; i++) {\n        indices.push(quantileIndex(arr.length, p[i]));\n    }\n    indices.push(arr.length - 1);\n    indices.sort(compare);\n\n    const stack = [0, indices.length - 1];\n\n    while (stack.length) {\n        const r = Math.ceil(stack.pop());\n        const l = Math.floor(stack.pop());\n        if (r - l <= 1) continue;\n\n        const m = Math.floor((l + r) / 2);\n        quantileSelect(\n            arr,\n            indices[m],\n            Math.floor(indices[l]),\n            Math.ceil(indices[r])\n        );\n\n        stack.push(l, m, m, r);\n    }\n}\n\nfunction compare(a, b) {\n    return a - b;\n}\n\nfunction quantileIndex(len, p) {\n    const idx = len * p;\n    if (p === 1) {\n        // If p is 1, directly return the last index\n        return len - 1;\n    } else if (p === 0) {\n        // If p is 0, directly return the first index\n        return 0;\n    } else if (idx % 1 !== 0) {\n        // If index is not integer, return the next index in array\n        return Math.ceil(idx) - 1;\n    } else if (len % 2 === 0) {\n        // If the list has even-length, we'll return the middle of two indices\n        // around quantile to indicate that we need an average value of the two\n        return idx - 0.5;\n    } else {\n        // Finally, in the simple case of an integer index\n        // with an odd-length list, return the index\n        return idx;\n    }\n}\n\nexport default quantile;\n","/* eslint no-bitwise: 0 */\n\n/**\n * This function returns the quantile in which one would find the given value in\n * the given array. With a sorted array, leveraging binary search, we can find\n * this information in logarithmic time.\n *\n * @param {Array<number>} x input\n * @returns {number} value value\n * @example\n * quantileRankSorted([1, 2, 3, 4], 3); // => 0.75\n * quantileRankSorted([1, 2, 3, 3, 4], 3); // => 0.7\n * quantileRankSorted([1, 2, 3, 4], 6); // => 1\n * quantileRankSorted([1, 2, 3, 3, 5], 4); // => 0.8\n */\nfunction quantileRankSorted(x, value) {\n    // Value is lesser than any value in the array\n    if (value < x[0]) {\n        return 0;\n    }\n\n    // Value is greater than any value in the array\n    if (value > x[x.length - 1]) {\n        return 1;\n    }\n\n    let l = lowerBound(x, value);\n\n    // Value is not in the array\n    if (x[l] !== value) {\n        return l / x.length;\n    }\n\n    l++;\n\n    const u = upperBound(x, value);\n\n    // The value exists only once in the array\n    if (u === l) {\n        return l / x.length;\n    }\n\n    // Here, we are basically computing the mean of the range of indices\n    // containing our searched value. But, instead, of initializing an\n    // array and looping over it, there is a dedicated math formula that\n    // we apply below to get the result.\n    const r = u - l + 1;\n    const sum = (r * (u + l)) / 2;\n    const mean = sum / r;\n\n    return mean / x.length;\n}\n\nfunction lowerBound(x, value) {\n    let mid = 0;\n    let lo = 0;\n    let hi = x.length;\n\n    while (lo < hi) {\n        mid = (lo + hi) >>> 1;\n\n        if (value <= x[mid]) {\n            hi = mid;\n        } else {\n            lo = -~mid;\n        }\n    }\n\n    return lo;\n}\n\nfunction upperBound(x, value) {\n    let mid = 0;\n    let lo = 0;\n    let hi = x.length;\n\n    while (lo < hi) {\n        mid = (lo + hi) >>> 1;\n\n        if (value >= x[mid]) {\n            lo = -~mid;\n        } else {\n            hi = mid;\n        }\n    }\n\n    return lo;\n}\n\nexport default quantileRankSorted;\n","import quantile from \"./quantile\";\n\n/**\n * The [Interquartile range](http://en.wikipedia.org/wiki/Interquartile_range) is\n * a measure of statistical dispersion, or how scattered, spread, or\n * concentrated a distribution is. It's computed as the difference between\n * the third quartile and first quartile.\n *\n * @param {Array<number>} x sample of one or more numbers\n * @returns {number} interquartile range: the span between lower and upper quartile,\n * 0.25 and 0.75\n * @example\n * interquartileRange([0, 1, 2, 3]); // => 2\n */\nfunction interquartileRange(x) {\n    // Interquartile range is the span between the upper quartile,\n    // at `0.75`, and lower quartile, `0.25`\n    const q1 = quantile(x, 0.75);\n    const q2 = quantile(x, 0.25);\n\n    if (typeof q1 === \"number\" && typeof q2 === \"number\") {\n        return q1 - q2;\n    }\n}\n\nexport default interquartileRange;\n","import quantile from \"./quantile\";\n\n/**\n * The [median](http://en.wikipedia.org/wiki/Median) is\n * the middle number of a list. This is often a good indicator of 'the middle'\n * when there are outliers that skew the `mean()` value.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * The median isn't necessarily one of the elements in the list: the value\n * can be the average of two elements if the list has an even length\n * and the two central values are different.\n *\n * @param {Array<number>} x input\n * @returns {number} median value\n * @example\n * median([10, 2, 5, 100, 2, 1]); // => 3.5\n */\nfunction median(x) {\n    return +quantile(x, 0.5);\n}\n\nexport default median;\n","import median from \"./median\";\n\n/**\n * The [Median Absolute Deviation](http://en.wikipedia.org/wiki/Median_absolute_deviation) is\n * a robust measure of statistical\n * dispersion. It is more resilient to outliers than the standard deviation.\n *\n * @param {Array<number>} x input array\n * @returns {number} median absolute deviation\n * @example\n * medianAbsoluteDeviation([1, 1, 2, 2, 4, 6, 9]); // => 1\n */\nfunction medianAbsoluteDeviation(x) {\n    // The mad of nothing is null\n    const medianValue = median(x);\n    const medianAbsoluteDeviations = [];\n\n    // Make a list of absolute deviations from the median\n    for (let i = 0; i < x.length; i++) {\n        medianAbsoluteDeviations.push(Math.abs(x[i] - medianValue));\n    }\n\n    // Find the median value of that list\n    return median(medianAbsoluteDeviations);\n}\n\nexport default medianAbsoluteDeviation;\n","/**\n * A [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)\n * in-place - which means that it **will change the order of the original\n * array by reference**.\n *\n * This is an algorithm that generates a random [permutation](https://en.wikipedia.org/wiki/Permutation)\n * of a set.\n *\n * @param {Array} x sample of one or more numbers\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @returns {Array} x\n * @example\n * var x = [1, 2, 3, 4];\n * shuffleInPlace(x);\n * // x is shuffled to a value like [2, 1, 4, 3]\n */\nfunction shuffleInPlace(x, randomSource) {\n    // a custom random number source can be provided if you want to use\n    // a fixed seed or another random number generator, like\n    // [random-js](https://www.npmjs.org/package/random-js)\n    randomSource = randomSource || Math.random;\n\n    // store the current length of the x to determine\n    // when no elements remain to shuffle.\n    let length = x.length;\n\n    // temporary is used to hold an item when it is being\n    // swapped between indices.\n    let temporary;\n\n    // The index to swap at each stage.\n    let index;\n\n    // While there are still items to shuffle\n    while (length > 0) {\n        // chose a random index within the subset of the array\n        // that is not yet shuffled\n        index = Math.floor(randomSource() * length--);\n\n        // store the value that we'll move temporarily\n        temporary = x[length];\n\n        // swap the value at `x[length]` with `x[index]`\n        x[length] = x[index];\n        x[index] = temporary;\n    }\n\n    return x;\n}\n\nexport default shuffleInPlace;\n","import shuffleInPlace from \"./shuffle_in_place\";\n\n/**\n * A [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)\n * is a fast way to create a random permutation of a finite set. This is\n * a function around `shuffle_in_place` that adds the guarantee that\n * it will not modify its input.\n *\n * @param {Array} x sample of 0 or more numbers\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @return {Array} shuffled version of input\n * @example\n * var shuffled = shuffle([1, 2, 3, 4]);\n * shuffled; // = [2, 3, 1, 4] or any other random permutation\n */\nfunction shuffle(x, randomSource) {\n    // slice the original array so that it is not modified\n    const sample = x.slice();\n\n    // and then shuffle that shallow-copied array, in place\n    return shuffleInPlace(sample.slice(), randomSource);\n}\n\nexport default shuffle;\n","/**\n * For a sorted input, counting the number of unique values\n * is possible in constant time and constant memory. This is\n * a simple implementation of the algorithm.\n *\n * Values are compared with `===`, so objects and non-primitive objects\n * are not handled in any special way.\n *\n * @param {Array<*>} x an array of any kind of value\n * @returns {number} count of unique values\n * @example\n * uniqueCountSorted([1, 2, 3]); // => 3\n * uniqueCountSorted([1, 1, 1]); // => 1\n */\nfunction uniqueCountSorted(x) {\n    let uniqueValueCount = 0,\n        lastSeenValue;\n    for (let i = 0; i < x.length; i++) {\n        if (i === 0 || x[i] !== lastSeenValue) {\n            lastSeenValue = x[i];\n            uniqueValueCount++;\n        }\n    }\n    return uniqueValueCount;\n}\n\nexport default uniqueCountSorted;\n","import numericSort from \"./numeric_sort\";\nimport uniqueCountSorted from \"./unique_count_sorted\";\n\n/**\n * Create a new column x row matrix.\n *\n * @private\n * @param {number} columns\n * @param {number} rows\n * @return {Array<Array<number>>} matrix\n * @example\n * makeMatrix(10, 10);\n */\nfunction makeMatrix(columns, rows) {\n    const matrix = [];\n    for (let i = 0; i < columns; i++) {\n        const column = [];\n        for (let j = 0; j < rows; j++) {\n            column.push(0);\n        }\n        matrix.push(column);\n    }\n    return matrix;\n}\n\n/**\n * Generates incrementally computed values based on the sums and sums of\n * squares for the data array\n *\n * @private\n * @param {number} j\n * @param {number} i\n * @param {Array<number>} sums\n * @param {Array<number>} sumsOfSquares\n * @return {number}\n * @example\n * ssq(0, 1, [-1, 0, 2], [1, 1, 5]);\n */\nfunction ssq(j, i, sums, sumsOfSquares) {\n    let sji; // s(j, i)\n    if (j > 0) {\n        const muji = (sums[i] - sums[j - 1]) / (i - j + 1); // mu(j, i)\n        sji =\n            sumsOfSquares[i] - sumsOfSquares[j - 1] - (i - j + 1) * muji * muji;\n    } else {\n        sji = sumsOfSquares[i] - (sums[i] * sums[i]) / (i + 1);\n    }\n    if (sji < 0) {\n        return 0;\n    }\n    return sji;\n}\n\n/**\n * Function that recursively divides and conquers computations\n * for cluster j\n *\n * @private\n * @param {number} iMin Minimum index in cluster to be computed\n * @param {number} iMax Maximum index in cluster to be computed\n * @param {number} cluster Index of the cluster currently being computed\n * @param {Array<Array<number>>} matrix\n * @param {Array<Array<number>>} backtrackMatrix\n * @param {Array<number>} sums\n * @param {Array<number>} sumsOfSquares\n */\nfunction fillMatrixColumn(\n    iMin,\n    iMax,\n    cluster,\n    matrix,\n    backtrackMatrix,\n    sums,\n    sumsOfSquares\n) {\n    if (iMin > iMax) {\n        return;\n    }\n\n    // Start at midpoint between iMin and iMax\n    const i = Math.floor((iMin + iMax) / 2);\n\n    matrix[cluster][i] = matrix[cluster - 1][i - 1];\n    backtrackMatrix[cluster][i] = i;\n\n    let jlow = cluster; // the lower end for j\n\n    if (iMin > cluster) {\n        jlow = Math.max(jlow, backtrackMatrix[cluster][iMin - 1] || 0);\n    }\n    jlow = Math.max(jlow, backtrackMatrix[cluster - 1][i] || 0);\n\n    let jhigh = i - 1; // the upper end for j\n    if (iMax < matrix.length - 1) {\n        jhigh = Math.min(jhigh, backtrackMatrix[cluster][iMax + 1] || 0);\n    }\n\n    let sji;\n    let sjlowi;\n    let ssqjlow;\n    let ssqj;\n    for (let j = jhigh; j >= jlow; --j) {\n        sji = ssq(j, i, sums, sumsOfSquares);\n\n        if (sji + matrix[cluster - 1][jlow - 1] >= matrix[cluster][i]) {\n            break;\n        }\n\n        // Examine the lower bound of the cluster border\n        sjlowi = ssq(jlow, i, sums, sumsOfSquares);\n\n        ssqjlow = sjlowi + matrix[cluster - 1][jlow - 1];\n\n        if (ssqjlow < matrix[cluster][i]) {\n            // Shrink the lower bound\n            matrix[cluster][i] = ssqjlow;\n            backtrackMatrix[cluster][i] = jlow;\n        }\n        jlow++;\n\n        ssqj = sji + matrix[cluster - 1][j - 1];\n        if (ssqj < matrix[cluster][i]) {\n            matrix[cluster][i] = ssqj;\n            backtrackMatrix[cluster][i] = j;\n        }\n    }\n\n    fillMatrixColumn(\n        iMin,\n        i - 1,\n        cluster,\n        matrix,\n        backtrackMatrix,\n        sums,\n        sumsOfSquares\n    );\n    fillMatrixColumn(\n        i + 1,\n        iMax,\n        cluster,\n        matrix,\n        backtrackMatrix,\n        sums,\n        sumsOfSquares\n    );\n}\n\n/**\n * Initializes the main matrices used in Ckmeans and kicks\n * off the divide and conquer cluster computation strategy\n *\n * @private\n * @param {Array<number>} data sorted array of values\n * @param {Array<Array<number>>} matrix\n * @param {Array<Array<number>>} backtrackMatrix\n */\nfunction fillMatrices(data, matrix, backtrackMatrix) {\n    const nValues = matrix[0].length;\n\n    // Shift values by the median to improve numeric stability\n    const shift = data[Math.floor(nValues / 2)];\n\n    // Cumulative sum and cumulative sum of squares for all values in data array\n    const sums = [];\n    const sumsOfSquares = [];\n\n    // Initialize first column in matrix & backtrackMatrix\n    for (let i = 0, shiftedValue; i < nValues; ++i) {\n        shiftedValue = data[i] - shift;\n        if (i === 0) {\n            sums.push(shiftedValue);\n            sumsOfSquares.push(shiftedValue * shiftedValue);\n        } else {\n            sums.push(sums[i - 1] + shiftedValue);\n            sumsOfSquares.push(\n                sumsOfSquares[i - 1] + shiftedValue * shiftedValue\n            );\n        }\n\n        // Initialize for cluster = 0\n        matrix[0][i] = ssq(0, i, sums, sumsOfSquares);\n        backtrackMatrix[0][i] = 0;\n    }\n\n    // Initialize the rest of the columns\n    let iMin;\n    for (let cluster = 1; cluster < matrix.length; ++cluster) {\n        if (cluster < matrix.length - 1) {\n            iMin = cluster;\n        } else {\n            // No need to compute matrix[K-1][0] ... matrix[K-1][N-2]\n            iMin = nValues - 1;\n        }\n\n        fillMatrixColumn(\n            iMin,\n            nValues - 1,\n            cluster,\n            matrix,\n            backtrackMatrix,\n            sums,\n            sumsOfSquares\n        );\n    }\n}\n\n/**\n * Ckmeans clustering is an improvement on heuristic-based clustering\n * approaches like Jenks. The algorithm was developed in\n * [Haizhou Wang and Mingzhou Song](http://journal.r-project.org/archive/2011-2/RJournal_2011-2_Wang+Song.pdf)\n * as a [dynamic programming](https://en.wikipedia.org/wiki/Dynamic_programming) approach\n * to the problem of clustering numeric data into groups with the least\n * within-group sum-of-squared-deviations.\n *\n * Minimizing the difference within groups - what Wang & Song refer to as\n * `withinss`, or within sum-of-squares, means that groups are optimally\n * homogenous within and the data is split into representative groups.\n * This is very useful for visualization, where you may want to represent\n * a continuous variable in discrete color or style groups. This function\n * can provide groups that emphasize differences between data.\n *\n * Being a dynamic approach, this algorithm is based on two matrices that\n * store incrementally-computed values for squared deviations and backtracking\n * indexes.\n *\n * This implementation is based on Ckmeans 3.4.6, which introduced a new divide\n * and conquer approach that improved runtime from O(kn^2) to O(kn log(n)).\n *\n * Unlike the [original implementation](https://cran.r-project.org/web/packages/Ckmeans.1d.dp/index.html),\n * this implementation does not include any code to automatically determine\n * the optimal number of clusters: this information needs to be explicitly\n * provided.\n *\n * ### References\n * _Ckmeans.1d.dp: Optimal k-means Clustering in One Dimension by Dynamic\n * Programming_ Haizhou Wang and Mingzhou Song ISSN 2073-4859\n *\n * from The R Journal Vol. 3/2, December 2011\n * @param {Array<number>} x input data, as an array of number values\n * @param {number} nClusters number of desired classes. This cannot be\n * greater than the number of values in the data array.\n * @returns {Array<Array<number>>} clustered input\n * @throws {Error} if the number of requested clusters is higher than the size of the data\n * @example\n * ckmeans([-1, 2, -1, 2, 4, 5, 6, -1, 2, -1], 3);\n * // The input, clustered into groups of similar numbers.\n * //= [[-1, -1, -1, -1], [2, 2, 2], [4, 5, 6]]);\n */\nfunction ckmeans(x, nClusters) {\n    if (nClusters > x.length) {\n        throw new Error(\n            \"cannot generate more classes than there are data values\"\n        );\n    }\n\n    const sorted = numericSort(x);\n    // we'll use this as the maximum number of clusters\n    const uniqueCount = uniqueCountSorted(sorted);\n\n    // if all of the input values are identical, there's one cluster\n    // with all of the input in it.\n    if (uniqueCount === 1) {\n        return [sorted];\n    }\n\n    // named 'S' originally\n    const matrix = makeMatrix(nClusters, sorted.length);\n    // named 'J' originally\n    const backtrackMatrix = makeMatrix(nClusters, sorted.length);\n\n    // This is a dynamic programming way to solve the problem of minimizing\n    // within-cluster sum of squares. It's similar to linear regression\n    // in this way, and this calculation incrementally computes the\n    // sum of squares that are later read.\n    fillMatrices(sorted, matrix, backtrackMatrix);\n\n    // The real work of Ckmeans clustering happens in the matrix generation:\n    // the generated matrices encode all possible clustering combinations, and\n    // once they're generated we can solve for the best clustering groups\n    // very quickly.\n    const clusters = [];\n    let clusterRight = backtrackMatrix[0].length - 1;\n\n    // Backtrack the clusters from the dynamic programming matrix. This\n    // starts at the bottom-right corner of the matrix (if the top-left is 0, 0),\n    // and moves the cluster target with the loop.\n    for (let cluster = backtrackMatrix.length - 1; cluster >= 0; cluster--) {\n        const clusterLeft = backtrackMatrix[cluster][clusterRight];\n\n        // fill the cluster from the sorted input by taking a slice of the\n        // array. the backtrack matrix makes this easy - it stores the\n        // indexes where the cluster should start and end.\n        clusters[cluster] = sorted.slice(clusterLeft, clusterRight + 1);\n\n        if (cluster > 0) {\n            clusterRight = clusterLeft - 1;\n        }\n    }\n\n    return clusters;\n}\n\nexport default ckmeans;\n","import mean from \"./mean\";\n\n/**\n * [Sample covariance](https://en.wikipedia.org/wiki/Sample_mean_and_sampleCovariance) of two datasets:\n * how much do the two datasets move together?\n * x and y are two datasets, represented as arrays of numbers.\n *\n * @param {Array<number>} x a sample of two or more data points\n * @param {Array<number>} y a sample of two or more data points\n * @throws {Error} if x and y do not have equal lengths\n * @throws {Error} if x or y have length of one or less\n * @returns {number} sample covariance\n * @example\n * sampleCovariance([1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]); // => -3.5\n */\nfunction sampleCovariance(x, y) {\n    // The two datasets must have the same length which must be more than 1\n    if (x.length !== y.length) {\n        throw new Error(\"sampleCovariance requires samples with equal lengths\");\n    }\n\n    if (x.length < 2) {\n        throw new Error(\n            \"sampleCovariance requires at least two data points in each sample\"\n        );\n    }\n\n    // determine the mean of each dataset so that we can judge each\n    // value of the dataset fairly as the difference from the mean. this\n    // way, if one dataset is [1, 2, 3] and [2, 3, 4], their covariance\n    // does not suffer because of the difference in absolute values\n    const xmean = mean(x);\n    const ymean = mean(y);\n    let sum = 0;\n\n    // for each pair of values, the covariance increases when their\n    // difference from the mean is associated - if both are well above\n    // or if both are well below\n    // the mean, the covariance increases significantly.\n    for (let i = 0; i < x.length; i++) {\n        sum += (x[i] - xmean) * (y[i] - ymean);\n    }\n\n    // this is Bessels' Correction: an adjustment made to sample statistics\n    // that allows for the reduced degree of freedom entailed in calculating\n    // values from samples rather than complete populations.\n    const besselsCorrection = x.length - 1;\n\n    // the covariance is weighted by the length of the datasets.\n    return sum / besselsCorrection;\n}\n\nexport default sampleCovariance;\n","import sumNthPowerDeviations from \"./sum_nth_power_deviations\";\n\n/**\n * The [sample variance](https://en.wikipedia.org/wiki/Variance#Sample_variance)\n * is the sum of squared deviations from the mean. The sample variance\n * is distinguished from the variance by the usage of [Bessel's Correction](https://en.wikipedia.org/wiki/Bessel's_correction):\n * instead of dividing the sum of squared deviations by the length of the input,\n * it is divided by the length minus one. This corrects the bias in estimating\n * a value from a set that you don't know if full.\n *\n * References:\n * * [Wolfram MathWorld on Sample Variance](http://mathworld.wolfram.com/SampleVariance.html)\n *\n * @param {Array<number>} x a sample of two or more data points\n * @throws {Error} if the length of x is less than 2\n * @return {number} sample variance\n * @example\n * sampleVariance([1, 2, 3, 4, 5]); // => 2.5\n */\nfunction sampleVariance(x) {\n    // The variance of no numbers is null\n    if (x.length < 2) {\n        throw new Error(\"sampleVariance requires at least two data points\");\n    }\n\n    const sumSquaredDeviationsValue = sumNthPowerDeviations(x, 2);\n\n    // this is Bessels' Correction: an adjustment made to sample statistics\n    // that allows for the reduced degree of freedom entailed in calculating\n    // values from samples rather than complete populations.\n    const besselsCorrection = x.length - 1;\n\n    // Find the mean value of that list\n    return sumSquaredDeviationsValue / besselsCorrection;\n}\n\nexport default sampleVariance;\n","import sampleVariance from \"./sample_variance\";\n\n/**\n * The [sample standard deviation](http://en.wikipedia.org/wiki/Standard_deviation#Sample_standard_deviation)\n * is the square root of the sample variance.\n *\n * @param {Array<number>} x input array\n * @returns {number} sample standard deviation\n * @example\n * sampleStandardDeviation([2, 4, 4, 4, 5, 5, 7, 9]).toFixed(2);\n * // => '2.14'\n */\nfunction sampleStandardDeviation(x) {\n    // The standard deviation of no numbers is null\n    const sampleVarianceX = sampleVariance(x);\n    return Math.sqrt(sampleVarianceX);\n}\n\nexport default sampleStandardDeviation;\n","/**\n * When combining two lists of values for which one already knows the means,\n * one does not have to necessary recompute the mean of the combined lists in\n * linear time. They can instead use this function to compute the combined\n * mean by providing the mean & number of values of the first list and the mean\n * & number of values of the second list.\n *\n * @since 3.0.0\n * @param {number} mean1 mean of the first list\n * @param {number} n1 number of items in the first list\n * @param {number} mean2 mean of the second list\n * @param {number} n2 number of items in the second list\n * @returns {number} the combined mean\n *\n * @example\n * combineMeans(5, 3, 4, 3); // => 4.5\n */\nfunction combineMeans(mean1, n1, mean2, n2) {\n    return (mean1 * n1 + mean2 * n2) / (n1 + n2);\n}\n\nexport default combineMeans;\n","/**\n * The Root Mean Square (RMS) is\n * a mean function used as a measure of the magnitude of a set\n * of numbers, regardless of their sign.\n * This is the square root of the mean of the squares of the\n * input numbers.\n * This runs on `O(n)`, linear time in respect to the array\n *\n * @param {Array<number>} x a sample of one or more data points\n * @returns {number} root mean square\n * @throws {Error} if x is empty\n * @example\n * rootMeanSquare([-1, 1, -1, 1]); // => 1\n */\nfunction rootMeanSquare(x) {\n    if (x.length === 0) {\n        throw new Error(\"rootMeanSquare requires at least one data point\");\n    }\n\n    let sumOfSquares = 0;\n    for (let i = 0; i < x.length; i++) {\n        sumOfSquares += Math.pow(x[i], 2);\n    }\n\n    return Math.sqrt(sumOfSquares / x.length);\n}\n\nexport default rootMeanSquare;\n","/**\n * [Bayesian Classifier](http://en.wikipedia.org/wiki/Naive_Bayes_classifier)\n *\n * This is a naïve bayesian classifier that takes\n * singly-nested objects.\n *\n * @class\n * @example\n * var bayes = new BayesianClassifier();\n * bayes.train({\n *   species: 'Cat'\n * }, 'animal');\n * var result = bayes.score({\n *   species: 'Cat'\n * })\n * // result\n * // {\n * //   animal: 1\n * // }\n */\nclass BayesianClassifier {\n    /*:: totalCount: number */\n    /*:: data: Object */\n    constructor() {\n        // The number of items that are currently\n        // classified in the model\n        this.totalCount = 0;\n        // Every item classified in the model\n        this.data = {};\n    }\n\n    /**\n     * Train the classifier with a new item, which has a single\n     * dimension of Javascript literal keys and values.\n     *\n     * @param {Object} item an object with singly-deep properties\n     * @param {string} category the category this item belongs to\n     * @return {undefined} adds the item to the classifier\n     */\n    train(item, category) {\n        // If the data object doesn't have any values\n        // for this category, create a new object for it.\n        if (!this.data[category]) {\n            this.data[category] = {};\n        }\n\n        // Iterate through each key in the item.\n        for (const k in item) {\n            const v = item[k];\n            // Initialize the nested object `data[category][k][item[k]]`\n            // with an object of keys that equal 0.\n            if (this.data[category][k] === undefined) {\n                this.data[category][k] = {};\n            }\n            if (this.data[category][k][v] === undefined) {\n                this.data[category][k][v] = 0;\n            }\n\n            // And increment the key for this key/value combination.\n            this.data[category][k][v]++;\n        }\n\n        // Increment the number of items classified\n        this.totalCount++;\n    }\n\n    /**\n     * Generate a score of how well this item matches all\n     * possible categories based on its attributes\n     *\n     * @param {Object} item an item in the same format as with train\n     * @returns {Object} of probabilities that this item belongs to a\n     * given category.\n     */\n    score(item) {\n        // Initialize an empty array of odds per category.\n        const odds = {};\n        let category;\n        // Iterate through each key in the item,\n        // then iterate through each category that has been used\n        // in previous calls to `.train()`\n        for (const k in item) {\n            const v = item[k];\n            for (category in this.data) {\n                // Create an empty object for storing key - value combinations\n                // for this category.\n                odds[category] = {};\n\n                // If this item doesn't even have a property, it counts for nothing,\n                // but if it does have the property that we're looking for from\n                // the item to categorize, it counts based on how popular it is\n                // versus the whole population.\n                if (this.data[category][k]) {\n                    odds[category][k + \"_\" + v] =\n                        (this.data[category][k][v] || 0) / this.totalCount;\n                } else {\n                    odds[category][k + \"_\" + v] = 0;\n                }\n            }\n        }\n\n        // Set up a new object that will contain sums of these odds by category\n        const oddsSums = {};\n\n        for (category in odds) {\n            // Tally all of the odds for each category-combination pair -\n            // the non-existence of a category does not add anything to the\n            // score.\n            oddsSums[category] = 0;\n            for (const combination in odds[category]) {\n                oddsSums[category] += odds[category][combination];\n            }\n        }\n\n        return oddsSums;\n    }\n}\n\nexport default BayesianClassifier;\n","/**\n * This is a single-layer [Perceptron Classifier](http://en.wikipedia.org/wiki/Perceptron) that takes\n * arrays of numbers and predicts whether they should be classified\n * as either 0 or 1 (negative or positive examples).\n * @class\n * @example\n * // Create the model\n * var p = new PerceptronModel();\n * // Train the model with input with a diagonal boundary.\n * for (var i = 0; i < 5; i++) {\n *     p.train([1, 1], 1);\n *     p.train([0, 1], 0);\n *     p.train([1, 0], 0);\n *     p.train([0, 0], 0);\n * }\n * p.predict([0, 0]); // 0\n * p.predict([0, 1]); // 0\n * p.predict([1, 0]); // 0\n * p.predict([1, 1]); // 1\n */\nclass PerceptronModel {\n    /*:: bias: number */\n    /*:: weights: Array<number> */\n    constructor() {\n        // The weights, or coefficients of the model;\n        // weights are only populated when training with data.\n        this.weights = [];\n        // The bias term, or intercept; it is also a weight but\n        // it's stored separately for convenience as it is always\n        // multiplied by one.\n        this.bias = 0;\n    }\n    /**\n     * **Predict**: Use an array of features with the weight array and bias\n     * to predict whether an example is labeled 0 or 1.\n     *\n     * @param {Array<number>} features an array of features as numbers\n     * @returns {number} 1 if the score is over 0, otherwise 0\n     */\n    predict(features) {\n        // Only predict if previously trained\n        // on the same size feature array(s).\n        if (features.length !== this.weights.length) {\n            return null;\n        }\n\n        // Calculate the sum of features times weights,\n        // with the bias added (implicitly times one).\n        let score = 0;\n        for (let i = 0; i < this.weights.length; i++) {\n            score += this.weights[i] * features[i];\n        }\n        score += this.bias;\n\n        // Classify as 1 if the score is over 0, otherwise 0.\n        if (score > 0) {\n            return 1;\n        } else {\n            return 0;\n        }\n    }\n\n    /**\n     * **Train** the classifier with a new example, which is\n     * a numeric array of features and a 0 or 1 label.\n     *\n     * @param {Array<number>} features an array of features as numbers\n     * @param {number} label either 0 or 1\n     * @returns {PerceptronModel} this\n     */\n    train(features, label) {\n        // Require that only labels of 0 or 1 are considered.\n        if (label !== 0 && label !== 1) {\n            return null;\n        }\n        // The length of the feature array determines\n        // the length of the weight array.\n        // The perceptron will continue learning as long as\n        // it keeps seeing feature arrays of the same length.\n        // When it sees a new data shape, it initializes.\n        if (features.length !== this.weights.length) {\n            this.weights = features;\n            this.bias = 1;\n        }\n        // Make a prediction based on current weights.\n        const prediction = this.predict(features);\n        // Update the weights if the prediction is wrong.\n        if (typeof prediction === \"number\" && prediction !== label) {\n            const gradient = label - prediction;\n            for (let i = 0; i < this.weights.length; i++) {\n                this.weights[i] += gradient * features[i];\n            }\n            this.bias += gradient;\n        }\n        return this;\n    }\n}\n\nexport default PerceptronModel;\n","/**\n * A [Factorial](https://en.wikipedia.org/wiki/Factorial), usually written n!, is the product of all positive\n * integers less than or equal to n. Often factorial is implemented\n * recursively, but this iterative approach is significantly faster\n * and simpler.\n *\n * @param {number} n input, must be an integer number 1 or greater\n * @returns {number} factorial: n!\n * @throws {Error} if n is less than 0 or not an integer\n * @example\n * factorial(5); // => 120\n */\nfunction factorial(n) {\n    // factorial is mathematically undefined for negative numbers\n    if (n < 0) {\n        throw new Error(\"factorial requires a non-negative value\");\n    }\n\n    if (Math.floor(n) !== n) {\n        throw new Error(\"factorial requires an integer input\");\n    }\n\n    // typically you'll expand the factorial function going down, like\n    // 5! = 5 * 4 * 3 * 2 * 1. This is going in the opposite direction,\n    // counting from 2 up to the number in question, and since anything\n    // multiplied by 1 is itself, the loop only needs to start at 2.\n    let accumulator = 1;\n    for (let i = 2; i <= n; i++) {\n        // for each number up to and including the number `n`, multiply\n        // the accumulator my that number.\n        accumulator *= i;\n    }\n    return accumulator;\n}\n\nexport default factorial;\n","// Define series coefficients\nconst COEFFICIENTS = [\n    0.99999999999999709182,\n    57.156235665862923517,\n    -59.597960355475491248,\n    14.136097974741747174,\n    -0.49191381609762019978,\n    0.33994649984811888699e-4,\n    0.46523628927048575665e-4,\n    -0.98374475304879564677e-4,\n    0.15808870322491248884e-3,\n    -0.21026444172410488319e-3,\n    0.2174396181152126432e-3,\n    -0.16431810653676389022e-3,\n    0.84418223983852743293e-4,\n    -0.2619083840158140867e-4,\n    0.36899182659531622704e-5\n];\n\nconst g = 607 / 128;\nconst LOGSQRT2PI = Math.log(Math.sqrt(2 * Math.PI));\n\n/**\n * Compute the logarithm of the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) of a value using Lanczos' approximation.\n * This function takes as input any real-value n greater than 0.\n * This function is useful for values of n too large for the normal gamma function (n > 165).\n * The code is based on Lanczo's Gamma approximation, defined [here](http://my.fit.edu/~gabdo/gamma.txt).\n *\n * @param {number} n Any real number greater than zero.\n * @returns {number} The logarithm of gamma of the input value.\n *\n * @example\n * gammaln(500); // 2605.1158503617335\n * gammaln(2.4); // 0.21685932244884043\n */\nfunction gammaln(n) {\n    // Return infinity if value not in domain\n    if (n <= 0) {\n        return Infinity;\n    }\n\n    // Decrement n, because approximation is defined for n - 1\n    n--;\n\n    // Create series approximation\n    let a = COEFFICIENTS[0];\n\n    for (let i = 1; i < 15; i++) {\n        a += COEFFICIENTS[i] / (n + i);\n    }\n\n    const tmp = g + 0.5 + n;\n\n    // Return natural logarithm of gamma(n)\n    return LOGSQRT2PI + Math.log(a) - tmp + (n + 0.5) * Math.log(tmp);\n}\n\nexport default gammaln;\n","/**\n * **Percentage Points of the χ2 (Chi-Squared) Distribution**\n *\n * The [χ2 (Chi-Squared) Distribution](http://en.wikipedia.org/wiki/Chi-squared_distribution) is used in the common\n * chi-squared tests for goodness of fit of an observed distribution to a theoretical one, the independence of two\n * criteria of classification of qualitative data, and in confidence interval estimation for a population standard\n * deviation of a normal distribution from a sample standard deviation.\n *\n * Values from Appendix 1, Table III of William W. Hines & Douglas C. Montgomery, \"Probability and Statistics in\n * Engineering and Management Science\", Wiley (1980).\n */\nconst chiSquaredDistributionTable = {\n    \"1\": {\n        \"0.995\": 0,\n        \"0.99\": 0,\n        \"0.975\": 0,\n        \"0.95\": 0,\n        \"0.9\": 0.02,\n        \"0.5\": 0.45,\n        \"0.1\": 2.71,\n        \"0.05\": 3.84,\n        \"0.025\": 5.02,\n        \"0.01\": 6.63,\n        \"0.005\": 7.88\n    },\n    \"2\": {\n        \"0.995\": 0.01,\n        \"0.99\": 0.02,\n        \"0.975\": 0.05,\n        \"0.95\": 0.1,\n        \"0.9\": 0.21,\n        \"0.5\": 1.39,\n        \"0.1\": 4.61,\n        \"0.05\": 5.99,\n        \"0.025\": 7.38,\n        \"0.01\": 9.21,\n        \"0.005\": 10.6\n    },\n    \"3\": {\n        \"0.995\": 0.07,\n        \"0.99\": 0.11,\n        \"0.975\": 0.22,\n        \"0.95\": 0.35,\n        \"0.9\": 0.58,\n        \"0.5\": 2.37,\n        \"0.1\": 6.25,\n        \"0.05\": 7.81,\n        \"0.025\": 9.35,\n        \"0.01\": 11.34,\n        \"0.005\": 12.84\n    },\n    \"4\": {\n        \"0.995\": 0.21,\n        \"0.99\": 0.3,\n        \"0.975\": 0.48,\n        \"0.95\": 0.71,\n        \"0.9\": 1.06,\n        \"0.5\": 3.36,\n        \"0.1\": 7.78,\n        \"0.05\": 9.49,\n        \"0.025\": 11.14,\n        \"0.01\": 13.28,\n        \"0.005\": 14.86\n    },\n    \"5\": {\n        \"0.995\": 0.41,\n        \"0.99\": 0.55,\n        \"0.975\": 0.83,\n        \"0.95\": 1.15,\n        \"0.9\": 1.61,\n        \"0.5\": 4.35,\n        \"0.1\": 9.24,\n        \"0.05\": 11.07,\n        \"0.025\": 12.83,\n        \"0.01\": 15.09,\n        \"0.005\": 16.75\n    },\n    \"6\": {\n        \"0.995\": 0.68,\n        \"0.99\": 0.87,\n        \"0.975\": 1.24,\n        \"0.95\": 1.64,\n        \"0.9\": 2.2,\n        \"0.5\": 5.35,\n        \"0.1\": 10.65,\n        \"0.05\": 12.59,\n        \"0.025\": 14.45,\n        \"0.01\": 16.81,\n        \"0.005\": 18.55\n    },\n    \"7\": {\n        \"0.995\": 0.99,\n        \"0.99\": 1.25,\n        \"0.975\": 1.69,\n        \"0.95\": 2.17,\n        \"0.9\": 2.83,\n        \"0.5\": 6.35,\n        \"0.1\": 12.02,\n        \"0.05\": 14.07,\n        \"0.025\": 16.01,\n        \"0.01\": 18.48,\n        \"0.005\": 20.28\n    },\n    \"8\": {\n        \"0.995\": 1.34,\n        \"0.99\": 1.65,\n        \"0.975\": 2.18,\n        \"0.95\": 2.73,\n        \"0.9\": 3.49,\n        \"0.5\": 7.34,\n        \"0.1\": 13.36,\n        \"0.05\": 15.51,\n        \"0.025\": 17.53,\n        \"0.01\": 20.09,\n        \"0.005\": 21.96\n    },\n    \"9\": {\n        \"0.995\": 1.73,\n        \"0.99\": 2.09,\n        \"0.975\": 2.7,\n        \"0.95\": 3.33,\n        \"0.9\": 4.17,\n        \"0.5\": 8.34,\n        \"0.1\": 14.68,\n        \"0.05\": 16.92,\n        \"0.025\": 19.02,\n        \"0.01\": 21.67,\n        \"0.005\": 23.59\n    },\n    \"10\": {\n        \"0.995\": 2.16,\n        \"0.99\": 2.56,\n        \"0.975\": 3.25,\n        \"0.95\": 3.94,\n        \"0.9\": 4.87,\n        \"0.5\": 9.34,\n        \"0.1\": 15.99,\n        \"0.05\": 18.31,\n        \"0.025\": 20.48,\n        \"0.01\": 23.21,\n        \"0.005\": 25.19\n    },\n    \"11\": {\n        \"0.995\": 2.6,\n        \"0.99\": 3.05,\n        \"0.975\": 3.82,\n        \"0.95\": 4.57,\n        \"0.9\": 5.58,\n        \"0.5\": 10.34,\n        \"0.1\": 17.28,\n        \"0.05\": 19.68,\n        \"0.025\": 21.92,\n        \"0.01\": 24.72,\n        \"0.005\": 26.76\n    },\n    \"12\": {\n        \"0.995\": 3.07,\n        \"0.99\": 3.57,\n        \"0.975\": 4.4,\n        \"0.95\": 5.23,\n        \"0.9\": 6.3,\n        \"0.5\": 11.34,\n        \"0.1\": 18.55,\n        \"0.05\": 21.03,\n        \"0.025\": 23.34,\n        \"0.01\": 26.22,\n        \"0.005\": 28.3\n    },\n    \"13\": {\n        \"0.995\": 3.57,\n        \"0.99\": 4.11,\n        \"0.975\": 5.01,\n        \"0.95\": 5.89,\n        \"0.9\": 7.04,\n        \"0.5\": 12.34,\n        \"0.1\": 19.81,\n        \"0.05\": 22.36,\n        \"0.025\": 24.74,\n        \"0.01\": 27.69,\n        \"0.005\": 29.82\n    },\n    \"14\": {\n        \"0.995\": 4.07,\n        \"0.99\": 4.66,\n        \"0.975\": 5.63,\n        \"0.95\": 6.57,\n        \"0.9\": 7.79,\n        \"0.5\": 13.34,\n        \"0.1\": 21.06,\n        \"0.05\": 23.68,\n        \"0.025\": 26.12,\n        \"0.01\": 29.14,\n        \"0.005\": 31.32\n    },\n    \"15\": {\n        \"0.995\": 4.6,\n        \"0.99\": 5.23,\n        \"0.975\": 6.27,\n        \"0.95\": 7.26,\n        \"0.9\": 8.55,\n        \"0.5\": 14.34,\n        \"0.1\": 22.31,\n        \"0.05\": 25,\n        \"0.025\": 27.49,\n        \"0.01\": 30.58,\n        \"0.005\": 32.8\n    },\n    \"16\": {\n        \"0.995\": 5.14,\n        \"0.99\": 5.81,\n        \"0.975\": 6.91,\n        \"0.95\": 7.96,\n        \"0.9\": 9.31,\n        \"0.5\": 15.34,\n        \"0.1\": 23.54,\n        \"0.05\": 26.3,\n        \"0.025\": 28.85,\n        \"0.01\": 32,\n        \"0.005\": 34.27\n    },\n    \"17\": {\n        \"0.995\": 5.7,\n        \"0.99\": 6.41,\n        \"0.975\": 7.56,\n        \"0.95\": 8.67,\n        \"0.9\": 10.09,\n        \"0.5\": 16.34,\n        \"0.1\": 24.77,\n        \"0.05\": 27.59,\n        \"0.025\": 30.19,\n        \"0.01\": 33.41,\n        \"0.005\": 35.72\n    },\n    \"18\": {\n        \"0.995\": 6.26,\n        \"0.99\": 7.01,\n        \"0.975\": 8.23,\n        \"0.95\": 9.39,\n        \"0.9\": 10.87,\n        \"0.5\": 17.34,\n        \"0.1\": 25.99,\n        \"0.05\": 28.87,\n        \"0.025\": 31.53,\n        \"0.01\": 34.81,\n        \"0.005\": 37.16\n    },\n    \"19\": {\n        \"0.995\": 6.84,\n        \"0.99\": 7.63,\n        \"0.975\": 8.91,\n        \"0.95\": 10.12,\n        \"0.9\": 11.65,\n        \"0.5\": 18.34,\n        \"0.1\": 27.2,\n        \"0.05\": 30.14,\n        \"0.025\": 32.85,\n        \"0.01\": 36.19,\n        \"0.005\": 38.58\n    },\n    \"20\": {\n        \"0.995\": 7.43,\n        \"0.99\": 8.26,\n        \"0.975\": 9.59,\n        \"0.95\": 10.85,\n        \"0.9\": 12.44,\n        \"0.5\": 19.34,\n        \"0.1\": 28.41,\n        \"0.05\": 31.41,\n        \"0.025\": 34.17,\n        \"0.01\": 37.57,\n        \"0.005\": 40\n    },\n    \"21\": {\n        \"0.995\": 8.03,\n        \"0.99\": 8.9,\n        \"0.975\": 10.28,\n        \"0.95\": 11.59,\n        \"0.9\": 13.24,\n        \"0.5\": 20.34,\n        \"0.1\": 29.62,\n        \"0.05\": 32.67,\n        \"0.025\": 35.48,\n        \"0.01\": 38.93,\n        \"0.005\": 41.4\n    },\n    \"22\": {\n        \"0.995\": 8.64,\n        \"0.99\": 9.54,\n        \"0.975\": 10.98,\n        \"0.95\": 12.34,\n        \"0.9\": 14.04,\n        \"0.5\": 21.34,\n        \"0.1\": 30.81,\n        \"0.05\": 33.92,\n        \"0.025\": 36.78,\n        \"0.01\": 40.29,\n        \"0.005\": 42.8\n    },\n    \"23\": {\n        \"0.995\": 9.26,\n        \"0.99\": 10.2,\n        \"0.975\": 11.69,\n        \"0.95\": 13.09,\n        \"0.9\": 14.85,\n        \"0.5\": 22.34,\n        \"0.1\": 32.01,\n        \"0.05\": 35.17,\n        \"0.025\": 38.08,\n        \"0.01\": 41.64,\n        \"0.005\": 44.18\n    },\n    \"24\": {\n        \"0.995\": 9.89,\n        \"0.99\": 10.86,\n        \"0.975\": 12.4,\n        \"0.95\": 13.85,\n        \"0.9\": 15.66,\n        \"0.5\": 23.34,\n        \"0.1\": 33.2,\n        \"0.05\": 36.42,\n        \"0.025\": 39.36,\n        \"0.01\": 42.98,\n        \"0.005\": 45.56\n    },\n    \"25\": {\n        \"0.995\": 10.52,\n        \"0.99\": 11.52,\n        \"0.975\": 13.12,\n        \"0.95\": 14.61,\n        \"0.9\": 16.47,\n        \"0.5\": 24.34,\n        \"0.1\": 34.28,\n        \"0.05\": 37.65,\n        \"0.025\": 40.65,\n        \"0.01\": 44.31,\n        \"0.005\": 46.93\n    },\n    \"26\": {\n        \"0.995\": 11.16,\n        \"0.99\": 12.2,\n        \"0.975\": 13.84,\n        \"0.95\": 15.38,\n        \"0.9\": 17.29,\n        \"0.5\": 25.34,\n        \"0.1\": 35.56,\n        \"0.05\": 38.89,\n        \"0.025\": 41.92,\n        \"0.01\": 45.64,\n        \"0.005\": 48.29\n    },\n    \"27\": {\n        \"0.995\": 11.81,\n        \"0.99\": 12.88,\n        \"0.975\": 14.57,\n        \"0.95\": 16.15,\n        \"0.9\": 18.11,\n        \"0.5\": 26.34,\n        \"0.1\": 36.74,\n        \"0.05\": 40.11,\n        \"0.025\": 43.19,\n        \"0.01\": 46.96,\n        \"0.005\": 49.65\n    },\n    \"28\": {\n        \"0.995\": 12.46,\n        \"0.99\": 13.57,\n        \"0.975\": 15.31,\n        \"0.95\": 16.93,\n        \"0.9\": 18.94,\n        \"0.5\": 27.34,\n        \"0.1\": 37.92,\n        \"0.05\": 41.34,\n        \"0.025\": 44.46,\n        \"0.01\": 48.28,\n        \"0.005\": 50.99\n    },\n    \"29\": {\n        \"0.995\": 13.12,\n        \"0.99\": 14.26,\n        \"0.975\": 16.05,\n        \"0.95\": 17.71,\n        \"0.9\": 19.77,\n        \"0.5\": 28.34,\n        \"0.1\": 39.09,\n        \"0.05\": 42.56,\n        \"0.025\": 45.72,\n        \"0.01\": 49.59,\n        \"0.005\": 52.34\n    },\n    \"30\": {\n        \"0.995\": 13.79,\n        \"0.99\": 14.95,\n        \"0.975\": 16.79,\n        \"0.95\": 18.49,\n        \"0.9\": 20.6,\n        \"0.5\": 29.34,\n        \"0.1\": 40.26,\n        \"0.05\": 43.77,\n        \"0.025\": 46.98,\n        \"0.01\": 50.89,\n        \"0.005\": 53.67\n    },\n    \"40\": {\n        \"0.995\": 20.71,\n        \"0.99\": 22.16,\n        \"0.975\": 24.43,\n        \"0.95\": 26.51,\n        \"0.9\": 29.05,\n        \"0.5\": 39.34,\n        \"0.1\": 51.81,\n        \"0.05\": 55.76,\n        \"0.025\": 59.34,\n        \"0.01\": 63.69,\n        \"0.005\": 66.77\n    },\n    \"50\": {\n        \"0.995\": 27.99,\n        \"0.99\": 29.71,\n        \"0.975\": 32.36,\n        \"0.95\": 34.76,\n        \"0.9\": 37.69,\n        \"0.5\": 49.33,\n        \"0.1\": 63.17,\n        \"0.05\": 67.5,\n        \"0.025\": 71.42,\n        \"0.01\": 76.15,\n        \"0.005\": 79.49\n    },\n    \"60\": {\n        \"0.995\": 35.53,\n        \"0.99\": 37.48,\n        \"0.975\": 40.48,\n        \"0.95\": 43.19,\n        \"0.9\": 46.46,\n        \"0.5\": 59.33,\n        \"0.1\": 74.4,\n        \"0.05\": 79.08,\n        \"0.025\": 83.3,\n        \"0.01\": 88.38,\n        \"0.005\": 91.95\n    },\n    \"70\": {\n        \"0.995\": 43.28,\n        \"0.99\": 45.44,\n        \"0.975\": 48.76,\n        \"0.95\": 51.74,\n        \"0.9\": 55.33,\n        \"0.5\": 69.33,\n        \"0.1\": 85.53,\n        \"0.05\": 90.53,\n        \"0.025\": 95.02,\n        \"0.01\": 100.42,\n        \"0.005\": 104.22\n    },\n    \"80\": {\n        \"0.995\": 51.17,\n        \"0.99\": 53.54,\n        \"0.975\": 57.15,\n        \"0.95\": 60.39,\n        \"0.9\": 64.28,\n        \"0.5\": 79.33,\n        \"0.1\": 96.58,\n        \"0.05\": 101.88,\n        \"0.025\": 106.63,\n        \"0.01\": 112.33,\n        \"0.005\": 116.32\n    },\n    \"90\": {\n        \"0.995\": 59.2,\n        \"0.99\": 61.75,\n        \"0.975\": 65.65,\n        \"0.95\": 69.13,\n        \"0.9\": 73.29,\n        \"0.5\": 89.33,\n        \"0.1\": 107.57,\n        \"0.05\": 113.14,\n        \"0.025\": 118.14,\n        \"0.01\": 124.12,\n        \"0.005\": 128.3\n    },\n    \"100\": {\n        \"0.995\": 67.33,\n        \"0.99\": 70.06,\n        \"0.975\": 74.22,\n        \"0.95\": 77.93,\n        \"0.9\": 82.36,\n        \"0.5\": 99.33,\n        \"0.1\": 118.5,\n        \"0.05\": 124.34,\n        \"0.025\": 129.56,\n        \"0.01\": 135.81,\n        \"0.005\": 140.17\n    }\n};\n\nexport default chiSquaredDistributionTable;\n","import interquartileRange from \"./interquartile_range\";\nimport stddev from \"./sample_standard_deviation\";\n\nconst SQRT_2PI = Math.sqrt(2 * Math.PI);\n\n/**\n * [Well-known kernels](https://en.wikipedia.org/wiki/Kernel_(statistics)#Kernel_functions_in_common_use)\n * @private\n */\nconst kernels = {\n    /**\n     * The gaussian kernel.\n     * @private\n     */\n    gaussian: function(u) {\n        return Math.exp(-0.5 * u * u) / SQRT_2PI;\n    }\n};\n\n/**\n * Well known bandwidth selection methods\n * @private\n */\nconst bandwidthMethods = {\n    /**\n     * The [\"normal reference distribution\"\n     * rule-of-thumb](https://stat.ethz.ch/R-manual/R-devel/library/MASS/html/bandwidth.nrd.html),\n     * a commonly used version of [Silverman's\n     * rule-of-thumb](https://en.wikipedia.org/wiki/Kernel_density_estimation#A_rule-of-thumb_bandwidth_estimator).\n     * @private\n     */\n    nrd: function(x) {\n        let s = stddev(x);\n        const iqr = interquartileRange(x);\n        if (typeof iqr === \"number\") {\n            s = Math.min(s, iqr / 1.34);\n        }\n        return 1.06 * s * Math.pow(x.length, -0.2);\n    }\n};\n\n/**\n * [Kernel density estimation](https://en.wikipedia.org/wiki/Kernel_density_estimation)\n * is a useful tool for, among other things, estimating the shape of the\n * underlying probability distribution from a sample.\n *\n * @name kernelDensityEstimation\n * @param X sample values\n * @param kernel The kernel function to use. If a function is provided, it should return non-negative values and integrate to 1. Defaults to 'gaussian'.\n * @param bandwidthMethod The \"bandwidth selection\" method to use, or a fixed bandwidth value. Defaults to \"nrd\", the commonly-used [\"normal reference distribution\" rule-of-thumb](https://stat.ethz.ch/R-manual/R-devel/library/MASS/html/bandwidth.nrd.html).\n * @returns {Function} An estimated [probability density function](https://en.wikipedia.org/wiki/Probability_density_function) for the given sample. The returned function runs in `O(X.length)`.\n */\nfunction kernelDensityEstimation(X, kernel, bandwidthMethod) {\n    let kernelFn;\n    if (kernel === undefined) {\n        kernelFn = kernels.gaussian;\n    } else if (typeof kernel === \"string\") {\n        if (!kernels[kernel]) {\n            throw new Error('Unknown kernel \"' + kernel + '\"');\n        }\n        kernelFn = kernels[kernel];\n    } else {\n        kernelFn = kernel;\n    }\n\n    let bandwidth;\n    if (typeof bandwidthMethod === \"undefined\") {\n        bandwidth = bandwidthMethods.nrd(X);\n    } else if (typeof bandwidthMethod === \"string\") {\n        if (!bandwidthMethods[bandwidthMethod]) {\n            throw new Error(\n                'Unknown bandwidth method \"' + bandwidthMethod + '\"'\n            );\n        }\n        bandwidth = bandwidthMethods[bandwidthMethod](X);\n    } else {\n        bandwidth = bandwidthMethod;\n    }\n\n    return function(x) {\n        let i = 0;\n        let sum = 0;\n        for (i = 0; i < X.length; i++) {\n            sum += kernelFn((x - X[i]) / bandwidth);\n        }\n        return sum / bandwidth / X.length;\n    };\n}\n\nexport default kernelDensityEstimation;\n","const SQRT_2PI = Math.sqrt(2 * Math.PI);\n\nfunction cumulativeDistribution(z) {\n    let sum = z,\n        tmp = z;\n\n    // 15 iterations are enough for 4-digit precision\n    for (let i = 1; i < 15; i++) {\n        tmp *= (z * z) / (2 * i + 1);\n        sum += tmp;\n    }\n    return (\n        Math.round((0.5 + (sum / SQRT_2PI) * Math.exp((-z * z) / 2)) * 1e4) /\n        1e4\n    );\n}\n\n/**\n * A standard normal table, also called the unit normal table or Z table,\n * is a mathematical table for the values of Φ (phi), which are the values of\n * the cumulative distribution function of the normal distribution.\n * It is used to find the probability that a statistic is observed below,\n * above, or between values on the standard normal distribution, and by\n * extension, any normal distribution.\n *\n * The probabilities are calculated using the\n * [Cumulative distribution function](https://en.wikipedia.org/wiki/Normal_distribution#Cumulative_distribution_function).\n * The table used is the cumulative, and not cumulative from 0 to mean\n * (even though the latter has 5 digits precision, instead of 4).\n */\nconst standardNormalTable = [];\n\nfor (let z = 0; z <= 3.09; z += 0.01) {\n    standardNormalTable.push(cumulativeDistribution(z));\n}\n\nexport default standardNormalTable;\n","/**\n * **[Gaussian error function](http://en.wikipedia.org/wiki/Error_function)**\n *\n * The `errorFunction(x/(sd * Math.sqrt(2)))` is the probability that a value in a\n * normal distribution with standard deviation sd is within x of the mean.\n *\n * This function returns a numerical approximation to the exact value.\n * It uses Horner's method to evaluate the polynomial of τ (tau).\n *\n * @param {number} x input\n * @return {number} error estimation\n * @example\n * errorFunction(1).toFixed(2); // => '0.84'\n */\nfunction errorFunction(x) {\n    const t = 1 / (1 + 0.5 * Math.abs(x));\n    const tau =\n        t *\n        Math.exp(\n            -x * x +\n                ((((((((0.17087277 * t - 0.82215223) * t + 1.48851587) * t -\n                    1.13520398) *\n                    t +\n                    0.27886807) *\n                    t -\n                    0.18628806) *\n                    t +\n                    0.09678418) *\n                    t +\n                    0.37409196) *\n                    t +\n                    1.00002368) *\n                    t -\n                1.26551223\n        );\n    if (x >= 0) {\n        return 1 - tau;\n    } else {\n        return tau - 1;\n    }\n}\n\nexport default errorFunction;\n","/**\n * The Inverse [Gaussian error function](http://en.wikipedia.org/wiki/Error_function)\n * returns a numerical approximation to the value that would have caused\n * `errorFunction()` to return x.\n *\n * @param {number} x value of error function\n * @returns {number} estimated inverted value\n */\nfunction inverseErrorFunction(x) {\n    const a = (8 * (Math.PI - 3)) / (3 * Math.PI * (4 - Math.PI));\n\n    const inv = Math.sqrt(\n        Math.sqrt(\n            Math.pow(2 / (Math.PI * a) + Math.log(1 - x * x) / 2, 2) -\n                Math.log(1 - x * x) / a\n        ) -\n            (2 / (Math.PI * a) + Math.log(1 - x * x) / 2)\n    );\n\n    if (x >= 0) {\n        return inv;\n    } else {\n        return -inv;\n    }\n}\n\nexport default inverseErrorFunction;\n","/**\n * [Sign](https://en.wikipedia.org/wiki/Sign_function) is a function\n * that extracts the sign of a real number\n *\n * @param {number} x input value\n * @returns {number} sign value either 1, 0 or -1\n * @throws {TypeError} if the input argument x is not a number\n * @private\n *\n * @example\n * sign(2); // => 1\n */\nfunction sign(x) {\n    if (typeof x === \"number\") {\n        if (x < 0) {\n            return -1;\n        } else if (x === 0) {\n            return 0;\n        } else {\n            return 1;\n        }\n    } else {\n        throw new TypeError(\"not a number\");\n    }\n}\n\nexport default sign;\n","/**\n * When adding a new value to a list, one does not have to necessary\n * recompute the mean of the list in linear time. They can instead use\n * this function to compute the new mean by providing the current mean,\n * the number of elements in the list that produced it and the new\n * value to add.\n *\n * @since 2.5.0\n * @param {number} mean current mean\n * @param {number} n number of items in the list\n * @param {number} newValue the added value\n * @returns {number} the new mean\n *\n * @example\n * addToMean(14, 5, 53); // => 20.5\n */\nfunction addToMean(mean, n, newValue) {\n    return mean + (newValue - mean) / (n + 1);\n}\n\nexport default addToMean;\n","/**\n * The [Bernoulli distribution](http://en.wikipedia.org/wiki/Bernoulli_distribution)\n * is the probability discrete\n * distribution of a random variable which takes value 1 with success\n * probability `p` and value 0 with failure\n * probability `q` = 1 - `p`. It can be used, for example, to represent the\n * toss of a coin, where \"1\" is defined to mean \"heads\" and \"0\" is defined\n * to mean \"tails\" (or vice versa). It is\n * a special case of a Binomial Distribution\n * where `n` = 1.\n *\n * @param {number} p input value, between 0 and 1 inclusive\n * @returns {number[]} values of bernoulli distribution at this point\n * @throws {Error} if p is outside 0 and 1\n * @example\n * bernoulliDistribution(0.3); // => [0.7, 0.3]\n */\nfunction bernoulliDistribution(p) /*: number[] */ {\n    // Check that `p` is a valid probability (0 ≤ p ≤ 1)\n    if (p < 0 || p > 1) {\n        throw new Error(\n            \"bernoulliDistribution requires probability to be between 0 and 1 inclusive\"\n        );\n    }\n\n    return [1 - p, p];\n}\n\nexport default bernoulliDistribution;\n","import epsilon from \"./epsilon\";\n\n/**\n * The [Binomial Distribution](http://en.wikipedia.org/wiki/Binomial_distribution) is the discrete probability\n * distribution of the number of successes in a sequence of n independent yes/no experiments, each of which yields\n * success with probability `probability`. Such a success/failure experiment is also called a Bernoulli experiment or\n * Bernoulli trial; when trials = 1, the Binomial Distribution is a Bernoulli Distribution.\n *\n * @param {number} trials number of trials to simulate\n * @param {number} probability\n * @returns {number[]} output\n */\nfunction binomialDistribution(trials, probability) /*: ?number[] */ {\n    // Check that `p` is a valid probability (0 ≤ p ≤ 1),\n    // that `n` is an integer, strictly positive.\n    if (probability < 0 || probability > 1 || trials <= 0 || trials % 1 !== 0) {\n        return undefined;\n    }\n\n    // We initialize `x`, the random variable, and `accumulator`, an accumulator\n    // for the cumulative distribution function to 0. `distribution_functions`\n    // is the object we'll return with the `probability_of_x` and the\n    // `cumulativeProbability_of_x`, as well as the calculated mean &\n    // variance. We iterate until the `cumulativeProbability_of_x` is\n    // within `epsilon` of 1.0.\n    let x = 0;\n    let cumulativeProbability = 0;\n    const cells = [];\n    let binomialCoefficient = 1;\n\n    // This algorithm iterates through each potential outcome,\n    // until the `cumulativeProbability` is very close to 1, at\n    // which point we've defined the vast majority of outcomes\n    do {\n        // a [probability mass function](https://en.wikipedia.org/wiki/Probability_mass_function)\n        cells[x] =\n            binomialCoefficient *\n            Math.pow(probability, x) *\n            Math.pow(1 - probability, trials - x);\n        cumulativeProbability += cells[x];\n        x++;\n        binomialCoefficient = (binomialCoefficient * (trials - x + 1)) / x;\n        // when the cumulativeProbability is nearly 1, we've calculated\n        // the useful range of this distribution\n    } while (cumulativeProbability < 1 - epsilon);\n\n    return cells;\n}\n\nexport default binomialDistribution;\n","import sign from \"./sign\";\n\n/**\n * [Bisection method](https://en.wikipedia.org/wiki/Bisection_method) is a root-finding\n * method that repeatedly bisects an interval to find the root.\n *\n * This function returns a numerical approximation to the exact value.\n *\n * @param {Function} func input function\n * @param {number} start - start of interval\n * @param {number} end - end of interval\n * @param {number} maxIterations - the maximum number of iterations\n * @param {number} errorTolerance - the error tolerance\n * @returns {number} estimated root value\n * @throws {TypeError} Argument func must be a function\n *\n * @example\n * bisect(Math.cos,0,4,100,0.003); // => 1.572265625\n */\nfunction bisect(func, start, end, maxIterations, errorTolerance) {\n    if (typeof func !== \"function\")\n        throw new TypeError(\"func must be a function\");\n\n    for (let i = 0; i < maxIterations; i++) {\n        const output = (start + end) / 2;\n\n        if (\n            func(output) === 0 ||\n            Math.abs((end - start) / 2) < errorTolerance\n        ) {\n            return output;\n        }\n\n        if (sign(func(output)) === sign(func(start))) {\n            start = output;\n        } else {\n            end = output;\n        }\n    }\n\n    throw new Error(\"maximum number of iterations exceeded\");\n}\n\nexport default bisect;\n","import chiSquaredDistributionTable from \"./chi_squared_distribution_table\";\nimport mean from \"./mean\";\n\n/**\n * The [χ2 (Chi-Squared) Goodness-of-Fit Test](http://en.wikipedia.org/wiki/Goodness_of_fit#Pearson.27s_chi-squared_test)\n * uses a measure of goodness of fit which is the sum of differences between observed and expected outcome frequencies\n * (that is, counts of observations), each squared and divided by the number of observations expected given the\n * hypothesized distribution. The resulting χ2 statistic, `chiSquared`, can be compared to the chi-squared distribution\n * to determine the goodness of fit. In order to determine the degrees of freedom of the chi-squared distribution, one\n * takes the total number of observed frequencies and subtracts the number of estimated parameters. The test statistic\n * follows, approximately, a chi-square distribution with (k − c) degrees of freedom where `k` is the number of non-empty\n * cells and `c` is the number of estimated parameters for the distribution.\n *\n * @param {Array<number>} data\n * @param {Function} distributionType a function that returns a point in a distribution:\n * for instance, binomial, bernoulli, or poisson\n * @param {number} significance\n * @returns {number} chi squared goodness of fit\n * @example\n * // Data from Poisson goodness-of-fit example 10-19 in William W. Hines & Douglas C. Montgomery,\n * // \"Probability and Statistics in Engineering and Management Science\", Wiley (1980).\n * var data1019 = [\n *     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n *     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n *     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n *     2, 2, 2, 2, 2, 2, 2, 2, 2,\n *     3, 3, 3, 3\n * ];\n * ss.chiSquaredGoodnessOfFit(data1019, ss.poissonDistribution, 0.05); //= false\n */\nfunction chiSquaredGoodnessOfFit(data, distributionType, significance) {\n    // Estimate from the sample data, a weighted mean.\n    const inputMean = mean(data);\n    // Calculated value of the χ2 statistic.\n    let chiSquared = 0;\n    // Number of hypothesized distribution parameters estimated, expected to be supplied in the distribution test.\n    // Lose one degree of freedom for estimating `lambda` from the sample data.\n    const c = 1;\n    // The hypothesized distribution.\n    // Generate the hypothesized distribution.\n    const hypothesizedDistribution = distributionType(inputMean);\n    const observedFrequencies = [];\n    const expectedFrequencies = [];\n\n    // Create an array holding a histogram from the sample data, of\n    // the form `{ value: numberOfOcurrences }`\n    for (let i = 0; i < data.length; i++) {\n        if (observedFrequencies[data[i]] === undefined) {\n            observedFrequencies[data[i]] = 0;\n        }\n        observedFrequencies[data[i]]++;\n    }\n\n    // The histogram we created might be sparse - there might be gaps\n    // between values. So we iterate through the histogram, making\n    // sure that instead of undefined, gaps have 0 values.\n    for (let i = 0; i < observedFrequencies.length; i++) {\n        if (observedFrequencies[i] === undefined) {\n            observedFrequencies[i] = 0;\n        }\n    }\n\n    // Create an array holding a histogram of expected data given the\n    // sample size and hypothesized distribution.\n    for (const k in hypothesizedDistribution) {\n        if (k in observedFrequencies) {\n            expectedFrequencies[+k] = hypothesizedDistribution[k] * data.length;\n        }\n    }\n\n    // Working backward through the expected frequencies, collapse classes\n    // if less than three observations are expected for a class.\n    // This transformation is applied to the observed frequencies as well.\n    for (let k = expectedFrequencies.length - 1; k >= 0; k--) {\n        if (expectedFrequencies[k] < 3) {\n            expectedFrequencies[k - 1] += expectedFrequencies[k];\n            expectedFrequencies.pop();\n\n            observedFrequencies[k - 1] += observedFrequencies[k];\n            observedFrequencies.pop();\n        }\n    }\n\n    // Iterate through the squared differences between observed & expected\n    // frequencies, accumulating the `chiSquared` statistic.\n    for (let k = 0; k < observedFrequencies.length; k++) {\n        chiSquared +=\n            Math.pow(observedFrequencies[k] - expectedFrequencies[k], 2) /\n            expectedFrequencies[k];\n    }\n\n    // Calculate degrees of freedom for this test and look it up in the\n    // `chiSquaredDistributionTable` in order to\n    // accept or reject the goodness-of-fit of the hypothesized distribution.\n    // Degrees of freedom, calculated as (number of class intervals -\n    // number of hypothesized distribution parameters estimated - 1)\n    const degreesOfFreedom = observedFrequencies.length - c - 1;\n    return (\n        chiSquaredDistributionTable[degreesOfFreedom][significance] < chiSquared\n    );\n}\n\nexport default chiSquaredGoodnessOfFit;\n","/**\n * Split an array into chunks of a specified size. This function\n * has the same behavior as [PHP's array_chunk](http://php.net/manual/en/function.array-chunk.php)\n * function, and thus will insert smaller-sized chunks at the end if\n * the input size is not divisible by the chunk size.\n *\n * `x` is expected to be an array, and `chunkSize` a number.\n * The `x` array can contain any kind of data.\n *\n * @param {Array} x a sample\n * @param {number} chunkSize size of each output array. must be a positive integer\n * @returns {Array<Array>} a chunked array\n * @throws {Error} if chunk size is less than 1 or not an integer\n * @example\n * chunk([1, 2, 3, 4, 5, 6], 2);\n * // => [[1, 2], [3, 4], [5, 6]]\n */\nfunction chunk(x, chunkSize) {\n    // a list of result chunks, as arrays in an array\n    const output = [];\n\n    // `chunkSize` must be zero or higher - otherwise the loop below,\n    // in which we call `start += chunkSize`, will loop infinitely.\n    // So, we'll detect and throw in that case to indicate\n    // invalid input.\n    if (chunkSize < 1) {\n        throw new Error(\"chunk size must be a positive number\");\n    }\n\n    if (Math.floor(chunkSize) !== chunkSize) {\n        throw new Error(\"chunk size must be an integer\");\n    }\n\n    // `start` is the index at which `.slice` will start selecting\n    // new array elements\n    for (let start = 0; start < x.length; start += chunkSize) {\n        // for each chunk, slice that part of the array and add it\n        // to the output. The `.slice` function does not change\n        // the original array.\n        output.push(x.slice(start, start + chunkSize));\n    }\n    return output;\n}\n\nexport default chunk;\n","/**\n * Implementation of Combinations\n * Combinations are unique subsets of a collection - in this case, k x from a collection at a time.\n * https://en.wikipedia.org/wiki/Combination\n * @param {Array} x any type of data\n * @param {int} k the number of objects in each group (without replacement)\n * @returns {Array<Array>} array of permutations\n * @example\n * combinations([1, 2, 3], 2); // => [[1,2], [1,3], [2,3]]\n */\n\nfunction combinations(x, k) {\n    let i;\n    let subI;\n    const combinationList = [];\n    let subsetCombinations;\n    let next;\n\n    for (i = 0; i < x.length; i++) {\n        if (k === 1) {\n            combinationList.push([x[i]]);\n        } else {\n            subsetCombinations = combinations(x.slice(i + 1, x.length), k - 1);\n            for (subI = 0; subI < subsetCombinations.length; subI++) {\n                next = subsetCombinations[subI];\n                next.unshift(x[i]);\n                combinationList.push(next);\n            }\n        }\n    }\n    return combinationList;\n}\n\nexport default combinations;\n","/**\n * Implementation of [Combinations](https://en.wikipedia.org/wiki/Combination) with replacement\n * Combinations are unique subsets of a collection - in this case, k x from a collection at a time.\n * 'With replacement' means that a given element can be chosen multiple times.\n * Unlike permutation, order doesn't matter for combinations.\n *\n * @param {Array} x any type of data\n * @param {int} k the number of objects in each group (without replacement)\n * @returns {Array<Array>} array of permutations\n * @example\n * combinationsReplacement([1, 2], 2); // => [[1, 1], [1, 2], [2, 2]]\n */\nfunction combinationsReplacement(x, k) {\n    const combinationList = [];\n\n    for (let i = 0; i < x.length; i++) {\n        if (k === 1) {\n            // If we're requested to find only one element, we don't need\n            // to recurse: just push `x[i]` onto the list of combinations.\n            combinationList.push([x[i]]);\n        } else {\n            // Otherwise, recursively find combinations, given `k - 1`. Note that\n            // we request `k - 1`, so if you were looking for k=3 combinations, we're\n            // requesting k=2. This -1 gets reversed in the for loop right after this\n            // code, since we concatenate `x[i]` onto the selected combinations,\n            // bringing `k` back up to your requested level.\n            // This recursion may go many levels deep, since it only stops once\n            // k=1.\n            const subsetCombinations = combinationsReplacement(\n                x.slice(i, x.length),\n                k - 1\n            );\n\n            for (let j = 0; j < subsetCombinations.length; j++) {\n                combinationList.push([x[i]].concat(subsetCombinations[j]));\n            }\n        }\n    }\n\n    return combinationList;\n}\n\nexport default combinationsReplacement;\n","import combineMeans from \"./combine_means\";\n\n/**\n * When combining two lists of values for which one already knows the variances,\n * one does not have to necessary recompute the variance of the combined lists\n * in linear time. They can instead use this function to compute the combined\n * variance by providing the variance, mean & number of values of the first list\n * and the variance, mean & number of values of the second list.\n *\n * @since 3.0.0\n * @param {number} variance1 variance of the first list\n * @param {number} mean1 mean of the first list\n * @param {number} n1 number of items in the first list\n * @param {number} variance2 variance of the second list\n * @param {number} mean2 mean of the second list\n * @param {number} n2 number of items in the second list\n * @returns {number} the combined mean\n *\n * @example\n * combineVariances(14 / 3, 5, 3, 8 / 3, 4, 3); // => 47 / 12\n */\nfunction combineVariances(variance1, mean1, n1, variance2, mean2, n2) {\n    const newMean = combineMeans(mean1, n1, mean2, n2);\n\n    return (\n        (n1 * (variance1 + Math.pow(mean1 - newMean, 2)) +\n            n2 * (variance2 + Math.pow(mean2 - newMean, 2))) /\n        (n1 + n2)\n    );\n}\n\nexport default combineVariances;\n","import standardNormalTable from \"./standard_normal_table\";\n\n/**\n * **[Cumulative Standard Normal Probability](http://en.wikipedia.org/wiki/Standard_normal_table)**\n *\n * Since probability tables cannot be\n * printed for every normal distribution, as there are an infinite variety\n * of normal distributions, it is common practice to convert a normal to a\n * standard normal and then use the standard normal table to find probabilities.\n *\n * You can use `.5 + .5 * errorFunction(x / Math.sqrt(2))` to calculate the probability\n * instead of looking it up in a table.\n *\n * @param {number} z\n * @returns {number} cumulative standard normal probability\n */\nfunction cumulativeStdNormalProbability(z) {\n    // Calculate the position of this value.\n    const absZ = Math.abs(z);\n    // Each row begins with a different\n    // significant digit: 0.5, 0.6, 0.7, and so on. Each value in the table\n    // corresponds to a range of 0.01 in the input values, so the value is\n    // multiplied by 100.\n    const index = Math.min(\n        Math.round(absZ * 100),\n        standardNormalTable.length - 1\n    );\n\n    // The index we calculate must be in the table as a positive value,\n    // but we still pay attention to whether the input is positive\n    // or negative, and flip the output value as a last step.\n    if (z >= 0) {\n        return standardNormalTable[index];\n    } else {\n        // due to floating-point arithmetic, values in the table with\n        // 4 significant figures can nevertheless end up as repeating\n        // fractions when they're computed here.\n        return +(1 - standardNormalTable[index]).toFixed(4);\n    }\n}\n\nexport default cumulativeStdNormalProbability;\n","/**\n * We use `ε`, epsilon, as a stopping criterion when we want to iterate\n * until we're \"close enough\". Epsilon is a very small number: for\n * simple statistics, that number is **0.0001**\n *\n * This is used in calculations like the binomialDistribution, in which\n * the process of finding a value is [iterative](https://en.wikipedia.org/wiki/Iterative_method):\n * it progresses until it is close enough.\n *\n * Below is an example of using epsilon in [gradient descent](https://en.wikipedia.org/wiki/Gradient_descent),\n * where we're trying to find a local minimum of a function's derivative,\n * given by the `fDerivative` method.\n *\n * @example\n * // From calculation, we expect that the local minimum occurs at x=9/4\n * var x_old = 0;\n * // The algorithm starts at x=6\n * var x_new = 6;\n * var stepSize = 0.01;\n *\n * function fDerivative(x) {\n *   return 4 * Math.pow(x, 3) - 9 * Math.pow(x, 2);\n * }\n *\n * // The loop runs until the difference between the previous\n * // value and the current value is smaller than epsilon - a rough\n * // meaure of 'close enough'\n * while (Math.abs(x_new - x_old) > ss.epsilon) {\n *   x_old = x_new;\n *   x_new = x_old - stepSize * fDerivative(x_old);\n * }\n *\n * console.log('Local minimum occurs at', x_new);\n */\nconst epsilon = 0.0001;\n\nexport default epsilon;\n","import max from \"./max\";\nimport min from \"./min\";\n\n/**\n * Given an array of x, this will find the extent of the\n * x and return an array of breaks that can be used\n * to categorize the x into a number of classes. The\n * returned array will always be 1 longer than the number of\n * classes because it includes the minimum value.\n *\n * @param {Array<number>} x an array of number values\n * @param {number} nClasses number of desired classes\n * @returns {Array<number>} array of class break positions\n * @example\n * equalIntervalBreaks([1, 2, 3, 4, 5, 6], 4); // => [1, 2.25, 3.5, 4.75, 6]\n */\nfunction equalIntervalBreaks(x, nClasses) {\n    if (x.length < 2) {\n        return x;\n    }\n\n    const theMin = min(x);\n    const theMax = max(x);\n\n    // the first break will always be the minimum value\n    // in the xset\n    const breaks = [theMin];\n\n    // The size of each break is the full range of the x\n    // divided by the number of classes requested\n    const breakSize = (theMax - theMin) / nClasses;\n\n    // In the case of nClasses = 1, this loop won't run\n    // and the returned breaks will be [min, max]\n    for (let i = 1; i < nClasses; i++) {\n        breaks.push(breaks[0] + breakSize * i);\n    }\n\n    // the last break will always be the\n    // maximum.\n    breaks.push(theMax);\n\n    return breaks;\n}\n\nexport default equalIntervalBreaks;\n","/**\n * This computes the minimum & maximum number in an array.\n *\n * This runs on `O(n)`, linear time in respect to the array\n *\n * @param {Array<number>} x sample of one or more data points\n * @returns {Array<number>} minimum & maximum value\n * @throws {Error} if the the length of x is less than one\n * @example\n * extent([1, 2, 3, 4]);\n * // => [1, 4]\n */\nfunction extent(x) {\n    if (x.length === 0) {\n        throw new Error(\"extent requires at least one data point\");\n    }\n\n    let min = x[0];\n    let max = x[0];\n    for (let i = 1; i < x.length; i++) {\n        if (x[i] > max) {\n            max = x[i];\n        }\n        if (x[i] < min) {\n            min = x[i];\n        }\n    }\n    return [min, max];\n}\n\nexport default extent;\n","/**\n * The extent is the lowest & highest number in the array. With a sorted array,\n * the first element in the array is always the lowest while the last element is always the largest, so this calculation\n * can be done in one step, or constant time.\n *\n * @param {Array<number>} x input\n * @returns {Array<number>} minimum & maximum value\n * @example\n * extentSorted([-100, -10, 1, 2, 5]); // => [-100, 5]\n */\nfunction extentSorted(x) {\n    return [x[0], x[x.length - 1]];\n}\n\nexport default extentSorted;\n","import factorial from \"./factorial\";\n\n/**\n * Compute the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) of a value using Nemes' approximation.\n * The gamma of n is equivalent to (n-1)!, but unlike the factorial function, gamma is defined for all real n except zero\n * and negative integers (where NaN is returned). Note, the gamma function is also well-defined for complex numbers,\n * though this implementation currently does not handle complex numbers as input values.\n * Nemes' approximation is defined [here](https://arxiv.org/abs/1003.6020) as Theorem 2.2.\n * Negative values use [Euler's reflection formula](https://en.wikipedia.org/wiki/Gamma_function#Properties) for computation.\n *\n * @param {number} n Any real number except for zero and negative integers.\n * @returns {number} The gamma of the input value.\n *\n * @example\n * gamma(11.5); // 11899423.084037038\n * gamma(-11.5); // 2.29575810481609e-8\n * gamma(5); // 24\n */\nfunction gamma(n) {\n    if (Number.isInteger(n)) {\n        if (n <= 0) {\n            // gamma not defined for zero or negative integers\n            return NaN;\n        } else {\n            // use factorial for integer inputs\n            return factorial(n - 1);\n        }\n    }\n\n    // Decrement n, because approximation is defined for n - 1\n    n--;\n\n    if (n < 0) {\n        // Use Euler's reflection formula for negative inputs\n        // see:  https://en.wikipedia.org/wiki/Gamma_function#Properties\n        return Math.PI / (Math.sin(Math.PI * -n) * gamma(-n));\n    } else {\n        // Nemes' expansion approximation\n        const seriesCoefficient =\n            Math.pow(n / Math.E, n) * Math.sqrt(2 * Math.PI * (n + 1 / 6));\n\n        const seriesDenom = n + 1 / 4;\n\n        const seriesExpansion =\n            1 +\n            1 / 144 / Math.pow(seriesDenom, 2) -\n            1 / 12960 / Math.pow(seriesDenom, 3) -\n            257 / 207360 / Math.pow(seriesDenom, 4) -\n            52 / 2612736 / Math.pow(seriesDenom, 5) +\n            5741173 / 9405849600 / Math.pow(seriesDenom, 6) +\n            37529 / 18811699200 / Math.pow(seriesDenom, 7);\n\n        return seriesCoefficient * seriesExpansion;\n    }\n}\n\nexport default gamma;\n","/**\n * The [Geometric Mean](https://en.wikipedia.org/wiki/Geometric_mean) is\n * a mean function that is more useful for numbers in different\n * ranges.\n *\n * This is the nth root of the input numbers multiplied by each other.\n *\n * The geometric mean is often useful for\n * **[proportional growth](https://en.wikipedia.org/wiki/Geometric_mean#Proportional_growth)**: given\n * growth rates for multiple years, like _80%, 16.66% and 42.85%_, a simple\n * mean will incorrectly estimate an average growth rate, whereas a geometric\n * mean will correctly estimate a growth rate that, over those years,\n * will yield the same end value.\n *\n * This runs on `O(n)`, linear time in respect to the array\n *\n * @param {Array<number>} x sample of one or more data points\n * @returns {number} geometric mean\n * @throws {Error} if x is empty\n * @throws {Error} if x contains a negative number\n * @example\n * var growthRates = [1.80, 1.166666, 1.428571];\n * var averageGrowth = ss.geometricMean(growthRates);\n * var averageGrowthRates = [averageGrowth, averageGrowth, averageGrowth];\n * var startingValue = 10;\n * var startingValueMean = 10;\n * growthRates.forEach(function(rate) {\n *   startingValue *= rate;\n * });\n * averageGrowthRates.forEach(function(rate) {\n *   startingValueMean *= rate;\n * });\n * startingValueMean === startingValue;\n */\nfunction geometricMean(x) {\n    // The mean of no numbers is null\n    if (x.length === 0) {\n        throw new Error(\"geometricMean requires at least one data point\");\n    }\n\n    // the starting value.\n    let value = 1;\n\n    for (let i = 0; i < x.length; i++) {\n        // the geometric mean is only valid for positive numbers\n        if (x[i] <= 0) {\n            throw new Error(\n                \"geometricMean requires only positive numbers as input\"\n            );\n        }\n\n        // repeatedly multiply the value by each number\n        value *= x[i];\n    }\n\n    return Math.pow(value, 1 / x.length);\n}\n\nexport default geometricMean;\n","/**\n * The [Harmonic Mean](https://en.wikipedia.org/wiki/Harmonic_mean) is\n * a mean function typically used to find the average of rates.\n * This mean is calculated by taking the reciprocal of the arithmetic mean\n * of the reciprocals of the input numbers.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs on `O(n)`, linear time in respect to the array.\n *\n * @param {Array<number>} x sample of one or more data points\n * @returns {number} harmonic mean\n * @throws {Error} if x is empty\n * @throws {Error} if x contains a negative number\n * @example\n * harmonicMean([2, 3]).toFixed(2) // => '2.40'\n */\nfunction harmonicMean(x) {\n    // The mean of no numbers is null\n    if (x.length === 0) {\n        throw new Error(\"harmonicMean requires at least one data point\");\n    }\n\n    let reciprocalSum = 0;\n\n    for (let i = 0; i < x.length; i++) {\n        // the harmonic mean is only valid for positive numbers\n        if (x[i] <= 0) {\n            throw new Error(\n                \"harmonicMean requires only positive numbers as input\"\n            );\n        }\n\n        reciprocalSum += 1 / x[i];\n    }\n\n    // divide n by the the reciprocal sum\n    return x.length / reciprocalSum;\n}\n\nexport default harmonicMean;\n","/**\n * [Simple linear regression](http://en.wikipedia.org/wiki/Simple_linear_regression)\n * is a simple way to find a fitted line\n * between a set of coordinates. This algorithm finds the slope and y-intercept of a regression line\n * using the least sum of squares.\n *\n * @param {Array<Array<number>>} data an array of two-element of arrays,\n * like `[[0, 1], [2, 3]]`\n * @returns {Object} object containing slope and intersect of regression line\n * @example\n * linearRegression([[0, 0], [1, 1]]); // => { m: 1, b: 0 }\n */\nfunction linearRegression(data) {\n    let m, b;\n\n    // Store data length in a local variable to reduce\n    // repeated object property lookups\n    const dataLength = data.length;\n\n    //if there's only one point, arbitrarily choose a slope of 0\n    //and a y-intercept of whatever the y of the initial point is\n    if (dataLength === 1) {\n        m = 0;\n        b = data[0][1];\n    } else {\n        // Initialize our sums and scope the `m` and `b`\n        // variables that define the line.\n        let sumX = 0,\n            sumY = 0,\n            sumXX = 0,\n            sumXY = 0;\n\n        // Use local variables to grab point values\n        // with minimal object property lookups\n        let point, x, y;\n\n        // Gather the sum of all x values, the sum of all\n        // y values, and the sum of x^2 and (x*y) for each\n        // value.\n        //\n        // In math notation, these would be SS_x, SS_y, SS_xx, and SS_xy\n        for (let i = 0; i < dataLength; i++) {\n            point = data[i];\n            x = point[0];\n            y = point[1];\n\n            sumX += x;\n            sumY += y;\n\n            sumXX += x * x;\n            sumXY += x * y;\n        }\n\n        // `m` is the slope of the regression line\n        m =\n            (dataLength * sumXY - sumX * sumY) /\n            (dataLength * sumXX - sumX * sumX);\n\n        // `b` is the y-intercept of the line.\n        b = sumY / dataLength - (m * sumX) / dataLength;\n    }\n\n    // Return both values as an object.\n    return {\n        m: m,\n        b: b\n    };\n}\n\nexport default linearRegression;\n","/**\n * Given the output of `linearRegression`: an object\n * with `m` and `b` values indicating slope and intercept,\n * respectively, generate a line function that translates\n * x values into y values.\n *\n * @param {Object} mb object with `m` and `b` members, representing\n * slope and intersect of desired line\n * @returns {Function} method that computes y-value at any given\n * x-value on the line.\n * @example\n * var l = linearRegressionLine(linearRegression([[0, 0], [1, 1]]));\n * l(0) // = 0\n * l(2) // = 2\n * linearRegressionLine({ b: 0, m: 1 })(1); // => 1\n * linearRegressionLine({ b: 1, m: 1 })(1); // => 2\n */\nfunction linearRegressionLine(mb /*: { b: number, m: number }*/) {\n    // Return a function that computes a `y` value for each\n    // x value it is given, based on the values of `b` and `a`\n    // that we just computed.\n    return function(x) {\n        return mb.b + mb.m * x;\n    };\n}\n\nexport default linearRegressionLine;\n","/**\n * The maximum is the highest number in the array. With a sorted array,\n * the last element in the array is always the largest, so this calculation\n * can be done in one step, or constant time.\n *\n * @param {Array<number>} x input\n * @returns {number} maximum value\n * @example\n * maxSorted([-100, -10, 1, 2, 5]); // => 5\n */\nfunction maxSorted(x) {\n    return x[x.length - 1];\n}\n\nexport default maxSorted;\n","import quantileSorted from \"./quantile_sorted\";\n\n/**\n * The [median](http://en.wikipedia.org/wiki/Median) is\n * the middle number of a list. This is often a good indicator of 'the middle'\n * when there are outliers that skew the `mean()` value.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * The median isn't necessarily one of the elements in the list: the value\n * can be the average of two elements if the list has an even length\n * and the two central values are different.\n *\n * @param {Array<number>} sorted input\n * @returns {number} median value\n * @example\n * medianSorted([10, 2, 5, 100, 2, 1]); // => 52.5\n */\nfunction medianSorted(sorted) {\n    return quantileSorted(sorted, 0.5);\n}\n\nexport default medianSorted;\n","/**\n * The minimum is the lowest number in the array. With a sorted array,\n * the first element in the array is always the smallest, so this calculation\n * can be done in one step, or constant time.\n *\n * @param {Array<number>} x input\n * @returns {number} minimum value\n * @example\n * minSorted([-100, -10, 1, 2, 5]); // => -100\n */\nfunction minSorted(x) {\n    return x[0];\n}\n\nexport default minSorted;\n","import modeSorted from \"./mode_sorted\";\nimport numericSort from \"./numeric_sort\";\n\n/**\n * The [mode](http://bit.ly/W5K4Yt) is the number that appears in a list the highest number of times.\n * There can be multiple modes in a list: in the event of a tie, this\n * algorithm will return the most recently seen mode.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs on `O(nlog(n))` because it needs to sort the array internally\n * before running an `O(n)` search to find the mode.\n *\n * @param {Array<number>} x input\n * @returns {number} mode\n * @example\n * mode([0, 0, 1]); // => 0\n */\nfunction mode(x) {\n    // Sorting the array lets us iterate through it below and be sure\n    // that every time we see a new number it's new and we'll never\n    // see the same number twice\n    return modeSorted(numericSort(x));\n}\n\nexport default mode;\n","/* globals Map: false */\n\n/**\n * The [mode](http://bit.ly/W5K4Yt) is the number that appears in a list the highest number of times.\n * There can be multiple modes in a list: in the event of a tie, this\n * algorithm will return the most recently seen mode.\n *\n * modeFast uses a Map object to keep track of the mode, instead of the approach\n * used with `mode`, a sorted array. As a result, it is faster\n * than `mode` and supports any data type that can be compared with `==`.\n * It also requires a\n * [JavaScript environment with support for Map](https://kangax.github.io/compat-table/es6/#test-Map),\n * and will throw an error if Map is not available.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * @param {Array<*>} x a sample of one or more data points\n * @returns {?*} mode\n * @throws {ReferenceError} if the JavaScript environment doesn't support Map\n * @throws {Error} if x is empty\n * @example\n * modeFast(['rabbits', 'rabbits', 'squirrels']); // => 'rabbits'\n */\nfunction modeFast(x) {\n    // This index will reflect the incidence of different values, indexing\n    // them like\n    // { value: count }\n    const index = new Map();\n\n    // A running `mode` and the number of times it has been encountered.\n    let mode;\n    let modeCount = 0;\n\n    for (let i = 0; i < x.length; i++) {\n        let newCount = index.get(x[i]);\n        if (newCount === undefined) {\n            newCount = 1;\n        } else {\n            newCount++;\n        }\n        if (newCount > modeCount) {\n            mode = x[i];\n            modeCount = newCount;\n        }\n        index.set(x[i], newCount);\n    }\n\n    if (modeCount === 0) {\n        throw new Error(\"mode requires at last one data point\");\n    }\n\n    return mode;\n}\n\nexport default modeFast;\n","import mean from \"./mean\";\nimport shuffleInPlace from \"./shuffle_in_place\";\n\n/**\n * Conducts a [permutation test](https://en.wikipedia.org/wiki/Resampling_(statistics)#Permutation_tests)\n * to determine if two data sets are *significantly* different from each other, using\n * the difference of means between the groups as the test statistic.\n * The function allows for the following hypotheses:\n * - two_tail = Null hypothesis: the two distributions are equal.\n * - greater = Null hypothesis: observations from sampleX tend to be smaller than those from sampleY.\n * - less = Null hypothesis: observations from sampleX tend to be greater than those from sampleY.\n * [Learn more about one-tail vs two-tail tests.](https://en.wikipedia.org/wiki/One-_and_two-tailed_tests)\n *\n * @param {Array<number>} sampleX first dataset (e.g. treatment data)\n * @param {Array<number>} sampleY second dataset (e.g. control data)\n * @param {string} alternative alternative hypothesis, either 'two_sided' (default), 'greater', or 'less'\n * @param {number} k number of values in permutation distribution.\n * @returns {number} p-value The probability of observing the difference between groups (as or more extreme than what we did), assuming the null hypothesis.\n *\n * @example\n * var control = [2, 5, 3, 6, 7, 2, 5];\n * var treatment = [20, 5, 13, 12, 7, 2, 2];\n * permutationTest(control, treatment); // ~0.1324\n */\nfunction permutationTest(sampleX, sampleY, alternative, k) {\n    // Set default arguments\n    if (k === undefined) {\n        k = 10000;\n    }\n    if (alternative === undefined) {\n        alternative = \"two_side\";\n    }\n    if (\n        alternative !== \"two_side\" &&\n        alternative !== \"greater\" &&\n        alternative !== \"less\"\n    ) {\n        throw new Error(\n            \"`alternative` must be either 'two_side', 'greater', or 'less'\"\n        );\n    }\n\n    // get means for each sample\n    const meanX = mean(sampleX);\n    const meanY = mean(sampleY);\n\n    // calculate initial test statistic. This will be our point of comparison with\n    // the generated test statistics.\n    const testStatistic = meanX - meanY;\n\n    // create test-statistic distribution\n    const testStatDsn = new Array(k);\n\n    // combine datsets so we can easily shuffle later\n    const allData = sampleX.concat(sampleY);\n    const midIndex = Math.floor(allData.length / 2);\n\n    for (let i = 0; i < k; i++) {\n        // 1. shuffle data assignments\n        shuffleInPlace(allData);\n        const permLeft = allData.slice(0, midIndex);\n        const permRight = allData.slice(midIndex, allData.length);\n\n        // 2.re-calculate test statistic\n        const permTestStatistic = mean(permLeft) - mean(permRight);\n\n        // 3. store test statistic to build test statistic distribution\n        testStatDsn[i] = permTestStatistic;\n    }\n\n    // Calculate p-value depending on alternative\n    // For this test, we calculate the percentage of 'extreme' test statistics (subject to our hypothesis)\n    // more info on permutation test p-value calculations: https://onlinecourses.science.psu.edu/stat464/node/35\n    let numExtremeTStats = 0;\n    if (alternative === \"two_side\") {\n        for (let i = 0; i <= k; i++) {\n            if (Math.abs(testStatDsn[i]) >= Math.abs(testStatistic)) {\n                numExtremeTStats += 1;\n            }\n        }\n    } else if (alternative === \"greater\") {\n        for (let i = 0; i <= k; i++) {\n            if (testStatDsn[i] >= testStatistic) {\n                numExtremeTStats += 1;\n            }\n        }\n    } else {\n        // alternative === 'less'\n        for (let i = 0; i <= k; i++) {\n            if (testStatDsn[i] <= testStatistic) {\n                numExtremeTStats += 1;\n            }\n        }\n    }\n\n    return numExtremeTStats / k;\n}\n\nexport default permutationTest;\n","/**\n * Implementation of [Heap's Algorithm](https://en.wikipedia.org/wiki/Heap%27s_algorithm)\n * for generating permutations.\n *\n * @param {Array} elements any type of data\n * @returns {Array<Array>} array of permutations\n */\nfunction permutationsHeap(elements) {\n    const indexes = new Array(elements.length);\n    const permutations = [elements.slice()];\n\n    for (let i = 0; i < elements.length; i++) {\n        indexes[i] = 0;\n    }\n\n    for (let i = 0; i < elements.length; ) {\n        if (indexes[i] < i) {\n            // At odd indexes, swap from indexes[i] instead\n            // of from the beginning of the array\n            let swapFrom = 0;\n            if (i % 2 !== 0) {\n                swapFrom = indexes[i];\n            }\n\n            // swap between swapFrom and i, using\n            // a temporary variable as storage.\n            const temp = elements[swapFrom];\n            elements[swapFrom] = elements[i];\n            elements[i] = temp;\n\n            permutations.push(elements.slice());\n            indexes[i]++;\n            i = 0;\n        } else {\n            indexes[i] = 0;\n            i++;\n        }\n    }\n\n    return permutations;\n}\n\nexport default permutationsHeap;\n","import epsilon from \"./epsilon\";\n\n/**\n * The [Poisson Distribution](http://en.wikipedia.org/wiki/Poisson_distribution)\n * is a discrete probability distribution that expresses the probability\n * of a given number of events occurring in a fixed interval of time\n * and/or space if these events occur with a known average rate and\n * independently of the time since the last event.\n *\n * The Poisson Distribution is characterized by the strictly positive\n * mean arrival or occurrence rate, `λ`.\n *\n * @param {number} lambda location poisson distribution\n * @returns {number[]} values of poisson distribution at that point\n */\nfunction poissonDistribution(lambda) /*: ?number[] */ {\n    // Check that lambda is strictly positive\n    if (lambda <= 0) {\n        return undefined;\n    }\n\n    // our current place in the distribution\n    let x = 0;\n    // and we keep track of the current cumulative probability, in\n    // order to know when to stop calculating chances.\n    let cumulativeProbability = 0;\n    // the calculated cells to be returned\n    const cells = [];\n    let factorialX = 1;\n\n    // This algorithm iterates through each potential outcome,\n    // until the `cumulativeProbability` is very close to 1, at\n    // which point we've defined the vast majority of outcomes\n    do {\n        // a [probability mass function](https://en.wikipedia.org/wiki/Probability_mass_function)\n        cells[x] = (Math.exp(-lambda) * Math.pow(lambda, x)) / factorialX;\n        cumulativeProbability += cells[x];\n        x++;\n        factorialX *= x;\n        // when the cumulativeProbability is nearly 1, we've calculated\n        // the useful range of this distribution\n    } while (cumulativeProbability < 1 - epsilon);\n\n    return cells;\n}\n\nexport default poissonDistribution;\n","import epsilon from \"./epsilon\";\nimport inverseErrorFunction from \"./inverse_error_function\";\n\n/**\n * The [Probit](http://en.wikipedia.org/wiki/Probit)\n * is the inverse of cumulativeStdNormalProbability(),\n * and is also known as the normal quantile function.\n *\n * It returns the number of standard deviations from the mean\n * where the p'th quantile of values can be found in a normal distribution.\n * So, for example, probit(0.5 + 0.6827/2) ≈ 1 because 68.27% of values are\n * normally found within 1 standard deviation above or below the mean.\n *\n * @param {number} p\n * @returns {number} probit\n */\nfunction probit(p) {\n    if (p === 0) {\n        p = epsilon;\n    } else if (p >= 1) {\n        p = 1 - epsilon;\n    }\n    return Math.sqrt(2) * inverseErrorFunction(2 * p - 1);\n}\n\nexport default probit;\n","/**\n * The [product](https://en.wikipedia.org/wiki/Product_(mathematics)) of an array\n * is the result of multiplying all numbers together, starting using one as the multiplicative identity.\n *\n * This runs on `O(n)`, linear time in respect to the array\n *\n * @param {Array<number>} x input\n * @return {number} product of all input numbers\n * @example\n * product([1, 2, 3, 4]); // => 24\n */\nfunction product(x) {\n    let value = 1;\n    for (let i = 0; i < x.length; i++) {\n        value *= x[i];\n    }\n    return value;\n}\n\nexport default product;\n","import numericSort from \"./numeric_sort\";\nimport quantileRankSorted from \"./quantile_rank_sorted\";\n\n/**\n * This function returns the quantile in which one would find the given value in\n * the given array. It will copy and sort your array before each run, so\n * if you know your array is already sorted, you should use `quantileRankSorted`\n * instead.\n *\n * @param {Array<number>} x input\n * @returns {number} value value\n * @example\n * quantileRank([4, 3, 1, 2], 3); // => 0.75\n * quantileRank([4, 3, 2, 3, 1], 3); // => 0.7\n * quantileRank([2, 4, 1, 3], 6); // => 1\n * quantileRank([5, 3, 1, 2, 3], 4); // => 0.8\n */\nfunction quantileRank(x, value) {\n    // Cloning and sorting the array\n    const sortedCopy = numericSort(x);\n\n    return quantileRankSorted(sortedCopy, value);\n}\n\nexport default quantileRank;\n","/**\n * The [R Squared](http://en.wikipedia.org/wiki/Coefficient_of_determination)\n * value of data compared with a function `f`\n * is the sum of the squared differences between the prediction\n * and the actual value.\n *\n * @param {Array<Array<number>>} x input data: this should be doubly-nested\n * @param {Function} func function called on `[i][0]` values within the dataset\n * @returns {number} r-squared value\n * @example\n * var samples = [[0, 0], [1, 1]];\n * var regressionLine = linearRegressionLine(linearRegression(samples));\n * rSquared(samples, regressionLine); // = 1 this line is a perfect fit\n */\nfunction rSquared(x, func) {\n    if (x.length < 2) {\n        return 1;\n    }\n\n    // Compute the average y value for the actual\n    // data set in order to compute the\n    // _total sum of squares_\n    let sum = 0;\n    for (let i = 0; i < x.length; i++) {\n        sum += x[i][1];\n    }\n    const average = sum / x.length;\n\n    // Compute the total sum of squares - the\n    // squared difference between each point\n    // and the average of all points.\n    let sumOfSquares = 0;\n    for (let j = 0; j < x.length; j++) {\n        sumOfSquares += Math.pow(average - x[j][1], 2);\n    }\n\n    // Finally estimate the error: the squared\n    // difference between the estimate and the actual data\n    // value at each point.\n    let err = 0;\n    for (let k = 0; k < x.length; k++) {\n        err += Math.pow(x[k][1] - func(x[k][0]), 2);\n    }\n\n    // As the error grows larger, its ratio to the\n    // sum of squares increases and the r squared\n    // value grows lower.\n    return 1 - err / sumOfSquares;\n}\n\nexport default rSquared;\n","import shuffle from \"./shuffle\";\n\n/**\n * Create a [simple random sample](http://en.wikipedia.org/wiki/Simple_random_sample)\n * from a given array of `n` elements.\n *\n * The sampled values will be in any order, not necessarily the order\n * they appear in the input.\n *\n * @param {Array<any>} x input array. can contain any type\n * @param {number} n count of how many elements to take\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @return {Array} subset of n elements in original array\n *\n * @example\n * var values = [1, 2, 4, 5, 6, 7, 8, 9];\n * sample(values, 3); // returns 3 random values, like [2, 5, 8];\n */\nfunction sample(x, n, randomSource) {\n    // shuffle the original array using a fisher-yates shuffle\n    const shuffled = shuffle(x, randomSource);\n\n    // and then return a subset of it - the first `n` elements.\n    return shuffled.slice(0, n);\n}\n\nexport default sample;\n","import sampleCovariance from \"./sample_covariance\";\nimport sampleStandardDeviation from \"./sample_standard_deviation\";\n\n/**\n * The [correlation](http://en.wikipedia.org/wiki/Correlation_and_dependence) is\n * a measure of how correlated two datasets are, between -1 and 1\n *\n * @param {Array<number>} x first input\n * @param {Array<number>} y second input\n * @returns {number} sample correlation\n * @example\n * sampleCorrelation([1, 2, 3, 4, 5, 6], [2, 2, 3, 4, 5, 60]).toFixed(2);\n * // => '0.69'\n */\nfunction sampleCorrelation(x, y) {\n    const cov = sampleCovariance(x, y);\n    const xstd = sampleStandardDeviation(x);\n    const ystd = sampleStandardDeviation(y);\n\n    return cov / xstd / ystd;\n}\n\nexport default sampleCorrelation;\n","import mean from \"./mean\";\n\n/**\n * [Kurtosis](http://en.wikipedia.org/wiki/Kurtosis) is\n * a measure of the heaviness of a distribution's tails relative to its\n * variance. The kurtosis value can be positive or negative, or even undefined.\n *\n * Implementation is based on Fisher's excess kurtosis definition and uses\n * unbiased moment estimators. This is the version found in Excel and available\n * in several statistical packages, including SAS and SciPy.\n *\n * @param {Array<number>} x a sample of 4 or more data points\n * @returns {number} sample kurtosis\n * @throws {Error} if x has length less than 4\n * @example\n * sampleKurtosis([1, 2, 2, 3, 5]); // => 1.4555765595463122\n */\nfunction sampleKurtosis(x) {\n    const n = x.length;\n\n    if (n < 4) {\n        throw new Error(\"sampleKurtosis requires at least four data points\");\n    }\n\n    const meanValue = mean(x);\n    let tempValue;\n    let secondCentralMoment = 0;\n    let fourthCentralMoment = 0;\n\n    for (let i = 0; i < n; i++) {\n        tempValue = x[i] - meanValue;\n        secondCentralMoment += tempValue * tempValue;\n        fourthCentralMoment += tempValue * tempValue * tempValue * tempValue;\n    }\n\n    return (\n        ((n - 1) / ((n - 2) * (n - 3))) *\n        ((n * (n + 1) * fourthCentralMoment) /\n            (secondCentralMoment * secondCentralMoment) -\n            3 * (n - 1))\n    );\n}\n\nexport default sampleKurtosis;\n","import mean from \"./mean\";\n\n/**\n * [Skewness](http://en.wikipedia.org/wiki/Skewness) is\n * a measure of the extent to which a probability distribution of a\n * real-valued random variable \"leans\" to one side of the mean.\n * The skewness value can be positive or negative, or even undefined.\n *\n * Implementation is based on the adjusted Fisher-Pearson standardized\n * moment coefficient, which is the version found in Excel and several\n * statistical packages including Minitab, SAS and SPSS.\n *\n * @since 4.1.0\n * @param {Array<number>} x a sample of 3 or more data points\n * @returns {number} sample skewness\n * @throws {Error} if x has length less than 3\n * @example\n * sampleSkewness([2, 4, 6, 3, 1]); // => 0.590128656384365\n */\nfunction sampleSkewness(x) {\n    if (x.length < 3) {\n        throw new Error(\"sampleSkewness requires at least three data points\");\n    }\n\n    const meanValue = mean(x);\n    let tempValue;\n    let sumSquaredDeviations = 0;\n    let sumCubedDeviations = 0;\n\n    for (let i = 0; i < x.length; i++) {\n        tempValue = x[i] - meanValue;\n        sumSquaredDeviations += tempValue * tempValue;\n        sumCubedDeviations += tempValue * tempValue * tempValue;\n    }\n\n    // this is Bessels' Correction: an adjustment made to sample statistics\n    // that allows for the reduced degree of freedom entailed in calculating\n    // values from samples rather than complete populations.\n    const besselsCorrection = x.length - 1;\n\n    // Find the mean value of that list\n    const theSampleStandardDeviation = Math.sqrt(\n        sumSquaredDeviations / besselsCorrection\n    );\n\n    const n = x.length;\n    const cubedS = Math.pow(theSampleStandardDeviation, 3);\n\n    return (n * sumCubedDeviations) / ((n - 1) * (n - 2) * cubedS);\n}\n\nexport default sampleSkewness;\n","/**\n * Sampling with replacement is a type of sampling that allows the same\n * item to be picked out of a population more than once.\n *\n * @param {Array<*>} x an array of any kind of value\n * @param {number} n count of how many elements to take\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @return {Array} n sampled items from the population\n * @example\n * var values = [1, 2, 3, 4];\n * sampleWithReplacement(values, 2); // returns 2 random values, like [2, 4];\n */\nfunction sampleWithReplacement(x, n, randomSource) {\n    if (x.length === 0) {\n        return [];\n    }\n\n    // a custom random number source can be provided if you want to use\n    // a fixed seed or another random number generator, like\n    // [random-js](https://www.npmjs.org/package/random-js)\n    randomSource = randomSource || Math.random;\n\n    const length = x.length;\n    const sample = [];\n\n    for (let i = 0; i < n; i++) {\n        const index = Math.floor(randomSource() * length);\n\n        sample.push(x[index]);\n    }\n\n    return sample;\n}\n\nexport default sampleWithReplacement;\n","/**\n * When removing a value from a list, one does not have to necessary\n * recompute the mean of the list in linear time. They can instead use\n * this function to compute the new mean by providing the current mean,\n * the number of elements in the list that produced it and the value to remove.\n *\n * @since 3.0.0\n * @param {number} mean current mean\n * @param {number} n number of items in the list\n * @param {number} value the value to remove\n * @returns {number} the new mean\n *\n * @example\n * subtractFromMean(20.5, 6, 53); // => 14\n */\nfunction subtractFromMean(mean, n, value) {\n    return (mean * n - value) / (n - 1);\n}\n\nexport default subtractFromMean;\n","/**\n * The simple [sum](https://en.wikipedia.org/wiki/Summation) of an array\n * is the result of adding all numbers together, starting from zero.\n *\n * This runs on `O(n)`, linear time in respect to the array\n *\n * @param {Array<number>} x input\n * @return {number} sum of all input numbers\n * @example\n * sumSimple([1, 2, 3]); // => 6\n */\nfunction sumSimple(x) {\n    let value = 0;\n    for (let i = 0; i < x.length; i++) {\n        value += x[i];\n    }\n    return value;\n}\n\nexport default sumSimple;\n","import mean from \"./mean\";\nimport standardDeviation from \"./standard_deviation\";\n\n/**\n * This is to compute [a one-sample t-test](https://en.wikipedia.org/wiki/Student%27s_t-test#One-sample_t-test), comparing the mean\n * of a sample to a known value, x.\n *\n * in this case, we're trying to determine whether the\n * population mean is equal to the value that we know, which is `x`\n * here. usually the results here are used to look up a\n * [p-value](http://en.wikipedia.org/wiki/P-value), which, for\n * a certain level of significance, will let you determine that the\n * null hypothesis can or cannot be rejected.\n *\n * @param {Array<number>} x sample of one or more numbers\n * @param {number} expectedValue expected value of the population mean\n * @returns {number} value\n * @example\n * tTest([1, 2, 3, 4, 5, 6], 3.385).toFixed(2); // => '0.16'\n */\nfunction tTest(x, expectedValue) {\n    // The mean of the sample\n    const sampleMean = mean(x);\n\n    // The standard deviation of the sample\n    const sd = standardDeviation(x);\n\n    // Square root the length of the sample\n    const rootN = Math.sqrt(x.length);\n\n    // returning the t value\n    return (sampleMean - expectedValue) / (sd / rootN);\n}\n\nexport default tTest;\n","import mean from \"./mean\";\nimport sampleVariance from \"./sample_variance\";\n\n/**\n * This is to compute [two sample t-test](http://en.wikipedia.org/wiki/Student's_t-test).\n * Tests whether \"mean(X)-mean(Y) = difference\", (\n * in the most common case, we often have `difference == 0` to test if two samples\n * are likely to be taken from populations with the same mean value) with\n * no prior knowledge on standard deviations of both samples\n * other than the fact that they have the same standard deviation.\n *\n * Usually the results here are used to look up a\n * [p-value](http://en.wikipedia.org/wiki/P-value), which, for\n * a certain level of significance, will let you determine that the\n * null hypothesis can or cannot be rejected.\n *\n * `diff` can be omitted if it equals 0.\n *\n * [This is used to confirm or deny](http://www.monarchlab.org/Lab/Research/Stats/2SampleT.aspx)\n * a null hypothesis that the two populations that have been sampled into\n * `sampleX` and `sampleY` are equal to each other.\n *\n * @param {Array<number>} sampleX a sample as an array of numbers\n * @param {Array<number>} sampleY a sample as an array of numbers\n * @param {number} [difference=0]\n * @returns {number|null} test result\n *\n * @example\n * tTestTwoSample([1, 2, 3, 4], [3, 4, 5, 6], 0); // => -2.1908902300206643\n */\nfunction tTestTwoSample(sampleX, sampleY, difference) {\n    const n = sampleX.length;\n    const m = sampleY.length;\n\n    // If either sample doesn't actually have any values, we can't\n    // compute this at all, so we return `null`.\n    if (!n || !m) {\n        return null;\n    }\n\n    // default difference (mu) is zero\n    if (!difference) {\n        difference = 0;\n    }\n\n    const meanX = mean(sampleX);\n    const meanY = mean(sampleY);\n    const sampleVarianceX = sampleVariance(sampleX);\n    const sampleVarianceY = sampleVariance(sampleY);\n\n    if (\n        typeof meanX === \"number\" &&\n        typeof meanY === \"number\" &&\n        typeof sampleVarianceX === \"number\" &&\n        typeof sampleVarianceY === \"number\"\n    ) {\n        const weightedVariance =\n            ((n - 1) * sampleVarianceX + (m - 1) * sampleVarianceY) /\n            (n + m - 2);\n\n        return (\n            (meanX - meanY - difference) /\n            Math.sqrt(weightedVariance * (1 / n + 1 / m))\n        );\n    }\n}\n\nexport default tTestTwoSample;\n","/**\n * The [Z-Score, or Standard Score](http://en.wikipedia.org/wiki/Standard_score).\n *\n * The standard score is the number of standard deviations an observation\n * or datum is above or below the mean. Thus, a positive standard score\n * represents a datum above the mean, while a negative standard score\n * represents a datum below the mean. It is a dimensionless quantity\n * obtained by subtracting the population mean from an individual raw\n * score and then dividing the difference by the population standard\n * deviation.\n *\n * The z-score is only defined if one knows the population parameters;\n * if one only has a sample set, then the analogous computation with\n * sample mean and sample standard deviation yields the\n * Student's t-statistic.\n *\n * @param {number} x\n * @param {number} mean\n * @param {number} standardDeviation\n * @return {number} z score\n * @example\n * zScore(78, 80, 5); // => -0.4\n */\nfunction zScore(x, mean, standardDeviation) {\n    return (x - mean) / standardDeviation;\n}\n\nexport default zScore;\n","export default function(x) {\n  return x;\n}\n","import identity from \"./identity.js\";\n\nexport default function(transform) {\n  if (transform == null) return identity;\n  var x0,\n      y0,\n      kx = transform.scale[0],\n      ky = transform.scale[1],\n      dx = transform.translate[0],\n      dy = transform.translate[1];\n  return function(input, i) {\n    if (!i) x0 = y0 = 0;\n    var j = 2, n = input.length, output = new Array(n);\n    output[0] = (x0 += input[0]) * kx + dx;\n    output[1] = (y0 += input[1]) * ky + dy;\n    while (j < n) output[j] = input[j], ++j;\n    return output;\n  };\n}\n","import reverse from \"./reverse.js\";\nimport transform from \"./transform.js\";\n\nexport default function(topology, o) {\n  if (typeof o === \"string\") o = topology.objects[o];\n  return o.type === \"GeometryCollection\"\n      ? {type: \"FeatureCollection\", features: o.geometries.map(function(o) { return feature(topology, o); })}\n      : feature(topology, o);\n}\n\nfunction feature(topology, o) {\n  var id = o.id,\n      bbox = o.bbox,\n      properties = o.properties == null ? {} : o.properties,\n      geometry = object(topology, o);\n  return id == null && bbox == null ? {type: \"Feature\", properties: properties, geometry: geometry}\n      : bbox == null ? {type: \"Feature\", id: id, properties: properties, geometry: geometry}\n      : {type: \"Feature\", id: id, bbox: bbox, properties: properties, geometry: geometry};\n}\n\nexport function object(topology, o) {\n  var transformPoint = transform(topology.transform),\n      arcs = topology.arcs;\n\n  function arc(i, points) {\n    if (points.length) points.pop();\n    for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length; k < n; ++k) {\n      points.push(transformPoint(a[k], k));\n    }\n    if (i < 0) reverse(points, n);\n  }\n\n  function point(p) {\n    return transformPoint(p);\n  }\n\n  function line(arcs) {\n    var points = [];\n    for (var i = 0, n = arcs.length; i < n; ++i) arc(arcs[i], points);\n    if (points.length < 2) points.push(points[0]); // This should never happen per the specification.\n    return points;\n  }\n\n  function ring(arcs) {\n    var points = line(arcs);\n    while (points.length < 4) points.push(points[0]); // This may happen if an arc has only two points.\n    return points;\n  }\n\n  function polygon(arcs) {\n    return arcs.map(ring);\n  }\n\n  function geometry(o) {\n    var type = o.type, coordinates;\n    switch (type) {\n      case \"GeometryCollection\": return {type: type, geometries: o.geometries.map(geometry)};\n      case \"Point\": coordinates = point(o.coordinates); break;\n      case \"MultiPoint\": coordinates = o.coordinates.map(point); break;\n      case \"LineString\": coordinates = line(o.arcs); break;\n      case \"MultiLineString\": coordinates = o.arcs.map(line); break;\n      case \"Polygon\": coordinates = polygon(o.arcs); break;\n      case \"MultiPolygon\": coordinates = o.arcs.map(polygon); break;\n      default: return null;\n    }\n    return {type: type, coordinates: coordinates};\n  }\n\n  return geometry(o);\n}\n","export default function(array, n) {\n  var t, j = array.length, i = j - n;\n  while (i < --j) t = array[i], array[i++] = array[j], array[j] = t;\n}\n","export default function(topology, arcs) {\n  var stitchedArcs = {},\n      fragmentByStart = {},\n      fragmentByEnd = {},\n      fragments = [],\n      emptyIndex = -1;\n\n  // Stitch empty arcs first, since they may be subsumed by other arcs.\n  arcs.forEach(function(i, j) {\n    var arc = topology.arcs[i < 0 ? ~i : i], t;\n    if (arc.length < 3 && !arc[1][0] && !arc[1][1]) {\n      t = arcs[++emptyIndex], arcs[emptyIndex] = i, arcs[j] = t;\n    }\n  });\n\n  arcs.forEach(function(i) {\n    var e = ends(i),\n        start = e[0],\n        end = e[1],\n        f, g;\n\n    if (f = fragmentByEnd[start]) {\n      delete fragmentByEnd[f.end];\n      f.push(i);\n      f.end = end;\n      if (g = fragmentByStart[end]) {\n        delete fragmentByStart[g.start];\n        var fg = g === f ? f : f.concat(g);\n        fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg;\n      } else {\n        fragmentByStart[f.start] = fragmentByEnd[f.end] = f;\n      }\n    } else if (f = fragmentByStart[end]) {\n      delete fragmentByStart[f.start];\n      f.unshift(i);\n      f.start = start;\n      if (g = fragmentByEnd[start]) {\n        delete fragmentByEnd[g.end];\n        var gf = g === f ? f : g.concat(f);\n        fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf;\n      } else {\n        fragmentByStart[f.start] = fragmentByEnd[f.end] = f;\n      }\n    } else {\n      f = [i];\n      fragmentByStart[f.start = start] = fragmentByEnd[f.end = end] = f;\n    }\n  });\n\n  function ends(i) {\n    var arc = topology.arcs[i < 0 ? ~i : i], p0 = arc[0], p1;\n    if (topology.transform) p1 = [0, 0], arc.forEach(function(dp) { p1[0] += dp[0], p1[1] += dp[1]; });\n    else p1 = arc[arc.length - 1];\n    return i < 0 ? [p1, p0] : [p0, p1];\n  }\n\n  function flush(fragmentByEnd, fragmentByStart) {\n    for (var k in fragmentByEnd) {\n      var f = fragmentByEnd[k];\n      delete fragmentByStart[f.start];\n      delete f.start;\n      delete f.end;\n      f.forEach(function(i) { stitchedArcs[i < 0 ? ~i : i] = 1; });\n      fragments.push(f);\n    }\n  }\n\n  flush(fragmentByEnd, fragmentByStart);\n  flush(fragmentByStart, fragmentByEnd);\n  arcs.forEach(function(i) { if (!stitchedArcs[i < 0 ? ~i : i]) fragments.push([i]); });\n\n  return fragments;\n}\n","import {object} from \"./feature.js\";\nimport stitch from \"./stitch.js\";\n\nfunction planarRingArea(ring) {\n  var i = -1, n = ring.length, a, b = ring[n - 1], area = 0;\n  while (++i < n) a = b, b = ring[i], area += a[0] * b[1] - a[1] * b[0];\n  return Math.abs(area); // Note: doubled area!\n}\n\nexport default function(topology) {\n  return object(topology, mergeArcs.apply(this, arguments));\n}\n\nexport function mergeArcs(topology, objects) {\n  var polygonsByArc = {},\n      polygons = [],\n      groups = [];\n\n  objects.forEach(geometry);\n\n  function geometry(o) {\n    switch (o.type) {\n      case \"GeometryCollection\": o.geometries.forEach(geometry); break;\n      case \"Polygon\": extract(o.arcs); break;\n      case \"MultiPolygon\": o.arcs.forEach(extract); break;\n    }\n  }\n\n  function extract(polygon) {\n    polygon.forEach(function(ring) {\n      ring.forEach(function(arc) {\n        (polygonsByArc[arc = arc < 0 ? ~arc : arc] || (polygonsByArc[arc] = [])).push(polygon);\n      });\n    });\n    polygons.push(polygon);\n  }\n\n  function area(ring) {\n    return planarRingArea(object(topology, {type: \"Polygon\", arcs: [ring]}).coordinates[0]);\n  }\n\n  polygons.forEach(function(polygon) {\n    if (!polygon._) {\n      var group = [],\n          neighbors = [polygon];\n      polygon._ = 1;\n      groups.push(group);\n      while (polygon = neighbors.pop()) {\n        group.push(polygon);\n        polygon.forEach(function(ring) {\n          ring.forEach(function(arc) {\n            polygonsByArc[arc < 0 ? ~arc : arc].forEach(function(polygon) {\n              if (!polygon._) {\n                polygon._ = 1;\n                neighbors.push(polygon);\n              }\n            });\n          });\n        });\n      }\n    }\n  });\n\n  polygons.forEach(function(polygon) {\n    delete polygon._;\n  });\n\n  return {\n    type: \"MultiPolygon\",\n    arcs: groups.map(function(polygons) {\n      var arcs = [], n;\n\n      // Extract the exterior (unique) arcs.\n      polygons.forEach(function(polygon) {\n        polygon.forEach(function(ring) {\n          ring.forEach(function(arc) {\n            if (polygonsByArc[arc < 0 ? ~arc : arc].length < 2) {\n              arcs.push(arc);\n            }\n          });\n        });\n      });\n\n      // Stitch the arcs into one or more rings.\n      arcs = stitch(topology, arcs);\n\n      // If more than one ring is returned,\n      // at most one of these rings can be the exterior;\n      // choose the one with the greatest absolute area.\n      if ((n = arcs.length) > 1) {\n        for (var i = 1, k = area(arcs[0]), ki, t; i < n; ++i) {\n          if ((ki = area(arcs[i])) > k) {\n            t = arcs[0], arcs[0] = arcs[i], arcs[i] = t, k = ki;\n          }\n        }\n      }\n\n      return arcs;\n    }).filter(function(arcs) {\n      return arcs.length > 0;\n    })\n  };\n}\n","import clamp from './clamp';\n\n// Calculation comes from this formula https://oag.ca.gov/sites/all/files/agweb/pdfs/cjsc/prof10/formulas.pdf\nexport function rate_perResidents(num, pop, rate) {\n  return (num / pop) * rate;\n}\n\nexport function cities(svg, topology, path) {\n  const citylabels = svg.append('g').attr('class', 'citylabels');\n\n  citylabels\n    .selectAll('g')\n    .data(topology.features)\n    .enter()\n    .append('g')\n    .attr('class', 'city')\n    .attr('transform', d => `translate(${path.centroid(d)})`);\n\n  citylabels\n    .selectAll('g')\n    .append('circle')\n    .attr('class', 'city-dot')\n    .attr('fill', 'none')\n    .attr('stroke', '#000')\n    .attr('r', 3);\n\n  citylabels\n    .selectAll('g')\n    .append('text')\n    .attr('class', 'city-label')\n    .attr('text-anchor', d => d.properties.anchor || 'middle')\n    .attr('dx', d => d.properties.dx || '8')\n    .attr('dy', d => d.properties.dy || '-8')\n    .text(d => d.properties.name);\n}\n\nexport function highways(svg, topology, path) {\n  svg\n    .selectAll('g')\n    .data(topology.features.filter(d => d.properties.level == 'Interstate'))\n    .enter()\n    .append('path')\n    .attr('class', 'highways')\n    .attr('stroke', 'rgba(170, 170, 170, 1)')\n    .attr('d', path);\n}\n\nexport function add_legend_for_gray(legend, type, scale, isMobile) {\n  const legend_for_gray = legend.append('g').attr('class', 'legend-gray');\n\n  legend_for_gray\n    .append('rect')\n    .attr('class', 'counties')\n    .attr('x', scale.range()[0] + (isMobile ? 20 : 0))\n    .attr('height', 15)\n    .attr('width', 30)\n    .attr('fill', '#e8e8e8')\n    .attr('stroke-width', '2')\n    .attr('y', type == 'raw' ? 70 : 45);\n\n  legend_for_gray\n    .append('text')\n    .attr('class', 'legend_gray_text')\n    .attr('x', scale.range()[0] + (isMobile ? 60 : 40))\n    .attr('y', type == 'raw' ? 80 : 55)\n    .text('No reported cases');\n}\n\n// A tooltip function that relocates the tooltip when it gets to close to the edge\n\nexport function relocateTooltip(tooltip, x, y, screenY) {\n  const tooltipPush = 25;\n  const { height, width } = tooltip.node().getBoundingClientRect();\n\n  const innerWidth = window.innerWidth;\n  const innerHeight = window.innerHeight;\n\n  const left = clamp(\n    x - width / 2,\n    tooltipPush,\n    innerWidth - width - tooltipPush\n  );\n\n  const top =\n    innerHeight > screenY + tooltipPush + height\n      ? y + tooltipPush\n      : y - height - tooltipPush;\n\n  tooltip.style('left', `${left}px`);\n  tooltip.style('top', `${top}px`);\n}\n","export default function clamp(n, min, max) {\n  return Math.min(Math.max(n, min), max);\n}\n","/* eslint-disable no-unused-vars */\nimport * as d3 from 'd3';\nimport _ from 'lodash';\nimport { intcomma, apmonth, apdate, pluralize } from 'journalize';\nimport {\n  movingAvg,\n  customDateFormat,\n  customMobileDateFormat,\n  customNumFormat,\n  getLabeledData,\n  mergeArrays,\n} from '../utils/charts-utils';\nimport * as moment from 'moment';\n// import { swoopyDrag } from '../swoopy-drag';\n// import { wordwrap } from 'd3-jetpack';\n\nimport data from '../../../data/daily_tables/all_tables.json';\nimport colors from '../../../data/chart-colors.json';\n\n// a reference to the default graphic container, change if needed\nconst container = d3.select('#deaths');\n\n// a helper function to grab the container's width\nconst getFrameWidth = () => container.node().offsetWidth;\n\n//set margins\nlet margin = {\n  top: 15,\n  left: 25,\n  bottom: 40,\n};\n\nlet breakPoint = 500;\n\n// grabbing totals\nlet dataTotals = [];\n\n// there are six properties prior that we want to exclude: 'latest_date', 'yesterday_date', 'week_ago', 'cases_latest_date', 'cases_yesterday_date', 'cases_week_ago', 'cases_yesterday_date'\nfor (let i = Object.keys(data).length - 1; i > 6; i--) {\n  var death_dif = data[Object.keys(data)[i - 1]].statewide_data.death_dif;\n  if (\n    moment(Object.keys(data)[i], 'M_D_YYYY').isBefore(\n      moment(data['cases_latest_date'], 'M_D_YYYY')\n    )\n  ) {\n    dataTotals.push({\n      incomplete: data[Object.keys(data)[i - 1]].statewide_data.incomplete,\n      unformatted_date: Object.keys(data)[i - 1],\n      new_deaths: death_dif ? death_dif : 0,\n    });\n  }\n}\n\n// changing to moment date+time objects\ndataTotals.forEach(d => (d.date = moment(d.unformatted_date, 'M_D_YYYY')));\n\n// // Get the new starting date because the state did not provide comprehensive deaths data before then\n// const start_date = dataTotals.filter(d => d.unformatted_date == '03_24_2020')\n\n// // Filter out everything before the new starting date\n// dataTotals = dataTotals.filter(d => d.date > start_date[0].date)\n\n// Add an id based on index to use for joining\ndataTotals.forEach((d, i) => (d.id = i));\n\n// Make object into array\nlet dataArray = dataTotals.map(d => d['new_deaths']);\n\nlet dataMovingAvg = movingAvg(dataArray, 7, undefined, 'moving_avg');\n\ndataTotals = mergeArrays(dataTotals, dataMovingAvg, 'id');\n\n// grabbing totals and ranges\nlet dateRange = d3.extent(dataTotals, d => d.date),\n  totalsMax = d3.max(dataTotals, d => d.new_deaths);\n\n// set ranges\nlet x = d3.scaleTime().domain(dateRange);\nlet y = d3\n  .scaleLinear()\n  .domain([0, totalsMax])\n  .nice();\n\n// append svg\nlet svg = container.append('svg'),\n  g = svg.append('g').attr('class', 'line-chart'),\n  labels_g = svg.append('g').attr('class', 'labels-container');\n\nlet xAxis = g.append('g').attr('class', 'axis axis--x'),\n  yAxis = g.append('g').attr('class', 'axis axis--y');\n\nlet line = d3\n  .line()\n  .defined(d => !isNaN(d.moving_avg))\n  .x(d => x(d.date))\n  .y(d => y(d.moving_avg));\n\nlet bars = g\n  .selectAll('.bar')\n  .data(dataTotals)\n  .enter()\n  .append('rect')\n  .attr('class', 'bar')\n  .attr('fill', d => {\n    if (d.incomplete && d.incomplete.includes('deaths'))\n      // color incomplete bars gray\n      return colors.bar_neutral;\n    else\n      return d.id == dataTotals.length - 1\n        ? colors.bar_highlight\n        : colors.bar_default;\n  })\n  .attr('opacity', 1);\n\ndataTotals.filter(line.defined());\n\nlet pathOutline = g\n  .append('path')\n  .data([dataTotals])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', '#fff')\n  .attr('stroke-width', 4);\n\nlet path = g\n  .append('path')\n  .data([dataTotals])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', colors.line_moving_avg)\n  .attr('stroke-width', 2);\n\nconst day_for_label = [[dataTotals][0][6]]; // Gets the day that where the 7-day average label will be next to\n\nlet moving_avg_label = g.append('g').attr('class', 'moving-avg-label');\n\nlet moving_avg_g = moving_avg_label\n  .selectAll('g')\n  .data(day_for_label)\n  .enter()\n  .append('g');\n\nlet moving_avgText = moving_avg_g.append('g').attr('class', 'label-text');\n\nmoving_avgText\n  .append('text')\n  .text('7-day average')\n  .attr('fill', colors.line_moving_avg)\n  .attr('font-weight', 700);\n\nlet labels = labels_g.append('g').attr('class', 'labeled-elements');\n\nlet labelElements = labels\n  .selectAll('g')\n  .data(getLabeledData(dataTotals, ['']))\n  .enter()\n  .append('g')\n  .attr('class', 'label-element');\n\nlet labelText = labelElements.append('g').attr('class', 'label-text');\n\nlabelText\n  .append('text')\n  .text((d, i) => {\n    if (i === 0) {\n      let month = apmonth(new Date(d.date)),\n        day = d.date.format('D');\n\n      return `${month} ${day}`;\n    } else return '';\n  })\n  .attr('font-weight', 700);\n\nlet casesLabel = labelText.append('text').text(d => {\n  return `${intcomma(d.new_deaths)} death${pluralize(d.new_deaths)}`;\n});\n\nfunction resize() {\n  let frameWidth = getFrameWidth(),\n    frameHeight;\n\n  if (frameWidth < breakPoint) {\n    frameHeight = 175;\n    margin.right = 80;\n  } else {\n    frameHeight = 225;\n    margin.right = 85;\n  }\n\n  let chartWidth = frameWidth - margin.left - margin.right,\n    chartHeight = frameHeight - margin.bottom;\n\n  svg.attr('width', frameWidth).attr('height', frameHeight);\n  g.attr('width', chartWidth).attr(\n    'transform',\n    `translate(${margin.left},${margin.top})`\n  );\n  labels_g.attr('transform', `translate(${margin.left},${margin.top})`);\n\n  let barWidth = chartWidth / dataTotals.length;\n\n  x.range([barWidth / 1.5, chartWidth - barWidth / 1.5]);\n  y.range([chartHeight, 0]);\n\n  bars\n    .attr('width', barWidth - barWidth / 5)\n    .attr('x', d => x(d.date) - barWidth / 2)\n    .attr('y', d => y(d.new_deaths))\n    .attr('height', d => chartHeight - y(d.new_deaths));\n\n  xAxis\n    .call(\n      d3\n        .axisBottom(x)\n        .ticks(15)\n        .tickFormat((d, i) => {\n          return frameWidth < breakPoint\n            ? customMobileDateFormat(d, i)\n            : customDateFormat(d, i, 2);\n        })\n    )\n    .attr('transform', `translate(0,${frameHeight - margin.bottom})`);\n\n  yAxis.call(\n    d3\n      .axisLeft(y)\n      .ticks(5)\n      .tickSize(-chartWidth)\n      .tickFormat(customNumFormat)\n  );\n\n  pathOutline.attr('d', line);\n  path.attr('d', line);\n\n  moving_avg_g\n    .attr('transform', d => `translate(${x(d.date)},${y(d.moving_avg)})`)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  moving_avgText\n    .attr('transform', (d, i) => {\n      if (i === 0 && frameWidth < breakPoint) {\n        return 'translate(0, -11)';\n      } else return 'translate(0, -11)';\n    })\n    .attr('text-anchor', 'start');\n\n  labelElements\n    .attr('transform', d => `translate(${x(d.date)},${y(d.new_deaths)})`)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  labelText\n    .attr('transform', (d, i) => {\n      if (i === 0 && frameWidth < breakPoint) {\n        return 'translate(9, -5)';\n      } else return 'translate(15, 0)';\n    })\n    .attr('text-anchor', 'start');\n\n  casesLabel.attr('dy', frameWidth < breakPoint ? 16 : 17);\n}\n\n// call resize on load\nresize();\nwindow.addEventListener('resize', _.debounce(resize, 200));\n\n// OUTSIDE OF RESIZE()\n\n// let events = g.append('g').attr('class', 'events');\n\n// let eventGroups = events\n//   .selectAll('g')\n//   .data([\n//     {\n//       event_desktop: 'San Antonio opens its first drive-thru testing site',\n//       event_mobile: 'Bush',\n//       date: '3_13',\n//     },\n//   ])\n//   .enter()\n//   .append('g');\n\n// let eventText = eventGroups.append('text');\n\n// let eventLines = eventGroups\n//   .append('line')\n//   .attr('stroke', '#d1d1d1')\n//   .attr('stroke-width', '1px')\n//   .attr('stroke-dasharray', 5);\n\n// let metaInfo = g\n//   .append('g')\n//   .attr('class', 'meta')\n//   .attr('font-size', '12px')\n//   .attr('fill', 'hsl(0, 0%, 47%)');\n\n// this is the same function findChartMeta() in nunjucks.js\n// find a way to import that function here\n// metaInfo\n//   .append('text')\n//   .text(`Note: ${data.Meta.find(d => d.Chart === 'Line').Note}`)\n//   .attr('y', 45);\n\n// metaInfo\n//   .append('text')\n//   .html(\n//     `Source: <a style=\"fill: hsl(0, 0%, 47%); text-decoration: underline;\"href=\"https://www.cbp.gov/sites/default/files/assets/documents/2019-Mar/bp-total-monthly-apps-sector-area-fy2018.pdf\">${\n//       data.Meta.find(d => d.Chart === 'Line').Source\n//     }</a>`\n//   )\n//   .attr('y', 65);\n\n//arrow marker, need to append to the svg first to use\n// svg\n//   .append('marker')\n//   .attr('id', 'arrow')\n//   .attr('viewBox', '-10 -10 20 20')\n//   .attr('markerWidth', 10)\n//   .attr('markerHeight', 10)\n//   .attr('fill', 'hsl(0, 0%, 29%)')\n//   .attr('orient', 'auto-start-reverse')\n//   .append('path')\n//   .attr('d', 'M-6.75,-6.75 L 0,0 L -6.75,6.75');\n\n// let swoopySel = svg.append('g').attr('class', 'swoopy-drag-lines');\n\n// //annotations for swoopyDrag\n// let annotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-25,-19C-32,-38,-47,-49,-63,-50',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-186, -77],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-186, -63],\n//   },\n// ];\n\n// let mobileAnnotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-12,-13C-30,-13,-42,-24,-46,-39',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-105, -75],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-105, -62],\n//   },\n// ];\n\n// INSIDE OF RESIZE()\n\n// eventGroups.attr(\n//   'transform',\n//   d => `translate(${(0, x(moment(d.date, 'M_D')))})`\n// );\n\n// eventLines.attr('y1', 5).attr('y2', chartHeight);\n\n// eventText\n//   .text(d => (frameWidth < breakPoint ? d.event_mobile : d.event_desktop))\n//   .attr('font-size', frameWidth < breakPoint ? '12px' : '14px')\n//   .attr('dx', frameWidth < breakPoint ? 5 : 10)\n//   .attr('dy', frameWidth < breakPoint ? 14 : 20);\n\n// metaInfo.attr('transform', `translate(0, ${chartHeight})`);\n\n// let swoopy = swoopyDrag()\n//   .x(d => x(d.xVal) + (frameWidth < breakPoint ? 5 : 20))\n//   .y(d => y(d.yVal) + 35)\n//   .draggable(false)\n//   .annotations(frameWidth < breakPoint ? mobileAnnotations : annotations);\n\n// swoopySel\n//   .attr('transform', `translate(${margin.left},${margin.top})`)\n//   .call(swoopy)\n//   .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n// swoopySel.selectAll('text').each(function(d) {\n//   d3.select(this)\n//     .text('')\n//     .attr('font-weight', d.weight)\n//     .tspans(wordwrap(d.text, frameWidth < breakPoint ? 24 : 24));\n// });\n\n// swoopySel.selectAll('path').attr('marker-start', 'url(#arrow)');\n\n// const partners_img_width = chartWidth * (frameWidth < breakPoint ? 1.1 : 0.7);\n// const partners_img_height = partners_img_width / 13.3;\n\n// if (isPartners) {\n//   d3.select('.partner_logo').remove();\n//   // For wider desktops\n//   const svg_img_width =\n//     frameWidth > 800 ? partners_img_width * 0.7 : partners_img_width;\n//   let partner_svg = container\n//     .append('svg')\n//     .attr('width', svg_img_width)\n//     .attr('class', 'partner_logo')\n//     .attr('height', partners_img_height + 25);\n\n//   const partner_link = partner_svg\n//     .append('a')\n//     .attr('xlink:href', 'https://www.texastribune.org/')\n//     .attr('target', '_parent')\n//     .attr('rel', 'noopener noreferrer');\n\n//   partner_link\n//     .append('svg:image')\n//     .attr('alt', 'Coronavirus tracker presented by The Texas Tribune')\n//     .attr('x', 0)\n//     .attr('y', 15)\n//     .attr('width', svg_img_width)\n//     .attr('height', partners_img_height)\n//     .attr('xlink:href', TT_logo_present);\n// }\n","/* eslint-disable no-unused-vars */\nimport * as d3 from 'd3';\nimport _ from 'lodash';\nimport { intcomma, apmonth, apdate, pluralize } from 'journalize';\nimport {\n  movingAvg,\n  movingAvgSubtractMethod,\n  customDateFormat,\n  customMobileDateFormatFour,\n  customNumFormat,\n  getLabeledData,\n  mergeArrays,\n} from '../utils/charts-utils';\nimport * as moment from 'moment';\n// import { swoopyDrag } from '../swoopy-drag';\n// import { wordwrap } from 'd3-jetpack';\n\n// import data\nimport data from '../../../data/daily_tables/all_tables.json';\nimport colors from '../../../data/chart-colors.json';\n\n// a reference to the default graphic container, change if needed\nconst container = d3.select('#covid-tests');\n\n// a helper function to grab the container's width\nconst getFrameWidth = () => container.node().offsetWidth;\n\n//set margins\nlet margin = {\n  top: 15,\n  left: 50,\n  bottom: 40,\n};\n\nlet breakPoint = 500;\n\n// grabbing totals\nlet dataTotals = [];\n\n// NOTE: THIS IS TEMPORARILY ADDED\n// to account for them not having testing data on 5/24\n// data['yesterday_date'] = '05_22_2020';\n\n// If we have incomplete data for the yesterday's date, let's use the day before\n// yesterday's date is what we use for the positivity rate\nlet cases_latest_date = data['cases_latest_date'];\n\nlet yesterday = moment(data['cases_latest_date'], 'M_D_YYYY')\n  .subtract(1, 'days')\n  .format('MM_DD_YYYY');\nlet yesterday_incomplete = data[yesterday].statewide_data.incomplete;\n\nif (yesterday_incomplete != undefined) {\n  if (\n    yesterday_incomplete.includes('viral_tests_diff') ||\n    yesterday_incomplete.includes('antibody_tests_diff') ||\n    yesterday_incomplete.includes('total_tests_diff')\n  ) {\n    cases_latest_date = yesterday;\n  }\n}\n\n// there are six properties prior that we want to exclude: 'latest_date', 'yesterday_date', 'week_ago', 'cases_latest_date', 'cases_yesterday_date', 'cases_week_ago', 'cases_yesterday_date'\nfor (let i = Object.keys(data).length - 1; i > 6; i--) {\n  if (\n    moment(Object.keys(data)[i], 'M_D_YYYY').isBefore(\n      moment(cases_latest_date, 'M_D_YYYY')\n    )\n  ) {\n    dataTotals.push({\n      incomplete: data[Object.keys(data)[i - 1]].statewide_data.incomplete,\n      unformatted_date: Object.keys(data)[i - 1],\n      total_tests: data[Object.keys(data)[i - 1]].statewide_data.total_tests,\n      new_tests:\n        data[Object.keys(data)[i - 1]].statewide_data.total_tests_diff &&\n        data[Object.keys(data)[i - 1]].statewide_data.total_tests_diff != ''\n          ? data[Object.keys(data)[i - 1]].statewide_data.total_tests_diff\n          : 0, // tests were not reported before 3/17, so we sub in a 0\n      viral_tests:\n        data[Object.keys(data)[i - 1]].statewide_data.viral_tests_diff < 0\n          ? 0\n          : data[Object.keys(data)[i - 1]].statewide_data.viral_tests_diff,\n      antibody_tests:\n        data[Object.keys(data)[i - 1]].statewide_data.antibody_tests_diff < 0\n          ? 0\n          : data[Object.keys(data)[i - 1]].statewide_data.antibody_tests_diff,\n    });\n  }\n}\n\n// changing to moment date+time objects\ndataTotals.forEach(d => (d.date = moment(d.unformatted_date, 'M_D_YYYY')));\n\n// Take out the last day because we won't have total\ndataTotals = dataTotals.slice(0, -1);\n\n// Add an id based on index to use for joining\ndataTotals.forEach((d, i) => (d.id = i));\n\n// any days that had missing data\nlet missedDates = dataTotals.filter(d => {\n  if (\n    d.antibody_tests == 'no_data' ||\n    d.viral_tests == 'no_data' ||\n    d.new_tests == 'no_data' ||\n    d.new_tests < 0\n  ) {\n    return true;\n  }\n});\n\n// Make object into array\nlet dataArray = dataTotals.map(d => d['total_tests']);\nlet dataMovingAvg = movingAvgSubtractMethod(dataArray, 7, 'moving_avg');\n\ndataTotals = mergeArrays(dataTotals, dataMovingAvg, 'id');\n\n// grabbing totals and ranges\nlet dateRange = d3.extent(dataTotals, d => d.date),\n  totalsMax = d3.max(dataTotals, d => d.new_tests);\n\n// set ranges\nlet x = d3.scaleTime().domain(dateRange);\nlet y = d3\n  .scaleLinear()\n  .domain([0, totalsMax])\n  .nice();\n\n// append svg\nlet svg = container.append('svg'),\n  g = svg.append('g').attr('class', 'line-chart'),\n  labels_g = svg.append('g').attr('class', 'labels-container');\n\nlet diagonalStripePattern = svg\n  .append('defs')\n  .append('pattern')\n  .attr('id', 'diagonal-stripe')\n  .attr('patternUnits', 'userSpaceOnUse')\n  .attr('patternTransform', 'rotate(45 0 0)')\n  .attr('width', 4)\n  .attr('height', 4);\n\ndiagonalStripePattern\n  .append('rect')\n  .attr('width', 4)\n  .attr('height', 4)\n  .style('fill', colors.bar_default);\n\ndiagonalStripePattern\n  .append('line')\n  .attr('x1', 0)\n  .attr('y1', 0)\n  .attr('x2', 0)\n  .attr('y2', 4)\n  .style('stroke', 'black')\n  .style('stroke-width', 1);\n\nlet xAxis = g.append('g').attr('class', 'axis axis--x'),\n  yAxis = g.append('g').attr('class', 'axis axis--y');\n\nlet line = d3\n  .line()\n  .defined(d => !isNaN(d.moving_avg))\n  .x(d => x(d.date))\n  .y(d => y(d.moving_avg));\n\ndataTotals.filter(line.defined());\n\n// Get the new starting date because the state did not provide comprehensive deaths data before then\nconst start_date = dataTotals.filter(d => d.unformatted_date == '05_14_2020');\n\n// Filter out everything before the new starting date\nconst dataTotals2 = dataTotals.filter(d => d.date < start_date[0].date);\nconst dataTotals3 = dataTotals.filter(d => {\n  return (\n    d.date >= start_date[0].date &&\n    !missedDates.map(d => d.date).includes(d.date) // filter out any dates that have missing test data\n  );\n});\n\nlet bars = g\n  .selectAll('.bar')\n  .data(dataTotals2)\n  .enter()\n  .append('rect')\n  .attr('class', 'bar')\n  .attr('fill', colors.bar_neutral)\n  .attr('opacity', 1);\n\nlet viral_bars = g\n  .selectAll('.viral_bar')\n  .data(dataTotals3)\n  .enter()\n  .append('rect')\n  .attr('class', 'viral_bar')\n  .attr('fill', d => {\n    if (d.incomplete && d.incomplete.includes('viral_tests_diff'))\n      // color incomplete bars gray\n      return colors.bar_neutral;\n    else return colors.bar_viral;\n  })\n  .attr('opacity', 1);\n\nlet antibody_bars = g\n  .selectAll('.antibody_bar')\n  .data(dataTotals3)\n  .enter()\n  .append('rect')\n  .attr('class', 'antibody_bar')\n  .attr('fill', d => {\n    if (d.incomplete && d.incomplete.includes('antibody_tests_diff'))\n      // color incomplete bars gray\n      return colors.bar_neutral;\n    else return colors.bar_antibody;\n  })\n  .attr('opacity', 1);\n\n// days that did not have the antibody and viral breakouts\n// Note: DSHS changed its viral tests numbers for June 6 so that the total number of viral tests actually decreased instead of increased giving us a negative daily viral tests so we have to make it not visible.\nlet missed_day_bars = g\n  .selectAll('.missed_day_bar')\n  .data(missedDates)\n  .enter()\n  .append('rect')\n  .attr('class', 'missed_day_bar')\n  .style('fill', d => {\n    return d.unformatted_date == '06_06_2020' ? '#FFFFFF' : colors.bar_neutral;\n  })\n  .attr('opacity', 1);\n\n// filter out days with no moving average\nlet dataTotalsNoMovingAvg = dataTotals.filter(d => {\n  if (\n    isNaN(d.moving_avg) ||\n    d.moving_avg < 0 ||\n    d.incomplete == '7_day_avg_tests'\n  ) {\n    return false;\n  } else {\n    return true;\n  }\n});\n\nlet pathOutline = g\n  .append('path')\n  .data([dataTotalsNoMovingAvg])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', '#fff')\n  .attr('stroke-width', 4);\n\nlet path = g\n  .append('path')\n  .data([dataTotalsNoMovingAvg])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', colors.line_moving_avg)\n  .attr('stroke-width', 2);\n\nconst day_for_label = [[dataTotalsNoMovingAvg][0][6]]; // Gets the day that where the 7-day average label will be next to\n\nlet moving_avg_label = g.append('g').attr('class', 'moving-avg-label');\n\nlet moving_avg_g = moving_avg_label\n  .selectAll('g')\n  .data(day_for_label)\n  .enter()\n  .append('g');\n\nlet moving_avgText = moving_avg_g.append('g').attr('class', 'label-text');\n\nmoving_avgText\n  .append('text')\n  .text('7-day average')\n  .attr('fill', colors.line_moving_avg)\n  .attr('font-weight', 700);\n\nlet labels = labels_g.append('g').attr('class', 'labeled-elements');\n\nlet labelElements = labels\n  .selectAll('g')\n  .data(getLabeledData(dataTotalsNoMovingAvg, ['']))\n  .enter()\n  .append('g')\n  .attr('class', 'label-element');\n\nlet labelText = labelElements.append('g').attr('class', 'label-text');\n\nlabelText\n  .append('text')\n  .text((d, i) => {\n    if (i === 0) {\n      let month = apmonth(new Date(d.date)),\n        day = d.date.format('D');\n\n      return `${month} ${day}`;\n    } else return '';\n  })\n  .attr('font-weight', 700);\n\nlet casesLabel = labelText\n  .append('text')\n  .attr('fill', colors.line_moving_avg)\n  .text(d => {\n    return `${intcomma(Math.round(d.moving_avg))} test${pluralize(\n      d.moving_avg\n    )}`;\n  });\n\n// Goal annotation\nlet events = g.append('g').attr('class', 'events');\n\nlet eventGroups = events\n  .selectAll('g')\n  .data([\n    {\n      event_desktop: 'Goal: 30,000 tests',\n      event_mobile: 'Goal: 30,000',\n      rate_threshold: 30000,\n    },\n  ])\n  .enter()\n  .append('g');\n\nlet eventText = eventGroups.append('text');\n\nlet eventLines = eventGroups\n  .append('line')\n  .attr('stroke', '#787878')\n  .attr('stroke-width', '1px')\n  .attr('stroke-dasharray', 5);\n\nfunction resize() {\n  let frameWidth = getFrameWidth(),\n    frameHeight;\n\n  if (frameWidth < breakPoint) {\n    frameHeight = 375;\n    margin.right = 75;\n  } else {\n    frameHeight = 425;\n    margin.right = 95;\n  }\n\n  let chartWidth = frameWidth - margin.left - margin.right,\n    chartHeight = frameHeight - margin.bottom;\n\n  svg.attr('width', frameWidth).attr('height', frameHeight);\n  g.attr('width', chartWidth).attr(\n    'transform',\n    `translate(${margin.left},${margin.top})`\n  );\n  labels_g.attr('transform', `translate(${margin.left},${margin.top})`);\n\n  let barWidth = chartWidth / dataTotals.length;\n\n  x.range([barWidth / 1.5, chartWidth - barWidth / 1.5]);\n  y.range([chartHeight, 0]);\n\n  bars\n    .attr('width', barWidth - barWidth / 5)\n    .attr('x', d => x(d.date) - barWidth / 2)\n    .attr('y', d => y(d.new_tests))\n    .attr('height', d => chartHeight - y(d.new_tests));\n\n  antibody_bars\n    .attr('width', barWidth - barWidth / 5)\n    .attr('x', d => x(d.date) - barWidth / 2)\n    .attr('y', d => y(d.antibody_tests))\n    .attr('height', d => chartHeight - y(d.antibody_tests));\n\n  viral_bars\n    .attr('width', barWidth - barWidth / 5)\n    .attr('x', d => x(d.date) - barWidth / 2)\n    .attr('y', d => y(d.antibody_tests) - (chartHeight - y(d.viral_tests)))\n    .attr('height', d => chartHeight - y(d.viral_tests));\n\n  missed_day_bars\n    .attr('width', barWidth - barWidth / 5)\n    .attr('x', d => x(d.date) - barWidth / 2)\n    .attr('y', d => y(d.new_tests))\n    .attr('height', d => {\n      if (d.new_tests == 'no_data' || d.new_tests < 0) return 0;\n      else return chartHeight - y(d.new_tests);\n    });\n\n  xAxis\n    .call(\n      d3\n        .axisBottom(x)\n        .ticks(frameWidth < breakPoint ? 10 : 15)\n        .tickFormat((d, i) => {\n          return frameWidth < breakPoint\n            ? customMobileDateFormatFour(d, i)\n            : customDateFormat(d, i, 2);\n        })\n    )\n    .attr('transform', `translate(0,${frameHeight - margin.bottom})`);\n\n  yAxis.call(\n    d3\n      .axisLeft(y)\n      .ticks(5)\n      .tickSize(-chartWidth)\n      .tickFormat(customNumFormat)\n  );\n\n  pathOutline.attr('d', line);\n  path.attr('d', line);\n\n  moving_avg_g\n    .attr('transform', d => `translate(${x(d.date)},${y(d.moving_avg)})`)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  moving_avgText\n    .attr('transform', (d, i) => {\n      if (i === 0 && frameWidth < breakPoint) {\n        return 'translate(0, -11)';\n      } else return 'translate(0, -11)';\n    })\n    .attr('text-anchor', 'start');\n\n  labelElements\n    .attr('transform', d => `translate(${x(d.date)},${y(d.moving_avg)})`)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  labelText\n    .attr('transform', (d, i) => {\n      if (i === 0 && frameWidth < breakPoint) {\n        return 'translate(9, 0)';\n      } else return 'translate(15, 0)';\n    })\n    .attr('text-anchor', 'start');\n\n  casesLabel.attr('dy', frameWidth < breakPoint ? 16 : 17);\n\n  // Goal annotation\n  eventGroups.attr('transform', d => `translate(0,${y(d.rate_threshold)})`);\n\n  eventLines.attr('x1', 0).attr('x2', chartWidth);\n\n  eventText\n    .attr('class', 'label-text font-weight-bold')\n    .text(d => (frameWidth < breakPoint ? d.event_mobile : d.event_desktop))\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px')\n    .attr('dx', frameWidth < breakPoint ? 5 : 10)\n    .attr('dy', frameWidth < breakPoint ? -7 : -10);\n}\n\n// call resize on load\nresize();\nwindow.addEventListener('resize', _.debounce(resize, 200));\n\n// OUTSIDE OF RESIZE()\n\n// let events = g.append('g').attr('class', 'events');\n\n// let eventGroups = events\n//   .selectAll('g')\n//   .data([\n//     {\n//       event_desktop: 'San Antonio opens its first drive-thru testing site',\n//       event_mobile: 'Bush',\n//       date: '3_13',\n//     },\n//   ])\n//   .enter()\n//   .append('g');\n\n// let eventText = eventGroups.append('text');\n\n// let eventLines = eventGroups\n//   .append('line')\n//   .attr('stroke', '#d1d1d1')\n//   .attr('stroke-width', '1px')\n//   .attr('stroke-dasharray', 5);\n\n// let metaInfo = g\n//   .append('g')\n//   .attr('class', 'meta')\n//   .attr('font-size', '12px')\n//   .attr('fill', 'hsl(0, 0%, 47%)');\n\n// this is the same function findChartMeta() in nunjucks.js\n// find a way to import that function here\n// metaInfo\n//   .append('text')\n//   .text(`Note: ${data.Meta.find(d => d.Chart === 'Line').Note}`)\n//   .attr('y', 45);\n\n// metaInfo\n//   .append('text')\n//   .html(\n//     `Source: <a style=\"fill: hsl(0, 0%, 47%); text-decoration: underline;\"href=\"https://www.cbp.gov/sites/default/files/assets/documents/2019-Mar/bp-total-monthly-apps-sector-area-fy2018.pdf\">${\n//       data.Meta.find(d => d.Chart === 'Line').Source\n//     }</a>`\n//   )\n//   .attr('y', 65);\n\n//arrow marker, need to append to the svg first to use\n// svg\n//   .append('marker')\n//   .attr('id', 'arrow')\n//   .attr('viewBox', '-10 -10 20 20')\n//   .attr('markerWidth', 10)\n//   .attr('markerHeight', 10)\n//   .attr('fill', 'hsl(0, 0%, 29%)')\n//   .attr('orient', 'auto-start-reverse')\n//   .append('path')\n//   .attr('d', 'M-6.75,-6.75 L 0,0 L -6.75,6.75');\n\n// let swoopySel = svg.append('g').attr('class', 'swoopy-drag-lines');\n\n// //annotations for swoopyDrag\n// let annotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-25,-19C-32,-38,-47,-49,-63,-50',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-186, -77],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-186, -63],\n//   },\n// ];\n\n// let mobileAnnotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-12,-13C-30,-13,-42,-24,-46,-39',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-105, -75],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-105, -62],\n//   },\n// ];\n\n// INSIDE OF RESIZE()\n\n// eventGroups.attr(\n//   'transform',\n//   d => `translate(${(0, x(moment(d.date, 'M_D')))})`\n// );\n\n// eventLines.attr('y1', 5).attr('y2', chartHeight);\n\n// eventText\n//   .text(d => (frameWidth < breakPoint ? d.event_mobile : d.event_desktop))\n//   .attr('font-size', frameWidth < breakPoint ? '12px' : '14px')\n//   .attr('dx', frameWidth < breakPoint ? 5 : 10)\n//   .attr('dy', frameWidth < breakPoint ? 14 : 20);\n\n// metaInfo.attr('transform', `translate(0, ${chartHeight})`);\n\n// let swoopy = swoopyDrag()\n//   .x(d => x(d.xVal) + (frameWidth < breakPoint ? 5 : 20))\n//   .y(d => y(d.yVal) + 35)\n//   .draggable(false)\n//   .annotations(frameWidth < breakPoint ? mobileAnnotations : annotations);\n\n// swoopySel\n//   .attr('transform', `translate(${margin.left},${margin.top})`)\n//   .call(swoopy)\n//   .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n// swoopySel.selectAll('text').each(function(d) {\n//   d3.select(this)\n//     .text('')\n//     .attr('font-weight', d.weight)\n//     .tspans(wordwrap(d.text, frameWidth < breakPoint ? 24 : 24));\n// });\n\n// swoopySel.selectAll('path').attr('marker-start', 'url(#arrow)');\n","/* eslint-disable no-unused-vars */\nimport * as d3 from 'd3';\nimport _ from 'lodash';\nimport { intcomma, apmonth, apdate, pluralize } from 'journalize';\nimport {\n  movingAvg,\n  customDateFormat,\n  customMobileDateFormat,\n  customNumFormat,\n  getLabeledData,\n  mergeArrays,\n} from '../utils/charts-utils';\nimport * as moment from 'moment';\nimport { wordwrap } from 'd3-jetpack';\n// import { swoopyDrag } from '../swoopy-drag';\n\nimport data from '../../../data/daily_tables/all_tables.json';\nimport colors from '../../../data/chart-colors.json';\n\n// console.log(moment('4_14_2020 4:00 pm', 'M_D_YYYY h:mm a').utc().format())\n\n// a reference to the default graphic container, change if needed\nconst container = d3.select('#new-cases');\n\n// a helper function to grab the container's width\nconst getFrameWidth = () => container.node().offsetWidth;\n\n//set margins\nlet margin = {\n  top: 15,\n  left: 55,\n  right: 45,\n  bottom: 40,\n};\n\nlet breakPoint = 500;\n\n// grabbing totals\nlet dataTotals = [];\n\n// there are six properties prior that we want to exclude: 'latest_date', 'yesterday_date', 'week_ago', 'cases_latest_date', 'cases_yesterday_date', 'cases_week_ago', 'cases_yesterday_date'\nfor (let i = Object.keys(data).length - 1; i > 6; i--) {\n  var case_dif = data[Object.keys(data)[i - 1]].statewide_data.case_dif;\n\n  if (\n    moment(Object.keys(data)[i], 'M_D_YYYY').isBefore(\n      moment(data['cases_latest_date'], 'M_D_YYYY')\n    )\n  ) {\n    dataTotals.push({\n      unformatted_date: Object.keys(data)[i - 1],\n      new_cases: case_dif ? case_dif : 0,\n      incomplete: data[Object.keys(data)[i - 1]].statewide_data.incomplete,\n    });\n  }\n}\n\n// changing to moment date+time objects\ndataTotals.forEach(d => (d.date = moment(d.unformatted_date, 'M_D_YYYY')));\n\n// Add an id based on index to use for joining\ndataTotals.forEach((d, i) => (d.id = i));\n\n// Make object into array\nlet dataArray = dataTotals.map(d => d['new_cases']);\n\nlet dataMovingAvg = movingAvg(dataArray, 7, undefined, 'moving_avg');\n\ndataTotals = mergeArrays(dataTotals, dataMovingAvg, 'id');\n\n// grabbing totals and ranges\nlet dateRange = d3.extent(dataTotals, d => d.date),\n  totalsMax = d3.max(dataTotals, d => d.new_cases);\n\n// set ranges\nlet x = d3.scaleTime().domain(dateRange);\nlet y = d3\n  .scaleLinear()\n  .domain([0, totalsMax])\n  .nice();\n\n// append svg\nlet svg = container.append('svg'),\n  g = svg.append('g').attr('class', 'line-chart'),\n  labels_g = svg.append('g').attr('class', 'labels-container');\n\nlet xAxis = g.append('g').attr('class', 'axis axis--x'),\n  yAxis = g.append('g').attr('class', 'axis axis--y');\n\nlet line = d3\n  .line()\n  .defined(d => !isNaN(d.moving_avg))\n  .x(d => x(d.date))\n  .y(d => y(d.moving_avg));\n\nlet bars = g\n  .selectAll('.bar')\n  .data(dataTotals)\n  .enter()\n  .append('rect')\n  .attr('class', 'bar')\n  .attr('fill', d => {\n    if (d.incomplete && d.incomplete.includes('case_dif'))\n      // color incomplete bars gray\n      return colors.bar_neutral;\n    else\n      return d.id == dataTotals.length - 1\n        ? colors.bar_highlight\n        : colors.bar_default;\n  })\n  .attr('opacity', 1);\n\nlet dateReopening = moment('5_01_2020', 'M_D_YYYY');\nlet dateMaskOrder = moment('7_02_2020', 'M_D_YYYY');\n\nlet reopeningGroup = g.append('g').attr('class', 'reopening-line');\nlet reopeningLine = reopeningGroup\n  .append('line')\n  .attr('x1', 0)\n  .attr('x2', 0)\n  .attr('y1', 0)\n  .attr('stroke', '#797979')\n  .attr('stroke-width', '1px')\n  .attr('stroke-dasharray', '3px');\nlet reopeningText = reopeningGroup.append('text');\n\nlet maskorderGroup = g.append('g').attr('class', 'reopening-line');\nlet maskorderLine = maskorderGroup\n  .append('line')\n  .attr('x1', 0)\n  .attr('x2', 0)\n  .attr('y1', 0)\n  .attr('stroke', '#797979')\n  .attr('stroke-width', '1px')\n  .attr('stroke-dasharray', '3px');\nlet maskorderText = maskorderGroup.append('text');\n\ndataTotals.filter(line.defined());\n\nlet pathOutline = g\n  .append('path')\n  .data([dataTotals])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', '#fff')\n  .attr('stroke-width', 4);\n\nlet path = g\n  .append('path')\n  .data([dataTotals])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', colors.line_moving_avg)\n  .attr('stroke-width', 2);\n\nconst day_for_label = [[dataTotals][0][6]]; // Gets the day that where the 7-day average label will be next to\n\nlet moving_avg_label = g.append('g').attr('class', 'moving-avg-label');\n\nlet moving_avg_g = moving_avg_label\n  .selectAll('g')\n  .data(day_for_label)\n  .enter()\n  .append('g');\n\nlet moving_avgText = moving_avg_g.append('g').attr('class', 'label-text');\n\nmoving_avgText\n  .append('text')\n  .text('7-day average')\n  .attr('fill', colors.line_moving_avg)\n  .attr('font-weight', 700);\n\nlet labels = labels_g.append('g').attr('class', 'labeled-elements');\n\nlet labelElements = labels\n  .selectAll('g')\n  .data(getLabeledData(dataTotals, ['']))\n  .enter()\n  .append('g')\n  .attr('class', 'label-element');\n\nlet labelText = labelElements.append('g').attr('class', 'label-text');\n\nlabelText\n  .append('text')\n  .text((d, i) => {\n    if (i === 0) {\n      let month = apmonth(new Date(d.date)),\n        day = d.date.format('D');\n\n      return `${month} ${day}`;\n    } else return '';\n  })\n  .attr('font-weight', 700);\n\nlet casesLabel = labelText.append('text').text(d => {\n  return `${intcomma(d.new_cases)} case${pluralize(d.new_cases)}`;\n});\n\nfunction resize() {\n  let frameWidth = getFrameWidth(),\n    frameHeight;\n\n  if (frameWidth < breakPoint) {\n    frameHeight = 275;\n    margin.right = 75;\n  } else {\n    frameHeight = 325;\n    margin.right = 95;\n  }\n\n  let chartWidth = frameWidth - margin.left - margin.right,\n    chartHeight = frameHeight - margin.bottom;\n\n  svg.attr('width', frameWidth).attr('height', frameHeight);\n  g.attr('width', chartWidth).attr(\n    'transform',\n    `translate(${margin.left},${margin.top})`\n  );\n  labels_g.attr('transform', `translate(${margin.left},${margin.top})`);\n\n  let barWidth = chartWidth / dataTotals.length;\n\n  x.range([barWidth / 1.5, chartWidth - barWidth / 1.5]);\n  y.range([chartHeight, 0]);\n\n  bars\n    .attr('width', barWidth - barWidth / 5)\n    .attr('x', d => x(d.date) - barWidth / 2)\n    .attr('y', d => y(d.new_cases))\n    .attr('height', d => chartHeight - y(d.new_cases));\n\n  xAxis\n    .call(\n      d3\n        .axisBottom(x)\n        .ticks(15)\n        .tickFormat((d, i) => {\n          return frameWidth < breakPoint\n            ? customMobileDateFormat(d, i)\n            : customDateFormat(d, i, 2);\n        })\n    )\n    .attr('transform', `translate(0,${frameHeight - margin.bottom})`);\n\n  yAxis.call(\n    d3\n      .axisLeft(y)\n      .ticks(5)\n      .tickSize(-chartWidth)\n      .tickFormat(customNumFormat)\n  );\n\n  pathOutline.attr('d', line);\n  path.attr('d', line);\n\n  moving_avg_g\n    .attr('transform', d => `translate(${x(d.date)},${y(d.moving_avg)})`)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  moving_avgText\n    .attr('transform', (d, i) => {\n      if (i === 0 && frameWidth < breakPoint) {\n        return 'translate(0, -11)';\n      } else return 'translate(0, -11)';\n    })\n    .attr('text-anchor', 'start');\n\n  labelElements\n    .attr('transform', d => `translate(${x(d.date)},${y(d.new_cases)})`)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  labelText\n    .attr('transform', (d, i) => {\n      if (i === 0 && frameWidth < breakPoint) {\n        return 'translate(9, 0)';\n      } else return 'translate(15, 0)';\n    })\n    .attr('text-anchor', 'start');\n\n  casesLabel.attr('dy', frameWidth < breakPoint ? 16 : 17);\n\n  reopeningGroup.attr('transform', `translate(${x(dateReopening)}, 0)`);\n  reopeningLine.attr('y2', chartHeight);\n  reopeningText\n    .attr('y', frameWidth < breakPoint ? 0 : 13)\n    .text('')\n    .tspans(wordwrap('Reopening began May 1', 15))\n    .attr('dx', 5)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  maskorderGroup.attr('transform', `translate(${x(dateMaskOrder)}, 0)`);\n  maskorderLine.attr('y2', chartHeight);\n  maskorderText\n    .attr('y', frameWidth < breakPoint ? 75 : 95)\n    .attr('text-anchor', 'end')\n    .text('')\n    .tspans(wordwrap('Mask order issued July 2', 15))\n    .attr('dx', -5)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n}\n\n// call resize on load\nresize();\nwindow.addEventListener('resize', _.debounce(resize, 200));\n\n// OUTSIDE OF RESIZE()\n\n// let events = g.append('g').attr('class', 'events');\n\n// let eventGroups = events\n//   .selectAll('g')\n//   .data([\n//     {\n//       event_desktop: 'San Antonio opens its first drive-thru testing site',\n//       event_mobile: 'Bush',\n//       date: '3_13',\n//     },\n//   ])\n//   .enter()\n//   .append('g');\n\n// let eventText = eventGroups.append('text');\n\n// let eventLines = eventGroups\n//   .append('line')\n//   .attr('stroke', '#d1d1d1')\n//   .attr('stroke-width', '1px')\n//   .attr('stroke-dasharray', 5);\n\n// let metaInfo = g\n//   .append('g')\n//   .attr('class', 'meta')\n//   .attr('font-size', '12px')\n//   .attr('fill', 'hsl(0, 0%, 47%)');\n\n// this is the same function findChartMeta() in nunjucks.js\n// find a way to import that function here\n// metaInfo\n//   .append('text')\n//   .text(`Note: ${data.Meta.find(d => d.Chart === 'Line').Note}`)\n//   .attr('y', 45);\n\n// metaInfo\n//   .append('text')\n//   .html(\n//     `Source: <a style=\"fill: hsl(0, 0%, 47%); text-decoration: underline;\"href=\"https://www.cbp.gov/sites/default/files/assets/documents/2019-Mar/bp-total-monthly-apps-sector-area-fy2018.pdf\">${\n//       data.Meta.find(d => d.Chart === 'Line').Source\n//     }</a>`\n//   )\n//   .attr('y', 65);\n\n//arrow marker, need to append to the svg first to use\n// svg\n//   .append('marker')\n//   .attr('id', 'arrow')\n//   .attr('viewBox', '-10 -10 20 20')\n//   .attr('markerWidth', 10)\n//   .attr('markerHeight', 10)\n//   .attr('fill', 'hsl(0, 0%, 29%)')\n//   .attr('orient', 'auto-start-reverse')\n//   .append('path')\n//   .attr('d', 'M-6.75,-6.75 L 0,0 L -6.75,6.75');\n\n// let swoopySel = svg.append('g').attr('class', 'swoopy-drag-lines');\n\n// //annotations for swoopyDrag\n// let annotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-25,-19C-32,-38,-47,-49,-63,-50',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-186, -77],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-186, -63],\n//   },\n// ];\n\n// let mobileAnnotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-12,-13C-30,-13,-42,-24,-46,-39',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-105, -75],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-105, -62],\n//   },\n// ];\n\n// INSIDE OF RESIZE()\n\n// eventGroups.attr(\n//   'transform',\n//   d => `translate(${(0, x(moment(d.date, 'M_D')))})`\n// );\n\n// eventLines.attr('y1', 5).attr('y2', chartHeight);\n\n// eventText\n//   .text(d => (frameWidth < breakPoint ? d.event_mobile : d.event_desktop))\n//   .attr('font-size', frameWidth < breakPoint ? '12px' : '14px')\n//   .attr('dx', frameWidth < breakPoint ? 5 : 10)\n//   .attr('dy', frameWidth < breakPoint ? 14 : 20);\n\n// metaInfo.attr('transform', `translate(0, ${chartHeight})`);\n\n// let swoopy = swoopyDrag()\n//   .x(d => x(d.xVal) + (frameWidth < breakPoint ? 5 : 20))\n//   .y(d => y(d.yVal) + 35)\n//   .draggable(false)\n//   .annotations(frameWidth < breakPoint ? mobileAnnotations : annotations);\n\n// swoopySel\n//   .attr('transform', `translate(${margin.left},${margin.top})`)\n//   .call(swoopy)\n//   .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n// swoopySel.selectAll('text').each(function(d) {\n//   d3.select(this)\n//     .text('')\n//     .attr('font-weight', d.weight)\n//     .tspans(wordwrap(d.text, frameWidth < breakPoint ? 24 : 24));\n// });\n\n// swoopySel.selectAll('path').attr('marker-start', 'url(#arrow)');\n","/* eslint-disable no-unused-vars */\nimport * as d3 from 'd3';\nimport _ from 'lodash';\nimport { intcomma, apmonth, apdate } from 'journalize';\nimport {\n  customDateFormat,\n  customMobileDateFormat,\n  customPercFormat,\n  getLabeledData,\n} from '../utils/charts-utils';\nimport * as moment from 'moment';\n// import { swoopyDrag } from '../swoopy-drag';\nimport { wordwrap } from 'd3-jetpack';\n\nimport data from '../../../data/daily_tables/all_tables.json';\nimport colors from '../../../data/chart-colors.json';\n\n// a reference to the default graphic container, change if needed\nconst container = d3.select('#positive-rate');\n\n// a helper function to grab the container's width\nconst getFrameWidth = () => container.node().offsetWidth;\n\n//set margins\nlet margin = {\n  top: 15,\n  left: 40,\n  bottom: 40,\n};\n\nlet breakPoint = 500;\n\n// grabbing totals\nlet dataTotals = [];\n\n// NOTE: THIS IS TEMPORARILY ADDED\n// to account for them not having testing data on 5/24\n// data['cases_latest_date'] = '08_23_2020';\n\n// If we have incomplete data for the yesterday's date, let's use the day before\n// yesterday's date is what we use for the positivity rate\nlet cases_latest_date = data['cases_latest_date'];\n\nlet yesterday = moment(data['cases_latest_date'], 'M_D_YYYY')\n  .subtract(1, 'days')\n  .format('MM_DD_YYYY');\nlet yesterday_incomplete = data[yesterday].statewide_data.incomplete;\n\nif (yesterday_incomplete != undefined) {\n  if (\n    yesterday_incomplete.includes('tests_diff') ||\n    yesterday_incomplete.includes('case_dif')\n  ) {\n    cases_latest_date = yesterday;\n  }\n}\n\n// Find the positive rate which is the ratio of positive cases for that day to the tests conducted that day\n// there are six properties prior that we want to exclude: 'latest_date', 'yesterday_date', 'week_ago', 'cases_latest_date', 'cases_yesterday_date', 'cases_week_ago', 'cases_yesterday_date'\nfor (let i = Object.keys(data).length - 1; i > 6; i--) {\n  if (\n    moment(Object.keys(data)[i], 'M_D_YYYY').isBefore(\n      moment(cases_latest_date, 'M_D_YYYY')\n    )\n  ) {\n    dataTotals.push({\n      incomplete: data[Object.keys(data)[i - 1]].statewide_data.incomplete,\n      unformatted_date: Object.keys(data)[i - 1],\n      positive_rate:\n        data[Object.keys(data)[i - 1]].statewide_data.specimen_positivity_rate,\n    });\n  }\n}\n\n// any days that had missing data\nlet missedDates = dataTotals.filter(d => {\n  if (d.positive_rate == 'no_data') {\n    return true;\n  }\n});\n\n// changing to moment date+time objects\ndataTotals.forEach(d => (d.date = moment(d.unformatted_date, 'M_D_YYYY')));\n\n// Get the new starting date because the state did not provide comprehensive deaths data before then\nconst start_date = dataTotals.filter(d => d.unformatted_date == '04_01_2020');\n\n// Filter out everything before the new starting date\ndataTotals = dataTotals.filter(d => d.date >= start_date[0].date);\nconst dataTotals2 = dataTotals.filter(d => {\n  return (\n    d.date >= start_date[0].date &&\n    !missedDates.map(d => d.date).includes(d.date) // filter out any dates that have missing test data\n  );\n})\n\n// Checks to see if the latest date we have is also missing the positivity rate\n// if so, filter it out so we use the previous date as the latest date\nvar latest_date = dataTotals[dataTotals.length - 1].date;\n\nif (missedDates.map(d => d.date).includes(latest_date)) {\n  dataTotals = dataTotals2;\n}\n\n\n// sort the data from earliest date to latest data\ndataTotals.sort((a, b) => (b.date.isBefore(a.date) ? 1 : -1));\n\n// slice the latest date off because positive rate lags a day behind\ndataTotals = dataTotals.slice(0, -1);\n\n// changing to moment date+time objects\ndataTotals.forEach(d => (d.date = moment(d.unformatted_date, 'M_D_YYYY')));\n\n// Add an id based on index to use for joining\ndataTotals.forEach((d, i) => (d.id = i));\n\n// grabbing totals and ranges\nlet dateRange = d3.extent(dataTotals, d => d.date),\n  totalsMaxAvg = d3.max(dataTotals, d => d.positive_rate);\n\n// set ranges\nlet x = d3.scaleTime().domain(dateRange);\nlet y = d3\n  .scaleLinear()\n  .domain([0, 40])\n  .nice();\n\n// append svg\nlet svg = container.append('svg'),\n  g = svg.append('g').attr('class', 'line-chart'),\n  labels_g = svg.append('g').attr('class', 'labels-container');\n\nlet xAxis = g.append('g').attr('class', 'axis axis--x'),\n  yAxis = g.append('g').attr('class', 'axis axis--y');\n\n// Get the new starting date for us to switch out to molecular tests, which is about 7 days after they started reporting it on May 13\nconst start_for_7_day_avg = dataTotals.filter(\n  d => d.unformatted_date == '05_20_2020'\n);\n\nlet line = d3\n  .line()\n  .defined(d => !isNaN(d.positive_rate))\n  .x(d => x(d.date))\n  .y(function(d) {\n    return y(d.positive_rate);\n  });\n\n// Note: DSHS changed its viral tests numbers for June 6 so that the total number of viral tests actually decreased instead of increased giving us a negative daily viral tests and completely screwing up the positive rate by giving us a negative positive rate so we have to make it not visible.\n// Note: DSHS started calculating their seven-day average using just molecular tests on August 9. We've adjusted this to reflect that change.\n\nlet missedDatesArea = g\n  .selectAll('.missing-dates')\n  .data(missedDates)\n  .enter()\n  .append('rect')\n  .attr('class', 'missing-dates')\n  .attr('fill', d => colors.bar_neutral)\n  .attr('opacity', 0.5);\n\nlet dateReopening = moment('5_01_2020', 'M_D_YYYY');\nlet dateMaskOrder = moment('7_02_2020', 'M_D_YYYY');\n\n// filter out days with no moving average\nlet dataTotalsNoMovingAvgSubtract = dataTotals.filter(\n  d => !isNaN(d.positive_rate)\n);\n\nlet pathOutline = g\n  .append('path')\n  .data([dataTotalsNoMovingAvgSubtract])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', '#fff')\n  .attr('stroke-width', 4);\n\nlet path = g\n  .append('path')\n  .data([dataTotalsNoMovingAvgSubtract])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', colors.line_moving_avg)\n  .attr('stroke-width', 2);\n\nlet reopeningGroup = g.append('g').attr('class', 'reopening-line');\nlet reopeningLine = reopeningGroup\n  .append('line')\n  .attr('x1', 0)\n  .attr('x2', 0)\n  .attr('y1', 0)\n  .attr('stroke', '#797979')\n  .attr('stroke-width', '1px')\n  .attr('stroke-dasharray', '3px');\nlet reopeningText = reopeningGroup.append('text');\n\nlet maskorderGroup = g.append('g').attr('class', 'reopening-line');\nlet maskorderLine = maskorderGroup\n  .append('line')\n  .attr('x1', 0)\n  .attr('x2', 0)\n  .attr('y1', 0)\n  .attr('stroke', '#797979')\n  .attr('stroke-width', '1px')\n  .attr('stroke-dasharray', '3px');\nlet maskorderText = maskorderGroup.append('text');\n\nconst day_for_label = [[dataTotals][0][6]]; // Gets the day that where the 7-day average label will be next to\n\nlet moving_avg_label = g.append('g').attr('class', 'moving-avg-label');\n\nlet moving_avg_g = moving_avg_label\n  .selectAll('g')\n  .data(day_for_label)\n  .enter()\n  .append('g');\n\nlet moving_avgText = moving_avg_g.append('g').attr('class', 'label-text');\n\nmoving_avgText\n  .append('text')\n  .text('7-day average')\n  .attr('fill', colors.line_moving_avg)\n  .attr('font-weight', 700);\n\nlet labels = labels_g.append('g').attr('class', 'labeled-elements');\n\nlet labelElements = labels\n  .selectAll('g')\n  .data(getLabeledData(dataTotals, ['']))\n  .enter()\n  .append('g')\n  .attr('class', 'label-element');\n\nlet labelText = labelElements.append('g').attr('class', 'label-text');\n\n// labelText\n//   .append('text')\n//   .text((d, i) => {\n//     if (i === 0) {\n//       let month = apmonth(new Date(d.date)),\n//         day = d.date.format('D');\n\n//       return `${month} ${day}`;\n//     } else return '';\n//   })\n//   .attr('font-weight', 700);\n\n// let casesLabel = labelText\n//   .append('text')\n//   .attr('fill', colors.line_moving_avg)\n//   .text(d => {\n//     return `${d3.format('.3')(d.positive_rate)}%`;\n//   });\n\nlet events = g.append('g').attr('class', 'events');\n\nlet eventGroups = events\n  .selectAll('g')\n  .data([\n    {\n      event_desktop: 'Goal: Below 6%',\n      event_mobile: 'Goal: Below 6%',\n      rate_threshold: 6,\n    },\n  ])\n  .enter()\n  .append('g');\n\nlet eventText = eventGroups.append('text');\n\nlet eventLines = eventGroups\n  .append('line')\n  .attr('stroke', '#787878')\n  .attr('stroke-width', '1px')\n  .attr('stroke-dasharray', 5);\n\nfunction resize() {\n  let frameWidth = getFrameWidth(),\n    frameHeight;\n\n  if (frameWidth < breakPoint) {\n    frameHeight = 275;\n    margin.right = 60;\n  } else {\n    frameHeight = 325;\n    margin.right = 65;\n  }\n\n  let chartWidth = frameWidth - margin.left,\n    chartHeight = frameHeight - margin.bottom;\n\n  svg.attr('width', frameWidth).attr('height', frameHeight);\n  g.attr('width', chartWidth).attr(\n    'transform',\n    `translate(${margin.left},${margin.top})`\n  );\n  labels_g.attr('transform', `translate(${margin.left},${margin.top})`);\n\n  let barWidth = chartWidth / dataTotals.length;\n\n  x.range([barWidth / 1.5, chartWidth - barWidth / 1.5]);\n  y.range([chartHeight, 0]);\n\n  xAxis\n    .call(\n      d3\n        .axisBottom(x)\n        .ticks(15)\n        .tickFormat((d, i) => {\n          return frameWidth < breakPoint\n            ? customMobileDateFormat(d, i)\n            : customDateFormat(d, i, 4);\n        })\n    )\n    .attr('transform', `translate(0,${frameHeight - margin.bottom})`);\n\n  yAxis.call(\n    d3\n      .axisLeft(y)\n      .ticks(5)\n      .tickSize(-chartWidth)\n      .tickFormat(customPercFormat)\n  );\n\n  missedDatesArea\n    .attr('width', barWidth) // to prevent a slight overlap\n    .attr('x', d => x(d.date) - barWidth / 2 - barWidth / 5 / 2) // space between bars is 1.5 so we shift this area half of that\n    .attr('y', 0)\n    .attr('height', chartHeight);\n\n  pathOutline.attr('d', line);\n  path.attr('d', line);\n\n  moving_avg_g\n    .attr('transform', d => `translate(${x(d.date)},${y(d.positive_rate)})`)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  moving_avgText\n    .attr('transform', (d, i) => {\n      if (i === 0 && frameWidth < breakPoint) {\n        return 'translate(0, -14)';\n      } else return 'translate(0, -14)';\n    })\n    .attr('text-anchor', 'start');\n\n  labelElements\n    .attr('transform', d => `translate(${x(d.date)},${y(d.positive_rate)})`)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  // labelText\n  //   .attr('transform', (d, i) => {\n  //     if (i === 0 && frameWidth < breakPoint) {\n  //       return 'translate(15, 0)';\n  //     } else return 'translate(15, 0)';\n  //   })\n  //   .attr('text-anchor', 'start');\n\n  // casesLabel.attr('dy', frameWidth < breakPoint ? 16 : 17);\n\n  eventGroups.attr('transform', d => `translate(0,${y(d.rate_threshold)})`);\n\n  eventLines.attr('x1', 0).attr('x2', chartWidth);\n\n  eventText\n    .attr('class', 'label-text font-weight-bold')\n    .text(d => (frameWidth < breakPoint ? d.event_mobile : d.event_desktop))\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px')\n    .attr('dx', frameWidth < breakPoint ? 5 : 10)\n    .attr('dy', frameWidth < breakPoint ? 16 : 18);\n\n  reopeningGroup.attr('transform', `translate(${x(dateReopening)}, 0)`);\n  reopeningLine.attr('y2', chartHeight);\n  reopeningText\n    .attr('y', frameWidth < breakPoint ? 25 : 92)\n    .text('')\n    .tspans(wordwrap('Reopening began May 1', 15))\n    .attr('dx', 5)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  maskorderGroup.attr('transform', `translate(${x(dateMaskOrder)}, 0)`);\n  maskorderLine.attr('y2', chartHeight);\n  maskorderText\n    .attr('y', frameWidth < breakPoint ? 80 : 92)\n    .attr('text-anchor', 'start')\n    .text('')\n    .tspans(wordwrap('Mask order issued July 2', 15))\n    .attr('dx', 5)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n}\n\n// call resize on load\nresize();\nwindow.addEventListener('resize', _.debounce(resize, 200));\n\n// OUTSIDE OF RESIZE()\n\n// let metaInfo = g\n//   .append('g')\n//   .attr('class', 'meta')\n//   .attr('font-size', '12px')\n//   .attr('fill', 'hsl(0, 0%, 47%)');\n\n// this is the same function findChartMeta() in nunjucks.js\n// find a way to import that function here\n// metaInfo\n//   .append('text')\n//   .text(`Note: ${data.Meta.find(d => d.Chart === 'Line').Note}`)\n//   .attr('y', 45);\n\n// metaInfo\n//   .append('text')\n//   .html(\n//     `Source: <a style=\"fill: hsl(0, 0%, 47%); text-decoration: underline;\"href=\"https://www.cbp.gov/sites/default/files/assets/documents/2019-Mar/bp-total-monthly-apps-sector-area-fy2018.pdf\">${\n//       data.Meta.find(d => d.Chart === 'Line').Source\n//     }</a>`\n//   )\n//   .attr('y', 65);\n\n// arrow marker, need to append to the svg first to use\n// svg\n//   .append('marker')\n//   .attr('id', 'arrow')\n//   .attr('viewBox', '-10 -10 20 20')\n//   .attr('markerWidth', 10)\n//   .attr('markerHeight', 10)\n//   .attr('fill', 'hsl(0, 0%, 29%)')\n//   .attr('orient', 'auto-start-reverse')\n//   .append('path')\n//   .attr('d', 'M-6.75,-6.75 L 0,0 L -6.75,6.75');\n\n// let swoopySel = svg.append('g').attr('class', 'swoopy-drag-lines');\n\n// // annotations for swoopyDrag\n// let annotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-25,-19C-32,-38,-47,-49,-63,-50',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-186, -77],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-186, -62],\n//   },\n// ];\n\n// let mobileAnnotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-16,-13C-30,-13,-42,-24,-46,-39',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-95, -76],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-95, -62],\n//   },\n// ];\n\n// INSIDE OF RESIZE()\n\n// metaInfo.attr('transform', `translate(0, ${chartHeight})`);\n\n// let swoopy = swoopyDrag()\n//   .x(d => x(d.xVal) + 10)\n//   .y(d => y(d.yVal))\n//   .draggable(false)\n//   .annotations(frameWidth < breakPoint ? mobileAnnotations : annotations);\n\n// swoopySel\n//   .attr('transform', `translate(${margin.left},${margin.top})`)\n//   .call(swoopy)\n//   .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n// swoopySel.selectAll('text').each(function(d) {\n//   d3.select(this)\n//     .text('')\n//     .attr('font-weight', d.weight)\n//     .tspans(wordwrap(d.text, frameWidth < breakPoint ? 24 : 24));\n// });\n\n// swoopySel.selectAll('path').attr('marker-start', 'url(#arrow)');\n","/* eslint-disable no-unused-vars */\nimport * as d3 from 'd3';\nimport _ from 'lodash';\nimport * as topojson from 'topojson-client';\nimport createBase from '../utils/d3-base';\nimport { intcomma } from 'journalize';\nimport {\n  highways,\n  cities,\n  add_legend_for_gray,\n  rate_perResidents,\n  relocateTooltip,\n} from '../utils/map-utils';\nimport * as ss from 'simple-statistics';\nimport loadAssetURL from '../utils/load-asset-url';\n\nconst partners = window.location.search;\nconst isPartners = partners ? true : false;\nconst TT_logo_present = loadAssetURL('TT-logo-present');\n\nimport topology from 'Assets/geography/texas_counties_roads.json';\nimport data from '../../../data/map/tx_covid_map.json';\n\nconst container = d3.select('#tx-rates-map');\n\nconst getFrameWidth = () => container.node().offsetWidth;\n\n// a helper function to clear the container of its contents\nconst clearContainer = () => container.html('');\n\n// breakpoint for mobile\nlet breakPoint = 544;\n\n// Toggle buttons\n\n// let btnContainer = document.querySelector('#btnGroup');\n// let btns = btnContainer.getElementsByClassName('button');\n\n// for (var t = 0; t < btns.length; t++) {\n//   btns[t].addEventListener('click', function (event) {\n//     var currentParent = document.querySelector('#btnGroup');\n//     var current = currentParent.getElementsByClassName('active');\n//     current[0].className = current[0].className.replace(' active', '');\n//     this.className += ' active';\n//     defVal = this.value;\n//     let promises = [topology, defVal];\n//     Promise.all(promises).then(ready);\n//   });\n// }\n\n// sets geo stuff for projection\nconst geoPath = d3.geoPath();\n\nconst geoIdentity = d3.geoIdentity().reflectY(true);\n\n// establish color bucket breakdown\nlet color = d3\n  .scaleQuantile()\n  .range([\n    '#ffffe0',\n    '#FFF5B2',\n    '#FDDE85',\n    '#FDBB45',\n    '#FDA23E',\n    '#F2691D',\n    '#DB3F2A',\n    '#A52C20',\n    '#6C1D1C',\n  ]);\n\nconst latest_date = data['latest_date'];\n\nconst cases = data[latest_date]['cases'];\n\nconst casesData = d3.map(),\n  rateData = d3.map(),\n  deathData = d3.map();\n\n// sets the data for cases, rate per 1000 and deaths\ncases.forEach(d =>\n  rateData.set(d.id, rate_perResidents(+d.cases, +d.population, 1000))\n);\ncases.forEach(d => casesData.set(d.id, +d.cases));\ncases.forEach(d => deathData.set(d.id, +d.deaths));\n\n// Make object into array so we can find the domain of data for color scale\nlet dataArray = Object.keys(rateData).map(key => rateData[key]);\n\nexport default function renderRateMap() {\n  clearContainer();\n\n  const frameWidth = getFrameWidth(); // calcuates the width on each render\n\n  // Establishes as isMobile function\n\n  const isMobile = frameWidth < breakPoint;\n\n  // uses `./utils/d3-base` to set up a bunch of conventional d3 stuff\n\n  const map = createBase({\n    container, // the chart container\n    height: isMobile ? frameWidth + (isPartners ? 120 : 70) : 600, // mobile height\n  });\n\n  // Creates the svg for the map\n\n  const svg = map.g.append('g').attr('class', 'g_rate_map');\n\n  let promises = [topology];\n\n  Promise.all(promises).then(ready);\n\n  function ready([shapefiles]) {\n    // Creates title and map base for the rate map\n\n    const state = topojson.merge(\n        shapefiles,\n        shapefiles.objects.counties.geometries\n      ),\n      counties = topojson.feature(shapefiles, shapefiles.objects.counties),\n      texas_highways = topojson.feature(shapefiles, shapefiles.objects.roads),\n      major_cities = topojson.feature(shapefiles, shapefiles.objects.places);\n\n    // Finding ckmeans Thresholds for scale, an alternative to the usual scale\n\n    // More info here: https://observablehq.com/@d3/quantile-quantize-and-threshold-scales\n\n    // https://medium.com/@dschnr/using-clustering-to-create-a-new-d3-js-color-scale-dec4ccd639d2\n\n    const numberOfClasses = color.range().length - 1;\n\n    let ckmeansThresholds = ss.ckmeans(dataArray, 3).map(v => v.pop());\n    let ckmeansBreaks = ss\n      .ckmeans(dataArray, numberOfClasses)\n      .map(v => v.pop());\n\n    // get the extent of data to find a range for domain\n    let dataRange = d3.extent(dataArray, d => d);\n\n    let x_legend = d3\n      .scaleLinear()\n      .rangeRound([\n        map.width * (isMobile ? 0.1 : 0.58),\n        map.width * (isMobile ? 0.9 : 0.825),\n      ]);\n\n    // Establish the domain\n    color.domain(ckmeansBreaks);\n    x_legend.domain(ckmeansBreaks);\n\n    const projection = geoIdentity.fitExtent(\n      [\n        [0, isMobile ? 75 : 0],\n        [map.width, map.height],\n      ],\n      state\n    );\n\n    const path = geoPath.projection(projection);\n\n    // Adding Texas county shapefile\n    const counties_shape = svg\n      .selectAll('g')\n      .data(counties.features)\n      .enter()\n      .append('path')\n      .attr('class', 'counties')\n      .attr('fill', d =>\n        (rateData.get(d.id)\n        ? (d.cases = rateData.get(d.id))\n        : (d.cases = 0))\n          ? color(d.cases)\n          : '#e8e8e8'\n      )\n      .attr('stroke', 'rgba(255, 255, 255, .6)')\n      .attr('d', path);\n\n    // Adds highways (the order of this is very important)\n    highways(svg, texas_highways, path);\n\n    // Add cities\n    cities(svg, major_cities, path);\n\n    const tooltip = container\n      .append('div')\n      .attr('class', 'tooltip')\n      .style('opacity', 0);\n\n    counties_shape.on('mouseover', MouseOver).on('mouseout', MouseOut);\n\n    function MouseOver(d, i) {\n      const active_county = svg\n        .append('path')\n        .datum(d)\n        .attr('d', path)\n        .classed('active_county', true);\n\n      const rate = rateData.get(d.id),\n        deaths = deathData.get(d.id),\n        cases = casesData.get(d.id);\n\n      var tooltip_div = `<div class='county-title'>${\n        d.properties.name\n      } County</div><div class='county-data'>Cases per 1,000: ${\n        rate ? rate.toFixed(2) : 0\n      }</div><table class=\"dv-table\"><tbody><tr><td class='tooltip_header'>\n      Cases\n     </td><td class=\"number text-right\">\n     ${cases ? intcomma(cases) : 0}\n    </td>\n           </tr><tr><td class='tooltip_header'>\n           Deaths\n          </td><td class=\"number text-right\">\n          ${cases ? intcomma(deaths) : 0}\n         </td></tr><tbody></table>`;\n\n      tooltip.style('opacity', 0.9).html(tooltip_div);\n\n      relocateTooltip(\n        tooltip,\n        d3.event.pageX,\n        d3.event.pageY,\n        d3.event.screenY\n      );\n    }\n\n    function MouseOut(d) {\n      // Add interactivity\n      tooltip.style('opacity', 0);\n      d3.selectAll('.active_county').remove();\n    }\n\n    const legend = svg\n      .append('g')\n      .attr('class', 'legend')\n      .attr('transform', `translate(${isMobile ? 0 : map.width / -50},${0})`);\n\n    const rate_legend = legend\n      .append('g')\n      .attr('class', 'rate_legend')\n      .attr('transform', `translate(${isMobile ? 0 : 0},${0})`);\n\n    // Creates legend based on rate data\n\n    const legend_rect_width =\n      (x_legend.range()[1] - x_legend.range()[0]) / numberOfClasses;\n    \n    legend\n      .append('g')\n      .attr('class', 'tick')\n      .append('g')\n      .attr('transform', `translate(${x_legend.range()[0]},-8)`)\n      .append('text')\n      .text('Cases per 1,000 residents')\n\n    rate_legend\n      .selectAll('rect')\n      .data(\n        color.range().map(function(d) {\n          d = color.invertExtent(d);\n          if (d[0] == null) d[0] = 0;\n          return d;\n        })\n      )\n      .enter()\n      .append('rect')\n      .attr('height', 10)\n      .attr('x', (d, i) => x_legend.range()[0] + i * legend_rect_width)\n      .attr('width', (d, i) => legend_rect_width + 2)\n      .attr('fill', d => color(d[0]));\n\n    rate_legend\n      .call(\n        d3\n          .axisBottom(x_legend)\n          .tickSize(15)\n          .tickFormat((d, i) =>\n            i\n              ? ckmeansBreaks[numberOfClasses - 1].toFixed(2) + '+'\n              : dataRange[0].toFixed(2)\n          )\n          .tickValues(color.domain())\n      )\n      .select('.domain')\n      .remove();\n\n    // This adds the \"No reported cases\" gray box below the legend\n    add_legend_for_gray(legend, 'rate', x_legend, isMobile);\n  }\n\n  const partners_img_width = map.width * (isMobile ? 1 : 0.5);\n  const partners_img_height = partners_img_width / 13.3;\n\n  if (isPartners) {\n    const partner_link = svg\n      .append('a')\n      .attr('xlink:href', 'https://www.texastribune.org/')\n      .attr('target', '_parent')\n      .attr('rel', 'noopener noreferrer');\n\n    partner_link\n      .append('svg:image')\n      .attr('alt', 'Coronavirus tracker presented by The Texas Tribune')\n      .attr('x', -20)\n      .attr('y', map.height - partners_img_height / 2)\n      .attr(\n        'width',\n        frameWidth > 800 ? partners_img_width * 0.7 : partners_img_width\n      )\n      .attr('height', partners_img_height)\n      .attr('xlink:href', TT_logo_present);\n  }\n}\n\n// function resize() {\n//   // code executed on window resize\n//   let frameWidth = getFrameWidth(),\n//     frameHeight;\n\n//   if (frameWidth < breakPoint) {\n//     frameHeight = 475;\n//   } else {\n//     frameHeight = 600;\n//   }\n\n//   let chartWidth = frameWidth,\n//     chartHeight = frameHeight;\n//   let promises = [topology];\n\n// }\n\n// // call resize on load\n// resize();\n// window.addEventListener('resize', _.debounce(resize, 200));\n","'use strict';\n\n// We depend on intersection-observer enough that it should just be assumed as necessary\nrequire('intersection-observer');\n","/**\n * Grabs the contents of a `jsonScript` created JSON inline string and returns\n * it as a JSON object. If the element does not exist, or if the script\n * element does not have the JSON MIME type, null is returned instead.\n *\n * @param  {String} elementId the ID of the JSON script element\n * @return {Object|null}\n */\nexport default function loadAssetURL(elementId) {\n  const element = document.getElementById(elementId);\n\n  if (element && element.getAttribute('type') === 'application/json') {\n    return JSON.parse(element.textContent).asset_url;\n  } else {\n    return null;\n  }\n}\n","import * as moment from 'moment';\nimport * as d3 from 'd3';\n\n// Finds the moving average\nexport function movingAvg(array, count, qualifier, propertyName) {\n  // calculate average for subarray\n  let avg = function(array, qualifier) {\n    var sum = 0,\n      count = 0,\n      val;\n    for (var i in array) {\n      val = array[i];\n      if (!qualifier || qualifier(val)) {\n        sum += val;\n        count++;\n      }\n    }\n    return sum / count;\n  };\n\n  let result = [],\n    val;\n\n  // pad beginning of result with null values\n  for (var i = 0; i < count - 1; i++) {\n    let resultObject = {};\n    resultObject[propertyName] = NaN;\n    resultObject['id'] = i;\n    result.push(resultObject);\n  }\n\n  // calculate average for each subarray and add to result\n  for (var i = 0, len = array.length - count; i <= len; i++) {\n    val = avg(array.slice(i, i + count), qualifier);\n    let resultObject = {};\n    if (isNaN(val)) {\n      resultObject[propertyName] = NaN;\n    } else {\n      resultObject[propertyName] = val;\n    }\n    resultObject['id'] = i + (count - 1);\n    result.push(resultObject);\n  }\n\n  return result;\n}\n\n// finds the moving average by subtracting today's total\n// by the total from 7 days ago, and dividing it by 7\n// does not work for days before 5/20\nexport function movingAvgSubtractMethod(array, count, propertyName) {\n  let result = [],\n    val;\n\n  // pad beginning of result with null values\n  // The reason why it's not starting on the 7th day was because it was skipping the 6th iteration so I made it so it gave the 7th day a zero, it's a very hacky day to do this\n  for (var i = 0; i < count; i++) {\n    let resultObject = {};\n    resultObject['id'] = i;\n    if (i == 6) {\n      resultObject[propertyName] = 0;\n      result.push(resultObject);\n    } else {\n      let resultObject = {};\n      resultObject[propertyName] = NaN;\n      result.push(resultObject);\n    }\n  }\n\n  // calculate average for each subarray and add to result\n  for (var i = 0, len = array.length - count; i <= len; i++) {\n    val = (array[i + count] - array[i]) / 7;\n    let resultObject = {};\n    resultObject['id'] = i + count;\n    if (isNaN(val)) {\n      resultObject[propertyName] = NaN;\n      result.push(resultObject);\n    } else {\n      resultObject[propertyName] = val;\n      result.push(resultObject);\n    }\n  }\n\n  return result;\n}\n\n// returns slope, intercept and r-square of the line\nexport function leastSquares(xSeries, ySeries) {\n  var reduceSumFunc = function(prev, cur) {\n    return prev + cur;\n  };\n\n  var xBar = (xSeries.reduce(reduceSumFunc) * 1.0) / xSeries.length;\n  var yBar = (ySeries.reduce(reduceSumFunc) * 1.0) / ySeries.length;\n\n  var ssXX = xSeries\n    .map(function(d) {\n      return Math.pow(d - xBar, 2);\n    })\n    .reduce(reduceSumFunc);\n\n  var ssYY = ySeries\n    .map(function(d) {\n      return Math.pow(d - yBar, 2);\n    })\n    .reduce(reduceSumFunc);\n\n  var ssXY = xSeries\n    .map(function(d, i) {\n      return (d - xBar) * (ySeries[i] - yBar);\n    })\n    .reduce(reduceSumFunc);\n\n  var slope = ssXY / ssXX;\n  var intercept = yBar - xBar * slope;\n  var rSquare = Math.pow(ssXY, 2) / (ssXX * ssYY);\n\n  return [slope, intercept, rSquare];\n}\n\nexport function customDateFormat(d, i, interval) {\n  let month = moment(d).format('MMM'),\n    short_month = moment(d).format('MMMM'),\n    day = moment(d).format('D');\n\n  if (i % interval == 0 && short_month.length > 4) return `${month}. ${day}`;\n  else if (i % interval == 0 && short_month.length <= 4)\n    return `${short_month} ${day}`;\n  else return '';\n}\n\nexport function customMobileDateFormat(d, i) {\n  let month = moment(d).format('MMM'),\n    short_month = moment(d).format('MMMM'),\n    day = moment(d).format('D');\n\n  if (i % 6 == 0 && short_month.length > 4) return `${month}. ${day}`;\n  else if (i % 6 == 0 && short_month.length <= 4)\n    return `${short_month} ${day}`;\n  else return '';\n}\n\n/// This function skips every fourth one instead of every sixth number on axis, used in new-tests.js\nexport function customMobileDateFormatFour(d, i) {\n  let month = moment(d).format('MMM'),\n    short_month = moment(d).format('MMMM'),\n    day = moment(d).format('D');\n\n  if (i % 4 == 0 && short_month.length > 4) return `${month}. ${day}`;\n  else if (i % 4 == 0 && short_month.length <= 4)\n    return `${short_month} ${day}`;\n  else return '';\n}\n\nexport function customNumFormat(d, i) {\n  if (i != 0) {\n    return d3.format(',')(d);\n  }\n}\n\nexport function customPercFormat(d, i) {\n  if (i != 0) {\n    return d3.format('.3')(d) + '%';\n  }\n}\n\nexport const mergeArrays = (a1, a2, key) =>\n  a1.map(itm => ({\n    ...a2.find(item => item[key] === itm[key] && item),\n    ...itm,\n  }));\n\n// dates should be listed in this format: April 2017\nexport function getLabeledData(data, dates) {\n  // always annotate the latest datapoint\n  let labeledData = [data[data.length - 1]];\n  dates.forEach(date => {\n    date = moment(date, 'M_D');\n    let foundData = data.find(d => d.date.isSame(date));\n    if (foundData) {\n      labeledData.push(foundData);\n    }\n  });\n  return labeledData;\n}\n","var map = {\n\t\"./af\": \"K/tc\",\n\t\"./af.js\": \"K/tc\",\n\t\"./ar\": \"jnO4\",\n\t\"./ar-dz\": \"o1bE\",\n\t\"./ar-dz.js\": \"o1bE\",\n\t\"./ar-kw\": \"Qj4J\",\n\t\"./ar-kw.js\": \"Qj4J\",\n\t\"./ar-ly\": \"HP3h\",\n\t\"./ar-ly.js\": \"HP3h\",\n\t\"./ar-ma\": \"CoRJ\",\n\t\"./ar-ma.js\": \"CoRJ\",\n\t\"./ar-sa\": \"gjCT\",\n\t\"./ar-sa.js\": \"gjCT\",\n\t\"./ar-tn\": \"bYM6\",\n\t\"./ar-tn.js\": \"bYM6\",\n\t\"./ar.js\": \"jnO4\",\n\t\"./az\": \"SFxW\",\n\t\"./az.js\": \"SFxW\",\n\t\"./be\": \"H8ED\",\n\t\"./be.js\": \"H8ED\",\n\t\"./bg\": \"hKrs\",\n\t\"./bg.js\": \"hKrs\",\n\t\"./bm\": \"p/rL\",\n\t\"./bm.js\": \"p/rL\",\n\t\"./bn\": \"kEOa\",\n\t\"./bn.js\": \"kEOa\",\n\t\"./bo\": \"0mo+\",\n\t\"./bo.js\": \"0mo+\",\n\t\"./br\": \"aIdf\",\n\t\"./br.js\": \"aIdf\",\n\t\"./bs\": \"JVSJ\",\n\t\"./bs.js\": \"JVSJ\",\n\t\"./ca\": \"1xZ4\",\n\t\"./ca.js\": \"1xZ4\",\n\t\"./cs\": \"PA2r\",\n\t\"./cs.js\": \"PA2r\",\n\t\"./cv\": \"A+xa\",\n\t\"./cv.js\": \"A+xa\",\n\t\"./cy\": \"l5ep\",\n\t\"./cy.js\": \"l5ep\",\n\t\"./da\": \"DxQv\",\n\t\"./da.js\": \"DxQv\",\n\t\"./de\": \"tGlX\",\n\t\"./de-at\": \"s+uk\",\n\t\"./de-at.js\": \"s+uk\",\n\t\"./de-ch\": \"u3GI\",\n\t\"./de-ch.js\": \"u3GI\",\n\t\"./de.js\": \"tGlX\",\n\t\"./dv\": \"WYrj\",\n\t\"./dv.js\": \"WYrj\",\n\t\"./el\": \"jUeY\",\n\t\"./el.js\": \"jUeY\",\n\t\"./en-SG\": \"zavE\",\n\t\"./en-SG.js\": \"zavE\",\n\t\"./en-au\": \"Dmvi\",\n\t\"./en-au.js\": \"Dmvi\",\n\t\"./en-ca\": \"OIYi\",\n\t\"./en-ca.js\": \"OIYi\",\n\t\"./en-gb\": \"Oaa7\",\n\t\"./en-gb.js\": \"Oaa7\",\n\t\"./en-ie\": \"4dOw\",\n\t\"./en-ie.js\": \"4dOw\",\n\t\"./en-il\": \"czMo\",\n\t\"./en-il.js\": \"czMo\",\n\t\"./en-nz\": \"b1Dy\",\n\t\"./en-nz.js\": \"b1Dy\",\n\t\"./eo\": \"Zduo\",\n\t\"./eo.js\": \"Zduo\",\n\t\"./es\": \"iYuL\",\n\t\"./es-do\": \"CjzT\",\n\t\"./es-do.js\": \"CjzT\",\n\t\"./es-us\": \"Vclq\",\n\t\"./es-us.js\": \"Vclq\",\n\t\"./es.js\": \"iYuL\",\n\t\"./et\": \"7BjC\",\n\t\"./et.js\": \"7BjC\",\n\t\"./eu\": \"D/JM\",\n\t\"./eu.js\": \"D/JM\",\n\t\"./fa\": \"jfSC\",\n\t\"./fa.js\": \"jfSC\",\n\t\"./fi\": \"gekB\",\n\t\"./fi.js\": \"gekB\",\n\t\"./fo\": \"ByF4\",\n\t\"./fo.js\": \"ByF4\",\n\t\"./fr\": \"nyYc\",\n\t\"./fr-ca\": \"2fjn\",\n\t\"./fr-ca.js\": \"2fjn\",\n\t\"./fr-ch\": \"Dkky\",\n\t\"./fr-ch.js\": \"Dkky\",\n\t\"./fr.js\": \"nyYc\",\n\t\"./fy\": \"cRix\",\n\t\"./fy.js\": \"cRix\",\n\t\"./ga\": \"USCx\",\n\t\"./ga.js\": \"USCx\",\n\t\"./gd\": \"9rRi\",\n\t\"./gd.js\": \"9rRi\",\n\t\"./gl\": \"iEDd\",\n\t\"./gl.js\": \"iEDd\",\n\t\"./gom-latn\": \"DKr+\",\n\t\"./gom-latn.js\": \"DKr+\",\n\t\"./gu\": \"4MV3\",\n\t\"./gu.js\": \"4MV3\",\n\t\"./he\": \"x6pH\",\n\t\"./he.js\": \"x6pH\",\n\t\"./hi\": \"3E1r\",\n\t\"./hi.js\": \"3E1r\",\n\t\"./hr\": \"S6ln\",\n\t\"./hr.js\": \"S6ln\",\n\t\"./hu\": \"WxRl\",\n\t\"./hu.js\": \"WxRl\",\n\t\"./hy-am\": \"1rYy\",\n\t\"./hy-am.js\": \"1rYy\",\n\t\"./id\": \"UDhR\",\n\t\"./id.js\": \"UDhR\",\n\t\"./is\": \"BVg3\",\n\t\"./is.js\": \"BVg3\",\n\t\"./it\": \"bpih\",\n\t\"./it-ch\": \"bxKX\",\n\t\"./it-ch.js\": \"bxKX\",\n\t\"./it.js\": \"bpih\",\n\t\"./ja\": \"B55N\",\n\t\"./ja.js\": \"B55N\",\n\t\"./jv\": \"tUCv\",\n\t\"./jv.js\": \"tUCv\",\n\t\"./ka\": \"IBtZ\",\n\t\"./ka.js\": \"IBtZ\",\n\t\"./kk\": \"bXm7\",\n\t\"./kk.js\": \"bXm7\",\n\t\"./km\": \"6B0Y\",\n\t\"./km.js\": \"6B0Y\",\n\t\"./kn\": \"PpIw\",\n\t\"./kn.js\": \"PpIw\",\n\t\"./ko\": \"Ivi+\",\n\t\"./ko.js\": \"Ivi+\",\n\t\"./ku\": \"JCF/\",\n\t\"./ku.js\": \"JCF/\",\n\t\"./ky\": \"lgnt\",\n\t\"./ky.js\": \"lgnt\",\n\t\"./lb\": \"RAwQ\",\n\t\"./lb.js\": \"RAwQ\",\n\t\"./lo\": \"sp3z\",\n\t\"./lo.js\": \"sp3z\",\n\t\"./lt\": \"JvlW\",\n\t\"./lt.js\": \"JvlW\",\n\t\"./lv\": \"uXwI\",\n\t\"./lv.js\": \"uXwI\",\n\t\"./me\": \"KTz0\",\n\t\"./me.js\": \"KTz0\",\n\t\"./mi\": \"aIsn\",\n\t\"./mi.js\": \"aIsn\",\n\t\"./mk\": \"aQkU\",\n\t\"./mk.js\": \"aQkU\",\n\t\"./ml\": \"AvvY\",\n\t\"./ml.js\": \"AvvY\",\n\t\"./mn\": \"lYtQ\",\n\t\"./mn.js\": \"lYtQ\",\n\t\"./mr\": \"Ob0Z\",\n\t\"./mr.js\": \"Ob0Z\",\n\t\"./ms\": \"6+QB\",\n\t\"./ms-my\": \"ZAMP\",\n\t\"./ms-my.js\": \"ZAMP\",\n\t\"./ms.js\": \"6+QB\",\n\t\"./mt\": \"G0Uy\",\n\t\"./mt.js\": \"G0Uy\",\n\t\"./my\": \"honF\",\n\t\"./my.js\": \"honF\",\n\t\"./nb\": \"bOMt\",\n\t\"./nb.js\": \"bOMt\",\n\t\"./ne\": \"OjkT\",\n\t\"./ne.js\": \"OjkT\",\n\t\"./nl\": \"+s0g\",\n\t\"./nl-be\": \"2ykv\",\n\t\"./nl-be.js\": \"2ykv\",\n\t\"./nl.js\": \"+s0g\",\n\t\"./nn\": \"uEye\",\n\t\"./nn.js\": \"uEye\",\n\t\"./pa-in\": \"8/+R\",\n\t\"./pa-in.js\": \"8/+R\",\n\t\"./pl\": \"jVdC\",\n\t\"./pl.js\": \"jVdC\",\n\t\"./pt\": \"8mBD\",\n\t\"./pt-br\": \"0tRk\",\n\t\"./pt-br.js\": \"0tRk\",\n\t\"./pt.js\": \"8mBD\",\n\t\"./ro\": \"lyxo\",\n\t\"./ro.js\": \"lyxo\",\n\t\"./ru\": \"lXzo\",\n\t\"./ru.js\": \"lXzo\",\n\t\"./sd\": \"Z4QM\",\n\t\"./sd.js\": \"Z4QM\",\n\t\"./se\": \"//9w\",\n\t\"./se.js\": \"//9w\",\n\t\"./si\": \"7aV9\",\n\t\"./si.js\": \"7aV9\",\n\t\"./sk\": \"e+ae\",\n\t\"./sk.js\": \"e+ae\",\n\t\"./sl\": \"gVVK\",\n\t\"./sl.js\": \"gVVK\",\n\t\"./sq\": \"yPMs\",\n\t\"./sq.js\": \"yPMs\",\n\t\"./sr\": \"zx6S\",\n\t\"./sr-cyrl\": \"E+lV\",\n\t\"./sr-cyrl.js\": \"E+lV\",\n\t\"./sr.js\": \"zx6S\",\n\t\"./ss\": \"Ur1D\",\n\t\"./ss.js\": \"Ur1D\",\n\t\"./sv\": \"X709\",\n\t\"./sv.js\": \"X709\",\n\t\"./sw\": \"dNwA\",\n\t\"./sw.js\": \"dNwA\",\n\t\"./ta\": \"PeUW\",\n\t\"./ta.js\": \"PeUW\",\n\t\"./te\": \"XLvN\",\n\t\"./te.js\": \"XLvN\",\n\t\"./tet\": \"V2x9\",\n\t\"./tet.js\": \"V2x9\",\n\t\"./tg\": \"Oxv6\",\n\t\"./tg.js\": \"Oxv6\",\n\t\"./th\": \"EOgW\",\n\t\"./th.js\": \"EOgW\",\n\t\"./tl-ph\": \"Dzi0\",\n\t\"./tl-ph.js\": \"Dzi0\",\n\t\"./tlh\": \"z3Vd\",\n\t\"./tlh.js\": \"z3Vd\",\n\t\"./tr\": \"DoHr\",\n\t\"./tr.js\": \"DoHr\",\n\t\"./tzl\": \"z1FC\",\n\t\"./tzl.js\": \"z1FC\",\n\t\"./tzm\": \"wQk9\",\n\t\"./tzm-latn\": \"tT3J\",\n\t\"./tzm-latn.js\": \"tT3J\",\n\t\"./tzm.js\": \"wQk9\",\n\t\"./ug-cn\": \"YRex\",\n\t\"./ug-cn.js\": \"YRex\",\n\t\"./uk\": \"raLr\",\n\t\"./uk.js\": \"raLr\",\n\t\"./ur\": \"UpQW\",\n\t\"./ur.js\": \"UpQW\",\n\t\"./uz\": \"Loxo\",\n\t\"./uz-latn\": \"AQ68\",\n\t\"./uz-latn.js\": \"AQ68\",\n\t\"./uz.js\": \"Loxo\",\n\t\"./vi\": \"KSF8\",\n\t\"./vi.js\": \"KSF8\",\n\t\"./x-pseudo\": \"/X5v\",\n\t\"./x-pseudo.js\": \"/X5v\",\n\t\"./yo\": \"fzPg\",\n\t\"./yo.js\": \"fzPg\",\n\t\"./zh-cn\": \"XDpg\",\n\t\"./zh-cn.js\": \"XDpg\",\n\t\"./zh-hk\": \"SatO\",\n\t\"./zh-hk.js\": \"SatO\",\n\t\"./zh-tw\": \"kOpN\",\n\t\"./zh-tw.js\": \"kOpN\"\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = \"RnhZ\";","import { h, render } from 'preact';\n\n// just in case this gets removed\nwindow.ttData = window.ttData || {};\n\n// related content\nconst relatedContentContainer = document.getElementById(\n  'related-content-container'\n);\n\nif (relatedContentContainer && window.ttData.gutenTag) {\n  import(\n    /* webpackChunkName: \"RelatedContent\" */ './components/RelatedContent'\n  ).then(({ default: RelatedContent }) =>\n    render(\n      <RelatedContent title={'Read more'} gutenTag={window.ttData.gutenTag} />,\n      relatedContentContainer\n    )\n  );\n}\n\n// trending ribbon\nconst ribbonContainer = document.getElementById('ribbon-container');\n\nif (ribbonContainer) {\n  import(\n    /* webpackChunkName: \"Ribbon\" */ './components/Ribbon'\n  ).then(({ default: Ribbon }) => render(<Ribbon />, ribbonContainer));\n}\n\n// ads\nimport(/* webpackChunkName: \"ads\" */ './utils/ad-loader').then(\n  ({ default: AdLoader }) => {\n    const ads = new AdLoader();\n    ads.init();\n  }\n);\n","// import JS files\nimport '../kickstart';\nimport _ from 'lodash';\n// import renderCasesMap from './case-map';\nimport renderRateMap from './rate-map';\nimport renderHospitalMap from './hospitals-map';\nimport './collapsible-table-rows';\nimport './new-deaths';\nimport './new-cases';\nimport './positive-rate';\nimport './new-tests';\nimport './daily-hospitalization';\n// import './hospital-bed-usage';\n// import './icu-beds';\n\nfunction resize() {\n  // code executed on window resize\n  // renderCasesMap();\n  renderRateMap();\n  renderHospitalMap();\n}\n\n// call resize on load\nresize();\nwindow.addEventListener('resize', _.debounce(resize, 200));\n","export default function(xy, dim) {\n  var node = this.node()\n  return !node ? this : node.getBBox ?\n    this.attr('transform', function(d,i) {\n      var p = typeof xy == 'function' ? xy.call(this, d,i) : xy;\n      if (dim === 0) p = [p, 0]; else if (dim === 1) p = [0, p];\n      return 'translate(' + p[0] +','+ p[1]+')';\n    }) :\n    this.style('transform', function(d,i) {\n      var p = typeof xy == 'function' ? xy.call(this, d,i) : xy;\n      if (dim === 0) p = [p, 0]; else if (dim === 1) p = [0, p];\n      return 'translate(' + p[0] +'px,'+ p[1]+'px)';\n    });\n}\n","export default function(name) {\n  if (typeof name === \"string\") {\n    var attr = {},\n      parts = name.split(/([\\.#])/g), p;\n      name = parts.shift();\n    while ((p = parts.shift())) {\n      if (p == '.') attr['class'] = attr['class'] ? attr['class'] + ' ' + parts.shift() : parts.shift();\n      else if (p == '#') attr.id = parts.shift();\n    }\n    return {tag: name, attr: attr};\n  }\n  return name;\n}\n","import {creator, selector} from \"d3-selection\";\nimport parseAttributes from \"./parseAttributes\";\n\nfunction constantNull() {\n  return null;\n}\n\nexport default function(name, before) {\n  var n = parseAttributes(name),\n      create = creator(n.tag),\n      select = before == null ? constantNull : typeof before === \"function\" ? before : selector(before);\n\n  var s = this.select(function() {\n    return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);\n  });\n\n\n  //attrs not provided by default in v4\n  for (var key in n.attr) { s.attr(key, n.attr[key]); }\n  return s;\n}","const camelCaseAttrs = /^(allowReorder|attributeName|attributeType|autoReverse|baseFrequency|baseProfile|calcMode|clipPathUnits|contentScriptType|contentStyleType|diffuseConstant|edgeMode|externalResourcesRequired|filterRes|filterUnits|glyphRef|gradientTransform|gradientUnits|kernelMatrix|kernelUnitLength|keyPoints|keySplines|keyTimes|lengthAdjust|limitingConeAngle|markerHeight|markerUnits|markerWidth|maskContentUnits|maskUnits|numOctaves|pathLength|patternContentUnits|patternTransform|patternUnits|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|referrerPolicy|refX|refY|repeatCount|repeatDur|requiredExtensions|requiredFeatures|specularConstant|specularExponent|spreadMethod|startOffset|stdDeviation|stitchTiles|surfaceScale|systemLanguage|tableValues|targetX|targetY|textLength|viewBox|viewTarget|xChannelSelector|yChannelSelector|zoomAndPan)$/;\n\nexport default function(name, value) {\n  if (typeof(name) == 'object'){\n    for (var key in name){\n      this.attr(camelCaseAttrs.test(key) ? key : key.replace(/([a-z\\d])([A-Z])/g, '$1-$2').toLowerCase(), name[key]);\n    }\n    return this;\n  } else{\n    return arguments.length == 1 ? this.attr(name) : this.attr(name, value);\n  }\n}\n","function f(){\n  var functions = arguments;\n\n  //convert all string arguments into field accessors\n  var i = 0, l = functions.length;\n  while (i < l) {\n    if (typeof(functions[i]) === 'string' || typeof(functions[i]) === 'number'){\n      functions[i] = (function(str){ return function(d){ return d[str]; }; })(functions[i]);\n    }\n    i++;\n  }\n\n   //return composition of functions\n  return function(d) {\n    var i=0, l = functions.length;\n    while (i++ < l) d = functions[i-1].call(this, d);\n    return d;\n  };\n}\n\nf.not = function(d){ return !d; };\nf.run = function(d){ return d(); };\nf.objToFn = function(obj, defaultVal){\n  if (arguments.length == 1) defaultVal = undefined;\n\n  return function(str){\n    return typeof(obj[str]) !== 'undefined' ? obj[str] : defaultVal;\n  };\n};\n\nexport default f;\n","import ƒ from \"./f\";\n\nexport default function(name, value) {\n  if (typeof(name) == 'object'){\n    for (var key in name){\n      addStyle(this, key, name[key]);\n    }\n    return this;\n  } else {\n    return arguments.length == 1 ? this.style(name) : addStyle(this, name, value);\n  }\n\n\n  function addStyle(sel, style, value){\n    style = style.replace(/([a-z\\d])([A-Z])/g, '$1-$2').toLowerCase();\n\n    var pxStyles = 'top left bottom right padding-top padding-left padding-bottom padding-right border-top b-width border-left-width border-botto-width m border-right-width  margin-top margin-left margin-bottom margin-right font-size width height stroke-width line-height margin padding border border-radius max-width min-width';\n\n    if (~pxStyles.indexOf(style) ){\n      sel.style(style, typeof value == 'function' ? wrapPx(value) : addPx(value));\n    } else{\n      sel.style(style, value);\n    }\n\n    return sel;\n  }\n\n  function addPx(d){ return d.match ? d : d + 'px'; }\n  function wrapPx(fn){\n    return function(){\n      var val = fn.apply(this, arguments)\n      return addPx(val)\n    }\n\n  }\n}\n","import {sum} from 'd3-array';\n\n// while this might not be reprentative for all fonts, it is\n// still better than assuming every character has the same width\n// (set monospace=true if you want to bypass this)\nvar CHAR_W = {\n    A:7,a:7,B:8,b:7,C:8,c:6,D:9,d:7,E:7,e:7,F:7,f:4,G:9,g:7,H:9,h:7,I:3,i:3,J:5,j:3,K:8,k:6,L:7,l:3,M:11,\n    m:11,N:9,n:7,O:9,o:7,P:8,p:7,Q:9,q:7,R:8,r:4,S:8,s:6,T:7,t:4,U:9,u:7,V:7,v:6,W:11,w:9,X:7,x:6,Y:7,y:6,Z:7,z:5,\n    '.':2,',':2,':':2,';':2\n};\n\nexport default function(line, maxCharactersPerLine, minCharactersPerLine, monospace) {\n    var l, lines = [], w = [], words = [], w1, maxChars, minChars, maxLineW, minLineW;\n    w1 = line.split(' ');\n    w1.forEach(function(s, i) {\n        var w2 = s.split('-');\n        var lw = (i < w1.length - 1 ? ' ' : '');\n        if (w2.length > 1) {\n            w2.forEach(function(t, j) {\n                w.push(t + (j < w2.length - 1 ? '-' : lw));\n            });\n        } else {\n            w.push(s + lw);\n        }\n    });\n    maxChars = maxCharactersPerLine || 40;\n    minChars = minCharactersPerLine || Math.max(3, Math.min(maxChars * 0.5, 0.75 * w.map(word_len).sort(num_asc)[Math.round(w.length / 2)]));\n    maxLineW = maxChars * CHAR_W.a;\n    minLineW = minChars * CHAR_W.a;\n    l = 0;\n    w.forEach(function(d) {\n        var ww = sum(d.split('').map(char_w));\n        if (l + ww > maxLineW && l > minLineW) {\n            lines.push(words.join(''));\n            words.length = 0;\n            l = 0;\n        }\n        l += ww;\n        return words.push(d);\n    });\n    if (words.length) {\n        lines.push(words.join(''));\n    }\n    return lines.filter(function(d) {\n        return d !== '';\n    });\n    function char_w(c) { return !monospace && CHAR_W[c] || CHAR_W.a; }\n    function word_len(d) { return d.length; }\n    function num_asc(a, b) { return a - b; }\n}\n\n","var array = Array.prototype;\n\nexport var map = array.map;\nexport var slice = array.slice;\n","import {bisector, tickStep} from \"d3-array\";\nimport {interpolateNumber as reinterpolate} from \"d3-interpolate\";\nimport {timeYear, timeMonth, timeWeek, timeDay, timeHour, timeMinute, timeSecond, timeMillisecond} from \"d3-time\";\nimport {timeFormat} from \"d3-time-format\";\nimport {map} from \"./array\";\nimport {default as continuous, copy, deinterpolateLinear as deinterpolate} from \"./continuous\";\nimport nice from \"./nice\";\n\nvar durationSecond = 1000,\n    durationMinute = durationSecond * 60,\n    durationHour = durationMinute * 60,\n    durationDay = durationHour * 24,\n    durationWeek = durationDay * 7,\n    durationMonth = durationDay * 30,\n    durationYear = durationDay * 365;\n\nfunction date(t) {\n  return new Date(t);\n}\n\nfunction number(t) {\n  return t instanceof Date ? +t : +new Date(+t);\n}\n\nexport function calendar(year, month, week, day, hour, minute, second, millisecond, format) {\n  var scale = continuous(deinterpolate, reinterpolate),\n      invert = scale.invert,\n      domain = scale.domain;\n\n  var formatMillisecond = format(\".%L\"),\n      formatSecond = format(\":%S\"),\n      formatMinute = format(\"%I:%M\"),\n      formatHour = format(\"%I %p\"),\n      formatDay = format(\"%a %d\"),\n      formatWeek = format(\"%b %d\"),\n      formatMonth = format(\"%B\"),\n      formatYear = format(\"%Y\");\n\n  var tickIntervals = [\n    [second,  1,      durationSecond],\n    [second,  5,  5 * durationSecond],\n    [second, 15, 15 * durationSecond],\n    [second, 30, 30 * durationSecond],\n    [minute,  1,      durationMinute],\n    [minute,  5,  5 * durationMinute],\n    [minute, 15, 15 * durationMinute],\n    [minute, 30, 30 * durationMinute],\n    [  hour,  1,      durationHour  ],\n    [  hour,  3,  3 * durationHour  ],\n    [  hour,  6,  6 * durationHour  ],\n    [  hour, 12, 12 * durationHour  ],\n    [   day,  1,      durationDay   ],\n    [   day,  2,  2 * durationDay   ],\n    [  week,  1,      durationWeek  ],\n    [ month,  1,      durationMonth ],\n    [ month,  3,  3 * durationMonth ],\n    [  year,  1,      durationYear  ]\n  ];\n\n  function tickFormat(date) {\n    return (second(date) < date ? formatMillisecond\n        : minute(date) < date ? formatSecond\n        : hour(date) < date ? formatMinute\n        : day(date) < date ? formatHour\n        : month(date) < date ? (week(date) < date ? formatDay : formatWeek)\n        : year(date) < date ? formatMonth\n        : formatYear)(date);\n  }\n\n  function tickInterval(interval, start, stop, step) {\n    if (interval == null) interval = 10;\n\n    // If a desired tick count is specified, pick a reasonable tick interval\n    // based on the extent of the domain and a rough estimate of tick size.\n    // Otherwise, assume interval is already a time interval and use it.\n    if (typeof interval === \"number\") {\n      var target = Math.abs(stop - start) / interval,\n          i = bisector(function(i) { return i[2]; }).right(tickIntervals, target);\n      if (i === tickIntervals.length) {\n        step = tickStep(start / durationYear, stop / durationYear, interval);\n        interval = year;\n      } else if (i) {\n        i = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i];\n        step = i[1];\n        interval = i[0];\n      } else {\n        step = Math.max(tickStep(start, stop, interval), 1);\n        interval = millisecond;\n      }\n    }\n\n    return step == null ? interval : interval.every(step);\n  }\n\n  scale.invert = function(y) {\n    return new Date(invert(y));\n  };\n\n  scale.domain = function(_) {\n    return arguments.length ? domain(map.call(_, number)) : domain().map(date);\n  };\n\n  scale.ticks = function(interval, step) {\n    var d = domain(),\n        t0 = d[0],\n        t1 = d[d.length - 1],\n        r = t1 < t0,\n        t;\n    if (r) t = t0, t0 = t1, t1 = t;\n    t = tickInterval(interval, t0, t1, step);\n    t = t ? t.range(t0, t1 + 1) : []; // inclusive stop\n    return r ? t.reverse() : t;\n  };\n\n  scale.tickFormat = function(count, specifier) {\n    return specifier == null ? tickFormat : format(specifier);\n  };\n\n  scale.nice = function(interval, step) {\n    var d = domain();\n    return (interval = tickInterval(interval, d[0], d[d.length - 1], step))\n        ? domain(nice(d, interval))\n        : scale;\n  };\n\n  scale.copy = function() {\n    return copy(scale, calendar(year, month, week, day, hour, minute, second, millisecond, format));\n  };\n\n  return scale;\n}\n\nexport default function() {\n  return calendar(timeYear, timeMonth, timeWeek, timeDay, timeHour, timeMinute, timeSecond, timeMillisecond, timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]);\n}\n","export default function(s) {\n  return s.match(/.{6}/g).map(function(x) {\n    return \"#\" + x;\n  });\n}\n","import colors from \"./colors\";\n\nexport default colors(\"1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf\");\n","import colors from \"./colors\";\n\nexport default colors(\"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6\");\n","import colors from \"./colors\";\n\nexport default colors(\"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9\");\n","import colors from \"./colors\";\n\nexport default colors(\"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5\");\n","export var deg2rad = Math.PI / 180;\nexport var rad2deg = 180 / Math.PI;\n","import define, {extend} from \"./define.js\";\nimport {Color, rgbConvert, Rgb, darker, brighter} from \"./color.js\";\nimport {deg2rad, rad2deg} from \"./math.js\";\n\nvar A = -0.14861,\n    B = +1.78277,\n    C = -0.29227,\n    D = -0.90649,\n    E = +1.97294,\n    ED = E * D,\n    EB = E * B,\n    BC_DA = B * C - D * A;\n\nfunction cubehelixConvert(o) {\n  if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);\n  if (!(o instanceof Rgb)) o = rgbConvert(o);\n  var r = o.r / 255,\n      g = o.g / 255,\n      b = o.b / 255,\n      l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),\n      bl = b - l,\n      k = (E * (g - l) - C * bl) / D,\n      s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1\n      h = s ? Math.atan2(k, bl) * rad2deg - 120 : NaN;\n  return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);\n}\n\nexport default function cubehelix(h, s, l, opacity) {\n  return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);\n}\n\nexport function Cubehelix(h, s, l, opacity) {\n  this.h = +h;\n  this.s = +s;\n  this.l = +l;\n  this.opacity = +opacity;\n}\n\ndefine(Cubehelix, cubehelix, extend(Color, {\n  brighter: function(k) {\n    k = k == null ? brighter : Math.pow(brighter, k);\n    return new Cubehelix(this.h, this.s, this.l * k, this.opacity);\n  },\n  darker: function(k) {\n    k = k == null ? darker : Math.pow(darker, k);\n    return new Cubehelix(this.h, this.s, this.l * k, this.opacity);\n  },\n  rgb: function() {\n    var h = isNaN(this.h) ? 0 : (this.h + 120) * deg2rad,\n        l = +this.l,\n        a = isNaN(this.s) ? 0 : this.s * l * (1 - l),\n        cosh = Math.cos(h),\n        sinh = Math.sin(h);\n    return new Rgb(\n      255 * (l + a * (A * cosh + B * sinh)),\n      255 * (l + a * (C * cosh + D * sinh)),\n      255 * (l + a * (E * cosh)),\n      this.opacity\n    );\n  }\n}));\n","import {cubehelix as colorCubehelix} from \"d3-color\";\nimport color, {hue} from \"./color.js\";\n\nfunction cubehelix(hue) {\n  return (function cubehelixGamma(y) {\n    y = +y;\n\n    function cubehelix(start, end) {\n      var h = hue((start = colorCubehelix(start)).h, (end = colorCubehelix(end)).h),\n          s = color(start.s, end.s),\n          l = color(start.l, end.l),\n          opacity = color(start.opacity, end.opacity);\n      return function(t) {\n        start.h = h(t);\n        start.s = s(t);\n        start.l = l(Math.pow(t, y));\n        start.opacity = opacity(t);\n        return start + \"\";\n      };\n    }\n\n    cubehelix.gamma = cubehelixGamma;\n\n    return cubehelix;\n  })(1);\n}\n\nexport default cubehelix(hue);\nexport var cubehelixLong = cubehelix(color);\n","import {cubehelix} from \"d3-color\";\nimport {interpolateCubehelixLong} from \"d3-interpolate\";\n\nexport default interpolateCubehelixLong(cubehelix(300, 0.5, 0.0), cubehelix(-240, 0.5, 1.0));\n","import {cubehelix} from \"d3-color\";\nimport {interpolateCubehelixLong} from \"d3-interpolate\";\n\nexport var warm = interpolateCubehelixLong(cubehelix(-100, 0.75, 0.35), cubehelix(80, 1.50, 0.8));\n\nexport var cool = interpolateCubehelixLong(cubehelix(260, 0.75, 0.35), cubehelix(80, 1.50, 0.8));\n\nvar rainbow = cubehelix();\n\nexport default function(t) {\n  if (t < 0 || t > 1) t -= Math.floor(t);\n  var ts = Math.abs(t - 0.5);\n  rainbow.h = 360 * t - 100;\n  rainbow.s = 1.5 - 1.5 * ts;\n  rainbow.l = 0.8 - 0.9 * ts;\n  return rainbow + \"\";\n}\n","import colors from \"./colors\";\n\nfunction ramp(range) {\n  var n = range.length;\n  return function(t) {\n    return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];\n  };\n}\n\nexport default ramp(colors(\"44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725\"));\n\nexport var magma = ramp(colors(\"00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf\"));\n\nexport var inferno = ramp(colors(\"00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4\"));\n\nexport var plasma = ramp(colors(\"0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921\"));\n","import {axisLeft} from 'd3-axis';\nimport {axisBottom} from 'd3-axis';\nimport {select} from \"d3-selection\";\nimport {scaleLinear} from \"d3-scale\";\n\nexport default function(c){\n  c = c || {};\n\n  c.margin = c.margin || {}\n  ;['top', 'right', 'bottom', 'left'].forEach(function(d){\n    if (!c.margin[d] && c.margin[d] !== 0) c.margin[d] = 20 ;\n  });\n\n  if (c.parentSel) c.sel = c.parentSel // backwords comp\n  var node = c.sel && c.sel.node()\n\n  c.totalWidth  = c.totalWidth  || node && node.offsetWidth  || 960;\n  c.totalHeight = c.totalHeight || node && node.offsetHeight || 500;\n\n  c.width  = c.width  || c.totalWidth  - c.margin.left - c.margin.right;\n  c.height = c.height || c.totalHeight - c.margin.top - c.margin.bottom;\n\n  c.totalWidth = c.width + c.margin.left + c.margin.right;\n  c.totalHeight = c.height + c.margin.top + c.margin.bottom;\n\n  c.sel = c.sel || select('body');\n  c.sel.st({position: 'relative', height: c.totalHeight, width: c.totalWidth})\n\n  c.x = c.x || scaleLinear().range([0, c.width]);\n  c.y = c.y || scaleLinear().range([c.height, 0]);\n\n  c.xAxis = c.xAxis || axisBottom().scale(c.x);\n  c.yAxis = c.yAxis || axisLeft().scale(c.y);\n\n  c.layers = (c.layers || 's').split('').map(function(type){\n    var layer\n    if (type == 's'){\n      layer = c.sel.append('svg')\n          .st({position: c.layers ? 'absolute' : ''})\n          .attr('width', c.totalWidth)\n          .attr('height', c.totalHeight)\n        .append('g')\n          .attr('transform', 'translate(' + c.margin.left + ',' + c.margin.top + ')');\n\n      if (!c.svg) c.svg = layer // defaults to lowest svg layer \n    } else if (type == 'c'){\n      var s = window.devicePixelRatio || 1\n\n      layer = c.sel.append('canvas')\n        .at({width: c.totalWidth*s, height: c.totalHeight*s})\n        .st({width: c.totalWidth, height: c.totalHeight})\n        .st({position: 'absolute'})\n        .node().getContext('2d')\n      layer.scale(s, s)\n      layer.translate(c.margin.left, c.margin.top)\n    } else if (type == 'd'){\n      layer = c.sel.append('div')\n        .st({\n          position: 'absolute', \n          left: c.margin.left,\n          top: c.margin.top,\n          width: c.width,\n          height: c.height\n        });\n    }\n\n    return layer\n  })\n\n  return c;\n}\n","export var slice = [].slice;\n","import {slice} from \"./array\";\n\nvar noabort = {};\n\nfunction Queue(size) {\n  this._size = size;\n  this._call =\n  this._error = null;\n  this._tasks = [];\n  this._data = [];\n  this._waiting =\n  this._active =\n  this._ended =\n  this._start = 0; // inside a synchronous task callback?\n}\n\nQueue.prototype = queue.prototype = {\n  constructor: Queue,\n  defer: function(callback) {\n    if (typeof callback !== \"function\") throw new Error(\"invalid callback\");\n    if (this._call) throw new Error(\"defer after await\");\n    if (this._error != null) return this;\n    var t = slice.call(arguments, 1);\n    t.push(callback);\n    ++this._waiting, this._tasks.push(t);\n    poke(this);\n    return this;\n  },\n  abort: function() {\n    if (this._error == null) abort(this, new Error(\"abort\"));\n    return this;\n  },\n  await: function(callback) {\n    if (typeof callback !== \"function\") throw new Error(\"invalid callback\");\n    if (this._call) throw new Error(\"multiple await\");\n    this._call = function(error, results) { callback.apply(null, [error].concat(results)); };\n    maybeNotify(this);\n    return this;\n  },\n  awaitAll: function(callback) {\n    if (typeof callback !== \"function\") throw new Error(\"invalid callback\");\n    if (this._call) throw new Error(\"multiple await\");\n    this._call = callback;\n    maybeNotify(this);\n    return this;\n  }\n};\n\nfunction poke(q) {\n  if (!q._start) {\n    try { start(q); } // let the current task complete\n    catch (e) {\n      if (q._tasks[q._ended + q._active - 1]) abort(q, e); // task errored synchronously\n      else if (!q._data) throw e; // await callback errored synchronously\n    }\n  }\n}\n\nfunction start(q) {\n  while (q._start = q._waiting && q._active < q._size) {\n    var i = q._ended + q._active,\n        t = q._tasks[i],\n        j = t.length - 1,\n        c = t[j];\n    t[j] = end(q, i);\n    --q._waiting, ++q._active;\n    t = c.apply(null, t);\n    if (!q._tasks[i]) continue; // task finished synchronously\n    q._tasks[i] = t || noabort;\n  }\n}\n\nfunction end(q, i) {\n  return function(e, r) {\n    if (!q._tasks[i]) return; // ignore multiple callbacks\n    --q._active, ++q._ended;\n    q._tasks[i] = null;\n    if (q._error != null) return; // ignore secondary errors\n    if (e != null) {\n      abort(q, e);\n    } else {\n      q._data[i] = r;\n      if (q._waiting) poke(q);\n      else maybeNotify(q);\n    }\n  };\n}\n\nfunction abort(q, e) {\n  var i = q._tasks.length, t;\n  q._error = e; // ignore active callbacks\n  q._data = undefined; // allow gc\n  q._waiting = NaN; // prevent starting\n\n  while (--i >= 0) {\n    if (t = q._tasks[i]) {\n      q._tasks[i] = null;\n      if (t.abort) {\n        try { t.abort(); }\n        catch (e) { /* ignore */ }\n      }\n    }\n  }\n\n  q._active = NaN; // allow notification\n  maybeNotify(q);\n}\n\nfunction maybeNotify(q) {\n  if (!q._active && q._call) {\n    var d = q._data;\n    q._data = undefined; // allow gc\n    q._call(q._error, d);\n  }\n}\n\nexport default function queue(concurrency) {\n  if (concurrency == null) concurrency = Infinity;\n  else if (!((concurrency = +concurrency) >= 1)) throw new Error(\"invalid concurrency\");\n  return new Queue(concurrency);\n}\n","import {map} from \"d3-collection\";\nimport {dispatch} from \"d3-dispatch\";\n\nexport default function(url, callback) {\n  var request,\n      event = dispatch(\"beforesend\", \"progress\", \"load\", \"error\"),\n      mimeType,\n      headers = map(),\n      xhr = new XMLHttpRequest,\n      user = null,\n      password = null,\n      response,\n      responseType,\n      timeout = 0;\n\n  // If IE does not support CORS, use XDomainRequest.\n  if (typeof XDomainRequest !== \"undefined\"\n      && !(\"withCredentials\" in xhr)\n      && /^(http(s)?:)?\\/\\//.test(url)) xhr = new XDomainRequest;\n\n  \"onload\" in xhr\n      ? xhr.onload = xhr.onerror = xhr.ontimeout = respond\n      : xhr.onreadystatechange = function(o) { xhr.readyState > 3 && respond(o); };\n\n  function respond(o) {\n    var status = xhr.status, result;\n    if (!status && hasResponse(xhr)\n        || status >= 200 && status < 300\n        || status === 304) {\n      if (response) {\n        try {\n          result = response.call(request, xhr);\n        } catch (e) {\n          event.call(\"error\", request, e);\n          return;\n        }\n      } else {\n        result = xhr;\n      }\n      event.call(\"load\", request, result);\n    } else {\n      event.call(\"error\", request, o);\n    }\n  }\n\n  xhr.onprogress = function(e) {\n    event.call(\"progress\", request, e);\n  };\n\n  request = {\n    header: function(name, value) {\n      name = (name + \"\").toLowerCase();\n      if (arguments.length < 2) return headers.get(name);\n      if (value == null) headers.remove(name);\n      else headers.set(name, value + \"\");\n      return request;\n    },\n\n    // If mimeType is non-null and no Accept header is set, a default is used.\n    mimeType: function(value) {\n      if (!arguments.length) return mimeType;\n      mimeType = value == null ? null : value + \"\";\n      return request;\n    },\n\n    // Specifies what type the response value should take;\n    // for instance, arraybuffer, blob, document, or text.\n    responseType: function(value) {\n      if (!arguments.length) return responseType;\n      responseType = value;\n      return request;\n    },\n\n    timeout: function(value) {\n      if (!arguments.length) return timeout;\n      timeout = +value;\n      return request;\n    },\n\n    user: function(value) {\n      return arguments.length < 1 ? user : (user = value == null ? null : value + \"\", request);\n    },\n\n    password: function(value) {\n      return arguments.length < 1 ? password : (password = value == null ? null : value + \"\", request);\n    },\n\n    // Specify how to convert the response content to a specific type;\n    // changes the callback value on \"load\" events.\n    response: function(value) {\n      response = value;\n      return request;\n    },\n\n    // Alias for send(\"GET\", …).\n    get: function(data, callback) {\n      return request.send(\"GET\", data, callback);\n    },\n\n    // Alias for send(\"POST\", …).\n    post: function(data, callback) {\n      return request.send(\"POST\", data, callback);\n    },\n\n    // If callback is non-null, it will be used for error and load events.\n    send: function(method, data, callback) {\n      xhr.open(method, url, true, user, password);\n      if (mimeType != null && !headers.has(\"accept\")) headers.set(\"accept\", mimeType + \",*/*\");\n      if (xhr.setRequestHeader) headers.each(function(value, name) { xhr.setRequestHeader(name, value); });\n      if (mimeType != null && xhr.overrideMimeType) xhr.overrideMimeType(mimeType);\n      if (responseType != null) xhr.responseType = responseType;\n      if (timeout > 0) xhr.timeout = timeout;\n      if (callback == null && typeof data === \"function\") callback = data, data = null;\n      if (callback != null && callback.length === 1) callback = fixCallback(callback);\n      if (callback != null) request.on(\"error\", callback).on(\"load\", function(xhr) { callback(null, xhr); });\n      event.call(\"beforesend\", request, xhr);\n      xhr.send(data == null ? null : data);\n      return request;\n    },\n\n    abort: function() {\n      xhr.abort();\n      return request;\n    },\n\n    on: function() {\n      var value = event.on.apply(event, arguments);\n      return value === event ? request : value;\n    }\n  };\n\n  if (callback != null) {\n    if (typeof callback !== \"function\") throw new Error(\"invalid callback: \" + callback);\n    return request.get(callback);\n  }\n\n  return request;\n}\n\nfunction fixCallback(callback) {\n  return function(error, xhr) {\n    callback(error == null ? xhr : null);\n  };\n}\n\nfunction hasResponse(xhr) {\n  var type = xhr.responseType;\n  return type && type !== \"text\"\n      ? xhr.response // null on error\n      : xhr.responseText; // \"\" on error\n}\n","import request from \"./request\";\n\nexport default function(defaultMimeType, response) {\n  return function(url, callback) {\n    var r = request(url).mimeType(defaultMimeType).response(response);\n    if (callback != null) {\n      if (typeof callback !== \"function\") throw new Error(\"invalid callback: \" + callback);\n      return r.get(callback);\n    }\n    return r;\n  };\n}\n","import request from \"./request\";\n\nexport default function(defaultMimeType, parse) {\n  return function(url, row, callback) {\n    if (arguments.length < 3) callback = row, row = null;\n    var r = request(url).mimeType(defaultMimeType);\n    r.row = function(_) { return arguments.length ? r.response(responseOf(parse, row = _)) : row; };\n    r.row(row);\n    return callback ? r.get(callback) : r;\n  };\n}\n\nfunction responseOf(parse, row) {\n  return function(request) {\n    return parse(request.responseText, row);\n  };\n}\n","import type from \"./type\";\n\nexport default type(\"text/html\", function(xhr) {\n  return document.createRange().createContextualFragment(xhr.responseText);\n});\n","import type from \"./type\";\n\nexport default type(\"application/json\", function(xhr) {\n  return JSON.parse(xhr.responseText);\n});\n","import type from \"./type\";\n\nexport default type(\"text/plain\", function(xhr) {\n  return xhr.responseText;\n});\n","import type from \"./type\";\n\nexport default type(\"application/xml\", function(xhr) {\n  var xml = xhr.responseXML;\n  if (!xml) throw new Error(\"parse error\");\n  return xml;\n});\n","import {csvParse} from \"d3-dsv\";\nimport dsv from \"./dsv\";\n\nexport default dsv(\"text/csv\", csvParse);\n","import {tsvParse} from \"d3-dsv\";\nimport dsv from \"./dsv\";\n\nexport default dsv(\"text/tab-separated-values\", tsvParse);\n","import {selection} from \"d3-selection\";\nimport {transition} from \"d3-transition\";\n\nimport translateSelection from \"./src/translate-selection\";\nimport append from \"./src/append\";\nimport insert from \"./src/insert\";\nimport parent from \"./src/parent\";\nimport selectAppend from \"./src/selectAppend\";\nimport tspans from \"./src/tspans\";\nimport appendMany from \"./src/appendMany\";\nimport at from \"./src/at\";\nimport st from \"./src/st\";\n\nselection.prototype.translate = translateSelection;\ntransition.prototype.translate = translateSelection;\nselection.prototype.append = append;\nselection.prototype.insert = insert;\nselection.prototype.parent = parent;\nselection.prototype.selectAppend = selectAppend;\nselection.prototype.tspans = tspans;\nselection.prototype.appendMany = appendMany;\nselection.prototype.at = at;\nselection.prototype.st = st;\ntransition.prototype.at = at;\ntransition.prototype.st = st;\nselection.prototype.prop = selection.prototype.property;\n\nexport {default as wordwrap} from \"./src/wordwrap\";\nexport {default as parseAttributes} from \"./src/parseAttributes\";\nexport {default as f} from \"./src/f\";\nexport {default as ascendingKey} from \"./src/ascendingKey\";\nexport {default as descendingKey} from \"./src/descendingKey\";\nexport {default as conventions} from \"./src/conventions\";\nexport {default as drawAxis} from \"./src/drawAxis\";\nexport {default as attachTooltip} from \"./src/attachTooltip\";\nexport {default as loadData} from \"./src/loadData\";\nexport {default as nestBy} from \"./src/nestBy\";\nexport {default as round} from \"./src/round\";\nexport {default as clamp} from \"./src/clamp\";\nexport {default as polygonClip} from \"./src/polygonClip\";\nexport {default as timer} from \"./src/timer\";\nexport {default as interval} from \"./src/interval\";\nexport {default as timeout} from \"./src/timeout\";\n","import {creator} from \"d3-selection\";\nimport parseAttributes from \"./parseAttributes\";\n\nexport default function(name) {\n  var create, n;\n\n  if (typeof name === \"function\"){\n    create = name;\n  } else {\n    n = parseAttributes(name)\n    create = creator(n.tag);\n  }\n  var sel = this.select(function(){\n    return this.appendChild(create.apply(this, arguments));\n  });\n\n  if (n) for (var key in n.attr) { sel.attr(key, n.attr[key]); }\n  return sel;\n}\n\n","import {creator} from \"d3-selection\";\n\nexport default function() {\n  var parents = [];\n  return this.filter(function() {\n    if (parents.indexOf(this.parentNode) > -1) return false;\n    parents.push(this.parentNode);\n    return true;\n  }).select(function() {\n    return this.parentNode;\n  });\n}\n","import {selector} from \"d3-selection\";\nimport {creator} from \"d3-selection\";\nimport parseAttributes from \"./parseAttributes\";\n\nexport default function(name) {\n  var select = selector(name),\n     n = parseAttributes(name), s;\n\n  name = creator(n.tag);\n\n  s = this.select(function() {\n    return select.apply(this, arguments) ||\n        this.appendChild(name.apply(this, arguments));\n  });\n\n  //attrs not provided by default in v4\n  for (var key in n.attr) { s.attr(key, n.attr[key]); }\n  return s;\n}\n","export default function(lines, lh) {\n  return this.selectAll('tspan')\n      .data(function(d) {\n        return (typeof(lines) == 'function' ? lines(d) : lines)\n          .map(function(l) {\n            return { line: l, parent: d };\n          });\n      })\n      .enter()\n    .append('tspan')\n      .text(function(d) { return d.line; })\n      .attr('x', 0)\n      .attr('dy', function(d, i) { return i ? (typeof(lh) == 'function' ? lh(d.parent, d.line, i) : lh) || 15 : 0; });\n}\n","export default function(name, data){\n  if (typeof(data) == 'string'){\n    console.warn(\"DEPRECATED: jetpack's appendMany order of arguments has changed. It's appendMany('div', data) from now on\")\n    var temp = data\n    data = name\n    name = temp\n  }\n\n  return this.selectAll(null).data(data).enter().append(name);\n}\n","/* eslint-disable no-unused-vars */\nimport * as d3 from 'd3';\nimport _ from 'lodash';\nimport { intcomma, apmonth, apdate, pluralize } from 'journalize';\nimport {\n  movingAvg,\n  customDateFormat,\n  customMobileDateFormatFour,\n  customNumFormat,\n  getLabeledData,\n  mergeArrays,\n} from '../utils/charts-utils';\nimport * as moment from 'moment';\nimport { wordwrap } from 'd3-jetpack';\n// import { swoopyDrag } from '../swoopy-drag';\n// import { wordwrap } from 'd3-jetpack';\n\nimport data from '../../../data/daily_tables/all_tables.json';\nimport colors from '../../../data/chart-colors.json';\n\n// a reference to the default graphic container, change if needed\nconst container = d3.select('#daily-hospitalizations');\n\n// a helper function to grab the container's width\nconst getFrameWidth = () => container.node().offsetWidth;\n\n//set margins\nlet margin = {\n  top: 15,\n  left: 45,\n  bottom: 40,\n};\n\nlet breakPoint = 500;\n\n// grabbing totals\nlet dataTotals = [];\n\n// there are six properties prior that we want to exclude: 'latest_date', 'yesterday_date', 'week_ago', 'cases_latest_date', 'cases_yesterday_date', 'cases_week_ago', 'cases_yesterday_date'\nfor (let i = Object.keys(data).length - 1; i > 6; i--) {\n  dataTotals.push({\n    unformatted_date: Object.keys(data)[i - 1],\n    new_hospitalizations:\n      data[Object.keys(data)[i - 1]].statewide_data.hospitalizations,\n    incomplete: data[Object.keys(data)[i - 1]].statewide_data.incomplete,\n  });\n}\n\n// changing to moment date+time objects\ndataTotals.forEach(d => (d.date = moment(d.unformatted_date, 'M_D_YYYY')));\n\n// Get the new starting date because the state did not provide comprehensive deaths data before then\nconst start_date = dataTotals.filter(d => d.unformatted_date == '04_06_2020');\n\n// Filter out everything before the new starting date\ndataTotals = dataTotals.filter(d => d.date > start_date[0].date);\n\n// Add an id based on index to use for joining\ndataTotals.forEach((d, i) => (d.id = i));\n\n// Make object into array\nlet dataArray = dataTotals.map(d => d['new_hospitalizations']);\n\nlet dataMovingAvg = movingAvg(dataArray, 7, val => val != '', 'moving_avg');\n\ndataTotals = mergeArrays(dataTotals, dataMovingAvg, 'id');\n\n// grabbing totals and ranges\nlet dateRange = d3.extent(dataTotals, d => d.date),\n  totalsMax = d3.max(dataTotals, d => d.new_hospitalizations);\n\n// set ranges\nlet x = d3.scaleTime().domain(dateRange);\nlet y = d3\n  .scaleLinear()\n  .domain([0, totalsMax])\n  .nice();\n\n// append svg\nlet svg = container.append('svg'),\n  g = svg.append('g').attr('class', 'line-chart'),\n  labels_g = svg.append('g').attr('class', 'labels-container');\n\nlet xAxis = g.append('g').attr('class', 'axis axis--x'),\n  yAxis = g.append('g').attr('class', 'axis axis--y');\n\nlet line = d3\n  .line()\n  .defined(d => !isNaN(d.moving_avg))\n  .x(d => x(d.date))\n  .y(d => y(d.moving_avg));\n\nlet bars = g\n  .selectAll('.bar')\n  .data(dataTotals)\n  .enter()\n  .append('rect')\n  .attr('class', 'bar')\n  .attr('fill', d => {\n    if (d.incomplete && d.incomplete.includes('hospitalizations'))\n      // color incomplete bars gray\n      return colors.bar_neutral;\n    else\n      return d.id == dataTotals.length - 1\n        ? colors.bar_highlight\n        : colors.bar_default;\n  })\n  .attr('opacity', 1);\n\nlet dateReopening = moment('5_01_2020', 'M_D_YYYY');\nlet dateMaskOrder = moment('7_02_2020', 'M_D_YYYY');\n\nlet reopeningGroup = g.append('g').attr('class', 'reopening-line');\nlet reopeningLine = reopeningGroup\n  .append('line')\n  .attr('x1', 0)\n  .attr('x2', 0)\n  .attr('y1', 0)\n  .attr('stroke', '#797979')\n  .attr('stroke-width', '1px')\n  .attr('stroke-dasharray', '3px');\nlet reopeningText = reopeningGroup.append('text');\n\nlet maskorderGroup = g.append('g').attr('class', 'reopening-line');\nlet maskorderLine = maskorderGroup\n  .append('line')\n  .attr('x1', 0)\n  .attr('x2', 0)\n  .attr('y1', 0)\n  .attr('stroke', '#797979')\n  .attr('stroke-width', '1px')\n  .attr('stroke-dasharray', '3px');\nlet maskorderText = maskorderGroup.append('text');\n\nlet pathOutline = g\n  .append('path')\n  .data([dataTotals])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', '#fff')\n  .attr('stroke-width', 4);\n\nlet path = g\n  .append('path')\n  .data([dataTotals])\n  .attr('class', 'line')\n  .attr('fill', 'none')\n  .attr('stroke', colors.line_moving_avg)\n  .attr('stroke-width', 2);\n\nconst day_for_label = [[dataTotals][0][6]]; // Gets the day that where the 7-day average label will be next to\n\nlet moving_avg_label = g.append('g').attr('class', 'moving-avg-label');\n\nlet moving_avg_g = moving_avg_label\n  .selectAll('g')\n  .data(day_for_label)\n  .enter()\n  .append('g');\n\nlet moving_avgText = moving_avg_g.append('g').attr('class', 'label-text');\n\nmoving_avgText\n  .append('text')\n  .text('7-day average')\n  .attr('fill', colors.line_moving_avg)\n  .attr('font-weight', 700);\n\nlet labels = labels_g.append('g').attr('class', 'labeled-elements');\n\nlet labelElements = labels\n  .selectAll('g')\n  .data(getLabeledData(dataTotals, ['']))\n  .enter()\n  .append('g')\n  .attr('class', 'label-element');\n\nlet labelText = labelElements.append('g').attr('class', 'label-text');\n\nlabelText\n  .append('text')\n  .text((d, i) => {\n    if (i === 0) {\n      let month = apmonth(new Date(d.date)),\n        day = d.date.format('D');\n\n      return `${month} ${day}`;\n    } else return '';\n  })\n  .attr('font-weight', 700);\n\nlet casesLabel = labelText.append('text');\n\nfunction resize() {\n  let frameWidth = getFrameWidth(),\n    frameHeight;\n\n  if (frameWidth < breakPoint) {\n    frameHeight = 275;\n    margin.right = 60;\n  } else {\n    frameHeight = 325;\n    margin.right = 120;\n  }\n\n  let chartWidth = frameWidth - margin.left - margin.right,\n    chartHeight = frameHeight - margin.bottom;\n\n  svg.attr('width', frameWidth).attr('height', frameHeight);\n  g.attr('width', chartWidth).attr(\n    'transform',\n    `translate(${margin.left},${margin.top})`\n  );\n  labels_g.attr('transform', `translate(${margin.left},${margin.top})`);\n\n  let barWidth = chartWidth / dataTotals.length;\n\n  x.range([barWidth / 1.5, chartWidth - barWidth / 1.5]);\n  y.range([chartHeight, 0]);\n\n  bars\n    .attr('width', barWidth - barWidth / 5)\n    .attr('x', d => x(d.date) - barWidth / 2)\n    .attr('y', d => y(d.new_hospitalizations))\n    .attr('height', d => chartHeight - y(d.new_hospitalizations));\n\n  xAxis\n    .call(\n      d3\n        .axisBottom(x)\n        .ticks(12)\n        .tickFormat((d, i) => {\n          return frameWidth < breakPoint\n            ? customMobileDateFormatFour(d, i)\n            : customDateFormat(d, i, 1);\n        })\n    )\n    .attr('transform', `translate(0,${frameHeight - margin.bottom})`);\n\n  yAxis.call(\n    d3\n      .axisLeft(y)\n      .ticks(5)\n      .tickSize(-chartWidth)\n      .tickFormat(customNumFormat)\n  );\n\n  pathOutline.attr('d', line);\n  path.attr('d', line);\n\n  moving_avg_g\n    .attr('transform', d => `translate(${x(d.date)},${y(d.moving_avg)})`)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  moving_avgText\n    .attr('transform', (d, i) => {\n      if (i === 0 && frameWidth < breakPoint) {\n        return 'translate(0, -14)';\n      } else return 'translate(0, -14)';\n    })\n    .attr('text-anchor', 'start');\n\n  labelElements\n    .attr(\n      'transform',\n      d => `translate(${x(d.date)},${y(d.new_hospitalizations)})`\n    )\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  labelText\n    .attr('transform', (d, i) => {\n      if (i === 0 && frameWidth < breakPoint) {\n        return 'translate(9, 0)';\n      } else return 'translate(13, 0)';\n    })\n    .attr('text-anchor', 'start');\n\n  casesLabel\n    .attr('dy', frameWidth < breakPoint ? 16 : 17)\n    .text('')\n    .tspans(d => {\n      return wordwrap(\n        `${intcomma(d.new_hospitalizations)} in ${pluralize(\n          d.new_hospitalizations,\n          '',\n          'a'\n        )} hospital${pluralize(d.new_hospitalizations)}`,\n        frameWidth > breakPoint ? 100 : 10\n      );\n    })\n    .attr('dy', frameWidth < breakPoint ? 16 : 17);\n\n  reopeningGroup.attr('transform', `translate(${x(dateReopening)}, 0)`);\n  reopeningLine.attr('y2', chartHeight);\n  reopeningText\n    .attr('y', 13)\n    .text('')\n    .tspans(wordwrap('Reopening began May 1', 15))\n    .attr('dx', 5)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n  maskorderGroup.attr('transform', `translate(${x(dateMaskOrder)}, 0)`);\n  maskorderLine.attr('y2', chartHeight);\n  maskorderText\n    .attr('y', 80)\n    .attr('text-anchor', 'end')\n    .text('')\n    .tspans(wordwrap('Mask order issued July 2', 15))\n    .attr('dx', -5)\n    .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n}\n\n// call resize on load\nresize();\nwindow.addEventListener('resize', _.debounce(resize, 200));\n\n// OUTSIDE OF RESIZE()\n\n// let events = g.append('g').attr('class', 'events');\n\n// let eventGroups = events\n//   .selectAll('g')\n//   .data([\n//     {\n//       event_desktop: 'San Antonio opens its first drive-thru testing site',\n//       event_mobile: 'Bush',\n//       date: '3_13',\n//     },\n//   ])\n//   .enter()\n//   .append('g');\n\n// let eventText = eventGroups.append('text');\n\n// let eventLines = eventGroups\n//   .append('line')\n//   .attr('stroke', '#d1d1d1')\n//   .attr('stroke-width', '1px')\n//   .attr('stroke-dasharray', 5);\n\n// let metaInfo = g\n//   .append('g')\n//   .attr('class', 'meta')\n//   .attr('font-size', '12px')\n//   .attr('fill', 'hsl(0, 0%, 47%)');\n\n// this is the same function findChartMeta() in nunjucks.js\n// find a way to import that function here\n// metaInfo\n//   .append('text')\n//   .text(`Note: ${data.Meta.find(d => d.Chart === 'Line').Note}`)\n//   .attr('y', 45);\n\n// metaInfo\n//   .append('text')\n//   .html(\n//     `Source: <a style=\"fill: hsl(0, 0%, 47%); text-decoration: underline;\"href=\"https://www.cbp.gov/sites/default/files/assets/documents/2019-Mar/bp-total-monthly-apps-sector-area-fy2018.pdf\">${\n//       data.Meta.find(d => d.Chart === 'Line').Source\n//     }</a>`\n//   )\n//   .attr('y', 65);\n\n//arrow marker, need to append to the svg first to use\n// svg\n//   .append('marker')\n//   .attr('id', 'arrow')\n//   .attr('viewBox', '-10 -10 20 20')\n//   .attr('markerWidth', 10)\n//   .attr('markerHeight', 10)\n//   .attr('fill', 'hsl(0, 0%, 29%)')\n//   .attr('orient', 'auto-start-reverse')\n//   .append('path')\n//   .attr('d', 'M-6.75,-6.75 L 0,0 L -6.75,6.75');\n\n// let swoopySel = svg.append('g').attr('class', 'swoopy-drag-lines');\n\n// //annotations for swoopyDrag\n// let annotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-25,-19C-32,-38,-47,-49,-63,-50',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-186, -77],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-186, -63],\n//   },\n// ];\n\n// let mobileAnnotations = [\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: 'M-12,-13C-30,-13,-42,-24,-46,-39',\n//     text: 'March 24',\n//     weight: 700,\n//     textOffset: [-105, -75],\n//   },\n//   {\n//     xVal: moment('3_24', 'M_D'),\n//     yVal: 500,\n//     path: '',\n//     text: 'State changed how it reports numbers.',\n//     weight: 400,\n//     textOffset: [-105, -62],\n//   },\n// ];\n\n// INSIDE OF RESIZE()\n\n// eventGroups.attr(\n//   'transform',\n//   d => `translate(${(0, x(moment(d.date, 'M_D')))})`\n// );\n\n// eventLines.attr('y1', 5).attr('y2', chartHeight);\n\n// eventText\n//   .text(d => (frameWidth < breakPoint ? d.event_mobile : d.event_desktop))\n//   .attr('font-size', frameWidth < breakPoint ? '12px' : '14px')\n//   .attr('dx', frameWidth < breakPoint ? 5 : 10)\n//   .attr('dy', frameWidth < breakPoint ? 14 : 20);\n\n// metaInfo.attr('transform', `translate(0, ${chartHeight})`);\n\n// let swoopy = swoopyDrag()\n//   .x(d => x(d.xVal) + (frameWidth < breakPoint ? 5 : 20))\n//   .y(d => y(d.yVal) + 35)\n//   .draggable(false)\n//   .annotations(frameWidth < breakPoint ? mobileAnnotations : annotations);\n\n// swoopySel\n//   .attr('transform', `translate(${margin.left},${margin.top})`)\n//   .call(swoopy)\n//   .attr('font-size', frameWidth < breakPoint ? '12px' : '13px');\n\n// swoopySel.selectAll('text').each(function(d) {\n//   d3.select(this)\n//     .text('')\n//     .attr('font-weight', d.weight)\n//     .tspans(wordwrap(d.text, frameWidth < breakPoint ? 24 : 24));\n// });\n\n// swoopySel.selectAll('path').attr('marker-start', 'url(#arrow)');\n","import { axisBottom, axisLeft } from 'd3-axis';\nimport { scaleLinear } from 'd3-scale';\n\nexport default function createBase({\n  margin,\n  container,\n  width,\n  height,\n  x,\n  y,\n  xAxis = axisBottom(),\n  yAxis = axisLeft(),\n  xAxisGap = 5,\n} = {}) {\n  margin = Object.assign({ top: 20, right: 20, bottom: 20, left: 20 }, margin);\n\n  margin.bottom += xAxisGap;\n\n  const parent = container.node();\n\n  const containerWidth = width || parent.offsetWidth;\n  const containerHeight = height || parent.offsetHeight;\n\n  const innerWidth = containerWidth - margin.left - margin.right;\n  const innerHeight = containerHeight - margin.top - margin.bottom;\n\n  const svg = container\n    .append('svg')\n    .attr('width', containerWidth)\n    .attr('height', containerHeight);\n\n  const g = svg\n    .append('g')\n    .attr('transform', `translate(${margin.left},${margin.top})`);\n\n  const xScale = x || scaleLinear().range([0, innerWidth]);\n  const yScale = y || scaleLinear().range([innerHeight, 0]);\n\n  xAxis.scale(xScale);\n  yAxis.scale(yScale);\n\n  const drawAxis = () => {\n    g.append('g')\n      .attr('class', 'axis axis--x')\n      .attr('transform', `translate(0,${innerHeight + xAxisGap})`)\n      .call(xAxis);\n\n    g.append('g')\n      .attr('class', 'axis axis--y')\n      .call(yAxis);\n  };\n\n  return {\n    margin,\n    container,\n    containerWidth,\n    containerHeight,\n    width: innerWidth,\n    height: innerHeight,\n    svg,\n    g,\n    x: xScale,\n    y: yScale,\n    xAxis,\n    yAxis,\n    drawAxis,\n  };\n}\n","\n// This is for the non-frames embeddable tables in the main apps page.\nfunction collapseElement(c_id) {\n  // on clicking the see more button, unhide counties and the see fewer button\n  document.getElementById(\n    'collapse-see-more-' + c_id\n  ).onclick = function collapse() {\n    let collapsible = document.getElementsByClassName('collapsible-' + c_id);\n\n    for (let i = 0; i < collapsible.length; i++) {\n      collapsible[i].classList.toggle('display-none');\n    }\n\n    document\n      .getElementById('see-more-' + c_id)\n      .classList.toggle('display-none');\n    document\n      .getElementById('see-fewer-' + c_id)\n      .classList.toggle('display-none');\n  };\n\n  // on clicking the see less button, hide counties and the see more button\n  document.getElementById(\n    'collapse-see-fewer-' + c_id\n  ).onclick = function collapse() {\n    let collapsible = document.getElementsByClassName('collapsible-' + c_id);\n\n    for (let i = 0; i < collapsible.length; i++) {\n      collapsible[i].classList.toggle('display-none');\n    }\n\n    document\n      .getElementById('see-more-' + c_id)\n      .classList.toggle('display-none');\n    document\n      .getElementById('see-fewer-' + c_id)\n      .classList.toggle('display-none');\n  };\n  // close collapse element\n}\n\nvar elements = ['counties', 'notes'];\n\nfor (var i = 0; i < elements.length; i++) {\n  collapseElement(elements[i]);\n};\n","/**\n * Virtual DOM Node\n * @typedef VNode\n * @property {string | function} nodeName The string of the DOM node to create or Component constructor to render\n * @property {Array<VNode | string>} children The children of node\n * @property {string | number | undefined} key The key used to identify this VNode in a list\n * @property {object} attributes The properties of this VNode\n */\nexport const VNode = function VNode() {};\n","/**\n * @typedef {import('./component').Component} Component\n * @typedef {import('./vnode').VNode} VNode\n */\n\n/**\n * Global options\n * @public\n * @typedef Options\n * @property {boolean} [syncComponentUpdates] If `true`, `prop` changes trigger synchronous component updates. Defaults to true.\n * @property {(vnode: VNode) => void} [vnode] Processes all created VNodes.\n * @property {(component: Component) => void} [afterMount] Hook invoked after a component is mounted.\n * @property {(component: Component) => void} [afterUpdate] Hook invoked after the DOM is updated with a component's latest render.\n * @property {(component: Component) => void} [beforeUnmount] Hook invoked immediately before a component is unmounted.\n * @property {(rerender: function) => void} [debounceRendering] Hook invoked whenever a rerender is requested. Can be used to debounce rerenders.\n * @property {(event: Event) => Event | void} [event] Hook invoked before any Preact event listeners. The return value (if any) replaces the native browser event given to event listeners\n */\n\n/** @type {Options}  */\nconst options = {};\n\nexport default options;\n","import { VNode } from './vnode';\nimport options from './options';\n\n\nconst stack = [];\n\nconst EMPTY_CHILDREN = [];\n\n/**\n * JSX/hyperscript reviver.\n * @see http://jasonformat.com/wtf-is-jsx\n * Benchmarks: https://esbench.com/bench/57ee8f8e330ab09900a1a1a0\n *\n * Note: this is exported as both `h()` and `createElement()` for compatibility\n * reasons.\n *\n * Creates a VNode (virtual DOM element). A tree of VNodes can be used as a\n * lightweight representation of the structure of a DOM tree. This structure can\n * be realized by recursively comparing it against the current _actual_ DOM\n * structure, and applying only the differences.\n *\n * `h()`/`createElement()` accepts an element name, a list of attributes/props,\n * and optionally children to append to the element.\n *\n * @example The following DOM tree\n *\n * `<div id=\"foo\" name=\"bar\">Hello!</div>`\n *\n * can be constructed using this function as:\n *\n * `h('div', { id: 'foo', name : 'bar' }, 'Hello!');`\n *\n * @param {string | function} nodeName An element name. Ex: `div`, `a`, `span`, etc.\n * @param {object | null} attributes Any attributes/props to set on the created element.\n * @param {VNode[]} [rest] Additional arguments are taken to be children to\n *  append. Can be infinitely nested Arrays.\n *\n * @public\n */\nexport function h(nodeName, attributes) {\n\tlet children=EMPTY_CHILDREN, lastSimple, child, simple, i;\n\tfor (i=arguments.length; i-- > 2; ) {\n\t\tstack.push(arguments[i]);\n\t}\n\tif (attributes && attributes.children!=null) {\n\t\tif (!stack.length) stack.push(attributes.children);\n\t\tdelete attributes.children;\n\t}\n\twhile (stack.length) {\n\t\tif ((child = stack.pop()) && child.pop!==undefined) {\n\t\t\tfor (i=child.length; i--; ) stack.push(child[i]);\n\t\t}\n\t\telse {\n\t\t\tif (typeof child==='boolean') child = null;\n\n\t\t\tif ((simple = typeof nodeName!=='function')) {\n\t\t\t\tif (child==null) child = '';\n\t\t\t\telse if (typeof child==='number') child = String(child);\n\t\t\t\telse if (typeof child!=='string') simple = false;\n\t\t\t}\n\n\t\t\tif (simple && lastSimple) {\n\t\t\t\tchildren[children.length-1] += child;\n\t\t\t}\n\t\t\telse if (children===EMPTY_CHILDREN) {\n\t\t\t\tchildren = [child];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tchildren.push(child);\n\t\t\t}\n\n\t\t\tlastSimple = simple;\n\t\t}\n\t}\n\n\tlet p = new VNode();\n\tp.nodeName = nodeName;\n\tp.children = children;\n\tp.attributes = attributes==null ? undefined : attributes;\n\tp.key = attributes==null ? undefined : attributes.key;\n\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\n\tif (options.vnode!==undefined) options.vnode(p);\n\n\treturn p;\n}\n","/**\n * Copy all properties from `props` onto `obj`.\n * @param {object} obj Object onto which properties should be copied.\n * @param {object} props Object from which to copy properties.\n * @returns {object}\n * @private\n */\nexport function extend(obj, props) {\n\tfor (let i in props) obj[i] = props[i];\n\treturn obj;\n}\n\n/** Invoke or update a ref, depending on whether it is a function or object ref.\n *  @param {object|function} [ref=null]\n *  @param {any} [value]\n */\nexport function applyRef(ref, value) {\n\tif (ref) {\n\t\tif (typeof ref=='function') ref(value);\n\t\telse ref.current = value;\n\t}\n}\n\n/**\n * Call a function asynchronously, as soon as possible. Makes\n * use of HTML Promise to schedule the callback if available,\n * otherwise falling back to `setTimeout` (mainly for IE<11).\n * @type {(callback: function) => void}\n */\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\n","// render modes\n\n/** Do not re-render a component */\nexport const NO_RENDER = 0;\n/** Synchronously re-render a component and its children */\nexport const SYNC_RENDER = 1;\n/** Synchronously re-render a component, even if its lifecycle methods attempt to prevent it. */\nexport const FORCE_RENDER = 2;\n/** Queue asynchronous re-render of a component and it's children */\nexport const ASYNC_RENDER = 3;\n\n\nexport const ATTR_KEY = '__preactattr_';\n\n/** DOM properties that should NOT have \"px\" added when numeric */\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;\n\n","import options from './options';\nimport { defer } from './util';\nimport { renderComponent } from './vdom/component';\n\n/**\n * Managed queue of dirty components to be re-rendered\n * @type {Array<import('./component').Component>}\n */\nlet items = [];\n\n/**\n * Enqueue a rerender of a component\n * @param {import('./component').Component} component The component to rerender\n */\nexport function enqueueRender(component) {\n\tif (!component._dirty && (component._dirty = true) && items.push(component)==1) {\n\t\t(options.debounceRendering || defer)(rerender);\n\t}\n}\n\n/** Rerender all enqueued dirty components */\nexport function rerender() {\n\tlet p;\n\twhile ( (p = items.pop()) ) {\n\t\tif (p._dirty) renderComponent(p);\n\t}\n}\n","import { extend } from '../util';\n\n\n/**\n * Check if two nodes are equivalent.\n * @param {import('../dom').PreactElement} node DOM Node to compare\n * @param {import('../vnode').VNode} vnode Virtual DOM node to compare\n * @param {boolean} [hydrating=false] If true, ignores component constructors\n *  when comparing.\n * @private\n */\nexport function isSameNodeType(node, vnode, hydrating) {\n\tif (typeof vnode==='string' || typeof vnode==='number') {\n\t\treturn node.splitText!==undefined;\n\t}\n\tif (typeof vnode.nodeName==='string') {\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\n\t}\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\n}\n\n\n/**\n * Check if an Element has a given nodeName, case-insensitively.\n * @param {import('../dom').PreactElement} node A DOM Element to inspect the name of.\n * @param {string} nodeName Unnormalized name to compare against.\n */\nexport function isNamedNode(node, nodeName) {\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\n}\n\n\n/**\n * Reconstruct Component-style `props` from a VNode.\n * Ensures default/fallback values from `defaultProps`:\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\n * @param {import('../vnode').VNode} vnode The VNode to get props for\n * @returns {object} The props to use for this VNode\n */\nexport function getNodeProps(vnode) {\n\tlet props = extend({}, vnode.attributes);\n\tprops.children = vnode.children;\n\n\tlet defaultProps = vnode.nodeName.defaultProps;\n\tif (defaultProps!==undefined) {\n\t\tfor (let i in defaultProps) {\n\t\t\tif (props[i]===undefined) {\n\t\t\t\tprops[i] = defaultProps[i];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn props;\n}\n","import { IS_NON_DIMENSIONAL } from '../constants';\nimport { applyRef } from '../util';\nimport options from '../options';\n\n/**\n * A DOM event listener\n * @typedef {(e: Event) => void} EventListner\n */\n\n/**\n * A mapping of event types to event listeners\n * @typedef {Object.<string, EventListener>} EventListenerMap\n */\n\n/**\n * Properties Preact adds to elements it creates\n * @typedef PreactElementExtensions\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\n */\n\n/**\n * A DOM element that has been extended with Preact properties\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\n */\n\n/**\n * Create an element with the given nodeName.\n * @param {string} nodeName The DOM node to create\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\n *  namespace.\n * @returns {PreactElement} The created DOM node\n */\nexport function createNode(nodeName, isSvg) {\n\t/** @type {PreactElement} */\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\n\tnode.normalizedNodeName = nodeName;\n\treturn node;\n}\n\n\n/**\n * Remove a child node from its parent if attached.\n * @param {Node} node The node to remove\n */\nexport function removeNode(node) {\n\tlet parentNode = node.parentNode;\n\tif (parentNode) parentNode.removeChild(node);\n}\n\n\n/**\n * Set a named attribute on the given Node, with special behavior for some names\n * and event handlers. If `value` is `null`, the attribute/handler will be\n * removed.\n * @param {PreactElement} node An element to mutate\n * @param {string} name The name/key to set, such as an event or attribute name\n * @param {*} old The last value that was set for this name/node pair\n * @param {*} value An attribute value, such as a function to be used as an\n *  event handler\n * @param {boolean} isSvg Are we currently diffing inside an svg?\n * @private\n */\nexport function setAccessor(node, name, old, value, isSvg) {\n\tif (name==='className') name = 'class';\n\n\n\tif (name==='key') {\n\t\t// ignore\n\t}\n\telse if (name==='ref') {\n\t\tapplyRef(old, null);\n\t\tapplyRef(value, node);\n\t}\n\telse if (name==='class' && !isSvg) {\n\t\tnode.className = value || '';\n\t}\n\telse if (name==='style') {\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\n\t\t\tnode.style.cssText = value || '';\n\t\t}\n\t\tif (value && typeof value==='object') {\n\t\t\tif (typeof old!=='string') {\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\n\t\t\t}\n\t\t\tfor (let i in value) {\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\n\t\t\t}\n\t\t}\n\t}\n\telse if (name==='dangerouslySetInnerHTML') {\n\t\tif (value) node.innerHTML = value.__html || '';\n\t}\n\telse if (name[0]=='o' && name[1]=='n') {\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\n\t\tname = name.toLowerCase().substring(2);\n\t\tif (value) {\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\n\t\t}\n\t\telse {\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\n\t\t}\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\n\t}\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\n\t\t// Attempt to set a DOM property to the given value.\n\t\t// IE & FF throw for certain property-value combinations.\n\t\ttry {\n\t\t\tnode[name] = value==null ? '' : value;\n\t\t} catch (e) { }\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\n\t}\n\telse {\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\n\t\t// spellcheck is treated differently than all other boolean values and\n\t\t// should not be removed when the value is `false`. See:\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\n\t\tif (value==null || value===false) {\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\n\t\t\telse node.removeAttribute(name);\n\t\t}\n\t\telse if (typeof value!=='function') {\n\t\t\tif (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\n\t\t\telse node.setAttribute(name, value);\n\t\t}\n\t}\n}\n\n\n/**\n * Proxy an event to hooked event handlers\n * @param {Event} e The event object from the browser\n * @private\n */\nfunction eventProxy(e) {\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\n}\n","import { ATTR_KEY } from '../constants';\nimport { isSameNodeType, isNamedNode } from './index';\nimport { buildComponentFromVNode } from './component';\nimport { createNode, setAccessor } from '../dom/index';\nimport { unmountComponent } from './component';\nimport options from '../options';\nimport { applyRef } from '../util';\nimport { removeNode } from '../dom/index';\n\n/**\n * Queue of components that have been mounted and are awaiting componentDidMount\n * @type {Array<import('../component').Component>}\n */\nexport const mounts = [];\n\n/** Diff recursion count, used to track the end of the diff cycle. */\nexport let diffLevel = 0;\n\n/** Global flag indicating if the diff is currently within an SVG */\nlet isSvgMode = false;\n\n/** Global flag indicating if the diff is performing hydration */\nlet hydrating = false;\n\n/** Invoke queued componentDidMount lifecycle methods */\nexport function flushMounts() {\n\tlet c;\n\twhile ((c = mounts.shift())) {\n\t\tif (options.afterMount) options.afterMount(c);\n\t\tif (c.componentDidMount) c.componentDidMount();\n\t}\n}\n\n\n/**\n * Apply differences in a given vnode (and it's deep children) to a real DOM Node.\n * @param {import('../dom').PreactElement} dom A DOM node to mutate into the shape of a `vnode`\n * @param {import('../vnode').VNode} vnode A VNode (with descendants forming a tree) representing\n *  the desired DOM structure\n * @param {object} context The current context\n * @param {boolean} mountAll Whether or not to immediately mount all components\n * @param {Element} parent ?\n * @param {boolean} componentRoot ?\n * @returns {import('../dom').PreactElement} The created/mutated element\n * @private\n */\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\n\tif (!diffLevel++) {\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\n\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\n\t}\n\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\n\n\t// append the element if its a new parent\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\n\n\t// diffLevel being reduced to 0 means we're exiting the diff\n\tif (!--diffLevel) {\n\t\thydrating = false;\n\t\t// invoke queued componentDidMount lifecycle methods\n\t\tif (!componentRoot) flushMounts();\n\t}\n\n\treturn ret;\n}\n\n\n/**\n * Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing.\n * @param {import('../dom').PreactElement} dom A DOM node to mutate into the shape of a `vnode`\n * @param {import('../vnode').VNode} vnode A VNode (with descendants forming a tree) representing the desired DOM structure\n * @param {object} context The current context\n * @param {boolean} mountAll Whether or not to immediately mount all components\n * @param {boolean} [componentRoot] ?\n * @private\n */\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\n\tlet out = dom,\n\t\tprevSvgMode = isSvgMode;\n\n\t// empty values (null, undefined, booleans) render as empty Text nodes\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\n\n\n\t// Fast case: Strings & Numbers create/update Text nodes.\n\tif (typeof vnode==='string' || typeof vnode==='number') {\n\n\t\t// update if it's already a Text node:\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\n\t\t\tif (dom.nodeValue!=vnode) {\n\t\t\t\tdom.nodeValue = vnode;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\n\t\t\tout = document.createTextNode(vnode);\n\t\t\tif (dom) {\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\n\t\t\t\trecollectNodeTree(dom, true);\n\t\t\t}\n\t\t}\n\n\t\tout[ATTR_KEY] = true;\n\n\t\treturn out;\n\t}\n\n\n\t// If the VNode represents a Component, perform a component diff:\n\tlet vnodeName = vnode.nodeName;\n\tif (typeof vnodeName==='function') {\n\t\treturn buildComponentFromVNode(dom, vnode, context, mountAll);\n\t}\n\n\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\n\n\n\t// If there's no existing element or it's the wrong type, create a new one:\n\tvnodeName = String(vnodeName);\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\n\t\tout = createNode(vnodeName, isSvgMode);\n\n\t\tif (dom) {\n\t\t\t// move children into the replacement node\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\n\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\n\n\t\t\t// recycle the old element (skips non-Element node types)\n\t\t\trecollectNodeTree(dom, true);\n\t\t}\n\t}\n\n\n\tlet fc = out.firstChild,\n\t\tprops = out[ATTR_KEY],\n\t\tvchildren = vnode.children;\n\n\tif (props==null) {\n\t\tprops = out[ATTR_KEY] = {};\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\n\t}\n\n\t// Optimization: fast-path for elements containing a single TextNode:\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\n\t\tif (fc.nodeValue!=vchildren[0]) {\n\t\t\tfc.nodeValue = vchildren[0];\n\t\t}\n\t}\n\t// otherwise, if there are existing or new children, diff them:\n\telse if (vchildren && vchildren.length || fc!=null) {\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\n\t}\n\n\n\t// Apply attributes/props from VNode to the DOM Element:\n\tdiffAttributes(out, vnode.attributes, props);\n\n\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\n\tisSvgMode = prevSvgMode;\n\n\treturn out;\n}\n\n\n/**\n * Apply child and attribute changes between a VNode and a DOM Node to the DOM.\n * @param {import('../dom').PreactElement} dom Element whose children should be compared & mutated\n * @param {Array<import('../vnode').VNode>} vchildren Array of VNodes to compare to `dom.childNodes`\n * @param {object} context Implicitly descendant context object (from most\n *  recent `getChildContext()`)\n * @param {boolean} mountAll Whether or not to immediately mount all components\n * @param {boolean} isHydrating if `true`, consumes externally created elements\n *  similar to hydration\n */\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\n\tlet originalChildren = dom.childNodes,\n\t\tchildren = [],\n\t\tkeyed = {},\n\t\tkeyedLen = 0,\n\t\tmin = 0,\n\t\tlen = originalChildren.length,\n\t\tchildrenLen = 0,\n\t\tvlen = vchildren ? vchildren.length : 0,\n\t\tj, c, f, vchild, child;\n\n\t// Build up a map of keyed children and an Array of unkeyed children:\n\tif (len!==0) {\n\t\tfor (let i=0; i<len; i++) {\n\t\t\tlet child = originalChildren[i],\n\t\t\t\tprops = child[ATTR_KEY],\n\t\t\t\tkey = vlen && props ? child._component ? child._component.__key : props.key : null;\n\t\t\tif (key!=null) {\n\t\t\t\tkeyedLen++;\n\t\t\t\tkeyed[key] = child;\n\t\t\t}\n\t\t\telse if (props || (child.splitText!==undefined ? (isHydrating ? child.nodeValue.trim() : true) : isHydrating)) {\n\t\t\t\tchildren[childrenLen++] = child;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (vlen!==0) {\n\t\tfor (let i=0; i<vlen; i++) {\n\t\t\tvchild = vchildren[i];\n\t\t\tchild = null;\n\n\t\t\t// attempt to find a node based on key matching\n\t\t\tlet key = vchild.key;\n\t\t\tif (key!=null) {\n\t\t\t\tif (keyedLen && keyed[key]!==undefined) {\n\t\t\t\t\tchild = keyed[key];\n\t\t\t\t\tkeyed[key] = undefined;\n\t\t\t\t\tkeyedLen--;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// attempt to pluck a node of the same type from the existing children\n\t\t\telse if (min<childrenLen) {\n\t\t\t\tfor (j=min; j<childrenLen; j++) {\n\t\t\t\t\tif (children[j]!==undefined && isSameNodeType(c = children[j], vchild, isHydrating)) {\n\t\t\t\t\t\tchild = c;\n\t\t\t\t\t\tchildren[j] = undefined;\n\t\t\t\t\t\tif (j===childrenLen-1) childrenLen--;\n\t\t\t\t\t\tif (j===min) min++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// morph the matched/found/created DOM child to match vchild (deep)\n\t\t\tchild = idiff(child, vchild, context, mountAll);\n\n\t\t\tf = originalChildren[i];\n\t\t\tif (child && child!==dom && child!==f) {\n\t\t\t\tif (f==null) {\n\t\t\t\t\tdom.appendChild(child);\n\t\t\t\t}\n\t\t\t\telse if (child===f.nextSibling) {\n\t\t\t\t\tremoveNode(f);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdom.insertBefore(child, f);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\t// remove unused keyed children:\n\tif (keyedLen) {\n\t\tfor (let i in keyed) if (keyed[i]!==undefined) recollectNodeTree(keyed[i], false);\n\t}\n\n\t// remove orphaned unkeyed children:\n\twhile (min<=childrenLen) {\n\t\tif ((child = children[childrenLen--])!==undefined) recollectNodeTree(child, false);\n\t}\n}\n\n\n\n/**\n * Recursively recycle (or just unmount) a node and its descendants.\n * @param {import('../dom').PreactElement} node DOM node to start\n *  unmount/removal from\n * @param {boolean} [unmountOnly=false] If `true`, only triggers unmount\n *  lifecycle, skips removal\n */\nexport function recollectNodeTree(node, unmountOnly) {\n\tlet component = node._component;\n\tif (component) {\n\t\t// if node is owned by a Component, unmount that component (ends up recursing back here)\n\t\tunmountComponent(component);\n\t}\n\telse {\n\t\t// If the node's VNode had a ref function, invoke it with null here.\n\t\t// (this is part of the React spec, and smart for unsetting references)\n\t\tif (node[ATTR_KEY]!=null) applyRef(node[ATTR_KEY].ref, null);\n\n\t\tif (unmountOnly===false || node[ATTR_KEY]==null) {\n\t\t\tremoveNode(node);\n\t\t}\n\n\t\tremoveChildren(node);\n\t}\n}\n\n\n/**\n * Recollect/unmount all children.\n *\t- we use .lastChild here because it causes less reflow than .firstChild\n *\t- it's also cheaper than accessing the .childNodes Live NodeList\n */\nexport function removeChildren(node) {\n\tnode = node.lastChild;\n\twhile (node) {\n\t\tlet next = node.previousSibling;\n\t\trecollectNodeTree(node, true);\n\t\tnode = next;\n\t}\n}\n\n\n/**\n * Apply differences in attributes from a VNode to the given DOM Element.\n * @param {import('../dom').PreactElement} dom Element with attributes to diff `attrs` against\n * @param {object} attrs The desired end-state key-value attribute pairs\n * @param {object} old Current/previous attributes (from previous VNode or\n *  element's prop cache)\n */\nfunction diffAttributes(dom, attrs, old) {\n\tlet name;\n\n\t// remove attributes no longer present on the vnode by setting them to undefined\n\tfor (name in old) {\n\t\tif (!(attrs && attrs[name]!=null) && old[name]!=null) {\n\t\t\tsetAccessor(dom, name, old[name], old[name] = undefined, isSvgMode);\n\t\t}\n\t}\n\n\t// add new & update changed attributes\n\tfor (name in attrs) {\n\t\tif (name!=='children' && name!=='innerHTML' && (!(name in old) || attrs[name]!==(name==='value' || name==='checked' ? dom[name] : old[name]))) {\n\t\t\tsetAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);\n\t\t}\n\t}\n}\n","import { SYNC_RENDER, NO_RENDER, FORCE_RENDER, ASYNC_RENDER, ATTR_KEY } from '../constants';\nimport options from '../options';\nimport { extend, applyRef } from '../util';\nimport { enqueueRender } from '../render-queue';\nimport { getNodeProps } from './index';\nimport { diff, mounts, diffLevel, flushMounts, recollectNodeTree, removeChildren } from './diff';\nimport { createComponent, recyclerComponents } from './component-recycler';\nimport { removeNode } from '../dom/index';\n\n/**\n * Set a component's `props` and possibly re-render the component\n * @param {import('../component').Component} component The Component to set props on\n * @param {object} props The new props\n * @param {number} renderMode Render options - specifies how to re-render the component\n * @param {object} context The new context\n * @param {boolean} mountAll Whether or not to immediately mount all components\n */\nexport function setComponentProps(component, props, renderMode, context, mountAll) {\n\tif (component._disable) return;\n\tcomponent._disable = true;\n\n\tcomponent.__ref = props.ref;\n\tcomponent.__key = props.key;\n\tdelete props.ref;\n\tdelete props.key;\n\n\tif (typeof component.constructor.getDerivedStateFromProps === 'undefined') {\n\t\tif (!component.base || mountAll) {\n\t\t\tif (component.componentWillMount) component.componentWillMount();\n\t\t}\n\t\telse if (component.componentWillReceiveProps) {\n\t\t\tcomponent.componentWillReceiveProps(props, context);\n\t\t}\n\t}\n\n\tif (context && context!==component.context) {\n\t\tif (!component.prevContext) component.prevContext = component.context;\n\t\tcomponent.context = context;\n\t}\n\n\tif (!component.prevProps) component.prevProps = component.props;\n\tcomponent.props = props;\n\n\tcomponent._disable = false;\n\n\tif (renderMode!==NO_RENDER) {\n\t\tif (renderMode===SYNC_RENDER || options.syncComponentUpdates!==false || !component.base) {\n\t\t\trenderComponent(component, SYNC_RENDER, mountAll);\n\t\t}\n\t\telse {\n\t\t\tenqueueRender(component);\n\t\t}\n\t}\n\n\tapplyRef(component.__ref, component);\n}\n\n\n\n/**\n * Render a Component, triggering necessary lifecycle events and taking\n * High-Order Components into account.\n * @param {import('../component').Component} component The component to render\n * @param {number} [renderMode] render mode, see constants.js for available options.\n * @param {boolean} [mountAll] Whether or not to immediately mount all components\n * @param {boolean} [isChild] ?\n * @private\n */\nexport function renderComponent(component, renderMode, mountAll, isChild) {\n\tif (component._disable) return;\n\n\tlet props = component.props,\n\t\tstate = component.state,\n\t\tcontext = component.context,\n\t\tpreviousProps = component.prevProps || props,\n\t\tpreviousState = component.prevState || state,\n\t\tpreviousContext = component.prevContext || context,\n\t\tisUpdate = component.base,\n\t\tnextBase = component.nextBase,\n\t\tinitialBase = isUpdate || nextBase,\n\t\tinitialChildComponent = component._component,\n\t\tskip = false,\n\t\tsnapshot = previousContext,\n\t\trendered, inst, cbase;\n\n\tif (component.constructor.getDerivedStateFromProps) {\n\t\tstate = extend(extend({}, state), component.constructor.getDerivedStateFromProps(props, state));\n\t\tcomponent.state = state;\n\t}\n\n\t// if updating\n\tif (isUpdate) {\n\t\tcomponent.props = previousProps;\n\t\tcomponent.state = previousState;\n\t\tcomponent.context = previousContext;\n\t\tif (renderMode!==FORCE_RENDER\n\t\t\t&& component.shouldComponentUpdate\n\t\t\t&& component.shouldComponentUpdate(props, state, context) === false) {\n\t\t\tskip = true;\n\t\t}\n\t\telse if (component.componentWillUpdate) {\n\t\t\tcomponent.componentWillUpdate(props, state, context);\n\t\t}\n\t\tcomponent.props = props;\n\t\tcomponent.state = state;\n\t\tcomponent.context = context;\n\t}\n\n\tcomponent.prevProps = component.prevState = component.prevContext = component.nextBase = null;\n\tcomponent._dirty = false;\n\n\tif (!skip) {\n\t\trendered = component.render(props, state, context);\n\n\t\t// context to pass to the child, can be updated via (grand-)parent component\n\t\tif (component.getChildContext) {\n\t\t\tcontext = extend(extend({}, context), component.getChildContext());\n\t\t}\n\n\t\tif (isUpdate && component.getSnapshotBeforeUpdate) {\n\t\t\tsnapshot = component.getSnapshotBeforeUpdate(previousProps, previousState);\n\t\t}\n\n\t\tlet childComponent = rendered && rendered.nodeName,\n\t\t\ttoUnmount, base;\n\n\t\tif (typeof childComponent==='function') {\n\t\t\t// set up high order component link\n\n\t\t\tlet childProps = getNodeProps(rendered);\n\t\t\tinst = initialChildComponent;\n\n\t\t\tif (inst && inst.constructor===childComponent && childProps.key==inst.__key) {\n\t\t\t\tsetComponentProps(inst, childProps, SYNC_RENDER, context, false);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttoUnmount = inst;\n\n\t\t\t\tcomponent._component = inst = createComponent(childComponent, childProps, context);\n\t\t\t\tinst.nextBase = inst.nextBase || nextBase;\n\t\t\t\tinst._parentComponent = component;\n\t\t\t\tsetComponentProps(inst, childProps, NO_RENDER, context, false);\n\t\t\t\trenderComponent(inst, SYNC_RENDER, mountAll, true);\n\t\t\t}\n\n\t\t\tbase = inst.base;\n\t\t}\n\t\telse {\n\t\t\tcbase = initialBase;\n\n\t\t\t// destroy high order component link\n\t\t\ttoUnmount = initialChildComponent;\n\t\t\tif (toUnmount) {\n\t\t\t\tcbase = component._component = null;\n\t\t\t}\n\n\t\t\tif (initialBase || renderMode===SYNC_RENDER) {\n\t\t\t\tif (cbase) cbase._component = null;\n\t\t\t\tbase = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, true);\n\t\t\t}\n\t\t}\n\n\t\tif (initialBase && base!==initialBase && inst!==initialChildComponent) {\n\t\t\tlet baseParent = initialBase.parentNode;\n\t\t\tif (baseParent && base!==baseParent) {\n\t\t\t\tbaseParent.replaceChild(base, initialBase);\n\n\t\t\t\tif (!toUnmount) {\n\t\t\t\t\tinitialBase._component = null;\n\t\t\t\t\trecollectNodeTree(initialBase, false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (toUnmount) {\n\t\t\tunmountComponent(toUnmount);\n\t\t}\n\n\t\tcomponent.base = base;\n\t\tif (base && !isChild) {\n\t\t\tlet componentRef = component,\n\t\t\t\tt = component;\n\t\t\twhile ((t=t._parentComponent)) {\n\t\t\t\t(componentRef = t).base = base;\n\t\t\t}\n\t\t\tbase._component = componentRef;\n\t\t\tbase._componentConstructor = componentRef.constructor;\n\t\t}\n\t}\n\n\tif (!isUpdate || mountAll) {\n\t\tmounts.push(component);\n\t}\n\telse if (!skip) {\n\t\t// Ensure that pending componentDidMount() hooks of child components\n\t\t// are called before the componentDidUpdate() hook in the parent.\n\t\t// Note: disabled as it causes duplicate hooks, see https://github.com/developit/preact/issues/750\n\t\t// flushMounts();\n\n\t\tif (component.componentDidUpdate) {\n\t\t\tcomponent.componentDidUpdate(previousProps, previousState, snapshot);\n\t\t}\n\t\tif (options.afterUpdate) options.afterUpdate(component);\n\t}\n\n\twhile (component._renderCallbacks.length) component._renderCallbacks.pop().call(component);\n\n\tif (!diffLevel && !isChild) flushMounts();\n}\n\n\n\n/**\n * Apply the Component referenced by a VNode to the DOM.\n * @param {import('../dom').PreactElement} dom The DOM node to mutate\n * @param {import('../vnode').VNode} vnode A Component-referencing VNode\n * @param {object} context The current context\n * @param {boolean} mountAll Whether or not to immediately mount all components\n * @returns {import('../dom').PreactElement} The created/mutated element\n * @private\n */\nexport function buildComponentFromVNode(dom, vnode, context, mountAll) {\n\tlet c = dom && dom._component,\n\t\toriginalComponent = c,\n\t\toldDom = dom,\n\t\tisDirectOwner = c && dom._componentConstructor===vnode.nodeName,\n\t\tisOwner = isDirectOwner,\n\t\tprops = getNodeProps(vnode);\n\twhile (c && !isOwner && (c=c._parentComponent)) {\n\t\tisOwner = c.constructor===vnode.nodeName;\n\t}\n\n\tif (c && isOwner && (!mountAll || c._component)) {\n\t\tsetComponentProps(c, props, ASYNC_RENDER, context, mountAll);\n\t\tdom = c.base;\n\t}\n\telse {\n\t\tif (originalComponent && !isDirectOwner) {\n\t\t\tunmountComponent(originalComponent);\n\t\t\tdom = oldDom = null;\n\t\t}\n\n\t\tc = createComponent(vnode.nodeName, props, context);\n\t\tif (dom && !c.nextBase) {\n\t\t\tc.nextBase = dom;\n\t\t\t// passing dom/oldDom as nextBase will recycle it if unused, so bypass recycling on L229:\n\t\t\toldDom = null;\n\t\t}\n\t\tsetComponentProps(c, props, SYNC_RENDER, context, mountAll);\n\t\tdom = c.base;\n\n\t\tif (oldDom && dom!==oldDom) {\n\t\t\toldDom._component = null;\n\t\t\trecollectNodeTree(oldDom, false);\n\t\t}\n\t}\n\n\treturn dom;\n}\n\n\n\n/**\n * Remove a component from the DOM and recycle it.\n * @param {import('../component').Component} component The Component instance to unmount\n * @private\n */\nexport function unmountComponent(component) {\n\tif (options.beforeUnmount) options.beforeUnmount(component);\n\n\tlet base = component.base;\n\n\tcomponent._disable = true;\n\n\tif (component.componentWillUnmount) component.componentWillUnmount();\n\n\tcomponent.base = null;\n\n\t// recursively tear down & recollect high-order component children:\n\tlet inner = component._component;\n\tif (inner) {\n\t\tunmountComponent(inner);\n\t}\n\telse if (base) {\n\t\tif (base[ATTR_KEY]!=null) applyRef(base[ATTR_KEY].ref, null);\n\n\t\tcomponent.nextBase = base;\n\n\t\tremoveNode(base);\n\t\trecyclerComponents.push(component);\n\n\t\tremoveChildren(base);\n\t}\n\n\tapplyRef(component.__ref, null);\n}\n","import { Component } from '../component';\n\n/**\n * Retains a pool of Components for re-use.\n * @type {Component[]}\n * @private\n */\nexport const recyclerComponents = [];\n\n\n/**\n * Create a component. Normalizes differences between PFC's and classful\n * Components.\n * @param {function} Ctor The constructor of the component to create\n * @param {object} props The initial props of the component\n * @param {object} context The initial context of the component\n * @returns {import('../component').Component}\n */\nexport function createComponent(Ctor, props, context) {\n\tlet inst, i = recyclerComponents.length;\n\n\tif (Ctor.prototype && Ctor.prototype.render) {\n\t\tinst = new Ctor(props, context);\n\t\tComponent.call(inst, props, context);\n\t}\n\telse {\n\t\tinst = new Component(props, context);\n\t\tinst.constructor = Ctor;\n\t\tinst.render = doRender;\n\t}\n\n\n\twhile (i--) {\n\t\tif (recyclerComponents[i].constructor===Ctor) {\n\t\t\tinst.nextBase = recyclerComponents[i].nextBase;\n\t\t\trecyclerComponents.splice(i, 1);\n\t\t\treturn inst;\n\t\t}\n\t}\n\n\treturn inst;\n}\n\n\n/** The `.render()` method for a PFC backing instance. */\nfunction doRender(props, state, context) {\n\treturn this.constructor(props, context);\n}\n","import { FORCE_RENDER } from './constants';\nimport { extend } from './util';\nimport { renderComponent } from './vdom/component';\nimport { enqueueRender } from './render-queue';\n/**\n * Base Component class.\n * Provides `setState()` and `forceUpdate()`, which trigger rendering.\n * @typedef {object} Component\n * @param {object} props The initial component props\n * @param {object} context The initial context from parent components' getChildContext\n * @public\n *\n * @example\n * class MyFoo extends Component {\n *   render(props, state) {\n *     return <div />;\n *   }\n * }\n */\nexport function Component(props, context) {\n\tthis._dirty = true;\n\n\t/**\n\t * @public\n\t * @type {object}\n\t */\n\tthis.context = context;\n\n\t/**\n\t * @public\n\t * @type {object}\n\t */\n\tthis.props = props;\n\n\t/**\n\t * @public\n\t * @type {object}\n\t */\n\tthis.state = this.state || {};\n\n\tthis._renderCallbacks = [];\n}\n\n\nextend(Component.prototype, {\n\n\t/**\n\t * Update component state and schedule a re-render.\n\t * @param {object} state A dict of state properties to be shallowly merged\n\t * \tinto the current state, or a function that will produce such a dict. The\n\t * \tfunction is called with the current state and props.\n\t * @param {() => void} callback A function to be called once component state is\n\t * \tupdated\n\t */\n\tsetState(state, callback) {\n\t\tif (!this.prevState) this.prevState = this.state;\n\t\tthis.state = extend(\n\t\t\textend({}, this.state),\n\t\t\ttypeof state === 'function' ? state(this.state, this.props) : state\n\t\t);\n\t\tif (callback) this._renderCallbacks.push(callback);\n\t\tenqueueRender(this);\n\t},\n\n\n\t/**\n\t * Immediately perform a synchronous re-render of the component.\n\t * @param {() => void} callback A function to be called after component is\n\t * \tre-rendered.\n\t * @private\n\t */\n\tforceUpdate(callback) {\n\t\tif (callback) this._renderCallbacks.push(callback);\n\t\trenderComponent(this, FORCE_RENDER);\n\t},\n\n\n\t/**\n\t * Accepts `props` and `state`, and returns a new Virtual DOM tree to build.\n\t * Virtual DOM is generally constructed via [JSX](http://jasonformat.com/wtf-is-jsx).\n\t * @param {object} props Props (eg: JSX attributes) received from parent\n\t * \telement/component\n\t * @param {object} state The component's current state\n\t * @param {object} context Context object, as returned by the nearest\n\t *  ancestor's `getChildContext()`\n\t * @returns {import('./vnode').VNode | void}\n\t */\n\trender() {}\n\n});\n","/* eslint-disable no-unused-vars */\nimport * as d3 from 'd3';\nimport _ from 'lodash';\nimport * as topojson from 'topojson-client';\nimport createBase from '../utils/d3-base';\nimport { intcomma } from 'journalize';\nimport {\n  highways,\n  cities,\n  add_legend_for_gray,\n  rate_perResidents,\n  relocateTooltip,\n} from '../utils/map-utils';\nimport * as ss from 'simple-statistics';\nimport loadAssetURL from '../utils/load-asset-url';\n\nconst partners = window.location.search;\nconst isPartners = partners ? true : false;\nconst TT_logo_present = loadAssetURL('TT-logo-present');\n\nimport topology from 'Assets/geography/texas_counties_roads.json';\nimport topology_hsa from 'Assets/geography/texas_tsas.json';\nimport data from '../../../data/map/tx_hospitals_map.json';\n\nconst container = d3.select('#tx-hospitals-map');\n\nconst getFrameWidth = () => container.node().offsetWidth;\n\n// a helper function to clear the container of its contents\nconst clearContainer = () => container.html('');\n\n// breakpoint for mobile\nlet breakPoint = 544;\n\n// Toggle buttons\n\n// let btnContainer = document.querySelector('#btnGroup');\n// let btns = btnContainer.getElementsByClassName('button');\n\n// for (var t = 0; t < btns.length; t++) {\n//   btns[t].addEventListener('click', function (event) {\n//     var currentParent = document.querySelector('#btnGroup');\n//     var current = currentParent.getElementsByClassName('active');\n//     current[0].className = current[0].className.replace(' active', '');\n//     this.className += ' active';\n//     defVal = this.value;\n//     let promises = [topology, defVal];\n//     Promise.all(promises).then(ready);\n//   });\n// }\n\n// sets geo stuff for projection\nconst geoPath = d3.geoPath();\n\nconst geoIdentity = d3.geoIdentity().reflectY(true);\n\n// establish color bucket breakdown\nlet color = d3.scaleQuantize().range([\n  // '#ffffe0',\n  // '#FFF5B2',\n  '#FDDE85',\n  // '#FDBB45', // take out some of the middle colors to accentuate extremes\n  '#FDA23E',\n  // '#F2691D',\n  '#DB3F2A',\n  // '#A52C20',\n  '#6C1D1C',\n]);\n\nconst latest_date = data['latest_date'];\n\nconst cases = data[latest_date]['cases'];\nconst cases_prev = data[latest_date]['cases_prev'];\n\nconst popData = d3.map(),\n  totalBedsData = d3.map(),\n  bedsAvailData = d3.map(),\n  icuBedsData = d3.map(),\n  ventsAvailData = d3.map(),\n  covidPatientsData = d3.map(),\n  rateData = d3.map(),\n  staffedInpatientBeds = d3.map();\n\n// sets the data for cases, rate per 1000 and total_beds\ncases.forEach(d =>\n  rateData.set(\n    d.trauma_service_area,\n    rate_perResidents(+d.covid_patients, +d.total_beds, 100)\n  )\n);\ncases.forEach(d => popData.set(d.trauma_service_area, +d['2020_pop']));\ncases.forEach(d => totalBedsData.set(d.trauma_service_area, +d.total_beds));\ncases.forEach(d => bedsAvailData.set(d.trauma_service_area, +d.beds_avail));\ncases.forEach(d => icuBedsData.set(d.trauma_service_area, +d.icu_beds_avail));\ncases.forEach(d => ventsAvailData.set(d.trauma_service_area, +d.vent_avail));\ncases.forEach(d =>\n  covidPatientsData.set(d.trauma_service_area, +d.covid_patients)\n);\ncases.forEach(d =>\n  staffedInpatientBeds.set(d.trauma_service_area, +d.staffed_inpatient_beds)\n);\n\n// Make object into array so we can find the domain of data for color scale\nlet dataArray = Object.keys(rateData).map(key => rateData[key]);\n\nexport default function renderHospitalMap() {\n  clearContainer();\n\n  const frameWidth = getFrameWidth(); // calcuates the width on each render\n\n  // Establishes as isMobile function\n\n  const isMobile = frameWidth < breakPoint;\n\n  // uses `./utils/d3-base` to set up a bunch of conventional d3 stuff\n\n  const map = createBase({\n    container, // the chart container\n    height: isMobile ? frameWidth + (isPartners ? 120 : 70) : 600, // mobile height\n  });\n\n  // Creates the svg for the map\n\n  const svg = map.g.append('g').attr('class', 'g_rate_map');\n\n  let promises = [topology, topology_hsa];\n\n  Promise.all(promises).then(ready);\n\n  function ready([shapefiles]) {\n    // Creates title and map base for the rate map\n\n    const state = topojson.merge(\n        shapefiles,\n        shapefiles.objects.counties.geometries\n      ),\n      // counties = topojson.feature(shapefiles, shapefiles.objects.counties),\n      texas_highways = topojson.feature(shapefiles, shapefiles.objects.roads),\n      major_cities = topojson.feature(shapefiles, shapefiles.objects.places),\n      hsas = topojson.feature(topology_hsa, topology_hsa.objects.tsa);\n\n    // Finding ckmeans Thresholds for scale, an alternative to the usual scale\n\n    // More info here: https://observablehq.com/@d3/quantile-quantize-and-threshold-scales\n\n    // https://medium.com/@dschnr/using-clustering-to-create-a-new-d3-js-color-scale-dec4ccd639d2\n\n    const numberOfClasses = color.range().length - 1;\n\n    let x_legend = d3\n      .scaleLinear()\n      .rangeRound([\n        map.width * (isMobile ? 0.1 : 0.58),\n        map.width * (isMobile ? 0.9 : 0.825),\n      ]);\n\n    // use this domain just for the hospitals map color scale\n    let startRange = 0,\n      endRange = 15,\n      newDomain = d3.range(startRange, endRange, 5);\n    newDomain.push(endRange); // push the max number in, not included in d3.range()'s array\n    \n    // Establish the domain\n    color.domain(newDomain);\n    x_legend.domain(newDomain);\n\n    const projection = geoIdentity.fitExtent(\n      [\n        [0, isMobile ? 75 : 0],\n        [map.width, map.height],\n      ],\n      state\n    );\n\n    const path = geoPath.projection(projection);\n\n    // Adding Texas county shapefile\n    // const counties_shape = svg\n    //   .selectAll('g')\n    //   .data(counties.features)\n    //   .enter()\n    //   .append('path')\n    //   .attr('class', 'counties')\n    //   .attr('fill', '#e8e8e8')\n    //   .attr('stroke', 'rgba(255, 255, 255, .6)')\n    //   .attr('d', path);\n\n    // Adding Texas HSA shapefile\n    const hsas_shape = svg\n      .selectAll('g')\n      .data(hsas.features)\n      .enter()\n      .append('path')\n      .attr('class', 'hsas')\n      .attr('fill', d => {\n        let hospital_beds_in_use = rateData.get(d.properties.TSA);\n        if (hospital_beds_in_use) {\n          var domain_reverse = newDomain.slice().reverse();\n\n          for (var i = 0; i < domain_reverse.length; i++) {\n            if (hospital_beds_in_use > domain_reverse[i]) {\n              return color.range()[numberOfClasses - i];\n            }\n          }\n        } else {\n          return '#e8e8e8';\n        }\n      })\n      .attr('stroke', 'rgba(255, 255, 255, .6)')\n      .attr('d', path);\n\n    // Adds highways (the order of this is very important)\n    highways(svg, texas_highways, path);\n\n    // Add cities\n    cities(svg, major_cities, path);\n\n    const tooltip = container\n      .append('div')\n      .attr('class', 'tooltip')\n      .style('opacity', 0);\n\n    hsas_shape.on('mouseover', MouseOver).on('mouseout', MouseOut);\n\n    function MouseOver(d, i) {\n      const active_county = svg\n        .append('path')\n        .datum(d)\n        .attr('d', path)\n        .classed('active_county', true);\n\n      const pop = popData.get(d.properties.TSA),\n        total_beds = totalBedsData.get(d.properties.TSA),\n        beds_avail = bedsAvailData.get(d.properties.TSA),\n        icu_beds = icuBedsData.get(d.properties.TSA),\n        vents_avail = ventsAvailData.get(d.properties.TSA),\n        covid_patients = covidPatientsData.get(d.properties.TSA),\n        rate = rateData.get(d.properties.TSA),\n        staffed_inpatient_beds = staffedInpatientBeds.get(d.properties.TSA);\n\n      var tooltip_div = `<div class='county-title'>${\n        d.properties.RAC\n      } </div><div style=\"margin-bottom: 0\" class='county-data'>Population: ${\n        pop ? intcomma(pop) : 0\n      }</div><div style=\"margin: 0.312rem 0;\" class='county-data'>COVID-19 patients take up <span style='font-weight:bold;'>${\n        rate ? rate.toFixed(1) : 0\n      }%</span> of the region's <br /> hospital capacity.</div><table class=\"dv-table\"><tbody><tr><td class='tooltip_header'>\n          COVID-19 patients\n        </td><td class=\"number text-right\">\n        ${covid_patients ? intcomma(covid_patients) : 0}\n        </td></tr><tr><td class='tooltip_header'>\n          Total beds\n        </td><td class=\"number text-right\">\n        ${total_beds ? intcomma(total_beds) : 0}\n        </td></tr><tr><td class='tooltip_header'>\n         ICU beds available\n        </td><td class=\"number text-right\">\n          ${icu_beds ? intcomma(icu_beds) : 0}\n        </td></tr></tbody></table>`;\n\n      tooltip.style('opacity', 0.9).html(tooltip_div);\n\n      relocateTooltip(\n        tooltip,\n        d3.event.pageX,\n        d3.event.pageY,\n        d3.event.screenY\n      );\n    }\n\n    function MouseOut(d) {\n      // Add interactivity\n      tooltip.style('opacity', 0);\n      d3.selectAll('.active_county').remove();\n    }\n\n    const legend = svg\n      .append('g')\n      .attr('class', 'legend')\n      .attr('transform', `translate(${isMobile ? 0 : map.width / -50},${15})`);\n\n    const rate_legend = legend\n      .append('g')\n      .attr('class', 'rate_legend')\n      .attr('transform', `translate(${isMobile ? 0 : 0},${0})`);\n\n    // Creates legend based on rate data\n\n    const legend_rect_width =\n      (x_legend.range()[1] - x_legend.range()[0]) / numberOfClasses;\n    \n    const legendText = rate_legend\n      .append('g')\n      .attr('class', 'tick')\n    \n    if (isMobile) {\n      legendText\n        .append('g')\n        .attr('transform', `translate(${x_legend.range()[0]},-8)`)\n        .append('text')\n        .text('Hospital beds used by COVID-19 patients')\n    } else {\n      legendText\n        .append('g')\n        .attr('transform', `translate(${x_legend.range()[0]},-23)`)\n        .append('text')\n        .text('Percent of hospital beds occupied')\n\n      legendText\n        .append('g')\n        .attr('transform', `translate(${x_legend.range()[0]},-8)`)\n        .append('text')\n        .text('by COVID-19 patients')\n    }\n      \n    rate_legend\n      .selectAll('rect')\n      .data(\n        color.range().map(function(d) {\n          d = color.invertExtent(d);\n          if (d[0] == null) d[0] = -1;\n          return d;\n        })\n      )\n      .enter()\n      .append('rect')\n      .attr('height', 10)\n      .attr('x', (d, i) => x_legend.range()[0] + i * legend_rect_width)\n      .attr('width', (d, i) => legend_rect_width + 2)\n      .attr('fill', d => color(d[0]));\n\n    // manually add ticks to the legend!\n    let ticks = rate_legend.append('g').attr('class', 'ticks');\n\n    let tickOne = ticks\n      .append('g')\n      .attr(\n        'transform',\n        `translate(${x_legend.range()[0]},0)`\n      )\n      .attr('class', 'tick');\n\n    tickOne\n      .append('line')\n      .attr('stroke', 'black')\n      .attr('stroke-width', '0.75px')\n      .attr('x1', 0)\n      .attr('x2', 0)\n      .attr('y1', 0)\n      .attr('y2', 15);\n\n    tickOne\n      .append('text')\n      .text(newDomain[0].toFixed(0) + '%')\n      .attr('x', 0)\n      .attr('y', 27)\n      .attr('text-anchor', 'middle');\n\n    let tickTwo = ticks\n      .append('g')\n      .attr(\n        'transform',\n        `translate(${x_legend.range()[0] + legend_rect_width * 3},0)`\n      )\n      .attr('class', 'tick');\n\n    tickTwo\n      .append('line')\n      .attr('stroke', 'black')\n      .attr('stroke-width', '0.75px')\n      .attr('x1', 0)\n      .attr('x2', 0)\n      .attr('y1', 0)\n      .attr('y2', 15);\n\n    tickTwo\n      .append('text')\n      .text(newDomain[newDomain.length - 1].toFixed(0) + '%+')\n      .attr('x', 0)\n      .attr('y', 27)\n      .attr('text-anchor', 'middle');\n\n    // rate_legend\n    //   .call(\n    //     d3\n    //       .axisBottom(x_legend)\n    //       .tickSize(15)\n    //       .tickFormat(\n    //         (d, i) =>\n    //           i ? newDomain[newDomain.length - 1].toFixed(0) + '%+' : '40%' // HACK\n    //       )\n    //       .tickValues(color.domain())\n    //   )\n    //   .select('.domain')\n    //   .remove();\n\n    // This adds the \"No reported cases\" gray box below the legend\n    // add_legend_for_gray(legend, 'rate', x_legend, isMobile);\n  }\n\n  const partners_img_width = map.width * (isMobile ? 1 : 0.5);\n  const partners_img_height = partners_img_width / 13.3;\n\n  if (isPartners) {\n    const partner_link = svg\n      .append('a')\n      .attr('xlink:href', 'https://www.texastribune.org/')\n      .attr('target', '_parent')\n      .attr('rel', 'noopener noreferrer');\n\n    partner_link\n      .append('svg:image')\n      .attr('alt', 'Coronavirus tracker presented by The Texas Tribune')\n      .attr('x', -20)\n      .attr('y', map.height - partners_img_height / 2)\n      .attr(\n        'width',\n        frameWidth > 800 ? partners_img_width * 0.7 : partners_img_width\n      )\n      .attr('height', partners_img_height)\n      .attr('xlink:href', TT_logo_present);\n  }\n}\n\n// function resize() {\n//   // code executed on window resize\n//   let frameWidth = getFrameWidth(),\n//     frameHeight;\n\n//   if (frameWidth < breakPoint) {\n//     frameHeight = 475;\n//   } else {\n//     frameHeight = 600;\n//   }\n\n//   let chartWidth = frameWidth,\n//     chartHeight = frameHeight;\n//   let promises = [topology];\n\n// }\n\n// // call resize on load\n// resize();\n// window.addEventListener('resize', _.debounce(resize, 200));\n"],"sourceRoot":""}