// Code generated by ent, DO NOT EDIT.

package ent

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

	"PasswordManager/ent/migrate"

	"PasswordManager/ent/additionalfield"
	"PasswordManager/ent/challenge"
	"PasswordManager/ent/emailchallenge"
	"PasswordManager/ent/note"
	"PasswordManager/ent/password"
	"PasswordManager/ent/session"
	"PasswordManager/ent/totpcredential"
	"PasswordManager/ent/url"
	"PasswordManager/ent/user"
	"PasswordManager/ent/vault"
	"PasswordManager/ent/webauthnchallenge"
	"PasswordManager/ent/webauthncredential"
	"PasswordManager/ent/webauthnregisterchallenge"

	"entgo.io/ent"
	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"github.com/google/uuid"
)

// 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
	// AdditionalField is the client for interacting with the AdditionalField builders.
	AdditionalField *AdditionalFieldClient
	// Challenge is the client for interacting with the Challenge builders.
	Challenge *ChallengeClient
	// EmailChallenge is the client for interacting with the EmailChallenge builders.
	EmailChallenge *EmailChallengeClient
	// Note is the client for interacting with the Note builders.
	Note *NoteClient
	// Password is the client for interacting with the Password builders.
	Password *PasswordClient
	// Session is the client for interacting with the Session builders.
	Session *SessionClient
	// TotpCredential is the client for interacting with the TotpCredential builders.
	TotpCredential *TotpCredentialClient
	// Url is the client for interacting with the Url builders.
	Url *URLClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// Vault is the client for interacting with the Vault builders.
	Vault *VaultClient
	// WebAuthnChallenge is the client for interacting with the WebAuthnChallenge builders.
	WebAuthnChallenge *WebAuthnChallengeClient
	// WebAuthnCredential is the client for interacting with the WebAuthnCredential builders.
	WebAuthnCredential *WebAuthnCredentialClient
	// WebAuthnRegisterChallenge is the client for interacting with the WebAuthnRegisterChallenge builders.
	WebAuthnRegisterChallenge *WebAuthnRegisterChallengeClient
}

// NewClient creates a new client configured with the given options.
func NewClient(opts ...Option) *Client {
	cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
	cfg.options(opts...)
	client := &Client{config: cfg}
	client.init()
	return client
}

func (c *Client) init() {
	c.Schema = migrate.NewSchema(c.driver)
	c.AdditionalField = NewAdditionalFieldClient(c.config)
	c.Challenge = NewChallengeClient(c.config)
	c.EmailChallenge = NewEmailChallengeClient(c.config)
	c.Note = NewNoteClient(c.config)
	c.Password = NewPasswordClient(c.config)
	c.Session = NewSessionClient(c.config)
	c.TotpCredential = NewTotpCredentialClient(c.config)
	c.Url = NewURLClient(c.config)
	c.User = NewUserClient(c.config)
	c.Vault = NewVaultClient(c.config)
	c.WebAuthnChallenge = NewWebAuthnChallengeClient(c.config)
	c.WebAuthnCredential = NewWebAuthnCredentialClient(c.config)
	c.WebAuthnRegisterChallenge = NewWebAuthnRegisterChallengeClient(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)
)

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

// 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, errors.New("ent: cannot start a transaction within a transaction")
	}
	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,
		AdditionalField:           NewAdditionalFieldClient(cfg),
		Challenge:                 NewChallengeClient(cfg),
		EmailChallenge:            NewEmailChallengeClient(cfg),
		Note:                      NewNoteClient(cfg),
		Password:                  NewPasswordClient(cfg),
		Session:                   NewSessionClient(cfg),
		TotpCredential:            NewTotpCredentialClient(cfg),
		Url:                       NewURLClient(cfg),
		User:                      NewUserClient(cfg),
		Vault:                     NewVaultClient(cfg),
		WebAuthnChallenge:         NewWebAuthnChallengeClient(cfg),
		WebAuthnCredential:        NewWebAuthnCredentialClient(cfg),
		WebAuthnRegisterChallenge: NewWebAuthnRegisterChallengeClient(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,
		AdditionalField:           NewAdditionalFieldClient(cfg),
		Challenge:                 NewChallengeClient(cfg),
		EmailChallenge:            NewEmailChallengeClient(cfg),
		Note:                      NewNoteClient(cfg),
		Password:                  NewPasswordClient(cfg),
		Session:                   NewSessionClient(cfg),
		TotpCredential:            NewTotpCredentialClient(cfg),
		Url:                       NewURLClient(cfg),
		User:                      NewUserClient(cfg),
		Vault:                     NewVaultClient(cfg),
		WebAuthnChallenge:         NewWebAuthnChallengeClient(cfg),
		WebAuthnCredential:        NewWebAuthnCredentialClient(cfg),
		WebAuthnRegisterChallenge: NewWebAuthnRegisterChallengeClient(cfg),
	}, nil
}

// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
//
//	client.Debug().
//		AdditionalField.
//		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.AdditionalField, c.Challenge, c.EmailChallenge, c.Note, c.Password, c.Session,
		c.TotpCredential, c.Url, c.User, c.Vault, c.WebAuthnChallenge,
		c.WebAuthnCredential, c.WebAuthnRegisterChallenge,
	} {
		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.AdditionalField, c.Challenge, c.EmailChallenge, c.Note, c.Password, c.Session,
		c.TotpCredential, c.Url, c.User, c.Vault, c.WebAuthnChallenge,
		c.WebAuthnCredential, c.WebAuthnRegisterChallenge,
	} {
		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 *AdditionalFieldMutation:
		return c.AdditionalField.mutate(ctx, m)
	case *ChallengeMutation:
		return c.Challenge.mutate(ctx, m)
	case *EmailChallengeMutation:
		return c.EmailChallenge.mutate(ctx, m)
	case *NoteMutation:
		return c.Note.mutate(ctx, m)
	case *PasswordMutation:
		return c.Password.mutate(ctx, m)
	case *SessionMutation:
		return c.Session.mutate(ctx, m)
	case *TotpCredentialMutation:
		return c.TotpCredential.mutate(ctx, m)
	case *URLMutation:
		return c.Url.mutate(ctx, m)
	case *UserMutation:
		return c.User.mutate(ctx, m)
	case *VaultMutation:
		return c.Vault.mutate(ctx, m)
	case *WebAuthnChallengeMutation:
		return c.WebAuthnChallenge.mutate(ctx, m)
	case *WebAuthnCredentialMutation:
		return c.WebAuthnCredential.mutate(ctx, m)
	case *WebAuthnRegisterChallengeMutation:
		return c.WebAuthnRegisterChallenge.mutate(ctx, m)
	default:
		return nil, fmt.Errorf("ent: unknown mutation type %T", m)
	}
}

// AdditionalFieldClient is a client for the AdditionalField schema.
type AdditionalFieldClient struct {
	config
}

// NewAdditionalFieldClient returns a client for the AdditionalField from the given config.
func NewAdditionalFieldClient(c config) *AdditionalFieldClient {
	return &AdditionalFieldClient{config: c}
}

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

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

// Create returns a builder for creating a AdditionalField entity.
func (c *AdditionalFieldClient) Create() *AdditionalFieldCreate {
	mutation := newAdditionalFieldMutation(c.config, OpCreate)
	return &AdditionalFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of AdditionalField entities.
func (c *AdditionalFieldClient) CreateBulk(builders ...*AdditionalFieldCreate) *AdditionalFieldCreateBulk {
	return &AdditionalFieldCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for AdditionalField.
func (c *AdditionalFieldClient) Update() *AdditionalFieldUpdate {
	mutation := newAdditionalFieldMutation(c.config, OpUpdate)
	return &AdditionalFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *AdditionalFieldClient) UpdateOne(af *AdditionalField) *AdditionalFieldUpdateOne {
	mutation := newAdditionalFieldMutation(c.config, OpUpdateOne, withAdditionalField(af))
	return &AdditionalFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *AdditionalFieldClient) UpdateOneID(id uuid.UUID) *AdditionalFieldUpdateOne {
	mutation := newAdditionalFieldMutation(c.config, OpUpdateOne, withAdditionalFieldID(id))
	return &AdditionalFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for AdditionalField.
func (c *AdditionalFieldClient) Delete() *AdditionalFieldDelete {
	mutation := newAdditionalFieldMutation(c.config, OpDelete)
	return &AdditionalFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *AdditionalFieldClient) DeleteOne(af *AdditionalField) *AdditionalFieldDeleteOne {
	return c.DeleteOneID(af.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *AdditionalFieldClient) DeleteOneID(id uuid.UUID) *AdditionalFieldDeleteOne {
	builder := c.Delete().Where(additionalfield.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &AdditionalFieldDeleteOne{builder}
}

// Query returns a query builder for AdditionalField.
func (c *AdditionalFieldClient) Query() *AdditionalFieldQuery {
	return &AdditionalFieldQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeAdditionalField},
		inters: c.Interceptors(),
	}
}

// Get returns a AdditionalField entity by its id.
func (c *AdditionalFieldClient) Get(ctx context.Context, id uuid.UUID) (*AdditionalField, error) {
	return c.Query().Where(additionalfield.ID(id)).Only(ctx)
}

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

// QueryPassword queries the password edge of a AdditionalField.
func (c *AdditionalFieldClient) QueryPassword(af *AdditionalField) *PasswordQuery {
	query := (&PasswordClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := af.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(additionalfield.Table, additionalfield.FieldID, id),
			sqlgraph.To(password.Table, password.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, additionalfield.PasswordTable, additionalfield.PasswordColumn),
		)
		fromV = sqlgraph.Neighbors(af.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *AdditionalFieldClient) mutate(ctx context.Context, m *AdditionalFieldMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&AdditionalFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&AdditionalFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&AdditionalFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&AdditionalFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown AdditionalField mutation op: %q", m.Op())
	}
}

// ChallengeClient is a client for the Challenge schema.
type ChallengeClient struct {
	config
}

// NewChallengeClient returns a client for the Challenge from the given config.
func NewChallengeClient(c config) *ChallengeClient {
	return &ChallengeClient{config: c}
}

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

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

// Create returns a builder for creating a Challenge entity.
func (c *ChallengeClient) Create() *ChallengeCreate {
	mutation := newChallengeMutation(c.config, OpCreate)
	return &ChallengeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Challenge entities.
func (c *ChallengeClient) CreateBulk(builders ...*ChallengeCreate) *ChallengeCreateBulk {
	return &ChallengeCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Challenge.
func (c *ChallengeClient) Update() *ChallengeUpdate {
	mutation := newChallengeMutation(c.config, OpUpdate)
	return &ChallengeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *ChallengeClient) UpdateOne(ch *Challenge) *ChallengeUpdateOne {
	mutation := newChallengeMutation(c.config, OpUpdateOne, withChallenge(ch))
	return &ChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *ChallengeClient) UpdateOneID(id uuid.UUID) *ChallengeUpdateOne {
	mutation := newChallengeMutation(c.config, OpUpdateOne, withChallengeID(id))
	return &ChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Challenge.
func (c *ChallengeClient) Delete() *ChallengeDelete {
	mutation := newChallengeMutation(c.config, OpDelete)
	return &ChallengeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *ChallengeClient) DeleteOne(ch *Challenge) *ChallengeDeleteOne {
	return c.DeleteOneID(ch.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *ChallengeClient) DeleteOneID(id uuid.UUID) *ChallengeDeleteOne {
	builder := c.Delete().Where(challenge.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &ChallengeDeleteOne{builder}
}

// Query returns a query builder for Challenge.
func (c *ChallengeClient) Query() *ChallengeQuery {
	return &ChallengeQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeChallenge},
		inters: c.Interceptors(),
	}
}

// Get returns a Challenge entity by its id.
func (c *ChallengeClient) Get(ctx context.Context, id uuid.UUID) (*Challenge, error) {
	return c.Query().Where(challenge.ID(id)).Only(ctx)
}

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

// QueryUser queries the user edge of a Challenge.
func (c *ChallengeClient) QueryUser(ch *Challenge) *UserQuery {
	query := (&UserClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := ch.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(challenge.Table, challenge.FieldID, id),
			sqlgraph.To(user.Table, user.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, challenge.UserTable, challenge.UserColumn),
		)
		fromV = sqlgraph.Neighbors(ch.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryEmailChallenge queries the emailChallenge edge of a Challenge.
func (c *ChallengeClient) QueryEmailChallenge(ch *Challenge) *EmailChallengeQuery {
	query := (&EmailChallengeClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := ch.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(challenge.Table, challenge.FieldID, id),
			sqlgraph.To(emailchallenge.Table, emailchallenge.FieldID),
			sqlgraph.Edge(sqlgraph.O2O, false, challenge.EmailChallengeTable, challenge.EmailChallengeColumn),
		)
		fromV = sqlgraph.Neighbors(ch.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryWebauthnChallenge queries the webauthnChallenge edge of a Challenge.
func (c *ChallengeClient) QueryWebauthnChallenge(ch *Challenge) *WebAuthnChallengeQuery {
	query := (&WebAuthnChallengeClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := ch.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(challenge.Table, challenge.FieldID, id),
			sqlgraph.To(webauthnchallenge.Table, webauthnchallenge.FieldID),
			sqlgraph.Edge(sqlgraph.O2O, false, challenge.WebauthnChallengeTable, challenge.WebauthnChallengeColumn),
		)
		fromV = sqlgraph.Neighbors(ch.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryTotpCredential queries the totpCredential edge of a Challenge.
func (c *ChallengeClient) QueryTotpCredential(ch *Challenge) *TotpCredentialQuery {
	query := (&TotpCredentialClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := ch.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(challenge.Table, challenge.FieldID, id),
			sqlgraph.To(totpcredential.Table, totpcredential.FieldID),
			sqlgraph.Edge(sqlgraph.O2O, false, challenge.TotpCredentialTable, challenge.TotpCredentialColumn),
		)
		fromV = sqlgraph.Neighbors(ch.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *ChallengeClient) mutate(ctx context.Context, m *ChallengeMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&ChallengeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&ChallengeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&ChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&ChallengeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Challenge mutation op: %q", m.Op())
	}
}

// EmailChallengeClient is a client for the EmailChallenge schema.
type EmailChallengeClient struct {
	config
}

// NewEmailChallengeClient returns a client for the EmailChallenge from the given config.
func NewEmailChallengeClient(c config) *EmailChallengeClient {
	return &EmailChallengeClient{config: c}
}

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

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

// Create returns a builder for creating a EmailChallenge entity.
func (c *EmailChallengeClient) Create() *EmailChallengeCreate {
	mutation := newEmailChallengeMutation(c.config, OpCreate)
	return &EmailChallengeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of EmailChallenge entities.
func (c *EmailChallengeClient) CreateBulk(builders ...*EmailChallengeCreate) *EmailChallengeCreateBulk {
	return &EmailChallengeCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for EmailChallenge.
func (c *EmailChallengeClient) Update() *EmailChallengeUpdate {
	mutation := newEmailChallengeMutation(c.config, OpUpdate)
	return &EmailChallengeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *EmailChallengeClient) UpdateOne(ec *EmailChallenge) *EmailChallengeUpdateOne {
	mutation := newEmailChallengeMutation(c.config, OpUpdateOne, withEmailChallenge(ec))
	return &EmailChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *EmailChallengeClient) UpdateOneID(id uuid.UUID) *EmailChallengeUpdateOne {
	mutation := newEmailChallengeMutation(c.config, OpUpdateOne, withEmailChallengeID(id))
	return &EmailChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for EmailChallenge.
func (c *EmailChallengeClient) Delete() *EmailChallengeDelete {
	mutation := newEmailChallengeMutation(c.config, OpDelete)
	return &EmailChallengeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *EmailChallengeClient) DeleteOne(ec *EmailChallenge) *EmailChallengeDeleteOne {
	return c.DeleteOneID(ec.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *EmailChallengeClient) DeleteOneID(id uuid.UUID) *EmailChallengeDeleteOne {
	builder := c.Delete().Where(emailchallenge.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &EmailChallengeDeleteOne{builder}
}

// Query returns a query builder for EmailChallenge.
func (c *EmailChallengeClient) Query() *EmailChallengeQuery {
	return &EmailChallengeQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeEmailChallenge},
		inters: c.Interceptors(),
	}
}

// Get returns a EmailChallenge entity by its id.
func (c *EmailChallengeClient) Get(ctx context.Context, id uuid.UUID) (*EmailChallenge, error) {
	return c.Query().Where(emailchallenge.ID(id)).Only(ctx)
}

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

// QueryChallenge queries the challenge edge of a EmailChallenge.
func (c *EmailChallengeClient) QueryChallenge(ec *EmailChallenge) *ChallengeQuery {
	query := (&ChallengeClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := ec.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(emailchallenge.Table, emailchallenge.FieldID, id),
			sqlgraph.To(challenge.Table, challenge.FieldID),
			sqlgraph.Edge(sqlgraph.O2O, true, emailchallenge.ChallengeTable, emailchallenge.ChallengeColumn),
		)
		fromV = sqlgraph.Neighbors(ec.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *EmailChallengeClient) mutate(ctx context.Context, m *EmailChallengeMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&EmailChallengeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&EmailChallengeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&EmailChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&EmailChallengeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown EmailChallenge mutation op: %q", m.Op())
	}
}

// NoteClient is a client for the Note schema.
type NoteClient struct {
	config
}

// NewNoteClient returns a client for the Note from the given config.
func NewNoteClient(c config) *NoteClient {
	return &NoteClient{config: c}
}

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

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

// Create returns a builder for creating a Note entity.
func (c *NoteClient) Create() *NoteCreate {
	mutation := newNoteMutation(c.config, OpCreate)
	return &NoteCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Note entities.
func (c *NoteClient) CreateBulk(builders ...*NoteCreate) *NoteCreateBulk {
	return &NoteCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Note.
func (c *NoteClient) Update() *NoteUpdate {
	mutation := newNoteMutation(c.config, OpUpdate)
	return &NoteUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *NoteClient) UpdateOne(n *Note) *NoteUpdateOne {
	mutation := newNoteMutation(c.config, OpUpdateOne, withNote(n))
	return &NoteUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *NoteClient) UpdateOneID(id uuid.UUID) *NoteUpdateOne {
	mutation := newNoteMutation(c.config, OpUpdateOne, withNoteID(id))
	return &NoteUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Note.
func (c *NoteClient) Delete() *NoteDelete {
	mutation := newNoteMutation(c.config, OpDelete)
	return &NoteDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *NoteClient) DeleteOne(n *Note) *NoteDeleteOne {
	return c.DeleteOneID(n.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *NoteClient) DeleteOneID(id uuid.UUID) *NoteDeleteOne {
	builder := c.Delete().Where(note.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &NoteDeleteOne{builder}
}

// Query returns a query builder for Note.
func (c *NoteClient) Query() *NoteQuery {
	return &NoteQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeNote},
		inters: c.Interceptors(),
	}
}

// Get returns a Note entity by its id.
func (c *NoteClient) Get(ctx context.Context, id uuid.UUID) (*Note, error) {
	return c.Query().Where(note.ID(id)).Only(ctx)
}

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

// QueryVault queries the vault edge of a Note.
func (c *NoteClient) QueryVault(n *Note) *VaultQuery {
	query := (&VaultClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := n.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(note.Table, note.FieldID, id),
			sqlgraph.To(vault.Table, vault.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, note.VaultTable, note.VaultColumn),
		)
		fromV = sqlgraph.Neighbors(n.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *NoteClient) mutate(ctx context.Context, m *NoteMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&NoteCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&NoteUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&NoteUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&NoteDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Note mutation op: %q", m.Op())
	}
}

// PasswordClient is a client for the Password schema.
type PasswordClient struct {
	config
}

// NewPasswordClient returns a client for the Password from the given config.
func NewPasswordClient(c config) *PasswordClient {
	return &PasswordClient{config: c}
}

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

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

// Create returns a builder for creating a Password entity.
func (c *PasswordClient) Create() *PasswordCreate {
	mutation := newPasswordMutation(c.config, OpCreate)
	return &PasswordCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Password entities.
func (c *PasswordClient) CreateBulk(builders ...*PasswordCreate) *PasswordCreateBulk {
	return &PasswordCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Password.
func (c *PasswordClient) Update() *PasswordUpdate {
	mutation := newPasswordMutation(c.config, OpUpdate)
	return &PasswordUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *PasswordClient) UpdateOne(pa *Password) *PasswordUpdateOne {
	mutation := newPasswordMutation(c.config, OpUpdateOne, withPassword(pa))
	return &PasswordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *PasswordClient) UpdateOneID(id uuid.UUID) *PasswordUpdateOne {
	mutation := newPasswordMutation(c.config, OpUpdateOne, withPasswordID(id))
	return &PasswordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Password.
func (c *PasswordClient) Delete() *PasswordDelete {
	mutation := newPasswordMutation(c.config, OpDelete)
	return &PasswordDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *PasswordClient) DeleteOne(pa *Password) *PasswordDeleteOne {
	return c.DeleteOneID(pa.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *PasswordClient) DeleteOneID(id uuid.UUID) *PasswordDeleteOne {
	builder := c.Delete().Where(password.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &PasswordDeleteOne{builder}
}

// Query returns a query builder for Password.
func (c *PasswordClient) Query() *PasswordQuery {
	return &PasswordQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypePassword},
		inters: c.Interceptors(),
	}
}

// Get returns a Password entity by its id.
func (c *PasswordClient) Get(ctx context.Context, id uuid.UUID) (*Password, error) {
	return c.Query().Where(password.ID(id)).Only(ctx)
}

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

// QueryAdditionalFields queries the additionalFields edge of a Password.
func (c *PasswordClient) QueryAdditionalFields(pa *Password) *AdditionalFieldQuery {
	query := (&AdditionalFieldClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := pa.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(password.Table, password.FieldID, id),
			sqlgraph.To(additionalfield.Table, additionalfield.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, password.AdditionalFieldsTable, password.AdditionalFieldsColumn),
		)
		fromV = sqlgraph.Neighbors(pa.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryUrls queries the urls edge of a Password.
func (c *PasswordClient) QueryUrls(pa *Password) *URLQuery {
	query := (&URLClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := pa.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(password.Table, password.FieldID, id),
			sqlgraph.To(url.Table, url.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, password.UrlsTable, password.UrlsColumn),
		)
		fromV = sqlgraph.Neighbors(pa.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryVault queries the vault edge of a Password.
func (c *PasswordClient) QueryVault(pa *Password) *VaultQuery {
	query := (&VaultClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := pa.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(password.Table, password.FieldID, id),
			sqlgraph.To(vault.Table, vault.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, password.VaultTable, password.VaultColumn),
		)
		fromV = sqlgraph.Neighbors(pa.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *PasswordClient) mutate(ctx context.Context, m *PasswordMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&PasswordCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&PasswordUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&PasswordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&PasswordDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Password mutation op: %q", m.Op())
	}
}

// SessionClient is a client for the Session schema.
type SessionClient struct {
	config
}

// NewSessionClient returns a client for the Session from the given config.
func NewSessionClient(c config) *SessionClient {
	return &SessionClient{config: c}
}

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

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

// Create returns a builder for creating a Session entity.
func (c *SessionClient) Create() *SessionCreate {
	mutation := newSessionMutation(c.config, OpCreate)
	return &SessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Session entities.
func (c *SessionClient) CreateBulk(builders ...*SessionCreate) *SessionCreateBulk {
	return &SessionCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Session.
func (c *SessionClient) Update() *SessionUpdate {
	mutation := newSessionMutation(c.config, OpUpdate)
	return &SessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *SessionClient) UpdateOne(s *Session) *SessionUpdateOne {
	mutation := newSessionMutation(c.config, OpUpdateOne, withSession(s))
	return &SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *SessionClient) UpdateOneID(id uuid.UUID) *SessionUpdateOne {
	mutation := newSessionMutation(c.config, OpUpdateOne, withSessionID(id))
	return &SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Session.
func (c *SessionClient) Delete() *SessionDelete {
	mutation := newSessionMutation(c.config, OpDelete)
	return &SessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *SessionClient) DeleteOne(s *Session) *SessionDeleteOne {
	return c.DeleteOneID(s.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *SessionClient) DeleteOneID(id uuid.UUID) *SessionDeleteOne {
	builder := c.Delete().Where(session.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &SessionDeleteOne{builder}
}

// Query returns a query builder for Session.
func (c *SessionClient) Query() *SessionQuery {
	return &SessionQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeSession},
		inters: c.Interceptors(),
	}
}

// Get returns a Session entity by its id.
func (c *SessionClient) Get(ctx context.Context, id uuid.UUID) (*Session, error) {
	return c.Query().Where(session.ID(id)).Only(ctx)
}

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

// QueryUser queries the user edge of a Session.
func (c *SessionClient) QueryUser(s *Session) *UserQuery {
	query := (&UserClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := s.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(session.Table, session.FieldID, id),
			sqlgraph.To(user.Table, user.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, session.UserTable, session.UserColumn),
		)
		fromV = sqlgraph.Neighbors(s.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *SessionClient) mutate(ctx context.Context, m *SessionMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&SessionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&SessionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&SessionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Session mutation op: %q", m.Op())
	}
}

// TotpCredentialClient is a client for the TotpCredential schema.
type TotpCredentialClient struct {
	config
}

// NewTotpCredentialClient returns a client for the TotpCredential from the given config.
func NewTotpCredentialClient(c config) *TotpCredentialClient {
	return &TotpCredentialClient{config: c}
}

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

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

// Create returns a builder for creating a TotpCredential entity.
func (c *TotpCredentialClient) Create() *TotpCredentialCreate {
	mutation := newTotpCredentialMutation(c.config, OpCreate)
	return &TotpCredentialCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of TotpCredential entities.
func (c *TotpCredentialClient) CreateBulk(builders ...*TotpCredentialCreate) *TotpCredentialCreateBulk {
	return &TotpCredentialCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for TotpCredential.
func (c *TotpCredentialClient) Update() *TotpCredentialUpdate {
	mutation := newTotpCredentialMutation(c.config, OpUpdate)
	return &TotpCredentialUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *TotpCredentialClient) UpdateOne(tc *TotpCredential) *TotpCredentialUpdateOne {
	mutation := newTotpCredentialMutation(c.config, OpUpdateOne, withTotpCredential(tc))
	return &TotpCredentialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *TotpCredentialClient) UpdateOneID(id uuid.UUID) *TotpCredentialUpdateOne {
	mutation := newTotpCredentialMutation(c.config, OpUpdateOne, withTotpCredentialID(id))
	return &TotpCredentialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for TotpCredential.
func (c *TotpCredentialClient) Delete() *TotpCredentialDelete {
	mutation := newTotpCredentialMutation(c.config, OpDelete)
	return &TotpCredentialDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *TotpCredentialClient) DeleteOne(tc *TotpCredential) *TotpCredentialDeleteOne {
	return c.DeleteOneID(tc.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *TotpCredentialClient) DeleteOneID(id uuid.UUID) *TotpCredentialDeleteOne {
	builder := c.Delete().Where(totpcredential.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &TotpCredentialDeleteOne{builder}
}

// Query returns a query builder for TotpCredential.
func (c *TotpCredentialClient) Query() *TotpCredentialQuery {
	return &TotpCredentialQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeTotpCredential},
		inters: c.Interceptors(),
	}
}

// Get returns a TotpCredential entity by its id.
func (c *TotpCredentialClient) Get(ctx context.Context, id uuid.UUID) (*TotpCredential, error) {
	return c.Query().Where(totpcredential.ID(id)).Only(ctx)
}

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

// QueryUser queries the user edge of a TotpCredential.
func (c *TotpCredentialClient) QueryUser(tc *TotpCredential) *UserQuery {
	query := (&UserClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := tc.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(totpcredential.Table, totpcredential.FieldID, id),
			sqlgraph.To(user.Table, user.FieldID),
			sqlgraph.Edge(sqlgraph.O2O, true, totpcredential.UserTable, totpcredential.UserColumn),
		)
		fromV = sqlgraph.Neighbors(tc.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryChallenge queries the challenge edge of a TotpCredential.
func (c *TotpCredentialClient) QueryChallenge(tc *TotpCredential) *ChallengeQuery {
	query := (&ChallengeClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := tc.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(totpcredential.Table, totpcredential.FieldID, id),
			sqlgraph.To(challenge.Table, challenge.FieldID),
			sqlgraph.Edge(sqlgraph.O2O, true, totpcredential.ChallengeTable, totpcredential.ChallengeColumn),
		)
		fromV = sqlgraph.Neighbors(tc.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *TotpCredentialClient) mutate(ctx context.Context, m *TotpCredentialMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&TotpCredentialCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&TotpCredentialUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&TotpCredentialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&TotpCredentialDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown TotpCredential mutation op: %q", m.Op())
	}
}

// URLClient is a client for the Url schema.
type URLClient struct {
	config
}

// NewURLClient returns a client for the Url from the given config.
func NewURLClient(c config) *URLClient {
	return &URLClient{config: c}
}

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

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

// Create returns a builder for creating a Url entity.
func (c *URLClient) Create() *URLCreate {
	mutation := newURLMutation(c.config, OpCreate)
	return &URLCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Url entities.
func (c *URLClient) CreateBulk(builders ...*URLCreate) *URLCreateBulk {
	return &URLCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Url.
func (c *URLClient) Update() *URLUpdate {
	mutation := newURLMutation(c.config, OpUpdate)
	return &URLUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *URLClient) UpdateOne(u *Url) *URLUpdateOne {
	mutation := newURLMutation(c.config, OpUpdateOne, withUrl(u))
	return &URLUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *URLClient) UpdateOneID(id uuid.UUID) *URLUpdateOne {
	mutation := newURLMutation(c.config, OpUpdateOne, withUrlID(id))
	return &URLUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Url.
func (c *URLClient) Delete() *URLDelete {
	mutation := newURLMutation(c.config, OpDelete)
	return &URLDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *URLClient) DeleteOne(u *Url) *URLDeleteOne {
	return c.DeleteOneID(u.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *URLClient) DeleteOneID(id uuid.UUID) *URLDeleteOne {
	builder := c.Delete().Where(url.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &URLDeleteOne{builder}
}

// Query returns a query builder for Url.
func (c *URLClient) Query() *URLQuery {
	return &URLQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeURL},
		inters: c.Interceptors(),
	}
}

// Get returns a Url entity by its id.
func (c *URLClient) Get(ctx context.Context, id uuid.UUID) (*Url, error) {
	return c.Query().Where(url.ID(id)).Only(ctx)
}

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

// QueryPassword queries the password edge of a Url.
func (c *URLClient) QueryPassword(u *Url) *PasswordQuery {
	query := (&PasswordClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := u.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(url.Table, url.FieldID, id),
			sqlgraph.To(password.Table, password.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, url.PasswordTable, url.PasswordColumn),
		)
		fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *URLClient) mutate(ctx context.Context, m *URLMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&URLCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&URLUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&URLUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&URLDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Url mutation op: %q", m.Op())
	}
}

// UserClient is a client for the User schema.
type UserClient struct {
	config
}

// NewUserClient returns a client for the User from the given config.
func NewUserClient(c config) *UserClient {
	return &UserClient{config: c}
}

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

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

// Create returns a builder for creating a User entity.
func (c *UserClient) Create() *UserCreate {
	mutation := newUserMutation(c.config, OpCreate)
	return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of User entities.
func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk {
	return &UserCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for User.
func (c *UserClient) Update() *UserUpdate {
	mutation := newUserMutation(c.config, OpUpdate)
	return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *UserClient) UpdateOne(u *User) *UserUpdateOne {
	mutation := newUserMutation(c.config, OpUpdateOne, withUser(u))
	return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *UserClient) UpdateOneID(id uuid.UUID) *UserUpdateOne {
	mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id))
	return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for User.
func (c *UserClient) Delete() *UserDelete {
	mutation := newUserMutation(c.config, OpDelete)
	return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *UserClient) DeleteOne(u *User) *UserDeleteOne {
	return c.DeleteOneID(u.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *UserClient) DeleteOneID(id uuid.UUID) *UserDeleteOne {
	builder := c.Delete().Where(user.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &UserDeleteOne{builder}
}

// Query returns a query builder for User.
func (c *UserClient) Query() *UserQuery {
	return &UserQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeUser},
		inters: c.Interceptors(),
	}
}

// Get returns a User entity by its id.
func (c *UserClient) Get(ctx context.Context, id uuid.UUID) (*User, error) {
	return c.Query().Where(user.ID(id)).Only(ctx)
}

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

// QueryTotpCredential queries the totpCredential edge of a User.
func (c *UserClient) QueryTotpCredential(u *User) *TotpCredentialQuery {
	query := (&TotpCredentialClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := u.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(user.Table, user.FieldID, id),
			sqlgraph.To(totpcredential.Table, totpcredential.FieldID),
			sqlgraph.Edge(sqlgraph.O2O, false, user.TotpCredentialTable, user.TotpCredentialColumn),
		)
		fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryWebauthnCredentials queries the webauthnCredentials edge of a User.
func (c *UserClient) QueryWebauthnCredentials(u *User) *WebAuthnCredentialQuery {
	query := (&WebAuthnCredentialClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := u.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(user.Table, user.FieldID, id),
			sqlgraph.To(webauthncredential.Table, webauthncredential.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, user.WebauthnCredentialsTable, user.WebauthnCredentialsColumn),
		)
		fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryWebauthnRegisterChallenges queries the webauthnRegisterChallenges edge of a User.
func (c *UserClient) QueryWebauthnRegisterChallenges(u *User) *WebAuthnRegisterChallengeQuery {
	query := (&WebAuthnRegisterChallengeClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := u.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(user.Table, user.FieldID, id),
			sqlgraph.To(webauthnregisterchallenge.Table, webauthnregisterchallenge.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, user.WebauthnRegisterChallengesTable, user.WebauthnRegisterChallengesColumn),
		)
		fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryVaults queries the vaults edge of a User.
func (c *UserClient) QueryVaults(u *User) *VaultQuery {
	query := (&VaultClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := u.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(user.Table, user.FieldID, id),
			sqlgraph.To(vault.Table, vault.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, user.VaultsTable, user.VaultsColumn),
		)
		fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QuerySessions queries the sessions edge of a User.
func (c *UserClient) QuerySessions(u *User) *SessionQuery {
	query := (&SessionClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := u.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(user.Table, user.FieldID, id),
			sqlgraph.To(session.Table, session.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, user.SessionsTable, user.SessionsColumn),
		)
		fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryChallenges queries the challenges edge of a User.
func (c *UserClient) QueryChallenges(u *User) *ChallengeQuery {
	query := (&ChallengeClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := u.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(user.Table, user.FieldID, id),
			sqlgraph.To(challenge.Table, challenge.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, user.ChallengesTable, user.ChallengesColumn),
		)
		fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op())
	}
}

// VaultClient is a client for the Vault schema.
type VaultClient struct {
	config
}

// NewVaultClient returns a client for the Vault from the given config.
func NewVaultClient(c config) *VaultClient {
	return &VaultClient{config: c}
}

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

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

// Create returns a builder for creating a Vault entity.
func (c *VaultClient) Create() *VaultCreate {
	mutation := newVaultMutation(c.config, OpCreate)
	return &VaultCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of Vault entities.
func (c *VaultClient) CreateBulk(builders ...*VaultCreate) *VaultCreateBulk {
	return &VaultCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for Vault.
func (c *VaultClient) Update() *VaultUpdate {
	mutation := newVaultMutation(c.config, OpUpdate)
	return &VaultUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *VaultClient) UpdateOne(v *Vault) *VaultUpdateOne {
	mutation := newVaultMutation(c.config, OpUpdateOne, withVault(v))
	return &VaultUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *VaultClient) UpdateOneID(id uuid.UUID) *VaultUpdateOne {
	mutation := newVaultMutation(c.config, OpUpdateOne, withVaultID(id))
	return &VaultUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for Vault.
func (c *VaultClient) Delete() *VaultDelete {
	mutation := newVaultMutation(c.config, OpDelete)
	return &VaultDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *VaultClient) DeleteOne(v *Vault) *VaultDeleteOne {
	return c.DeleteOneID(v.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *VaultClient) DeleteOneID(id uuid.UUID) *VaultDeleteOne {
	builder := c.Delete().Where(vault.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &VaultDeleteOne{builder}
}

// Query returns a query builder for Vault.
func (c *VaultClient) Query() *VaultQuery {
	return &VaultQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeVault},
		inters: c.Interceptors(),
	}
}

// Get returns a Vault entity by its id.
func (c *VaultClient) Get(ctx context.Context, id uuid.UUID) (*Vault, error) {
	return c.Query().Where(vault.ID(id)).Only(ctx)
}

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

// QueryPasswords queries the passwords edge of a Vault.
func (c *VaultClient) QueryPasswords(v *Vault) *PasswordQuery {
	query := (&PasswordClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := v.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(vault.Table, vault.FieldID, id),
			sqlgraph.To(password.Table, password.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, vault.PasswordsTable, vault.PasswordsColumn),
		)
		fromV = sqlgraph.Neighbors(v.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryNotes queries the notes edge of a Vault.
func (c *VaultClient) QueryNotes(v *Vault) *NoteQuery {
	query := (&NoteClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := v.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(vault.Table, vault.FieldID, id),
			sqlgraph.To(note.Table, note.FieldID),
			sqlgraph.Edge(sqlgraph.O2M, false, vault.NotesTable, vault.NotesColumn),
		)
		fromV = sqlgraph.Neighbors(v.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

// QueryUser queries the user edge of a Vault.
func (c *VaultClient) QueryUser(v *Vault) *UserQuery {
	query := (&UserClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := v.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(vault.Table, vault.FieldID, id),
			sqlgraph.To(user.Table, user.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, vault.UserTable, vault.UserColumn),
		)
		fromV = sqlgraph.Neighbors(v.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *VaultClient) mutate(ctx context.Context, m *VaultMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&VaultCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&VaultUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&VaultUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&VaultDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown Vault mutation op: %q", m.Op())
	}
}

// WebAuthnChallengeClient is a client for the WebAuthnChallenge schema.
type WebAuthnChallengeClient struct {
	config
}

// NewWebAuthnChallengeClient returns a client for the WebAuthnChallenge from the given config.
func NewWebAuthnChallengeClient(c config) *WebAuthnChallengeClient {
	return &WebAuthnChallengeClient{config: c}
}

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

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

// Create returns a builder for creating a WebAuthnChallenge entity.
func (c *WebAuthnChallengeClient) Create() *WebAuthnChallengeCreate {
	mutation := newWebAuthnChallengeMutation(c.config, OpCreate)
	return &WebAuthnChallengeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of WebAuthnChallenge entities.
func (c *WebAuthnChallengeClient) CreateBulk(builders ...*WebAuthnChallengeCreate) *WebAuthnChallengeCreateBulk {
	return &WebAuthnChallengeCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for WebAuthnChallenge.
func (c *WebAuthnChallengeClient) Update() *WebAuthnChallengeUpdate {
	mutation := newWebAuthnChallengeMutation(c.config, OpUpdate)
	return &WebAuthnChallengeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *WebAuthnChallengeClient) UpdateOne(wac *WebAuthnChallenge) *WebAuthnChallengeUpdateOne {
	mutation := newWebAuthnChallengeMutation(c.config, OpUpdateOne, withWebAuthnChallenge(wac))
	return &WebAuthnChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *WebAuthnChallengeClient) UpdateOneID(id uuid.UUID) *WebAuthnChallengeUpdateOne {
	mutation := newWebAuthnChallengeMutation(c.config, OpUpdateOne, withWebAuthnChallengeID(id))
	return &WebAuthnChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for WebAuthnChallenge.
func (c *WebAuthnChallengeClient) Delete() *WebAuthnChallengeDelete {
	mutation := newWebAuthnChallengeMutation(c.config, OpDelete)
	return &WebAuthnChallengeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *WebAuthnChallengeClient) DeleteOne(wac *WebAuthnChallenge) *WebAuthnChallengeDeleteOne {
	return c.DeleteOneID(wac.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *WebAuthnChallengeClient) DeleteOneID(id uuid.UUID) *WebAuthnChallengeDeleteOne {
	builder := c.Delete().Where(webauthnchallenge.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &WebAuthnChallengeDeleteOne{builder}
}

// Query returns a query builder for WebAuthnChallenge.
func (c *WebAuthnChallengeClient) Query() *WebAuthnChallengeQuery {
	return &WebAuthnChallengeQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeWebAuthnChallenge},
		inters: c.Interceptors(),
	}
}

// Get returns a WebAuthnChallenge entity by its id.
func (c *WebAuthnChallengeClient) Get(ctx context.Context, id uuid.UUID) (*WebAuthnChallenge, error) {
	return c.Query().Where(webauthnchallenge.ID(id)).Only(ctx)
}

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

// QueryChallenge queries the challenge edge of a WebAuthnChallenge.
func (c *WebAuthnChallengeClient) QueryChallenge(wac *WebAuthnChallenge) *ChallengeQuery {
	query := (&ChallengeClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := wac.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(webauthnchallenge.Table, webauthnchallenge.FieldID, id),
			sqlgraph.To(challenge.Table, challenge.FieldID),
			sqlgraph.Edge(sqlgraph.O2O, true, webauthnchallenge.ChallengeTable, webauthnchallenge.ChallengeColumn),
		)
		fromV = sqlgraph.Neighbors(wac.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *WebAuthnChallengeClient) mutate(ctx context.Context, m *WebAuthnChallengeMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&WebAuthnChallengeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&WebAuthnChallengeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&WebAuthnChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&WebAuthnChallengeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown WebAuthnChallenge mutation op: %q", m.Op())
	}
}

// WebAuthnCredentialClient is a client for the WebAuthnCredential schema.
type WebAuthnCredentialClient struct {
	config
}

// NewWebAuthnCredentialClient returns a client for the WebAuthnCredential from the given config.
func NewWebAuthnCredentialClient(c config) *WebAuthnCredentialClient {
	return &WebAuthnCredentialClient{config: c}
}

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

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

// Create returns a builder for creating a WebAuthnCredential entity.
func (c *WebAuthnCredentialClient) Create() *WebAuthnCredentialCreate {
	mutation := newWebAuthnCredentialMutation(c.config, OpCreate)
	return &WebAuthnCredentialCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of WebAuthnCredential entities.
func (c *WebAuthnCredentialClient) CreateBulk(builders ...*WebAuthnCredentialCreate) *WebAuthnCredentialCreateBulk {
	return &WebAuthnCredentialCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for WebAuthnCredential.
func (c *WebAuthnCredentialClient) Update() *WebAuthnCredentialUpdate {
	mutation := newWebAuthnCredentialMutation(c.config, OpUpdate)
	return &WebAuthnCredentialUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *WebAuthnCredentialClient) UpdateOne(wac *WebAuthnCredential) *WebAuthnCredentialUpdateOne {
	mutation := newWebAuthnCredentialMutation(c.config, OpUpdateOne, withWebAuthnCredential(wac))
	return &WebAuthnCredentialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *WebAuthnCredentialClient) UpdateOneID(id uuid.UUID) *WebAuthnCredentialUpdateOne {
	mutation := newWebAuthnCredentialMutation(c.config, OpUpdateOne, withWebAuthnCredentialID(id))
	return &WebAuthnCredentialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for WebAuthnCredential.
func (c *WebAuthnCredentialClient) Delete() *WebAuthnCredentialDelete {
	mutation := newWebAuthnCredentialMutation(c.config, OpDelete)
	return &WebAuthnCredentialDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *WebAuthnCredentialClient) DeleteOne(wac *WebAuthnCredential) *WebAuthnCredentialDeleteOne {
	return c.DeleteOneID(wac.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *WebAuthnCredentialClient) DeleteOneID(id uuid.UUID) *WebAuthnCredentialDeleteOne {
	builder := c.Delete().Where(webauthncredential.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &WebAuthnCredentialDeleteOne{builder}
}

// Query returns a query builder for WebAuthnCredential.
func (c *WebAuthnCredentialClient) Query() *WebAuthnCredentialQuery {
	return &WebAuthnCredentialQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeWebAuthnCredential},
		inters: c.Interceptors(),
	}
}

// Get returns a WebAuthnCredential entity by its id.
func (c *WebAuthnCredentialClient) Get(ctx context.Context, id uuid.UUID) (*WebAuthnCredential, error) {
	return c.Query().Where(webauthncredential.ID(id)).Only(ctx)
}

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

// QueryUser queries the user edge of a WebAuthnCredential.
func (c *WebAuthnCredentialClient) QueryUser(wac *WebAuthnCredential) *UserQuery {
	query := (&UserClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := wac.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(webauthncredential.Table, webauthncredential.FieldID, id),
			sqlgraph.To(user.Table, user.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, webauthncredential.UserTable, webauthncredential.UserColumn),
		)
		fromV = sqlgraph.Neighbors(wac.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *WebAuthnCredentialClient) mutate(ctx context.Context, m *WebAuthnCredentialMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&WebAuthnCredentialCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&WebAuthnCredentialUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&WebAuthnCredentialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&WebAuthnCredentialDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown WebAuthnCredential mutation op: %q", m.Op())
	}
}

// WebAuthnRegisterChallengeClient is a client for the WebAuthnRegisterChallenge schema.
type WebAuthnRegisterChallengeClient struct {
	config
}

// NewWebAuthnRegisterChallengeClient returns a client for the WebAuthnRegisterChallenge from the given config.
func NewWebAuthnRegisterChallengeClient(c config) *WebAuthnRegisterChallengeClient {
	return &WebAuthnRegisterChallengeClient{config: c}
}

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

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

// Create returns a builder for creating a WebAuthnRegisterChallenge entity.
func (c *WebAuthnRegisterChallengeClient) Create() *WebAuthnRegisterChallengeCreate {
	mutation := newWebAuthnRegisterChallengeMutation(c.config, OpCreate)
	return &WebAuthnRegisterChallengeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// CreateBulk returns a builder for creating a bulk of WebAuthnRegisterChallenge entities.
func (c *WebAuthnRegisterChallengeClient) CreateBulk(builders ...*WebAuthnRegisterChallengeCreate) *WebAuthnRegisterChallengeCreateBulk {
	return &WebAuthnRegisterChallengeCreateBulk{config: c.config, builders: builders}
}

// Update returns an update builder for WebAuthnRegisterChallenge.
func (c *WebAuthnRegisterChallengeClient) Update() *WebAuthnRegisterChallengeUpdate {
	mutation := newWebAuthnRegisterChallengeMutation(c.config, OpUpdate)
	return &WebAuthnRegisterChallengeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOne returns an update builder for the given entity.
func (c *WebAuthnRegisterChallengeClient) UpdateOne(warc *WebAuthnRegisterChallenge) *WebAuthnRegisterChallengeUpdateOne {
	mutation := newWebAuthnRegisterChallengeMutation(c.config, OpUpdateOne, withWebAuthnRegisterChallenge(warc))
	return &WebAuthnRegisterChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// UpdateOneID returns an update builder for the given id.
func (c *WebAuthnRegisterChallengeClient) UpdateOneID(id uuid.UUID) *WebAuthnRegisterChallengeUpdateOne {
	mutation := newWebAuthnRegisterChallengeMutation(c.config, OpUpdateOne, withWebAuthnRegisterChallengeID(id))
	return &WebAuthnRegisterChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// Delete returns a delete builder for WebAuthnRegisterChallenge.
func (c *WebAuthnRegisterChallengeClient) Delete() *WebAuthnRegisterChallengeDelete {
	mutation := newWebAuthnRegisterChallengeMutation(c.config, OpDelete)
	return &WebAuthnRegisterChallengeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}

// DeleteOne returns a builder for deleting the given entity.
func (c *WebAuthnRegisterChallengeClient) DeleteOne(warc *WebAuthnRegisterChallenge) *WebAuthnRegisterChallengeDeleteOne {
	return c.DeleteOneID(warc.ID)
}

// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *WebAuthnRegisterChallengeClient) DeleteOneID(id uuid.UUID) *WebAuthnRegisterChallengeDeleteOne {
	builder := c.Delete().Where(webauthnregisterchallenge.ID(id))
	builder.mutation.id = &id
	builder.mutation.op = OpDeleteOne
	return &WebAuthnRegisterChallengeDeleteOne{builder}
}

// Query returns a query builder for WebAuthnRegisterChallenge.
func (c *WebAuthnRegisterChallengeClient) Query() *WebAuthnRegisterChallengeQuery {
	return &WebAuthnRegisterChallengeQuery{
		config: c.config,
		ctx:    &QueryContext{Type: TypeWebAuthnRegisterChallenge},
		inters: c.Interceptors(),
	}
}

// Get returns a WebAuthnRegisterChallenge entity by its id.
func (c *WebAuthnRegisterChallengeClient) Get(ctx context.Context, id uuid.UUID) (*WebAuthnRegisterChallenge, error) {
	return c.Query().Where(webauthnregisterchallenge.ID(id)).Only(ctx)
}

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

// QueryUser queries the user edge of a WebAuthnRegisterChallenge.
func (c *WebAuthnRegisterChallengeClient) QueryUser(warc *WebAuthnRegisterChallenge) *UserQuery {
	query := (&UserClient{config: c.config}).Query()
	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
		id := warc.ID
		step := sqlgraph.NewStep(
			sqlgraph.From(webauthnregisterchallenge.Table, webauthnregisterchallenge.FieldID, id),
			sqlgraph.To(user.Table, user.FieldID),
			sqlgraph.Edge(sqlgraph.M2O, true, webauthnregisterchallenge.UserTable, webauthnregisterchallenge.UserColumn),
		)
		fromV = sqlgraph.Neighbors(warc.driver.Dialect(), step)
		return fromV, nil
	}
	return query
}

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

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

func (c *WebAuthnRegisterChallengeClient) mutate(ctx context.Context, m *WebAuthnRegisterChallengeMutation) (Value, error) {
	switch m.Op() {
	case OpCreate:
		return (&WebAuthnRegisterChallengeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdate:
		return (&WebAuthnRegisterChallengeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpUpdateOne:
		return (&WebAuthnRegisterChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
	case OpDelete, OpDeleteOne:
		return (&WebAuthnRegisterChallengeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
	default:
		return nil, fmt.Errorf("ent: unknown WebAuthnRegisterChallenge mutation op: %q", m.Op())
	}
}

// hooks and interceptors per client, for fast access.
type (
	hooks struct {
		AdditionalField, Challenge, EmailChallenge, Note, Password, Session,
		TotpCredential, Url, User, Vault, WebAuthnChallenge, WebAuthnCredential,
		WebAuthnRegisterChallenge []ent.Hook
	}
	inters struct {
		AdditionalField, Challenge, EmailChallenge, Note, Password, Session,
		TotpCredential, Url, User, Vault, WebAuthnChallenge, WebAuthnCredential,
		WebAuthnRegisterChallenge []ent.Interceptor
	}
)
