"use strict";(()=>{var e={};e.id=7031,e.ids=[7031],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")},57147:e=>{e.exports=require("fs")},71017:e=>{e.exports=require("path")},79061:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>k,patchFetch:()=>S,requestAsyncStorage:()=>v,routeModule:()=>y,serverHooks:()=>q,staticGenerationAsyncStorage:()=>g});var a={};t.r(a),t.d(a,{POST:()=>x});var i=t(49303),o=t(88716),s=t(60670),n=t(87070),l=t(56681),p=t.n(l),u=t(57147),c=t.n(u),d=t(71017),w=t.n(d);let h=w().resolve(process.cwd(),".."),m=w().join(h,"data","flipkart_temp_data"),f=async(e,r)=>{try{c().existsSync(m)||c().mkdirSync(m,{recursive:!0});let t=r.replace(/[^a-zA-Z0-9]/g,"_"),a=w().join(m,`${t}.json`);c().writeFileSync(a,JSON.stringify(e,null,2),"utf-8")}catch(e){console.error("❌ Error saving data:",e.message)}};async function x(e){let r;try{let{query:t,pagination:a}=await e.json();if(!t)return n.NextResponse.json({error:"query is required"},{status:400});r=await p().chromium.launch();let i=await r.newPage(),o=`https://www.flipkart.com/search?q=${t}&page=${a}`;await i.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await i.waitForTimeout(3e3);let s=(await i.evaluate(()=>{let e=document.querySelectorAll('div[style="flex-grow: 1; overflow: auto;"] div.cPHDOP.col-12-12 div[data-tkid]'),r=[];return e.forEach(e=>{let t=e.querySelector("a")?.href||"",a=e.querySelectorAll("a")||[],i="";a.length&&(i=a[1]?.innerText||"");let o=e.querySelector("a div.Nx9bqj")?.innerText.trim()||"",s=e.querySelector("a div.yRaY8j")?.innerText.trim()||"",n=e.querySelector("span.Y1HWO0")?.innerText||"",l=e.querySelector("span.Wphh3N")?.innerText||"";t&&r.push({product_url:t,title:i,price:o,original_price:s,email:"N/A",website:"N/A",phone:"N/A",whatsapp:"N/A",seller:"N/A",rating_star:n,rating_count:l,source:"flipkart"})}),r})).map(e=>({...e,query:t}));return await f(s,`${t}`,"flipkart_temp_data"),await r.close(),n.NextResponse.json(s)}catch(e){return console.error("Scraping Error:",e),n.NextResponse.json({error:"Failed to scrape website"},{status:500})}finally{r&&await r.close()}}let y=new i.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/flipkart_scraper/route",pathname:"/api/flipkart_scraper",filename:"route",bundlePath:"app/api/flipkart_scraper/route"},resolvedPagePath:"C:\\Users\\Design Collection\\OneDrive\\Desktop\\Jitendra Vishwakarma\\Next Dashboard\\web crawler for user dev\\Scrape Genius\\app\\api\\flipkart_scraper\\route.js",nextConfigOutput:"",userland:a}),{requestAsyncStorage:v,staticGenerationAsyncStorage:g,serverHooks:q}=y,k="/api/flipkart_scraper/route";function S(){return(0,s.patchFetch)({serverHooks:q,staticGenerationAsyncStorage:g})}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[8948,5972],()=>t(79061));module.exports=a})();