package esi

import (
	json "encoding/json"

	easyjson "github.com/mailru/easyjson"
	jlexer "github.com/mailru/easyjson/jlexer"
	jwriter "github.com/mailru/easyjson/jwriter"
)

var (
	_ *json.RawMessage
	_ *jlexer.Lexer
	_ *jwriter.Writer
	_ easyjson.Marshaler
)

func easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi(in *jlexer.Lexer, out *GetCharactersCharacterIdChatChannels200OkList) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		in.Skip()
		*out = nil
	} else {
		in.Delim('[')
		if *out == nil {
			if !in.IsDelim(']') {
				*out = make(GetCharactersCharacterIdChatChannels200OkList, 0, 1)
			} else {
				*out = GetCharactersCharacterIdChatChannels200OkList{}
			}
		} else {
			*out = (*out)[:0]
		}
		for !in.IsDelim(']') {
			var v1 GetCharactersCharacterIdChatChannels200Ok
			(v1).UnmarshalEasyJSON(in)
			*out = append(*out, v1)
			in.WantComma()
		}
		in.Delim(']')
	}
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi(out *jwriter.Writer, in GetCharactersCharacterIdChatChannels200OkList) {
	if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
		out.RawString("null")
	} else {
		out.RawByte('[')
		for v2, v3 := range in {
			if v2 > 0 {
				out.RawByte(',')
			}
			(v3).MarshalEasyJSON(out)
		}
		out.RawByte(']')
	}
}

func (v GetCharactersCharacterIdChatChannels200OkList) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

func (v GetCharactersCharacterIdChatChannels200OkList) MarshalEasyJSON(w *jwriter.Writer) {
	easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi(w, v)
}

func (v *GetCharactersCharacterIdChatChannels200OkList) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi(&r, v)
	return r.Error()
}

func (v *GetCharactersCharacterIdChatChannels200OkList) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi(l, v)
}
func easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi1(in *jlexer.Lexer, out *GetCharactersCharacterIdChatChannels200Ok) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeString()
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "channel_id":
			out.ChannelId = int32(in.Int32())
		case "name":
			out.Name = string(in.String())
		case "owner_id":
			out.OwnerId = int32(in.Int32())
		case "comparison_key":
			out.ComparisonKey = string(in.String())
		case "has_password":
			out.HasPassword = bool(in.Bool())
		case "motd":
			out.Motd = string(in.String())
		case "allowed":
			if in.IsNull() {
				in.Skip()
				out.Allowed = nil
			} else {
				in.Delim('[')
				if out.Allowed == nil {
					if !in.IsDelim(']') {
						out.Allowed = make([]GetCharactersCharacterIdChatChannelsAllowed, 0, 2)
					} else {
						out.Allowed = []GetCharactersCharacterIdChatChannelsAllowed{}
					}
				} else {
					out.Allowed = (out.Allowed)[:0]
				}
				for !in.IsDelim(']') {
					var v4 GetCharactersCharacterIdChatChannelsAllowed
					(v4).UnmarshalEasyJSON(in)
					out.Allowed = append(out.Allowed, v4)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "operators":
			if in.IsNull() {
				in.Skip()
				out.Operators = nil
			} else {
				in.Delim('[')
				if out.Operators == nil {
					if !in.IsDelim(']') {
						out.Operators = make([]GetCharactersCharacterIdChatChannelsOperator, 0, 2)
					} else {
						out.Operators = []GetCharactersCharacterIdChatChannelsOperator{}
					}
				} else {
					out.Operators = (out.Operators)[:0]
				}
				for !in.IsDelim(']') {
					var v5 GetCharactersCharacterIdChatChannelsOperator
					(v5).UnmarshalEasyJSON(in)
					out.Operators = append(out.Operators, v5)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "blocked":
			if in.IsNull() {
				in.Skip()
				out.Blocked = nil
			} else {
				in.Delim('[')
				if out.Blocked == nil {
					if !in.IsDelim(']') {
						out.Blocked = make([]GetCharactersCharacterIdChatChannelsBlocked, 0, 1)
					} else {
						out.Blocked = []GetCharactersCharacterIdChatChannelsBlocked{}
					}
				} else {
					out.Blocked = (out.Blocked)[:0]
				}
				for !in.IsDelim(']') {
					var v6 GetCharactersCharacterIdChatChannelsBlocked
					(v6).UnmarshalEasyJSON(in)
					out.Blocked = append(out.Blocked, v6)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "muted":
			if in.IsNull() {
				in.Skip()
				out.Muted = nil
			} else {
				in.Delim('[')
				if out.Muted == nil {
					if !in.IsDelim(']') {
						out.Muted = make([]GetCharactersCharacterIdChatChannelsMuted, 0, 1)
					} else {
						out.Muted = []GetCharactersCharacterIdChatChannelsMuted{}
					}
				} else {
					out.Muted = (out.Muted)[:0]
				}
				for !in.IsDelim(']') {
					var v7 GetCharactersCharacterIdChatChannelsMuted
					(v7).UnmarshalEasyJSON(in)
					out.Muted = append(out.Muted, v7)
					in.WantComma()
				}
				in.Delim(']')
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi1(out *jwriter.Writer, in GetCharactersCharacterIdChatChannels200Ok) {
	out.RawByte('{')
	first := true
	_ = first
	if in.ChannelId != 0 {
		const prefix string = ",\"channel_id\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Int32(int32(in.ChannelId))
	}
	if in.Name != "" {
		const prefix string = ",\"name\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Name))
	}
	if in.OwnerId != 0 {
		const prefix string = ",\"owner_id\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Int32(int32(in.OwnerId))
	}
	if in.ComparisonKey != "" {
		const prefix string = ",\"comparison_key\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.ComparisonKey))
	}
	if in.HasPassword {
		const prefix string = ",\"has_password\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.HasPassword))
	}
	if in.Motd != "" {
		const prefix string = ",\"motd\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Motd))
	}
	if len(in.Allowed) != 0 {
		const prefix string = ",\"allowed\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v8, v9 := range in.Allowed {
				if v8 > 0 {
					out.RawByte(',')
				}
				(v9).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	if len(in.Operators) != 0 {
		const prefix string = ",\"operators\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v10, v11 := range in.Operators {
				if v10 > 0 {
					out.RawByte(',')
				}
				(v11).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	if len(in.Blocked) != 0 {
		const prefix string = ",\"blocked\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v12, v13 := range in.Blocked {
				if v12 > 0 {
					out.RawByte(',')
				}
				(v13).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	if len(in.Muted) != 0 {
		const prefix string = ",\"muted\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v14, v15 := range in.Muted {
				if v14 > 0 {
					out.RawByte(',')
				}
				(v15).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	out.RawByte('}')
}

func (v GetCharactersCharacterIdChatChannels200Ok) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi1(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

func (v GetCharactersCharacterIdChatChannels200Ok) MarshalEasyJSON(w *jwriter.Writer) {
	easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi1(w, v)
}

func (v *GetCharactersCharacterIdChatChannels200Ok) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi1(&r, v)
	return r.Error()
}

func (v *GetCharactersCharacterIdChatChannels200Ok) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi1(l, v)
}
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.

package esi

import (
	json "encoding/json"

	easyjson "github.com/mailru/easyjson"
	jlexer "github.com/mailru/easyjson/jlexer"
	jwriter "github.com/mailru/easyjson/jwriter"
)

// suppress unused package warning
var (
	_ *json.RawMessage
	_ *jlexer.Lexer
	_ *jwriter.Writer
	_ easyjson.Marshaler
)

func easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi(in *jlexer.Lexer, out *GetCharactersCharacterIdChatChannels200OkList) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		in.Skip()
		*out = nil
	} else {
		in.Delim('[')
		if *out == nil {
			if !in.IsDelim(']') {
				*out = make(GetCharactersCharacterIdChatChannels200OkList, 0, 1)
			} else {
				*out = GetCharactersCharacterIdChatChannels200OkList{}
			}
		} else {
			*out = (*out)[:0]
		}
		for !in.IsDelim(']') {
			var v1 GetCharactersCharacterIdChatChannels200Ok
			(v1).UnmarshalEasyJSON(in)
			*out = append(*out, v1)
			in.WantComma()
		}
		in.Delim(']')
	}
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi(out *jwriter.Writer, in GetCharactersCharacterIdChatChannels200OkList) {
	if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
		out.RawString("null")
	} else {
		out.RawByte('[')
		for v2, v3 := range in {
			if v2 > 0 {
				out.RawByte(',')
			}
			(v3).MarshalEasyJSON(out)
		}
		out.RawByte(']')
	}
}

// MarshalJSON supports json.Marshaler interface
func (v GetCharactersCharacterIdChatChannels200OkList) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetCharactersCharacterIdChatChannels200OkList) MarshalEasyJSON(w *jwriter.Writer) {
	easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetCharactersCharacterIdChatChannels200OkList) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetCharactersCharacterIdChatChannels200OkList) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi(l, v)
}
func easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi1(in *jlexer.Lexer, out *GetCharactersCharacterIdChatChannels200Ok) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeString()
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "channel_id":
			out.ChannelId = int32(in.Int32())
		case "name":
			out.Name = string(in.String())
		case "owner_id":
			out.OwnerId = int32(in.Int32())
		case "comparison_key":
			out.ComparisonKey = string(in.String())
		case "has_password":
			out.HasPassword = bool(in.Bool())
		case "motd":
			out.Motd = string(in.String())
		case "allowed":
			if in.IsNull() {
				in.Skip()
				out.Allowed = nil
			} else {
				in.Delim('[')
				if out.Allowed == nil {
					if !in.IsDelim(']') {
						out.Allowed = make([]GetCharactersCharacterIdChatChannelsAllowed, 0, 2)
					} else {
						out.Allowed = []GetCharactersCharacterIdChatChannelsAllowed{}
					}
				} else {
					out.Allowed = (out.Allowed)[:0]
				}
				for !in.IsDelim(']') {
					var v4 GetCharactersCharacterIdChatChannelsAllowed
					(v4).UnmarshalEasyJSON(in)
					out.Allowed = append(out.Allowed, v4)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "operators":
			if in.IsNull() {
				in.Skip()
				out.Operators = nil
			} else {
				in.Delim('[')
				if out.Operators == nil {
					if !in.IsDelim(']') {
						out.Operators = make([]GetCharactersCharacterIdChatChannelsOperator, 0, 2)
					} else {
						out.Operators = []GetCharactersCharacterIdChatChannelsOperator{}
					}
				} else {
					out.Operators = (out.Operators)[:0]
				}
				for !in.IsDelim(']') {
					var v5 GetCharactersCharacterIdChatChannelsOperator
					(v5).UnmarshalEasyJSON(in)
					out.Operators = append(out.Operators, v5)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "blocked":
			if in.IsNull() {
				in.Skip()
				out.Blocked = nil
			} else {
				in.Delim('[')
				if out.Blocked == nil {
					if !in.IsDelim(']') {
						out.Blocked = make([]GetCharactersCharacterIdChatChannelsBlocked, 0, 1)
					} else {
						out.Blocked = []GetCharactersCharacterIdChatChannelsBlocked{}
					}
				} else {
					out.Blocked = (out.Blocked)[:0]
				}
				for !in.IsDelim(']') {
					var v6 GetCharactersCharacterIdChatChannelsBlocked
					(v6).UnmarshalEasyJSON(in)
					out.Blocked = append(out.Blocked, v6)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "muted":
			if in.IsNull() {
				in.Skip()
				out.Muted = nil
			} else {
				in.Delim('[')
				if out.Muted == nil {
					if !in.IsDelim(']') {
						out.Muted = make([]GetCharactersCharacterIdChatChannelsMuted, 0, 1)
					} else {
						out.Muted = []GetCharactersCharacterIdChatChannelsMuted{}
					}
				} else {
					out.Muted = (out.Muted)[:0]
				}
				for !in.IsDelim(']') {
					var v7 GetCharactersCharacterIdChatChannelsMuted
					(v7).UnmarshalEasyJSON(in)
					out.Muted = append(out.Muted, v7)
					in.WantComma()
				}
				in.Delim(']')
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi1(out *jwriter.Writer, in GetCharactersCharacterIdChatChannels200Ok) {
	out.RawByte('{')
	first := true
	_ = first
	if in.ChannelId != 0 {
		const prefix string = ",\"channel_id\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Int32(int32(in.ChannelId))
	}
	if in.Name != "" {
		const prefix string = ",\"name\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Name))
	}
	if in.OwnerId != 0 {
		const prefix string = ",\"owner_id\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Int32(int32(in.OwnerId))
	}
	if in.ComparisonKey != "" {
		const prefix string = ",\"comparison_key\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.ComparisonKey))
	}
	if in.HasPassword {
		const prefix string = ",\"has_password\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.HasPassword))
	}
	if in.Motd != "" {
		const prefix string = ",\"motd\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Motd))
	}
	if len(in.Allowed) != 0 {
		const prefix string = ",\"allowed\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v8, v9 := range in.Allowed {
				if v8 > 0 {
					out.RawByte(',')
				}
				(v9).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	if len(in.Operators) != 0 {
		const prefix string = ",\"operators\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v10, v11 := range in.Operators {
				if v10 > 0 {
					out.RawByte(',')
				}
				(v11).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	if len(in.Blocked) != 0 {
		const prefix string = ",\"blocked\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v12, v13 := range in.Blocked {
				if v12 > 0 {
					out.RawByte(',')
				}
				(v13).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	if len(in.Muted) != 0 {
		const prefix string = ",\"muted\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v14, v15 := range in.Muted {
				if v14 > 0 {
					out.RawByte(',')
				}
				(v15).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	out.RawByte('}')
}

// MarshalJSON supports json.Marshaler interface
func (v GetCharactersCharacterIdChatChannels200Ok) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi1(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetCharactersCharacterIdChatChannels200Ok) MarshalEasyJSON(w *jwriter.Writer) {
	easyjson15e3e24fEncodeGithubComAntihaxGoesiEsi1(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetCharactersCharacterIdChatChannels200Ok) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi1(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetCharactersCharacterIdChatChannels200Ok) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson15e3e24fDecodeGithubComAntihaxGoesiEsi1(l, v)
}
