import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{DocumentRef}from'../../../ai/types.js';import type{HighlightActivateDetail,LyraAnchor,LyraHighlight}from'../document-viewer/anchors.js';import type{ShikiLanguageInput}from'../../conversation/code-block/code-loader.js';import type{LyraDiffViewLayout}from'../../utility/diff-view/diff-view.class.js';import type{LyraClipboardWriteFailure,LyraClipboardWriteSuccess}from'../../../internal/clipboard.js'; /** Which pane a comparison side identifies -- `'old'` is the "before" version, `'new'` is the * "after" version. */ export type DocumentComparePaneSide='old'|'new'; /** `'diff'` (the default) renders one inline ``; `'side-by-side'` renders two * independently-scrollable `` panes. */ export type LyraDocumentCompareView='diff'|'side-by-side'; /** `true`-defaulting boolean attribute converter -- Lit's default presence-based `type: Boolean` * can never be set back to `false` from a plain-HTML attribute once the property's own default is * `true` (removing an attribute that was never present fires no `attributeChangedCallback`), so * `fromAttribute` checks the literal string instead (mirrors `lr-checkpoint`'s identical * converter). */ export interface LyraDocumentCompareEventMap{ /** Bubbles unchanged from the internal `` after the clipboard write fulfills. */ 'lr-copy':CustomEvent; /** Bubbles unchanged from the internal `` when clipboard writing fails. */ 'lr-error':CustomEvent; /** Detailed clipboard failure bubbled unchanged from the internal ``. */ 'lr-copy-error':CustomEvent; /** Bubbles unchanged from whichever pane's `` it originated in, while `view="side-by-side"`. `detail: { highlightId }`. Activating a highlight that shares its `id` with a highlight on the *other* version also scrolls that pane to the matching highlight -- see the class doc's "Synchronized anchors" section. */ 'lr-highlight-activate':CustomEvent; /** Bubbles unchanged from whichever pane's `` it originated in. `detail: { src, filename }`. */ 'lr-download':CustomEvent<{src:string;filename:string;}>; /** Bubbles unchanged from whichever pane's `` it originated in (a failed `text/*` fetch). `detail: { error }`. */ 'lr-render-error':CustomEvent<{error:unknown;}>;} /** * One document version to compare. Extends the shared `DocumentRef` (`id`/`name`/`mimeType`/ * `uri`/`version`) with the two fields a comparison needs that a bare document reference doesn't * carry: the literal `text` an `` diffs directly, and this version's own * `` region `highlights` (see "Synchronized anchors" below). `uri` (from * `DocumentRef`) maps onto ``'s own `src` property, and `mimeType` maps onto * its `mimeType` property field-for-field; `name` maps onto its differently-named `filename` * property (per `DocumentRef`'s own doc comment, `name` matches ``'s property * name, not ``'s). */ export interface DocumentCompareVersion extends DocumentRef{ /** Literal text content for this version -- diffed directly by `view="diff"` (no fetch involved), unlike ``'s own text-format dispatch which fetches `uri`. */ readonly text?:string; /** Region highlights rendered over this version's own `` pane (image format only -- see that component's own scope). An id shared between `oldVersion.highlights` and `newVersion.highlights` is what "synchronized anchors" resolves against. */ readonly highlights?:readonly LyraHighlight[];} /** * `` — side-by-side or inline comparison of two document versions, composed * entirely from two existing primitives rather than reimplementing either: `` is the * real two-string line diff (`view="diff"`, the default), and `` renders each * version's own actual content in `view="side-by-side"`. * * **Synchronized anchors.** ``'s own `layout="split"` needs no scroll-sync of its * own -- both columns already live inside one shared scrolling container, so they move together * for free. `view="side-by-side"` is different: it renders two *independent* * `` panes, each with its own scrollbar, so nothing keeps them aligned on its * own. This component adds exactly two minimal, purpose-built coordination mechanisms for that * case (mirroring ``'s own proven proportional-scroll algorithm rather than * inventing a new one): * - **Continuous scroll sync** (`syncScroll`, default `true`): scrolling either pane * proportionally scrolls the other to the same *fraction* of its own scrollable range, not the * same pixel offset -- the two versions can have very different lengths. A re-entrancy guard * stops the mirrored write from bouncing back. * - **Highlight-anchor sync**: activating a region highlight in one pane (`lr-highlight-activate`) * that shares its normalized `id` with a highlight in the *other* preview scrolls that pane to * its own matching highlight via ``'s own `scrollToAnchor()`. Both lookup * and activation use the preview's trimmed, nonempty, first-wins highlight projection. The * `lr-highlight-activate` event itself still bubbles through unchanged (`detail: { * highlightId }`, no * side discriminator) so an existing listener contract stays exactly what * `` already documents. * - A shared `anchor` property (same declarative shape as ``'s own `anchor`) * drives both panes to the same target at once via their own `scrollToAnchor()`. * - Replacing a pane with a different source identity resets that pane to the top (both panes while * `syncScroll` is true). Re-rendering the same identity preserves reading position, and an active * shared `anchor` always wins over the reset. * * A nonempty host `aria-label` makes the host the sole named semantic owner. An explicitly empty * host label remains on the shadow group, and absence restores its localized comparison label. * * @customElement lr-document-compare * @event lr-copy - See `LyraDocumentCompareEventMap`. * @event lr-error - See `LyraDocumentCompareEventMap`. * @event lr-copy-error - See `LyraDocumentCompareEventMap`. * @event lr-highlight-activate - See `LyraDocumentCompareEventMap`. * @event lr-download - See `LyraDocumentCompareEventMap`. * @event lr-render-error - See `LyraDocumentCompareEventMap`. * @csspart base - The root wrapper. * @csspart diff - The internal ``, rendered while `view="diff"`. * @csspart panes - The row (or, under 640px, column) wrapping both panes, rendered while `view="side-by-side"`. * @csspart pane-old - The first (old/before) version's labeled, independently-scrollable pane. * @csspart pane-new - The second (new/after) version's labeled, independently-scrollable pane. * @csspart pane-header - A pane's visible label. * @csspart pane-empty - The placeholder shown in a pane whose version is unset. * @cssprop [--lr-document-compare-pane-max-height=var(--lr-size-24rem)] - Maximum block size of a side-by-side pane before it scrolls internally. * @status stable * @since 4.1.0 */ export declare class LyraDocumentCompare extends LyraElement{static styles:import("lit").CSSResultGroup[]; /** `'diff'` (the default) renders one inline ``; `'side-by-side'` renders two * independently-scrollable `` panes -- see the class doc's "Synchronized * anchors" section for how the two panes are kept in sync. Unsupported values normalize to * reflected `diff`. */ private _view;get view():LyraDocumentCompareView;set view(next:LyraDocumentCompareView);private _oldVersion?; /** The "before" version. Display fields are copied through own data descriptors at assignment, * while invalid records render as an unset pane. */ get oldVersion():DocumentCompareVersion|undefined;set oldVersion(value:DocumentCompareVersion|undefined);private _newVersion?; /** The "after" version. Display fields are copied through own data descriptors at assignment, * while invalid records render as an unset pane. */ get newVersion():DocumentCompareVersion|undefined;set newVersion(value:DocumentCompareVersion|undefined); /** Forwarded to the internal ``'s own `layout` property while `view="diff"`; * unsupported values normalize to reflected `unified`. */ private _diffLayout;get diffLayout():LyraDiffViewLayout;set diffLayout(next:LyraDiffViewLayout); /** Forwarded to the internal ``'s own `copyable` property while `view="diff"`. */ copyable:boolean;private _language; /** Forwarded to the internal ``'s own `language` property while `view="diff"`. * Runtime values outside the documented string contract fall back to no highlighting. */ get language():string;set language(value:string); /** Forwarded to the internal ``'s own `languages` property while `view="diff"`. */ languages?:Readonly>; /** Whether scrolling one `view="side-by-side"` pane proportionally scrolls the other. See the * class doc's "Synchronized anchors" section. */ syncScroll:boolean; /** A CSS length (e.g. `"30rem"`); once set, overrides `--lr-document-compare-pane-max-height` -- * the max block size of each `view="side-by-side"` pane -- declaratively, the same `max-height` * attribute every other content-viewer sibling exposes, rather than requiring a consumer to set * the differently-named CSS custom property inline. Invalid values are ignored. */ maxHeight:string; /** A shared scroll-to-anchor target forwarded to both `view="side-by-side"` panes' * `scrollToAnchor()`. `hasChanged: () => true` so re-assigning the same value (e.g. re-clicking * the same source reference) still re-fires, mirroring ``'s identical * property. */ anchor:LyraAnchor|string|null;private paneOldEl?;private paneNewEl?;private previewOldEl?;private previewNewEl?;private suppressSync;private syncReleaseFrame?;private syncReleaseView?;disconnectedCallback():void;adoptedCallback():void;private cancelSyncRelease;private scheduleSyncRelease;protected updated(changed:PropertyValues):void;private onPaneScroll; /** Handles a pane's own `lr-highlight-activate` (not re-emitted -- the event bubbles through * unchanged, see the class doc). When the other version has a highlight sharing this ID, * scrolls that pane to it too. */ private onHighlightActivate;private versionLabel;private renderDiff;private renderVersionPane;private renderSideBySide;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-document-compare':LyraDocumentCompare;}}