// Copyright (c) 2016 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package zap

import (
	
	

	
)

// Array constructs a field with the given key and ArrayMarshaler. It provides
// a flexible, but still type-safe and efficient, way to add array-like types
// to the logging context. The struct's MarshalLogArray method is called lazily.
func ( string,  zapcore.ArrayMarshaler) Field {
	return Field{Key: , Type: zapcore.ArrayMarshalerType, Interface: }
}

// Bools constructs a field that carries a slice of bools.
func ( string,  []bool) Field {
	return Array(, bools())
}

// ByteStrings constructs a field that carries a slice of []byte, each of which
// must be UTF-8 encoded text.
func ( string,  [][]byte) Field {
	return Array(, byteStringsArray())
}

// Complex128s constructs a field that carries a slice of complex numbers.
func ( string,  []complex128) Field {
	return Array(, complex128s())
}

// Complex64s constructs a field that carries a slice of complex numbers.
func ( string,  []complex64) Field {
	return Array(, complex64s())
}

// Durations constructs a field that carries a slice of time.Durations.
func ( string,  []time.Duration) Field {
	return Array(, durations())
}

// Float64s constructs a field that carries a slice of floats.
func ( string,  []float64) Field {
	return Array(, float64s())
}

// Float32s constructs a field that carries a slice of floats.
func ( string,  []float32) Field {
	return Array(, float32s())
}

// Ints constructs a field that carries a slice of integers.
func ( string,  []int) Field {
	return Array(, ints())
}

// Int64s constructs a field that carries a slice of integers.
func ( string,  []int64) Field {
	return Array(, int64s())
}

// Int32s constructs a field that carries a slice of integers.
func ( string,  []int32) Field {
	return Array(, int32s())
}

// Int16s constructs a field that carries a slice of integers.
func ( string,  []int16) Field {
	return Array(, int16s())
}

// Int8s constructs a field that carries a slice of integers.
func ( string,  []int8) Field {
	return Array(, int8s())
}

// Objects constructs a field with the given key, holding a list of the
// provided objects that can be marshaled by Zap.
//
// Note that these objects must implement zapcore.ObjectMarshaler directly.
// That is, if you're trying to marshal a []Request, the MarshalLogObject
// method must be declared on the Request type, not its pointer (*Request).
// If it's on the pointer, use ObjectValues.
//
// Given an object that implements MarshalLogObject on the value receiver, you
// can log a slice of those objects with Objects like so:
//
//	type Author struct{ ... }
//	func (a Author) MarshalLogObject(enc zapcore.ObjectEncoder) error
//
//	var authors []Author = ...
//	logger.Info("loading article", zap.Objects("authors", authors))
//
// Similarly, given a type that implements MarshalLogObject on its pointer
// receiver, you can log a slice of pointers to that object with Objects like
// so:
//
//	type Request struct{ ... }
//	func (r *Request) MarshalLogObject(enc zapcore.ObjectEncoder) error
//
//	var requests []*Request = ...
//	logger.Info("sending requests", zap.Objects("requests", requests))
//
// If instead, you have a slice of values of such an object, use the
// ObjectValues constructor.
//
//	var requests []Request = ...
//	logger.Info("sending requests", zap.ObjectValues("requests", requests))
func [ zapcore.ObjectMarshaler]( string,  []) Field {
	return Array(, objects[]())
}

type objects[ zapcore.ObjectMarshaler] []

func ( objects[]) ( zapcore.ArrayEncoder) error {
	for ,  := range  {
		if  := .AppendObject();  != nil {
			return 
		}
	}
	return nil
}

// ObjectMarshalerPtr is a constraint that specifies that the given type
// implements zapcore.ObjectMarshaler on a pointer receiver.
type ObjectMarshalerPtr[ any] interface {
	*
	zapcore.ObjectMarshaler
}

// ObjectValues constructs a field with the given key, holding a list of the
// provided objects, where pointers to these objects can be marshaled by Zap.
//
// Note that pointers to these objects must implement zapcore.ObjectMarshaler.
// That is, if you're trying to marshal a []Request, the MarshalLogObject
// method must be declared on the *Request type, not the value (Request).
// If it's on the value, use Objects.
//
// Given an object that implements MarshalLogObject on the pointer receiver,
// you can log a slice of those objects with ObjectValues like so:
//
//	type Request struct{ ... }
//	func (r *Request) MarshalLogObject(enc zapcore.ObjectEncoder) error
//
//	var requests []Request = ...
//	logger.Info("sending requests", zap.ObjectValues("requests", requests))
//
// If instead, you have a slice of pointers of such an object, use the Objects
// field constructor.
//
//	var requests []*Request = ...
//	logger.Info("sending requests", zap.Objects("requests", requests))
func [ any,  ObjectMarshalerPtr[]]( string,  []) Field {
	return Array(, objectValues[, ]())
}

type objectValues[ any,  ObjectMarshalerPtr[]] []

func ( objectValues[, ]) ( zapcore.ArrayEncoder) error {
	for  := range  {
		// It is necessary for us to explicitly reference the "P" type.
		// We cannot simply pass "&os[i]" to AppendObject because its type
		// is "*T", which the type system does not consider as
		// implementing ObjectMarshaler.
		// Only the type "P" satisfies ObjectMarshaler, which we have
		// to convert "*T" to explicitly.
		var   = &[]
		if  := .AppendObject();  != nil {
			return 
		}
	}
	return nil
}

// Strings constructs a field that carries a slice of strings.
func ( string,  []string) Field {
	return Array(, stringArray())
}

// Stringers constructs a field with the given key, holding a list of the
// output provided by the value's String method
//
// Given an object that implements String on the value receiver, you
// can log a slice of those objects with Objects like so:
//
//	type Request struct{ ... }
//	func (a Request) String() string
//
//	var requests []Request = ...
//	logger.Info("sending requests", zap.Stringers("requests", requests))
//
// Note that these objects must implement fmt.Stringer directly.
// That is, if you're trying to marshal a []Request, the String method
// must be declared on the Request type, not its pointer (*Request).
func [ fmt.Stringer]( string,  []) Field {
	return Array(, stringers[]())
}

type stringers[ fmt.Stringer] []

func ( stringers[]) ( zapcore.ArrayEncoder) error {
	for ,  := range  {
		.AppendString(.String())
	}
	return nil
}

// Times constructs a field that carries a slice of time.Times.
func ( string,  []time.Time) Field {
	return Array(, times())
}

// Uints constructs a field that carries a slice of unsigned integers.
func ( string,  []uint) Field {
	return Array(, uints())
}

// Uint64s constructs a field that carries a slice of unsigned integers.
func ( string,  []uint64) Field {
	return Array(, uint64s())
}

// Uint32s constructs a field that carries a slice of unsigned integers.
func ( string,  []uint32) Field {
	return Array(, uint32s())
}

// Uint16s constructs a field that carries a slice of unsigned integers.
func ( string,  []uint16) Field {
	return Array(, uint16s())
}

// Uint8s constructs a field that carries a slice of unsigned integers.
func ( string,  []uint8) Field {
	return Array(, uint8s())
}

// Uintptrs constructs a field that carries a slice of pointer addresses.
func ( string,  []uintptr) Field {
	return Array(, uintptrs())
}

// Errors constructs a field that carries a slice of errors.
func ( string,  []error) Field {
	return Array(, errArray())
}

type bools []bool

func ( bools) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendBool([])
	}
	return nil
}

type byteStringsArray [][]byte

func ( byteStringsArray) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendByteString([])
	}
	return nil
}

type complex128s []complex128

func ( complex128s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendComplex128([])
	}
	return nil
}

type complex64s []complex64

func ( complex64s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendComplex64([])
	}
	return nil
}

type durations []time.Duration

func ( durations) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendDuration([])
	}
	return nil
}

type float64s []float64

func ( float64s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendFloat64([])
	}
	return nil
}

type float32s []float32

func ( float32s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendFloat32([])
	}
	return nil
}

type ints []int

func ( ints) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendInt([])
	}
	return nil
}

type int64s []int64

func ( int64s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendInt64([])
	}
	return nil
}

type int32s []int32

func ( int32s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendInt32([])
	}
	return nil
}

type int16s []int16

func ( int16s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendInt16([])
	}
	return nil
}

type int8s []int8

func ( int8s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendInt8([])
	}
	return nil
}

type stringArray []string

func ( stringArray) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendString([])
	}
	return nil
}

type times []time.Time

func ( times) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendTime([])
	}
	return nil
}

type uints []uint

func ( uints) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendUint([])
	}
	return nil
}

type uint64s []uint64

func ( uint64s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendUint64([])
	}
	return nil
}

type uint32s []uint32

func ( uint32s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendUint32([])
	}
	return nil
}

type uint16s []uint16

func ( uint16s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendUint16([])
	}
	return nil
}

type uint8s []uint8

func ( uint8s) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendUint8([])
	}
	return nil
}

type uintptrs []uintptr

func ( uintptrs) ( zapcore.ArrayEncoder) error {
	for  := range  {
		.AppendUintptr([])
	}
	return nil
}