//
//  MPPositive_JsonGenres.swift
//  relax.offline.mp3.music
//
//  Created by Mr.Zhou on 2024/7/11.
//

import UIKit
///心情与流派结构
struct JsonGenres: Codable {
    let contents:Contents?
    let header:Header?
    enum CodingKeys: String, CodingKey {
        case contents = "contents"
        case header = "header"
    }
    init(from decoder: Decoder) throws {
        let values = try decoder.container(keyedBy: CodingKeys.self)
        contents = try values.decodeIfPresent(Contents.self, forKey: .contents)
        header = try values.decodeIfPresent(Header.self, forKey: .header)
    }
    struct Contents: Codable {
        let singleColumnBrowseResultsRenderer:SingleColumnBrowseResultsRenderer?
        enum CodingKeys: String, CodingKey {
            case singleColumnBrowseResultsRenderer = "singleColumnBrowseResultsRenderer"
        }
        init(from decoder: Decoder) throws {
            let values = try decoder.container(keyedBy: CodingKeys.self)
            singleColumnBrowseResultsRenderer = try values.decodeIfPresent(SingleColumnBrowseResultsRenderer.self, forKey: .singleColumnBrowseResultsRenderer)
        }
        struct SingleColumnBrowseResultsRenderer: Codable {
            let tabs:[Tab]?
            enum CodingKeys: String, CodingKey {
                case tabs = "tabs"
            }
            init(from decoder: Decoder) throws {
                let values = try decoder.container(keyedBy: CodingKeys.self)
                tabs = try values.decodeIfPresent([Tab].self, forKey: .tabs)
            }
            struct Tab:Codable {
                let tabRenderer:TabRenderer?
                enum CodingKeys: String, CodingKey {
                    case tabRenderer = "tabRenderer"
                }
                init(from decoder: Decoder) throws {
                    let values = try decoder.container(keyedBy: CodingKeys.self)
                    tabRenderer = try values.decodeIfPresent(TabRenderer.self, forKey: .tabRenderer)
                }
                struct TabRenderer: Codable {
                    let content:Content?
                    enum CodingKeys: String, CodingKey {
                        case content = "content"
                    }
                    init(from decoder: Decoder) throws {
                        let values = try decoder.container(keyedBy: CodingKeys.self)
                        content = try values.decodeIfPresent(Content.self, forKey: .content)
                    }
                    struct Content: Codable {
                        let sectionListRenderer:SectionListRenderer?
                        enum CodingKeys: String, CodingKey {
                            case sectionListRenderer = "sectionListRenderer"
                        }
                        init(from decoder: Decoder) throws {
                            let values = try decoder.container(keyedBy: CodingKeys.self)
                            sectionListRenderer = try values.decodeIfPresent(SectionListRenderer.self, forKey: .sectionListRenderer)
                        }
                        struct SectionListRenderer: Codable {
                            let contents:[Content]?
                            enum CodingKeys: String, CodingKey {
                                case contents = "contents"
                            }
                            init(from decoder: Decoder) throws {
                                let values = try decoder.container(keyedBy: CodingKeys.self)
                                contents = try values.decodeIfPresent([Content].self, forKey: .contents)
                            }
                            struct Content: Codable {
                                let gridRenderer:GridRenderer?
                                enum CodingKeys: String, CodingKey {
                                    case gridRenderer = "gridRenderer"
                                }
                                init(from decoder: Decoder) throws {
                                    let values = try decoder.container(keyedBy: CodingKeys.self)
                                    gridRenderer = try values.decodeIfPresent(GridRenderer.self, forKey: .gridRenderer)
                                }
                                struct GridRenderer: Codable {
                                    let items:[Item]?
                                    enum CodingKeys: String, CodingKey {
                                        case items = "items"
                                    }
                                    init(from decoder: Decoder) throws {
                                        let values = try decoder.container(keyedBy: CodingKeys.self)
                                        items = try values.decodeIfPresent([Item].self, forKey: .items)
                                    }
                                    struct Item: Codable {
                                        let musicNavigationButtonRenderer:MusicNavigationButtonRenderer?
                                        enum CodingKeys: String, CodingKey {
                                            case musicNavigationButtonRenderer = "musicNavigationButtonRenderer"
                                        }
                                        init(from decoder: Decoder) throws {
                                            let values = try decoder.container(keyedBy: CodingKeys.self)
                                            musicNavigationButtonRenderer = try values.decodeIfPresent(MusicNavigationButtonRenderer.self, forKey: .musicNavigationButtonRenderer)
                                        }
                                        struct MusicNavigationButtonRenderer: Codable {
                                            ///对应标题
                                            let buttonText:ButtonText?
                                            ///对应颜色
                                            let solid:Solid?
                                            ///点击事件
                                            let clickCommand:ClickCommand?
                                            enum CodingKeys: String, CodingKey {
                                                case buttonText = "buttonText"
                                                case solid = "solid"
                                                case clickCommand = "clickCommand"
                                            }
                                            init(from decoder: Decoder) throws {
                                                let values = try decoder.container(keyedBy: CodingKeys.self)
                                                buttonText = try values.decodeIfPresent(ButtonText.self, forKey: .buttonText)
                                                solid = try values.decodeIfPresent(Solid.self, forKey: .solid)
                                                clickCommand = try values.decodeIfPresent(ClickCommand.self, forKey: .clickCommand)
                                            }
                                            //对应标题
                                            struct ButtonText: Codable{
                                                //标题组
                                                let runs:[Run]?
                                                enum CodingKeys: String, CodingKey {
                                                    case runs = "runs"
                                                }
                                                init(from decoder: Decoder) throws {
                                                    let values = try decoder.container(keyedBy: CodingKeys.self)
                                                    runs = try values.decodeIfPresent([Run].self, forKey: .runs)
                                                }
                                                struct Run: Codable {
                                                    //标题文本
                                                    let text:String?
                                                    enum CodingKeys: String, CodingKey {
                                                        case text = "text"
                                                        
                                                    }
                                                    init(from decoder: Decoder) throws {
                                                        let values = try decoder.container(keyedBy: CodingKeys.self)
                                                        text = try values.decodeIfPresent(String.self, forKey: .text)
                                                    }
                                                }
                                            }
                                            //对应颜色
                                            struct Solid: Codable {
                                                ///颜色值
                                                let leftStripeColor:Int?
                                                enum CodingKeys: String, CodingKey {
                                                    case leftStripeColor = "leftStripeColor"
                                                }
                                                init(from decoder: Decoder) throws {
                                                    let values = try decoder.container(keyedBy: CodingKeys.self)
                                                    leftStripeColor = try values.decodeIfPresent(Int.self, forKey: .leftStripeColor)
                                                }
                                            }
                                            //对应事件
                                            struct ClickCommand: Codable {
                                                let browseEndpoint:BrowseEndpoint?
                                                enum CodingKeys: String, CodingKey {
                                                    case browseEndpoint = "browseEndpoint"
                                                }
                                                init(from decoder: Decoder) throws {
                                                    let values = try decoder.container(keyedBy: CodingKeys.self)
                                                    browseEndpoint = try values.decodeIfPresent(BrowseEndpoint.self, forKey: .browseEndpoint)
                                                }
                                                struct BrowseEndpoint: Codable {
                                                    let browseId:String?
                                                    let params:String?
                                                    enum CodingKeys: String, CodingKey {
                                                        case browseId = "browseId"
                                                        case params = "params"
                                                    }
                                                    init(from decoder: Decoder) throws {
                                                        let values = try decoder.container(keyedBy: CodingKeys.self)
                                                        browseId = try values.decodeIfPresent(String.self, forKey: .browseId)
                                                        params = try values.decodeIfPresent(String.self, forKey: .params)
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    struct Header: Codable {
        let musicHeaderRenderer:MusicHeaderRenderer?
        enum CodingKeys: String, CodingKey {
            case musicHeaderRenderer = "musicHeaderRenderer"
        }
        init(from decoder: Decoder) throws {
            let values = try decoder.container(keyedBy: CodingKeys.self)
            musicHeaderRenderer = try values.decodeIfPresent(MusicHeaderRenderer.self, forKey: .musicHeaderRenderer)
        }
        struct MusicHeaderRenderer: Codable {
            let title:Title?
            enum CodingKeys: String, CodingKey {
                case title = "title"
            }
            init(from decoder: Decoder) throws {
                let values = try decoder.container(keyedBy: CodingKeys.self)
                title = try values.decodeIfPresent(Title.self, forKey: .title)
            }
            struct Title: Codable {
                let runs:[Run]?
                enum CodingKeys: String, CodingKey {
                    case runs = "runs"
                }
                init(from decoder: Decoder) throws {
                    let values = try decoder.container(keyedBy: CodingKeys.self)
                    runs = try values.decodeIfPresent([Run].self, forKey: .runs)
                }
                struct Run: Codable {
                    let text:String?
                    enum CodingKeys: String, CodingKey {
                        case text = "text"
                    }
                    init(from decoder: Decoder) throws {
                        let values = try decoder.container(keyedBy: CodingKeys.self)
                        text = try values.decodeIfPresent(String.self, forKey: .text)
                    }
                }
            }
        }
    }
}
