package value_objects

import (
	"github.com/google/uuid"
)

// SessionID represents a unique session identifier
type SessionID struct {
	value uuid.UUID
}

// NewSessionID creates a new SessionID
func NewSessionID() SessionID {
	return SessionID{value: uuid.New()}
}

// SessionIDFromString creates a SessionID from a string
func SessionIDFromString(s string) (SessionID, error) {
	id, err := uuid.Parse(s)
	if err != nil {
		return SessionID{}, err
	}
	return SessionID{value: id}, nil
}

// SessionIDFromUUID creates a SessionID from a UUID
func SessionIDFromUUID(id uuid.UUID) SessionID {
	return SessionID{value: id}
}

// String returns the string representation
func (id SessionID) String() string {
	return id.value.String()
}

// UUID returns the UUID value
func (id SessionID) UUID() uuid.UUID {
	return id.value
}

// IsZero checks if the SessionID is zero
func (id SessionID) IsZero() bool {
	return id.value == uuid.Nil
}

// Equals checks if two SessionIDs are equal
func (id SessionID) Equals(other SessionID) bool {
	return id.value == other.value
}
