//go:build !no_gotd_slices
// +build !no_gotd_slices

// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// InputInvoiceClassArray is adapter for slice of InputInvoiceClass.
type InputInvoiceClassArray []InputInvoiceClass

// Sort sorts slice of InputInvoiceClass.
func (s InputInvoiceClassArray) Sort(less func(a, b InputInvoiceClass) bool) InputInvoiceClassArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceClass.
func (s InputInvoiceClassArray) SortStable(less func(a, b InputInvoiceClass) bool) InputInvoiceClassArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceClass.
func (s InputInvoiceClassArray) Retain(keep func(x InputInvoiceClass) bool) InputInvoiceClassArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceClassArray) First() (v InputInvoiceClass, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceClassArray) Last() (v InputInvoiceClass, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceClassArray) PopFirst() (v InputInvoiceClass, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceClass
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceClassArray) Pop() (v InputInvoiceClass, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// AsInputInvoiceMessage returns copy with only InputInvoiceMessage constructors.
func (s InputInvoiceClassArray) AsInputInvoiceMessage() (to InputInvoiceMessageArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceMessage)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceSlug returns copy with only InputInvoiceSlug constructors.
func (s InputInvoiceClassArray) AsInputInvoiceSlug() (to InputInvoiceSlugArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceSlug)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoicePremiumGiftCode returns copy with only InputInvoicePremiumGiftCode constructors.
func (s InputInvoiceClassArray) AsInputInvoicePremiumGiftCode() (to InputInvoicePremiumGiftCodeArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoicePremiumGiftCode)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceStars returns copy with only InputInvoiceStars constructors.
func (s InputInvoiceClassArray) AsInputInvoiceStars() (to InputInvoiceStarsArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceStars)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceChatInviteSubscription returns copy with only InputInvoiceChatInviteSubscription constructors.
func (s InputInvoiceClassArray) AsInputInvoiceChatInviteSubscription() (to InputInvoiceChatInviteSubscriptionArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceChatInviteSubscription)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceStarGift returns copy with only InputInvoiceStarGift constructors.
func (s InputInvoiceClassArray) AsInputInvoiceStarGift() (to InputInvoiceStarGiftArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceStarGift)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceStarGiftUpgrade returns copy with only InputInvoiceStarGiftUpgrade constructors.
func (s InputInvoiceClassArray) AsInputInvoiceStarGiftUpgrade() (to InputInvoiceStarGiftUpgradeArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceStarGiftUpgrade)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceStarGiftTransfer returns copy with only InputInvoiceStarGiftTransfer constructors.
func (s InputInvoiceClassArray) AsInputInvoiceStarGiftTransfer() (to InputInvoiceStarGiftTransferArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceStarGiftTransfer)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoicePremiumGiftStars returns copy with only InputInvoicePremiumGiftStars constructors.
func (s InputInvoiceClassArray) AsInputInvoicePremiumGiftStars() (to InputInvoicePremiumGiftStarsArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoicePremiumGiftStars)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceBusinessBotTransferStars returns copy with only InputInvoiceBusinessBotTransferStars constructors.
func (s InputInvoiceClassArray) AsInputInvoiceBusinessBotTransferStars() (to InputInvoiceBusinessBotTransferStarsArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceBusinessBotTransferStars)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceStarGiftResale returns copy with only InputInvoiceStarGiftResale constructors.
func (s InputInvoiceClassArray) AsInputInvoiceStarGiftResale() (to InputInvoiceStarGiftResaleArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceStarGiftResale)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceStarGiftPrepaidUpgrade returns copy with only InputInvoiceStarGiftPrepaidUpgrade constructors.
func (s InputInvoiceClassArray) AsInputInvoiceStarGiftPrepaidUpgrade() (to InputInvoiceStarGiftPrepaidUpgradeArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceStarGiftPrepaidUpgrade)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoicePremiumAuthCode returns copy with only InputInvoicePremiumAuthCode constructors.
func (s InputInvoiceClassArray) AsInputInvoicePremiumAuthCode() (to InputInvoicePremiumAuthCodeArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoicePremiumAuthCode)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceStarGiftDropOriginalDetails returns copy with only InputInvoiceStarGiftDropOriginalDetails constructors.
func (s InputInvoiceClassArray) AsInputInvoiceStarGiftDropOriginalDetails() (to InputInvoiceStarGiftDropOriginalDetailsArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceStarGiftDropOriginalDetails)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputInvoiceStarGiftAuctionBid returns copy with only InputInvoiceStarGiftAuctionBid constructors.
func (s InputInvoiceClassArray) AsInputInvoiceStarGiftAuctionBid() (to InputInvoiceStarGiftAuctionBidArray) {
	for _, elem := range s {
		value, ok := elem.(*InputInvoiceStarGiftAuctionBid)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// InputInvoiceMessageArray is adapter for slice of InputInvoiceMessage.
type InputInvoiceMessageArray []InputInvoiceMessage

// Sort sorts slice of InputInvoiceMessage.
func (s InputInvoiceMessageArray) Sort(less func(a, b InputInvoiceMessage) bool) InputInvoiceMessageArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceMessage.
func (s InputInvoiceMessageArray) SortStable(less func(a, b InputInvoiceMessage) bool) InputInvoiceMessageArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceMessage.
func (s InputInvoiceMessageArray) Retain(keep func(x InputInvoiceMessage) bool) InputInvoiceMessageArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceMessageArray) First() (v InputInvoiceMessage, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceMessageArray) Last() (v InputInvoiceMessage, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceMessageArray) PopFirst() (v InputInvoiceMessage, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceMessage
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceMessageArray) Pop() (v InputInvoiceMessage, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceSlugArray is adapter for slice of InputInvoiceSlug.
type InputInvoiceSlugArray []InputInvoiceSlug

// Sort sorts slice of InputInvoiceSlug.
func (s InputInvoiceSlugArray) Sort(less func(a, b InputInvoiceSlug) bool) InputInvoiceSlugArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceSlug.
func (s InputInvoiceSlugArray) SortStable(less func(a, b InputInvoiceSlug) bool) InputInvoiceSlugArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceSlug.
func (s InputInvoiceSlugArray) Retain(keep func(x InputInvoiceSlug) bool) InputInvoiceSlugArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceSlugArray) First() (v InputInvoiceSlug, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceSlugArray) Last() (v InputInvoiceSlug, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceSlugArray) PopFirst() (v InputInvoiceSlug, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceSlug
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceSlugArray) Pop() (v InputInvoiceSlug, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoicePremiumGiftCodeArray is adapter for slice of InputInvoicePremiumGiftCode.
type InputInvoicePremiumGiftCodeArray []InputInvoicePremiumGiftCode

// Sort sorts slice of InputInvoicePremiumGiftCode.
func (s InputInvoicePremiumGiftCodeArray) Sort(less func(a, b InputInvoicePremiumGiftCode) bool) InputInvoicePremiumGiftCodeArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoicePremiumGiftCode.
func (s InputInvoicePremiumGiftCodeArray) SortStable(less func(a, b InputInvoicePremiumGiftCode) bool) InputInvoicePremiumGiftCodeArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoicePremiumGiftCode.
func (s InputInvoicePremiumGiftCodeArray) Retain(keep func(x InputInvoicePremiumGiftCode) bool) InputInvoicePremiumGiftCodeArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoicePremiumGiftCodeArray) First() (v InputInvoicePremiumGiftCode, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoicePremiumGiftCodeArray) Last() (v InputInvoicePremiumGiftCode, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoicePremiumGiftCodeArray) PopFirst() (v InputInvoicePremiumGiftCode, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoicePremiumGiftCode
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoicePremiumGiftCodeArray) Pop() (v InputInvoicePremiumGiftCode, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceStarsArray is adapter for slice of InputInvoiceStars.
type InputInvoiceStarsArray []InputInvoiceStars

// Sort sorts slice of InputInvoiceStars.
func (s InputInvoiceStarsArray) Sort(less func(a, b InputInvoiceStars) bool) InputInvoiceStarsArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceStars.
func (s InputInvoiceStarsArray) SortStable(less func(a, b InputInvoiceStars) bool) InputInvoiceStarsArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceStars.
func (s InputInvoiceStarsArray) Retain(keep func(x InputInvoiceStars) bool) InputInvoiceStarsArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceStarsArray) First() (v InputInvoiceStars, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceStarsArray) Last() (v InputInvoiceStars, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceStarsArray) PopFirst() (v InputInvoiceStars, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceStars
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceStarsArray) Pop() (v InputInvoiceStars, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceChatInviteSubscriptionArray is adapter for slice of InputInvoiceChatInviteSubscription.
type InputInvoiceChatInviteSubscriptionArray []InputInvoiceChatInviteSubscription

// Sort sorts slice of InputInvoiceChatInviteSubscription.
func (s InputInvoiceChatInviteSubscriptionArray) Sort(less func(a, b InputInvoiceChatInviteSubscription) bool) InputInvoiceChatInviteSubscriptionArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceChatInviteSubscription.
func (s InputInvoiceChatInviteSubscriptionArray) SortStable(less func(a, b InputInvoiceChatInviteSubscription) bool) InputInvoiceChatInviteSubscriptionArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceChatInviteSubscription.
func (s InputInvoiceChatInviteSubscriptionArray) Retain(keep func(x InputInvoiceChatInviteSubscription) bool) InputInvoiceChatInviteSubscriptionArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceChatInviteSubscriptionArray) First() (v InputInvoiceChatInviteSubscription, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceChatInviteSubscriptionArray) Last() (v InputInvoiceChatInviteSubscription, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceChatInviteSubscriptionArray) PopFirst() (v InputInvoiceChatInviteSubscription, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceChatInviteSubscription
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceChatInviteSubscriptionArray) Pop() (v InputInvoiceChatInviteSubscription, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceStarGiftArray is adapter for slice of InputInvoiceStarGift.
type InputInvoiceStarGiftArray []InputInvoiceStarGift

// Sort sorts slice of InputInvoiceStarGift.
func (s InputInvoiceStarGiftArray) Sort(less func(a, b InputInvoiceStarGift) bool) InputInvoiceStarGiftArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceStarGift.
func (s InputInvoiceStarGiftArray) SortStable(less func(a, b InputInvoiceStarGift) bool) InputInvoiceStarGiftArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceStarGift.
func (s InputInvoiceStarGiftArray) Retain(keep func(x InputInvoiceStarGift) bool) InputInvoiceStarGiftArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceStarGiftArray) First() (v InputInvoiceStarGift, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceStarGiftArray) Last() (v InputInvoiceStarGift, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftArray) PopFirst() (v InputInvoiceStarGift, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceStarGift
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftArray) Pop() (v InputInvoiceStarGift, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceStarGiftUpgradeArray is adapter for slice of InputInvoiceStarGiftUpgrade.
type InputInvoiceStarGiftUpgradeArray []InputInvoiceStarGiftUpgrade

// Sort sorts slice of InputInvoiceStarGiftUpgrade.
func (s InputInvoiceStarGiftUpgradeArray) Sort(less func(a, b InputInvoiceStarGiftUpgrade) bool) InputInvoiceStarGiftUpgradeArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceStarGiftUpgrade.
func (s InputInvoiceStarGiftUpgradeArray) SortStable(less func(a, b InputInvoiceStarGiftUpgrade) bool) InputInvoiceStarGiftUpgradeArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceStarGiftUpgrade.
func (s InputInvoiceStarGiftUpgradeArray) Retain(keep func(x InputInvoiceStarGiftUpgrade) bool) InputInvoiceStarGiftUpgradeArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceStarGiftUpgradeArray) First() (v InputInvoiceStarGiftUpgrade, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceStarGiftUpgradeArray) Last() (v InputInvoiceStarGiftUpgrade, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftUpgradeArray) PopFirst() (v InputInvoiceStarGiftUpgrade, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceStarGiftUpgrade
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftUpgradeArray) Pop() (v InputInvoiceStarGiftUpgrade, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceStarGiftTransferArray is adapter for slice of InputInvoiceStarGiftTransfer.
type InputInvoiceStarGiftTransferArray []InputInvoiceStarGiftTransfer

// Sort sorts slice of InputInvoiceStarGiftTransfer.
func (s InputInvoiceStarGiftTransferArray) Sort(less func(a, b InputInvoiceStarGiftTransfer) bool) InputInvoiceStarGiftTransferArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceStarGiftTransfer.
func (s InputInvoiceStarGiftTransferArray) SortStable(less func(a, b InputInvoiceStarGiftTransfer) bool) InputInvoiceStarGiftTransferArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceStarGiftTransfer.
func (s InputInvoiceStarGiftTransferArray) Retain(keep func(x InputInvoiceStarGiftTransfer) bool) InputInvoiceStarGiftTransferArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceStarGiftTransferArray) First() (v InputInvoiceStarGiftTransfer, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceStarGiftTransferArray) Last() (v InputInvoiceStarGiftTransfer, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftTransferArray) PopFirst() (v InputInvoiceStarGiftTransfer, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceStarGiftTransfer
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftTransferArray) Pop() (v InputInvoiceStarGiftTransfer, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoicePremiumGiftStarsArray is adapter for slice of InputInvoicePremiumGiftStars.
type InputInvoicePremiumGiftStarsArray []InputInvoicePremiumGiftStars

// Sort sorts slice of InputInvoicePremiumGiftStars.
func (s InputInvoicePremiumGiftStarsArray) Sort(less func(a, b InputInvoicePremiumGiftStars) bool) InputInvoicePremiumGiftStarsArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoicePremiumGiftStars.
func (s InputInvoicePremiumGiftStarsArray) SortStable(less func(a, b InputInvoicePremiumGiftStars) bool) InputInvoicePremiumGiftStarsArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoicePremiumGiftStars.
func (s InputInvoicePremiumGiftStarsArray) Retain(keep func(x InputInvoicePremiumGiftStars) bool) InputInvoicePremiumGiftStarsArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoicePremiumGiftStarsArray) First() (v InputInvoicePremiumGiftStars, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoicePremiumGiftStarsArray) Last() (v InputInvoicePremiumGiftStars, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoicePremiumGiftStarsArray) PopFirst() (v InputInvoicePremiumGiftStars, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoicePremiumGiftStars
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoicePremiumGiftStarsArray) Pop() (v InputInvoicePremiumGiftStars, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceBusinessBotTransferStarsArray is adapter for slice of InputInvoiceBusinessBotTransferStars.
type InputInvoiceBusinessBotTransferStarsArray []InputInvoiceBusinessBotTransferStars

// Sort sorts slice of InputInvoiceBusinessBotTransferStars.
func (s InputInvoiceBusinessBotTransferStarsArray) Sort(less func(a, b InputInvoiceBusinessBotTransferStars) bool) InputInvoiceBusinessBotTransferStarsArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceBusinessBotTransferStars.
func (s InputInvoiceBusinessBotTransferStarsArray) SortStable(less func(a, b InputInvoiceBusinessBotTransferStars) bool) InputInvoiceBusinessBotTransferStarsArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceBusinessBotTransferStars.
func (s InputInvoiceBusinessBotTransferStarsArray) Retain(keep func(x InputInvoiceBusinessBotTransferStars) bool) InputInvoiceBusinessBotTransferStarsArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceBusinessBotTransferStarsArray) First() (v InputInvoiceBusinessBotTransferStars, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceBusinessBotTransferStarsArray) Last() (v InputInvoiceBusinessBotTransferStars, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceBusinessBotTransferStarsArray) PopFirst() (v InputInvoiceBusinessBotTransferStars, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceBusinessBotTransferStars
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceBusinessBotTransferStarsArray) Pop() (v InputInvoiceBusinessBotTransferStars, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceStarGiftResaleArray is adapter for slice of InputInvoiceStarGiftResale.
type InputInvoiceStarGiftResaleArray []InputInvoiceStarGiftResale

// Sort sorts slice of InputInvoiceStarGiftResale.
func (s InputInvoiceStarGiftResaleArray) Sort(less func(a, b InputInvoiceStarGiftResale) bool) InputInvoiceStarGiftResaleArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceStarGiftResale.
func (s InputInvoiceStarGiftResaleArray) SortStable(less func(a, b InputInvoiceStarGiftResale) bool) InputInvoiceStarGiftResaleArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceStarGiftResale.
func (s InputInvoiceStarGiftResaleArray) Retain(keep func(x InputInvoiceStarGiftResale) bool) InputInvoiceStarGiftResaleArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceStarGiftResaleArray) First() (v InputInvoiceStarGiftResale, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceStarGiftResaleArray) Last() (v InputInvoiceStarGiftResale, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftResaleArray) PopFirst() (v InputInvoiceStarGiftResale, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceStarGiftResale
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftResaleArray) Pop() (v InputInvoiceStarGiftResale, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceStarGiftPrepaidUpgradeArray is adapter for slice of InputInvoiceStarGiftPrepaidUpgrade.
type InputInvoiceStarGiftPrepaidUpgradeArray []InputInvoiceStarGiftPrepaidUpgrade

// Sort sorts slice of InputInvoiceStarGiftPrepaidUpgrade.
func (s InputInvoiceStarGiftPrepaidUpgradeArray) Sort(less func(a, b InputInvoiceStarGiftPrepaidUpgrade) bool) InputInvoiceStarGiftPrepaidUpgradeArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceStarGiftPrepaidUpgrade.
func (s InputInvoiceStarGiftPrepaidUpgradeArray) SortStable(less func(a, b InputInvoiceStarGiftPrepaidUpgrade) bool) InputInvoiceStarGiftPrepaidUpgradeArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceStarGiftPrepaidUpgrade.
func (s InputInvoiceStarGiftPrepaidUpgradeArray) Retain(keep func(x InputInvoiceStarGiftPrepaidUpgrade) bool) InputInvoiceStarGiftPrepaidUpgradeArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceStarGiftPrepaidUpgradeArray) First() (v InputInvoiceStarGiftPrepaidUpgrade, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceStarGiftPrepaidUpgradeArray) Last() (v InputInvoiceStarGiftPrepaidUpgrade, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftPrepaidUpgradeArray) PopFirst() (v InputInvoiceStarGiftPrepaidUpgrade, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceStarGiftPrepaidUpgrade
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftPrepaidUpgradeArray) Pop() (v InputInvoiceStarGiftPrepaidUpgrade, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoicePremiumAuthCodeArray is adapter for slice of InputInvoicePremiumAuthCode.
type InputInvoicePremiumAuthCodeArray []InputInvoicePremiumAuthCode

// Sort sorts slice of InputInvoicePremiumAuthCode.
func (s InputInvoicePremiumAuthCodeArray) Sort(less func(a, b InputInvoicePremiumAuthCode) bool) InputInvoicePremiumAuthCodeArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoicePremiumAuthCode.
func (s InputInvoicePremiumAuthCodeArray) SortStable(less func(a, b InputInvoicePremiumAuthCode) bool) InputInvoicePremiumAuthCodeArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoicePremiumAuthCode.
func (s InputInvoicePremiumAuthCodeArray) Retain(keep func(x InputInvoicePremiumAuthCode) bool) InputInvoicePremiumAuthCodeArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoicePremiumAuthCodeArray) First() (v InputInvoicePremiumAuthCode, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoicePremiumAuthCodeArray) Last() (v InputInvoicePremiumAuthCode, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoicePremiumAuthCodeArray) PopFirst() (v InputInvoicePremiumAuthCode, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoicePremiumAuthCode
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoicePremiumAuthCodeArray) Pop() (v InputInvoicePremiumAuthCode, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceStarGiftDropOriginalDetailsArray is adapter for slice of InputInvoiceStarGiftDropOriginalDetails.
type InputInvoiceStarGiftDropOriginalDetailsArray []InputInvoiceStarGiftDropOriginalDetails

// Sort sorts slice of InputInvoiceStarGiftDropOriginalDetails.
func (s InputInvoiceStarGiftDropOriginalDetailsArray) Sort(less func(a, b InputInvoiceStarGiftDropOriginalDetails) bool) InputInvoiceStarGiftDropOriginalDetailsArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceStarGiftDropOriginalDetails.
func (s InputInvoiceStarGiftDropOriginalDetailsArray) SortStable(less func(a, b InputInvoiceStarGiftDropOriginalDetails) bool) InputInvoiceStarGiftDropOriginalDetailsArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceStarGiftDropOriginalDetails.
func (s InputInvoiceStarGiftDropOriginalDetailsArray) Retain(keep func(x InputInvoiceStarGiftDropOriginalDetails) bool) InputInvoiceStarGiftDropOriginalDetailsArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceStarGiftDropOriginalDetailsArray) First() (v InputInvoiceStarGiftDropOriginalDetails, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceStarGiftDropOriginalDetailsArray) Last() (v InputInvoiceStarGiftDropOriginalDetails, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftDropOriginalDetailsArray) PopFirst() (v InputInvoiceStarGiftDropOriginalDetails, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceStarGiftDropOriginalDetails
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftDropOriginalDetailsArray) Pop() (v InputInvoiceStarGiftDropOriginalDetails, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputInvoiceStarGiftAuctionBidArray is adapter for slice of InputInvoiceStarGiftAuctionBid.
type InputInvoiceStarGiftAuctionBidArray []InputInvoiceStarGiftAuctionBid

// Sort sorts slice of InputInvoiceStarGiftAuctionBid.
func (s InputInvoiceStarGiftAuctionBidArray) Sort(less func(a, b InputInvoiceStarGiftAuctionBid) bool) InputInvoiceStarGiftAuctionBidArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputInvoiceStarGiftAuctionBid.
func (s InputInvoiceStarGiftAuctionBidArray) SortStable(less func(a, b InputInvoiceStarGiftAuctionBid) bool) InputInvoiceStarGiftAuctionBidArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputInvoiceStarGiftAuctionBid.
func (s InputInvoiceStarGiftAuctionBidArray) Retain(keep func(x InputInvoiceStarGiftAuctionBid) bool) InputInvoiceStarGiftAuctionBidArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputInvoiceStarGiftAuctionBidArray) First() (v InputInvoiceStarGiftAuctionBid, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputInvoiceStarGiftAuctionBidArray) Last() (v InputInvoiceStarGiftAuctionBid, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftAuctionBidArray) PopFirst() (v InputInvoiceStarGiftAuctionBid, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputInvoiceStarGiftAuctionBid
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputInvoiceStarGiftAuctionBidArray) Pop() (v InputInvoiceStarGiftAuctionBid, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}
