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

import { l } from '@atproto/lex'

const $nsid = 'com.atproto.label.defs'

export { $nsid }

/** Metadata tag on an atproto resource (eg, repo or record). */
type Label = {
  $type?: 'com.atproto.label.defs#label'

  /**
   * Optionally, CID specifying the specific version of 'uri' resource this label applies to.
   */
  cid?: l.CidString

  /**
   * Timestamp when this label was created.
   */
  cts: l.DatetimeString

  /**
   * Timestamp at which this label expires (no longer applies).
   */
  exp?: l.DatetimeString

  /**
   * If true, this is a negation label, overwriting a previous label.
   */
  neg?: boolean

  /**
   * Signature of dag-cbor encoded label.
   */
  sig?: Uint8Array

  /**
   * DID of the actor who created this label.
   */
  src: l.DidString

  /**
   * AT URI of the record, repository (account), or other resource that this label applies to.
   */
  uri: l.UriString

  /**
   * The short string name of the value or type of this label.
   */
  val: string

  /**
   * The AT Protocol version of the label object.
   */
  ver?: number
}

export type { Label }

/** Metadata tag on an atproto resource (eg, repo or record). */
const label = /*#__PURE__*/ l.typedObject<Label>(
  $nsid,
  'label',
  /*#__PURE__*/ l.object({
    cid: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string({ format: 'cid' })),
    cts: /*#__PURE__*/ l.string({ format: 'datetime' }),
    exp: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.string({ format: 'datetime' }),
    ),
    neg: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.boolean()),
    sig: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.bytes()),
    src: /*#__PURE__*/ l.string({ format: 'did' }),
    uri: /*#__PURE__*/ l.string({ format: 'uri' }),
    val: /*#__PURE__*/ l.string({ maxLength: 128 }),
    ver: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.integer()),
  }),
)

export { label }

/** Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel. */
type SelfLabel = {
  $type?: 'com.atproto.label.defs#selfLabel'

  /**
   * The short string name of the value or type of this label.
   */
  val: string
}

export type { SelfLabel }

/** Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel. */
const selfLabel = /*#__PURE__*/ l.typedObject<SelfLabel>(
  $nsid,
  'selfLabel',
  /*#__PURE__*/ l.object({ val: /*#__PURE__*/ l.string({ maxLength: 128 }) }),
)

export { selfLabel }

type LabelValue =
  | '!hide'
  | '!warn'
  | '!no-unauthenticated'
  | 'porn'
  | 'sexual'
  | 'nudity'
  | 'graphic-media'
  | 'bot'
  | l.UnknownString

export type { LabelValue }

const labelValue = /*#__PURE__*/ l.string<{
  knownValues: [
    '!hide',
    '!warn',
    '!no-unauthenticated',
    'porn',
    'sexual',
    'nudity',
    'graphic-media',
    'bot',
  ]
}>()

export { labelValue }

/** Metadata tags on an atproto record, published by the author within the record. */
type SelfLabels = {
  $type?: 'com.atproto.label.defs#selfLabels'
  values: SelfLabel[]
}

export type { SelfLabels }

/** Metadata tags on an atproto record, published by the author within the record. */
const selfLabels = /*#__PURE__*/ l.typedObject<SelfLabels>(
  $nsid,
  'selfLabels',
  /*#__PURE__*/ l.object({
    values: /*#__PURE__*/ l.array(
      /*#__PURE__*/ l.ref<SelfLabel>((() => selfLabel) as any),
      { maxLength: 10 },
    ),
  }),
)

export { selfLabels }

/** Declares a label value and its expected interpretations and behaviors. */
type LabelValueDefinition = {
  $type?: 'com.atproto.label.defs#labelValueDefinition'

  /**
   * What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.
   */
  blurs: 'content' | 'media' | 'none' | l.UnknownString
  locales: LabelValueDefinitionStrings[]

  /**
   * How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.
   */
  severity: 'inform' | 'alert' | 'none' | l.UnknownString

  /**
   * Does the user need to have adult content enabled in order to configure this label?
   */
  adultOnly?: boolean

  /**
   * The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).
   */
  identifier: string

  /**
   * The default setting for this label.
   */
  defaultSetting?: 'ignore' | 'warn' | 'hide' | l.UnknownString
}

export type { LabelValueDefinition }

/** Declares a label value and its expected interpretations and behaviors. */
const labelValueDefinition = /*#__PURE__*/ l.typedObject<LabelValueDefinition>(
  $nsid,
  'labelValueDefinition',
  /*#__PURE__*/ l.object({
    blurs: /*#__PURE__*/ l.string<{
      knownValues: ['content', 'media', 'none']
    }>(),
    locales: /*#__PURE__*/ l.array(
      /*#__PURE__*/ l.ref<LabelValueDefinitionStrings>(
        (() => labelValueDefinitionStrings) as any,
      ),
    ),
    severity: /*#__PURE__*/ l.string<{
      knownValues: ['inform', 'alert', 'none']
    }>(),
    adultOnly: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.boolean()),
    identifier: /*#__PURE__*/ l.string({ maxLength: 100, maxGraphemes: 100 }),
    defaultSetting: /*#__PURE__*/ l.optional(
      /*#__PURE__*/ l.withDefault(
        /*#__PURE__*/ l.string<{ knownValues: ['ignore', 'warn', 'hide'] }>(),
        'warn',
      ),
    ),
  }),
)

export { labelValueDefinition }

/** Strings which describe the label in the UI, localized into a specific language. */
type LabelValueDefinitionStrings = {
  $type?: 'com.atproto.label.defs#labelValueDefinitionStrings'

  /**
   * The code of the language these strings are written in.
   */
  lang: l.LanguageString

  /**
   * A short human-readable name for the label.
   */
  name: string

  /**
   * A longer description of what the label means and why it might be applied.
   */
  description: string
}

export type { LabelValueDefinitionStrings }

/** Strings which describe the label in the UI, localized into a specific language. */
const labelValueDefinitionStrings =
  /*#__PURE__*/ l.typedObject<LabelValueDefinitionStrings>(
    $nsid,
    'labelValueDefinitionStrings',
    /*#__PURE__*/ l.object({
      lang: /*#__PURE__*/ l.string({ format: 'language' }),
      name: /*#__PURE__*/ l.string({ maxLength: 640, maxGraphemes: 64 }),
      description: /*#__PURE__*/ l.string({
        maxLength: 100000,
        maxGraphemes: 10000,
      }),
    }),
  )

export { labelValueDefinitionStrings }
