import Buffer from "buffer";
import processBrowser from "process/browser";
import console from "console-browserify";
var buffer = {
  Buffer
};
import { jsx } from "react/jsx-runtime";
import { flowItemBrief } from "@midscene/web/yaml";
import { Steps } from "antd";
import { useState } from "react";
function YamlPlayerStatusIndicator({
  player
}) {
  const [loadingProgressText, setLoadingProgressText] = useState("");
  const [steps, setSteps] = useState([]);
  if (player) {
    player.onTaskStatusChange = (taskStatus) => {
      const currentTask = taskStatus;
      const newSteps = [];
      for (let i = 0; i < currentTask.totalSteps; i++) {
        const flow = currentTask.flow[i];
        const brief = flowItemBrief(flow);
        const tips = (flow.aiActionProgressTips || []).join("\n");
        newSteps.push({
          title: currentTask.name || "(unnamed)",
          description: /* @__PURE__ */ jsx("pre", { children: tips })
        });
      }
      setSteps(newSteps);
      let overallStatus = "";
      if (taskStatus.status === "init") {
        overallStatus = "initializing...";
      } else if (taskStatus.status === "running" || taskStatus.status === "error") {
        const item = taskStatus.flow[0];
        const tips = (item == null ? void 0 : item.aiActionProgressTips) || [];
        if (tips.length > 0) {
          overallStatus = tips[tips.length - 1];
        }
      }
      setLoadingProgressText(overallStatus);
    };
  }
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Steps, { direction: "vertical", size: "small", current: 1, items: steps }) });
}
export {
  YamlPlayerStatusIndicator
};
