"use strict";(()=>{var e={};e.id=8401,e.ids=[8401],e.modules={20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},56681:e=>{e.exports=require("playwright")},92819:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>h,patchFetch:()=>w,requestAsyncStorage:()=>p,routeModule:()=>d,serverHooks:()=>f,staticGenerationAsyncStorage:()=>m});var a={};t.r(a),t.d(a,{POST:()=>c});var o=t(49303),i=t(88716),n=t(60670),l=t(87070),u=t(56681),s=t.n(u);async function c(e){let r;try{let{keyword:t,validate:a=!1,pageNo:o}=await e.json();if(!t)return l.NextResponse.json({error:"Keyword is required"},{status:400});r=await s().chromium.launch({headless:!0});let i=await r.newPage(),n=[],u=`https://www.tradeindia.com/search.html?keyword=${encodeURIComponent(t)}&page=${o}`;await i.goto(u,{waitUntil:"domcontentloaded",timeout:3e4}),await i.waitForSelector(".card.d-flex.flex-column",{timeout:15e3}),await i.waitForTimeout(3e3);let c=await i.evaluate(()=>{let e=document.querySelectorAll(".card.d-flex.flex-column"),r=[];return e.forEach(e=>{let t=e.querySelector(".card_title")?.innerText||"",a=e.querySelector(".img_container a")?.href||"",o=e.querySelector("h3.coy-name")?.innerText||e.querySelector('a[rel="nofollow"] p.coy-name')?.innerText||"",i=e.querySelector('a[href*="tradeindia.com"]:not([href*="products"])')?.href||"",n=e.querySelectorAll(".product_details > div")[1]?.innerText?.trim()||"",l=Array.from(e.querySelectorAll("p")).find(e=>e.innerText.includes("Business Type:"))?.innerText.replace("Business Type:","").trim()||"",u=e.querySelector('.product_details a[target="_blank"][rel="noreferrer nofollow"]')?.href||"",s=Array.from(e.querySelectorAll("a")).find(e=>e.getAttribute("href")?.includes("tel")),c=s?.getAttribute("href")?.replace("tel:","").replace(/^(\+91[\s-]?)/,"");r.push({title:t,product_url:a,company:o,company_url:i,location:n,business_type:l,website:u,phone_number:c?[c]:[]})}),r}),d=[];if(c.length)for(let e of c)if(e.business_type)d.push(e);else try{await i.goto(e.product_url,{waitUntil:"domcontentloaded",timeout:3e4}),await i.waitForTimeout(3e3);let r=await i.evaluate(()=>{let e=document.querySelector(".detail-row .info-block .info-rt .sc-c6d82cff-0.fioeCJ")?.innerText||"";return{url:document.querySelector(".seller-name-url")?.href||"",busi_type:e}});if(r){let t={...e,business_type:r.busi_type,company_url:r.url};d.push(t)}}catch(e){console.log("error")}return n.push(...d),await r.close(),l.NextResponse.json(n)}catch(e){return console.error("Scraping Error:",e),l.NextResponse.json({error:"Failed to scrape TradeIndia"},{status:500})}finally{r&&await r.close()}}let d=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/trade_india/route",pathname:"/api/trade_india",filename:"route",bundlePath:"app/api/trade_india/route"},resolvedPagePath:"C:\\Users\\Design Collection\\OneDrive\\Desktop\\Jitendra Vishwakarma\\Next Dashboard\\web crawler for user dev\\Scrape Genius\\app\\api\\trade_india\\route.js",nextConfigOutput:"",userland:a}),{requestAsyncStorage:p,staticGenerationAsyncStorage:m,serverHooks:f}=d,h="/api/trade_india/route";function w(){return(0,n.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:m})}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[8948,5972],()=>t(92819));module.exports=a})();