import { normalizeMimeTypeObject, getObjectKeys } from "@scalar/oas-utils/helpers";
function hasMediaTypeContent(mediaType) {
  if (!mediaType) {
    return false;
  }
  const hasSchema = Boolean(mediaType.schema);
  const hasExample = "example" in mediaType && mediaType.example !== null;
  const hasExamples = Boolean(mediaType.examples);
  return hasSchema || hasExample || hasExamples;
}
function isResponseKey(responseKey) {
  return responseKey === "default" || /^[1-5][0-9]{2}$/.test(responseKey) || /^[1-5]XX$/.test(responseKey);
}
function hasResponseContent(response, responseKey) {
  if (responseKey !== void 0) {
    if (!isResponseKey(responseKey)) {
      return false;
    }
    return Boolean(response);
  }
  const normalizedContent = normalizeMimeTypeObject(response?.content);
  const keys = getObjectKeys(normalizedContent ?? {});
  const mediaType = normalizedContent?.["application/json"] ?? normalizedContent?.["application/xml"] ?? normalizedContent?.["text/plain"] ?? normalizedContent?.["text/html"] ?? normalizedContent?.["*/*"] ?? normalizedContent?.[keys[0] ?? ""];
  return hasMediaTypeContent(mediaType);
}
export {
  hasResponseContent
};
