package flaresolverr

import "net/http"

type ChallengeResolutionResultT struct {
	URL         string            `json:"url"`
	Status      int               `json:"status"`
	Headers     map[string]string `json:"headers"`
	Response    string            `json:"-"`
	RawResponse any               `json:"response"`
	Cookies     []*http.Cookie
	RawCookies  []struct {
		Name         string  `json:"name"`
		Value        string  `json:"value"`
		Domain       string  `json:"domain"`
		Path         string  `json:"path"`
		Expires      float64 `json:"expires"`
		Size         int64   `json:"size"`
		HttpOnly     bool    `json:"httpOnly"`
		Secure       bool    `json:"secure"`
		Session      bool    `json:"session"`
		SameSite     string  `json:"sameSite"`
		Priority     string  `json:"priority"`
		SameParty    bool    `json:"sameParty"`
		SourceScheme string  `json:"sourceScheme"`
		SourcePort   uint    `json:"sourcePort"`
		PartitionKey string  `json:"partitionKey"`
	} `json:"cookies"`
	UserAgent string `json:"userAgent"`
}

type ChallengeResolutionT struct {
	Status  string                      `json:"status"`
	Message string                      `json:"message"`
	Result  *ChallengeResolutionResultT `json:"result"`
}

type Cookie struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type V1RequestBase struct {
	Cmd        string   `json:"cmd,omitempty"`
	Cookies    []Cookie `json:"cookies,omitempty"`
	MaxTimeout int      `json:"maxTimeout,omitempty"`
	Proxy      struct {
		Url string `json:"url"`
	} `json:"proxy,omitempty"`
	Session           string            `json:"session,omitempty"`
	SessionTTLMinutes int               `json:"session_ttl_minutes,omitempty"`
	Headers           map[string]string `json:"headers,omitempty"`   // Deprecated v2.0.0
	UserAgent         string            `json:"userAgent,omitempty"` // Deprecated v2.0.0

	// V1Request
	URL               string `json:"url,omitempty"`
	PostData          string `json:"postData,omitempty"` // Must be a string with application/x-www-form-urlencoded
	ReturnOnlyCookies bool   `json:"returnOnlyCookies,omitempty"`
	Download          bool   `json:"download,omitempty"`      // Deprecated v2.0.0
	ReturnRawHtml     bool   `json:"returnRawHtml,omitempty"` // Deprecated v2.0.0
}

type V1ResponseBase struct {
	Status         string                      `json:"status"`
	Message        string                      `json:"message"`
	Session        string                      `json:"session"`
	Sessions       []string                    `json:"sessions"`
	StartTimestamp int64                       `json:"startTimestamp"`
	EndTimestamp   int64                       `json:"endTimestamp"`
	Version        string                      `json:"version"`
	Solution       *ChallengeResolutionResultT `json:"solution"`

	// Hidden vars
	Error500 bool `json:"__error_500__"`
}

type IndexResponse struct {
	Msg       string `json:"msg"`
	Version   string `json:"version"`
	UserAgent string `json:"userAgent"`
}

type HealthResponse struct {
	Status string `json:"status"`
}