'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _formatHelpers = require('../../../helpers/formatHelpers');

exports.default = pluginContext => (data, formatterContext) => {
  var _pluginContext$record = pluginContext.recordDataHelpers;
  const getPart = _pluginContext$record.getPart,
        deepGet = _pluginContext$record.deepGet;


  if (!data) {
    return '';
  }

  const common = getPart(data, 'conditionchecks_common');

  if (!common) {
    return '';
  }

  const conditioncheckRefNumber = common.get('conditionCheckRefNumber');
  const condition = deepGet(common, ['conditionCheckGroupList', 'conditionCheckGroup', 0, 'condition']);
  const formattedCondition = (0, _formatHelpers.formatOption)('conditions', condition, formatterContext);

  return [conditioncheckRefNumber, formattedCondition].filter(part => !!part).join(' – ');
};