'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,
        DateInput = _pluginContext$inputC.DateInput,
        HierarchyInput = _pluginContext$inputC.HierarchyInput,
        OptionPickerInput = _pluginContext$inputC.OptionPickerInput,
        TextInput = _pluginContext$inputC.TextInput,
        TermPickerInput = _pluginContext$inputC.TermPickerInput,
        CheckboxInput = _pluginContext$inputC.CheckboxInput,
        StructuredDateInput = _pluginContext$inputC.StructuredDateInput;
  const config = pluginContext.configHelpers.configKey;
  var _pluginContext$dataTy = pluginContext.dataTypes;
  const DATA_TYPE_BOOL = _pluginContext$dataTy.DATA_TYPE_BOOL,
        DATA_TYPE_STRUCTURED_DATE = _pluginContext$dataTy.DATA_TYPE_STRUCTURED_DATE;
  const extensions = pluginContext.config.extensions;


  return {
    document: Object.assign({
      [config]: {
        view: {
          type: CompoundInput,
          props: {
            defaultChildSubpath: 'ns2:works_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.work.parent',
                    'defaultMessage': 'Broader work'
                  },
                  children: {
                    'id': 'hierarchyInput.work.children',
                    'defaultMessage': 'Narrower works'
                  },
                  siblings: {
                    'id': 'hierarchyInput.work.siblings',
                    'defaultMessage': 'Adjacent works'
                  }
                })
              }
            }
          }
        }
      }
    }, extensions.core.fields, {
      'ns2:works_common': {
        [config]: {
          service: {
            ns: 'http://collectionspace.org/services/work'
          }
        },
        csid: {
          [config]: {
            cloneable: false
          }
        },
        inAuthority: {
          [config]: {
            cloneable: false
          }
        },
        refName: {
          [config]: {
            cloneable: false
          }
        },
        shortIdentifier: {
          [config]: {
            cloneable: false
          }
        },
        workTermGroupList: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              required: {
                'id': 'field.works_common.workTermGroupList.required',
                'defaultMessage': 'At least one term display name is required. Please enter a value.'
              }
            }),
            required: true,
            view: {
              type: CompoundInput
            }
          },
          workTermGroup: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.works_common.workTermGroup.name',
                  'defaultMessage': 'Term'
                }
              }),
              repeating: true,
              view: {
                type: CompoundInput
              }
            },
            termDisplayName: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.termDisplayName.name',
                    'defaultMessage': 'Display name'
                  }
                }),
                required: true,
                view: {
                  type: TextInput
                }
              }
            },
            termName: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.termName.name',
                    'defaultMessage': 'Name'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termType: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.termType.name',
                    'defaultMessage': 'Type'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termFlag: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.works_common.termFlag.fullName',
                    'defaultMessage': 'Term flag'
                  },
                  name: {
                    'id': 'field.works_common.termFlag.name',
                    'defaultMessage': 'Flag'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'worktermflag'
                  }
                }
              }
            },
            termStatus: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.termStatus.name',
                    'defaultMessage': 'Status'
                  }
                }),
                view: {
                  type: OptionPickerInput,
                  props: {
                    source: 'workTermStatuses'
                  }
                }
              }
            },
            termQualifier: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.termQualifier.name',
                    'defaultMessage': 'Qualifier'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termLanguage: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.works_common.termLanguage.fullName',
                    'defaultMessage': 'Term language'
                  },
                  name: {
                    'id': 'field.works_common.termLanguage.name',
                    'defaultMessage': 'Language'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'languages'
                  }
                }
              }
            },
            termPrefForLang: {
              [config]: {
                dataType: DATA_TYPE_BOOL,
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.termPrefForLang.name',
                    'defaultMessage': 'Preferred for lang'
                  }
                }),
                view: {
                  type: CheckboxInput
                }
              }
            },
            termSource: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.termSource.name',
                    'defaultMessage': 'Name'
                  },
                  fullName: {
                    'id': 'field.works_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.works_common.termSourceDetail.name',
                    'defaultMessage': 'Detail'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termSourceID: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.termSourceID.name',
                    'defaultMessage': 'ID'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termSourceNote: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.termSourceNote.name',
                    'defaultMessage': 'Note'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            }
          }
        },
        workType: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.works_common.workType.name',
                'defaultMessage': 'Work type'
              }
            }),
            view: {
              type: TermPickerInput,
              props: {
                source: 'worktype'
              }
            }
          }
        },
        workDateGroupList: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          workDateGroup: Object.assign({
            [config]: {
              dataType: DATA_TYPE_STRUCTURED_DATE,
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.works_common.workDateGroup.name',
                  'defaultMessage': 'Work date'
                }
              }),
              repeating: true,
              searchView: {
                type: DateInput
              },
              view: {
                type: StructuredDateInput
              }
            }
          }, extensions.structuredDate.fields)
        },
        workHistoryNote: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.works_common.workHistoryNote.name',
                'defaultMessage': 'History note'
              }
            }),
            view: {
              type: TextInput,
              props: {
                multiline: true
              }
            }
          }
        },
        creatorGroupList: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          creatorGroup: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.works_common.creatorGroup.name',
                  'defaultMessage': 'Creator'
                }
              }),
              repeating: true,
              view: {
                type: CompoundInput,
                props: {
                  tabular: true
                }
              }
            },
            creator: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.creator.name',
                    'defaultMessage': 'Name'
                  },
                  fullName: {
                    'id': 'field.works_common.creator.fullName',
                    'defaultMessage': 'Creator name'
                  }
                }),
                view: {
                  type: AutocompleteInput,
                  props: {
                    source: 'person/local,person/shared,organization/local,organization/shared'
                  }
                }
              }
            },
            creatorType: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.works_common.creatorType.fullName',
                    'defaultMessage': 'Creator type'
                  },
                  name: {
                    'id': 'field.works_common.creatorType.name',
                    'defaultMessage': 'Type'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'workcreatortype'
                  }
                }
              }
            }
          }
        },
        publisherGroupList: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          publisherGroup: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.works_common.publisherGroup.name',
                  'defaultMessage': 'Publisher'
                }
              }),
              repeating: true,
              view: {
                type: CompoundInput,
                props: {
                  tabular: true
                }
              }
            },
            publisher: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.publisher.name',
                    'defaultMessage': 'Name'
                  },
                  fullName: {
                    'id': 'field.works_common.publisher.fullName',
                    'defaultMessage': 'Publisher name'
                  }
                }),
                view: {
                  type: AutocompleteInput,
                  props: {
                    source: 'person/local,person/shared,organization/local,organization/shared'
                  }
                }
              }
            },
            publisherType: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.works_common.publisherType.fullName',
                    'defaultMessage': 'Publisher type'
                  },
                  name: {
                    'id': 'field.works_common.publisherType.name',
                    'defaultMessage': 'Type'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'workpublishertype'
                  }
                }
              }
            }
          }
        },
        addrGroupList: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          addrGroup: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.works_common.addrGroup.name',
                  'defaultMessage': 'Address'
                }
              }),
              repeating: true,
              view: {
                type: CompoundInput
              }
            },
            addressType: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.works_common.addressType.fullName',
                    'defaultMessage': 'Address type'
                  },
                  name: {
                    'id': 'field.works_common.addressType.name',
                    'defaultMessage': 'Type'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'addresstype'
                  }
                }
              }
            },
            addressPlace1: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.addressPlace1.name',
                    'defaultMessage': 'Line 1'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            addressPlace2: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.addressPlace2.name',
                    'defaultMessage': 'Line 2'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            addressMunicipality: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.addressMunicipality.name',
                    'defaultMessage': 'Municipality'
                  }
                }),
                view: {
                  type: AutocompleteInput,
                  props: {
                    source: 'place/local,place/tgn'
                  }
                }
              }
            },
            addressStateOrProvince: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.addressStateOrProvince.name',
                    'defaultMessage': 'State/Province'
                  }
                }),
                view: {
                  type: AutocompleteInput,
                  props: {
                    source: 'place/local,place/tgn'
                  }
                }
              }
            },
            addressPostCode: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.addressPostCode.name',
                    'defaultMessage': 'Postal code'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            addressCountry: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.works_common.addressCountry.name',
                    'defaultMessage': 'Country'
                  }
                }),
                view: {
                  type: AutocompleteInput,
                  props: {
                    source: 'place/local,place/tgn'
                  }
                }
              }
            }
          }
        }
      }
    })
  };
};