// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"log"
	"reflect"

	"github.com/AvengeMedia/dankcalendar/core/ent/migrate"

	"entgo.io/ent"
	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"github.com/AvengeMedia/dankcalendar/core/ent/account"
	"github.com/AvengeMedia/dankcalendar/core/ent/calendar"
	"github.com/AvengeMedia/dankcalendar/core/ent/event"
	"github.com/AvengeMedia/dankcalendar/core/ent/invitationstate"
	"github.com/AvengeMedia/dankcalendar/core/ent/reminderstate"
	"github.com/AvengeMedia/dankcalendar/core/ent/secret"
	"github.com/AvengeMedia/dankcalendar/core/ent/task"

	stdsql "database/sql"
)

// Client is the client that holds all ent builders.
type Client struct {
	config
	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Account is the client for interacting with the Account builders.
	Account *AccountClient
	// Calendar is the client for interacting with the Calendar builders.
	Calendar *CalendarClient
	// Event is the client for interacting with the Event builders.
	Event *EventClient
	// InvitationState is the client for interacting with the InvitationState builders.
	InvitationState *InvitationStateClient
	// ReminderState is the client for interacting with the ReminderState builders.
	ReminderState *ReminderStateClient
	// Secret is the client for interacting with the Secret builders.
	Secret *SecretClient
	// Task is the client for interacting with the Task builders.
	Task *TaskClient
}

// NewClient creates a new client configured with the given options.
func NewClient(opts ...Option) *Client {
	client := &Client{config: newConfig(opts...)}
	client.init()
	return client
}

func (c *Client) init() {
	c.Schema = migrate.NewSchema(c.driver)
	c.Account = NewAccountClient(c.config)
	c.Calendar = NewCalendarClient(c.config)
	c.Event = NewEventClient(c.config)
	c.InvitationState = NewInvitationStateClient(c.config)
	c.ReminderState = NewReminderStateClient(c.config)
	c.Secret = NewSecretClient(c.config)
	c.Task = NewTaskClient(c.config)
}

type (
	// config is the configuration for the client and its builder.
	config struct {
		// driver used for executing database requests.
		driver dialect.Driver
		// debug enable a debug logging.
		debug bool
		// log used for logging on debug mode.
		log func(...any)
		// hooks to execute on mutations.
		hooks *hooks
		// interceptors to execute on queries.
		inters *inters
	}
	// Option function to configure the client.
	Option func(*config)
)

// newConfig creates a new config for the client.
func newConfig(opts ...Option) config {
	cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
	cfg.options(opts...)
	return cfg
}

// options applies the options on the config object.
func (c *config) options(opts ...Option) {
	for _, opt := range opts {
		opt(c)
	}
	if c.debug {
		c.driver = dialect.Debug(c.driver, c.log)
	}
}

// Debug enables debug logging on the ent.Driver.
func Debug() Option {
	return func(c *config) {
		c.debug = true
	}
}

// Log sets the logging function for debug mode.
func Log(fn func(...any)) Option {
	return func(c *config) {
		c.log = fn
	}
}

// Driver configures the client driver.
func Driver(driver dialect.Driver) Option {
	return func(c *config) {
		c.driver = driver
	}
}

// Open opens a database/sql.DB specified by the driver name and
// the data source name, and returns a new client attached to it.
// Optional parameters can be added for configuring the client.
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
	switch driverName {
	case dialect.MySQL, dialect.Postgres, dialect.SQLite:
		drv, err := sql.Open(driverName, dataSourceName)
		if err != nil {
			return nil, err
		}
		return NewClient(append(options, Driver(drv))...), nil
	default:
		return nil, fmt.Errorf("unsupported driver: %q", driverName)
	}
}

// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")

// Tx returns a new transactional client. The provided context
// is used until the transaction is committed or rolled back.
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
	if _, ok := c.driver.(*txDriver); ok {
		return nil, ErrTxStarted
	}
	tx, err := newTx(ctx, c.driver)
	if err != nil {
		return nil, fmt.Errorf("ent: starting a transaction: %w", err)
	}
	cfg := c.config
	cfg.driver = tx
	return &Tx{
		ctx:             ctx,
		config:          cfg,
		Account:         NewAccountClient(cfg),
		Calendar:        NewCalendarClient(cfg),
		Event:           NewEventClient(cfg),
		InvitationState: NewInvitationStateClient(cfg),
		ReminderState:   NewReminderStateClient(cfg),
		Secret:          NewSecretClient(cfg),
		Task:            NewTaskClient(cfg),
	}, nil
}

// BeginTx returns a transactional client with specified options.
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
	if _, ok := c.driver.(*txDriver); ok {
		return nil, errors.New("ent: cannot start a transaction within a transaction")
	}
	tx, err := c.driver.(interface {
		BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
	}).BeginTx(ctx, opts)
	if err != nil {
		return nil, fmt.Errorf("ent: starting a transaction: %w", err)
	}
	cfg := c.config
	cfg.driver = &txDriver{tx: tx, drv: c.driver}
	return &Tx{
		ctx:             ctx,
		config:          cfg,
		Account:         NewAccountClient(cfg),
		Calendar:        NewCalendarClient(cfg),
		Event:           NewEventClient(cfg),
		InvitationState: NewInvitationStateClient(cfg),
		ReminderState:   NewReminderStateClient(cfg),
		Secret:          NewSecretClient(cfg),
		Task:            NewTaskClient(cfg),
	}, nil
}

// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
//
//	client.Debug().
//		Account.
//		Query().
//		Count(ctx)
func (c *Client) Debug() *Client {
	if c.debug {
		return c
	}
	cfg := c.config
	cfg.driver = dialect.Debug(c.driver, c.log)
	client := &Client{config: cfg}
	client.init()
	return client
}

// Close closes the database connection and prevents new queries from starting.
func (c *Client) Close() error {
	return c.driver.Close()
}

// Use adds the mutation hooks to all the entity clients.
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
func (c *Client) Use(hooks ...Hook) {
	for _, n := range []interface{ Use(...Hook) }{
		c.Account, c.Calendar, c.Event, c.InvitationState, c.ReminderState, c.Secret,
		c.Task,
	} {
		n.Use(hooks...)
	}
}

// Intercept adds the query interceptors to all the entity clients.
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
func (c *Client) Intercept(interceptors ...Interceptor) {
	for _, n := range []interface{ Intercept(...Interceptor) }{
		c.Account, c.Calendar, c.Event, c.InvitationState, c.ReminderState, c.Secret,
		c.Task,
	} {
		n.Intercept(interceptors...)
	}
}

// Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
	switch m := m.(type) {
	case *AccountMutation:
		return c.Account.mutate(ctx, m)
	case *CalendarMutation:
		return c.Calendar.mutate(ctx, m)
	case *EventMutation:
		return c.Event.mutate(ctx, m)
	case *InvitationStateMutation:
		return c.InvitationState.mutate(ctx, m)
	case *ReminderStateMutation:
		return c.ReminderState.mutate(ctx, m)
	case *SecretMutation:
		return c.Secret.mutate(ctx, m)
	case *TaskMutation:
		return c.Task.mutate(ctx, m)
	default:
		return nil, fmt.Errorf("ent: unknown mutation type %T", m)
	}
}

// AccountClient is a client for the Account schema.
type AccountClient struct {
	config
}

// NewAccountClient returns a client for the Account from the given config.
func NewAccountClient(c config) *AccountClient {
	return &AccountClient{config: c}
}

// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `account.Hooks(f(g(h())))`.
func (c *AccountClient) Use(hooks ...Hook) {
	c.hooks.Account = append(c.hooks.Account, hooks...)
}

// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `account.Intercept(f(g(h())))`.
func (c *AccountClient) Intercept(interceptors ...Interceptor) {
	c.inters.Account = append(c.inters.Account, interceptors...)
}

// Create returns a builder for creating a Account entity.
func (c *AccountClient) Create() *AccountCreate {
	mutation := newAccountMutation(c.config, OpCreate)
	return &AccountCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Account entities.
func (c *AccountClient) CreateBulk(builders ...*AccountCreate) *AccountCreateBulk {
	return &AccountCreateBulk{config: c.config, builders: builders}
}

// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *AccountClient) MapCreateBulk(slice any, setFunc func(*AccountCreate, int)) *AccountCreateBulk {
	rv := reflect.ValueOf(slice)
	if rv.Kind() != reflect.Slice {
		return &AccountCreateBulk{err: fmt.Errorf("calling to AccountClient.MapCreateBulk with wrong type %T, need slice", slice)}
	}
	builders := make([]*AccountCreate, rv.Len())
	for i := 0; i < rv.Len(); i++ {
		builders[i] = c.Create()
		setFunc(builders[i], i)
	}
	return &AccountCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Account.
func (c *AccountClient) Update() *AccountUpdate {
	mutation := newAccountMutation(c.config, OpUpdate)
	return &AccountUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *AccountClient) UpdateOne(_m *Account) *AccountUpdateOne {
	mutation := newAccountMutation(c.config, OpUpdateOne, withAccount(_m))
	return &AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *AccountClient) UpdateOneID(id string) *AccountUpdateOne {
	mutation := newAccountMutation(c.config, OpUpdateOne, withAccountID(id))
	return &AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Account.
func (c *AccountClient) Delete() *AccountDelete {
	mutation := newAccountMutation(c.config, OpDelete)
	return &AccountDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *AccountClient) DeleteOne(_m *Account) *AccountDeleteOne {
	return c.DeleteOneID(_m.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *AccountClient) DeleteOneID(id string) *AccountDeleteOne {
	builder := c.Delete().Where(account.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &AccountDeleteOne{builder}
}

// Query returns a query builder for Account.
func (c *AccountClient) Query() *AccountQuery {
	return &AccountQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeAccount},
		inters: c.Interceptors(),
	}
}

// Get returns a Account entity by its id.
func (c *AccountClient) Get(ctx context.Context, id string) (*Account, error) {
	return c.Query().Where(account.ID(id)).Only(ctx)
}

// GetX is like Get, but panics if an error occurs.
func (c *AccountClient) GetX(ctx context.Context, id string) *Account {
	obj, err := c.Get(ctx, id)
	if err != nil {
		panic(err)
	}
	return obj
}

// QueryCalendars queries the calendars edge of a Account.
func (c *AccountClient) QueryCalendars(_m *Account) *CalendarQuery {
	query := (&CalendarClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := _m.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(account.Table, account.FieldID, id),
			sqlgraph.To(calendar.Table, calendar.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, account.CalendarsTable, account.CalendarsColumn),
		)
		fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QuerySecrets queries the secrets edge of a Account.
func (c *AccountClient) QuerySecrets(_m *Account) *SecretQuery {
	query := (&SecretClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := _m.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(account.Table, account.FieldID, id),
			sqlgraph.To(secret.Table, secret.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, account.SecretsTable, account.SecretsColumn),
		)
		fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// Hooks returns the client hooks.
func (c *AccountClient) Hooks() []Hook {
	return c.hooks.Account
}

// Interceptors returns the client interceptors.
func (c *AccountClient) Interceptors() []Interceptor {
	return c.inters.Account
}

func (c *AccountClient) mutate(ctx context.Context, m *AccountMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&AccountCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&AccountUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&AccountDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Account mutation op: %q", m.Op())
	}
}

// CalendarClient is a client for the Calendar schema.
type CalendarClient struct {
	config
}

// NewCalendarClient returns a client for the Calendar from the given config.
func NewCalendarClient(c config) *CalendarClient {
	return &CalendarClient{config: c}
}

// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `calendar.Hooks(f(g(h())))`.
func (c *CalendarClient) Use(hooks ...Hook) {
	c.hooks.Calendar = append(c.hooks.Calendar, hooks...)
}

// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `calendar.Intercept(f(g(h())))`.
func (c *CalendarClient) Intercept(interceptors ...Interceptor) {
	c.inters.Calendar = append(c.inters.Calendar, interceptors...)
}

// Create returns a builder for creating a Calendar entity.
func (c *CalendarClient) Create() *CalendarCreate {
	mutation := newCalendarMutation(c.config, OpCreate)
	return &CalendarCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Calendar entities.
func (c *CalendarClient) CreateBulk(builders ...*CalendarCreate) *CalendarCreateBulk {
	return &CalendarCreateBulk{config: c.config, builders: builders}
}

// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *CalendarClient) MapCreateBulk(slice any, setFunc func(*CalendarCreate, int)) *CalendarCreateBulk {
	rv := reflect.ValueOf(slice)
	if rv.Kind() != reflect.Slice {
		return &CalendarCreateBulk{err: fmt.Errorf("calling to CalendarClient.MapCreateBulk with wrong type %T, need slice", slice)}
	}
	builders := make([]*CalendarCreate, rv.Len())
	for i := 0; i < rv.Len(); i++ {
		builders[i] = c.Create()
		setFunc(builders[i], i)
	}
	return &CalendarCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Calendar.
func (c *CalendarClient) Update() *CalendarUpdate {
	mutation := newCalendarMutation(c.config, OpUpdate)
	return &CalendarUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *CalendarClient) UpdateOne(_m *Calendar) *CalendarUpdateOne {
	mutation := newCalendarMutation(c.config, OpUpdateOne, withCalendar(_m))
	return &CalendarUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *CalendarClient) UpdateOneID(id string) *CalendarUpdateOne {
	mutation := newCalendarMutation(c.config, OpUpdateOne, withCalendarID(id))
	return &CalendarUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Calendar.
func (c *CalendarClient) Delete() *CalendarDelete {
	mutation := newCalendarMutation(c.config, OpDelete)
	return &CalendarDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *CalendarClient) DeleteOne(_m *Calendar) *CalendarDeleteOne {
	return c.DeleteOneID(_m.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *CalendarClient) DeleteOneID(id string) *CalendarDeleteOne {
	builder := c.Delete().Where(calendar.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &CalendarDeleteOne{builder}
}

// Query returns a query builder for Calendar.
func (c *CalendarClient) Query() *CalendarQuery {
	return &CalendarQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeCalendar},
		inters: c.Interceptors(),
	}
}

// Get returns a Calendar entity by its id.
func (c *CalendarClient) Get(ctx context.Context, id string) (*Calendar, error) {
	return c.Query().Where(calendar.ID(id)).Only(ctx)
}

// GetX is like Get, but panics if an error occurs.
func (c *CalendarClient) GetX(ctx context.Context, id string) *Calendar {
	obj, err := c.Get(ctx, id)
	if err != nil {
		panic(err)
	}
	return obj
}

// QueryAccount queries the account edge of a Calendar.
func (c *CalendarClient) QueryAccount(_m *Calendar) *AccountQuery {
	query := (&AccountClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := _m.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(calendar.Table, calendar.FieldID, id),
			sqlgraph.To(account.Table, account.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, calendar.AccountTable, calendar.AccountColumn),
		)
		fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryEvents queries the events edge of a Calendar.
func (c *CalendarClient) QueryEvents(_m *Calendar) *EventQuery {
	query := (&EventClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := _m.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(calendar.Table, calendar.FieldID, id),
			sqlgraph.To(event.Table, event.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, calendar.EventsTable, calendar.EventsColumn),
		)
		fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryTasks queries the tasks edge of a Calendar.
func (c *CalendarClient) QueryTasks(_m *Calendar) *TaskQuery {
	query := (&TaskClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := _m.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(calendar.Table, calendar.FieldID, id),
			sqlgraph.To(task.Table, task.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, calendar.TasksTable, calendar.TasksColumn),
		)
		fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// Hooks returns the client hooks.
func (c *CalendarClient) Hooks() []Hook {
	return c.hooks.Calendar
}

// Interceptors returns the client interceptors.
func (c *CalendarClient) Interceptors() []Interceptor {
	return c.inters.Calendar
}

func (c *CalendarClient) mutate(ctx context.Context, m *CalendarMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&CalendarCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&CalendarUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&CalendarUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&CalendarDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Calendar mutation op: %q", m.Op())
	}
}

// EventClient is a client for the Event schema.
type EventClient struct {
	config
}

// NewEventClient returns a client for the Event from the given config.
func NewEventClient(c config) *EventClient {
	return &EventClient{config: c}
}

// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `event.Hooks(f(g(h())))`.
func (c *EventClient) Use(hooks ...Hook) {
	c.hooks.Event = append(c.hooks.Event, hooks...)
}

// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `event.Intercept(f(g(h())))`.
func (c *EventClient) Intercept(interceptors ...Interceptor) {
	c.inters.Event = append(c.inters.Event, interceptors...)
}

// Create returns a builder for creating a Event entity.
func (c *EventClient) Create() *EventCreate {
	mutation := newEventMutation(c.config, OpCreate)
	return &EventCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Event entities.
func (c *EventClient) CreateBulk(builders ...*EventCreate) *EventCreateBulk {
	return &EventCreateBulk{config: c.config, builders: builders}
}

// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *EventClient) MapCreateBulk(slice any, setFunc func(*EventCreate, int)) *EventCreateBulk {
	rv := reflect.ValueOf(slice)
	if rv.Kind() != reflect.Slice {
		return &EventCreateBulk{err: fmt.Errorf("calling to EventClient.MapCreateBulk with wrong type %T, need slice", slice)}
	}
	builders := make([]*EventCreate, rv.Len())
	for i := 0; i < rv.Len(); i++ {
		builders[i] = c.Create()
		setFunc(builders[i], i)
	}
	return &EventCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Event.
func (c *EventClient) Update() *EventUpdate {
	mutation := newEventMutation(c.config, OpUpdate)
	return &EventUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *EventClient) UpdateOne(_m *Event) *EventUpdateOne {
	mutation := newEventMutation(c.config, OpUpdateOne, withEvent(_m))
	return &EventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *EventClient) UpdateOneID(id string) *EventUpdateOne {
	mutation := newEventMutation(c.config, OpUpdateOne, withEventID(id))
	return &EventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Event.
func (c *EventClient) Delete() *EventDelete {
	mutation := newEventMutation(c.config, OpDelete)
	return &EventDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *EventClient) DeleteOne(_m *Event) *EventDeleteOne {
	return c.DeleteOneID(_m.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *EventClient) DeleteOneID(id string) *EventDeleteOne {
	builder := c.Delete().Where(event.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &EventDeleteOne{builder}
}

// Query returns a query builder for Event.
func (c *EventClient) Query() *EventQuery {
	return &EventQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeEvent},
		inters: c.Interceptors(),
	}
}

// Get returns a Event entity by its id.
func (c *EventClient) Get(ctx context.Context, id string) (*Event, error) {
	return c.Query().Where(event.ID(id)).Only(ctx)
}

// GetX is like Get, but panics if an error occurs.
func (c *EventClient) GetX(ctx context.Context, id string) *Event {
	obj, err := c.Get(ctx, id)
	if err != nil {
		panic(err)
	}
	return obj
}

// QueryCalendar queries the calendar edge of a Event.
func (c *EventClient) QueryCalendar(_m *Event) *CalendarQuery {
	query := (&CalendarClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := _m.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(event.Table, event.FieldID, id),
			sqlgraph.To(calendar.Table, calendar.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, event.CalendarTable, event.CalendarColumn),
		)
		fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// Hooks returns the client hooks.
func (c *EventClient) Hooks() []Hook {
	return c.hooks.Event
}

// Interceptors returns the client interceptors.
func (c *EventClient) Interceptors() []Interceptor {
	return c.inters.Event
}

func (c *EventClient) mutate(ctx context.Context, m *EventMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&EventCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&EventUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&EventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&EventDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Event mutation op: %q", m.Op())
	}
}

// InvitationStateClient is a client for the InvitationState schema.
type InvitationStateClient struct {
	config
}

// NewInvitationStateClient returns a client for the InvitationState from the given config.
func NewInvitationStateClient(c config) *InvitationStateClient {
	return &InvitationStateClient{config: c}
}

// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `invitationstate.Hooks(f(g(h())))`.
func (c *InvitationStateClient) Use(hooks ...Hook) {
	c.hooks.InvitationState = append(c.hooks.InvitationState, hooks...)
}

// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `invitationstate.Intercept(f(g(h())))`.
func (c *InvitationStateClient) Intercept(interceptors ...Interceptor) {
	c.inters.InvitationState = append(c.inters.InvitationState, interceptors...)
}

// Create returns a builder for creating a InvitationState entity.
func (c *InvitationStateClient) Create() *InvitationStateCreate {
	mutation := newInvitationStateMutation(c.config, OpCreate)
	return &InvitationStateCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of InvitationState entities.
func (c *InvitationStateClient) CreateBulk(builders ...*InvitationStateCreate) *InvitationStateCreateBulk {
	return &InvitationStateCreateBulk{config: c.config, builders: builders}
}

// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *InvitationStateClient) MapCreateBulk(slice any, setFunc func(*InvitationStateCreate, int)) *InvitationStateCreateBulk {
	rv := reflect.ValueOf(slice)
	if rv.Kind() != reflect.Slice {
		return &InvitationStateCreateBulk{err: fmt.Errorf("calling to InvitationStateClient.MapCreateBulk with wrong type %T, need slice", slice)}
	}
	builders := make([]*InvitationStateCreate, rv.Len())
	for i := 0; i < rv.Len(); i++ {
		builders[i] = c.Create()
		setFunc(builders[i], i)
	}
	return &InvitationStateCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for InvitationState.
func (c *InvitationStateClient) Update() *InvitationStateUpdate {
	mutation := newInvitationStateMutation(c.config, OpUpdate)
	return &InvitationStateUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *InvitationStateClient) UpdateOne(_m *InvitationState) *InvitationStateUpdateOne {
	mutation := newInvitationStateMutation(c.config, OpUpdateOne, withInvitationState(_m))
	return &InvitationStateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *InvitationStateClient) UpdateOneID(id int) *InvitationStateUpdateOne {
	mutation := newInvitationStateMutation(c.config, OpUpdateOne, withInvitationStateID(id))
	return &InvitationStateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for InvitationState.
func (c *InvitationStateClient) Delete() *InvitationStateDelete {
	mutation := newInvitationStateMutation(c.config, OpDelete)
	return &InvitationStateDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *InvitationStateClient) DeleteOne(_m *InvitationState) *InvitationStateDeleteOne {
	return c.DeleteOneID(_m.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *InvitationStateClient) DeleteOneID(id int) *InvitationStateDeleteOne {
	builder := c.Delete().Where(invitationstate.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &InvitationStateDeleteOne{builder}
}

// Query returns a query builder for InvitationState.
func (c *InvitationStateClient) Query() *InvitationStateQuery {
	return &InvitationStateQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeInvitationState},
		inters: c.Interceptors(),
	}
}

// Get returns a InvitationState entity by its id.
func (c *InvitationStateClient) Get(ctx context.Context, id int) (*InvitationState, error) {
	return c.Query().Where(invitationstate.ID(id)).Only(ctx)
}

// GetX is like Get, but panics if an error occurs.
func (c *InvitationStateClient) GetX(ctx context.Context, id int) *InvitationState {
	obj, err := c.Get(ctx, id)
	if err != nil {
		panic(err)
	}
	return obj
}

// Hooks returns the client hooks.
func (c *InvitationStateClient) Hooks() []Hook {
	return c.hooks.InvitationState
}

// Interceptors returns the client interceptors.
func (c *InvitationStateClient) Interceptors() []Interceptor {
	return c.inters.InvitationState
}

func (c *InvitationStateClient) mutate(ctx context.Context, m *InvitationStateMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&InvitationStateCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&InvitationStateUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&InvitationStateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&InvitationStateDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown InvitationState mutation op: %q", m.Op())
	}
}

// ReminderStateClient is a client for the ReminderState schema.
type ReminderStateClient struct {
	config
}

// NewReminderStateClient returns a client for the ReminderState from the given config.
func NewReminderStateClient(c config) *ReminderStateClient {
	return &ReminderStateClient{config: c}
}

// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `reminderstate.Hooks(f(g(h())))`.
func (c *ReminderStateClient) Use(hooks ...Hook) {
	c.hooks.ReminderState = append(c.hooks.ReminderState, hooks...)
}

// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `reminderstate.Intercept(f(g(h())))`.
func (c *ReminderStateClient) Intercept(interceptors ...Interceptor) {
	c.inters.ReminderState = append(c.inters.ReminderState, interceptors...)
}

// Create returns a builder for creating a ReminderState entity.
func (c *ReminderStateClient) Create() *ReminderStateCreate {
	mutation := newReminderStateMutation(c.config, OpCreate)
	return &ReminderStateCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of ReminderState entities.
func (c *ReminderStateClient) CreateBulk(builders ...*ReminderStateCreate) *ReminderStateCreateBulk {
	return &ReminderStateCreateBulk{config: c.config, builders: builders}
}

// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *ReminderStateClient) MapCreateBulk(slice any, setFunc func(*ReminderStateCreate, int)) *ReminderStateCreateBulk {
	rv := reflect.ValueOf(slice)
	if rv.Kind() != reflect.Slice {
		return &ReminderStateCreateBulk{err: fmt.Errorf("calling to ReminderStateClient.MapCreateBulk with wrong type %T, need slice", slice)}
	}
	builders := make([]*ReminderStateCreate, rv.Len())
	for i := 0; i < rv.Len(); i++ {
		builders[i] = c.Create()
		setFunc(builders[i], i)
	}
	return &ReminderStateCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for ReminderState.
func (c *ReminderStateClient) Update() *ReminderStateUpdate {
	mutation := newReminderStateMutation(c.config, OpUpdate)
	return &ReminderStateUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *ReminderStateClient) UpdateOne(_m *ReminderState) *ReminderStateUpdateOne {
	mutation := newReminderStateMutation(c.config, OpUpdateOne, withReminderState(_m))
	return &ReminderStateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *ReminderStateClient) UpdateOneID(id int) *ReminderStateUpdateOne {
	mutation := newReminderStateMutation(c.config, OpUpdateOne, withReminderStateID(id))
	return &ReminderStateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for ReminderState.
func (c *ReminderStateClient) Delete() *ReminderStateDelete {
	mutation := newReminderStateMutation(c.config, OpDelete)
	return &ReminderStateDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *ReminderStateClient) DeleteOne(_m *ReminderState) *ReminderStateDeleteOne {
	return c.DeleteOneID(_m.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *ReminderStateClient) DeleteOneID(id int) *ReminderStateDeleteOne {
	builder := c.Delete().Where(reminderstate.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &ReminderStateDeleteOne{builder}
}

// Query returns a query builder for ReminderState.
func (c *ReminderStateClient) Query() *ReminderStateQuery {
	return &ReminderStateQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeReminderState},
		inters: c.Interceptors(),
	}
}

// Get returns a ReminderState entity by its id.
func (c *ReminderStateClient) Get(ctx context.Context, id int) (*ReminderState, error) {
	return c.Query().Where(reminderstate.ID(id)).Only(ctx)
}

// GetX is like Get, but panics if an error occurs.
func (c *ReminderStateClient) GetX(ctx context.Context, id int) *ReminderState {
	obj, err := c.Get(ctx, id)
	if err != nil {
		panic(err)
	}
	return obj
}

// Hooks returns the client hooks.
func (c *ReminderStateClient) Hooks() []Hook {
	return c.hooks.ReminderState
}

// Interceptors returns the client interceptors.
func (c *ReminderStateClient) Interceptors() []Interceptor {
	return c.inters.ReminderState
}

func (c *ReminderStateClient) mutate(ctx context.Context, m *ReminderStateMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&ReminderStateCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&ReminderStateUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&ReminderStateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&ReminderStateDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown ReminderState mutation op: %q", m.Op())
	}
}

// SecretClient is a client for the Secret schema.
type SecretClient struct {
	config
}

// NewSecretClient returns a client for the Secret from the given config.
func NewSecretClient(c config) *SecretClient {
	return &SecretClient{config: c}
}

// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `secret.Hooks(f(g(h())))`.
func (c *SecretClient) Use(hooks ...Hook) {
	c.hooks.Secret = append(c.hooks.Secret, hooks...)
}

// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `secret.Intercept(f(g(h())))`.
func (c *SecretClient) Intercept(interceptors ...Interceptor) {
	c.inters.Secret = append(c.inters.Secret, interceptors...)
}

// Create returns a builder for creating a Secret entity.
func (c *SecretClient) Create() *SecretCreate {
	mutation := newSecretMutation(c.config, OpCreate)
	return &SecretCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Secret entities.
func (c *SecretClient) CreateBulk(builders ...*SecretCreate) *SecretCreateBulk {
	return &SecretCreateBulk{config: c.config, builders: builders}
}

// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *SecretClient) MapCreateBulk(slice any, setFunc func(*SecretCreate, int)) *SecretCreateBulk {
	rv := reflect.ValueOf(slice)
	if rv.Kind() != reflect.Slice {
		return &SecretCreateBulk{err: fmt.Errorf("calling to SecretClient.MapCreateBulk with wrong type %T, need slice", slice)}
	}
	builders := make([]*SecretCreate, rv.Len())
	for i := 0; i < rv.Len(); i++ {
		builders[i] = c.Create()
		setFunc(builders[i], i)
	}
	return &SecretCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Secret.
func (c *SecretClient) Update() *SecretUpdate {
	mutation := newSecretMutation(c.config, OpUpdate)
	return &SecretUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *SecretClient) UpdateOne(_m *Secret) *SecretUpdateOne {
	mutation := newSecretMutation(c.config, OpUpdateOne, withSecret(_m))
	return &SecretUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *SecretClient) UpdateOneID(id string) *SecretUpdateOne {
	mutation := newSecretMutation(c.config, OpUpdateOne, withSecretID(id))
	return &SecretUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Secret.
func (c *SecretClient) Delete() *SecretDelete {
	mutation := newSecretMutation(c.config, OpDelete)
	return &SecretDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *SecretClient) DeleteOne(_m *Secret) *SecretDeleteOne {
	return c.DeleteOneID(_m.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *SecretClient) DeleteOneID(id string) *SecretDeleteOne {
	builder := c.Delete().Where(secret.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &SecretDeleteOne{builder}
}

// Query returns a query builder for Secret.
func (c *SecretClient) Query() *SecretQuery {
	return &SecretQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeSecret},
		inters: c.Interceptors(),
	}
}

// Get returns a Secret entity by its id.
func (c *SecretClient) Get(ctx context.Context, id string) (*Secret, error) {
	return c.Query().Where(secret.ID(id)).Only(ctx)
}

// GetX is like Get, but panics if an error occurs.
func (c *SecretClient) GetX(ctx context.Context, id string) *Secret {
	obj, err := c.Get(ctx, id)
	if err != nil {
		panic(err)
	}
	return obj
}

// QueryAccount queries the account edge of a Secret.
func (c *SecretClient) QueryAccount(_m *Secret) *AccountQuery {
	query := (&AccountClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := _m.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(secret.Table, secret.FieldID, id),
			sqlgraph.To(account.Table, account.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, secret.AccountTable, secret.AccountColumn),
		)
		fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// Hooks returns the client hooks.
func (c *SecretClient) Hooks() []Hook {
	return c.hooks.Secret
}

// Interceptors returns the client interceptors.
func (c *SecretClient) Interceptors() []Interceptor {
	return c.inters.Secret
}

func (c *SecretClient) mutate(ctx context.Context, m *SecretMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&SecretCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&SecretUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&SecretUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&SecretDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Secret mutation op: %q", m.Op())
	}
}

// TaskClient is a client for the Task schema.
type TaskClient struct {
	config
}

// NewTaskClient returns a client for the Task from the given config.
func NewTaskClient(c config) *TaskClient {
	return &TaskClient{config: c}
}

// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `task.Hooks(f(g(h())))`.
func (c *TaskClient) Use(hooks ...Hook) {
	c.hooks.Task = append(c.hooks.Task, hooks...)
}

// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `task.Intercept(f(g(h())))`.
func (c *TaskClient) Intercept(interceptors ...Interceptor) {
	c.inters.Task = append(c.inters.Task, interceptors...)
}

// Create returns a builder for creating a Task entity.
func (c *TaskClient) Create() *TaskCreate {
	mutation := newTaskMutation(c.config, OpCreate)
	return &TaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Task entities.
func (c *TaskClient) CreateBulk(builders ...*TaskCreate) *TaskCreateBulk {
	return &TaskCreateBulk{config: c.config, builders: builders}
}

// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *TaskClient) MapCreateBulk(slice any, setFunc func(*TaskCreate, int)) *TaskCreateBulk {
	rv := reflect.ValueOf(slice)
	if rv.Kind() != reflect.Slice {
		return &TaskCreateBulk{err: fmt.Errorf("calling to TaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
	}
	builders := make([]*TaskCreate, rv.Len())
	for i := 0; i < rv.Len(); i++ {
		builders[i] = c.Create()
		setFunc(builders[i], i)
	}
	return &TaskCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Task.
func (c *TaskClient) Update() *TaskUpdate {
	mutation := newTaskMutation(c.config, OpUpdate)
	return &TaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *TaskClient) UpdateOne(_m *Task) *TaskUpdateOne {
	mutation := newTaskMutation(c.config, OpUpdateOne, withTask(_m))
	return &TaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *TaskClient) UpdateOneID(id string) *TaskUpdateOne {
	mutation := newTaskMutation(c.config, OpUpdateOne, withTaskID(id))
	return &TaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Task.
func (c *TaskClient) Delete() *TaskDelete {
	mutation := newTaskMutation(c.config, OpDelete)
	return &TaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *TaskClient) DeleteOne(_m *Task) *TaskDeleteOne {
	return c.DeleteOneID(_m.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *TaskClient) DeleteOneID(id string) *TaskDeleteOne {
	builder := c.Delete().Where(task.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &TaskDeleteOne{builder}
}

// Query returns a query builder for Task.
func (c *TaskClient) Query() *TaskQuery {
	return &TaskQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeTask},
		inters: c.Interceptors(),
	}
}

// Get returns a Task entity by its id.
func (c *TaskClient) Get(ctx context.Context, id string) (*Task, error) {
	return c.Query().Where(task.ID(id)).Only(ctx)
}

// GetX is like Get, but panics if an error occurs.
func (c *TaskClient) GetX(ctx context.Context, id string) *Task {
	obj, err := c.Get(ctx, id)
	if err != nil {
		panic(err)
	}
	return obj
}

// QueryCalendar queries the calendar edge of a Task.
func (c *TaskClient) QueryCalendar(_m *Task) *CalendarQuery {
	query := (&CalendarClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := _m.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(task.Table, task.FieldID, id),
			sqlgraph.To(calendar.Table, calendar.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, task.CalendarTable, task.CalendarColumn),
		)
		fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// Hooks returns the client hooks.
func (c *TaskClient) Hooks() []Hook {
	return c.hooks.Task
}

// Interceptors returns the client interceptors.
func (c *TaskClient) Interceptors() []Interceptor {
	return c.inters.Task
}

func (c *TaskClient) mutate(ctx context.Context, m *TaskMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&TaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&TaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&TaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&TaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Task mutation op: %q", m.Op())
	}
}

// hooks and interceptors per client, for fast access.
type (
	hooks struct {
		Account, Calendar, Event, InvitationState, ReminderState, Secret,
		Task []ent.Hook
	}
	inters struct {
		Account, Calendar, Event, InvitationState, ReminderState, Secret,
		Task []ent.Interceptor
	}
)

// ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it.
// See, database/sql#DB.ExecContext for more information.
func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) {
	ex, ok := c.driver.(interface {
		ExecContext(context.Context, string, ...any) (stdsql.Result, error)
	})
	if !ok {
		return nil, fmt.Errorf("Driver.ExecContext is not supported")
	}
	return ex.ExecContext(ctx, query, args...)
}

// QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it.
// See, database/sql#DB.QueryContext for more information.
func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) {
	q, ok := c.driver.(interface {
		QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
	})
	if !ok {
		return nil, fmt.Errorf("Driver.QueryContext is not supported")
	}
	return q.QueryContext(ctx, query, args...)
}
