import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraClipboardWriteFailure,type LyraClipboardWriteSuccess}from'../../../internal/clipboard.js';import type{LyraToolbarAction}from'../../conversation/message-actions/toolbar-actions.js';export type{LyraClipboardWriteFailure,LyraClipboardWriteOutcome,LyraClipboardWriteSuccess,LyraCopyErrorReason,}from'../../../internal/clipboard.js'; /** When the copy button's tooltip is available. */ export type LyraCopyButtonTooltip='full'|'copy'|'none'; /** Side on which the copy button's tooltip appears. */ export type LyraCopyButtonTooltipPlacement='top'|'right'|'bottom'|'left';export interface LyraCopyButtonEventMap{'lr-copy':CustomEvent;'lr-error':CustomEvent;'lr-toolbar-actions-change':Event;'lr-copy-error':CustomEvent;} /** * `` — a standalone icon-only copy-to-clipboard affordance for a plain * single/multi-line text value in a layout the consumer controls (e.g. absolutely positioned in * the corner of an `lr-textarea` or a read-only output field). Unlike `lr-code-block`'s or * `lr-json-viewer`'s own built-in copy buttons, this takes no positioning opinion of its own and * has no code/JSON content model to adopt just to reuse the copy affordance. * * When `from` is set it takes precedence over `value`: an element id copies `textContent`, * `id[attribute]` copies an attribute, and `id.property` copies a property. An empty value, a * missing source, or a rejected Clipboard API call enters the error state. Native `dir` and * `lang` remain inherited global attributes. Renderer bookkeeping and manifest-inferred form * metadata are deliberately not component properties; this control is not form-associated. * * The confirmation state is only entered once the clipboard write actually resolves; a rejected * write (denied permission, insecure context, unfocused document) renders a distinct failure * glyph, announces itself through the live region, and emits both `lr-error` and the retained, * detailed `lr-copy-error` alias. * * This trigger has no `size` property of its own: it composes ``, so the built-in * trigger's hit area is that component's shared `--lr-icon-button-size` floor (2.5rem/40px), same * as everywhere else in the library. For a dense action row (e.g. several copy buttons packed into * a toolbar) where 40px is more than the layout can afford, lower `--lr-icon-button-size-scope` * (the subtree-scoped input) or `--lr-theme-icon-button-size` (the application-wide one) -- NOT * `--lr-icon-button-size` itself, which every `LyraElement` re-declares on its own `:host` and so * never reaches a composed child (`internal/tokens.test.ts` proves this) -- on this element or * any ancestor of it; `::part(base__control)` also reaches the same composed native control * directly for a one-off override. Either way the shrink is local to the elements it targets, not * a library-wide floor change. A coarse-pointer/no-hover safety net (`internal/tokens.styles.ts`'s * `baseTokens`) then floors the rendered hit area back at 2.75rem/44px regardless of how far the * dense-row override lowered it, so an intentionally cramped desktop toolbar is still comfortably * tappable the moment the pointer reaching it is a finger rather than a mouse. * * @customElement lr-copy-button * @slot - A custom trigger. When present, it replaces the built-in icon button. * @slot copy-icon - Resting copy icon for the built-in button. * @slot success-icon - Confirmation icon for the built-in button. * @slot error-icon - Failure icon for the built-in button. * @event lr-copy - Clipboard writing fulfilled. The frozen shared outcome detail is * `{ ok: true, text }`. Failed writes emit `lr-copy-error` instead. * @event lr-error - The source could not be resolved or clipboard writing failed. A bubbling, * composed, non-cancelable `CustomEvent` with no detail, matching the mapped notification. * @event lr-copy-error - Source resolution or clipboard writing failed. The frozen detail is * `{ ok: false, text, reason, error }`, where * `reason` is `'unsupported' | 'denied' | 'failed'` and `error` is the platform error (a * `DOMException` for a real rejection) or a component-created source error. Retained as a * richer Lyra compatibility alias for `lr-error`. * @event lr-toolbar-actions-change - The logical action exposed to a parent toolbar changed its * disabled state or backing trigger. Bubbling, composed, and non-cancelable. * @csspart base - The built-in trigger, which is a composed `` rather than this * component's own `