import React, { useState } from 'react';
import { Button, ACCENT_TYPES } from '../button';
import { Modal } from '../modal';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export function ButtonSwitcher({
  showAdvancedScheduler,
  advancedSchedulerToggleButtonText,
  onUseAdvancedScheduler,
  simpleSchedulerModalTexts,
  simpleSchedulerToggleButtonText,
  onUseSimpleScheduler,
  isDisabled = false,
  switchToSimpleTriggerId = 'switch-to-simple-scheduler-container',
  switchToAdvancedTriggerId = 'switch-to-advanced-scheduler-container',
  icon
}) {
  const [showUseSimpleSchedulerAlert, setShowUseSimpleSchedulerAlert] = useState(false);
  if (showAdvancedScheduler) {
    return /*#__PURE__*/_jsxs("div", {
      className: "use-simple-scheduler-container",
      children: [/*#__PURE__*/_jsx(Button, {
        id: switchToSimpleTriggerId,
        className: "margin-top-2",
        accentType: ACCENT_TYPES.COMMAND,
        leftIcon: icon,
        onClick: () => {
          setShowUseSimpleSchedulerAlert(true);
        },
        testId: "use-simple-scheduler-button",
        isDisabled: isDisabled,
        children: simpleSchedulerToggleButtonText
      }), showUseSimpleSchedulerAlert && /*#__PURE__*/_jsx(Modal, {
        title: simpleSchedulerModalTexts.title,
        testId: "use-simple-scheduler-alert-modal",
        modalKey: "use-simple-scheduler-alert-modal",
        show: showUseSimpleSchedulerAlert,
        onConfirmModal: () => {
          onUseSimpleScheduler();
          setShowUseSimpleSchedulerAlert(false);
        },
        aria: {
          labelledby: switchToSimpleTriggerId
        },
        confirmButtonText: simpleSchedulerModalTexts.confirmButtonText,
        showDismissButton: true,
        dismissButtonText: simpleSchedulerModalTexts.dismissButtonText,
        onDismissModal: () => {
          setShowUseSimpleSchedulerAlert(false);
        },
        labelText: simpleSchedulerModalTexts.labelText,
        children: simpleSchedulerModalTexts.content
      })]
    });
  }
  return /*#__PURE__*/_jsx(Button, {
    id: switchToAdvancedTriggerId,
    className: "margin-top-2",
    accentType: ACCENT_TYPES.COMMAND,
    leftIcon: icon,
    onClick: onUseAdvancedScheduler,
    testId: "use-advanced-scheduler-button",
    isDisabled: isDisabled,
    children: advancedSchedulerToggleButtonText
  });
}