import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraAnchorTargetEventMap}from'../../../internal/anchor-target.js';import type{LyraAnchor}from'../document-viewer/anchors.js';import type{LyraPageViewerSnapshot,LyraPageViewerStateChangeDetail}from'../page-rail/page-rail.class.js';import type{LyraSearchChangeDetail}from'../../../internal/text-viewer-target.js'; /** One entry of a PDF's table of contents, as returned by `getOutline()`. `page` is a 1-based page * number; it's omitted when the entry's destination couldn't be resolved to a page. */ export interface PdfOutlineItem{title:string;page?:number;children?:PdfOutlineItem[];}export interface LyraPdfViewerEventMap extends LyraAnchorTargetEventMap{'lr-render-error':CustomEvent<{error:unknown;}>;'lr-page-change':CustomEvent<{page:number;pageCount:number;}>;'lr-zoom-change':CustomEvent<{zoom:number;}>;'lr-load':CustomEvent<{pageCount:number;}>;'lr-search-change':CustomEvent;'lr-page-viewer-state-change':CustomEvent;}declare class LyraPdfViewerBase extends LyraElement{}declare const LyraPdfViewer_base:Omit &(new(...args:ConstructorParameters)=>InstanceType &import("../../../lyra.js").LyraAnchorTarget&{renderAnchorLiveRegion():unknown;}); /** * Fetches PDF bytes and renders their pages with the optional `pdfjs-dist` peer. Pages are composed * through `lr-virtual-list`, while a PDF.js text layer keeps rendered text selectable and copyable. * Adopts `DocumentAnchorTarget`: `page`, `text-quote`, and `region` anchors resolve; highlights paint * via one `` per page, stacked beneath the text layer (canvas -> highlights -> * text layer) so starting a text selection over a cited passage keeps working. Pointer activation of * a highlight is hit-tested at the page-wrapper level (`onPageClick`) since the text layer sitting on * top intercepts most direct pointer events; keyboard activation reaches the highlight layer's own * roving-tabindex rects directly, since z-stacking doesn't affect tab order. Accepted residual: a * click that ends a text-selection drag over a highlighted passage never activates it (the * selection-in-progress check in `onPageClick` exists precisely to distinguish that case from a * genuine activation click). * The composed virtual-list lifecycle is an implementation detail: visible-range changes update * `page`, while raw `lr-visible-range-change` and `lr-virtual-scroll` events stay contained. * Known capability boundaries: `search()`/text-quote anchors match exact (whitespace- and * soft-hyphen-normalized) text only -- there is no fuzzy/approximate mode (see `internal/ * text-quote.ts`'s own doc comment for the exact normalization rules). Non-Latin cMap-encoded fonts * get no special handling beyond whatever `pdfjs-dist` resolves on its own. A scanned or * image-only PDF has no text layer at all, so it has nothing to select or search. * * @customElement lr-pdf-viewer * @event lr-render-error - Fired when fetching, parsing, or rendering fails, including synchronous * or rejected text-layer rendering. Text-layer failures are contained without an unhandled * promise rejection. * @event lr-page-change - Fired when the current page changes, but only once the document is * ready -- a page set while the document is still loading is reflected in the viewer snapshot * rather than announced, so a late subscriber reads it instead of missing it. This is a state * broadcast, not a user-intent signal: unlike `` (which never mutates its own * `page`, so its same-named event is a request the host applies) this viewer owns `page`, and * scroll-driven crossings change it with no consumer action at all. Every accepted transition is * therefore announced the same way -- scrolling, `nextPage()`/`previousPage()`/`goToPage()`, * anchor resolution, a load resetting to page 1, and a plain `viewer.page = n` assignment * included. A write that clamps or rounds back onto the page already showing changed nothing and * is silent. * @event lr-zoom-change - Fired when the zoom multiplier changes, on the same state-broadcast * contract as `lr-page-change`: a programmatic `zoom` write announces exactly like a toolbar * click. Not fired for the initial value, only for a transition away from it, and not for a * write that clamps back onto the zoom already applied. * @event lr-load - Fired once the document reaches `ready`. `detail: { pageCount }`. * @event lr-highlight-activate - A highlight was activated. `detail: { highlightId }`. * @event lr-text-select - A text selection ended inside a page's text layer. `detail: { text, * anchor, rects }`. * @event lr-anchor-result - Fired after an `anchor` (or `scrollToAnchor()` call) is applied. * `detail: { found }`. * @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 1,000 pages/1,000,000 corpus code units/4,000,000 search code units, and retains * at most 10,000 matches; a false `matchCountExact` makes `matchCount` a lower bound (including * when a page could not be read or any ceiling is reached). * @event lr-page-viewer-state-change - Correlated page lifecycle state. `detail.snapshot` is the * same readonly value exposed by `pageViewerSnapshot`; its `identity` changes for every load. * @csspart base - The named root viewer container with explicit `aria-busy`. * @csspart toolbar - Pagination and zoom controls. * @csspart previous-button - The previous-page button. * @csspart next-button - The next-page button. * @csspart zoom-out-button - The zoom-out button. * @csspart zoom-in-button - The zoom-in button. * @csspart page-indicator - The current page text. * @csspart zoom-indicator - The current zoom percentage. * @csspart pages - The virtualized page list. * @csspart page - One rendered page wrapper. * @csspart page-canvas - The canvas a page's content is painted onto. * @csspart page-error - A visible, page-local fallback when one page fails without invalidating * the rest of the document. * @csspart page-error-visible - A currently visible page-local fallback (also carries * `page-error`). * @csspart text-layer - Selectable text positioned over a page canvas. * @csspart text-span - One generated text run inside a page's text layer. * @csspart search-match - A painted in-document search match. * @csspart search-match-active - The currently active search match (also carries `search-match`). * @csspart error - Visible ordinary error text; transitions announce through the shared * document-level assertive region. * @csspart spinner - The decorative loading placeholder and its ordinary visually-hidden label; * transitions announce through the shared document-level polite region. * @cssprop [--lr-pdf-viewer-height=var(--lr-size-24rem)] - Block size of the virtualized page list. * @cssprop [--lr-pdf-viewer-toolbar-bg=var(--lr-color-brand-quiet)] - Background of the `toolbar` * part, independent of the shared `--lr-color-brand-quiet` token. * @cssprop [--lr-pdf-viewer-toolbar-button-hover-bg=var(--lr-color-surface)] - Hover fill of the * toolbar buttons. Defaults to the surface fill rather than the toolbar's own tint so the hover * state is actually visible against it. * Also settable via the `max-height` property. * @cssprop [--lr-pdf-viewer-text-selection-bg=var(--lr-color-brand-quiet)] - Background of a * native text selection over a `text-span`, independent of the shared `--lr-color-brand-quiet` * token. * @cssprop [--lr-pdf-viewer-search-match-bg=var(--lr-color-warning-quiet)] - Background of a * painted, non-active search match. * @cssprop [--lr-pdf-viewer-search-match-active-bg=var(--lr-color-warning)] - Background of the * currently active search match. * @status stable * @since 4.0.0 */ export declare class LyraPdfViewer extends LyraPdfViewer_base{static styles:import("lit").CSSResultGroup[]; /** URL to fetch and render as a PDF document. */ src:string; /** Display name used as the document's accessible label fallback. */ name:string; /** One-based current page, clamped to the loaded document's page count. */ page:number; /** Page zoom multiplier, clamped to the range 0.25–4. */ zoom:number; /** A CSS length (e.g. `"30rem"`); once set, overrides `--lr-pdf-viewer-height` -- the block size * of the virtualized page list -- declaratively, the same `max-height` attribute * ``/``/`` expose, rather than requiring a * consumer to set the differently-named CSS custom property inline. Invalid values are * ignored. */ maxHeight:string; /** URL of the `pdfjs-dist` web worker chunk (`pdfjs-dist/build/pdf.worker.min.mjs`) as emitted by * the consuming application's own bundler. PDF.js rejects every `getDocument()` call with * `No "GlobalWorkerOptions.workerSrc" specified.` until a worker is configured, and a bare package * specifier cannot be resolved from inside this library at runtime (there is no import map for it * in a bundled app, and joining it to Lyra's own module URL points into Lyra's dist tree, where no * worker exists), so a bundled application supplies the URL here. Document-relative values resolve * against the document base; only `http:`, `https:`, `blob:` and `file:` URLs are accepted and * anything else is ignored. * * `GlobalWorkerOptions` is PDF.js's process-wide singleton, so this is applied only while that * singleton is still unset: a worker the application configured itself is never overwritten, and * when two viewers carry different values only the first one to load PDF.js takes effect for the * whole page. Assigning it after PDF.js has already loaded is not silently dropped -- it is * re-applied on the next load -- but it still cannot displace a worker that is already configured. * The equivalent escape hatch, and the right choice for an application that wants one explicit * worker for every viewer, is to import `pdfjs-dist` and set `GlobalWorkerOptions.workerSrc` * directly during startup. */ workerSrc:string; /** Anchor kinds this viewer resolves. `page` and page-addressed `region` anchors require an * integer within the loaded document's range; unlike the public `page` property, anchors are * rejected rather than clamped. */ readonly anchorKinds:readonly['page','text-quote','region'];private loadState;private pageViewerIdentity;private pageViewerSnapshotValue; /** True while `page` was last set by the user scrolling the page list rather than by * `nextPage()`/`previousPage()`/an explicit `page` assignment. `renderBody()` withholds * `activeItemId` in that case so `` doesn't `scrollActiveIntoView()` back to a * page boundary on every scroll-driven page crossing, fighting the user's own scroll. */ private scrollDrivenPage;private loadLibrary;private generation;private readonly pageCanvases;private readonly pageRenderTasks;private readonly pageRenderVersions;private pageRenderGeneration;private readonly pageCanvasRefs;private readonly textLayerContainers;private readonly textLayerContainerRefs;private readonly textLayers;private readonly textLayerReadyPromises;private readonly pageTextCache;private readonly pageTextTruncated;private readonly pageSearchIndexes;private readonly mountedPageTextIndexes;private pdfTextScopeBuilds;private readonly thumbnailRenderTasks;private readonly thumbnailRenderVersions;private thumbnailRenderGeneration;private readonly pageHighlightItems;private readonly pageHighlightLayerElements;private readonly highlightLayerRefs;private textSelectionCleanup?;private readonly pendingPageMountWaitCancels;private pdfPageSourceCount;private pdfPageSource;private searchMatches;private searchMatchCountExact;private searchActiveIndex;private searchQuery;private searchGeneration;private textIndexLocale?;private pendingSearchResetEvent;private anchorOperationGeneration;private readonly announcements; /** * Atomic readonly state for page-rail and other page-addressed integrations. Unlike the legacy * `lr-load`/`lr-page-change` pair, a late subscriber can read this immediately, and `identity` * distinguishes same-count document replacements. */ get pageViewerSnapshot():LyraPageViewerSnapshot;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;firstUpdated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private cancelPendingPageMountWaits; /** Releases the current PDF.js document's worker and buffered pages before replacing or dropping * `loadState` -- `PDFDocumentProxy` is not garbage-collected on its own; every `src` change and * every disconnect must explicitly `destroy()` the previous document or it (and its worker) leaks. */ private destroyLoadedDoc; /** Clamps a candidate page number to `[1, pageCount]` (or `[1, 1]` before a document is loaded), * rounding a fractional page to the nearest whole page and defaulting a non-finite/`NaN` page * to `1` rather than letting it reach the virtualized page list unsanitized. */ private clampPage;private publishPageViewerSnapshot;private createPageSource;private indexedPages;private load;nextPage():void;previousPage():void;zoomIn():void;zoomOut():void; /** Sets `page` and resolves once the target page's canvas has actually mounted inside the * virtualized list (bounded by a timeout, so a page that somehow never mounts can't hang this * promise forever). Resolves `false` without changing `page` for an out-of-range value. */ goToPage(page:number):Promise;private waitForPageMount;private setPage;private setZoom;scrollToAnchor(target:LyraAnchor|string):Promise;protected applyAnchor(anchor:LyraAnchor):Promise;private isCurrentAnchorOperation;private pageSearchOrder;private applyTextQuoteAnchor;private resolveQuoteRangeOnPage;private applyRegionAnchor;private virtualListScrollContainer;private scrollRangeIntoView;private scrollPercentRectIntoView;protected computeSelectionAnchor(range:Range):LyraAnchor|null;private pageForNode; /** Overrides `DocumentAnchorTarget`'s default selection binding. Page content renders inside * ``'s own nested shadow root (virtualization adds a second shadow boundary * below this viewer's own render root), one level deeper than the mixin's default composed-range * lookup resolves. Left unresolved, a selection ending inside a page's text layer retargets to the * boundary of `` itself, which has no light-DOM text of its own -- the resulting * range stringifies to nothing and the selection is silently dropped. This override adds the * virtual list's own shadow root to the lookup so the resolved range still reaches the actual * selected text, then follows the same selection-end/rAF-debounced-`selectionchange` shape the * default binding uses -- with one more adjustment: the default binding's own containment check * (`contentRoot.contains(range.commonAncestorContainer)`) can't see past a shadow boundary either * (`Node.contains()` only walks light-DOM `parentNode` links), so it's replaced here with * `containsAcrossShadowBoundaries()`, which also follows a `ShadowRoot`'s `.host` link. */ protected bindTextSelection(contentRoot:Element):void; /** Raw reading-order text of one page, independent of DOM materialization. Rejects on no loaded * document or an out-of-range page. Per-page LRU cache (64 pages) with shared in-flight promises. * Deliberately no `getDocumentText()` -- callers loop pages. */ getPageText(page:number):Promise;private evictPageTextCacheEntry;private clearPageTextCache;private loadPageText; /** Renders `page` into `canvas` at `width` CSS px (default 96), devicePixelRatio-aware. Cancels a * prior in-flight render for the same canvas. Resolves `false` when not ready or out of range. * Caller owns the canvas -- no bitmap transfer, no hidden cache. */ renderPageThumbnail(page:number,canvas:HTMLCanvasElement,options?:{width?:number;}):Promise; /** Maps pdf.js's own `getOutline()` tree to `PdfOutlineItem[]`, resolving each entry's * destination to a 1-based page number best-effort -- an unresolvable destination keeps its * `title`/`children` with `page` omitted rather than dropping the entry. Peer output is capped at * 10,000 unique entries and 100 levels; cycles are ignored. `[]` for a document with no outline * or before one is loaded. */ getOutline():Promise;private mapOutlineItems;private resolveOutlineDestPage;private createRawPageTextIndex;private rawPageTextIndex;private buildMountedPageScope;private mountedPageTextIndex; /** Case-insensitive substring search over every page's text (via `getPageText()`). Matches use * the shared bounded text-quote index's normalized coordinate space, never touching * `highlights` -- painting is a self-contained overlay * scoped to search only (see `paintSearchMatches()`). An empty/whitespace-only query behaves like * `clearSearch()` and resolves `0`. Queries are capped at 4,096 code units, a pass at 1,000 * pages/1,000,000 corpus code units/4,000,000 search code units, and retained matches at 10,000; * `lr-search-change.detail.matchCountExact=false` identifies that return as a lower bound. */ search(query:string):Promise; /** Advances to the next match, wrapping to the first after the last. Resolves `false` (no-op) * when there are no matches. */ searchNext():Promise; /** Moves to the previous match, wrapping to the last before the first. Resolves `false` (no-op) * when there are no matches. */ searchPrevious():Promise; /** Clears the query, matches, and any painted marks, and resets `lr-search-change` to a * 0-match/no-active-index state. */ clearSearch():void;private hasSearchState;private resetSearchState;private emitSearchChange;private focusSearchMatch; /** Unwraps every painted `` back into plain text, across every mounted * page's text-layer container (or just `container` when given, for a single-page repaint). */ private clearSearchPaint; /** Resolves a bounded active-centred window against the mounted page's shared text scope and * wraps each search match's normalized-offset range in a * `` (`search-match-active` added for the current match). A page whose * text layer hasn't mounted yet (out of the virtualized render window) is silently skipped -- * painting resumes the next time that page's text layer finishes rendering, via the hook in * `renderTextLayer()`. */ private paintSearchMatches;private remainingSearchMarkBudget;private resolveMountedPageHighlights;private mountedPagesForHighlight;private resolveHighlightRectsForPage;private highlightLayerRef; /** Pointer-activation hit-test for a page's painted highlights -- see the class doc for why this * exists instead of relying on the highlight layer's own click handling. */ private onPageClick; /** ``'s own `lr-highlight-activate` (bubbles + composed by default -- see * `LyraElement.emit()`) fires directly on it for a click that lands squarely on its own * rect-target (rare -- the text layer sitting on top normally intercepts a direct pointer click * first, see `onPageClick`'s class-doc rationale) and for Enter/Space keyboard activation, which * reaches the layer's own roving-tabindex rects directly since z-stacking doesn't affect tab * order. Left unstopped, that raw event keeps bubbling right past this viewer under the very same * public event name `onPageClick` above also emits -- reaching any consumer listening on * `` as an undocumented duplicate. Stop it here and re-emit the viewer's own single * copy instead, so exactly one `lr-highlight-activate` -- always originating from the viewer * itself -- reaches consumers regardless of activation path. */ private onHighlightLayerActivate;private renderToolbar;private renderPage;private setPageError;private renderTextLayer; /** Names every text run PDF.js just generated as a `text-span` part. The runs are created * imperatively by `TextLayer.render()`, and they land inside ``'s shadow root * along with the rest of the page item -- so the stylesheet reaches them through * `lr-virtual-list::part(text-span)`, which cannot be written as a descendant of the * `text-layer` part. Naming them also makes each run reachable from a consumer's own * `lr-pdf-viewer::part(text-span)` rule. */ private markTextRunParts;private pageCanvasRef;private textLayerContainerRef;private renderPageItem;private onVisibleRangeChanged;private stopInternalEvent;private renderBody;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-pdf-viewer':LyraPdfViewer;}}export{};