{"version":3,"file":"aggregateUtils.mjs","names":["SeverityTypeEnums","NumberOperatorEnums","getThresholdStatus","aggThreshold","aggregateValue","thresholdTypes","type","Success","threshold","successThreshold","Error","errorThreshold","Warning","warningThreshold","Info","infoThreshold","thresholdStatus","evaluateThreshold","getCountThresholdStatus","thresholds","value","undefined","ordered","success","error","warning","info","band","JSON","parse","console","operator","value1","value2","thresholdMet","Equals","parseFloat","Does_Not_Equal","Greater_Than","Less_Than","Greater_Than_Or_Equal_To","Less_Than_Or_Equal_To","Between"],"sources":["../../../../src/UI/utilityDisplay/utilities/aggregateUtils.js"],"sourcesContent":["import { SeverityTypeEnums } from '../../../enums/unitySystemEnums';\nimport { NumberOperatorEnums } from '../../../models/NumberOperator';\n\nexport const getThresholdStatus = (aggThreshold, aggregateValue) => {\n  if (!aggThreshold || !aggregateValue) return null;\n  // Order of this array matters\n  const thresholdTypes = [\n    {\n      type: SeverityTypeEnums.Success,\n      threshold: aggThreshold.successThreshold\n    },\n    { type: SeverityTypeEnums.Error, threshold: aggThreshold.errorThreshold },\n    {\n      type: SeverityTypeEnums.Warning,\n      threshold: aggThreshold.warningThreshold\n    },\n    { type: SeverityTypeEnums.Info, threshold: aggThreshold.infoThreshold }\n  ];\n\n  let thresholdStatus = '';\n  for (const { type, threshold } of thresholdTypes) {\n    if (threshold && evaluateThreshold(threshold, aggregateValue)) {\n      thresholdStatus = type;\n      break;\n    }\n  }\n\n  return thresholdStatus;\n};\n\n/**\n * Severity for a count chip's value against its optional bands\n * (CountChipThresholds — { success/error/warning/info: { operator, value1,\n * value2 } }). Same band evaluation and precedence order as\n * getThresholdStatus, but a count of 0 is a real value here — \"success when\n * 0\" is the whole point of a zero band — so only a missing value skips.\n */\nexport const getCountThresholdStatus = (thresholds, value) => {\n  if (!thresholds || value === null || value === undefined) return '';\n  const ordered = [\n    [SeverityTypeEnums.Success, thresholds.success],\n    [SeverityTypeEnums.Error, thresholds.error],\n    [SeverityTypeEnums.Warning, thresholds.warning],\n    [SeverityTypeEnums.Info, thresholds.info]\n  ];\n  for (const [type, band] of ordered) {\n    if (band && evaluateThreshold(band, value)) return type;\n  }\n  return '';\n};\n\nconst evaluateThreshold = (threshold = {}, aggregateValue) => {\n  if (typeof threshold === 'string') {\n    try {\n      threshold = JSON.parse(threshold);\n    } catch {\n      console.error(`Could not parse: ${threshold}`);\n      return false;\n    }\n  }\n  const { operator, value1, value2 } = threshold;\n  let thresholdMet = false;\n\n  switch (operator) {\n    case NumberOperatorEnums.Equals:\n      thresholdMet = aggregateValue === parseFloat(value1);\n      break;\n    case NumberOperatorEnums.Does_Not_Equal:\n      thresholdMet = aggregateValue !== parseFloat(value1);\n      break;\n    case NumberOperatorEnums.Greater_Than:\n      thresholdMet = aggregateValue > parseFloat(value1);\n      break;\n    case NumberOperatorEnums.Less_Than:\n      thresholdMet = aggregateValue < parseFloat(value1);\n      break;\n    case NumberOperatorEnums.Greater_Than_Or_Equal_To:\n      thresholdMet = aggregateValue >= parseFloat(value1);\n      break;\n    case NumberOperatorEnums.Less_Than_Or_Equal_To:\n      thresholdMet = aggregateValue <= parseFloat(value1);\n      break;\n    case NumberOperatorEnums.Between:\n      thresholdMet =\n        aggregateValue >= parseFloat(value1) &&\n        aggregateValue <= parseFloat(value2);\n      break;\n    default:\n      break;\n  }\n\n  return thresholdMet;\n};\n"],"mappings":";;;AAGA,MAAaE,sBAAsBC,cAAcC,mBAAmB;AAClE,KAAI,CAACD,gBAAgB,CAACC,eAAgB,QAAO;CAE7C,MAAMC,iBAAiB;EACrB;GACEC,MAAMN,kBAAkBO;GACxBC,WAAWL,aAAaM;GACzB;EACD;GAAEH,MAAMN,kBAAkBU;GAAOF,WAAWL,aAAaQ;GAAgB;EACzE;GACEL,MAAMN,kBAAkBY;GACxBJ,WAAWL,aAAaU;GACzB;EACD;GAAEP,MAAMN,kBAAkBc;GAAMN,WAAWL,aAAaY;GAAe;EACxE;CAED,IAAIC,kBAAkB;AACtB,MAAK,MAAM,EAAEV,MAAME,eAAe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