/// <reference types="./types/api"/>
/// <reference types="./types/models"/>
/// <reference types="./types/plugins"/>
/// <reference types="./types/state"/>
/// <reference types="./types/window"/>

declare module "@bimdata/viewer" {
  /** See: https://developers.bimdata.io/viewer/reference/makeBIMDataViewer.html */
  export default function makeBIMDataViewer(cfg: BDV.ViewerConfig): BDV.Viewer;
}

declare namespace BDV {
  interface Viewer {
    /** See: https://developers.bimdata.io/viewer/reference/mount.html#mount */
    mount(container: HTMLElement | string, layout?: any): any;
    destroy(): void;
    setAccessToken(token: string): void;
    setLocale(lang: ViewerLocale): void;
    registerPlugin(plugin: PluginDefinition): void;
    registerWindow(window: Object): void;
    unregisterWindow(name: string): void;
    loadModels(modelIds: number[]): Promise<StateModel[]>;
  }

  type ViewerLocale = "de" | "en" | "es" | "fr" | "it";

  interface ViewerConfig {
    ui?: ViewerConfigUI;
    api: ViewerConfigApi;
    plugins?: ViewerConfigPlugins;
    locale?: ViewerLocale;
  }

  interface ViewerConfigUI {
    bimdataLogo?: boolean;
    contextMenu?: boolean;
    header?: boolean;
    mobile?: boolean;
    resizable?: boolean;
    style?: {
      backgroundColor?: string;
      colorPrimary?: string;
      colorPrimaryLighter?: string;
      colorPrimaryLight?: string;
      colorPrimaryDark?: string;
      colorSecondary?: string;
      colorSecondaryLight?: string;
      colorSecondaryLighter?: string;
      colorSecondaryDark?: string;
      colorSilverLight?: string;
      colorSilver?: string;
      colorSilverDark?: string;
      colorGraniteLight?: string;
      colorGranite?: string;
      colorSuccess?: string;
      colorSuccessLight?: string;
      colorSuccessLighter?: string;
      colorSuccessDark?: string;
      colorWarning?: string;
      colorWarningLight?: string;
      colorWarningLighter?: string;
      colorWarningDark?: string;
      colorHigh?: string;
      colorHighLight?: string;
      colorHighLighter?: string;
      colorHighDark?: string;
      colorText?: string;
      headerHeight?: string;
    };
    version?: boolean;
  }

  interface ViewerConfigApi {
    apiUrl?: string;
    archiveUrl?: string;
    pdfBackendUrl?: string;
    accessToken: string;
    cloudId: number;
    projectId: number;
    modelIds?: number[];
    onlyLoadUuids?: {
      [id: number]: string[];
    };

    offline?: {
      enabled: boolean;
      data: string | Blob;
    };
  }

  interface ViewerConfigPlugins {
    "360-annotations"?: boolean;
    accessMarketplace?: boolean;
    "anchor-synchronization"?: boolean;
    "anchor-synchronization-window"?: boolean;
    alerts?: boolean;
    back?: boolean;
    bcf?: boolean;
    bcfManager?:
    | boolean
    | {
      topicGuid?: string;
    };
    buildingMaker?: boolean;
    "drawing-tools"?: boolean;
    dwg?:
    | boolean
    | {
      help?: boolean;
      modelLoader?: "hidden" | "disabled";
    };
    "dwg-layer"?: boolean;
    dxf?:
    | boolean
    | {
      help?: boolean;
      modelLoader?: "hidden" | "disabled";
    };
    firstPersonView?: boolean;
    fullscreen?: boolean;
    ged?: boolean;
    label?:
    | boolean
    | {
      classes?: Array<{ name: string; color: string; }>;
    };
    measure2d?: boolean;
    measure3d?: boolean;
    measureDwg?: boolean;
    metaBuildingStructure?: boolean;
    miniMap2d?: boolean;
    miniMap360?: boolean;
    mobile?:
    | boolean
    | {
      edges?: boolean;
      enableDTX?: boolean;
    };
    "mobile-plan"?: boolean;
    navigationVersionsModel?: boolean;
    pdf?: boolean;
    pdfExport?: boolean;
    photosphere?:
    | boolean
    | {
      modelLoader?: "hidden" | "disabled";
    };
    photosphereBuilding?: boolean;
    plan?:
    | boolean
    | {
      help?: boolean;
      metaBuildingStructure?: boolean;
      modelLoader?: "hidden" | "disabled";
      storeySelector?: boolean;
      storeySelectorAutoOpen?: boolean;
    };
    "plan-mask"?: boolean;
    "plan-mask-button"?: boolean;
    pointCloud?:
    | boolean
    | {
      help?: boolean;
      modelLoader?: "hidden" | "disabled";
      navCube?: boolean;
      pivotMarker?: boolean;
    };
    pointCloudParameters?: boolean;
    properties?:
    | boolean
    | {
      editProperties?: boolean;
    };
    "right-angled"?: boolean;
    rotation2d?: boolean;
    search?: boolean;
    section?: boolean;
    smartview?: boolean;
    split?: boolean;
    structure?:
    | boolean
    | {
      export?: boolean;
      merge?: boolean;
      translateIfcEntities?: boolean;
      customTranslations?: Object;
    };
    "structure-properties"?:
    | boolean
    | {
      editProperties?: boolean;
      export?: boolean;
      merge?: boolean;
      translateIfcEntities?: boolean;
      customTranslations?: Object;
    };
    synchronization?: boolean;
    viewer2d?:
    | boolean
    | {
      compass?: boolean;
      help?: boolean;
      modelLoader?: "hidden" | "disabled";
      storeySelector?: boolean;
      storeySelectorAutoOpen?: boolean;
    };
    "viewer2d-background"?: boolean;
    "viewer2d-parameters"?: boolean;
    "viewer2d-screenshot"?: boolean;
    viewer3d?:
    | boolean
    | {
      defaultScaleCanvasResolutionFactor?: number;
      edges?: boolean;
      enableDTX?: boolean;
      enableDynamicLOD?: boolean;
      enableOffsets?: boolean;
      home?: boolean;
      help?: boolean;
      interactiveSpaces?: boolean;
      modelLoader?: "hidden" | "disabled";
      navCube?: boolean;
      navigationVersionsModel?: boolean;
      performanceModeScaleCanvasResolutionFactor?: number;
      pivotMarker?: boolean;
      scaleCanvasResolution?: boolean;
    };
    "viewer3d-parameters"?: boolean;
    "window-manager"?: boolean;
    "window-selector"?: boolean;
    "zone-editor"?:
    | boolean
    | {
      doneButton?: boolean;
    };
    "zone-editor-button"?: boolean;
  }
}
