import type { Component } from 'vue'; import type { CitationRef } from './citation-links.js'; export type { CitationLocator, CitationRef } from './citation-links.js'; export type CitationMeta = { /** Human-readable document title. Hosts must never surface internal ids here. */ title: string; /** Display name of the base/source the document belongs to. */ sourceLabel?: string; /** Identifier of the document at its origin (case number, súmula number, ...). */ identifier?: string; /** Link to the document at its original source, when one exists. */ url?: string; /** ISO date associated with the document. */ date?: string; /** What `date` refers to (julgamento, aprovação, publicação, ...). */ dateLabel?: string; /** Short excerpt shown in the citation popover. */ snippet?: string; /** Status badge, e.g. a súmula that is no longer in force. */ badge?: { label: string; tone?: 'neutral' | 'warning' | 'danger'; }; /** * Whether the built-in document panel applies to THIS citation. Absent means yes whenever * the host configured `getDocument` (or `onOpen`); `false` hides "Ver documento" for one * citation while keeping the panel for the rest — a document whose official page is the * better destination, or whose body the host does not hold in a presentable form. */ documentAvailable?: boolean; }; export type CitationDocument = { /** Plain-text document content as stored by the host. */ content: string; /** True when the host cut `content` short; the panel discloses it. */ truncated?: boolean; }; export type CitationOccurrence = { /** Inclusive char offset of the occurrence in the document content. */ offset: number; /** Exclusive end offset of the occurrence. */ end: number; }; /** * Host-provided citation behavior. The lib owns detection, rendering and interaction * states; the host owns data access (and with it, authorization: every callback runs * against the host's own backend with the viewing user's identity). * * A `resolve` that returns `null` renders the citation as unverified — deliberately * indistinguishable between "does not exist" and "not visible to this viewer". */ export type ChatCitationsConfig = { /** Resolve a citation to display metadata; `null` marks it unverified. */ resolve: (ref: CitationRef) => Promise; /** Fetch the document body; providing this enables the built-in document panel. */ getDocument?: (ref: CitationRef) => Promise; /** Locate a term's occurrences for highlighting; absent = client-side best effort. */ locate?: (ref: CitationRef, term: string) => Promise; /** Replaces the built-in citation chip. */ component?: Component; /** Takes over the click entirely; the built-in panel is not opened. */ onOpen?: (ref: CitationRef, meta: CitationMeta | null) => void; }; export type CitationStatus = 'loading' | 'resolved' | 'unresolved';