{"version":3,"file":"helpers.mjs","sources":["../../lib/utils/helpers.ts"],"sourcesContent":["// @ts-nocheck\n/* eslint-disable no-restricted-syntax,guard-for-in,no-param-reassign,no-lonely-if */\n/**\n * @created 11.05.2017\n * @description Contains helper functions for general purposes needed in the Application.\n */\n\n/* eslint-disable no-undef */\n/* eslint-disable no-nested-ternary */\nimport {\n  has,\n  isString,\n  isObject,\n  isNil,\n  isArray,\n} from 'lodash';\nimport { getName, registerLocale } from 'i18n-iso-countries';\n\n// Import all images.\n// eager loading of images is needed for now for better compatibility.\n// See https://vitejs.dev/guide/features.html#glob-import\nconst imageModules = import.meta.globEager('../assets/img/**/*.png');\nconst localeModules = import.meta.globEager('../config/langs/{bg,cs,da,de,el,es,et,fr,hr,hu,it,lt,lv,nl,nb,pl,pt,ro,sk,sl,fi,sv}.json');\nconst RELATIVE_PATH_TO_IMAGES = '../assets/img';\n\n// ga and mt missing, nb for no\nconst languageList = ['bg', 'cs', 'da', 'de', 'el', 'es', 'et', 'fr', 'hr', 'hu', 'it', 'lt', 'lv', 'nl', 'nb', 'pl', 'pt', 'ro', 'sk', 'sl', 'fi', 'sv'];\nlanguageList.forEach( (lang) => {\n  const locale = localeModules[`../config/langs/${lang}.json`];\n  if (locale) {\n    registerLocale(locale.default);\n  }\n});\n\n\n/**\n * @description         Returns an array that contains unique values\n *                      of the given properties in the given array.\n * @param { String }    prop   - The key of {array} which values will be unique.\n * @param { [Object] }  array - The array to take keys from.\n * @returns { [*] }     A new Array containing unique values of the {arrays} {key} property\n */\nfunction unique(prop, array) {\n  // Filter elements in {array} that do not have a {prop} key.\n  return [...new Set(array.filter(\n    // Remove duplicates by creating a Set and remove items where {prop} has no value.\n    item => Object.prototype.hasOwnProperty.call(item, prop) && !!item[prop],\n  )\n    // Create a new array containing the {prop} values of each given item.\n    .map(item => item[prop]))];\n}\n\n\n/**\n * @description         Abstract function that returns an image from /assets/img\n * @param { String }    image - The path to the image from /assets/img without fileending e.g. \"/flags/eu\"\n * @param { String }    defaultFallbackImage - The path to the default fallback image from /assets/img without fileending e.g. \"/flags/eu\"\n * @returns { String }  An image, represented by its absolute path.\n */\nfunction getImg(image = '', defaultFallbackImage = '') {\n  const maybeImageFrontSlash = image.startsWith('/') ? image : `/${image}`;\n  const maybeFallbackImageFrontSlash = defaultFallbackImage.startsWith('/') ? defaultFallbackImage : `/${defaultFallbackImage}`;\n  let img;\n\n  try {\n    img = imageModules[`${RELATIVE_PATH_TO_IMAGES}${maybeImageFrontSlash}.png`];\n    if (!img) {\n      throw new Error('Image not found');\n    }\n  } catch (err) {\n    if (defaultFallbackImage) img = imageModules[`${RELATIVE_PATH_TO_IMAGES}${maybeFallbackImageFrontSlash}.png`];\n    else img = imageModules[`${RELATIVE_PATH_TO_IMAGES}/img-not-available.png`];\n  }\n\n  return img.default;\n}\n\n\n\n/**\n * @description         Returns an image of a flag.\n * @param { String }    countryId - The ID (example: 'en', 'de', 'fr') of a country to get the flag from.\n * @returns { String }  An image, represented by its absolute path.\n */\nfunction getCountryFlagImg(countryId) {\n  let img;\n  try {\n    img = imageModules[`${RELATIVE_PATH_TO_IMAGES}/flags/${countryId.toLowerCase()}.png`];\n  } catch (err) {\n    img = imageModules[`${RELATIVE_PATH_TO_IMAGES}/flags/eu.png`];\n  }\n  return img.default;\n}\n\n\nfunction getRepresentativeLocaleOf(prop, userLocale, fallbacks) {\n  if (!prop || isNil(prop) || (!isObject(prop) && !isString(prop))) return undefined;\n  // Check if prop is only a string without translations\n  if (isString(prop)) return prop;\n  // Use language setting of user\n  if (has(prop, userLocale)) return userLocale;\n  // Iterate over given fallback languages\n  if (fallbacks && isArray(fallbacks)) {\n    const foundLang = fallbacks.find(lang => lang\n      && isString(lang)\n      && has(prop, lang.toLowerCase()));\n    if (foundLang) return foundLang;\n  }\n  // Use the first language in the given property if none of the languages is present\n  const key = Object.keys(prop)[0];\n  if (key) return key;\n  // Use default text if prop does not have any items\n  return undefined;\n}\n\n/**\n * @description         Checks if a translation for the given prop parameter is available and returns it in the following priority order:\n *                      1. User set locale\n *                      2. Given fallback languages\n *                      3. Any available language\n * @param { Object }    prop - The object that should contain the translations\n * @param { String }    userLocale - The currently set locale.\n * @param { [String] }  fallbacks - The fallback languages to check for, when given locale is not available in given prop\n * @returns { String }  A translated text.\n */\nfunction getTranslationFor(prop, userLocale, fallbacks) {\n  const locale = getRepresentativeLocaleOf(prop, userLocale, fallbacks);\n  return locale\n    ? prop[locale]\n    : undefined;\n}\n\n\n/**\n * @description Returns the translation for a facet item\n * @param  { String } fieldId\n * @param { String } facetId\n * @param { String } userLocale\n * @param { String } fallback\n * @returns { String } The translated facet item, if available\n */\nfunction getFacetTranslation(fieldId, facetId, userLocale, fallback) {\n  if (fieldId === 'country') {\n    const locale = userLocale === 'no' ? 'nb' : userLocale;\n    const name = getName(facetId, locale);\n    // Translation missing because this.$t('message.catalogFacets.euInstitutions') is not working here\n    // return isNil(name)\n    //   ? (fallback === 'EU institutions' ? this.$t('message.catalogFacets.euInstitutions') : fallback)\n    //   : name;\n    return isNil(name)\n      ? fallback\n      : name;\n  }\n  if (isObject(fallback)) {\n    return has(fallback, userLocale)\n      ? fallback[userLocale]\n      : has(fallback, 'en')\n        ? fallback.en\n        : Object.keys(fallback).length > 0\n          ? fallback[0]\n          : 'No title available';\n  }\n  return isNil(fallback)\n    ? 'No title available'\n    : (isString(fallback)\n      ? fallback\n      : fallback.toString());\n}\n\n\n/**\n * Truncates a String to a maximum character count of maxChars\n * @param text\n * @param maxChars\n * @param noAppend\n */\nfunction truncate(text, maxChars, noAppend) {\n  if (!text) return '';\n  const trunc = text.substring(0, maxChars);\n  if (noAppend || text.length <= maxChars) return trunc;\n  return `${trunc}...`;\n}\n\n/**\n * normalizing the dataset id\n * @param str string to be normalized\n */\nfunction normalize(str) {\n  const normalized = str.normalize('NFKD');\n  return normalized.replace('%', '').replace('\\\\W', '-').replace('-+', '-').toLowerCase();\n}\n\n/**\n * remove mailto or tel\n * @param str string\n */\nfunction removeMailtoOrTel(str) {\n  return str.replace(/^(mailto|tel):/, '');\n}\n\nfunction replaceHttp(str) {\n  try {\n    const url = new URL(str);\n    if (url.protocol === 'http:') {\n      url.protocol = 'https:';\n    }\n    return url.href;\n  } catch (ex) {\n    // Return original string if it is not a valid URL\n    return str;\n  }\n}\n\n/**\n * Returns a function that takes an object and returns a modified object\n * where for each dstProp in dstProps holds: object.dstProp === object.srcProp\n *\n * This function aims to help maintain stability against DCAT-AP schema changes\n * by providing alternative keys names for access\n *\n * @example\n * const foo = { foo: 'hello world' };\n * const mirrorFooAsBar = mirrorPropertyFn('foo', 'bar');\n * const mirrored = mirrorFooAsBar(foo);\n * log(mirrored.foo) // -> 'hello world'\n * log(mirrored.bar) // -> 'hello world'\n * @param {String} srcProp\n * @param {String | Array<String>} dstProps\n * @returns {Function}\n */\nfunction mirrorPropertyFn(srcProp, dstProps) {\n  const dstPropsArray = isArray(dstProps)\n    ? dstProps\n    : [dstProps];\n\n  // Return function that returns a proxy that does the mirroring when\n  // accessing dstProps\n  return obj => new Proxy({\n    // Add preliminary dstProps to object so lodash _.has won't return false\n    ...obj,\n    ...dstPropsArray.reduce((acc, prop) => {\n      // eslint-disable-next-line no-param-reassign\n      acc[prop] = obj[srcProp];\n      return acc;\n    }, {}),\n  }, {\n    get(target, prop, receiver) {\n      // If accessing dstProp, return srcProp value\n      const foundTargetProp = dstPropsArray.includes(srcProp);\n      const maybeRedirectedProp = foundTargetProp\n        ? srcProp\n        : prop;\n      return Reflect.get(target, maybeRedirectedProp, receiver);\n    },\n  });\n}\n\n\n/**\n * @description Function for determining of given data is of type object\n * @param {*} data\n * @returns Boolean determining, if data is object\n */\nfunction matchesObjectStructure(data) {\n  const dataKeys = Object.keys(data);\n  const firstValue = data[dataKeys[0]];\n\n  if (typeof firstValue === 'string' || typeof firstValue === 'number') {\n    return true;\n  }\n  return false;\n}\n\n/**\n* @description Function to search for all properties in inputconfiguration which provide a 'source'-property.\n* Each name provided by a 'source'-property is saved inside the propertyNamesArray and returned as an array of property-names.\n* @param {Array} inputConfigArray Array of inputconfiguration containing information about components to render.\n* @param {Array} propertyNamesArray Array of names retrieved from components with a 'source'-property.\n* @returns {Array} Array with all names retireved (popertyNamesArray)\n*/\nfunction findPropertiesWithSources(inputConfigArray, propertyNamesArray) {\n  for (const index in inputConfigArray) {\n    // only subcomponents without a 'children'-property contain a 'source'-property\n    // if there is a 'children'-property the current component isn't a subcomponent so\n    // the function needs be called again on this component to get to the subcomponent\n    if (Object.keys(inputConfigArray[index]).includes('children')) {\n      findPropertiesWithSources(inputConfigArray[index].children, propertyNamesArray);\n    } else if (inputConfigArray[index].type === 'conditional-input') {\n      const conditionalInputKeys = Object.keys(inputConfigArray[index].data);\n      for (const inputKeyIndex in conditionalInputKeys) {\n        findPropertiesWithSources(inputConfigArray[index].data[conditionalInputKeys[inputKeyIndex]], propertyNamesArray);\n      }\n    } else {\n      // not all subcomponents contain a 'source'-property\n      if (Object.keys(inputConfigArray[index]).includes('source')) {\n        // the 'source'-property provides a name which links to further information in the generalconfig-file\n        if (!propertyNamesArray.includes(inputConfigArray[index].source.name)) {\n          propertyNamesArray.push(inputConfigArray[index].source.name);\n        }\n      }\n    }\n  }\n\n  return propertyNamesArray;\n}\n\n/**\n*\n* @param {*} dataset\n* @param {*} properties\n* @param {*} translatableProperties\n*/\nfunction setTranslation(dataset, properties, translatableProperties, languageInformation) {\n  for (const propertyIndex in properties) {\n    const propertyName = properties[propertyIndex];\n    const propertyValue = dataset[propertyName];\n\n    if (translatableProperties.includes(propertyName)) {\n      const translationSelectoren = Object.keys(languageInformation.translation[languageInformation.locale].message.dataupload[propertyName]);\n\n      if (propertyValue !== '') {\n        if (translationSelectoren.includes(propertyValue)) {\n          dataset[propertyName] = languageInformation.translation[languageInformation.locale].message.dataupload[propertyName][propertyValue];\n        }\n      }\n    }\n  }\n}\n\n/**\n* @description Appends current locale to an url\n* @param {String} url url\n*/\nfunction appendCurrentLocaleToURL(url) {\n  try {\n    const urlHost = new URL(url).host;\n    const baseUrlHost = new URL(this.$env.api.baseUrl).host;\n    const isOurHostname = urlHost === baseUrlHost;\n    if (isOurHostname) {\n      return `${url}?locale=${this.$route.query.locale}`;\n    }\n    return url;\n  } catch {\n    // when there is no hostname then it should link to our website\n    return `${url}?locale=${this.$route.query.locale}`;\n  }\n}\n\n/**\n* @description Add preceding zero for numbers < 100 (if not already existing)\n* @param {String} value value\n*/\nfunction addPrecedingZero(value) {\n  return `${parseInt(value, 10) < 10 ? 0 : ''}${parseInt(value, 10)}`;\n}\n\n/**\n* @description Formatting temporalResolution property into human-readable format\n* @param {String} datetime datetime in temporalResolution format\n*/\nfunction formatDatetime(datetime) {\n  let date = datetime.split('T')[0].substr(1,);\n\n  const year = date.split('Y')[0];\n  date = date.split('Y')[1];\n\n  const month = addPrecedingZero(date.split('M')[0]);\n  date = date.split('M')[1];\n\n  const day = addPrecedingZero(date.split('D')[0]);\n\n  let time = datetime.split('T')[1];\n\n  const hour = addPrecedingZero(time.split('H')[0]);\n  time = time.split('H')[1];\n\n  const minute = addPrecedingZero(time.split('M')[0]);\n  time = time.split('M')[1];\n\n  const second = addPrecedingZero(time.split('S')[0]);\n\n  return `${hour}:${minute}:${second} - ${day}.${month}.${year}`;\n}\n\n/**\n * @description Creates a navigation guard that adds a locale to the query if it is not present.\n */\nfunction createStickyLocale(fallbackLocale: string = 'en') {\n  return function stickyLocale(to: any, from: any, next: Function) {\n      const toLocale = to.query.locale;\n      const fromLocale = from.query.locale;\n\n      const newLocale = toLocale ?? fromLocale ?? fallbackLocale;\n\n      newLocale !== toLocale \n          ? next({ ...to, query: { ...to.query, locale: newLocale } })\n          : next();\n  };\n}\n\n// Export all functions as default export.\nexport {\n  unique,\n  getImg,\n  getCountryFlagImg,\n  getFacetTranslation,\n  getRepresentativeLocaleOf,\n  getTranslationFor,\n  truncate,\n  normalize,\n  removeMailtoOrTel,\n  replaceHttp,\n  mirrorPropertyFn,\n  matchesObjectStructure,\n  findPropertiesWithSources,\n  setTranslation,\n  appendCurrentLocaleToURL,\n  addPrecedingZero,\n  formatDatetime,\n  createStickyLocale,\n};\n"],"names":["imageModules","localeModules","RELATIVE_PATH_TO_IMAGES","languageList","lang","locale","registerLocale","unique","prop","array","item","getImg","image","defaultFallbackImage","maybeImageFrontSlash","maybeFallbackImageFrontSlash","img","getCountryFlagImg","countryId","getRepresentativeLocaleOf","userLocale","fallbacks","isNil","isObject","isString","has","isArray","foundLang","key","getTranslationFor","getFacetTranslation","fieldId","facetId","fallback","name","getName","truncate","text","maxChars","noAppend","trunc","normalize","str","removeMailtoOrTel","replaceHttp","url","mirrorPropertyFn","srcProp","dstProps","dstPropsArray","obj","acc","target","receiver","maybeRedirectedProp","matchesObjectStructure","data","dataKeys","firstValue","findPropertiesWithSources","inputConfigArray","propertyNamesArray","index","conditionalInputKeys","inputKeyIndex","setTranslation","dataset","properties","translatableProperties","languageInformation","propertyIndex","propertyName","propertyValue","translationSelectoren","appendCurrentLocaleToURL","urlHost","baseUrlHost","addPrecedingZero","value","formatDatetime","datetime","date","year","month","day","time","hour","minute","second","createStickyLocale","fallbackLocale","to","from","next","toLocale","fromLocale","newLocale"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAMA,kgDACAC,ktBACAC,IAA0B,iBAG1BC,KAAe,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,IAAI;AACxJA,GAAa,QAAS,CAACC,MAAS;AAC9B,QAAMC,IAASJ,GAAc,mBAAmBG,CAAI,OAAO;AAC3D,EAAIC,KACFC,GAAeD,EAAO,OAAO;AAEjC,CAAC;AAUD,SAASE,GAAOC,GAAMC,GAAO;AAE3B,SAAO,CAAC,GAAG,IAAI,IAAIA,EAAM;AAAA;AAAA,IAEvB,CAAAC,MAAQ,OAA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