import{join as c}from"node:path";import u from"picomatch";import{PUBLIC_API_DEFINITIONS_FOLDER as p,L10N_DIR_NAME as h,I18N_DIR_NAME as l}from"../../constants/common.js";import{RESERVED_ROUTES as f}from"../../plugins/get-reserved-routes.js";import{canDownloadApiDefinition as m,filterDataByAccessDeep as D}from"../../utils/rbac.js";function s(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return i.map(s);const n={};for(const t in i)if(Object.hasOwn(i,t)){if(t.toString().startsWith("x-parsed-"))continue;n[t]=s(i[t])}return n}function O(i){return i.reduce((n,t)=>(t.relativePath.startsWith(h)||t.relativePath.startsWith(l)||t.definition?.paths&&Object.keys(t.definition.paths).length>0&&n.push({...t,definition:s(t.definition)}),n),[])}function R(i,n,t,r){return i.reduce((e,o)=>{if(!m(c(p,o.relativePath),t,r,n))return e;const a=D(o.definition,n,t,r);return e.push({...o,definition:a}),e},[])}function _(i,n){return i.filter(({relativePath:t})=>!u(n||[])(t))}function g(i={}){for(const[n,t]of Object.entries(i))if(n===f.mcp||(typeof t=="string"?t:t.to)===f.mcp)return!0;return!1}export{R as filterDefinitionsByRbac,_ as filterIgnoredDefinitions,O as getCleanedUpDefinitions,g as isMcpInRedirects};
