import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{DocumentRef}from'../../../ai/types.js';import type{TableSortDirection}from'../table/table.class.js';import{type LyraSize}from'../../../internal/variants.js'; /** How recently a document's content was verified/updated, consumer-computed (this component * performs no staleness calculation of its own -- it only renders whichever bucket the host * already assigned). Ordered fresh -> aging -> stale for `freshness`-column sorting. */ export type LibraryDocumentFreshness='fresh'|'aging'|'stale'; /** * One inventory row. Extends the shared `DocumentRef` (`src/ai/types.ts`) -- `id`/`name`/ * `mimeType`/`uri`/`version` assign directly onto/from it with no adapter -- with the * tags/owner/freshness fields specific to an inventory view that the provider-neutral * `DocumentRef` deliberately doesn't carry. `updatedAt` reuses * `ChatMessage.timestamp`'s own `Date | string` shape from the same `src/ai/types.ts` module for * consistency across this component family. */ export interface LibraryDocument extends DocumentRef{ /** Optional tags. An own undefined value is treated like omission. */ tags?:readonly string[];owner?:string; /** Last-updated timestamp. `Date | string` (ISO-8601), matching `ChatMessage.timestamp`. */ updatedAt?:Date|string;freshness?:LibraryDocumentFreshness;} /** Column keys `sortKey` accepts. Not every column is sortable (`type`/`tags`/`select` are not). */ export type LibraryDocumentSortKey='name'|'version'|'owner'|'freshness'|'updatedAt';export interface DocumentLibraryFilterChangeDetail{readonly searchTerm:string;readonly tags:readonly string[];readonly matchCount:number;}export interface DocumentLibrarySortRequestDetail{readonly phase:'request';readonly sortKey:LibraryDocumentSortKey;readonly sortDir:TableSortDirection;}export interface DocumentLibrarySortCommitDetail{readonly phase:'commit';readonly sortKey:LibraryDocumentSortKey;readonly sortDir:TableSortDirection;} /** Canonical request/commit sort transaction detail. */ export type DocumentLibrarySortDetail=DocumentLibrarySortRequestDetail|DocumentLibrarySortCommitDetail;export interface DocumentLibrarySelectionChangeDetail{readonly documentIds:readonly string[];}export interface DocumentLibraryOpenDetail{readonly documentId:string;}export interface LyraDocumentLibraryEventMap{'lr-filter-change':CustomEvent>;'lr-sort-request':CustomEvent;'lr-sort':CustomEvent;'lr-selection-change':CustomEvent>;'lr-open':CustomEvent; /** The nested table's built-in `[part='retry-button']` was activated, only rendered while * `error` is set. Cancelable: the default action clears `error`; `preventDefault()` leaves it * set instead. Mirrors ``'s own `lr-retry` contract exactly (decision 40) -- this * component owns the property and re-proposes its own event rather than letting the nested * table's internal state drift out of sync with it. */ 'lr-retry':CustomEvent;} /** * `` — a searchable, filterable inventory of documents with versions, tags, * owners, freshness, and bulk selection. A controlled data view: it performs no upload, sync, or * mutation of its own, only presents `documents` and emits request/notification events, mirroring * this package's other orchestration-level list surfaces (``'s * `lr-thread-pin`/`-archive`/`-delete` convention). * * Composes `` for the inventory grid itself, since bulk selection, tags, and per-row * type icons all need arbitrary cell content rather than a stringified value. * `` supports arbitrary `cell()`/`headerCell()` content and `priority`-driven responsive * column hiding, which this component relies on for its 320px-allocation behavior. Search * (``) and the tag facet (``) are both self-managed * (client-side filtering against `documents`, like ``'s own `searchable` field) — * override matching entirely via `filter`. Row selection uses `` per cell. The * composed table stays in multiple-selection semantics so `selectedDocumentIds` reaches row * `aria-selected`, but its click-anywhere selection event is contained and rolled back because row * activation opens the document; checkbox controls remain the sole selection interaction. * `` is set to `sort-mode="server"` because this component owns ordering: * `visibleDocuments` already sorts against real values (timestamps for `updatedAt`, a rank for * `freshness`). Client mode would order the rows a second time from `String(cell(row))`, and these * `cell()`s render formatted dates and templates — which made the Updated column come out * alphabetical by month name rather than chronological. `sortKey`/`sortDir` are still passed * down: they drive the header's sort affordance, not the order. * Post-mount selection-count changes announce through the document's shared light-DOM polite * sink, including zero and repeated equal counts; initial declarative selection stays silent. The * visible selection bar remains ordinary, non-live content. * Document identity is a unique nonempty `id`: malformed records (including a missing/non-string * `name` or non-string `tags` entry), blank ids, and later duplicate records are omitted at * assignment, so the first valid occurrence owns filtering, counts, selection, rows, and events. * Internal search, tag-filter, and checkbox native/prefixed value-event aliases, the tag * combobox's show/hide lifecycle, plus table selection/pagination events, are consumed at their * translation boundary; hosts receive only the documented library-level events. * * A separate `error` state reports a failed load without discarding the toolbar/selection-bar * context around it: while `error` is set, the nested `` shows its own built-in * failed-load state (the same `error`-prefixed exported parts and `[part='retry-button']` as * `` itself) in place of the document rows, behind this component's own `error` slot. * `error` beats the empty state, matching ``'s own precedence. This component forwards * `error`/`errorHeading`/`errorDescription` to the nested table but owns the retry commit itself, * the same intercept-and-re-propose shape `onTableSortRequest` already uses for sort. * * @customElement lr-document-library * @event lr-filter-change - The search term or tag facet changed. Frozen readonly * `detail: { searchTerm, tags, matchCount }`. * The translated child `lr-input`/`change` event does not escape the library. * @event lr-sort-request - Cancelable sort proposal translated from the composed table. Frozen * readonly `detail: { phase: 'request', sortKey, sortDir }`. * @event lr-sort - Accepted sort transaction. Frozen readonly * `detail: { phase: 'commit', sortKey, sortDir }`. * @event lr-selection-change - The bulk selection changed (a row checkbox, the header * select-all checkbox, or "Clear selection"). Frozen readonly * `detail: { documentIds: readonly string[] }`. Translated checkbox * `lr-change` events do not escape the library. * @event lr-open - A document was activated (its name, or Enter/Space/click elsewhere on its * row). Frozen readonly `detail: { documentId }`. * @event lr-retry - The nested table's built-in `[part='retry-button']` was activated, only * rendered while `error` is set. Cancelable: the default action clears `error`; * `preventDefault()` leaves it set instead. * @slot error - Replaces the nested table's built-in failed-load state, including its retry * button, while `error` is set. * @csspart base - The root region. * @csspart toolbar - Wraps the search field and tag filter. * @csspart search - The `` search field. * @csspart tag-filter - The `` tag facet filter. Only rendered while at least one * document declares a `tags` entry. * @csspart selection-bar - The ordinary, non-live "N selected" / "Clear selection" bar. Only * rendered while `selectedDocumentIds` is non-empty; selection announcements use the shared light-DOM * polite sink. * @csspart selection-count - The selected-count text inside `selection-bar`. * @csspart clear-selection - The "Clear selection" button inside `selection-bar`. * @csspart table - The `` inventory grid. * @csspart document-name - Each row's clickable document-name button. * @csspart row - Exported from ``'s own `row` part. * @csspart cell - Exported from ``'s own `cell` part. * @csspart header-cell - Exported from ``'s own `header-cell` part. * @csspart error-row - The nested table's single full-width row that replaces the document rows * while `error` is set. * @csspart error-cell - The cell inside `error-row` that holds the failed-load content. * @csspart error - The nested table's built-in `` host rendered while `error` is set. * @csspart error-base - Exported from the built-in error ``'s own `base` part. * @csspart error-icon - Exported from the built-in error ``'s `icon` part. * @csspart error-heading - Exported from the built-in error ``'s `heading` part. * @csspart error-description - Exported from the built-in error ``'s `description` part. * @csspart error-actions - Exported from the built-in error ``'s `actions` part. * @csspart retry-button - The built-in retry control rendered into the error state's `actions`. * @status stable * @since 4.1.0 */ export declare class LyraDocumentLibrary extends LyraElement{static styles:import("lit").CSSResultGroup[];protected static readonly immutableEventDetails:readonly string[];private _documents; /** Clone-owned readonly inventory, bounded to the first 10,000 source documents and 10,000 tags * per document. Document records, nested tag arrays, and dates are snapshotted at assignment * time; records without a string name or with non-string tag entries, blank ids, and later * duplicate ids are omitted first-wins before filters, counts, selection, rows, and events. Reads * return detached snapshots so even `Date` mutators cannot reach retained state. Reassign the * collection to update. */ get documents():readonly LibraryDocument[];set documents(value:readonly LibraryDocument[]); /** Bulk-selected document ids. Settable up front (pre-selection) and mutated internally by the * row/select-all checkboxes and "Clear selection" — read it back, or listen for * `lr-selection-change`, to persist the current selection. Automatically pruned of any id no * longer present in `documents` (no event fires for that pruning -- only an actual selection * interaction does, mirroring ``'s identical silent-resync convention for its * own `expanded` state). Assignment snapshots at most 10,000 unique ids; reassign to update. */ private _selectedDocumentIds;get selectedDocumentIds():readonly string[];set selectedDocumentIds(value:readonly string[]); /** Currently-applied tag facet (`AND` semantics -- a document must carry every listed tag). * Settable up front and mutated internally by the tag filter combobox. Assignment snapshots at * most 10,000 unique tags; reassign to update. */ private _tagFilter;get tagFilter():readonly string[];set tagFilter(value:readonly string[]); /** Overrides the default case-insensitive name/owner/tag substring match. Receives the already * trimmed, lowercased search text, mirroring ``'s identical `filter` contract. */ filter?:(document:LibraryDocument,query:string)=>boolean; /** Controlled sortable column key. */ sortKey:LibraryDocumentSortKey; /** Controlled canonical sort direction shared with ``. */ sortDir:TableSortDirection; /** Controlled search query applied to document names, owners, and tags. Removing the * attribute clears filtering while retaining the native null property readback. */ searchTerm:string;loading:boolean; /** Reports a failed document-list load. Forwarded to the nested ``, whose own * built-in failed-load state renders in place of the document rows; ``'s own * precedence applies (`error` beats the empty state). Reflected so `[error]` is selectable * from outside. */ error:boolean; /** Failed-load heading override, forwarded to the nested table. Omitted localizes the table's * own `tableLoadFailed` default. */ errorHeading?:string; /** Failed-load supporting copy, forwarded to the nested table. */ errorDescription:string; /** True once a real light-DOM child assigned `slot="error"` is observed -- see * `errorSlotObserver` below. Gates whether the `error` slot passthrough is mounted on the * nested ``: an always-mounted passthrough would count as "assigned content" for the * table's own `error` slot regardless of whether anything real is inside it, permanently * hiding the table's built-in failed-load state even when the consumer never used the slot. */ private hasErrorSlot;private errorSlotObserver?;private computeHasErrorSlot; /** The nested table's `lr-retry` intercepted at the boundary: this component owns `error`, so * it stops the table's own event from leaking out unmediated, re-proposes its own cancelable * `lr-retry`, and only then decides whether to clear `error` -- and whether to also veto the * nested table's own default clear, so the two never drift out of sync. Mirrors * `onTableSortRequest`'s identical intercept-and-re-propose shape. */ private onTableRetry;private _size?; /** Density tier for the toolbar's own search field and tag filter, on the library's one size * ladder, in either spelling -- `2xs`/`xs`/`s`/`m`/`l`/`xl`, or Web Awesome's and Shoelace's * `small`/`medium`/`large`. Forwarded verbatim to the composed `` and ``, * which is the only way to reach them: each resolves its tier inside its own shadow root, so no * custom property this component could publish would get there. Opt-in: with no size both keep * their own `m` default, exactly what they rendered before, and the two stay on the same tier as * each other at every setting so the toolbar row never goes ragged. Forwarded as a property * rather than an attribute, because removing an already-written `size` attribute again would * leave each child's own `size` at `null` instead of back at its own default. Unsupported * values normalize to the omitted state and remove the attribute. */ get size():LyraSize|undefined;set size(next:LyraSize|undefined); /** Accessible name for the region and the inner grid. Defaults to the localized * `documentLibraryLabel` when unset. An explicitly empty string renders as an empty label * rather than falling back. */ label?:string;private announcementSink?;private isMounting;connectedCallback():void;disconnectedCallback():void;private releaseAnnouncementSink;private syncAnnouncementSink;private snapshotDocuments;private snapshotIds;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private selectionCountText;private normalizeDate;private defaultFilter;private matchesTagFilter;private compareDocuments; /** The current search+tag-facet-filtered, sorted view of `documents`. */ private get visibleDocuments(); /** Every distinct tag across `documents`, sorted for stable combobox ordering. Empty when no * document declares any tag -- the tag-filter combobox itself is only rendered while this is * non-empty. */ private get allTags();private emitFilterChange;private onSearchInput;private onTagFilterChange;private isSortKey;private onTableSortRequest;private onTableSortCommit;private stopOwnedEvent; /** Row activation opens a document; checkbox controls own selection. Keep the composed table in * multiple-selection semantics for truthful `aria-selected`, but contain and roll back its * click-anywhere selection behavior at this wrapper boundary. */ private onTableSelectionChange;private openDocument;private setSelected;private toggleSelection;private toggleSelectAll;private clearSelection;private freshnessLabel;private renderSelectAllCheckbox;private renderRowCheckbox;private renderNameCell;private renderTagsCell;private renderFreshnessCell;private renderUpdatedCell;private buildColumns;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-document-library':LyraDocumentLibrary;}}