'use strict';

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

var _reactIntl = require('react-intl');

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

exports.default = function (pluginContext) {
  var _valueAmounts, _valueAmountsList, _ns2Valuationcontrol;

  var _pluginContext$inputC = pluginContext.inputComponents,
      CompoundInput = _pluginContext$inputC.CompoundInput,
      DateInput = _pluginContext$inputC.DateInput,
      OptionPickerInput = _pluginContext$inputC.OptionPickerInput,
      TextInput = _pluginContext$inputC.TextInput,
      AutocompleteInput = _pluginContext$inputC.AutocompleteInput,
      IDGeneratorInput = _pluginContext$inputC.IDGeneratorInput,
      TermPickerInput = _pluginContext$inputC.TermPickerInput;
  var config = pluginContext.configHelpers.configKey;
  var _pluginContext$dataTy = pluginContext.dataTypes,
      DATA_TYPE_DATE = _pluginContext$dataTy.DATA_TYPE_DATE,
      DATA_TYPE_FLOAT = _pluginContext$dataTy.DATA_TYPE_FLOAT;
  var extensions = pluginContext.config.extensions;


  return {
    document: Object.assign(_defineProperty({}, config, {
      view: {
        type: CompoundInput,
        props: {
          defaultChildSubpath: 'ns2:valuationcontrols_common'
        }
      }
    }), extensions.core.fields, {
      'ns2:valuationcontrols_common': (_ns2Valuationcontrol = {}, _defineProperty(_ns2Valuationcontrol, config, {
        service: {
          ns: 'http://collectionspace.org/services/valuationcontrol'
        }
      }), _defineProperty(_ns2Valuationcontrol, 'valuationcontrolRefNumber', _defineProperty({}, config, {
        cloneable: false,
        messages: (0, _reactIntl.defineMessages)({
          name: {
            'id': 'field.valuationcontrols_common.valuationcontrolRefNumber.name',
            'defaultMessage': 'Reference number'
          }
        }),
        required: true,
        searchView: {
          type: TextInput
        },
        view: {
          type: IDGeneratorInput,
          props: {
            idGeneratorName: 'valuationcontrol'
          }
        }
      })), _defineProperty(_ns2Valuationcontrol, 'valueAmountsList', (_valueAmountsList = {}, _defineProperty(_valueAmountsList, config, {
        view: {
          type: CompoundInput
        }
      }), _defineProperty(_valueAmountsList, 'valueAmounts', (_valueAmounts = {}, _defineProperty(_valueAmounts, config, {
        messages: (0, _reactIntl.defineMessages)({
          name: {
            'id': 'field.valuationcontrols_common.valueAmounts.name',
            'defaultMessage': 'Amount'
          }
        }),
        repeating: true,
        view: {
          type: CompoundInput,
          props: {
            tabular: true
          }
        }
      }), _defineProperty(_valueAmounts, 'valueCurrency', _defineProperty({}, config, {
        messages: (0, _reactIntl.defineMessages)({
          name: {
            'id': 'field.valuationcontrols_common.valueCurrency.name',
            'defaultMessage': 'Currency'
          }
        }),
        view: {
          type: TermPickerInput,
          props: {
            source: 'currency'
          }
        }
      })), _defineProperty(_valueAmounts, 'valueAmount', _defineProperty({}, config, {
        dataType: DATA_TYPE_FLOAT,
        messages: (0, _reactIntl.defineMessages)({
          name: {
            'id': 'field.valuationcontrols_common.valueAmount.name',
            'defaultMessage': 'Value'
          },
          fullName: {
            'id': 'field.valuationcontrols_common.valueAmount.fullName',
            'defaultMessage': 'Amount value'
          }
        }),
        view: {
          type: TextInput
        }
      })), _valueAmounts)), _valueAmountsList)), _defineProperty(_ns2Valuationcontrol, 'valueDate', _defineProperty({}, config, {
        dataType: DATA_TYPE_DATE,
        messages: (0, _reactIntl.defineMessages)({
          name: {
            'id': 'field.valuationcontrols_common.valueDate.name',
            'defaultMessage': 'Date'
          }
        }),
        view: {
          type: DateInput
        }
      })), _defineProperty(_ns2Valuationcontrol, 'valueRenewalDate', _defineProperty({}, config, {
        dataType: DATA_TYPE_DATE,
        messages: (0, _reactIntl.defineMessages)({
          name: {
            'id': 'field.valuationcontrols_common.valueRenewalDate.name',
            'defaultMessage': 'Renewal date'
          }
        }),
        view: {
          type: DateInput
        }
      })), _defineProperty(_ns2Valuationcontrol, 'valueSource', _defineProperty({}, config, {
        messages: (0, _reactIntl.defineMessages)({
          name: {
            'id': 'field.valuationcontrols_common.valueSource.name',
            'defaultMessage': 'Source'
          }
        }),
        view: {
          type: AutocompleteInput,
          props: {
            source: 'person/local,person/shared,organization/local,organization/shared'
          }
        }
      })), _defineProperty(_ns2Valuationcontrol, 'valueType', _defineProperty({}, config, {
        messages: (0, _reactIntl.defineMessages)({
          name: {
            'id': 'field.valuationcontrols_common.valueType.name',
            'defaultMessage': 'Type'
          }
        }),
        view: {
          type: OptionPickerInput,
          props: {
            source: 'valueTypes'
          }
        }
      })), _defineProperty(_ns2Valuationcontrol, 'valueNote', _defineProperty({}, config, {
        messages: (0, _reactIntl.defineMessages)({
          name: {
            'id': 'field.valuationcontrols_common.valueNote.name',
            'defaultMessage': 'Note'
          }
        }),
        view: {
          type: TextInput,
          props: {
            multiline: true
          }
        }
      })), _ns2Valuationcontrol)
    })
  };
};