"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 {
    AutocompleteInput,
    CompoundInput,
    HierarchyInput,
    OptionPickerInput,
    TextInput,
    TermPickerInput,
    CheckboxInput,
    StructuredDateInput
  } = configContext.inputComponents;
  const {
    configKey: config
  } = configContext.configHelpers;
  const {
    DATA_TYPE_BOOL,
    DATA_TYPE_STRUCTURED_DATE
  } = configContext.dataTypes;
  const {
    extensions
  } = configContext.config;
  return {
    document: _objectSpread({
      [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': _objectSpread({
        [config]: {
          service: {
            ns: 'http://collectionspace.org/services/work'
          }
        },
        csid: {
          [config]: {
            cloneable: false,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                "id": "field.works_common.csid.name",
                "defaultMessage": "System CSID"
              }
            }),
            view: {
              type: TextInput
            }
          }
        },
        inAuthority: {
          [config]: {
            cloneable: false,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                "id": "field.works_common.inAuthority.name",
                "defaultMessage": "System authority CSID"
              }
            }),
            view: {
              type: TextInput
            }
          }
        },
        refName: {
          [config]: {
            cloneable: false,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                "id": "field.works_common.refName.name",
                "defaultMessage": "System ref name"
              }
            }),
            view: {
              type: TextInput
            }
          }
        },
        shortIdentifier: {
          [config]: {
            cloneable: false,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                "id": "field.works_common.shortIdentifier.name",
                "defaultMessage": "System short ID"
              }
            }),
            view: {
              type: TextInput
            }
          }
        },
        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)({
                  fullName: {
                    "id": "field.works_common.termDisplayName.fullName",
                    "defaultMessage": "Term display name"
                  },
                  name: {
                    "id": "field.works_common.termDisplayName.name",
                    "defaultMessage": "Display name"
                  }
                }),
                required: true,
                view: {
                  type: TextInput
                }
              }
            },
            termName: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    "id": "field.works_common.termName.fullName",
                    "defaultMessage": "Term name"
                  },
                  name: {
                    "id": "field.works_common.termName.name",
                    "defaultMessage": "Name"
                  }
                }),
                view: {
                  type: TextInput,
                  props: {
                    // Suppress Chrome autofill
                    autoComplete: 'cspace-name'
                  }
                }
              }
            },
            termType: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    "id": "field.works_common.termType.fullName",
                    "defaultMessage": "Term type"
                  },
                  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)({
                  fullName: {
                    "id": "field.works_common.termStatus.fullName",
                    "defaultMessage": "Term status"
                  },
                  name: {
                    "id": "field.works_common.termStatus.name",
                    "defaultMessage": "Status"
                  }
                }),
                view: {
                  type: OptionPickerInput,
                  props: {
                    source: 'workTermStatuses'
                  }
                }
              }
            },
            termQualifier: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    "id": "field.works_common.termQualifier.fullName",
                    "defaultMessage": "Term qualifier"
                  },
                  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)({
                  fullName: {
                    "id": "field.works_common.termPrefForLang.fullName",
                    "defaultMessage": "Term preferred for lang"
                  },
                  name: {
                    "id": "field.works_common.termPrefForLang.name",
                    "defaultMessage": "Preferred for lang"
                  }
                }),
                view: {
                  type: CheckboxInput
                }
              }
            },
            termSource: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    "id": "field.works_common.termSource.fullName",
                    "defaultMessage": "Term source name"
                  },
                  groupName: {
                    "id": "field.works_common.termSource.groupName",
                    "defaultMessage": "Source name"
                  },
                  name: {
                    "id": "field.works_common.termSource.name",
                    "defaultMessage": "Name"
                  }
                }),
                view: {
                  type: AutocompleteInput,
                  props: {
                    source: 'citation/local,citation/shared,citation/worldcat'
                  }
                }
              }
            },
            termSourceDetail: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    "id": "field.works_common.termSourceDetail.fullName",
                    "defaultMessage": "Term source detail"
                  },
                  groupName: {
                    "id": "field.works_common.termSourceDetail.groupName",
                    "defaultMessage": "Source detail"
                  },
                  name: {
                    "id": "field.works_common.termSourceDetail.name",
                    "defaultMessage": "Detail"
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termSourceID: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    "id": "field.works_common.termSourceID.fullName",
                    "defaultMessage": "Term source ID"
                  },
                  groupName: {
                    "id": "field.works_common.termSourceID.groupName",
                    "defaultMessage": "Source ID"
                  },
                  name: {
                    "id": "field.works_common.termSourceID.name",
                    "defaultMessage": "ID"
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            },
            termSourceNote: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    "id": "field.works_common.termSourceNote.fullName",
                    "defaultMessage": "Term source note"
                  },
                  groupName: {
                    "id": "field.works_common.termSourceNote.groupName",
                    "defaultMessage": "Source note"
                  },
                  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: _objectSpread({
            [config]: {
              dataType: DATA_TYPE_STRUCTURED_DATE,
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  "id": "field.works_common.workDateGroup.name",
                  "defaultMessage": "Work date"
                }
              }),
              repeating: true,
              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)({
                  fullName: {
                    "id": "field.works_common.creator.fullName",
                    "defaultMessage": "Creator name"
                  },
                  name: {
                    "id": "field.works_common.creator.name",
                    "defaultMessage": "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)({
                  fullName: {
                    "id": "field.works_common.publisher.fullName",
                    "defaultMessage": "Publisher name"
                  },
                  name: {
                    "id": "field.works_common.publisher.name",
                    "defaultMessage": "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'
                  }
                }
              }
            }
          }
        }
      }, extensions.address.fields)
    })
  };
};

exports.default = _default;