package rasel.lunar.launcher.model.others

import rasel.lunar.launcher.model.RssDataInterface
import rasel.lunar.launcher.model.RssDataType
import rasel.lunar.launcher.utils.JamoUtils


class Child {
    var kind: String? = null
    var data: Data? = null
}

class CrosspostParentList {
    var approved_at_utc: Any? = null
    var subreddit: String? = null
    var selftext: String? = null
    var author_fullname: String? = null
    var saved: Boolean = false
    var mod_reason_title: Any? = null
    var gilded: Int = 0
    var clicked: Boolean = false
    var title: String? = null
    var link_flair_richtext: ArrayList<Any>? = null
    var subreddit_name_prefixed: String? = null
    var hidden: Boolean = false
    var pwls: Any? = null
    var link_flair_css_class: String? = null
    var downs: Int = 0
    var thumbnail_height: Int = 0
    var top_awarded_type: Any? = null
    var hide_score: Boolean = false
    var name: String? = null
    var quarantine: Boolean = false
    var link_flair_text_color: String? = null
    var upvote_ratio: Double = 0.0
    var author_flair_background_color: Any? = null
    var subreddit_type: String? = null
    var ups: Int = 0
    var total_awards_received: Int = 0
    var media_embed: MediaEmbed? = null
    var thumbnail_width: Int = 0
    var author_flair_template_id: Any? = null
    var is_original_content: Boolean = false
    var user_reports: ArrayList<Any>? = null
    var secure_media: SecureMedia? = null
    var is_reddit_media_domain: Boolean = false
    var is_meta: Boolean = false
    var category: Any? = null
    var secure_media_embed: SecureMediaEmbed? = null
    var link_flair_text: String? = null
    var can_mod_post: Boolean = false
    var score: Int = 0
    var approved_by: Any? = null
    var is_created_from_ads_ui: Boolean = false
    var author_premium: Boolean = false
    var thumbnail: String? = null
    var edited: String? = null
    var author_flair_css_class: Any? = null
    var author_flair_richtext: ArrayList<Any>? = null
    var gildings: Gildings? = null
    var post_hint: String? = null
    var content_categories: Any? = null
    var is_self: Boolean = false
    var mod_note: Any? = null
    var created: Double = 0.0
    var link_flair_type: String? = null
    var wls: Any? = null
    var removed_by_category: Any? = null
    var banned_by: Any? = null
    var author_flair_type: String? = null
    var domain: String? = null
    var allow_live_comments: Boolean = false
    var selftext_html: Any? = null
    var likes: Any? = null
    var suggested_sort: Any? = null
    var banned_at_utc: Any? = null
    var url_overridden_by_dest: String? = null
    var view_count: Any? = null
    var archived: Boolean = false
    var no_follow: Boolean = false
    var is_crosspostable: Boolean = false
    var pinned: Boolean = false
    var over_18: Boolean = false
    var preview: Preview? = null
    var all_awardings: ArrayList<Any>? = null
    var awarders: ArrayList<Any>? = null
    var media_only: Boolean = false
    var can_gild: Boolean = false
    var spoiler: Boolean = false
    var locked: Boolean = false
    var author_flair_text: Any? = null
    var treatment_tags: ArrayList<Any>? = null
    var visited: Boolean = false
    var removed_by: Any? = null
    var num_reports: Any? = null
    var distinguished: Any? = null
    var subreddit_id: String? = null
    var author_is_blocked: Boolean = false
    var mod_reason_by: Any? = null
    var removal_reason: Any? = null
    var link_flair_background_color: String? = null
    var id: String? = null
    var is_robot_indexable: Boolean = false
    var report_reasons: Any? = null
    var author: String? = null
    var discussion_type: Any? = null
    var num_comments: Int = 0
    var send_replies: Boolean = false
    var whitelist_status: Any? = null
    var contest_mode: Boolean = false
    var mod_reports: ArrayList<Any>? = null
    var author_patreon_flair: Boolean = false
    var author_flair_text_color: Any? = null
    var permalink: String? = null
    var parent_whitelist_status: Any? = null
    var stickied: Boolean = false
    var url: String? = null
    var subreddit_subscribers: Int = 0
    var created_utc: Double = 0.0
    var num_crossposts: Int = 0
    var media: Media? = null
    var is_video: Boolean = false
    var link_flair_template_id: String? = null
}

class Data : RssDataInterface {
    var after: String? = null
    var dist: Int = 0
    var modhash: String? = null
    var geo_filter: Any? = null
    var children: ArrayList<Child>? = null
    var before: Any? = null
    var approved_at_utc: Any? = null
    var subreddit: String? = null
    var selftext: String? = null
    var user_reports: ArrayList<Any>? = null
    var saved: Boolean = false
    var mod_reason_title: Any? = null
    var gilded: Int = 0
    var clicked: Boolean = false
    var title: String? = null
    var link_flair_richtext: ArrayList<Any>? = null
    var subreddit_name_prefixed: String? = null
    var hidden: Boolean = false
    var pwls: Any? = null
    var link_flair_css_class: Any? = null
    var downs: Int = 0
    var thumbnail_height: Int = 0
    var top_awarded_type: Any? = null
    var hide_score: Boolean = false
    var name: String? = null
    var quarantine: Boolean = false
    var link_flair_text_color: String? = null
    var upvote_ratio: Double = 0.0
    var author_flair_background_color: Any? = null
    var subreddit_type: String? = null
    var ups: Int = 0
    var total_awards_received: Int = 0
    var media_embed: MediaEmbed? = null
    var thumbnail_width: Int = 0
    var author_flair_template_id: Any? = null
    var is_original_content: Boolean = false
    var author_fullname: String? = null
    var secure_media: SecureMedia? = null
    var is_reddit_media_domain: Boolean = false
    var is_meta: Boolean = false
    var category: Any? = null
    var secure_media_embed: SecureMediaEmbed? = null
    var link_flair_text: Any? = null
    var can_mod_post: Boolean = false
    var score: Int = 0
    var approved_by: Any? = null
    var is_created_from_ads_ui: Boolean = false
    var author_premium: Boolean = false
    var thumbnail: String? = null
    var edited: String? = null
    var author_flair_css_class: Any? = null
    var author_flair_richtext: ArrayList<Any>? = null
    var gildings: Gildings? = null
    var post_hint: String? = null
    var content_categories: Any? = null
    var is_self: Boolean = false
    var mod_note: Any? = null
    var crosspost_parent_list: ArrayList<CrosspostParentList>? = null
    var created: Double = 0.0
    var link_flair_type: String? = null
    var wls: Any? = null
    var removed_by_category: Any? = null
    var banned_by: Any? = null
    var author_flair_type: String? = null
    var domain: String? = null
    var allow_live_comments: Boolean = false
    var selftext_html: Any? = null
    var likes: Any? = null
    var suggested_sort: Any? = null
    var banned_at_utc: Any? = null
    var url_overridden_by_dest: String? = null
    var view_count: Any? = null
    var archived: Boolean = false
    var no_follow: Boolean = false
    var is_crosspostable: Boolean = false
    var pinned: Boolean = false
    var over_18: Boolean = false
    var preview: Preview? = null
    var all_awardings: ArrayList<Any>? = null
    var awarders: ArrayList<Any>? = null
    var media_only: Boolean = false
    var can_gild: Boolean = false
    var spoiler: Boolean = false
    var locked: Boolean = false
    var author_flair_text: Any? = null
    var treatment_tags: ArrayList<Any>? = null
    var visited: Boolean = false
    var removed_by: Any? = null
    var num_reports: Any? = null
    var distinguished: Any? = null
    var subreddit_id: String? = null
    var author_is_blocked: Boolean = false
    var mod_reason_by: Any? = null
    var removal_reason: Any? = null
    var link_flair_background_color: String? = null
    var id: String? = null
    var is_robot_indexable: Boolean = false
    var report_reasons: Any? = null
    var author: String? = null
    var discussion_type: Any? = null
    var num_comments: Int = 0
    var send_replies: Boolean = false
    var whitelist_status: Any? = null
    var contest_mode: Boolean = false
    var mod_reports: ArrayList<Any>? = null
    var author_patreon_flair: Boolean = false
    var crosspost_parent: String? = null
    var author_flair_text_color: Any? = null
    var permalink: String? = null
    var parent_whitelist_status: Any? = null
    var stickied: Boolean = false
    var url: String? = null
    var subreddit_subscribers: Int = 0
    var created_utc: Double = 0.0
    var num_crossposts: Int = 0
    var media: Media? = null
    var is_video: Boolean = false

    override fun title(): String {
        return title ?: ""
    }

    override fun thumbnailUrl(): String {
        return thumbnail ?: ""
    }

    override fun originPage(): String {
        if (post_hint?.contains("video") == true && (permalink?.length ?: 0 > 3)) {
            return "https://www.reddit.com".plus(permalink)
        }
        return url ?: ""
    }

    override fun description(): String {
        return  subreddit_name_prefixed ?: subreddit ?: ""
    }

    override fun pubDate(): Long {
//        return beforeDay(java.util.Date(),2)
        if (created_utc != null) {
            return created_utc!!.toLong() * 1000L
        } else if (created != null) {
            return created!!.toLong() * 1000L
        }
        return 0L
    }

    override fun category(): RssDataType {
        return  if (description()?.contains("nsfw") == true) {
            RssDataType.REDDIT_nsfw
        } else RssDataType.REDDIT
    }
    override fun getCho(): String? {
        return JamoUtils.split(title!!).joinToString("")
    }
}

class Gif {
    var source: Source? = null
    var resolutions: ArrayList<Resolution>? = null
}

class Gildings

class Image {
    var source: Source? = null
    var resolutions: ArrayList<Resolution>? = null
    var variants: Variants? = null
    var id: String? = null
}

class Media {
    var type: String? = null
    var oembed: Oembed? = null
}

class MediaEmbed {
    var content: String? = null
    var width: Int = 0
    var scrolling: Boolean = false
    var height: Int = 0
}

class Mp4 {
    var source: Source? = null
    var resolutions: ArrayList<Resolution>? = null
}

class Nsfw {
    var source: Source? = null
    var resolutions: ArrayList<Resolution>? = null
}

class Obfuscated {
    var source: Source? = null
    var resolutions: ArrayList<Resolution>? = null
}

class Oembed {
    var provider_url: String? = null
    var version: String? = null
    var title: String? = null
    var thumbnail_width: Int = 0
    var height: Int = 0
    var width: Int = 0
    var html: String? = null
    var provider_name: String? = null
    var thumbnail_url: String? = null
    var type: String? = null
    var thumbnail_height: Int = 0
}

class Preview {
    var images: ArrayList<Image>? = null
    var reddit_video_preview: RedditVideoPreview? = null
    var enabled: Boolean = false
}

class RedditVideoPreview {
    var bitrate_kbps: Int = 0
    var fallback_url: String? = null
    var height: Int = 0
    var width: Int = 0
    var scrubber_media_url: String? = null
    var dash_url: String? = null
    var duration: Int = 0
    var hls_url: String? = null
    var is_gif: Boolean = false
    var transcoding_status: String? = null
}

class Resolution {
    var url: String? = null
    var width: Int = 0
    var height: Int = 0
}

class Reddit {
    var kind: String? = null
    var data: Data? = null
}

class SecureMedia {
    var type: String? = null
    var oembed: Oembed? = null
}

class SecureMediaEmbed {
    var content: String? = null
    var width: Int = 0
    var scrolling: Boolean = false
    var media_domain_url: String? = null
    var height: Int = 0
}

class Source {
    var url: String? = null
    var width: Int = 0
    var height: Int = 0
}

class Variants {
    var obfuscated: Obfuscated? = null
    var nsfw: Nsfw? = null
    var gif: Gif? = null
    var mp4: Mp4? = null
}
