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