import axios from "axios";

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

let cks = '_pxvid=33d7e349-1d9a-11ef-8481-4d2726792e52; _px2=eyJ1IjoiMzM3YTU5MDAtMWQ5YS0xMWVmLWFiMGUtMjE0MzJkYTI1YzFiIiwidiI6IjMzZDdlMzQ5LTFkOWEtMTFlZi04NDgxLTRkMjcyNjc5MmU1MiIsInQiOjE3MTY5NzM2NjI3MTUsImgiOiI3MTE1MzgxMjI1NGRmYTJkYTY1NzJkNWYxOWMyMTA2YTVkY2Q4ZDIzYzFlMmRiNDJlYmZmMzUzMzhiNGE2MTEyIn0='



let prox = 'http://uni00002_custom_zone_US2_sid_4428759_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=',
    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)
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)
}