import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import'../../forms/input/input.class.js';import'../../layout/segmented/segmented.class.js';import'../../overlays/chip/chip.class.js';import'../../overlays/chip/chip-group.class.js';import'../../overlays/spinner/spinner.class.js';import'../../overlays/empty/empty.class.js';import type{RetrievalQuery,CancelEventDetail}from'../../../ai/types.js';import{type LyraSize}from'../../../internal/variants.js'; /** The three retrieval modes `RetrievalQuery.mode` supports, reused verbatim rather than * redefining the union -- see `src/ai/types.ts`'s own header for why. */ export type LyraRetrievalMode=RetrievalQuery['mode']; /** `detail` for `lr-filters-change` -- the complete, already-updated `filters`/`scope` state * after a chip removal, mirroring ``'s `lr-sources-change` "full next state" * convention rather than a single-item delta. */ export interface RetrievalFiltersChangeDetail{filters:Record;scope:string[];}export interface LyraRetrievalSearchEventMap{'lr-search':CustomEvent>;'lr-cancel':CustomEvent;'lr-filters-change':CustomEvent>;} /** * `` -- the query bar for a retrieval/RAG surface: query text, an active- * filter/scope chip row, a vector/keyword/hybrid mode selector, and loading/error/empty status * feedback. Consumes `RetrievalQuery` (`src/ai/types.ts`) as the shape emitted on submit. * * Fully controlled, like every other Lyra input: `query`/`mode`/`filters`/`scope` are host-owned * properties. This component never performs retrieval itself -- it only emits `lr-search`; the * host owns the actual fetch and toggles `loading` around it. Because this component has no way * to know when a request resolves (only `loading`, set from outside), submitting again (Enter, or * clicking the button) while `loading` is already `true` is treated as **superseding** the * in-flight request: `lr-cancel` fires immediately before the new `lr-search`. The submit button * itself doubles as an explicit Cancel affordance while `loading` -- clicking it only emits * `lr-cancel`, without resubmitting, the same "just stop" action ``'s Stop * button offers for its own `stoppable` busy state. * * Composes `` for the query field, `` for the mode * selector (the same small-closed-set-choice-in-a-toolbar role it already fills, left at the shared * default size so it resolves the same `--lr-form-control-height` as the query field and the submit * button and the row reads as one flush line), ``/`` for removable active-filter/scope * chips, `` for the loading state, and `` (compact) for the empty state. * `filters`/`scope` chip removal updates this component's own copy first, then emits * `lr-filters-change` with the complete next state -- the same "update, then emit; reassign to * control" round-trip ``'s `selectedSourceIds` already establishes. `empty` is a * host-driven flag (the last completed search returned zero results); this component holds no * results data of its own -- see `` for rendering the actual chunk list. * * 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. * * @customElement lr-retrieval-search * @event lr-search - The query was submitted (Enter in the query field, or the submit button * while not `loading`). `detail`: the full `RetrievalQuery` (`{ text, mode, filters, scope }`). * @event lr-cancel - The in-flight request should be cancelled: either the user clicked the * button while `loading` (`detail: {}`), or a new submission superseded the in-flight one before * it resolved (`detail: { reason: 'superseded' }`, fired immediately before the new `lr-search`). * @event lr-filters-change - A `filters`/`scope` chip's remove button was activated. `detail`: the * complete updated `{ filters, scope }` state. * @csspart base - The root search shell. It owns `role="search"` and the fallback name unless a * non-empty host `aria-label` makes the host the sole overall owner. * @csspart row - The row holding the query field, mode selector, and submit/cancel button. * @csspart query - The query ``. * @csspart mode - The vector/keyword/hybrid ``. * @cssprop [--lr-retrieval-search-submit-min-height=var(--lr-icon-button-size)] - Minimum height of * the submit button. A `size` tier raises it to that tier's shared form-control height; the * shared tappable-target minimum always stays underneath, so no tier can shrink the button past * the WCAG floor. * @csspart submit - The submit/cancel `