export class HTMX {
  addClass(elt: HTMLElement, className: string): undefined;
  ajax(
    verb: string,
    path: string,
    context?: null | string | HTMLElement | {
      source?: any
      event?: any
      handler?: any
      target?: any
      values?: any
      headers?: any
    }): void;
  closest(elt: HTMLElement, className: string): HTMLElement | void;
  config: {
    attributesToSettle: Array<string>,
    defaultSettleDelay: number,
    defaultSwapDelay: number,
    defaultSwapStyle: "none" | "innerHTML" | "outerHTML" | "afterbegin" | "beforebegin" | "beforeend" | "afterend",
    historyCacheSize: number,
    historyEnabled: boolean,
    includeIndicatorStyles: boolean,
    indicatorClass: string,
    requestClass: string,
    settlingClass: string,
    swappingClass: string,
    allowEval: boolean,
    useTemplateFragments: boolean,
    withCredentials: boolean,
    wsReconnectDelay: "full-jitter" | Function,
    refreshOnHistoryMiss: boolean,
    disableSelector: string,
  }
  createEventSource: (url: string) => EventSource;
  createWebSocket: (url: string) => WebSocket;
  defineExtension(name: string, ext: any): void;
  find(selector: string): HTMLElement | null;
  find(elt: HTMLElement, selector: string): HTMLElement | null;
  findAll(selector: string): NodeList;
  findAll(elt: HTMLElement, selector: string): NodeList;
  logAll(): void;
  logger: (elt: HTMLElement, event: Event, data: any) => void;
  off(eventName: string, listener: EventListener): EventListener;
  off(target: string | HTMLElement, eventName: string, listener: EventListener): EventListener;
  on(eventName: string, listener: EventListener): EventListener;
  on(target: string | HTMLElement, eventName: string, listener: EventListener): EventListener;
  onLoad(callback: (elt: HTMLElement) => void): EventListener;
  parseInterval(string: string): number;
  process(elt: HTMLElement): undefined
  remove(elt: HTMLElement): undefined;
  removeClass(elt: HTMLElement, className: string): undefined;
  removeExtension(name: string): undefined;
  takeClass(elt: HTMLElement, className: string): undefined;
  toggleClass(elt: HTMLElement, className: string): undefined;
  trigger(elt: HTMLElement, name: string, details: any): any;
  values(elt: HTMLElement, requestType?: string): object;
}

declare global {
  export const htmx: HTMX;
  export type HtmxEvent = {
    detail: {
      elt: HTMLElement,
      xhr: XMLHttpRequest,
      target: HtmlElement,
      requestConfig: {
        parameters: any,
        unfilteredParameters: any,
        headers: {[string]: string},
        target: any,
        verb: any,
        errors: any,
        path: string,
        triggeringEvent: any,
      },
    },
  }
}
