/**
 * `<chat-thread-ui>` — Primitive chat message thread surface — a minimal scroll container
for ad-hoc message rendering. Distinct from the bespoke shell
child <chat-thread> (module-tier, lives inside <chat-shell>, owns
scroll-to-bottom + [streaming] + [empty] reflected state). Use
chat-thread-ui when embedding chat-like rows OUTSIDE a chat-shell
(e.g. a comment thread inside <card-ui>); use <chat-thread> when
authoring a chat-shell.

 *
 * @see https://ui-kit.exe.xyz/site/components/chat-thread
 *
 * Type declarations generated by scripts/build/dts-codegen.mjs from
 * the component's `.a2ui.json` sidecar(s). Edit the source `.yaml`,
 * run `npm run build:components`, then `npm run codegen:dts` to
 * regenerate; or hand-author this file fully if rich event types are
 * needed beyond what the yaml `events:` block can express.
 */

import { UIElement } from '../../core/element.js';

export interface ChatThreadSubmitEventDetail {
  /** Selected model identifier. */
  model: string;
  /** Submitted message text. */
  text: string;
}

export type ChatThreadSubmitEvent = CustomEvent<ChatThreadSubmitEventDetail>;

export class UIChatThread extends UIElement {
  /** Component property: streaming. */
  streaming: boolean;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UIChatThread, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'submit', listener: (ev: ChatThreadSubmitEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}

export interface ChatInputSubmitEventDetail {
  /** Currently selected model value (empty if no model picker). */
  model: string;
  /** Submitted message text from the inner textarea. */
  text: string;
}

export type ChatInputSubmitEvent = CustomEvent<ChatInputSubmitEventDetail>;

export class UIChatInput extends UIElement {
  /** Disable the entire input. Textarea becomes contenteditable=false;
send button disabled.
 */
  disabled: boolean;
  /** In-flight / streaming state. Send button disabled, submit events
suppressed, but textarea stays editable so the user can draft a
follow-up while the model is still responding.
 */
  loading: boolean;
  /** Currently selected model value (reflected, two-way with inner
`<select-ui slot="model">`). Empty when no model picker is shown.
 */
  model: string;
  /** JSON array of model options for the inner model picker —
[{value, label}] or [{label, options: [...]}] groups. Empty array
hides the model picker.
 */
  models: unknown[];
  /** Textarea placeholder. Defaults to "Type a message...". */
  placeholder: string;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UIChatInput, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'submit', listener: (ev: ChatInputSubmitEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
