import { useContext } from "react";
import { firstRight } from "./../../ricos-content/index.js";
import { RicosContext } from "./../../ricos-context/index.js";
import { getToolbarSettings, useToolbarSettings } from "./../../ricos-context/toolbar-context.js";
import { ToolbarType } from "./../../ricos-types/index.js";
import { unreachable } from "./../../_shared/uncreachable.js";
import { isiOS } from "./../../editor-common/index.js";
const useIsToolbarEmpty = (toolbarType) => {
  const { isMobile } = useContext(RicosContext);
  const { toolbarSettings, ...settings } = useToolbarSettings((state) => ({
    toolbarSettings: getToolbarSettings(toolbarType)(state),
    ...state
  }));
  const baseShouldCreate = getShouldCreate(isMobile, toolbarSettings?.shouldCreate);
  let isVisible;
  switch (toolbarType) {
    case ToolbarType.STATIC:
      isVisible = !!settings?.useStaticTextToolbar && baseShouldCreate;
      break;
    case ToolbarType.PLUGIN:
    case ToolbarType.SIDE:
      isVisible = baseShouldCreate;
      break;
    case ToolbarType.MOBILE:
      isVisible = isMobile && baseShouldCreate;
      break;
    case ToolbarType.INLINE:
      isVisible = !isMobile && !settings?.useStaticTextToolbar && baseShouldCreate;
      break;
    case ToolbarType.FOOTER:
      isVisible = !isMobile && baseShouldCreate;
      break;
    case ToolbarType.QUICK_ACTIONS:
    case ToolbarType.FORMATTING:
    case ToolbarType.INSERT_PLUGIN:
    case ToolbarType.TEXT:
    case ToolbarType.SHORTCUT:
    case ToolbarType.LINK:
    case ToolbarType.EXTERNAL:
    case ToolbarType.PLUGIN_MENU:
    case ToolbarType.EMPTY:
      isVisible = false;
      break;
    default:
      unreachable(toolbarType);
      isVisible = false;
      break;
  }
  return !isVisible;
};
const getShouldCreate = (isMobile, shouldCreateFn) => {
  const config = shouldCreateFn?.() || { desktop: true, mobile: { ios: true, android: true } };
  const shouldCreate = true;
  return firstRight(shouldCreate, true, [
    [() => !isMobile, () => config.desktop],
    [() => isMobile && isiOS(), () => config.mobile?.ios],
    [() => isMobile && !isiOS(), () => config.mobile?.android]
  ]) ?? true;
};
export {
  useIsToolbarEmpty
};
//# sourceMappingURL=use-is-toolbar-empty.js.map
