import React, { useEffect, useState } from "react";
import { RicosTranslate, fetchEditorTranslations } from "./../../wix-rich-content-common/index.js";
function LocaleResourceProvider({
  locale,
  children,
  fallback
}) {
  const [currentLocaleResource, setLocaleResource] = useState(null);
  useEffect(() => {
    const handleLocaleResource = async () => {
      const localeResource = await fetchEditorTranslations(locale);
      if (localeResource) {
        setLocaleResource(localeResource);
      }
    };
    handleLocaleResource();
  }, []);
  if (!currentLocaleResource) {
    return fallback;
  }
  return /* @__PURE__ */ React.createElement(
    RicosTranslate,
    {
      locale: currentLocaleResource.locale,
      localeResource: currentLocaleResource.localeResource ?? {}
    },
    children(currentLocaleResource.locale)
  );
}
var locale_resource_provider_default = LocaleResourceProvider;
export {
  LocaleResourceProvider,
  locale_resource_provider_default as default
};
//# sourceMappingURL=locale-resource-provider.js.map
