"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/status/normalize.ts
var normalize_exports = {};
__export(normalize_exports, {
  isManagedStatusWaiting: () => isManagedStatusWaiting,
  isManagedStatusWorking: () => isManagedStatusWorking,
  normalizeActiveChatData: () => normalizeActiveChatData,
  normalizeManagedStatus: () => normalizeManagedStatus
});
module.exports = __toCommonJS(normalize_exports);
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 })
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  isManagedStatusWaiting,
  isManagedStatusWorking,
  normalizeActiveChatData,
  normalizeManagedStatus
});
//# sourceMappingURL=normalize.js.map