/*
 * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
 */

import { l } from '@atproto/lex'
import * as RepoStrongRef from '../../com/atproto/repo/strongRef.defs.js'

const $nsid = 'buzz.bookhive.defs'

export { $nsid }

type Review = {
  $type?: 'buzz.bookhive.defs#review'

  /**
   * The DID of the user who made the review
   */
  did: string

  /**
   * The number of stars given to the book
   */
  stars?: number

  /**
   * The handle of the user who made the review
   */
  handle: string

  /**
   * The review content
   */
  review: string

  /**
   * The date the review was created
   */
  createdAt: l.DatetimeString
}

export type { Review }

const review = /*#__PURE__*/ l.typedObject<Review>(
  $nsid,
  'review',
  /*#__PURE__*/ l.object({
    did: /*#__PURE__*/ l.string(),
    stars: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.integer()),
    handle: /*#__PURE__*/ l.string(),
    review: /*#__PURE__*/ l.string(),
    createdAt: /*#__PURE__*/ l.string({ format: 'datetime' }),
  }),
)

export { review }

type Comment = {
  $type?: 'buzz.bookhive.defs#comment'

  /**
   * The DID of the user who made the comment
   */
  did: string
  book: RepoStrongRef.Main

  /**
   * The handle of the user who made the comment
   */
  handle: string
  parent: RepoStrongRef.Main

  /**
   * The content of the comment.
   */
  comment: string

  /**
   * Client-declared timestamp when this comment was originally created.
   */
  createdAt: l.DatetimeString
}

export type { Comment }

const comment = /*#__PURE__*/ l.typedObject<Comment>(
  $nsid,
  'comment',
  /*#__PURE__*/ l.object({
    did: /*#__PURE__*/ l.string(),
    book: /*#__PURE__*/ l.ref<RepoStrongRef.Main>(
      (() => RepoStrongRef.main) as any,
    ),
    handle: /*#__PURE__*/ l.string(),
    parent: /*#__PURE__*/ l.ref<RepoStrongRef.Main>(
      (() => RepoStrongRef.main) as any,
    ),
    comment: /*#__PURE__*/ l.string({ maxLength: 100000, maxGraphemes: 10000 }),
    createdAt: /*#__PURE__*/ l.string({ format: 'datetime' }),
  }),
)

export { comment }

type Profile = {
  $type?: 'buzz.bookhive.defs#profile'
  avatar?: string
  handle: string
  reviews: number
  booksRead: number
  description?: string
  displayName: string

  /**
   * Whether the authed user is following this profile
   */
  isFollowing?: boolean
}

export type { Profile }

const profile = /*#__PURE__*/ l.typedObject<Profile>(
  $nsid,
  'profile',
  /*#__PURE__*/ l.object({
    avatar: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    handle: /*#__PURE__*/ l.string(),
    reviews: /*#__PURE__*/ l.integer({ minimum: 0 }),
    booksRead: /*#__PURE__*/ l.integer({ minimum: 0 }),
    description: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    displayName: /*#__PURE__*/ l.string(),
    isFollowing: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.boolean()),
  }),
)

export { profile }

/** User is currently reading the book */
type Reading = 'buzz.bookhive.defs#reading'

export type { Reading }

/** User is currently reading the book */
const reading = /*#__PURE__*/ l.token($nsid, 'reading')

export { reading }

type Activity = {
  $type?: 'buzz.bookhive.defs#activity'
  type: 'review' | 'rated' | 'started' | 'finished' | l.UnknownString

  /**
   * The title of the book
   */
  title: string

  /**
   * The hive id of the book
   */
  hiveId: string

  /**
   * The DID of the user who added the book
   */
  userDid: string
  createdAt: l.DatetimeString

  /**
   * The handle of the user who added the book
   */
  userHandle: string
}

export type { Activity }

const activity = /*#__PURE__*/ l.typedObject<Activity>(
  $nsid,
  'activity',
  /*#__PURE__*/ l.object({
    type: /*#__PURE__*/ l.string<{
      knownValues: ['review', 'rated', 'started', 'finished']
    }>(),
    title: /*#__PURE__*/ l.string(),
    hiveId: /*#__PURE__*/ l.string(),
    userDid: /*#__PURE__*/ l.string(),
    createdAt: /*#__PURE__*/ l.string({ format: 'datetime' }),
    userHandle: /*#__PURE__*/ l.string(),
  }),
)

export { activity }

/** User has finished reading the book */
type Finished = 'buzz.bookhive.defs#finished'

export type { Finished }

/** User has finished reading the book */
const finished = /*#__PURE__*/ l.token($nsid, 'finished')

export { finished }

type UserBook = {
  $type?: 'buzz.bookhive.defs#userBook'

  /**
   * Cover image of the book
   */
  cover?: string

  /**
   * Whether the user owns this book
   */
  owned?: boolean

  /**
   * Number of stars given to the book (1-10) which will be mapped to 1-5 stars
   */
  stars?: number

  /**
   * The title of the book
   */
  title: string

  /**
   * The book's hive id, used to correlate user's books with the hive
   */
  hiveId: string

  /**
   * Average rating (0-1000)
   */
  rating?: number

  /**
   * The book's review
   */
  review?: string
  status?:
    | 'buzz.bookhive.defs#finished'
    | 'buzz.bookhive.defs#reading'
    | 'buzz.bookhive.defs#wantToRead'
    | 'buzz.bookhive.defs#abandoned'
    | l.UnknownString

  /**
   * The authors of the book (tab separated)
   */
  authors: string

  /**
   * The DID of the user who added the book
   */
  userDid: string
  createdAt: l.DatetimeString

  /**
   * The date the user started reading the book
   */
  startedAt?: l.DatetimeString

  /**
   * Cover image of the book
   */
  thumbnail: string

  /**
   * The date the user finished reading the book
   */
  finishedAt?: l.DatetimeString

  /**
   * The handle of the user who added the book
   */
  userHandle?: string

  /**
   * Book description/summary
   */
  description?: string

  /**
   * External identifiers for the book
   */
  identifiers?: BookIdentifiers

  /**
   * Progress tracking information for the book
   */
  bookProgress?: BookProgress
}

export type { UserBook }

const userBook = /*#__PURE__*/ l.typedObject<UserBook>(
  $nsid,
  'userBook',
  /*#__PURE__*/ l.object({
    cover: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    owned: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.boolean()),
    stars: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.integer({ maximum: 10, minimum: 1 }),
    ),
    title: /*#__PURE__*/ l.string({ maxLength: 512, minLength: 1 }),
    hiveId: /*#__PURE__*/ l.string(),
    rating: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.integer({ maximum: 1000, minimum: 0 }),
    ),
    review: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string({ maxGraphemes: 15000 }),
    ),
    status: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string<{
        knownValues: [
          'buzz.bookhive.defs#finished',
          'buzz.bookhive.defs#reading',
          'buzz.bookhive.defs#wantToRead',
          'buzz.bookhive.defs#abandoned',
        ]
      }>(),
    ),
    authors: /*#__PURE__*/ l.string({ maxLength: 2048, minLength: 1 }),
    userDid: /*#__PURE__*/ l.string(),
    createdAt: /*#__PURE__*/ l.string({ format: 'datetime' }),
    startedAt: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string({ format: 'datetime' }),
    ),
    thumbnail: /*#__PURE__*/ l.string(),
    finishedAt: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string({ format: 'datetime' }),
    ),
    userHandle: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    description: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string({ maxLength: 5000 }),
    ),
    identifiers: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.ref<BookIdentifiers>((() => bookIdentifiers) as any),
    ),
    bookProgress: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.ref<BookProgress>((() => bookProgress) as any),
    ),
  }),
)

export { userBook }

/** User has abandoned the book */
type Abandoned = 'buzz.bookhive.defs#abandoned'

export type { Abandoned }

/** User has abandoned the book */
const abandoned = /*#__PURE__*/ l.token($nsid, 'abandoned')

export { abandoned }

/** User wants to read the book */
type WantToRead = 'buzz.bookhive.defs#wantToRead'

export type { WantToRead }

/** User wants to read the book */
const wantToRead = /*#__PURE__*/ l.token($nsid, 'wantToRead')

export { wantToRead }

/** Reading progress tracking data */
type BookProgress = {
  $type?: 'buzz.bookhive.defs#bookProgress'

  /**
   * How far through the book the reader is (0-100)
   */
  percent?: number

  /**
   * When the progress was last updated
   */
  updatedAt: l.DatetimeString

  /**
   * Total number of pages in the book
   */
  totalPages?: number

  /**
   * Current page the user is on
   */
  currentPage?: number

  /**
   * Total number of chapters in the book
   */
  totalChapters?: number

  /**
   * Current chapter the user is on
   */
  currentChapter?: number
}

export type { BookProgress }

/** Reading progress tracking data */
const bookProgress = /*#__PURE__*/ l.typedObject<BookProgress>(
  $nsid,
  'bookProgress',
  /*#__PURE__*/ l.object({
    percent: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.integer({ maximum: 100, minimum: 0 }),
    ),
    updatedAt: /*#__PURE__*/ l.string({ format: 'datetime' }),
    totalPages: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.integer({ minimum: 1 }),
    ),
    currentPage: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.integer({ minimum: 1 }),
    ),
    totalChapters: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.integer({ minimum: 1 }),
    ),
    currentChapter: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.integer({ minimum: 1 }),
    ),
  }),
)

export { bookProgress }

/** External identifiers for a book */
type BookIdentifiers = {
  $type?: 'buzz.bookhive.defs#bookIdentifiers'

  /**
   * BookHive's internal ID
   */
  hiveId?: string

  /**
   * 10-digit ISBN
   */
  isbn10?: string

  /**
   * 13-digit ISBN
   */
  isbn13?: string

  /**
   * Goodreads book ID
   */
  goodreadsId?: string
}

export type { BookIdentifiers }

/** External identifiers for a book */
const bookIdentifiers = /*#__PURE__*/ l.typedObject<BookIdentifiers>(
  $nsid,
  'bookIdentifiers',
  /*#__PURE__*/ l.object({
    hiveId: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    isbn10: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    isbn13: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    goodreadsId: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
  }),
)

export { bookIdentifiers }
