import{getStatusCodeType as h,JsonPointer as c,getValueFromMdParsedExtension as d,getContent as x}from"../utils/index.js";import{getField as C}from"./field.js";import{getMediaContent as j}from"./mediaContent.js";function M({parser:n,code:s,defaultAsError:a,infoOrRef:m,options:p,isEvent:y,operation:o}){const g=!!y,{resolved:t}=n.deref(m),e={code:s};t["x-summary"]!==void 0?(e.summary=d(t,"x-summary"),e.description=d(t,"description")||""):(e.summary=d(t,"description")||"",e.description=""),e.type=h(s,a);const i=t.headers,u=m.$ref||c.join(o?.pointer||"",["responses",s]);i!==void 0&&(e.headers=Object.keys(i).map(r=>{const l=i[r];return C(n,{...l,name:r},c.join(u,["headers",r]),p,{operation:o,type:"response",response:e})}));const f=x(n,t);return f!==void 0&&(e.content=j({parser:n,info:f,isRequestType:g,options:p,data:{operation:o,type:"response",response:e,absolutePointer:u}})),e}export{M as getResponse};
