import{removeMarkdownLinks as j}from"../../openapi-docs/utils.js";function w(t,n,o,i){if(!t)return[];const e={};return l(e,t,n,o,i),Object.values(e)}function l(t,n,o,i,e,f=[]){if(!(!n||n.type==="null")){if(n.type==="object"&&n.properties){for(const[r,u]of Object.entries(n.properties))if(typeof u=="object"&&u!==null){const d=f.concat([r]),p=n.required?.includes(r)||!1,y=c(r,u,o,d,p,i,e),O=A(y);if(t[O]!==void 0)continue;t[O]=y,l(t,u,o,i,e,d)}}if(n.type==="array"&&n.items&&typeof n.items=="object"&&n.items!==null&&l(t,n.items,o,i,e,f),n.oneOf&&Array.isArray(n.oneOf))for(const r of n.oneOf)typeof r=="object"&&r!==null&&l(t,r,o,i,e,f);if(n.anyOf&&Array.isArray(n.anyOf))for(const r of n.anyOf)typeof r=="object"&&r!==null&&l(t,r,o,i,e,f);if(n.allOf&&Array.isArray(n.allOf))for(const r of n.allOf)typeof r=="object"&&r!==null&&l(t,r,o,i,e,f)}}function c(t,n,o,i,e,f,r){const u=S(n),d=j(n.description||""),p=n.example,y=n.enum;return{name:t,description:d,place:o,mediaType:void 0,path:i.slice(0,-1),type:u||"unknown",required:e,example:p?JSON.stringify(p):void 0,enum:y?.length?y:void 0,deepLink:k(i,o,f,r)}}function S(t){return t.type?Array.isArray(t.type)?t.type.filter(n=>n!=="null").join(" | "):t.type:t.properties?"object":t.items?"array":t.enum?"enum":t.format?t.format:"unknown"}function A(t){return`${t.name}${t.description}${t.place}`}function k(t,n,o,i){let e="",f="";n==="message headers"?f="headers":n==="message payload"&&(f="payload"),t.length>0&&(e=t.join("/"));let r=`#${o}/messages`;return i&&(r+=`&m=${i.toLowerCase()}`),f&&(r+=`&t=${f}`),e&&(r+=`&path=${e.toLowerCase()}`),r}export{w as processSchema};
