import{join as e}from"node:path";import{getLocalizedUrl as t}from"@intlayer/core/localization";import{getMarkdownMetadata as n}from"@intlayer/core/transpiler";import{Locales as r}from"@intlayer/types";const i=r.ENGLISH,a=`https://github.com/aymericzip/intlayer/blob/main/docs`,o=`https://intlayer.org/`,s=e=>Object.keys(e),c=async(e,t=i)=>{let n=await Promise.all(Object.entries(e).map(([e,n])=>[e,n[t]]).map(async([e,t])=>[e,await t]));return Object.fromEntries(n)},l=async(e,t,n=i)=>{if(!e[t])throw Error(`File ${t} not found`);let r=await e[t]?.[n];if(!r){let n=await e[t][i];if(!n)throw Error(`File ${t} not found`);return n}return r},u=(r,s,c=i)=>{let l=n(s),u=(l.slugs??[]).map(String),d=(l.keywords??[]).map(String),f=e(`/`,...u),p=r.slice(1);return{...l,docKey:r,slugs:u,keywords:d,githubUrl:`${a}${p}`.replace(`/en/`,`/${c}/`),relativeUrl:t(f,c),url:t(e(o,f),c)}},d=async(e,t,n=i)=>u(t,await l(e,t,n),n),f=async(e,t=i)=>{let n=await Promise.all(Object.entries(e).map(async([n])=>[n,await d(e,n,t)]));return Object.fromEntries(n)},p=async(e,t,n=i,r=!1)=>{let a=Array.isArray(t)?t:[t],o=await f(e,i),s=Object.values(o).filter(e=>a.every(t=>e.slugs?.includes(t)));return r&&(s=s.filter(e=>e.slugs.length===a.length)),n===i?s:await Promise.all(s.map(async t=>await d(e,t.docKey,n)))},m=async(e,t,n=i,r=!1)=>{let a=Array.isArray(t)?t:[t],o=await f(e,i),s=Object.values(o).filter(e=>a.every(t=>e.slugs?.includes(t)));return r&&(s=s.filter(e=>e.slugs.length===a.length)),await Promise.all(s.map(async t=>await l(e,t.docKey,n)))};export{a as GITHUB_URL_PREFIX,o as URL_PREFIX,i as defaultLocale,u as formatMetadata,l as getFile,m as getFileBySlug,d as getFileMetadata,p as getFileMetadataBySlug,f as getFileMetadataRecord,c as getFiles,s as getKeys};
//# sourceMappingURL=common.mjs.map