import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{AnchorResultDetail,HighlightActivateDetail,LyraAnchor,LyraAnchorKind}from'../document-viewer/anchors.js';import{type LyraViewerSource}from'../viewer-source.js';import{type LyraClipboardWriteFailure,type LyraClipboardWriteSuccess}from'../../../internal/clipboard.js';import type{LyraSearchChangeDetail}from'../../../internal/text-viewer-target.js';export interface LyraXmlViewerEventMap{'lr-copy':CustomEvent;'lr-error':CustomEvent;'lr-copy-error':CustomEvent;'lr-search-change':CustomEvent;'lr-render-error':CustomEvent<{error:unknown;}>;'lr-anchor-result':CustomEvent;'lr-highlight-activate':CustomEvent;} /** Effective XML source authority. Inline presence wins, including an empty string. */ export type LyraXmlViewerSource=LyraViewerSource;declare class LyraXmlViewerBase extends LyraElement{}declare const LyraXmlViewer_base:Omit &(new(...args:ConstructorParameters)=>InstanceType &import("../../../lyra.js").LyraAnchorTarget&{renderAnchorLiveRegion():unknown;}); /** * `` — collapsible, copyable, `DOMParser`-based tree view for XML documents, * mirroring `lr-json-viewer`'s UX (`collapsed-depth`, `copyable`, structural-path-keyed expand * state that survives a same-shape `xml` reassignment -- e.g. a streaming document being patched * in place) adapted for XML's own node kinds: elements with attributes, text, comments, CDATA * sections, and processing instructions, rendered in their original mixed-child source order. * * Search is a purely imperative surface (`search()`/`searchNext()`/`searchPrevious()`/ * `clearSearch()`), the same uniform contract every anchor-target, search-capable viewer in this * library implements (`lr-pdf-viewer`, `lr-ebook-viewer`, `lr-notebook-viewer`) rather than * a settable property. Each of the three navigating methods resolves only once the newly active * match's row has been scrolled into view, the same way `lr-docx-viewer` follows its own active * match: marking `data-active-match` without scrolling leaves a find-in-page host stepping through * matches the reader never sees. `node-path` anchors address an element by child-index chain from * the document root, with an optional trailing `'@attrName'` segment addressing one of that * element's attributes. Resolving one paints `data-active` on the addressed `[part="node"]` row and, * for an attribute-addressing path, on that one `[part="attribute"]` pair -- so a citation pointing * at a single attribute value of a multi-attribute element stays distinguishable in the rendered * DOM. * * Host-supplied `highlights` are resolved the same way: every entry whose anchor is a `node-path` * this document can resolve tints its element row (`data-highlight`, carrying the entry's tone) and * gains a focusable `[part="highlight-action"]` button that emits `lr-highlight-activate`. Entries * whose anchor kind or path this viewer cannot resolve -- including a missing or non-array path -- * are ignored rather than partially painted, and a highlight inside a collapsed subtree paints * once that subtree is expanded. * * Namespace-literal: qualified names render exactly as authored, with no namespace-URI-aware * matching. Every document type declaration is rejected before `DOMParser`, preventing both * external-entity access and browser-specific internal-entity expansion. * * @customElement lr-xml-viewer * @event lr-copy - The clipboard write fulfilled. `detail: { ok: true, text }`. * @event lr-error - A clipboard write failed; generic no-detail notification. * @event lr-copy-error - A clipboard write failed. `detail: { ok: false, text, reason, error }`. * @event lr-search-change - Fired whenever the search query, match count, or active match * index changes, including source-reset and effective-locale re-evaluation. `detail: { * query, matchCount, matchCountExact, activeIndex }`. Search accepts at most 4,096 query code * units, scans at most 4,000,000 tag/attribute/text code units, and retains at most 10,000 * matches; a false `matchCountExact` makes `matchCount` a lower bound after any ceiling. * @event lr-render-error - Fired when fetching or parsing the document fails, including a * parse error or exceeding the node cap. `detail: { error }`. * @event lr-anchor-result - Fired after an `anchor` property assignment or a `scrollToAnchor()` * call is applied. Non-cancelable. `detail: { found }`. * @event lr-highlight-activate - A `highlights` entry's `[part="highlight-action"]` button was * activated by click or Enter/Space. Non-cancelable. `detail: { highlightId }`. * @csspart base - The root scroll container. * @csspart toolbar - The whole-document copy button row (only when `copyable`). * @csspart copy-button - A copy-to-clipboard button -- the whole-document one (in `toolbar`) or a * per-node one (only when `copyable`). * @csspart tree - The rendered node tree. * @csspart node - One element row (`data-active` while it's the resolved anchor target, * `data-match` while any part of it matches the current search, `data-active-match` while it's * the currently active search match, `data-highlight` carrying the tone of a `highlights` entry * resolved to it, and `data-active-highlight` while that entry is `activeHighlightId`). * @csspart tag - An element's tag name (`data-match`). * @csspart attribute - One attribute's name/value pair wrapper (`data-active` while a `node-path` * anchor's trailing `'@attrName'` segment addresses this specific attribute). * @csspart attribute-name - An attribute's name. * @csspart attribute-value - An attribute's value (`data-match`). * @csspart text - A text leaf (`data-match`). * @csspart comment - A comment leaf. * @csspart cdata - A CDATA section leaf. * @csspart pi - A processing-instruction leaf. * @csspart toggle - An element's expand/collapse button (only on elements with renderable * children). Its collapsed chevron mirrors with effective RTL direction; the expanded chevron * points down in either direction. * @csspart toggle-placeholder - A non-interactive alignment spacer in place of `toggle` on an * empty element. It is accessibility-hidden and cannot be revealed into a phantom control by * consumer CSS. * @csspart highlight-action - The focusable button a resolved `highlights` entry adds to its * element row; emits `lr-highlight-activate`. * @csspart error - The error region. * @csspart spinner - Visible ordinary loading content with a motion-safe progress indicator. * @cssprop [--lr-xml-viewer-active-attribute-color=var(--lr-color-brand)] - Outline color of the * `[part="attribute"]` an attribute-addressing `node-path` anchor resolved to. * @cssprop [--lr-xml-viewer-tag-color=var(--lr-color-brand)] - Text color of `[part="tag"]`, an * element's rendered tag name, independent of the active-attribute outline above. * @cssprop [--lr-xml-viewer-highlight-accent-background=var(--lr-color-brand-quiet)] - Row * background of an accent-tone (the default tone) `highlights` entry. * @cssprop [--lr-xml-viewer-highlight-success-background=var(--lr-color-success-quiet)] - Row * background of a success-tone `highlights` entry. * @cssprop [--lr-xml-viewer-highlight-warning-background=var(--lr-color-warning-quiet)] - Row * background of a warning-tone `highlights` entry. * @cssprop [--lr-xml-viewer-highlight-danger-background=var(--lr-color-danger-quiet)] - Row * background of a danger-tone `highlights` entry. * @cssprop [--lr-xml-viewer-highlight-neutral-background=var(--lr-color-surface-raised)] - Row * background of a neutral-tone `highlights` entry. Deliberately not `--lr-color-surface`: the * viewer's own ambient background would render a neutral highlight as unhighlighted. * @cssprop [--lr-xml-viewer-highlight-active-outline=var(--lr-color-brand)] - Outline color of the * `highlights` entry currently named by `activeHighlightId`. * @cssprop [--lr-xml-viewer-max-height=none] - Maximum block size of the scrollable body before * it scrolls internally. Also settable via the `max-height` property. * @cssprop [--lr-xml-viewer-active-match-color=var(--lr-color-warning)] - Outline color of the * `[part="node"]` holding the current search match. Scoped to the active match, so the dashed * outline on the other matches keeps the shared warning token. * @cssprop [--lr-xml-viewer-match-color=var(--lr-color-warning)] - Outline color of a * (non-active) `[part="node"]` search match, and the tint source for a matching * `[part="text"]`'s background. Distinct from `--lr-xml-viewer-active-match-color`, so the * non-active matches can be recolored without touching the active one. * @cssprop [--lr-xml-viewer-match-bg=var(--lr-color-warning-quiet)] - Background of a matching * `[part="tag"]`/`[part="attribute-value"]`. * @status stable * @since 4.0.0 */ export declare class LyraXmlViewer extends LyraXmlViewer_base{static styles:import("lit").CSSResultGroup[]; /** URL to fetch and parse as XML. Ignored once `xml` is set. */ src:string; /** Raw XML text to parse and render, wins over `src`. Setting this parses synchronously. */ get xml():string|undefined;set xml(value:string|undefined);private _xml?; /** Readonly discriminated snapshot of the effective source authority. */ get source():LyraXmlViewerSource; /** Display name used as the viewer's accessible label. */ name:string; /** Elements at or beyond this nesting depth (root = 0) start collapsed. Omit/undefined: * nothing auto-collapses. */ collapsedDepth?:number; /** Shows copy-to-clipboard affordances: one for the whole document, plus one per element. */ copyable:boolean; /** A CSS length (e.g. `"20rem"`); once set, the viewer scrolls internally past this height * instead of growing the page. */ /** A CSS `max-height`; invalid values are ignored. */ maxHeight:string; /** Anchor kinds this component resolves via `scrollToAnchor()`. */ readonly anchorKinds:readonly LyraAnchorKind[];private xmlState; /** Per-path (`JSON.stringify(path)`) explicit expand/collapse, overriding the * `collapsedDepth`/search defaults once an element's toggle has been used. Pruned whenever the * document reloads (see `setDoc()`), so a long-lived instance bound to reshaping/streaming XML * doesn't accumulate one entry per path ever toggled for the life of the instance. */ private expandedOverrides;private activePath; /** `attrKey(pathKey, attrName)` of the attribute a `node-path` anchor's trailing `'@attrName'` * segment addressed, or `null` when the current anchor stops at element granularity. */ private activeAttr;private activeSearchIndex;private searchQuery; /** Resolved once per `render()` and read by every recursive `renderNode()` call, so painting N * rows never re-resolves M highlights N times. */ private renderedHighlights;private searchState;private lastSearchLocale;private pendingSearchStateEvent;private generation;private readonly announcements;private copyFeedback;private copyGeneration;private copyTimer?; /** `collapsedDepth`, normalized to a finite non-negative integer when set -- `undefined` * (nothing auto-collapses) is left as-is, since it's a meaningful, intentional value, not an * invalid one. A raw `NaN` (e.g. an invalid `collapsed-depth` attribute) would otherwise make * every `depth >= collapsedDepth` comparison false, silently disabling auto-collapse instead of * falling back to a sane depth. Mirrors ``'s identical guard. */ private get safeCollapsedDepth();protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private parseInline;private loadFromSrc;private resetSearchForSourceReplacement;private setDoc;private computeSearch;protected applyAnchor(anchor:LyraAnchor):Promise; /** * Host-supplied `highlights` resolved against the loaded document, keyed by the rendered path key * of the element each one addresses. Entries are deduplicated by public `id` (a host re-sending * the same citation must not paint twice), then filtered down to `node-path` anchors this * document can actually resolve -- an unresolvable entry is dropped whole rather than painted at * some coarser granularity. `index`/`total` position each surviving entry for its localized * accessible name, exactly as `` numbers its own region highlights; two entries * resolving to the SAME element still both count toward `total`, while the first retained one * owns that row's paint. Painting retains at most 100 resolved entries from a 1,000-entry * candidate window; an active entry anywhere in the bounded host snapshot is placed first and * retained inside both ceilings. */ private resolveHighlights; /** The localized accessible name of one highlight's action button -- its own `label` when the * host supplied one, otherwise its position in the resolved set. Mirrors ``. */ private highlightActionLabel;private expandAncestors; /** Case-insensitive substring search over every element's tag name, attribute names/values, * and own text, layered over the already-parsed document -- accepts at most 4,096 query code * units, scans at most 4,000,000 code units, resolves at most 10,000 retained matches, and fires * `lr-search-change`; `detail.matchCountExact=false` identifies a ceiling-truncated lower * bound. Replacing the source invalidates document-relative matches and emits the canonical * empty `lr-search-change` reset. Imperative navigation reopens the active match and its * ancestors, including manually collapsed nodes; later manual collapse still takes precedence. */ search(query:string):Promise; /** Advances to the next match, wrapping to the first after the last. Resolves `true` once the * active match moved, `false` when there are no matches -- the shape the shared * `LyraTextViewerTarget` search contract declares, so a find-in-page host can drive every * searchable component through one typed surface. */ searchNext():Promise; /** Moves to the previous match, wrapping to the last before the first. Resolves `true` once the * active match moved, `false` when there are no matches. */ searchPrevious():Promise;clearSearch():void; /** Brings the row carrying `data-active-match` on screen once the state change that moved the * marker has actually rendered -- the tree is Lit-rendered, so unlike ``'s * synchronously-painted marks the row does not exist yet at call time. Marking the active match * without scrolling to it leaves a find-in-page host stepping through matches the reader never * sees, which is what every other search-capable viewer here avoids. Reduced motion drops the * smooth behavior, matching the sibling viewers. */ private scrollActiveMatchIntoView;private emitSearchChange;private toggleNode;private isExpanded;private cancelCopyTimer;private resetCopyFeedback;private showCopyFeedback;private copyText;private serializeXml;private copySerializedXml;private copyButtonLabel;private renderCopyButton;private renderNode;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-xml-viewer':LyraXmlViewer;}}export{};