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

import { l } from '@atproto/lex'
import * as LabelDefs from '../../com/atproto/label/defs.defs.js'
import * as ThemeBasic from './theme/basic.defs.js'

const $nsid = 'site.standard.publication'

export { $nsid }

/** A publication record representing a blog, website, or content platform. Publications serve as containers for documents and define the overall branding and settings. */
type Main = {
  $type: 'site.standard.publication'

  /**
   * Base publication url (ex: https://standard.site). The canonical document URL is formed by combining this value with the document path.
   */
  url: l.UriString

  /**
   * Square image to identify the publication. Should be at least 256x256.
   */
  icon?: l.BlobRef

  /**
   * Name of the publication.
   */
  name: string

  /**
   * Self-label values for this publication. Effectively content warnings.
   */
  labels?: l.$Typed<LabelDefs.SelfLabels> | l.Unknown$TypedObject

  /**
   * Simplified publication theme for tools and apps to utilize when displaying content.
   */
  basicTheme?: ThemeBasic.Main

  /**
   * Brief description of the publication.
   */
  description?: string

  /**
   * Object containing platform specific preferences (with a few shared properties).
   */
  preferences?: Preferences
}

export type { Main }

/** A publication record representing a blog, website, or content platform. Publications serve as containers for documents and define the overall branding and settings. */
const main = /*#__PURE__*/ l.record<'tid', Main>(
  'tid',
  $nsid,
  /*#__PURE__*/ l.object({
    url: /*#__PURE__*/ l.string({ format: 'uri' }),
    icon: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.blob({ accept: ['image/*'], maxSize: 1000000 }),
    ),
    name: /*#__PURE__*/ l.string({ maxLength: 5000, maxGraphemes: 500 }),
    labels: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.typedUnion(
        [
          /*#__PURE__*/ l.typedRef<LabelDefs.SelfLabels>(
            (() => LabelDefs.selfLabels) as any,
          ),
        ],
        false,
      ),
    ),
    basicTheme: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.ref<ThemeBasic.Main>((() => ThemeBasic.main) as any),
    ),
    description: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string({ maxLength: 30000, maxGraphemes: 3000 }),
    ),
    preferences: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.ref<Preferences>((() => preferences) as any),
    ),
  }),
)

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 Preferences = {
  $type?: 'site.standard.publication#preferences'

  /**
   * Boolean which decides whether the publication should appear in discovery feeds.
   */
  showInDiscover?: boolean
}

export type { Preferences }

const preferences = /*#__PURE__*/ l.typedObject<Preferences>(
  $nsid,
  'preferences',
  /*#__PURE__*/ l.object({
    showInDiscover: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.withDefault(/*#__PURE__*/ l.boolean(), true),
    ),
  }),
)

export { preferences }
