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