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

import { l } from '@atproto/lex'

const $nsid = 'fm.teal.alpha.feed.play'

export { $nsid }

/** A track that was played. */
type Main = {
  $type: 'fm.teal.alpha.feed.play'

  /**
   * The name of the track
   */
  trackName: string

  /**
   * The MusicBrainz ID of the track
   */
  trackMbId?: string

  /**
   * The MusicBrainz recording ID of the track
   */
  recordingMbId?: string

  /**
   * The length of the track in seconds
   */
  duration?: number

  /**
   * Array of artists in order of original appearance.
   */
  artists: Artist[]

  /**
   * The name of the release/album
   */
  releaseName?: string

  /**
   * The MusicBrainz release ID
   */
  releaseMbId?: string

  /**
   * The ISRC code associated with the recording
   */
  isrc?: string

  /**
   * The URL associated with this track
   */
  originUrl?: string

  /**
   * The base domain of the music service. e.g. music.apple.com, tidal.com, spotify.com.
   */
  musicServiceBaseDomain?: string

  /**
   * A user-agent style string specifying the submission client.
   */
  submissionClientAgent?: string

  /**
   * The time the track was played
   */
  playedTime?: l.DatetimeString
}

export type { Main }

/** A track that was played. */
const main = /*#__PURE__*/ l.record<'tid', Main>(
  'tid',
  $nsid,
  /*#__PURE__*/ l.object({
    trackName: /*#__PURE__*/ l.string({
      minLength: 1,
      maxLength: 256,
      maxGraphemes: 2560,
    }),
    trackMbId: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    recordingMbId: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    duration: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.integer()),
    artists: /*#__PURE__*/ l.array(
      /*#__PURE__*/ l.ref<Artist>((() => artist) as any),
    ),
    releaseName: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string({ maxLength: 256, maxGraphemes: 2560 }),
    ),
    releaseMbId: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    isrc: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    originUrl: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    musicServiceBaseDomain: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
    submissionClientAgent: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string({ maxLength: 256, maxGraphemes: 2560 }),
    ),
    playedTime: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string({ format: 'datetime' }),
    ),
  }),
)

export { main }

export const $type = $nsid
export const $isTypeOf = /*#__PURE__*/ main.isTypeOf.bind(main)
export const $build = /*#__PURE__*/ main.build.bind(main)
export const $assert = /*#__PURE__*/ main.assert.bind(main)
export const $check = /*#__PURE__*/ main.check.bind(main)
export const $cast = /*#__PURE__*/ main.cast.bind(main)
export const $ifMatches = /*#__PURE__*/ main.ifMatches.bind(main)
export const $matches = /*#__PURE__*/ main.matches.bind(main)
export const $parse = /*#__PURE__*/ main.parse.bind(main)
export const $safeParse = /*#__PURE__*/ main.safeParse.bind(main)
export const $validate = /*#__PURE__*/ main.validate.bind(main)
export const $safeValidate = /*#__PURE__*/ main.safeValidate.bind(main)

type Artist = {
  $type?: 'fm.teal.alpha.feed.play#artist'

  /**
   * The name of the artist
   */
  artistName: string

  /**
   * The MusicBrainz artist ID
   */
  artistMbId?: string
}

export type { Artist }

const artist = /*#__PURE__*/ l.typedObject<Artist>(
  $nsid,
  'artist',
  /*#__PURE__*/ l.object({
    artistName: /*#__PURE__*/ l.string({
      minLength: 1,
      maxLength: 256,
      maxGraphemes: 2560,
    }),
    artistMbId: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
  }),
)

export { artist }
