/**
 * `<noodles-ui>` — SVG connection lines (noodles) between children with declared ports. Supports bezier, step, and straight curves.
 *
 * @see https://ui-kit.exe.xyz/site/components/noodles
 *
 * 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 NoodlesNoodleConnectEventDetail {
  /** Source node ID. */
  from: string;
  /** Source port identifier. */
  fromPort: string;
  /** Connection ID. */
  id: string;
  /** Target node ID. */
  to: string;
  /** Target port identifier. */
  toPort: string;
}

export type NoodlesNoodleConnectEvent = CustomEvent<NoodlesNoodleConnectEventDetail>;
export interface NoodlesNoodleDisconnectEventDetail {
  /** Source node ID. */
  from: string;
  /** Source port identifier. */
  fromPort: string;
  /** Connection ID. */
  id: string;
  /** Target node ID. */
  to: string;
  /** Target port identifier. */
  toPort: string;
}

export type NoodlesNoodleDisconnectEvent = CustomEvent<NoodlesNoodleDisconnectEventDetail>;
export type NoodlesNoodleDragEvent = CustomEvent<unknown>;

export class UINoodles extends UIElement {
  /** Flowing dash animation on noodles */
  animated: boolean;
  /** Noodle stroke color. Defaults to --a-accent */
  color: string;
  /** Noodle curve style */
  curve: 'bezier' | 'step' | 'straight';
  /** Allow interactive creation/deletion of connections via drag */
  editable: boolean;
  /** Port indicator size */
  portSize: number;
  /** View-only mode; disables drag/edit while keeping connections visible */
  readonly: boolean;
  /** Show port indicators */
  showPorts: boolean;
  /** Line stroke width */
  strokeWidth: number;
  /** Bezier control point distance (0-1). Higher = wider curves */
  tension: number;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UINoodles, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'noodle-connect', listener: (ev: NoodlesNoodleConnectEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'noodle-disconnect', listener: (ev: NoodlesNoodleDisconnectEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'noodle-drag', listener: (ev: NoodlesNoodleDragEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
