import axios from "axios";

const tlsUrl = 'http://52.52.23.116/tls/forward';

let cks ="_pxvid=bd50bc51-1d9d-11ef-a3fc-f403f760dd61; _px2=eyJ1IjoiYmQxNTEwODAtMWQ5ZC0xMWVmLWFiMGUtMjE0MzJkYTI1YzFiIiwidiI6ImJkNTBiYzUxLTFkOWQtMTFlZi1hM2ZjLWY0MDNmNzYwZGQ2MSIsInQiOjE3MTY5NzUxODE3MTYsImgiOiJmZGZjYmI1NWFiNDcyZmUzYzY1NjFiZTQ2ZmE5ODMyZTE1MTUyNWE0N2U0NmQ4MzRhYzFmNDQyYmZjNmIyNzk4In0="








let prox = 'http://uni00002_custom_zone_US2_sid_4142218_time_5:FdkiGHty9a@us.ipwo.net:7878';
console.log(JSON.stringify({
    url: 'https://booking.flyfrontier.com/Flight/InternalSelect?o1=BNA&d1=ATL&dd1=Apr%2027,%202024&ADT=1&mon=true&promo=',
    headers: {
        "Host": "booking.flyfrontier.com",
        "sec-ch-ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"macOS\"",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
        "sec-fetch-site": "same-site",
        "sec-fetch-mode": "navigate",
        "sec-fetch-user": "?1",
        "sec-fetch-dest": "document",
        "accept-language": "en",
        "cookie": cks
    },
    allow_redirects: true,
    debug: true,
    method: "GET",
    proxy: prox,
    random_tls: true,

}))
let res = await axios.post(tlsUrl, JSON.stringify({
    // url: 'https://booking.flyfrontier.com/Flight/InternalSelect?o1=BNA&d1=ATL&dd1=Apr%2027,%202024&ADT=1&mon=true&promo=',
    url: 'https://booking.flyfrontier.com/Flight/InternalSelect?o1=SEA&d1=DEN&dd1=Jun+21%2C+2024&ADT=3&mon=true&dd1=',
    headers: {
        "Host": "booking.flyfrontier.com",
        "sec-ch-ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"macOS\"",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
        "sec-fetch-site": "same-site",
        "sec-fetch-mode": "navigate",
        "sec-fetch-user": "?1",
        "sec-fetch-dest": "document",
        "accept-language": "en",
        "cookie": cks
    },
    allow_redirects: true,
    debug: true,
    method: "GET",
    proxy: prox,
    random_tls: true,

}));
console.log(res.data.text.includes('FlightData'))
if (res.data.status_code === 200) {
    // console.log(res.data.text)
    this.log.warn('success', res.data.status_code, res.data.text.includes('FlightData'))
    await this.add_headers()
} else {
    this.log.error('error', res.data.status_code)
}