// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

import { useTranslate } from '../LocaleProvider';
import { jsx as _jsx } from "react/jsx-runtime";
/**
 * `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 = 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__*/_jsx(Tag, {
    ...tagProps
  });
};
export default Translate;