{
  "version": 3,
  "sources": ["../../../../src/packages/catalogs.config/getCatalogsFromWorkspaceManifest.ts"],
  "sourcesContent": ["import { PnpmError } from '../error/index.ts';\nimport type { Catalogs } from '../catalogs.types/index.ts';\nimport type { WorkspaceManifest } from '../workspace.read-manifest/index.ts';\n\nexport function getCatalogsFromWorkspaceManifest(\n  workspaceManifest: Pick<WorkspaceManifest, 'catalog' | 'catalogs'> | undefined\n): Catalogs {\n  // If the pnpm-workspace.yaml file doesn't exist, no catalogs are defined.\n  //\n  // In some cases, it makes sense for callers to handle null/undefined checks\n  // of this form. In this case, let's explicitly handle not found\n  // pnpm-workspace.yaml files by returning an empty catalog to make consuming\n  // logic easier.\n  if (workspaceManifest == null) {\n    return {};\n  }\n\n  checkDefaultCatalogIsDefinedOnce(workspaceManifest);\n\n  return {\n    // If workspaceManifest.catalog is undefined, intentionally allow the spread\n    // below to overwrite it. The check above ensures only one or the either is\n    // defined.\n    default: workspaceManifest.catalog,\n\n    ...workspaceManifest.catalogs,\n  };\n}\n\nexport function checkDefaultCatalogIsDefinedOnce(\n  manifest: Pick<WorkspaceManifest, 'catalog' | 'catalogs'>\n): void {\n  if (manifest.catalog != null && manifest.catalogs?.default != null) {\n    throw new PnpmError(\n      'INVALID_CATALOGS_CONFIGURATION',\n      \"The 'default' catalog was defined multiple times. Use the 'catalog' field or 'catalogs.default', but not both.\"\n    );\n  }\n}\n"],
  "mappings": "AAAA,SAAS,iBAAiB;AAInB,SAAS,iCACd,mBACU;AAOV,MAAI,qBAAqB,MAAM;AAC7B,WAAO,CAAC;AAAA,EACV;AAEA,mCAAiC,iBAAiB;AAElD,SAAO;AAAA;AAAA;AAAA;AAAA,IAIL,SAAS,kBAAkB;AAAA,IAE3B,GAAG,kBAAkB;AAAA,EACvB;AACF;AAEO,SAAS,iCACd,UACM;AACN,MAAI,SAAS,WAAW,QAAQ,SAAS,UAAU,WAAW,MAAM;AAClE,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
  "names": []
}
