var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/PisellProcedure/PisellProcedure.tsx
var PisellProcedure_exports = {};
__export(PisellProcedure_exports, {
  default: () => PisellProcedure_default
});
module.exports = __toCommonJS(PisellProcedure_exports);
var import_react = __toESM(require("react"));
var import_pisellLayout = __toESM(require("../pisellLayout"));
var import_components = require("./components");
var import_hooks = require("./hooks");
var import_utils = require("./utils");
var import_useMobile = require("../../hooks/useMobile");
var import_PisellProcedure = require("./PisellProcedure.less");
var PisellProcedure = (0, import_react.forwardRef)(
  (props, ref) => {
    const {
      // 通用属性
      className,
      style,
      mode = "page",
      showHeader = true,
      showSidebar = true,
      showFooter = true,
      // 步骤控制
      defaultCurrent = 0,
      onStepsChange,
      // 区域配置
      headerProps,
      bodyProps,
      footerProps,
      // 事件回调
      onClose,
      onPrev,
      onNext,
      onFirstStepBack,
      onBackConfirm,
      onCloseConfirm,
      // 低代码属性
      __designMode,
      __id,
      ...other
    } = props;
    const isMobileDetected = (0, import_useMobile.useMobile)(744);
    const isMobile = mode === "modal" ? false : isMobileDetected;
    const { currentStep, goPrev, goNext, goToStep } = (0, import_hooks.useStepManager)({
      stepsProps: headerProps == null ? void 0 : headerProps.stepsProps,
      defaultCurrent,
      onPrev,
      onNext,
      onStepsChange
    });
    const [summaryModalOpen, setSummaryModalOpen] = (0, import_react.useState)(false);
    const openSummaryModal = (0, import_react.useCallback)(() => setSummaryModalOpen(true), []);
    const closeSummaryModal = (0, import_react.useCallback)(() => setSummaryModalOpen(false), []);
    (0, import_react.useImperativeHandle)(
      ref,
      () => ({
        /**
         * 跳转到上一步
         */
        goPrev: () => goPrev(),
        /**
         * 跳转到下一步
         */
        goNext: () => goNext(),
        /**
         * 跳转到指定步骤
         */
        goToStep: (step) => goToStep(step),
        /**
         * 获取当前步骤索引
         */
        getCurrentStep: () => currentStep,
        /**
         * 打开移动端总结弹窗
         */
        openSummaryModal,
        /**
         * 关闭移动端总结弹窗
         */
        closeSummaryModal
      }),
      [
        goPrev,
        goNext,
        goToStep,
        currentStep,
        openSummaryModal,
        closeSummaryModal
      ]
    );
    const footerPosition = (0, import_react.useMemo)(() => {
      if (isMobile && mode !== "modal") return "float-all";
      return (footerProps == null ? void 0 : footerProps.position) || "float-sidebar";
    }, [mode, isMobile, footerProps == null ? void 0 : footerProps.position]);
    const containerCls = (0, import_react.useMemo)(() => {
      return (0, import_utils.mergeClassNames)(
        "pisell-procedure",
        className,
        // 弹窗模式添加 --modal 修饰类，用于禁用媒体查询
        mode === "modal" && "pisell-procedure--modal",
        (0, import_utils.modifierClassName)("pisell-procedure", `footer-${footerPosition}`)
      );
    }, [className, mode, footerPosition]);
    const footerIsGlobal = (0, import_utils.isFooterGlobal)(footerPosition);
    return /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: containerCls,
        style,
        "data-component": "pisell-procedure",
        "data-id": __id,
        ...other
      },
      /* @__PURE__ */ import_react.default.createElement(import_pisellLayout.default, null, showHeader && /* @__PURE__ */ import_react.default.createElement(
        import_components.ProcedureHeader,
        {
          headerProps,
          currentStep,
          goPrev,
          onClose,
          onFirstStepBack,
          onBackConfirm,
          onCloseConfirm,
          goToStep
        }
      ), /* @__PURE__ */ import_react.default.createElement(
        import_components.ProcedureBody,
        {
          bodyProps,
          footerProps,
          footerPosition,
          showFooter: showFooter && !footerIsGlobal,
          showSidebar,
          summaryModalOpen,
          onOpenSummaryModal: openSummaryModal,
          onCloseSummaryModal: closeSummaryModal,
          goPrev,
          goNext,
          mode
        }
      ), showFooter && footerIsGlobal && /* @__PURE__ */ import_react.default.createElement(
        import_components.ProcedureFooter,
        {
          footerProps,
          position: footerPosition,
          isGlobal: true,
          sidebarContent: bodyProps == null ? void 0 : bodyProps.sidebarSlot,
          summaryModalOpen,
          onOpenSummaryModal: openSummaryModal,
          onCloseSummaryModal: closeSummaryModal,
          goPrev,
          goNext,
          mode
        }
      ))
    );
  }
);
PisellProcedure.displayName = "PisellProcedure";
var PisellProcedure_default = PisellProcedure;
