"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

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

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

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; }

var _default = configContext => {
  const {
    CompoundInput,
    DateInput,
    OptionPickerInput,
    TextInput,
    AutocompleteInput,
    IDGeneratorInput,
    TermPickerInput
  } = configContext.inputComponents;
  const {
    configKey: config
  } = configContext.configHelpers;
  const {
    DATA_TYPE_DATE,
    DATA_TYPE_FLOAT
  } = configContext.dataTypes;
  const {
    extensions
  } = configContext.config;
  return {
    document: _objectSpread({
      [config]: {
        view: {
          type: CompoundInput,
          props: {
            defaultChildSubpath: 'ns2:valuationcontrols_common'
          }
        }
      }
    }, extensions.core.fields, {
      'ns2:valuationcontrols_common': {
        [config]: {
          service: {
            ns: 'http://collectionspace.org/services/valuationcontrol'
          }
        },
        valuationcontrolRefNumber: {
          [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: {
                source: 'valuationcontrol'
              }
            }
          }
        },
        valueAmountsList: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          valueAmounts: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  "id": "field.valuationcontrols_common.valueAmounts.name",
                  "defaultMessage": "Amount"
                }
              }),
              repeating: true,
              view: {
                type: CompoundInput,
                props: {
                  tabular: true
                }
              }
            },
            valueCurrency: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    "id": "field.valuationcontrols_common.valueCurrency.fullName",
                    "defaultMessage": "Amount currency"
                  },
                  name: {
                    "id": "field.valuationcontrols_common.valueCurrency.name",
                    "defaultMessage": "Currency"
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'currency'
                  }
                }
              }
            },
            valueAmount: {
              [config]: {
                dataType: DATA_TYPE_FLOAT,
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    "id": "field.valuationcontrols_common.valueAmount.fullName",
                    "defaultMessage": "Amount value"
                  },
                  name: {
                    "id": "field.valuationcontrols_common.valueAmount.name",
                    "defaultMessage": "Value"
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            }
          }
        },
        valueDate: {
          [config]: {
            dataType: DATA_TYPE_DATE,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                "id": "field.valuationcontrols_common.valueDate.name",
                "defaultMessage": "Date"
              }
            }),
            view: {
              type: DateInput
            }
          }
        },
        valueRenewalDate: {
          [config]: {
            dataType: DATA_TYPE_DATE,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                "id": "field.valuationcontrols_common.valueRenewalDate.name",
                "defaultMessage": "Renewal date"
              }
            }),
            view: {
              type: DateInput
            }
          }
        },
        valueSource: {
          [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'
              }
            }
          }
        },
        valueType: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                "id": "field.valuationcontrols_common.valueType.name",
                "defaultMessage": "Type"
              }
            }),
            view: {
              type: OptionPickerInput,
              props: {
                source: 'valueTypes'
              }
            }
          }
        },
        valueNote: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                "id": "field.valuationcontrols_common.valueNote.name",
                "defaultMessage": "Note"
              }
            }),
            view: {
              type: TextInput,
              props: {
                multiline: true
              }
            }
          }
        }
      }
    })
  };
};

exports.default = _default;