import{type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js'; /** Sync lifecycle state of one knowledge source, as last reported by the host. */ export type KnowledgeSourceSyncStatus='idle'|'syncing'|'paused'|'synced'|'error'; /** Health of the most recent indexing pass over a source's content, as last reported by the host. */ export type KnowledgeSourceIndexingHealth='healthy'|'degraded'|'failed'|'unknown'; /** The current viewer's access level on a source -- informational only (see the class doc's * authorization note). */ export type KnowledgeSourcePermission='owner'|'editor'|'viewer'|'restricted'; /** * One connected knowledge-base source (e.g. a Drive/Notion connector, an uploaded document set, a * crawled URL). `id`/`name` follow the same spirit as `DocumentRef` (`src/ai/types.ts`) -- a stable * identity plus a display name -- but a source is a *connector feeding* documents into the * knowledge base, not a document itself, so the remaining fields are its own. */ export interface KnowledgeSource{id:string;name:string; /** Free-form connector/source kind (e.g. `'drive'`, `'notion'`, `'upload'`, `'url'`) -- * consumer-defined and rendered as-is (not routed through `localize()` -- caller-supplied data, * not library copy). Omit when there's nothing meaningful to show. */ type?:string;syncStatus:KnowledgeSourceSyncStatus; /** Omitted/absent is treated the same as `'unknown'`. */ indexingHealth?:KnowledgeSourceIndexingHealth;permission?:KnowledgeSourcePermission;documentCount?:number; /** Epoch milliseconds or an ISO-8601 string, matching `LyraChatThread`/`ChatMessage`'s own * `Date | string` timestamp convention elsewhere in this library. Omitted/unparseable renders as * "never synced". */ lastSyncedAt?:Date|string; /** Shown only while `syncStatus` is `'error'`. Caller-supplied data, not routed through * `localize()`. */ errorMessage?:string;}export interface LyraKnowledgeBaseEventMap{ /** The toolbar's "Add source" affordance was activated. No `sourceId` -- there is nothing yet to * reference; the host owns the actual creation flow (naming, connector picking, ...). */ 'lr-source-create':CustomEvent; /** A row's "Sync now" action was activated. */ 'lr-source-sync':CustomEvent<{sourceId:string;}>; /** A row's "Pause sync" action was activated. */ 'lr-source-pause':CustomEvent<{sourceId:string;}>; /** A row's "Delete source" action was activated. No built-in confirmation, matching * `lr-thread-list`'s identical `lr-thread-delete` contract. */ 'lr-source-delete':CustomEvent<{sourceId:string;}>; /** 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 source list for a retrieval knowledge base: sync status, indexing * health, permissions, and per-row create/sync/pause/delete affordances. A controlled data view, * like every other Lyra data component: it never syncs or indexes anything itself, only presents * `sources` and emits request-only events (`lr-source-create`/`-sync`/`-pause`/`-delete`) for the * host to act on and reflect back into a new `sources` value -- mirrors `lr-thread-list`'s * `lr-thread-pin`/`-archive`/`-delete` convention exactly. * * `permission` is rendered informationally only (a badge in the permission column); this component * does not gate the per-row action menu by it -- authorization enforcement is the host's own * concern, consistent with the controlled/presentational-only contract above. A `'syncing'` row's * "Sync now" action is disabled (a sync is already running); every other row's is enabled, * including `'error'`, so re-running a failed sync is one click. "Pause sync" is enabled only while * `'syncing'`. * * Composes `` for the source list (its own click/keydown delegation already treats any * custom-element or `role="menuitem"` cell content as interactive, so the per-row `` never * misfires the table's row-click handling), `` for the sync-status/indexing-health/ * permission indicators, `` for the aggregate summary row above the table, and * `` + `` for the per-row action affordances. The table's own * `lr-row-click` is intentionally stopped from * propagating further (this component doesn't expose row-click/selection semantics -- only the * per-row action menu is interactive). * * Public collection properties take bounded, clone-owned readonly snapshots. Create a new * collection and reassign it after changes; mutating the assigned array does not update the view. * Blank source ids and later duplicates are ignored before summary counts, rendering, or actions. * The first source for an id wins. * * A separate `error` state reports a failed source-list load without discarding the toolbar and * summary 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 source rows, behind this component's own `error` slot. * Precedence matches ``'s: `error` beats the empty state, so a failed load never falls * through to "no sources" copy that would hide the retry affordance. This component forwards * `error`/`errorHeading`/`errorDescription` to the nested table but owns the retry commit itself * (it intercepts the table's own `lr-retry`, re-proposes its own cancelable one, and only then * clears `error`) so the outer property never drifts out of sync with the table's internal state. * * @customElement lr-knowledge-base * @event lr-source-create - The toolbar "Add source" affordance was activated. No detail. * @event lr-source-sync - A row's "Sync now" action was activated. `detail: { sourceId }`. * @event lr-source-pause - A row's "Pause sync" action was activated. `detail: { sourceId }`. * @event lr-source-delete - A row's "Delete source" action was activated. `detail: { sourceId }`. * @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. * @csspart toolbar - The heading + "Add source" row. * @csspart heading - The heading text. * @csspart create-button - The "Add source" ``, omitted while `hideCreate` is set. * @csspart summary - The aggregate-stats row, omitted while `hideSummary` is set or `sources` is empty. * @csspart summary-stat - One `` inside `summary`. * @csspart table - The `` listing every source. * @csspart name-cell - A row's source-name cell wrapper. * @csspart source-name - The source's name text. * @csspart source-type - The source's `type` text, omitted when unset. * @csspart sync-cell - A row's sync-status cell wrapper. * @csspart sync-badge - The sync-status ``. * @csspart sync-timestamp - The formatted `lastSyncedAt` text (or a "never synced" fallback). * @csspart sync-error - The `errorMessage` text, shown only while `syncStatus` is `'error'` and it's set. * @csspart health-cell - A row's indexing-health cell wrapper. * @csspart health-badge - The indexing-health ``. * @csspart document-count - The formatted `documentCount` text, omitted when unset. * @csspart permission-badge - The permission ``, omitted when `permission` is unset. * @csspart actions-menu - A row's `` shell. * @csspart actions-trigger - The kebab `