var h=class{constructor(e={}){this.enrichers=[],this.config=e,this.stats={totalEvents:0,enrichedEvents:0,skippedEvents:0,errors:{}}}register(e){return this.enrichers.push(e),this.enrichers.sort((t,s)=>s.getPriority()-t.getPriority()),this}unregister(e){return this.enrichers=this.enrichers.filter(t=>t.getName()!==e),this}get(e){return this.enrichers.find(t=>t.getName()===e)}setEnabled(e,t){let s=this.get(e);return s&&(s.enabled=t),this}async enrich(e,t){this.stats.totalEvents++;let s={...e},n=[],i=[],a=[];for(let r of this.enrichers)try{if(!r.canEnrich(t)){i.push(r.getName());continue}let o=Date.now(),c=await r.enrich(e,t),l=Date.now()-o;c?(Object.assign(s,c),n.push({name:r.getName(),duration:l})):i.push(r.getName())}catch(o){console.warn(`[EnrichmentPipeline] ${r.getName()} failed:`,o.message),a.push(r.getName()),this.stats.errors[r.getName()]=(this.stats.errors[r.getName()]||0)+1}return s._enrichment={version:"1.0",timestamp:new Date().toISOString(),enrichers:{run:n,skipped:i,failed:a}},n.length>0?this.stats.enrichedEvents++:this.stats.skippedEvents++,s}async enrichBatch(e,t){let s=[];for(let n of e){let i=await this.enrich(n,t);s.push(i)}return s}getStats(){return{...this.stats,enrichers:this.enrichers.map(e=>({name:e.getName(),enabled:e.enabled,priority:e.getPriority(),errors:this.stats.errors[e.getName()]||0}))}}resetStats(){this.stats={totalEvents:0,enrichedEvents:0,skippedEvents:0,errors:{}}}logStatus(){console.log(`
\u{1F4CA} Enrichment Pipeline Status:`),console.log(`   Total events: ${this.stats.totalEvents}`),console.log(`   Enriched: ${this.stats.enrichedEvents}`),console.log(`   Skipped: ${this.stats.skippedEvents}`),console.log(`
   Registered enrichers (${this.enrichers.length}):`);for(let e of this.enrichers){let t=e.enabled?"\u2713":"\u2717",s=this.stats.errors[e.getName()]||0,n=s>0?` (${s} errors)`:"";console.log(`     ${t} ${e.getName()} (priority: ${e.getPriority()})${n}`)}console.log()}},d=h;export{h as EnrichmentPipeline,d as default};
