{"version":3,"file":"mapper.cjs","sources":["../../../../../src/components/DateTimePickers/TimeRangePicker/mapper.ts"],"sourcesContent":["import { TimeOption, TimeRange, TimeZone, rangeUtil, dateTimeFormat } from '@grafana/data';\n\nimport { getFeatureToggle } from '../../../utils/featureToggle';\nimport { commonFormat } from '../commonFormat';\n\n/**\n * Takes a printable TimeOption and builds a TimeRange with DateTime properties from it\n */\nexport const mapOptionToTimeRange = (option: TimeOption, timeZone?: TimeZone): TimeRange => {\n  return rangeUtil.convertRawToRange({ from: option.from, to: option.to }, timeZone, undefined, commonFormat);\n};\n\n/**\n * Takes a TimeRange and makes a printable TimeOption with formatted date strings correct for the timezone from it\n */\nexport const mapRangeToTimeOption = (range: TimeRange, timeZone?: TimeZone): TimeOption => {\n  const from = dateTimeFormat(range.from, { timeZone, format: commonFormat });\n  const to = dateTimeFormat(range.to, { timeZone, format: commonFormat });\n\n  let display = `${from} to ${to}`;\n\n  if (getFeatureToggle('localeFormatPreference')) {\n    display = rangeUtil.describeTimeRange(range, timeZone);\n  }\n\n  return {\n    from,\n    to,\n    display,\n  };\n};\n"],"names":["rangeUtil","commonFormat","dateTimeFormat","getFeatureToggle"],"mappings":";;;;;;;;;AAQO,MAAM,oBAAA,GAAuB,CAAC,MAAA,EAAoB,QAAA,KAAmC;AAC1F,EAAA,OAAOA,cAAA,CAAU,iBAAA,CAAkB,EAAE,IAAA,EAAM,MAAA,CAAO,IAAA,EAAM,EAAA,EAAI,MAAA,CAAO,EAAA,EAAG,EAAG,QAAA,EAAU,KAAA,CAAA,EAAWC,yBAAY,CAAA;AAC5G;AAKO,MAAM,oBAAA,GAAuB,CAAC,KAAA,EAAkB,QAAA,KAAoC;AACzF,EAAA,MAAM,IAAA,GAAOC,oBAAe,KAAA,CAAM,IAAA,EAAM,EAAE,QAAA,EAAU,MAAA,EAAQD,2BAAc,CAAA;AAC1E,EAAA,MAAM,EAAA,GAAKC,oBAAe,KAAA,CAAM,EAAA,EAAI,EAAE,QAAA,EAAU,MAAA,EAAQD,2BAAc,CAAA;AAEtE,EAAA,IAAI,OAAA,GAAU,CAAA,EAAG,IAAI,CAAA,IAAA,EAAO,EAAE,CAAA,CAAA;AAE9B,EAAA,IAAIE,8BAAA,CAAiB,wBAAwB,CAAA,EAAG;AAC9C,IAAA,OAAA,GAAUH,cAAA,CAAU,iBAAA,CAAkB,KAAA,EAAO,QAAQ,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,EAAA;AAAA,IACA;AAAA,GACF;AACF;;;;;"}