//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{}
)

// InputBotInlineMessageClassArray is adapter for slice of InputBotInlineMessageClass.
type InputBotInlineMessageClassArray []InputBotInlineMessageClass

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

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

// Retain filters in-place slice of InputBotInlineMessageClass.
func (s InputBotInlineMessageClassArray) Retain(keep func(x InputBotInlineMessageClass) bool) InputBotInlineMessageClassArray {
	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 InputBotInlineMessageClassArray) First() (v InputBotInlineMessageClass, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputBotInlineMessageClassArray) Last() (v InputBotInlineMessageClass, 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 *InputBotInlineMessageClassArray) PopFirst() (v InputBotInlineMessageClass, 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 InputBotInlineMessageClass
	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 *InputBotInlineMessageClassArray) Pop() (v InputBotInlineMessageClass, 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
}

// AsInputBotInlineMessageMediaAuto returns copy with only InputBotInlineMessageMediaAuto constructors.
func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageMediaAuto() (to InputBotInlineMessageMediaAutoArray) {
	for _, elem := range s {
		value, ok := elem.(*InputBotInlineMessageMediaAuto)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputBotInlineMessageText returns copy with only InputBotInlineMessageText constructors.
func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageText() (to InputBotInlineMessageTextArray) {
	for _, elem := range s {
		value, ok := elem.(*InputBotInlineMessageText)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputBotInlineMessageMediaGeo returns copy with only InputBotInlineMessageMediaGeo constructors.
func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageMediaGeo() (to InputBotInlineMessageMediaGeoArray) {
	for _, elem := range s {
		value, ok := elem.(*InputBotInlineMessageMediaGeo)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputBotInlineMessageMediaVenue returns copy with only InputBotInlineMessageMediaVenue constructors.
func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageMediaVenue() (to InputBotInlineMessageMediaVenueArray) {
	for _, elem := range s {
		value, ok := elem.(*InputBotInlineMessageMediaVenue)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputBotInlineMessageMediaContact returns copy with only InputBotInlineMessageMediaContact constructors.
func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageMediaContact() (to InputBotInlineMessageMediaContactArray) {
	for _, elem := range s {
		value, ok := elem.(*InputBotInlineMessageMediaContact)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputBotInlineMessageGame returns copy with only InputBotInlineMessageGame constructors.
func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageGame() (to InputBotInlineMessageGameArray) {
	for _, elem := range s {
		value, ok := elem.(*InputBotInlineMessageGame)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputBotInlineMessageMediaInvoice returns copy with only InputBotInlineMessageMediaInvoice constructors.
func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageMediaInvoice() (to InputBotInlineMessageMediaInvoiceArray) {
	for _, elem := range s {
		value, ok := elem.(*InputBotInlineMessageMediaInvoice)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputBotInlineMessageMediaWebPage returns copy with only InputBotInlineMessageMediaWebPage constructors.
func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageMediaWebPage() (to InputBotInlineMessageMediaWebPageArray) {
	for _, elem := range s {
		value, ok := elem.(*InputBotInlineMessageMediaWebPage)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// InputBotInlineMessageMediaAutoArray is adapter for slice of InputBotInlineMessageMediaAuto.
type InputBotInlineMessageMediaAutoArray []InputBotInlineMessageMediaAuto

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

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

// Retain filters in-place slice of InputBotInlineMessageMediaAuto.
func (s InputBotInlineMessageMediaAutoArray) Retain(keep func(x InputBotInlineMessageMediaAuto) bool) InputBotInlineMessageMediaAutoArray {
	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 InputBotInlineMessageMediaAutoArray) First() (v InputBotInlineMessageMediaAuto, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputBotInlineMessageMediaAutoArray) Last() (v InputBotInlineMessageMediaAuto, 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 *InputBotInlineMessageMediaAutoArray) PopFirst() (v InputBotInlineMessageMediaAuto, 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 InputBotInlineMessageMediaAuto
	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 *InputBotInlineMessageMediaAutoArray) Pop() (v InputBotInlineMessageMediaAuto, 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
}

// InputBotInlineMessageTextArray is adapter for slice of InputBotInlineMessageText.
type InputBotInlineMessageTextArray []InputBotInlineMessageText

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

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

// Retain filters in-place slice of InputBotInlineMessageText.
func (s InputBotInlineMessageTextArray) Retain(keep func(x InputBotInlineMessageText) bool) InputBotInlineMessageTextArray {
	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 InputBotInlineMessageTextArray) First() (v InputBotInlineMessageText, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputBotInlineMessageTextArray) Last() (v InputBotInlineMessageText, 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 *InputBotInlineMessageTextArray) PopFirst() (v InputBotInlineMessageText, 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 InputBotInlineMessageText
	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 *InputBotInlineMessageTextArray) Pop() (v InputBotInlineMessageText, 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
}

// InputBotInlineMessageMediaGeoArray is adapter for slice of InputBotInlineMessageMediaGeo.
type InputBotInlineMessageMediaGeoArray []InputBotInlineMessageMediaGeo

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

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

// Retain filters in-place slice of InputBotInlineMessageMediaGeo.
func (s InputBotInlineMessageMediaGeoArray) Retain(keep func(x InputBotInlineMessageMediaGeo) bool) InputBotInlineMessageMediaGeoArray {
	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 InputBotInlineMessageMediaGeoArray) First() (v InputBotInlineMessageMediaGeo, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputBotInlineMessageMediaGeoArray) Last() (v InputBotInlineMessageMediaGeo, 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 *InputBotInlineMessageMediaGeoArray) PopFirst() (v InputBotInlineMessageMediaGeo, 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 InputBotInlineMessageMediaGeo
	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 *InputBotInlineMessageMediaGeoArray) Pop() (v InputBotInlineMessageMediaGeo, 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
}

// InputBotInlineMessageMediaVenueArray is adapter for slice of InputBotInlineMessageMediaVenue.
type InputBotInlineMessageMediaVenueArray []InputBotInlineMessageMediaVenue

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

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

// Retain filters in-place slice of InputBotInlineMessageMediaVenue.
func (s InputBotInlineMessageMediaVenueArray) Retain(keep func(x InputBotInlineMessageMediaVenue) bool) InputBotInlineMessageMediaVenueArray {
	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 InputBotInlineMessageMediaVenueArray) First() (v InputBotInlineMessageMediaVenue, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputBotInlineMessageMediaVenueArray) Last() (v InputBotInlineMessageMediaVenue, 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 *InputBotInlineMessageMediaVenueArray) PopFirst() (v InputBotInlineMessageMediaVenue, 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 InputBotInlineMessageMediaVenue
	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 *InputBotInlineMessageMediaVenueArray) Pop() (v InputBotInlineMessageMediaVenue, 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
}

// InputBotInlineMessageMediaContactArray is adapter for slice of InputBotInlineMessageMediaContact.
type InputBotInlineMessageMediaContactArray []InputBotInlineMessageMediaContact

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

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

// Retain filters in-place slice of InputBotInlineMessageMediaContact.
func (s InputBotInlineMessageMediaContactArray) Retain(keep func(x InputBotInlineMessageMediaContact) bool) InputBotInlineMessageMediaContactArray {
	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 InputBotInlineMessageMediaContactArray) First() (v InputBotInlineMessageMediaContact, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputBotInlineMessageMediaContactArray) Last() (v InputBotInlineMessageMediaContact, 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 *InputBotInlineMessageMediaContactArray) PopFirst() (v InputBotInlineMessageMediaContact, 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 InputBotInlineMessageMediaContact
	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 *InputBotInlineMessageMediaContactArray) Pop() (v InputBotInlineMessageMediaContact, 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
}

// InputBotInlineMessageGameArray is adapter for slice of InputBotInlineMessageGame.
type InputBotInlineMessageGameArray []InputBotInlineMessageGame

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

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

// Retain filters in-place slice of InputBotInlineMessageGame.
func (s InputBotInlineMessageGameArray) Retain(keep func(x InputBotInlineMessageGame) bool) InputBotInlineMessageGameArray {
	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 InputBotInlineMessageGameArray) First() (v InputBotInlineMessageGame, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputBotInlineMessageGameArray) Last() (v InputBotInlineMessageGame, 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 *InputBotInlineMessageGameArray) PopFirst() (v InputBotInlineMessageGame, 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 InputBotInlineMessageGame
	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 *InputBotInlineMessageGameArray) Pop() (v InputBotInlineMessageGame, 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
}

// InputBotInlineMessageMediaInvoiceArray is adapter for slice of InputBotInlineMessageMediaInvoice.
type InputBotInlineMessageMediaInvoiceArray []InputBotInlineMessageMediaInvoice

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

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

// Retain filters in-place slice of InputBotInlineMessageMediaInvoice.
func (s InputBotInlineMessageMediaInvoiceArray) Retain(keep func(x InputBotInlineMessageMediaInvoice) bool) InputBotInlineMessageMediaInvoiceArray {
	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 InputBotInlineMessageMediaInvoiceArray) First() (v InputBotInlineMessageMediaInvoice, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputBotInlineMessageMediaInvoiceArray) Last() (v InputBotInlineMessageMediaInvoice, 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 *InputBotInlineMessageMediaInvoiceArray) PopFirst() (v InputBotInlineMessageMediaInvoice, 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 InputBotInlineMessageMediaInvoice
	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 *InputBotInlineMessageMediaInvoiceArray) Pop() (v InputBotInlineMessageMediaInvoice, 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
}

// InputBotInlineMessageMediaWebPageArray is adapter for slice of InputBotInlineMessageMediaWebPage.
type InputBotInlineMessageMediaWebPageArray []InputBotInlineMessageMediaWebPage

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

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

// Retain filters in-place slice of InputBotInlineMessageMediaWebPage.
func (s InputBotInlineMessageMediaWebPageArray) Retain(keep func(x InputBotInlineMessageMediaWebPage) bool) InputBotInlineMessageMediaWebPageArray {
	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 InputBotInlineMessageMediaWebPageArray) First() (v InputBotInlineMessageMediaWebPage, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputBotInlineMessageMediaWebPageArray) Last() (v InputBotInlineMessageMediaWebPage, 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 *InputBotInlineMessageMediaWebPageArray) PopFirst() (v InputBotInlineMessageMediaWebPage, 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 InputBotInlineMessageMediaWebPage
	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 *InputBotInlineMessageMediaWebPageArray) Pop() (v InputBotInlineMessageMediaWebPage, 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
}
