import{stripLogicalPathExtension}from"#discover/filesystem.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{normalizeChannelDefinition}from"#internal/authored-definition/channel.js";import{isDisabledRouteSentinel}from"#public/definitions/channel.js";async function compileChannelDefinition(n,r){let i=await loadModuleBackedDefinition({agentRoot:n,kind:`channel`,source:r}),a=stripLogicalPathExtension(r.logicalPath).replace(/^channels\//,``);if(isDisabledRouteSentinel(i))return{kind:`disabled`,name:a,logicalPath:r.logicalPath};let o=normalizeChannelDefinition(i,`Expected the channel export "${r.exportName??`default`}" from "${r.logicalPath}" to match the public Eve shape.`);return o.routes.map(e=>({kind:`channel`,name:a,logicalPath:r.logicalPath,method:e.method.toUpperCase(),urlPath:e.path,sourceId:r.sourceId,sourceKind:`module`,exportName:r.exportName,adapterKind:extractAdapterKind(o.adapter)}))}function extractAdapterKind(e){if(typeof e!=`object`||!e)return;let t=e.kind;return typeof t==`string`&&t.length>0?t:void 0}export{compileChannelDefinition};