import './regexp-exec-abstract-04d119fc.js';
import './es.string.split-cd1f3afc.js';
import './es.object.to-string-5a59fbfc.js';
import { _ as _export } from './export-ecf4b1cb.js';
import { a as arrayIteration } from './array-iteration-dec5536e.js';
import { a as addToUnscopables } from './es.array.includes-1f433385.js';
import './es.object.keys-6369b884.js';

var $find = arrayIteration.find;


var FIND = 'find';
var SKIPS_HOLES = true;

// Shouldn't skip holes
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });

// `Array.prototype.find` method
// https://tc39.es/ecma262/#sec-array.prototype.find
_export({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  find: function find(callbackfn /* , that = undefined */) {
    return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  }
});

// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
addToUnscopables(FIND);

var i18n = {
  computed: {
    /**
     * check if i18n plugin is available
     * @returns {boolean}
     */
    hasI18n: function hasI18n() {
      return Boolean(this.$i18n);
    }
  },
  methods: {
    /**
     * get the i18n term from json files present in your project - this works exactly like
     * vue-i18n except that the count variable can not be skipped if you want to use
     * named formatting
     *
     * @param {string} key - your locale file key
     * @param {number} count - your count number for pluralization
     * @param {object} variables - your object for named formatting - object property needs
     *  to be named like the localization file variable
     *  (https://kazupon.github.io/vue-i18n/guide/formatting.html)
     * @returns {string}
     */
    getI18nTerm: function getI18nTerm(key) {
      var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
      var variables = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

      if (this.hasI18n && this.$te(key)) {
        if (count >= 0) {
          return this.$tc(key, count, variables);
        }

        return this.$t(key, variables);
      }

      var termPath = key.split('.');
      return termPath.pop() || key;
    },

    /**
     * function to provide an object with translations for all available languages
     * @param {string} key - the locale file key
     * @param {string[]} locales - an array of available locales
     * @returns {Object}
     */
    setLangLabels: function setLangLabels(key, locales) {
      var _this = this;

      return locales.reduce(function (prev, curr) {
        _this.$set(prev, curr, _this.$i18n ? _this.$t(key, curr) : key.split('.').pop());

        return prev;
      }, {});
    },

    /**
     * function to
     * a) check if provided value is a language object and if yes
     * b) get the correct label from an object with language (ISO 639-1) as property
     *    (e.g. { de: 'yyy', en: 'xxx' })
     * @param {string|Object} value - the string or object to be processed
     * @param {boolean} useAny - specify if a label in a different language should be used
     *  if the currently set language has no result
     * @returns {Object|string}
     */
    getLangLabel: function getLangLabel(value) {
      var useAny = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      var language = this.hasI18n ? this.language || this.$i18n.locale : this.language;
      if (typeof value === 'string') return value;

      if (value && language && value[language]) {
        return value[language];
      }

      if (value && language && useAny) {
        var availableLang = Object.keys(value).find(function (key) {
          return !!value[key];
        }); // return the first one that has content

        return value[availableLang] || value[language] || '';
      }

      return value;
    }
  }
};

export { i18n as i };
