'use strict';

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

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

exports.default = pluginContext => {
  var _pluginContext$inputC = pluginContext.inputComponents;
  const AutocompleteInput = _pluginContext$inputC.AutocompleteInput,
        CompoundInput = _pluginContext$inputC.CompoundInput,
        HierarchyInput = _pluginContext$inputC.HierarchyInput,
        OptionPickerInput = _pluginContext$inputC.OptionPickerInput,
        TextInput = _pluginContext$inputC.TextInput,
        TermPickerInput = _pluginContext$inputC.TermPickerInput,
        CheckboxInput = _pluginContext$inputC.CheckboxInput,
        DateInput = _pluginContext$inputC.DateInput;
  const config = pluginContext.configHelpers.configKey;
  const DATA_TYPE_DATE = pluginContext.dataTypes.DATA_TYPE_DATE;
  const extensions = pluginContext.config.extensions;


  return {
    document: Object.assign({
      [config]: {
        view: {
          type: CompoundInput,
          props: {
            defaultChildSubpath: 'ns2:locations_common'
          }
        }
      },
      'rel:relations-common-list': {
        [config]: {
          service: {
            ns: 'http://collectionspace.org/services/relation'
          }
        },
        'relation-list-item': {
          [config]: {
            view: {
              type: HierarchyInput,
              props: {
                messages: (0, _reactIntl.defineMessages)({
                  parent: {
                    'id': 'hierarchyInput.location.parent',
                    'defaultMessage': 'Broader location'
                  },
                  children: {
                    'id': 'hierarchyInput.location.children',
                    'defaultMessage': 'Narrower locations'
                  },
                  siblings: {
                    'id': 'hierarchyInput.location.siblings',
                    'defaultMessage': 'Adjacent locations'
                  }
                })
              }
            }
          }
        }
      }
    }, extensions.core.fields, {
      'ns2:locations_common': {
        [config]: {
          service: {
            ns: 'http://collectionspace.org/services/location'
          }
        },
        csid: {
          [config]: {
            cloneable: false
          }
        },
        inAuthority: {
          [config]: {
            cloneable: false
          }
        },
        refName: {
          [config]: {
            cloneable: false
          }
        },
        shortIdentifier: {
          [config]: {
            cloneable: false
          }
        },
        locTermGroupList: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              required: {
                'id': 'field.locations_common.locTermGroupList.required',
                'defaultMessage': 'At least one term display name is required. Please enter a value.'
              }
            }),
            required: true,
            view: {
              type: CompoundInput
            }
          },
          locTermGroup: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.locations_common.locTermGroup.name',
                  'defaultMessage': 'Term'
                }
              }),
              repeating: true,
              view: {
                type: CompoundInput
              }
            },
            termDisplayName: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termDisplayName.name',
                    'defaultMessage': 'Display name'
                  }
                }),
                required: true,
                view: {
                  type: TextInput
                }
              }
            },
            termName: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termName.name',
                    'defaultMessage': 'Name'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termType: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termType.name',
                    'defaultMessage': 'Type'
                  }
                }),
                view: {
                  type: OptionPickerInput,
                  props: {
                    source: 'locationTermTypes'
                  }
                }
              }
            },
            termFlag: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.locations_common.termFlag.fullName',
                    'defaultMessage': 'Term flag'
                  },
                  name: {
                    'id': 'field.locations_common.termFlag.name',
                    'defaultMessage': 'Flag'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'locationtermflag'
                  }
                }
              }
            },
            termStatus: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termStatus.name',
                    'defaultMessage': 'Status'
                  }
                }),
                view: {
                  type: OptionPickerInput,
                  props: {
                    source: 'locationTermStatuses'
                  }
                }
              }
            },
            termQualifier: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termQualifier.name',
                    'defaultMessage': 'Qualifier'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termLanguage: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.locations_common.termLanguage.fullName',
                    'defaultMessage': 'Term language'
                  },
                  name: {
                    'id': 'field.locations_common.termLanguage.name',
                    'defaultMessage': 'Language'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'languages'
                  }
                }
              }
            },
            termPrefForLang: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termPrefForLang.name',
                    'defaultMessage': 'Preferred for lang'
                  }
                }),
                view: {
                  type: CheckboxInput
                }
              }
            },
            termSource: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termSource.name',
                    'defaultMessage': 'Name'
                  },
                  fullName: {
                    'id': 'field.locations_common.termSource.fullName',
                    'defaultMessage': 'Source name'
                  }
                }),
                view: {
                  type: AutocompleteInput,
                  props: {
                    source: 'citation/local,citation/shared,citation/worldcat'
                  }
                }
              }
            },
            termSourceDetail: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termSourceDetail.name',
                    'defaultMessage': 'Detail'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termSourceID: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termSourceID.name',
                    'defaultMessage': 'ID'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termSourceNote: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.termSourceNote.name',
                    'defaultMessage': 'Note'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            }
          }
        },
        accessNote: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.locations_common.accessNote.name',
                'defaultMessage': 'Access note'
              }
            }),
            searchView: {
              type: TextInput
            },
            view: {
              type: TextInput,
              props: {
                multiline: true
              }
            }
          }
        },
        address: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.locations_common.address.name',
                'defaultMessage': 'Address'
              }
            }),
            view: {
              type: TextInput
            }
          }
        },
        conditionGroupList: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          conditionGroup: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.persons_common.conditionGroup.name',
                  'defaultMessage': 'Condition note'
                }
              }),
              repeating: true,
              view: {
                type: CompoundInput,
                props: {
                  tabular: true
                }
              }
            },
            conditionNote: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.conditionNote.name',
                    'defaultMessage': 'Note'
                  },
                  fullName: {
                    'id': 'field.locations_common.conditionNote.fullName',
                    'defaultMessage': 'Condition note'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            conditionNoteDate: {
              [config]: {
                dataType: DATA_TYPE_DATE,
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.locations_common.conditionNoteDate.name',
                    'defaultMessage': 'Date'
                  },
                  fullName: {
                    'id': 'field.locations_common.conditionNoteDate.fullName',
                    'defaultMessage': 'Condition note date'
                  }
                }),
                view: {
                  type: DateInput
                }
              }
            }
          }
        },
        securityNote: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.locations_common.securityNote.name',
                'defaultMessage': 'Security note'
              }
            }),
            searchView: {
              type: TextInput
            },
            view: {
              type: TextInput,
              props: {
                multiline: true
              }
            }
          }
        },
        locationType: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.locations_common.locationType.name',
                'defaultMessage': 'Storage location type'
              }
            }),
            view: {
              type: TermPickerInput,
              props: {
                source: 'locationtype'
              }
            }
          }
        }
      }
    })
  };
};