package decoder

import (
	
	
	
	
	

	
	
	
)

// The values of a stream of the semantics of encoding/json/v2, which the v2 json package decodes by UnmarshalRead. A
// value which the buffer holds whole is decoded by the decoders of v2, as Unmarshal decodes it, and an object or an
// array which it doesn't is decoded element by element, as Stream.Decode does for v1 ( see stream_elements.go ), by
// the rules of v2: the decoding stops at the first error, the names of an object are matched and checked as the
// decoders of v2 do, a value of a type which a method or a function reads whole is read whole, as encoding/json/v2
// reads it, and a method or a function which reads a jsontext.Decoder is given one which reads on from the reader of
// the stream. The strings are copied out of the buffer, as Unmarshal copies them out of its input, so that the buffer
// is reused.
//
// The objects and the arrays which a value is decoded element by element in are the path of the call ( see
// V2Call.Path ), which the v2 json package finds the place of an error with: the innermost function records the part
// of the buffer to read again ( see StreamPlace ), from the end of the token before the member, the element or the
// value which failed. That token, a delimiter or the bracket which begins the level, is kept in the buffer until the
// value after it is decoded, or begins to be decoded element by element: a decoder is attached at it, and the place
// of an error found again from it.

// streamsV2 are the streams of the calls of the v2 json package, which keep their buffers and their contexts.
var streamsV2 = sync.Pool{New: func() any { return NewStreamV2() }}

// NewStreamV2 returns a new stream for the decodings of v2, which a pool keeps: its context has the decoders of the
// types decoded last, as a context of the pool of the contexts has them ( see RuntimeContext.recentDecoders ).
func () *Stream {
	 := NewStream(nil)
	.ctx.recentDecoders = &[recentDecoderSets]recentDecoderSet{}
	return 
}

// maxReusedStreamBuffer is the size of the largest buffer which a stream of the pool keeps: one which grew for a long
// token or a value read whole is dropped.
const maxReusedStreamBuffer = 4 * (initBufSize + bufPadding)

// TakeStreamV2 returns a stream which reads r, for a decoding of v2 by the state of the call of its context ( see
// RuntimeContext.V2Call ), whose path is the top level.
func ( io.Reader) *Stream {
	 := streamsV2.Get().(*Stream)
	.BeginV2()
	return 
}

// BeginV2 makes the stream, which has no reader ( see EndV2 ), read r, for a decoding of v2 by the state of the
// call of its context, whose path is the top level.
func ( *Stream) ( io.Reader) {
	.r = 
	 := .ctx.V2Call()
	.Stream = 
	.Path = append(.Path[:0], textcoder.Level{})
	.pathNames = append(.pathNames[:0], namePlace{})
}

// BeginV2At is BeginV2 for a value at the place levels, whose names are its own, which are made the path of the
// call of the stream, without a copy ( see SetPath ). It returns the path the call had, whose arrays the caller
// keeps for its next levels.
func ( *Stream) ( io.Reader,  []textcoder.Level) []textcoder.Level {
	.r = 
	 := .ctx.V2Call()
	.Stream = 
	 := .Path
	.Path = 
	.clearPathNames()
	return 
}

// viewedInput is the source of a stream which reads in place an input which is whole ( see ViewV2 ).
var viewedInput byte

// ViewV2 makes the stream, which BeginV2At began, read in place in, a whole input, which has a nul byte after it, from
// the offset base of the whole input: it reads nothing more, and its buffer is its own again after EndV2. A caller
// which decodes a value of in whole, as decodeWholeV2 decodes the value of a stream, sets the stream at the value
// ( see LendAt ), so that a method or a function of the value finds its place by the stream.
func ( *Stream) ( []byte,  int64) {
	.src, .own = unsafe.Pointer(&viewedInput), .buf
	.buf, .offset, .length = , , int64(len())-1
	.readErr = io.EOF
}

// The room which a jsontext.Decoder leaves after its input for a stream which reads its buffer in place is the
// padding of the buffer of a stream ( see textcoder.InputRoom ): the conversion of their difference, a negative
// constant if they differ, doesn't compile then.
const _, _ = uint(textcoder.InputRoom - bufPadding), uint(bufPadding - textcoder.InputRoom)

// BorrowV2 makes the stream, which BeginV2 or BeginV2At began, read the input of dec, a jsontext.Decoder, from the
// offset from of the whole input, in the buffer of dec, in place, and read more into it through dec, initBufSize
// bytes at most at a time, as it reads its reader ( see readSource ): the bytes are not copied into its own buffer.
// It reports false, having done nothing, if the buffer can't be read so ( see textcoder.DecoderBuffer ). Once a
// decoder attached at a value reads on, the stream holds what it needs of the buffer in its own, and reads its reader
// ( see ReadOn ).
func ( *Stream) ( unsafe.Pointer,  int64) bool {
	, ,  := textcoder.DecoderBuffer()
	if ! ||  <  {
		return false
	}
	.src, .own = , .buf
	.buf, .offset, .length, .cursor = [:cap()], , int64(len()), -
	.buf[.length] = nul
	return true
}

// readSource is read for a stream which reads the buffer of a jsontext.Decoder in place ( see BorrowV2 ): the
// decoder reads more into its buffer, keeping what the stream keeps, which it may move.
func ( *Stream) () bool {
	if int64(len(.buf))-.length <= textcoder.InputRoom {
		// the names of the path which the levels have by their places in the buffer, which the decoder moves, as it
		// is full ( see textcoder.FetchInput )
		.copyNames()
	}
	, , ,  := textcoder.FetchInput(.src, .offset+.keepStart(), initBufSize)
	.cursor -=  - .offset
	.buf, .offset, .length = [:cap()], , int64(len())
	.buf[.length] = nul
	if  != nil {
		.readErr = 
	}
	return  > 0 ||  == nil
}

// leaveSource makes the stream, which reads the buffer of a jsontext.Decoder in place, hold what a read keeps of the
// buffer in its own, and read its reader, as a stream of a reader does.
func ( *Stream) () {
	.copyNames()
	 := .keepStart()
	 := .length - 
	if int64(len(.own)) <= +bufPadding {
		// room for the bytes, the padding after them and a read of a byte at least, as read needs it
		.own = make([]byte, +bufPadding+1)
	}
	copy(.own, .buf[:.length])
	.buf, .own, .src = .own, nil, nil
	.offset, .cursor, .length = .offset+, .cursor-, 
	.buf[.length] = nul
}

// leaveSourceFrom makes the stream, if it reads the buffer of a jsontext.Decoder in place, hold the bytes from the
// total offset from in its own buffer ( see leaveSource ), for a decoder attached at the value after from, which
// may read on: the input which it reads and its place are then the ones of a stream of a reader.
func ( *Stream) ( int64) {
	if .src != nil {
		,  := .keepFromHere()
		.leaveSource()
		.keeps, .keepFrom = , 
	}
}

// ReleaseStreamV2 puts the stream back, without its reader and the state of its call ( see EndV2 ).
func ( *Stream) {
	.EndV2()
	streamsV2.Put()
}

// EndV2 drops the reader of the stream and the state of its call, which may then read another reader ( see
// BeginV2 ).
func ( *Stream) () {
	if .src != nil {
		// the buffer of the stream, which read the one of a jsontext.Decoder in place
		.buf, .own, .src = .own, nil, nil
	}
	// the value of the call, which refers to nothing, is set by the next decoding before it reads it, but not the
	// place, which the caller reads after a failure before the decoding too ( see DecodeV2After )
	 := .ctx.v2
	.Stream, .Place.Set = nil, false
	if len(.names.entries) != 0 {
		.names.truncate(0, 0)
	}
	if .skippers != [3]unsafe.Pointer{} {
		releaseSkippers()
	}
	if len(.buf) > maxReusedStreamBuffer {
		.buf = make([]byte, initBufSize+bufPadding)
	}
	.length, .cursor, .offset = 0, 0, 0
	.buf[0] = nul
	.r, .readErr, .err = nil, nil, nil
	.keeps, .keepFrom = false, 0
	.ctx.Option.Flags, .ctx.Option.V2 = 0, 0
}

// StartAt makes the stream, which has read nothing, start at the offset of the input, which its reader reads from.
func ( *Stream) ( int64) {
	.offset = 
}

// Offset returns the offset in the input of the cursor of the stream.
func ( *Stream) () int64 {
	return .offset + .cursor
}

// Drop empties the buffer of the stream, which a decoder attached at its value read on from and failed after: the
// stream has nothing to give back ( see Read ), as the decoding of the value fails.
func ( *Stream) () {
	.copyNames()
	.offset += .length
	.cursor, .length = 0, 0
	.buf[0] = nul
}

// Unread returns the bytes of the buffer which the stream read after its cursor.
func ( *Stream) () []byte {
	return .buf[.cursor:.length]
}

// Context returns the context of the stream, which its values are decoded by.
func ( *Stream) () *RuntimeContext {
	return .ctx
}

// Read returns what has been read and not dropped, and the offset of its first byte in the input.
func ( *Stream) () ([]byte, int64) {
	return .buf[:.length], .offset
}

// ReadsInPlace reports whether the stream reads the buffer of a jsontext.Decoder in place ( see BorrowV2 ), which
// what it has read is then: it has not left it for its own buffer ( see leaveSource ).
func ( *Stream) () bool {
	return .src != nil
}

// ReadError returns the error of the reader, which the stream reports at the end of what it read, or nil if the
// reader reached the end of the input, or has not failed.
func ( *Stream) () error {
	if .readErr == io.EOF {
		return nil
	}
	return .readErr
}

// ReadOn reads more of the input into p, for a decoder attached at the value of the stream ( see V2Call.Value ):
// initBufSize bytes at most, as the stream reads, and the error of the reader is kept, as the stream keeps it.
func ( *Stream) ( []byte) (int, error) {
	if .readErr != nil {
		return 0, .readErr
	}
	if .src != nil {
		.leaveSource()
	}
	,  := .r.Read([:min(len(), initBufSize)])
	if  != nil {
		.readErr = 
	}
	return , 
}

// Resume makes the stream go on at the offset end of the input, where a decoder attached at its value stopped: in the
// buffer, or, if the decoder read on, before rest, what it read and didn't use, which the buffer takes.
func ( *Stream) ( int64,  []byte) {
	.copyNames()
	if  == nil {
		.cursor =  - .offset
		return
	}
	if int64(len()) > int64(len(.buf))-bufPadding {
		.buf = make([]byte, int64(len())+bufPadding)
	}
	.length = int64(copy(.buf, ))
	.buf[.length] = nul
	.offset, .cursor = , 0
}

// DecodeV2 decodes the next value of the stream by dec, a decoder of v2, into p: whole if the buffer holds it, and
// else element by element. The value is nested in depth objects and arrays, the ones of the path but the top level.
// It returns the error of the reader, io.EOF at the end of the input, if no value is left, and the error of the
// decoding, whose place is recorded ( see V2Call.Place ) unless it is an error of encoding/json/v2 at its place.
func ( *Stream) ( Decoder,  unsafe.Pointer,  int64) error {
	.ctx.v2.Place.Set = false
	// the end of the token before the value, before the white space, which is kept while the value is looked for
	 := .offset + .cursor
	,  := .keepFromHere()
	if !.skipSpaceBefore() {
		.keeps, .keepFrom = , 
		return .endError()
	}
	return .decodeTopV2(, , , , , )
}

// DecodeLongV2After is DecodeV2After for an object or an array at the offset start of what has been read, which the
// caller found not whole in it ( see WholeEndV2 ), by dec, which is not the decoder of a method, a function or a
// pointer ( see ReadsJSONText ): it is decoded element by element at once, as decodeTopV2 decodes it after its scan.
func ( *Stream) ( Decoder,  unsafe.Pointer, , ,  int64) error {
	 := .ctx.v2
	// the names of the objects of the value which an error ended are dropped after it ( see DecodeV2After )
	,  := .names.mark()
	.Place.Set = false
	.cursor =  - .offset
	.beginElements()
	 := .decodeLongV2(, , , )
	.names.truncate(, )
	return 
}

// DecodeV2After is DecodeV2 for a value at the offset start of the input, after from, the offset of the end of the
// token before it, which the stream reads from: the white space and the delimiter between them, which were checked,
// are skipped. It never returns io.EOF.
func ( *Stream) ( Decoder,  unsafe.Pointer, , ,  int64) error {
	// the names of the objects of the value which an error ended are dropped after it: the value of a method, whose
	// error the method may ignore, leaves none to the objects around it ( see callNames )
	,  := .ctx.v2.names.mark()
	 := .decodeV2After(, , , , )
	.ctx.v2.names.truncate(, )
	return 
}

func ( *Stream) ( Decoder,  unsafe.Pointer, , ,  int64) error {
	.ctx.v2.Place.Set = false
	,  := .keepFromHere()
	for .offset+.length <=  {
		if !.read() {
			.keeps, .keepFrom = , 
			return .unexpectedEndError()
		}
	}
	.cursor =  - .offset
	return .decodeTopV2(, , , , , )
}

// decodeTopV2 decodes the value at the cursor of DecodeV2, after from, the end of the token before it, which is kept
// while the value is looked for: keeps and keepFrom are what the stream kept before.
func ( *Stream) ( Decoder,  unsafe.Pointer, ,  int64,  bool,  int64) error {
	switch .(type) {
	case *v2UnmarshalFromDecoder, *v2FuncDecoder, *ptrDecoder, *basicPtrDecoder, *v2InvalidDecoder:
		// a method or a function which reads a jsontext.Decoder, which may read on past the value, as the one of
		// encoding/json/v2 reads the values after it, also through a pointer; or a type of no representation, whose
		// error is before the value is read, whatever follows
		.keeps, .keepFrom = , 
		.beginElements()
		return .decodeNestedV2(, , , )
	}
	,  := .scanValue()
	.keeps, .keepFrom = , 
	switch {
	case  == errLongValue:
		// an object or an array, which what has been read doesn't hold whole: the decoder is not one of a pointer
		// or a method, which decodeNestedV2 looks through
		.beginElements()
		return .decodeLongV2(, , , )
	case  != nil:
		return .placeAt(, )
	}
	return .decodeWholeV2(, , , , )
}

// beginElements makes the index of the objects and the arrays which the value at the cursor is decoded element by
// element in start at the value ( see bracketIndex ).
func ( *Stream) () {
	if .elements == nil {
		// the entries of the first steps of the lookups ( see indexFirstStep ), which a slice grown from nothing
		// would take a few allocations for
		.elements = &bracketIndex{closes: make([]bracketClose, 0, indexFirstStep/4)}
	}
	*.elements = bracketIndex{closes: .elements.closes[:0], end: .offset + .cursor}
}

// AfterTopLevel moves the stream to the end of the input after its top-level value, which only white space may
// follow, and reports whether it is there: if not, the place of the byte after the value is recorded ( see
// V2Call.Place ). It returns the error of the reader.
func ( *Stream) () (bool, error) {
	if .skipWhiteSpace() {
		.setPlace(.offset+.cursor, .length)
		return false, nil
	}
	if .readErr != io.EOF {
		return false, .readErr
	}
	return true, nil
}

// setPlace records the place of an error of the decoding, which the buffer has from the total offset from up to end,
// unless an inner value recorded its own ( see V2Call.Place ).
func ( *Stream) (,  int64) {
	// the names of the path, which the error is found again with
	.copyNames()
	if  := &.ctx.v2.Place; !.Set {
		* = StreamPlace{From:  - .offset, End: , Set: true}
	}
}

// placeAt records the place of err, which the buffer has from the total offset from up to what has been read, and
// returns err.
func ( *Stream) ( error,  int64) error {
	.setPlace(, .length)
	return 
}

// placeDelimiterError is placeAt for err, the error of the next member or element of an object or an array which is
// read token by token, after from, the end of the token before it: an error at a comma or a colon, which is not
// one where it is, is found again after the byte after it which is not white space has been read, as encoding/json/v2
// reads the token after a delimiter before it reports the delimiter, and its error tells that token.
func ( *Stream) ( error,  int64) error {
	if  := .buf[.cursor];  == ',' ||  == ':' {
		.readPastDelimiter()
	}
	return .placeAt(, )
}

// readPastDelimiter reads the input after the comma or the colon at the cursor, keeping the bytes from the total
// offset from, up to the first byte after it which is not white space, or the end of the input.
func ( *Stream) ( int64) {
	,  := .keepFromHere()
	 := .offset + .cursor + 1
	for {
		 :=  - .offset
		for  < .length && isWhiteSpace[.buf[]] {
			++
		}
		if  = .offset + ;  < .length || !.read() {
			break
		}
	}
	.keeps, .keepFrom = , 
}

// placeValue is placeAt for the value at the cursor, which ends at end.
func ( *Stream) ( error, ,  int64) error {
	.setPlace(, )
	return 
}

// keepFromHere makes the buffer keep the bytes from the total offset from, which reads would drop, and returns what
// it kept before, which the caller sets back.
func ( *Stream) ( int64) (bool, int64) {
	,  := .keeps, .keepFrom
	if !.keeps || .keepFrom >  {
		.keeps, .keepFrom = true, 
	}
	return , 
}

// SetPath sets the path of the call of the stream to levels, the place of the next value which it decodes, copied
// into path, whose arrays it reuses, and returns the path it had, which the caller sets back by RestorePath.
func ( *Stream) (,  []textcoder.Level) []textcoder.Level {
	.copyNames()
	 := .ctx.v2
	 := .Path
	 = [:0]
	for ,  := range  {
		 := len()
		if  < cap() {
			// the entry, whose name keeps its array: the name of the level is copied, as the names of the path are
			// copied into ( see setName )
			 = [:+1]
			[].Object, [].Count = .Object, .Count
		} else {
			 = append(, textcoder.Level{Object: .Object, Count: .Count})
		}
		 := [].Name[:0]
		if len(.Name) != 0 {
			 = append(, .Name...)
		}
		if  == nil && .Name != nil {
			 = []byte{} // the name "", which is a name
		}
		[].Name = 
	}
	.Path = 
	.clearPathNames()
	return 
}

// clearPathNames makes the places of the names of the path of the call none, one for each level ( see setNameAt ).
func ( *V2Call) () {
	if  := len(.Path); cap(.pathNames) >=  {
		.pathNames = .pathNames[:]
		clear(.pathNames)
	} else {
		.pathNames = make([]namePlace, )
	}
}

// RestorePath sets the path of the call of the stream back to saved, which SetPath returned, and returns the path
// which it set, whose arrays the caller keeps for the next SetPath.
func ( *Stream) ( []textcoder.Level) []textcoder.Level {
	.copyNames()
	 := .ctx.v2
	 := .Path
	.Path = 
	// the names of saved were copied when it was set aside ( see SetPath )
	.clearPathNames()
	return 
}

// pushLevel adds the level of an object or an array which is decoded element by element to the path, and returns
// its index.
func ( *Stream) ( bool) int {
	 := .ctx.v2
	 := len(.Path)
	.pathNames = append(.pathNames[:], namePlace{})
	if  < cap(.Path) {
		// the entry, whose name keeps its array for the names of the level
		.Path = .Path[:+1]
		 := &.Path[]
		.Object, .Count, .Name = , 0, .Name[:0]
		return 
	}
	.Path = append(.Path, textcoder.Level{Object: })
	return 
}

// level returns the level i of the path.
func ( *Stream) ( int) *textcoder.Level {
	return &.ctx.v2.Path[]
}

// popLevel removes the level i, which ended, from the path.
func ( *Stream) ( int) {
	 := .ctx.v2
	.Path, .pathNames = .Path[:], .pathNames[:]
}

// decodeNestedV2 decodes the value at the cursor, nested in depth objects and arrays, by dec into p: whole if the
// buffer holds it, and else element by element. from is the total offset of the end of the token before the value,
// which the buffer has, and keeps while the value is looked for and read whole, but not while it is decoded element by
// element: a decoder attached at the value is attached there before anything more is read.
func ( *Stream) ( Decoder,  unsafe.Pointer, ,  int64) error {
	switch d := .(type) {
	case *ptrDecoder:
		if .buf[.cursor] != 'n' {
			// the value which the pointer points to, which is set to a new one if it is nil: its decoder may be one
			// of a method or a function which reads a jsontext.Decoder, and null sets the pointer to nil
			 := *(*unsafe.Pointer)()
			if  == nil {
				 = newValue(.typ)
				*(*unsafe.Pointer)() = 
			}
			return .(.dec, , , )
		}
	case *basicPtrDecoder:
		if .buf[.cursor] != 'n' {
			// as a ptrDecoder, by the allocator of the type
			 := *(*unsafe.Pointer)()
			if  == nil {
				 = .alloc()
				*(*unsafe.Pointer)() = 
			}
			return .(.dec, , , )
		}
	case *v2EmbeddedPtrDecoder:
		// a field through an embedded pointer, which is set to a new value if it is nil
		if *(*unsafe.Pointer)() == nil {
			if !.settable {
				return .placeAt(&errors.UnmarshalError{GoType: .root, Start: .cursor, NoKind: true, Err: errNilField}, )
			}
			*(*unsafe.Pointer)() = newValue(.elem)
		}
		return .(.dec, unsafe.Add(*(*unsafe.Pointer)(), .offset), , )
	case *v2UnmarshalFromDecoder:
		if  := .decodeAttached(.typ, , , , nil);  != ErrUseDefault {
			return 
		}
		return .(.next, , , )
	case *v2FuncDecoder:
		return .decodeFuncsV2(, , , )
	case *v2InvalidDecoder:
		// the error before the value is read, as encoding/json/v2 reports it, whatever the value is
		return .placeAt(&errors.UnmarshalError{GoType: .typ, Start: .cursor, NoKind: true, Err: .err}, )
	case *v2StringifiedPtrDecoder:
		// by the decoder of the pointer: an object or an array element by element, which is not the JSON string
		// "null", and any value but null of a pointer to a pointer, which fails before the value is read
		 := .buf[.cursor]
		if ,  := .ptr.(*v2InvalidDecoder);  == '{' ||  == '[' ||  &&  != 'n' {
			return .(.ptr, , , )
		}
	case *intDecoder, *uintDecoder, *floatDecoder, *boolDecoder, v2StringDecoder, *v2InterfaceDecoder:
		// a string, a number or a literal which the buffer has whole is decoded in it, as v1 decodes it, after from,
		// which a read for the rest of a string keeps ( see decodeScalar, which decodes a value of an interface only
		// into a nil interface{} )
		if  := .buf[.cursor];  != '{' &&  != '[' {
			,  := .keepFromHere()
			 := .decodeScalar(, , )
			.keeps, .keepFrom = , 
			if  {
				return nil
			}
		}
	}
	,  := .keepFromHere()
	, ,  := .elementEnd()
	if  == nil && ! {
		// a value decoded element by element doesn't keep the bytes before it
		.keeps, .keepFrom = , 
		var  bool
		if ,  = .decodeElementsV2(, , , );  {
			return 
		}
		 := .offset + .cursor
		.keepFromHere()
		if ,  = .wholeEnd();  != nil {
			 = .wholeValueError(, )
		}
	}
	if  == nil {
		 = .decodeWholeV2(, , , , )
	} else {
		 = .placeAt(, )
	}
	.keeps, .keepFrom = , 
	return 
}

// decodeLongV2 is decodeNestedV2 for the object or the array at the cursor which what has been read doesn't hold
// whole, found by scanValue: it is decoded element by element, or, if dec doesn't decode it so, read whole and
// decoded, without the lookup of its end by elementEnd, which looks at the same bytes again and indexes them.
func ( *Stream) ( Decoder,  unsafe.Pointer, ,  int64) error {
	,  := .decodeElementsV2(, , , )
	if  {
		return 
	}
	 := .offset + .cursor
	,  := .keepFromHere()
	,  := .wholeEnd()
	if  == nil {
		 = .decodeWholeV2(, , , , )
	} else {
		 = .placeAt(.wholeValueError(, ), )
	}
	.keeps, .keepFrom = , 
	return 
}

// wholeValueError returns err, an error of wholeEnd, which read the value at the total offset start whole for its
// decoder: a syntax error is the one of the read of the whole value, which encoding/json/v2 reads whole for the
// decoder.
func ( *Stream) ( error,  int64) error {
	if .grammarFailure() &&  != .readErr {
		return &errors.UnmarshalError{Start:  - .offset, Err: , Method: errors.UnmarshalWholeValue}
	}
	return 
}

// decodeWholeV2 decodes the value at the cursor, which ends at end, nested in depth objects and arrays, by dec into
// p, as Unmarshal decodes it: a type error which a decoder of v1 recorded is the error of the value. from is the
// total offset of the end of the token before the value.
func ( *Stream) ( Decoder,  unsafe.Pointer, , ,  int64) error {
	 := .ctx
	 := .v2
	.Value = StreamValue{From:  - .offset, Start: .cursor}
	 := .length
	if  := .buf[.cursor];  != 't' &&  != 'f' &&  != 'n' {
		// the end of the value is known: a nul byte is put there while the value is decoded, as Decode puts it
		 = 
	}
	 := .buf[]
	.buf[] = nul
	.Buf = .buf[:+1]
	.origin = .Buf
	,  := .Decode(, .cursor, , )
	if  == nil && .typeError != nil {
		 = .v2Error()
	}
	.buf[] = 
	.Buf, .origin = nil, nil
	.Value = StreamValue{}
	if  != nil {
		.DiscardTypeError()
		return .placeValue(, , )
	}
	.cursor = 
	return nil
}

// decodeAttached decodes the value at the cursor, nested in depth objects and arrays, which the buffer doesn't hold
// whole, into p, of typ, by its UnmarshalJSONFrom method, or by fn, a function of UnmarshalFromFunc, if it is set:
// they are given a jsontext.Decoder attached at its place, after from, the end of the token before it, which reads
// on from the reader of the stream. It returns ErrUseDefault if they declined the value.
func ( *Stream) ( reflect.Type,  unsafe.Pointer, ,  int64,  *UnmarshalFunc) error {
	.leaveSourceFrom()
	 := .ctx
	 := .v2
	.Value = StreamValue{From:  - .offset, Start: .cursor, ReadsOn: true}
	 := .offset + .cursor
	.copyNames()
	var  error
	if  != nil {
		_,  = .Decode(, .cursor, , , )
	} else {
		_,  = V2Hooks.UnmarshalFrom(, .cursor, , , )
	}
	.Value = StreamValue{}
	if  == ErrUseDefault {
		// the value, which the decoder read nothing of, is decoded from its start
		.cursor =  - .offset
	}
	return 
}

// decodeFuncsV2 decodes the value at the cursor, nested in depth objects and arrays, into p by the functions of d in
// their order, as v2FuncDecoder.Decode does: a function which reads a jsontext.Decoder is given one attached at its
// place, and any other the value read whole. from is the total offset of the end of the token before the value.
func ( *Stream) ( *v2FuncDecoder,  unsafe.Pointer, ,  int64) error {
	for ,  := range .funcs {
		if .FromDecoder {
			if  := .decodeAttached(.typ, , , , );  != ErrUseDefault {
				return 
			}
			continue
		}
		// a function which takes the value whole, which is read whole for it and the ones after it
		 := .offset + .cursor
		,  := .keepFromHere()
		, ,  := .elementEnd()
		if  == nil && ! {
			if ,  = .wholeEnd();  != nil {
				 = .wholeValueError(, )
			}
		}
		if  == nil {
			 = .decodeWholeV2(&v2FuncDecoder{typ: .typ, funcs: .funcs[:], next: .next}, , , , )
		} else {
			 = .placeAt(, )
		}
		.keeps, .keepFrom = , 
		return 
	}
	return .decodeNestedV2(.next, , , )
}

// decodeElementsV2 decodes the object or the array at the cursor, nested in depth objects and arrays, by dec into p
// element by element, after from, the total offset of the end of the token before it. It reports false, having read
// nothing, if dec doesn't decode it so: a value of a type which reads it whole, as encoding/json/v2 reads a value of
// a string, a number, bytes or a method whole before its error. A value of another kind than its type, which
// encoding/json/v2 reports at its first token, is the error.
func ( *Stream) ( Decoder,  unsafe.Pointer, ,  int64) (bool, error) {
	 := .buf[.cursor]
	var  reflect.Type
	switch d := .(type) {
	case *v2StructDecoder:
		if  == '{' {
			if .initErr != nil {
				return true, .placeAt(&errors.UnmarshalError{GoType: .initErr.GoType, Start: .cursor, Err: .initErr.Err}, )
			}
			return true, .decodeStructElementsV2(, , , )
		}
		 = .typ
	case *v2MapDecoder:
		if  == '{' {
			return true, .decodeMapElementsV2(, , , )
		}
		 = .typ
	case *v2AnyMapDecoder:
		if  == '{' {
			 := *(*map[string]any)()
			if  == nil {
				 = map[string]any{}
			}
			 := .decodeAnyObjectV2(.iface, , , )
			*(*map[string]any)() = 
			return true, 
		}
		 = interfaceMapType
	case *v2SliceDecoder:
		if  == '[' {
			return true, .decodeSliceElementsV2(, , , )
		}
		 = .typ
	case *v2ArrayDecoder:
		if  == '[' {
			return true, .decodeArrayElementsV2(, , , )
		}
		 = .typ
	case *v2FormatBytesWithLegacySemanticsDecoder:
		if  == '[' {
			return .(.elements, , , )
		}
		// any other value, which is read whole as bytes are
		return false, nil
	case *boolDecoder:
		 = .typ
	case *v2InvalidDecoder:
		// a type of no representation, which is the error before the value is read
		return true, .placeAt(&errors.UnmarshalError{GoType: .typ, Start: .cursor, NoKind: true, Err: .err}, )
	case *v2InterfaceDecoder:
		return .decodeInterfaceElementsV2(, , , )
	default:
		return false, nil
	}
	// an object or an array of a type of another kind, whose error is at its first token
	return true, .placeAt(&errors.UnmarshalError{GoType: , Start: .cursor}, )
}

// openElementsV2 moves the cursor after the bracket which begins the object or the array whose elements are read,
// nested in depth objects and arrays, after from, the total offset of the end of the token before it, and returns the
// depth of its elements and the index of its level in the path.
func ( *Stream) ( bool, ,  int64) (int64, int, error) {
	,  := .openElements()
	if  != nil {
		return 0, 0, .placeAt(, )
	}
	return , .pushLevel(), nil
}

// nextMemberV2 moves the cursor after the name of the next member of the object whose members are read, and returns
// the name, quoted as the buffer has it: first is set before the first one. It reports false after the end of the
// object.
func ( *Stream) ( bool) ([]byte, bool, error) {
	, , , ,  := .nextMember()
	if  != nil || ! {
		return nil, , 
	}
	return .buf[:.cursor], true, nil
}

// memberValueV2 moves the cursor from after the name of a member to its value, and returns the total offset of the
// end of the name, the token before the value.
func ( *Stream) () (int64, error) {
	 := .offset + .cursor
	if  := .memberValue();  != nil {
		return 0, 
	}
	return , nil
}

// copyName copies name, the name of the next member of an object, before its colon is read, which a read may drop
// the name in the buffer for, into the spare name of the path ( see setName ).
func ( *Stream) ( []byte) {
	 := .ctx.v2
	if .spareName = append(.spareName[:0], ...); .spareName == nil {
		// the name "", which is a name, as a level without a name has none ( see textcoder.Level )
		.spareName = []byte{}
	}
}

// setName makes the name which copyName copied the last name of the level lv of the path, of its member k, whose
// colon is read: the level takes the spare name, and gives its former name, which the levels inside the value of
// the member and the next member copy theirs into.
func ( *Stream) (,  int) {
	 := .ctx.v2
	 := &.Path[]
	.Count = countAfterName(int64())
	.Name, .spareName = .spareName, .Name[:0]
	.pathNames[] = namePlace{}
}

// countAfterName and countAfterValue are the count of the level of an object of the path, which counts its names and
// its values ( see textcoder.Level ), once the name of its member k is read, and once the value is.
func countAfterName( int64) int64  { return 2* + 1 }
func countAfterValue( int64) int64 { return 2* + 2 }

// namesCounted is the number of the names of an object which the count of its level counts.
func namesCounted( int64) int64 { return ( + 1) / 2 }

// namePlace is the place of a name of an object in the buffer of a stream: the total offsets of its first byte and of
// the byte after it, inside the quotes. The zero namePlace is no name.
type namePlace struct {
	from, to int64
}

// isName reports whether the place is the one of a name: a name is after a quote, so that its end is 1 at least.
func ( namePlace) () bool { return .to != 0 }

// setNameAt makes the name of the buffer from the total offset from up to to, inside its quotes, which the buffer
// keeps, the last name of the level lv of the path, of its member k, whose colon is read, as setName does for a name
// which copyName copied: the level has the name by its place, until copyNames copies it, before the buffer drops it.
func ( *Stream) (,  int, ,  int64) {
	 := .ctx.v2
	.Path[].Count = countAfterName(int64())
	.pathNames[] = namePlace{from: , to: }
	.namesFrom = min(.namesFrom, )
}

// exactField returns the field of the name key of an object, which nextMember found, with what it found of it in
// info, and reports whether it is plain, as plainFieldV2 finds the field of a plain name in the buffer: a name of
// ASCII without an escape, which is the field whose name is the name as it is. The field of any other is found by
// memberOf.
func exactField( *structKeys,  []byte,  stringInfo) (*structFieldSet, bool) {
	if .firstEscape >= 0 || .nonASCII {
		return nil, false
	}
	if !.hasExactLength(len()) {
		return nil, true
	}
	,  := keyWords()
	return .findExact(, , ), true
}

// copyNames copies the names which the levels of the path have by their places in the buffer ( see setNameAt )
// into the levels: before the buffer drops them or moves its bytes, and before the path is read, by the error of
// the decoding or by a method or a function which reads a jsontext.Decoder.
func ( *Stream) () {
	 := .ctx.v2
	for  := .namesFrom;  < len(.pathNames); ++ {
		 := .pathNames[]
		if !.isName() {
			continue
		}
		 := &.Path[]
		if .Name = append(.Name[:0], .buf[.from-.offset:.to-.offset]...); .Name == nil {
			.Name = []byte{} // the name "", which is a name
		}
		.pathNames[] = namePlace{}
	}
	.namesFrom = len(.pathNames)
	if .skip.active {
		.copySkipNames()
	}
}

// copyStreamNames copies the names of the path of the stream which ctx decodes, if it decodes one ( see
// Stream.copyNames ), for a method or a function which reads a jsontext.Decoder, which may read the path.
func copyStreamNames( *RuntimeContext) {
	 := .v2
	if  == nil {
		return
	}
	if .Stream == nil && .Lent != nil {
		// a value of UnmarshalDecode which is decoded in the buffer of its decoder, whose stream the method or the
		// function needs
		V2Hooks.Lend()
	}
	if .Stream != nil {
		.Stream.copyNames()
	}
}

// WholeEndV2 returns the end of the object or the array at cursor of buf, which has the input up to length, followed
// by the room of a decoder ( see textcoder.InputRoom ), and reports whether it ends there: false for any other value.
func ( []byte, ,  int64) (int64, bool) {
	if  := [];  != '{' &&  != '[' {
		return 0, false
	}
	var  compoundScanner
	return .scan(, , )
}

// DecodeWholeInV2 decodes the value of buf from cursor up to end, which buf holds whole, by dec into p, as
// decodeWholeV2 decodes the value of a stream which the buffer holds whole: nested in depth objects and arrays, in
// buf, whose byte at end is nul while the value is decoded. A type error which a decoder of v1 recorded is the error
// of the value, and the names of the objects of the value which an error ended are dropped after it, as
// DecodeV2After drops them.
func ( *RuntimeContext,  []byte, , ,  int64,  Decoder,  unsafe.Pointer) (int64, error) {
	 := .v2
	,  := .names.mark()
	 := []
	[] = nul
	.Buf = [:+1]
	.origin = .Buf
	,  := .Decode(, , , )
	if  == nil && .typeError != nil {
		 = .v2Error()
	}
	[] = 
	.Buf, .origin = nil, nil
	if  != nil {
		.DiscardTypeError()
	}
	.names.truncate(, )
	return , 
}

// LendAt makes the stream, which BorrowV2 made read the buffer of a jsontext.Decoder from the offset from, the end of
// the token before its next value, at that value, at the offset start, as decodeWholeV2 is while it decodes it: for
// a value which the caller decodes whole in the buffer ( see V2Hooks.Lend ).
func ( *Stream) (,  int64) {
	 := .ctx.v2
	.Place.Set = false
	.cursor =  - .offset
	.Value = StreamValue{From:  - .offset, Start: .cursor}
}

// PlaceWholeV2 records the place of err, the error of the value at the cursor, which the caller decoded whole in the
// buffer up to end ( see DecodeWholeInV2 ), after from, the total offset of the end of the token before it, as
// decodeWholeV2 records it. It returns err.
func ( *Stream) ( error, ,  int64) error {
	.ctx.v2.Value = StreamValue{}
	return .placeValue(, , )
}

// ReadsJSONText reports whether dec is the decoder of a method or a function which reads a jsontext.Decoder, which
// may read on past its value, or of a pointer, whose value may be one: decodeTopV2 decodes them by decodeNestedV2.
func ( Decoder) bool {
	switch .(type) {
	case *v2UnmarshalFromDecoder, *v2FuncDecoder, *ptrDecoder, *basicPtrDecoder:
		return true
	}
	return false
}

// decodeStructElementsV2 decodes the object at the cursor into the struct at p, as v2StructDecoder.Decode does, after
// from, the total offset of the end of the token before it.
func ( *Stream) ( *v2StructDecoder,  unsafe.Pointer, ,  int64) error {
	, ,  := .openElementsV2(true, , )
	if  != nil {
		return 
	}
	 := .ctx
	// the loop of the options, which are looked at once for the object, as v2StructDecoder.Decode chooses it
	if !.foldAlways && .fallback == nil &&
		.Option.V2&(V2MatchCaseInsensitiveNames|V2RejectUnknownMembers|V2AllowDuplicateNames) == V2AllowDuplicateNames {
		return .decodeStructMembersV2(, , , )
	}
	 := .Option.V2&V2AllowDuplicateNames == 0
	 := .foldAlways || .Option.V2&V2MatchCaseInsensitiveNames != 0
	var  uint64
	var  []uint64
	var  nameSet
	for  := 0; ; ++ {
		// the end of the token before the member, which the place of its errors is read again from, kept until the
		// value of the member
		 := .offset + .cursor
		,  := .keepFromHere()
		, ,  := .nextMemberV2( == 0)
		if  != nil {
			return .placeDelimiterError(, )
		}
		if ! {
			.end(.v2)
			.keeps, .keepFrom = , 
			.popLevel()
			return nil
		}
		 := .cursor - int64(len())
		var  *structFieldSet
		var  bool
		if  {
			, _,  = .foldedFieldV2(, .buf[:.length+1], )
		} else {
			, _,  = plainFieldV2(.keyDecoder.keys, .buf[:.length+1], )
		}
		 := [1 : len()-1]
		if ! {
			// a name which v2StructDecoder.Decode finds by memberOf
			, ,  := .keyDecoder.decodeKey(.buf[:.length+1], , false)
			if  != nil {
				return .placeAt(, )
			}
			if , ,  = .memberOf(, , );  != nil {
				if ,  := .(*errors.UnmarshalError);  {
					.Start = 
				}
				return .placeAt(, )
			}
		}
		switch {
		case  != nil:
			if ! {
				break
			}
			if  := .fieldIdx;  < seenFields {
				 := uint64(1) << uint()
				if & != 0 {
					return .placeAt(&errors.UnmarshalError{Start: , Err: errors.ErrDuplicateName}, )
				}
				 |= 
			} else if fieldSeen(, &, len(.fields)) {
				return .placeAt(&errors.UnmarshalError{Start: , Err: errors.ErrDuplicateName}, )
			}
		case .Option.V2&V2RejectUnknownMembers != 0 && .fallback == nil:
			return .placeAt(&errors.UnmarshalError{GoType: .typ, Start: , Err: errors.ErrUnknownName}, )
		case :
			if !.addCopy(.V2Call(), nil, ) {
				return .placeAt(&errors.UnmarshalError{Start: , Err: errors.ErrDuplicateName}, )
			}
		}
		var  []byte
		var  *[]byte
		if  == nil && .fallback != nil && .fallback.mapType == nil {
			// a member which a jsontext.Value takes, checked before its value is read, with its name as the input
			// has it
			if ,  = .fallback.openRaw();  != nil {
				return .placeAt(&errors.UnmarshalError{GoType: jsonfields.RawValueType, Start: , Err: }, )
			}
			 = bytes.Clone()
		}
		.copyName()
		,  := .memberValueV2()
		if  != nil {
			return .placeAt(, )
		}
		.setName(, )
		.keeps, .keepFrom = , 
		switch {
		case  != nil:
			 = .decodeNestedV2(.dec, unsafe.Add(, .offset), , )
		case  != nil:
			 = .appendRawV2(, , , )
		case .fallback != nil:
			 = .decodeFallbackV2(.fallback, , , , .level().Name)
		default:
			 = .skipValueV2(, )
		}
		if  != nil {
			return 
		}
		.level().Count = countAfterValue(int64())
	}
}

// decodeStructMembersV2 is the loop of decodeStructElementsV2 with V2AllowDuplicateNames, for a struct whose names
// are matched as they are, which has no fallback, without V2RejectUnknownMembers: the members of the object whose
// level of the path is lv, after its bracket, nested in depth objects and arrays, are decoded as decodeStructElements
// decodes them for v1, and the ones of no field skipped. The bytes from the end of the token before a member, the
// place of its errors, are kept while its name and a string, a number or a literal of its value are read, which the
// buffer has whole: as decodeStructElementsV2 keeps them for the name and decodeNestedV2 for the value.
func ( *Stream) ( *v2StructDecoder,  unsafe.Pointer,  int64,  int) error {
	 := .ctx
	// what the caller keeps: the bytes of a member are kept from the end of the token before it, unless the caller
	// keeps them, from before the object
	,  := .keeps, .keepFrom
	for  := 0; ; ++ {
		 := .offset + .cursor
		if ! {
			.keeps, .keepFrom = true, 
		}
		, , , ,  := .nextMember( == 0)
		if  != nil {
			return .placeDelimiterError(, )
		}
		if ! {
			.keeps, .keepFrom = , 
			.popLevel()
			return nil
		}
		,  := exactField(.keyDecoder.keys, , )
		if ! {
			// a name which v2StructDecoder.Decode finds by memberOf, which is copied decoded
			, ,  := .keyDecoder.decodeKey(.buf[:.length+1], , false)
			if  != nil {
				return .placeAt(, )
			}
			var  []byte
			if , ,  = .memberOf(, .buf[:.cursor], );  != nil {
				if ,  := .(*errors.UnmarshalError);  {
					.Start = 
				}
				return .placeAt(, )
			}
			.copyName()
		}
		// the name as the buffer has it, inside its quotes, which is kept up to the colon
		,  := .offset++1, .offset+.cursor
		if  := .memberValue();  != nil {
			return .placeAt(, )
		}
		if  {
			.setNameAt(, , , -1)
		} else {
			.setName(, )
		}
		switch {
		case  == nil:
			.keeps, .keepFrom = , 
			 = .skipValueV2(, )
		case .buf[.cursor] != '{' && .buf[.cursor] != '[' && .decodeScalar(.dec, unsafe.Add(, .offset), ):
			// a string, a number or a literal which the buffer has whole, as decodeNestedV2 decodes it: the decoders
			// of the values of v2 which decodeScalar decodes are the ones which decodeNestedV2 gives it
			.keeps, .keepFrom = , 
		default:
			.keeps, .keepFrom = , 
			 = .decodeNestedV2(.dec, unsafe.Add(, .offset), , )
		}
		if  != nil {
			return 
		}
		.level().Count = countAfterValue(int64())
	}
}

// appendRawV2 appends the member of the name raw, as the input has it, whose value is at the cursor, to b, a
// jsontext.Value fallback which openRaw made ready, as v2Fallback.decodeMember does. The value, which encoding/json/v2
// reads whole, is nested in depth objects and arrays, after from, the total offset of the end of the name before it.
func ( *Stream) ( *[]byte,  []byte, ,  int64) error {
	,  := .keepFromHere()
	 := .offset + .cursor
	, ,  := .elementEnd()
	if  == nil && ! {
		if ,  = .wholeEnd();  != nil {
			 = .wholeValueError(, )
		}
	}
	// the value is read: nothing more is read for it
	.keeps, .keepFrom = , 
	if  != nil {
		return .placeAt(, )
	}
	 := .ctx
	.Buf = .buf[:.length+1]
	_,  = .skipValueV2(.cursor, )
	.Buf = nil
	if  != nil {
		return .placeValue(&errors.UnmarshalError{GoType: jsonfields.RawValueType, Start: .cursor, Err: }, , )
	}
	* = append(*, ...)
	* = append(*, ':')
	* = append(*, .buf[.cursor:]...)
	* = append(*, '}')
	.cursor = 
	return nil
}

// decodeFallbackV2 decodes the value at the cursor, of the member of the name, which is of no field of the struct at
// p, into its map fallback, as v2Fallback.decodeMember does. from is the total offset of the end of the name before
// the value, nested in depth objects and arrays.
func ( *Stream) ( *v2Fallback,  unsafe.Pointer, ,  int64,  []byte) error {
	 := valueAt(ptrTypeOf(.mapType), .target())
	if .IsNil() {
		.Set(reflect.MakeMap(.mapType))
	}
	 := reflect.ValueOf(string()).Convert(.mapType.Key())
	 := reflect.New(.mapType.Elem())
	if  := .MapIndex(); .IsValid() {
		.Elem().Set()
	}
	 := .decodeNestedV2(.value, .UnsafePointer(), , )
	.SetMapIndex(, .Elem())
	return 
}

// skipValueV2 skips the value at the cursor, nested in depth objects and arrays, after from, the total offset of the
// end of the token before it, as encoding/json/v2 skips it: checked for the text which v2 rejects, by the decoder if
// the buffer holds it whole, and else by a jsontext.Decoder attached at its place, which reads on from the reader of
// the stream.
func ( *Stream) (,  int64) error {
	,  := .keepFromHere()
	, ,  := .elementEnd()
	// the value is found, or the decoder is attached before anything more is read
	.keeps, .keepFrom = , 
	if  != nil {
		return .placeAt(, )
	}
	if ! {
		if .ctx.Option.V2&asV1Text == asV1Text {
			// a value of the grammar only, as v1 skips it
			return .skipLongV2()
		}
		.leaveSourceFrom()
		 := .ctx.v2
		.Value = StreamValue{From:  - .offset, Start: .cursor, ReadsOn: true}
		.copyNames()
		 := V2Hooks.SkipStreamValue(, )
		.Value = StreamValue{}
		return 
	}
	 := .ctx
	.Buf = .buf[:.length+1]
	_,  = .skipValueV2(.cursor, )
	.Buf = nil
	if  != nil {
		return .placeValue(, , )
	}
	.cursor = 
	return nil
}

// decodeMapElementsV2 decodes the object at the cursor into the map at p, as v2MapDecoder.Decode does, after from, the
// total offset of the end of the token before it.
func ( *Stream) ( *v2MapDecoder,  unsafe.Pointer, ,  int64) error {
	, ,  := .openElementsV2(true, , )
	if  != nil {
		return 
	}
	 := .ctx
	 := valueAt(.ptrType, )
	if .IsNil() {
		.Set(reflect.MakeMap(.typ))
	}
	 := .Option.V2&V2AllowDuplicateNames == 0
	var  reflect.Value
	if  && .Len() > 0 {
		 = reflect.MakeMap(reflect.MapOf(.typ.Key(), emptyStructType))
	}
	// names are the names of the keys, if two keys may have the same name
	var  nameSet
	 :=  && !uniqueKeyNames(.keyDecoder, .typ.Key().Kind(), .Option.V2&V2AllowInvalidUTF8 != 0)
	,  := reflect.New(.typ.Key()), reflect.New(.typ.Elem())
	for  := 0; ; ++ {
		// the end of the token before the entry, which the place of its errors is read again from, kept until the
		// value of the entry
		 := .offset + .cursor
		,  := .keepFromHere()
		, ,  := .nextMemberV2( == 0)
		if  != nil {
			return .placeDelimiterError(, )
		}
		if ! {
			.end(.v2)
			.keeps, .keepFrom = , 
			.popLevel()
			return nil
		}
		 := .cursor - int64(len())
		// the name is decoded as a value of the key type, which the buffer holds whole
		.Elem().SetZero()
		.Buf = .buf[:.length+1]
		.origin = .Buf
		 := .v2
		.Value = StreamValue{From:  - .offset, Start: }
		_,  = .keyDecoder.Decode(, , , .UnsafePointer())
		.Value = StreamValue{}
		.Buf, .origin = nil, nil
		if  == nil && .typeError != nil {
			.Buf = .buf[:.length+1]
			 = .v2Error()
			.Buf = nil
		}
		if  != nil {
			.DiscardTypeError()
			return .placeAt(, )
		}
		 := unquotedName()
		if  && !.addCopy(.V2Call(), nil, ) {
			return .placeAt(&errors.UnmarshalError{Start: , Err: errors.ErrDuplicateName}, )
		}
		 := .Elem()
		if  := .MapIndex(); .IsValid() {
			if  && (!.IsValid() || .MapIndex().IsValid()) {
				return .placeAt(&errors.UnmarshalError{Start: , Err: errors.ErrDuplicateName}, )
			}
			// the value of the name is decoded into, but replaced with MergeWithLegacySemantics
			if .Option.V2&V2MergeWithLegacySemantics == 0 {
				.Elem().Set()
			} else {
				.Elem().SetZero()
			}
		} else {
			.Elem().SetZero()
		}
		.copyName()
		,  := .memberValueV2()
		if  != nil {
			return .placeAt(, )
		}
		.setName(, )
		.keeps, .keepFrom = , 
		 = .decodeNestedV2(.valueDecoder, .UnsafePointer(), , )
		.SetMapIndex(, .Elem())
		if .IsValid() {
			.SetMapIndex(, reflect.Zero(emptyStructType))
		}
		if  != nil {
			return 
		}
		.level().Count = countAfterValue(int64())
	}
}

// nextElementV2 moves the cursor to the next element of the array whose elements are read, which has idx elements
// before it, and returns the total offset of the end of the token before it, which the place of its errors is read
// again from, as the place of the element. It reports false after the end of the array.
func ( *Stream) ( int) (int64, bool, error) {
	 := .offset + .cursor
	,  := .keepFromHere()
	,  := .nextElement( == 0)
	.keeps, .keepFrom = , 
	return , , 
}

// decodeSliceElementsV2 decodes the array at the cursor into the slice at p, as v2SliceDecoder.Decode does, after
// from, the total offset of the end of the token before it.
func ( *Stream) ( *v2SliceDecoder,  unsafe.Pointer, ,  int64) error {
	if .zero && (*sliceHeader)().cap > 0 && .Option.V2&V2MergeWithLegacySemantics == 0 {
		 := valueAt(.slicePtrType, )
		.Slice(0, .Cap()).Clear()
	}
	, ,  := .openElementsV2(false, , )
	if  != nil {
		return 
	}
	 := (*sliceHeader)()
	// the elements are decoded into the slice up to limit, and into a buffer after it, as sliceDecoder.Decode does
	 := sliceTarget{d: .sliceDecoder, dst: , limit: max(.cap, inPlaceSliceLength)}
	 := readsWhole(.valueDecoder)
	for  := 0; ; {
		, ,  := .nextElementV2()
		if  != nil || ! {
			.finish(, , )
			if  != nil {
				return .placeDelimiterError(, )
			}
			.popLevel()
			return nil
		}
		if  {
			,  := .decodeRunV2(&, , , , )
			if  != nil {
				.finish(, +1, )
				return 
			}
			if  >  {
				 = 
				continue
			}
		}
		if  := .decodeNestedV2(.valueDecoder, .elem(), , );  != nil {
			.finish(, +1, )
			return 
		}
		.decoded()
		++
		.level().Count = int64()
	}
}

// decodeRunV2 decodes the elements of the array whose elements are read into t, from the element idx at the cursor,
// after step, the total offset of the end of the token before it: the ones which the buffer holds whole, up to the
// last one which is an object or an array that ends in what has been read, as decodeRun does, each as decodeWholeV2
// decodes it, without the lookup of its end. It returns the number of the elements of the array decoded, which the
// level lv of the path counts: idx if the buffer holds no such element. The decoder of the elements reads a value
// whole ( see readsWhole ).
func ( *Stream) ( *sliceTarget, ,  int, ,  int64) (int, error) {
	.indexAt()
	,  := .elements.lastElementClose(.offset+.cursor, )
	if ! {
		return , nil
	}
	 := .ctx
	 := .v2
	 := .d.valueDecoder
	// a nul byte is put after the last element while the run is decoded, as decodeRun puts it
	 :=  - .offset + 1
	 := .buf[]
	.buf[] = nul
	 := .buf[:+1]
	.Buf, .origin = , 
	var  error
	for {
		.Value = StreamValue{From:  - .offset, Start: .cursor}
		,  := .Decode(, .cursor, , .elem())
		if  == nil && .typeError != nil {
			 = .v2Error()
		}
		if  != nil {
			.DiscardTypeError()
			 = .placeValue(, , )
			break
		}
		.decoded()
		++
		.level().Count = int64()
		.cursor,  = , .offset+
		// the next element is in the run if it starts before its end
		 := skipWhiteSpace(, )
		if [] != ',' {
			break
		}
		if  = skipWhiteSpace(, +1);  >=  {
			break
		}
		.cursor = 
	}
	.buf[] = 
	.Buf, .origin = nil, nil
	.Value = StreamValue{}
	return , 
}

// readsWhole reports whether decodeNestedV2 decodes a value which the buffer holds whole by dec as decodeWholeV2
// decodes it: unless dec, or the decoder of the value which dec decodes through pointers, is one of a method or a
// function which reads a jsontext.Decoder, which is given one attached at the value. The pointers of a type which
// points to itself, through other types or not, lead to no other decoder: slow, which follows them at half the
// pace, meets dec in them.
func readsWhole( Decoder) bool {
	 := 
	for  := false; ;  = ! {
		switch d := .(type) {
		case *v2UnmarshalFromDecoder, *v2FuncDecoder:
			return false
		case *ptrDecoder:
			 = .dec
		case *basicPtrDecoder:
			 = .dec
		default:
			return true
		}
		if  {
			 = pointeeDecoder()
		}
		if  ==  {
			return true
		}
	}
}

// pointeeDecoder returns the decoder of the value which dec, a decoder of a pointer, decodes through it.
func pointeeDecoder( Decoder) Decoder {
	switch d := .(type) {
	case *ptrDecoder:
		return .dec
	case *basicPtrDecoder:
		return .dec
	}
	return 
}

// decodeArrayElementsV2 decodes the array at the cursor into the array at p, as v2ArrayDecoder.Decode does, after
// from, the total offset of the end of the token before it.
func ( *Stream) ( *v2ArrayDecoder,  unsafe.Pointer, ,  int64) error {
	, ,  := .openElementsV2(false, , )
	if  != nil {
		return 
	}
	var  error
	// an element is decoded into its zero value, but into the element with MergeWithLegacySemantics
	 := .Option.V2&V2MergeWithLegacySemantics == 0
	for  := 0; ; ++ {
		, ,  := .nextElementV2()
		if  != nil {
			return .placeDelimiterError(, )
		}
		if ! {
			for ;  < .alen; ++ {
				.elem.zero(unsafe.Add(, uintptr()*.elem.size))
				 = errArrayUnderflow
			}
			if  != nil && .Option.V2&V2UnmarshalArrayFromAnyLength == 0 {
				// the error of the length is at the end of the array, which tells it
				return .placeAt(&errors.UnmarshalError{GoType: .typ, Start: .cursor - 1, Err: }, )
			}
			.popLevel()
			return nil
		}
		if  < .alen {
			 := unsafe.Add(, uintptr()*.elem.size)
			if  {
				.elem.zero()
			}
			 = .decodeNestedV2(.valueDecoder, , , )
		} else {
			 = .skipValueV2(, )
			 = errArrayOverflow
		}
		if  != nil {
			return 
		}
		.level().Count = int64( + 1)
	}
}

// decodeInterfaceElementsV2 decodes the object or the array at the cursor into the interface value at p, as
// v2InterfaceDecoder.Decode does, after from, the total offset of the end of the token before it. It reports false,
// having read nothing, for a value which is read whole.
func ( *Stream) ( *v2InterfaceDecoder,  unsafe.Pointer, ,  int64) (bool, error) {
	 := .ctx
	if (*[2]unsafe.Pointer)()[0] != nil && .Option.V2&V2MergeWithLegacySemantics != 0 && !.holdsPointer() {
		// MergeWithLegacySemantics decodes into a pointer which the interface value holds only
		*(*[2]unsafe.Pointer)() = [2]unsafe.Pointer{}
	}
	if (*[2]unsafe.Pointer)()[0] != nil {
		// a value which the interface value holds is decoded into
		 := valueAt(.ptrType, )
		 := .Elem()
		if !.fromAny && (.Type() == interfaceMapType || .Type() == anySliceType) {
			return true, .decodeMergingV2(, , , )
		}
		 := reflect.New(.Type())
		.Elem().Set()
		,  := .DecoderOfV2(ptrTypeOf(.Type()))
		if  != nil {
			return true, 
		}
		 = .decodeNestedV2(, .UnsafePointer(), , )
		.Set(.Elem())
		return true, 
	}
	switch {
	case !.empty:
		return true, .placeAt(&errors.UnmarshalError{GoType: .typ, Start: .cursor, NoKind: true, Err: errNilInterface}, )
	case .fromAny:
		// the value of the type of its kind, which the functions of unmarshaling decode
		 := reflect.New(anyValueTypes[.buf[.cursor]])
		,  := .DecoderOfV2(ptrTypeOf(.Elem().Type()))
		if  != nil {
			return true, 
		}
		 = .decodeNestedV2(, .UnsafePointer(), , )
		valueAt(.ptrType, ).Set(.Elem())
		return true, 
	}
	return true, .decodeMergingV2(, , , )
}

// decodeMergingV2 decodes the object or the array at the cursor into the interface{} at p, as decodeMerging does:
// into the map[string]interface{} or the []interface{} which it holds, or a new one.
func ( *Stream) ( *v2InterfaceDecoder,  unsafe.Pointer, ,  int64) error {
	 := *(*any)()
	if .buf[.cursor] == '{' {
		,  := .(map[string]any)
		if  != nil && ! {
			return .placeAt(&errors.UnmarshalError{GoType: reflect.TypeOf(), Start: .cursor}, )
		}
		if  == nil {
			// a new map, of the entries of the object, which are decoded first
			,  := .decodeNewAnyObjectV2(, , )
			if  != nil {
				*(*any)() = 
			}
			return 
		}
		return .decodeAnyObjectV2(, , , )
	}
	,  := .([]any)
	if  != nil && ! {
		return .placeAt(&errors.UnmarshalError{GoType: reflect.TypeOf(), Start: .cursor}, )
	}
	if  == nil {
		// a new slice, of the elements of the array, which are decoded first
		,  := .decodeNewAnyArrayV2(, , )
		if  != nil {
			*(*any)() = 
		}
		return 
	}
	 := .decodeAnyArrayV2(, &, , )
	*(*any)() = 
	return 
}

// decodeNewAnyObjectV2 decodes the object at the cursor into a new map[string]interface{}, as decodeObjectInto does,
// after from, the total offset of the end of the token before it: the entries are pushed to the stack of the
// context, as decodeAnyObject pushes them for v1, and put into a map of their number at the end, which it returns,
// with the entries before an error. The value of a name which the object had is decoded into its first value.
func ( *Stream) ( *v2InterfaceDecoder, ,  int64) (map[string]any, error) {
	, ,  := .openElementsV2(true, , )
	if  != nil {
		return nil, 
	}
	 := .ctx
	 := len(.entryStack)
	var  anyNames
	for  := 0; ; ++ {
		// the end of the token before the member, which the place of its errors is read again from, kept until the
		// value of the member
		 := .offset + .cursor
		,  := .keepFromHere()
		, , , ,  := .nextMember( == 0)
		if  != nil {
			return .anyEntries(), .placeDelimiterError(, )
		}
		if ! {
			.keeps, .keepFrom = , 
			.popLevel()
			return .anyEntries(), nil
		}
		 := .buf[:.cursor]
		if .Option.V2&V2AllowInvalidUTF8 == 0 && hasNotASCIIOrEscape() && !validV2Text() {
			return .anyEntries(), .placeAt(errV2Text, )
		}
		 := string(decodeLiteral(, ))
		 := .index(, , )
		if  >= 0 && .Option.V2&V2AllowDuplicateNames == 0 {
			return .anyEntries(), .placeAt(&errors.UnmarshalError{Start: , Err: errors.ErrDuplicateName}, )
		}
		 := .firstEscape < 0 && !.nonASCII
		if ! {
			.copyName(unsafeBytes())
		}
		 := .offset + .cursor
		if  := .memberValue();  != nil {
			return .anyEntries(), .placeAt(, )
		}
		if  {
			.setNameAt(, , -int64(len())-1, -1)
		} else {
			.setName(, )
		}
		.keeps, .keepFrom = , 
		if  >= 0 {
			// the value of a name which the object had, which is decoded into the first one: out of ctx.slot, which
			// the values in it are decoded into, from nil
			 := .entryStack[].value
			 = .decodeNestedV2(, unsafe.Pointer(&), , )
			.entryStack[].value = 
		} else {
			 = .decodeNestedV2(, unsafe.Pointer(&.slot), , )
			.entryStack = append(.entryStack, anyEntry{key: , value: .slot})
			.slot = nil
		}
		if  != nil {
			return .anyEntries(), 
		}
		.level().Count = countAfterValue(int64())
	}
}

// anyNames finds the names of the entries of an object which decodeNewAnyObjectV2 pushed: by the bits of their
// hashes in mask, and a comparison with the names of the entries of its bit, up to maxListedNames names, and by the
// keys of a map of their entries past them, so that an object of many names is not quadratic in its names.
type anyNames struct {
	mask nameMask
	set  map[string]int
}

// index returns the index in the stack of the entry of the name, which the entries of the stack from base are, or -1
// if they don't have it, and adds the name, which the caller pushes the entry of then.
func ( *anyNames) ( *RuntimeContext,  int,  string) int {
	 := .entryStack[:]
	if .set != nil {
		if ,  := .set[];  {
			return 
		}
		.set[] = len(.entryStack)
		return -1
	}
	,  := .mask.bit(nameHash(unsafeBytes()))
	if *& != 0 {
		for  := range  {
			if [].key ==  {
				return  + 
			}
		}
	}
	* |= 
	if len() == maxListedNames {
		// the names, past which they are found by the map, which has room for as many again
		.set = make(map[string]int, 2*maxListedNames)
		for  := range  {
			.set[[].key] =  + 
		}
		.set[] = len(.entryStack)
	}
	return -1
}

// anyEntries returns a new map of the entries of the stack of the context from base, which it removes.
func ( *RuntimeContext) ( int) map[string]any {
	 := .entryStack[:]
	 := make(map[string]any, len())
	for  := range  {
		[[].key] = [].value
	}
	.popEntries()
	return 
}

// decodeNewAnyArrayV2 decodes the array at the cursor into a new []interface{}, as decodeArrayInto does, after from,
// the total offset of the end of the token before it: the elements are pushed to the stack of the context, as
// decodeAnyArray pushes them for v1, and copied into a slice of their number at the end, which it returns, with the
// elements before an error.
func ( *Stream) ( *v2InterfaceDecoder, ,  int64) ([]any, error) {
	, ,  := .openElementsV2(false, , )
	if  != nil {
		return nil, 
	}
	 := .ctx
	 := len(.anyStack)
	for  := 0; ; ++ {
		, ,  := .nextElementV2()
		if  != nil {
			return .anyElements(), .placeDelimiterError(, )
		}
		if ! {
			.popLevel()
			return .anyElements(), nil
		}
		 = .decodeNestedV2(, unsafe.Pointer(&.slot), , )
		.anyStack = append(.anyStack, .slot)
		.slot = nil
		if  != nil {
			return .anyElements(), 
		}
		.level().Count = int64( + 1)
	}
}

// anyElements returns a new slice of the elements of the stack of the context from base, which it removes: an empty
// one, not nil, if there are none.
func ( *RuntimeContext) ( int) []any {
	 := make([]any, len(.anyStack)-)
	copy(, .anyStack[:])
	.popAny()
	return 
}

// decodeAnyObjectV2 decodes the object at the cursor into m, as decodeObjectInto does, after from, the total offset
// of the end of the token before it.
func ( *Stream) ( *v2InterfaceDecoder,  map[string]any, ,  int64) error {
	, ,  := .openElementsV2(true, , )
	if  != nil {
		return 
	}
	 := .ctx
	var  nameSet
	for  := 0; ; ++ {
		// the end of the token before the member, which the place of its errors is read again from, kept until the
		// value of the member
		 := .offset + .cursor
		,  := .keepFromHere()
		, ,  := .nextMemberV2( == 0)
		if  != nil {
			return .placeDelimiterError(, )
		}
		if ! {
			.end(.v2)
			.keeps, .keepFrom = , 
			.popLevel()
			return nil
		}
		if .Option.V2&V2AllowInvalidUTF8 == 0 && hasNotASCIIOrEscape() && !validV2Text() {
			return .placeAt(errV2Text, )
		}
		 := string(unquotedName())
		if .Option.V2&V2AllowDuplicateNames == 0 && !.addCopy(.V2Call(), nil, unsafeBytes()) {
			 := .cursor - int64(len())
			return .placeAt(&errors.UnmarshalError{Start: , Err: errors.ErrDuplicateName}, )
		}
		.copyName(unsafeBytes())
		,  := .memberValueV2()
		if  != nil {
			return .placeAt(, )
		}
		.setName(, )
		.keeps, .keepFrom = , 
		// the value of the name in the map is decoded into, as decodeElem does: the decoder of the interface{}
		// decodes a name of an object twice into its first value ( see v2InterfaceDecoder.Decode ), but with
		// MergeWithLegacySemantics, which replaces it
		var  any
		if .Option.V2&V2MergeWithLegacySemantics == 0 {
			 = []
		}
		 = .decodeNestedV2(, unsafe.Pointer(&), , )
		[] = 
		if  != nil {
			return 
		}
		.level().Count = countAfterValue(int64())
	}
}

// decodeAnyArrayV2 decodes the array at the cursor into *a from its first element, as decodeArrayInto does, after
// from, the total offset of the end of the token before it.
func ( *Stream) ( *v2InterfaceDecoder,  *[]any, ,  int64) error {
	, ,  := .openElementsV2(false, , )
	if  != nil {
		return 
	}
	* = (*)[:0]
	if * == nil {
		* = []any{}
	}
	for  := 0; ; ++ {
		, ,  := .nextElementV2()
		if  != nil {
			return .placeDelimiterError(, )
		}
		if ! {
			.popLevel()
			return nil
		}
		* = append(*, nil)
		if  := .decodeNestedV2(, unsafe.Pointer(&(*)[len(*)-1]), , );  != nil {
			return 
		}
		.level().Count = int64( + 1)
	}
}