import{CONFIG_FILE_NAME as f}from"../../../constants/common.js";import{reporter as i}from"../../tools/notifiers/reporter.js";import{FileNotFoundError as y}from"../../utils/fs.js";import{resolveSrcSet as a}from"../../utils/resolve-src-set.js";import{resolveAssetPath as l}from"../../utils/resolve-asset-path.js";async function u(t={},p,s,o){const r={...t};if(t.entityTypes)for(const c of Object.keys(t.entityTypes)){if(!r.entityTypes?.[c])continue;const e=t.entityTypes[c];if(e.icon?.src)try{e.icon.src=await l(e.icon.src,o,{fromFileRelativePath:p,contentDir:o.cwd,outdir:s})}catch(n){n instanceof y?i.panicOnBuildContentError('Cannot resolve "entityTypeConfig.icon.src": %rp',e.icon.src):i.panicOnBuild(`Cannot resolve "entityTypeConfig.icon.src": %rp: ${n.message}`,e.icon.src)}if(e.icon?.srcSet)try{e.icon.srcSet=await a(e.icon.srcSet,o,{fromFileRelativePath:f,contentDir:o.cwd,outdir:s})}catch(n){n instanceof y?i.panicOnBuildContentError(`Cannot resolve "entityTypeConfig.icon.srcSet" "${e.icon.srcSet}"`):i.panicOnBuild(`Cannot resolve "entityTypeConfig.icon.srcSet" "${e.icon.srcSet}": ${n.message}`)}r.entityTypes[c]=e}return r}export{u as resolveEntitiesCatalogConfig};
