"use strict";(()=>{var e={};e.id=4414,e.ids=[4414],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")},72153:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>_,patchFetch:()=>q,requestAsyncStorage:()=>g,routeModule:()=>x,serverHooks:()=>v,staticGenerationAsyncStorage:()=>S});var a={};r.r(a),r.d(a,{POST:()=>y});var o=r(49303),n=r(88716),i=r(60670),s=r(87070),l=r(56681),u=r(57147),c=r.n(u),d=r(71017),p=r.n(d);let m=p().resolve(process.cwd(),".."),w=p().join(m,"data","justdial_temp_data"),h=async(e,t)=>{try{c().existsSync(w)||c().mkdirSync(w,{recursive:!0});let r=t.replace(/[^a-zA-Z0-9]/g,"_"),a=p().join(w,`${r}.json`);c().writeFileSync(a,JSON.stringify(e,null,2),"utf-8")}catch(e){console.error("❌ Error saving data:",e.message)}};async function y(e){try{let r=new AbortController,a=r.signal;e.signal?.addEventListener("abort",()=>{r.abort()});let{keyword:o,url:n,city:i="",validate:u}=await e.json();if(!o&&!n)return s.NextResponse.json({error:"Keyword or URL is required"},{status:400});let c=await l.chromium.connectOverCDP("http://localhost:9222"),d=c.contexts()[0].pages()[0],p=`https://www.justdial.com/${encodeURIComponent(i.trim())}/${encodeURIComponent(o)}`;await d.goto(n||p,{waitUntil:"domcontentloaded",timeout:24e4}),await d.waitForTimeout(3e3),await d.waitForSelector("#mainContent",{timeout:6e4});let m=2;u&&(m=12e3),await d.evaluate(()=>{document.body.style.zoom="0.25"}),await d.waitForTimeout(3e3);let w=2,y=0;async function t(e,t="down"){await e.evaluate(async({step:e,interval:t,direction:r})=>{let a=document.body.scrollHeight,o=Math.ceil(a/e);for(let a=0;a<o;a++)window.scrollBy(0,"down"===r?e:-e),await new Promise(e=>setTimeout(e,t))},{step:100,interval:20,direction:t})}for(let e=1;e<m&&!a.aborted&&0!==w;e++){let e=await d.evaluate(()=>{let e=document.querySelectorAll("#mainContent > div"),t=[];return e.forEach(e=>{let r=e.querySelector('a[target="_self"]')?.href||"",a=e.querySelector("h2 .resultbox_title_anchor")?.innerText.trim()||"",o=e.querySelector("address")?.innerText.trim()||"",n=e.querySelector(".callNowAnchor .callcontent")?.innerText.trim()||"",i=Array.from(e.querySelectorAll(".resultbox_amenities .amenities_tabs")).map(e=>e.innerText.trim()),s=e.querySelector(".btnresponse")?.innerText.trim()||"";r&&t.push({product_url:r,title:a,address:o,phone:n,tags:i,enquiries:s})}),t});y===e.length&&w--,y!==e.length&&(w=2,y=e.length),await h(e,`${n||`${o} contact no. in ${i}`}`,"justdial_temp_data"),await t(d,"down"),await d.waitForTimeout(1e3),await t(d,"up"),await d.waitForTimeout(1e3)}let x=await d.evaluate(()=>{let e=document.querySelectorAll("#mainContent > div"),t=[];return e.forEach(e=>{let r=e.querySelector('a[target="_self"]')?.href||"",a=e.querySelector("h2 .resultbox_title_anchor")?.innerText.trim()||"",o=e.querySelector("address")?.innerText.trim()||"",n=e.querySelector(".callNowAnchor .callcontent")?.innerText.trim()||"",i=Array.from(e.querySelectorAll(".resultbox_amenities .amenities_tabs")).map(e=>e.innerText.trim()),s=e.querySelector(".btnresponse")?.innerText.trim()||"";r&&t.push({product_url:r,title:a,address:o,phone:n,tags:i,enquiries:s})}),t});return await h(x,`${n||`${o} contact no. in ${i}`}`,"justdial_temp_data"),await c.close(),s.NextResponse.json(x)}catch(e){return console.error("Scraping Error:",e),s.NextResponse.json({error:"Failed to scrape website"},{status:500})}}let x=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/justdial_scraper/route",pathname:"/api/justdial_scraper",filename:"route",bundlePath:"app/api/justdial_scraper/route"},resolvedPagePath:"C:\\Users\\Design Collection\\OneDrive\\Desktop\\Jitendra Vishwakarma\\Next Dashboard\\web crawler for user dev\\Scrape Genius\\app\\api\\justdial_scraper\\route.js",nextConfigOutput:"",userland:a}),{requestAsyncStorage:g,staticGenerationAsyncStorage:S,serverHooks:v}=x,_="/api/justdial_scraper/route";function q(){return(0,i.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:S})}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972],()=>r(72153));module.exports=a})();