common/helpers/wikimedia.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.buildWikipediaUrl = buildWikipediaUrl;
exports.getWikidataId = getWikidataId;
require("core-js/modules/es.array.find.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/web.dom-collections.iterator.js");
require("core-js/modules/web.url.js");
require("core-js/modules/web.url-search-params.js");
require("core-js/modules/es.regexp.exec.js");
require("core-js/modules/es.string.replace.js");
require("core-js/modules/esnext.string.replace-all.js");
/*
 * Copyright (C) 2023  David Kellner
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/** Page object with the extract property from the Wikipedia API. */

/** Wikipedia extract which includes information about the Wikipedia project where it comes from. */

var wikidataIdentifierTypeIds = {
  Author: 18,
  Edition: 4,
  EditionGroup: 19,
  Publisher: 20,
  Series: 30,
  Work: 21
};
function getWikidataId(entity) {
  var _entity$identifierSet, _identifiers$find;
  var identifiers = (_entity$identifierSet = entity.identifierSet) === null || _entity$identifierSet === void 0 ? void 0 : _entity$identifierSet.identifiers;
  var wikidataTypeId = wikidataIdentifierTypeIds[entity.type];
  return identifiers === null || identifiers === void 0 ? void 0 : (_identifiers$find = identifiers.find(function (identifier) {
    return identifier.typeId === wikidataTypeId;
  })) === null || _identifiers$find === void 0 ? void 0 : _identifiers$find.value;
}
function buildWikipediaUrl(article) {
  return new URL(article.title.replaceAll(' ', '_'), "https://".concat(article.language, ".wikipedia.org/wiki/"));
}
//# sourceMappingURL=wikimedia.js.map