// src/status/normalize.ts
var WORKING_STATUSES = /* @__PURE__ */ new Set([
  "generating",
  "streaming",
  "loading",
  "loading_reference",
  "thinking",
  "active"
]);
function hasApprovalButtons(activeModal) {
  return (activeModal?.buttons?.length ?? 0) > 0;
}
function normalizeManagedStatus(status, opts) {
  if (hasApprovalButtons(opts?.activeModal)) return "waiting_approval";
  const normalized = String(status || "idle").trim().toLowerCase();
  if (normalized === "waiting_approval") return "waiting_approval";
  if (WORKING_STATUSES.has(normalized)) return "generating";
  if (normalized === "error") return "error";
  if (normalized === "stopped") return "stopped";
  if (normalized === "starting") return "starting";
  if (normalized === "panel_hidden") return "panel_hidden";
  if (normalized === "not_monitored") return "not_monitored";
  if (normalized === "disconnected") return "disconnected";
  return "idle";
}
function isManagedStatusWorking(status) {
  return normalizeManagedStatus(status) === "generating";
}
function isManagedStatusWaiting(status, opts) {
  return normalizeManagedStatus(status, opts) === "waiting_approval";
}
function normalizeActiveChatData(activeChat) {
  if (!activeChat) return activeChat;
  return {
    ...activeChat,
    status: normalizeManagedStatus(activeChat.status, { activeModal: activeChat.activeModal })
  };
}
export {
  isManagedStatusWaiting,
  isManagedStatusWorking,
  normalizeActiveChatData,
  normalizeManagedStatus
};
//# sourceMappingURL=normalize.mjs.map