/**
 * `<accordion-ui>` — Accordion container managing single or multiple open states across
a collection of <accordion-item-ui> children. Each item carries its
own [open] reflected state; the accordion host coordinates exclusive
opening when [multiple] is unset (default single-open mode). Use
inside settings pages, FAQ blocks, or any progressive-disclosure
pattern where one-level collapsible groups suffice — for arbitrary
hierarchy use <tree-ui>; for in-page view switching use <tabs-ui>.

 *
 * @see https://ui-kit.exe.xyz/site/components/accordion
 *
 * 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 AccordionToggleEventDetail {
  /** New open state of the panel. */
  open: boolean;
}

export type AccordionToggleEvent = CustomEvent<AccordionToggleEventDetail>;

export class UIAccordion extends UIElement {
  /** Allow multiple panels to be open simultaneously */
  multiple: boolean;

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

export interface AccordionItemToggleEventDetail {
  /** New open state. */
  open: boolean;
}

export type AccordionItemToggleEvent = CustomEvent<AccordionItemToggleEventDetail>;

export class UIAccordionItem extends UIElement {
  /** Whether the section is expanded. */
  open: boolean;
  /** Header text — the clickable label that toggles the section. */
  text: string;

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