// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.

package server

import (
	json "encoding/json"
	config "github.com/khlieng/dispatch/config"
	storage "github.com/khlieng/dispatch/storage"
	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 easyjson7e607aefDecodeGithubComKhliengDispatchServer(in *jlexer.Lexer, out *indexData) {
	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 "defaults":
			if in.IsNull() {
				in.Skip()
				out.Defaults = nil
			} else {
				if out.Defaults == nil {
					out.Defaults = new(config.Defaults)
				}
				easyjson7e607aefDecodeGithubComKhliengDispatchConfig(in, &*out.Defaults)
			}
		case "servers":
			if in.IsNull() {
				in.Skip()
				out.Servers = nil
			} else {
				in.Delim('[')
				if out.Servers == nil {
					if !in.IsDelim(']') {
						out.Servers = make([]Server, 0, 1)
					} else {
						out.Servers = []Server{}
					}
				} else {
					out.Servers = (out.Servers)[:0]
				}
				for !in.IsDelim(']') {
					var v1 Server
					if data := in.Raw(); in.Ok() {
						in.AddError((v1).UnmarshalJSON(data))
					}
					out.Servers = append(out.Servers, v1)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "channels":
			if in.IsNull() {
				in.Skip()
				out.Channels = nil
			} else {
				in.Delim('[')
				if out.Channels == nil {
					if !in.IsDelim(']') {
						out.Channels = make([]*storage.Channel, 0, 8)
					} else {
						out.Channels = []*storage.Channel{}
					}
				} else {
					out.Channels = (out.Channels)[:0]
				}
				for !in.IsDelim(']') {
					var v2 *storage.Channel
					if in.IsNull() {
						in.Skip()
						v2 = nil
					} else {
						if v2 == nil {
							v2 = new(storage.Channel)
						}
						easyjson7e607aefDecodeGithubComKhliengDispatchStorage(in, &*v2)
					}
					out.Channels = append(out.Channels, v2)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "hexIP":
			out.HexIP = bool(in.Bool())
		case "version":
			if data := in.Raw(); in.Ok() {
				in.AddError((out.Version).UnmarshalJSON(data))
			}
		case "settings":
			if in.IsNull() {
				in.Skip()
				out.Settings = nil
			} else {
				if out.Settings == nil {
					out.Settings = new(storage.ClientSettings)
				}
				if data := in.Raw(); in.Ok() {
					in.AddError((*out.Settings).UnmarshalJSON(data))
				}
			}
		case "users":
			if in.IsNull() {
				in.Skip()
				out.Users = nil
			} else {
				if out.Users == nil {
					out.Users = new(Userlist)
				}
				if data := in.Raw(); in.Ok() {
					in.AddError((*out.Users).UnmarshalJSON(data))
				}
			}
		case "messages":
			if in.IsNull() {
				in.Skip()
				out.Messages = nil
			} else {
				if out.Messages == nil {
					out.Messages = new(Messages)
				}
				if data := in.Raw(); in.Ok() {
					in.AddError((*out.Messages).UnmarshalJSON(data))
				}
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson7e607aefEncodeGithubComKhliengDispatchServer(out *jwriter.Writer, in indexData) {
	out.RawByte('{')
	first := true
	_ = first
	if in.Defaults != nil {
		const prefix string = ",\"defaults\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		easyjson7e607aefEncodeGithubComKhliengDispatchConfig(out, *in.Defaults)
	}
	if len(in.Servers) != 0 {
		const prefix string = ",\"servers\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v3, v4 := range in.Servers {
				if v3 > 0 {
					out.RawByte(',')
				}
				out.Raw((v4).MarshalJSON())
			}
			out.RawByte(']')
		}
	}
	if len(in.Channels) != 0 {
		const prefix string = ",\"channels\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v5, v6 := range in.Channels {
				if v5 > 0 {
					out.RawByte(',')
				}
				if v6 == nil {
					out.RawString("null")
				} else {
					easyjson7e607aefEncodeGithubComKhliengDispatchStorage(out, *v6)
				}
			}
			out.RawByte(']')
		}
	}
	if in.HexIP {
		const prefix string = ",\"hexIP\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.HexIP))
	}
	if true {
		const prefix string = ",\"version\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Raw((in.Version).MarshalJSON())
	}
	if in.Settings != nil {
		const prefix string = ",\"settings\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Raw((*in.Settings).MarshalJSON())
	}
	if in.Users != nil {
		const prefix string = ",\"users\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Raw((*in.Users).MarshalJSON())
	}
	if in.Messages != nil {
		const prefix string = ",\"messages\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Raw((*in.Messages).MarshalJSON())
	}
	out.RawByte('}')
}

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

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

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

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *indexData) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson7e607aefDecodeGithubComKhliengDispatchServer(l, v)
}
func easyjson7e607aefDecodeGithubComKhliengDispatchStorage(in *jlexer.Lexer, out *storage.Channel) {
	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 "server":
			out.Server = string(in.String())
		case "name":
			out.Name = string(in.String())
		case "topic":
			out.Topic = string(in.String())
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson7e607aefEncodeGithubComKhliengDispatchStorage(out *jwriter.Writer, in storage.Channel) {
	out.RawByte('{')
	first := true
	_ = first
	if in.Server != "" {
		const prefix string = ",\"server\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Server))
	}
	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.Topic != "" {
		const prefix string = ",\"topic\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Topic))
	}
	out.RawByte('}')
}
func easyjson7e607aefDecodeGithubComKhliengDispatchConfig(in *jlexer.Lexer, out *config.Defaults) {
	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 "name":
			out.Name = string(in.String())
		case "host":
			out.Host = string(in.String())
		case "port":
			out.Port = int(in.Int())
		case "channels":
			if in.IsNull() {
				in.Skip()
				out.Channels = nil
			} else {
				in.Delim('[')
				if out.Channels == nil {
					if !in.IsDelim(']') {
						out.Channels = make([]string, 0, 4)
					} else {
						out.Channels = []string{}
					}
				} else {
					out.Channels = (out.Channels)[:0]
				}
				for !in.IsDelim(']') {
					var v7 string
					v7 = string(in.String())
					out.Channels = append(out.Channels, v7)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "password":
			out.Password = string(in.String())
		case "ssl":
			out.SSL = bool(in.Bool())
		case "readOnly":
			out.ReadOnly = bool(in.Bool())
		case "showDetails":
			out.ShowDetails = bool(in.Bool())
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson7e607aefEncodeGithubComKhliengDispatchConfig(out *jwriter.Writer, in config.Defaults) {
	out.RawByte('{')
	first := true
	_ = first
	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.Host != "" {
		const prefix string = ",\"host\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Host))
	}
	if in.Port != 0 {
		const prefix string = ",\"port\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Int(int(in.Port))
	}
	if len(in.Channels) != 0 {
		const prefix string = ",\"channels\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v8, v9 := range in.Channels {
				if v8 > 0 {
					out.RawByte(',')
				}
				out.String(string(v9))
			}
			out.RawByte(']')
		}
	}
	if in.Password != "" {
		const prefix string = ",\"password\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Password))
	}
	if in.SSL {
		const prefix string = ",\"ssl\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.SSL))
	}
	if in.ReadOnly {
		const prefix string = ",\"readOnly\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.ReadOnly))
	}
	if in.ShowDetails {
		const prefix string = ",\"showDetails\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.ShowDetails))
	}
	out.RawByte('}')
}
func easyjson7e607aefDecodeGithubComKhliengDispatchServer1(in *jlexer.Lexer, out *dispatchVersion) {
	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 "tag":
			out.Tag = string(in.String())
		case "commit":
			out.Commit = string(in.String())
		case "date":
			out.Date = string(in.String())
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson7e607aefEncodeGithubComKhliengDispatchServer1(out *jwriter.Writer, in dispatchVersion) {
	out.RawByte('{')
	first := true
	_ = first
	if in.Tag != "" {
		const prefix string = ",\"tag\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Tag))
	}
	if in.Commit != "" {
		const prefix string = ",\"commit\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Commit))
	}
	if in.Date != "" {
		const prefix string = ",\"date\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Date))
	}
	out.RawByte('}')
}

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

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

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

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *dispatchVersion) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson7e607aefDecodeGithubComKhliengDispatchServer1(l, v)
}
func easyjson7e607aefDecodeGithubComKhliengDispatchServer2(in *jlexer.Lexer, out *connectDefaults) {
	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 "name":
			out.Name = string(in.String())
		case "host":
			out.Host = string(in.String())
		case "port":
			out.Port = int(in.Int())
		case "channels":
			if in.IsNull() {
				in.Skip()
				out.Channels = nil
			} else {
				in.Delim('[')
				if out.Channels == nil {
					if !in.IsDelim(']') {
						out.Channels = make([]string, 0, 4)
					} else {
						out.Channels = []string{}
					}
				} else {
					out.Channels = (out.Channels)[:0]
				}
				for !in.IsDelim(']') {
					var v10 string
					v10 = string(in.String())
					out.Channels = append(out.Channels, v10)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "password":
			out.Password = bool(in.Bool())
		case "ssl":
			out.SSL = bool(in.Bool())
		case "readOnly":
			out.ReadOnly = bool(in.Bool())
		case "showDetails":
			out.ShowDetails = bool(in.Bool())
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson7e607aefEncodeGithubComKhliengDispatchServer2(out *jwriter.Writer, in connectDefaults) {
	out.RawByte('{')
	first := true
	_ = first
	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.Host != "" {
		const prefix string = ",\"host\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Host))
	}
	if in.Port != 0 {
		const prefix string = ",\"port\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Int(int(in.Port))
	}
	if len(in.Channels) != 0 {
		const prefix string = ",\"channels\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('[')
			for v11, v12 := range in.Channels {
				if v11 > 0 {
					out.RawByte(',')
				}
				out.String(string(v12))
			}
			out.RawByte(']')
		}
	}
	if in.Password {
		const prefix string = ",\"password\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.Password))
	}
	if in.SSL {
		const prefix string = ",\"ssl\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.SSL))
	}
	if in.ReadOnly {
		const prefix string = ",\"readOnly\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.ReadOnly))
	}
	if in.ShowDetails {
		const prefix string = ",\"showDetails\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.ShowDetails))
	}
	out.RawByte('}')
}

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

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

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

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