"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _LocaleProvider = require("../LocaleProvider");
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

/**
 * `Translate` component.
 * @since 0.0.42
 */
const Translate = _ref => {
  let {
    component,
    content,
    children,
    params,
    unsafe,
    fallback,
    namespace,
    translators,
    ...props
  } = _ref;
  const Tag = component || 'span';
  const translate = (0, _LocaleProvider.useTranslate)(namespace);
  const key = content || children || '';
  const translator = translators && translators[key];
  if (translator) {
    if (typeof translator === 'function') {
      return translator(params);
    }
    return translator;
  }
  const message = translate(key, params, fallback);
  const tagProps = {
    ...props
  };
  if (unsafe) {
    tagProps.dangerouslySetInnerHTML = {
      __html: message
    };
  } else {
    tagProps.children = message;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Tag, {
    ...tagProps
  });
};
var _default = exports.default = Translate;