import { extractEntity, isEntityPresent } from '@atlaskit/link-extractors';
/**
 * Return link summary
 */
export var extractSummary = function extractSummary(jsonLd) {
  if (typeof (jsonLd === null || jsonLd === void 0 ? void 0 : jsonLd.summary) === 'string') {
    var summary = jsonLd.summary.trim();
    return Boolean(summary) ? summary : undefined;
  }
};

/**
 * Return link summary
 */
export var extractSmartLinkSummary = function extractSmartLinkSummary(response) {
  if (isEntityPresent(response)) {
    var _extractEntity;
    return (_extractEntity = extractEntity(response)) === null || _extractEntity === void 0 ? void 0 : _extractEntity.description;
  }
  return (response === null || response === void 0 ? void 0 : response.data) && extractSummary(response.data);
};