class ParallelDataStreamController{constructor(){this.targetCount=1/0,this.collectedCount=0,this.isStopped=!1,window.addEventListener("message",t=>{t.data&&"gmaps_extraction_stop_injected"===t.data.action&&this.stopPipeline()}),chrome.runtime.onMessage.addListener(t=>{"gmaps_extraction_stop"===t.action&&this.stopPipeline(),"gmaps_extraction_start"===t.action&&(this.targetCount=t.targetCount||1/0,this.collectedCount=0,this.isStopped=!1)})}stopPipeline(){this.isStopped=!0;try{window.stopFeedScroll&&window.stopFeedScroll(),window.stopNavigator&&window.stopNavigator()}catch(t){}}async processLeadsBatch(t,e,a,o){if(this.isStopped)return{newLeadsCount:0,stopped:!0};let s=0;for(let i=0;i<t.length&&!this.isStopped;i++){try{const n=await e(t[i],i);if(!n)continue;if(n.placeID&&!a.has(n.placeID)){a.add(n.placeID),this.collectedCount++,s++,o&&await o(n);try{chrome.runtime.sendMessage({action:"hot_lead_stream",lead:n,currentCount:this.collectedCount,target:this.targetCount}).catch(()=>{})}catch(t){}if(this.collectedCount>=this.targetCount){this.stopPipeline();break}}}catch(t){}i%3==0&&await new Promise(t=>setTimeout(t,0))}return{newLeadsCount:s,stopped:this.isStopped}}}window.ParallelDataStream=new ParallelDataStreamController;