MAJOR=21
MINOR=2
DEVNAME=sg2
  J   ˆl–Ãa¾”ªi?u8 ¸Û71hß�þ_qÅœp,Æ2‘àÿ?Ïƒ@sÎ_“I|¥ŽõHºl=$¤�zTÖ™	ÆÍ 	f    // Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

import { computedWithControl } from '@vueuse/shared'

import type { TicketArticle } from '#shared/entities/ticket/types.ts'
import { isUnprocessableEmailArticle } from '#shared/entities/ticket-article/composables/useTicketArticleUnprocessableEmail.ts'

import type { Ref } from 'vue'

interface ArticleRow {
  type: 'article-bubble'
  article: TicketArticle
}

interface UnprocessableEmailRow {
  type: 'unprocessable-email'
  article: TicketArticle
}

interface ArticleDeliveryRow {
  type: 'delivery'
  content: string
}

interface MoreRow {
  type: 'more'
  count: number
}

interface SystemRaw {
  type: 'system'
  subject?: Maybe<string>
  to?: Maybe<string>
  reaction?: Maybe<string>
}

export type TicketArticleRow = (
  | ArticleRow
  | UnprocessableEmailRow
  | SystemRaw
  | MoreRow
  | ArticleDeliveryRow
) & {
  key: string
}

export const useTicketArticleRows = (
  articles: Ref<TicketArticle[]>,
  leadingNodesCount: Ref<number>,
  totalCount: Ref<number>,
) => {
  const rows = computedWithControl(articles, () => {
    const needMoreButton = articles.value.length < totalCount.value

    return articles.value.reduce((memo, article, index) => {
      if (isUnprocessableEmailArticle(article)) {
        memo.push({
          type: 'unprocessable-email',
          article,
          key: article.internalId.toString(),
        })
      } else if (article.preferences?.delivery_message) {
        memo.push({
          type: 'delivery',
          content: article.bodyWithUrls,
          key: article.internalId.toString(),
        })
      } else if (article.sender?.name === 'System' && article.type?.name !== 'note') {
        memo.push({
          type: 'system',
          subject: article.subject,
          to: article.to?.raw || '',
          reaction: article.preferences?.whatsapp?.reaction?.emoji,
          key: article.internalId.toString(),
        })
      } else {
        memo.push({
          type: 'article-bubble',
          article,
          key: article.internalId.toString(),
        })
      }

      if (index === leadingNodesCount.value - 1 && needMoreButton) {
        memo.push({
          type: 'more',
          key: 'more',

          count: totalCount.value - articles.value.length,
        })
      }
      return memo
    }, [] as TicketArticleRow[])
  })
  return { rows }
}
  D   ˆl–Ým_JJeJe@µq±\ ”Å£�þDÈE›”RFá
<ð?ŸÑ…"m·?Ð_ŠI|¥�+Wé3ž¯ÈÏ ?÷     # $Id: states.py 9037 2022-03-05 23:31:10Z milde $
# Author: David Goodger <goodger@python.org>
# Copyright: This module has been placed in the public domain.

"""
This is the ``docutils.parsers.rst.states`` module, the core of
the reStructuredText parser.  It defines the following:

:Classes:
    - `RSTStateMachine`: reStructuredText parser's entry point.
    - `NestedStateMachine`: recursive StateMachine.
    - `RSTState`: reStructuredText State superclass.
    - `Inliner`: For parsing inline markup.
    - `Body`: Generic classifier of the first line of a block.
    - `SpecializedBody`: Superclass for compound element members.
    - `BulletList`: Second and subsequent bullet_list list_items
    - `DefinitionList`: Second+ definition_list_items.
    - `EnumeratedList`: Second+ enumerated_list list_items.
    - `FieldList`: Second+ fields.
    - `OptionList`: Second+ option_list_items.
    - `RFC2822List`: Second+ RFC2822-style fields.
    - `ExtensionOptions`: Parses directive option fields.
    - `Explicit`: Second+ explicit markup constructs.
    - `SubstitutionDef`: For embedded directives in substitution definitions.
    - `Text`: Classifier of second line of a text block.
    - `SpecializedText`: Superclass for continuation lines of Text-variants.
    - `Definition`: Second line of potential definition_list_item.
    - `Line`: Second line of overlined section title or transition marker.
    - `Struct`: An auxiliary collection class.

:Exception classes: