/**
 * `<password-strength-ui>` — Visual strength indicator for password inputs — 4-segment bar (weak /
fair / good / strong) computed from a heuristic combining length,
character-class diversity, and repeat-pattern penalty. Pairs with
`<input-ui type="password">` via JS:
  input.addEventListener('input', e => meter.value = e.target.value)
Read-only display primitive — no form participation. Emits a
`score-change` event when the bucket changes so consumers can gate
a submit button on `detail.satisfied` (score ≥ min-score).

**Security note:** [value] is held as a JS property only, NOT
reflected to a DOM attribute. The element stamps the bar + label
from the property; the password never appears in the rendered HTML.
Do not set the value via setAttribute (it will be no-op).

 *
 * @see https://ui-kit.exe.xyz/site/components/password-strength
 *
 * 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 PasswordStrengthScoreChangeEventDetail {
  label: string;
  satisfied: string;
  score: string;
}

export type PasswordStrengthScoreChangeEvent = CustomEvent<PasswordStrengthScoreChangeEventDetail>;

export class UIPasswordStrength extends UIElement {
  /** Minimum acceptable score (0–3). The `score-change` event's
`detail.satisfied` boolean reflects whether the current score
meets this threshold. Useful for gating a submit button.
 */
  minScore: number;
  /** Display the textual score label ("Weak" / "Fair" / "Good" /
"Strong") below the bar. Defaults to true.
 */
  showLabel: boolean;
  /** The password string to score. JS-property only — NOT reflected
to a DOM attribute (so the password never leaks into rendered
HTML). Wire to an input via `input.addEventListener('input', e =>
meter.value = e.target.value)`.
 */
  value: string;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UIPasswordStrength, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'score-change', listener: (ev: PasswordStrengthScoreChangeEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
