import { IKosModelManager } from '../core/kosModelManager';
import { FeatureFlagService } from '../util/feature-flags';
export {};

declare namespace NodeJS {
  export interface ProcessEnv {
    KOS_ALLOW_ANONYMOUS: string;
    KOS_PLATFORM: string;
    KOS_LOG_WS: string;
    KOS_LOGIN_URL: string;
    KOS_APP_PORT: string;
    KOS_PORT: string;
    KOS_STUDIO_PORT: string;
    KOS_CONNECTION_ALIAS: string;
    KOS_MOCK_WS: string;
    KOS_LOG_WS: string;
    KOS_FOS_PORT: string;
    KOS_USE_FOS: string;
    KOS_WS_TIMEOUT: string;
    KOS_LOG_LEVEL: string;
    KOS_MOCK_FETCH: string;
    KOS_MESSAGE_LOGGING: string;
    KOS_MESSAGE_STUDIO_LOGGING: string;
  }
}

declare global {
  interface KosAgent {
    agentEnabled?: boolean;
    initializeAgent?: (modelManager: IKosModelManager) => void;
  }
  type KosMockWsHandler = (requestId: string) => string;
  type TransportData = string | ArrayBufferLike | Blob | ArrayBufferView;
  type TransportSend = (data: TransportData, handler: KosMockWsHandler) => void;
  interface Window {
    kosTopicHandlers?: Record<string, () => string>;
    kosTopicIntercept?: (data: TransportData) => {
      handler: KosMockWsHandler;
      requestId: string;
    };
    kosMockSend?: TransportSend;
    kos?: KosAgent;
    kosMockWs?: boolean;
    kosEnableMocks?: boolean;
    kosLogEvents?: boolean;
    kosUseFos?: boolean;
    kosFosPort?: number;
    kosLogLevel?: string;
    kosMessageLogging?: boolean;
    kosMessageStudioLogging?: boolean;
    setKosLogLevel: (level: any) => void;
    enableKosMessageLog: () => void;
    disableKosMessageLog: () => void;
    KosFeatureFlags: FeatureFlagService;
  }
}

declare global {
  interface Window {
    kosWindowWebsocketOpen: () => void;
    kosWindowWebsocketSend: (
      data: string | ArrayBufferLike | Blob | ArrayBufferView
    ) => void;
    kosWindowWebsocketRecv: (msg: string) => void;
    kosLog: (msg: string) => void;
  }
}
