"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require$$0 = require("react/jsx-runtime");
const designSystem = require("@choiceform/design-system");
const iconsReact = require("@choiceform/icons-react");
const React = require("react");
const markdown = require("../../../common/markdown/markdown.cjs");
const MessageProgressTv = designSystem.tcv({
  slots: {
    root: "flex justify-between gap-1",
    content: "text-secondary-foreground flex-1",
    icon: "text-icon-secondary flex size-5 items-center justify-center",
    progress: "text-secondary-foreground text-message"
  }
});
const MessageProgress = React.memo(function MessageProgress2(props) {
  const { children, className } = props;
  const extractProgress = (content2) => {
    const percentMatch = content2.match(/(\d+)%/);
    const fractionMatch = content2.match(/(\d+)\/(\d+)/);
    if (percentMatch) {
      return {
        type: "percentage",
        value: parseInt(percentMatch[1]),
        total: 100
      };
    }
    if (fractionMatch) {
      return {
        type: "fraction",
        value: parseInt(fractionMatch[1]),
        total: parseInt(fractionMatch[2])
      };
    }
    return null;
  };
  const content = typeof children === "string" ? children : "";
  const progress = extractProgress(content);
  const tv = MessageProgressTv();
  return /* @__PURE__ */ require$$0.jsxs("div", { className: designSystem.tcx(tv.root(), className), children: [
    /* @__PURE__ */ require$$0.jsx("div", { className: tv.icon(), children: /* @__PURE__ */ require$$0.jsx(iconsReact.PromptMessagePlanning, {}) }),
    content && /* @__PURE__ */ require$$0.jsx(markdown.Markdown, { className: tv.content(), children: content }),
    progress && /* @__PURE__ */ require$$0.jsx("span", { className: tv.progress(), children: progress.type === "percentage" ? `${progress.value}%` : `${progress.value}/${progress.total}` })
  ] });
});
exports.MessageProgress = MessageProgress;
//# sourceMappingURL=message-progress.cjs.map
