import type { IValueObject } from '@core/shared/domain';

export interface AvatarIdProps {
  value: string;
}

export class AvatarId implements IValueObject<AvatarIdProps> {
  public readonly props: AvatarIdProps;

  private constructor(value: string) {
    this.props = { value };
  }

  static create(raw: string): AvatarId {
    const value = raw?.trim();

    if (!value) {
      throw new Error('Avatar ID cannot be empty');
    }

    return new AvatarId(value);
  }

  toString(): string {
    return this.props.value;
  }

  equals(other: IValueObject<AvatarIdProps>): boolean {
    return this.props.value === other.props.value;
  }
}