"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash"),t=require("../convert.js");exports.convertCostToSave=function(e){return e*t.convertValue(1,"length","ft")},exports.convertCostToShow=function(e){return e/t.convertValue(1,"length","ft")},exports.convertPercentageMetrics=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.precision,o=void 0===n?2:n,u=100*t;return e.round(u>100&&u<101.5?100:u,o)},exports.convertPercentageToSave=function(e){return Number(e)/100},exports.getAverage=function(e){return e.sumVal/e.number},exports.getConvertedMetricValue=function(r,n,o,u){if(!Number.isFinite(r)||!n)return null;var i=n.unitType,a=n.from,s=n.to,c=n.customConvert,v=n.convertForMultiRigs,l=n.precision,p=void 0===l?2:l,f=n.allowNegativeValue,g=void 0!==f&&f,m=v&&o?v({sumVal:r,maxVal:u,number:o}):r;if(c)return c(m,n);var x=i?t.convertValue(m,i,a,s,p):m;return x=e.round(x,p),x=g?x:Math.max(x,0)},exports.getMax=function(e){return e.maxVal},exports.getMetricUnitDisplay=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.formatUnitDisplay,o=void 0===n?e.identity:n,u=r.to,i=r.unitType;return u||i?o(u||t.getUnitDisplay(i)):""},exports.getSum=function(e){return e.sumVal};
