// src/types/ymaps.d.ts
declare namespace ymaps {
  type ReadyCallback = () => void;

  interface IEventEmitter {
    add: (eventName: string, handler: (...args: any[]) => any) => void;
    remove?: (eventName: string, handler: (...args: any[]) => any) => void;
    fire?: (eventName: string, eventObject?: any) => void;
  }

  interface IGeoObjectCollection {
    add: (geoObject: any) => void;
    remove?: (geoObject: any) => void;
    removeAll?: () => void;
  }

  interface MapOptions {
    center?: [number, number];
    zoom?: number;
    controls?: string[];
    [key: string]: any;
  }

  class Map implements IEventEmitter {
    constructor(container: HTMLElement | string, options?: MapOptions);

    events: IEventEmitter;
    geoObjects: IGeoObjectCollection;

    setCenter(center: [number, number] | number[], zoom?: number): void;
    getCenter(): [number, number];

    setZoom(zoom: number, options?: any): void;
    getZoom(): number;

    destroy(): void;
  }

  interface PlacemarkOptions {
    iconLayout?: string;
    iconImageHref?: string;
    iconImageSize?: [number, number];
    iconImageOffset?: [number, number];
    iconColor?: string;
    draggable?: boolean;
    [key: string]: any;
  }

  class Placemark implements IEventEmitter {
    constructor(coords: [number, number] | number[], properties?: any, options?: PlacemarkOptions);
    properties: any;
    events: IEventEmitter;
  }

  function ready(callback: ReadyCallback): void;
}

declare global {
  interface Window {
    ymaps?: typeof ymaps;
  }
}

declare module "ymaps" {
  export = ymaps;
}
