"use strict";(()=>{var e={};e.id=6869,e.ids=[6869],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")},38784:(e,r,a)=>{a.r(r),a.d(r,{originalPathname:()=>f,patchFetch:()=>q,requestAsyncStorage:()=>g,routeModule:()=>x,serverHooks:()=>b,staticGenerationAsyncStorage:()=>S});var t={};a.r(t),a.d(t,{POST:()=>h});var i=a(49303),s=a(88716),o=a(60670),n=a(87070),c=a(56681),p=a.n(c),l=a(57147),d=a.n(l),u=a(71017),m=a.n(u);let y=m().resolve(process.cwd(),".."),w=m().join(y,"data","amazon_temp_data"),v=async(e,r)=>{try{d().existsSync(w)||d().mkdirSync(w,{recursive:!0});let a=r.replace(/[^a-zA-Z0-9]/g,"_"),t=m().join(w,`${a}.json`);d().writeFileSync(t,JSON.stringify(e,null,2),"utf-8")}catch(e){console.error("❌ Error saving data:",e.message)}};async function h(e){try{let r=new AbortController;r.signal,e.signal?.addEventListener("abort",()=>{r.abort()});let{query:a,pagination:t,countryUrl:i}=await e.json();if(!a)return n.NextResponse.json({error:"query is required"},{status:400});let s=await p().chromium.launch(),o=await s.newPage(),c=`${i}/s?k=${a}}&page=${t}`;await o.goto(c,{waitUntil:"domcontentloaded",timeout:6e4}),await o.waitForTimeout(3e3),await o.waitForSelector('span[data-component-type="s-search-results"]',{timeout:6e4});let l=(await o.evaluate(()=>{let e=document.querySelectorAll('span[data-component-type="s-search-results"] div[role="listitem"]'),r=[];return e.forEach(e=>{let a=e.querySelector('div[data-cy="title-recipe"] a')?.href||"",t=e.querySelector('div[data-cy="title-recipe"]')?.innerText.trim()||"",i=e.querySelector('div[data-cy="price-recipe"] a[aria-describedby="price-link"] span[data-a-color="base"] span[class="a-offscreen"]')?.innerText.trim()||"",s=e.querySelector('div[data-cy="price-recipe"] a[aria-describedby="price-link"] span[data-a-color="secondary"] span[class="a-offscreen"]')?.innerText.trim()||"",o=e.querySelector('div[data-cy="reviews-block"] div.a-row.a-size-small i[data-cy="reviews-ratings-slot"] span')?.innerText||"",n=e.querySelector('div[data-cy="reviews-block"] div.a-row.a-size-small a > span[aria-hidden="true"]')?.innerText||"";a&&r.push({product_url:a,title:t,price:i,original_price:s,email:"N/A",website:"N/A",phone:"N/A",whatsapp:"N/A",seller:"N/A",rating_star:o,rating_count:n,source:"amazon"})}),r})).map(e=>({...e,query:a}));return await v(l,`${a}`,"amazon_temp_data"),await s.close(),n.NextResponse.json(l)}catch(e){return console.error("Scraping Error:",e),n.NextResponse.json({error:"Failed to scrape website"},{status:500})}}let x=new i.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/amazon_scraper/route",pathname:"/api/amazon_scraper",filename:"route",bundlePath:"app/api/amazon_scraper/route"},resolvedPagePath:"C:\\Users\\Design Collection\\OneDrive\\Desktop\\Jitendra Vishwakarma\\Next Dashboard\\web crawler for user dev\\Scrape Genius\\app\\api\\amazon_scraper\\route.js",nextConfigOutput:"",userland:t}),{requestAsyncStorage:g,staticGenerationAsyncStorage:S,serverHooks:b}=x,f="/api/amazon_scraper/route";function q(){return(0,o.patchFetch)({serverHooks:b,staticGenerationAsyncStorage:S})}}};var r=require("../../../webpack-runtime.js");r.C(e);var a=e=>r(r.s=e),t=r.X(0,[8948,5972],()=>a(38784));module.exports=t})();