{"version":3,"sources":["../src/api/route-shape.ts"],"sourcesContent":["import {\n  AmbiguousRouteError,\n  assertUniqueRouteParameters,\n  getRoutePatternShape,\n} from \"../routing/specificity\";\n\nexport interface APIRouteShapeSource<TSource> {\n  routePath: string;\n  source: TSource;\n  filePath: string;\n}\n\n/** Validate API URL shapes and return the lower-priority route replaced by this source. */\nexport function registerAPIRouteShape<TSource>(\n  shapes: Map<string, APIRouteShapeSource<TSource>>,\n  routePath: string,\n  filePath: string,\n  source: TSource,\n): string | undefined {\n  assertUniqueRouteParameters(routePath, \"api\");\n  const shape = getRoutePatternShape(routePath, \"api\");\n  const existing = shapes.get(shape);\n  const replacesPath = existing && existing.routePath !== routePath;\n\n  if (replacesPath && existing.source === source) {\n    throw new AmbiguousRouteError(\n      `Ambiguous API routes \"${existing.routePath}\" and \"${routePath}\" match the same URLs. Found ${existing.filePath} and ${filePath}. Keep only one route for this URL shape.`,\n    );\n  }\n\n  shapes.set(shape, { routePath, source, filePath });\n  return replacesPath ? existing.routePath : undefined;\n}\n"],"mappings":";;;;;;;;;;AAaO,SAAS,sBACd,QACA,WACA,UACA,QACoB;AACpB,8BAA4B,WAAW,KAAK;AAC5C,QAAM,QAAQ,qBAAqB,WAAW,KAAK;AACnD,QAAM,WAAW,OAAO,IAAI,KAAK;AACjC,QAAM,eAAe,YAAY,SAAS,cAAc;AAExD,MAAI,gBAAgB,SAAS,WAAW,QAAQ;AAC9C,UAAM,IAAI;AAAA,MACR,yBAAyB,SAAS,SAAS,UAAU,SAAS,gCAAgC,SAAS,QAAQ,QAAQ,QAAQ;AAAA,IACjI;AAAA,EACF;AAEA,SAAO,IAAI,OAAO,EAAE,WAAW,QAAQ,SAAS,CAAC;AACjD,SAAO,eAAe,SAAS,YAAY;AAC7C;AAnBgB;","names":[]}