// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package slog

import (
	
	
)

// An Attr is a key-value pair.
type Attr struct {
	Key   string
	Value Value
}

// String returns an Attr for a string value.
func (,  string) Attr {
	return Attr{, StringValue()}
}

// Int64 returns an Attr for an int64.
func ( string,  int64) Attr {
	return Attr{, Int64Value()}
}

// Int converts an int to an int64 and returns
// an Attr with that value.
func ( string,  int) Attr {
	return Int64(, int64())
}

// Uint64 returns an Attr for a uint64.
func ( string,  uint64) Attr {
	return Attr{, Uint64Value()}
}

// Float64 returns an Attr for a floating-point number.
func ( string,  float64) Attr {
	return Attr{, Float64Value()}
}

// Bool returns an Attr for a bool.
func ( string,  bool) Attr {
	return Attr{, BoolValue()}
}

// Time returns an Attr for a [time.Time].
// It discards the monotonic portion.
func ( string,  time.Time) Attr {
	return Attr{, TimeValue()}
}

// Duration returns an Attr for a [time.Duration].
func ( string,  time.Duration) Attr {
	return Attr{, DurationValue()}
}

// Group returns an Attr for a Group [Value].
// The first argument is the key; the remaining arguments
// are converted to Attrs as in [Logger.Log].
//
// Use Group to collect several key-value pairs under a single
// key on a log line, or as the result of LogValue
// in order to log a single value as multiple Attrs.
func ( string,  ...any) Attr {
	return Attr{, GroupValue(argsToAttrSlice()...)}
}

func argsToAttrSlice( []any) []Attr {
	var (
		  Attr
		 []Attr
	)
	for len() > 0 {
		,  = argsToAttr()
		 = append(, )
	}
	return 
}

// Any returns an Attr for the supplied value.
// See [AnyValue] for how values are treated.
func ( string,  any) Attr {
	return Attr{, AnyValue()}
}

// Equal reports whether a and b have equal keys and values.
func ( Attr) ( Attr) bool {
	return .Key == .Key && .Value.Equal(.Value)
}

func ( Attr) () string {
	return fmt.Sprintf("%s=%s", .Key, .Value)
}

// isEmpty reports whether a has an empty key and a nil value.
// That can be written as Attr{} or Any("", nil).
func ( Attr) () bool {
	return .Key == "" && .Value.num == 0 && .Value.any == nil
}