declare module "dh-mini-sdk-for-wx-2.0.1" {
  type Callback = (result: any) => void;

  type SuccessCallback = (response: Response) => void;

  type FailCallback = (error: Error) => void;

  type CompleteCallback = (result: Result) => void;

  interface Response {
    code: string | number | undefined;
    data: any;
    message: string
  }

  interface Error {
    code: string | number | undefined;
    data: any;
    message: string
  }

  interface Result {
    code: string | number | undefined;
    data: any;
    message: string
  }

  interface Options {
    requests: Requests;
    gameAppId: string | number;
    appId: string | number;
    appVersion: string;
    packageName: string;
    channel: string | number;
    mainChannel: string | number;
    secondChannel: string | number;
    heartbeatEnable?: boolean;
    reyunAppKey?: string;
    gravityEngineAccessToken?: string;
    gravityEngineDebug?: boolean;
    gravityEnginePayEventEnable?: boolean;
    tencentUserActionId: number;
    tencentSecretKey: string;
    tencentDebug?: boolean;
  }

  interface Requests {
    login: string | string[];
    pay: string | string[];
    midas: string | string[];
    survey: string | string[];
    customerService: string | string[];
    gameClub: string | string[];
    log: string | string[];
    errorLog: string | string[];
  }

  interface UserInfo {
    accountId: number;
    accountName: string;
    accountView: string;
    expireTimestamp: number;
    loginTimestamp: number;
    loginType: number;
    region: number;
    sign: string;
    token: string;
    isFirstLogin: boolean;
    userExtraInfo: UserExtraInfo;
  }

  interface UserExtraInfo {
    openId: string;
    userName: string;
    avatar: string;
    nickName: string;
  }

  interface UserRoleInfo {
    type: "LOGIN_GAME" | "CREATE_ROLE" | "LEVEL_UP" | "PAY_SUCCESS";
    areaId?: string | number;
    areaName?: string;
    roleId?: string | number;
    roleName?: string;
    roleLevel?: number;
    roleVipLevel?: number;
    itemId?: string;
    itemName?: string;
    orderId?: string | number;
    orderPrice?: number;
    currency?: string;
    payType?: string;
  }

  interface LoginOptions {
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface UploadRoleInfoOptions {
    type: "LOGIN_GAME" | "CREATE_ROLE" | "LEVEL_UP" | "PAY_SUCCESS";
    areaId?: string | number;
    areaName?: string;
    roleId?: string | number;
    roleName?: string;
    roleLevel?: number;
    roleVipLevel?: number;
    itemId?: string;
    itemName?: string;
    orderId?: string | number;
    orderPrice?: number;
    currency?: string;
    payType?: string;
  }

  interface CreateUserInfoButtonOptions {
    type: "text" | "image";
    text?: string;
    image?: string;
    style: {
      top: number;
      left: number;
      width: number;
      height: number;
      borderWidth?: number;
      borderRadius?: number;
      borderColor?: string;
      backgroundColor?: string;
      color?: string;
      fontSize?: number;
      textAlign?: string;
      lineHeight?: number;
    };
    withCredentials?: boolean;
    lang?: "en" | "zh_CN" | "zh_TW";
  }

  interface UserInfoButton {
    show: () => void;
    hide: () => void;
    destroy: () => void;
    onTap: (listener: Callback) => void;
    offTap: (listener: Callback) => void;
  }

  interface GetUserInfoOptions {
    withCredentials?: boolean;
    lang?: "en" | "zh_CN" | "zh_TW";
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface PayOptions {
    cardMessageTitle?: string;
    cardMessageImage?: string;
    areaId?: string | number;
    areaName?: string;
    roleId?: string | number;
    roleName?: string;
    roleLevel?: number;
    itemId: string;
    itemName: string;
    itemNum?: number;
    itemPrice: number;
    currency?: string;
    rate: number;
    memo?: string;
    remark?: string;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface PaySettings {
    android?: "h5" | "midas";
    ios?: "h5";
    windows?: "h5" | "midas";
    mac?: "h5";
    devtools?: "h5" | "midas";
  }

  interface CreateRewardedVideoAdOptions {
    adUnitId: string;
    adMultiton?: boolean;
    adPlatform?: string;
    adPosition?: string;
    onLoad?: (response: Response) => void;
    onClose?: (result: Result) => void;
    onError?: (error: Error) => void;
  }

  interface RewardedVideoAd {
    load: (callback?: Callback) => void;
    show: (options?: RewardedVideoAdShowOptions | Callback, callback?: Callback) => void;
    destroy: () => void;
  }

  interface RewardedVideoAdShowOptions {
    adPosition?: string;
  }

  interface OpenSurveyOptions {
    areaId?: string | number;
    roleId?: string | number;
    roleName?: string;
    roleLevel?: number;
    surveyId: number;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface OpenCustomerServiceOptions {
    areaId?: string | number;
    roleId?: string | number;
    roleName?: string;
    roleLevel?: number;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface CreateFeedbackButtonOptions {
    type: "text" | "image";
    text?: string;
    image?: string;
    style: {
      top: number;
      left: number;
      width: number;
      height: number;
      borderWidth?: number;
      borderRadius?: number;
      borderColor?: string;
      backgroundColor?: string;
      color?: string;
      fontSize?: number;
      textAlign?: string;
      lineHeight?: number;
    }
  }

  interface FeedbackButton {
    show: () => void;
    hide: () => void;
    destroy: () => void;
    onTap: (listener: Callback) => void;
    offTap: (listener: Callback) => void;
  }

  interface OpenChannelsUserProfileOptions {
    finderUserName: string;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface OpenChannelsEventOptions {
    finderUserName: string;
    eventId: string;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface OpenChannelsActivityOptions {
    finderUserName: string;
    feedId: string;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface OpenChannelsLiveOptions {
    finderUserName: string;
    feedId?: string;
    noticeId?: string;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface ReserveChannelsLiveOptions {
    noticeId: string;
  }

  interface GetChannelsLiveNoticeInfoOptions {
    finderUserName: string;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface GetChannelsLiveInfoOptions {
    finderUserName: string;
    startTime?: number;
    endTime?: number;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface CreateGameClubButtonOptions {
    type: "text" | "image";
    text?: string;
    icon?: "green" | "white" | "dark" | "light";
    image?: string;
    style: {
      top: number;
      left: number;
      width: number;
      height: number;
      borderWidth?: number;
      borderRadius?: number;
      borderColor?: string;
      backgroundColor?: string;
      color?: string;
      fontSize?: number;
      textAlign?: string;
      lineHeight?: number;
    };
    openlink?: string;
    hasRedDot?: boolean;
  }

  interface GameClubButton {
    show: () => void;
    hide: () => void;
    destroy: () => void;
    onTap: (listener: Callback) => void;
    offTap: (listener: Callback) => void;
  }

  interface ShareImageToGameClubOptions {
    title: string;
    content: string;
    url?: string;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface ShareCanvasToGameClubOptions {
    title: string;
    content: string;
    x?: number;
    y?: number;
    width?: number;
    height?: number;
    destWidth?: number;
    destHeight?: number;
    fileType?: "png" | "jpg";
    quality?: number;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface GetGameClubDataOptions {
    dataTypeList: GameClubDataType[];
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface GameClubDataType {
    type: number;
    subKey?: string;
  }

  interface GameRecorder {
    isFrameSupported(): boolean;
    isSoundSupported(): boolean;
    isVolumeSupported(): boolean;
    isAtempoSupported(): boolean;
    on(event: string, callback: Callback): void;
    off(event: string, callback: Callback): void;
    start(options?: GameRecorderStartOptions): Promise<any>;
    pause(): Promise<any>;
    resume(): Promise<any>;
    stop(): Promise<any>;
    abort(): Promise<any>;
  }

  interface GameRecorderStartOptions {
    fps?: number;
    bitrate?: number;
    gop?: number;
    duration?: number;
    hookBgm?: boolean
  }

  interface ShareGameRecorderVideoOptions {
    title?: string;
    desc?: string;
    path?: string;
    query?: string;
    timeRange?: number[][];
    bgm?: string;
    volume?: number;
    atempo?: number;
    audioMix?: boolean;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface CreateGameRecorderShareButtonOptions {
    icon?: string;
    image?: string;
    text?: string;
    style?: {
      top?: number;
      left?: number;
      height?: number;
      paddingLeft?: number;
      paddingRight?: number;
      color?: string;
      fontSize?: number;
      iconMarginRight?: number;
    };
    share?: {
      path?: string;
      query?: string;
      timeRange?: number[][];
      bgm?: string;
      volume?: number;
      atempo?: number;
      audioMix?: boolean;
    }
  }

  interface GameRecorderShareButton {
    show: () => void;
    hide: () => void;
    destroy: () => void;
    onTap: (listener: Callback) => void;
    offTap: (listener: Callback) => void;
  }

  interface SetShareOptions {
    title?: string;
    imageUrl?: string;
    imageUrlId?: string;
    imagePreviewUrl?: string;
    imagePreviewUrlId?: string;
    path?: string;
    query?: Record<string, unknown>;
  }

  interface ShareOptions {
    title?: string;
    imageUrl?: string;
    imageUrlId?: string;
    path?: string;
    query?: Record<string, unknown>;
  }

  interface ShowShareImageMenuOptions {
    path: string;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface SubscribeMessageOptions {
    tmplIds: string[];
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface SubscribeSystemMessageOptions {
    msgTypeList: string[];
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface OpenSettingOptions {
    withSubscriptions?: boolean;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface GetSettingOptions {
    withSubscriptions?: boolean;
    success?: SuccessCallback;
    fail?: FailCallback;
    complete?: CompleteCallback;
  }

  interface TrackEventEventParams {
    [key: string]: any;
  }

  interface ModalConfirmOptions {
    title: string;
    content: string;
    cancelText?: string;
    confirmText?: string;
    success?: Callback;
    fail?: Callback;
    complete?: Callback;
  }

  interface AnalyticsRoleOptions {
    areaId?: string | number;
    roleId?: string | number;
    roleName?: string;
    roleGender?: number;
    soles?: number;
  }

  interface AnalyticsPayOptions {
    areaId?: string | number;
    roleId?: string | number;
    roleLevel?: number;
    roleVipLevel?: number;
    channel?: number;
    orderId: string;
    orderPrice: number;
    itemId: string;
    payType?: string;
    currency?: string;
  }

  interface AnalyticsAdOptions {
    adUnitId?: string;
    adType?: number;
    adPlatform?: string;
    adPosition?: string;
    adEventName: "ad_play" | "ad_inclick" | "ad_close" | "ad_error";
    adEventResult?: 0 | 1 | 2;
    adEventMessage?: string;
    adPlayDuration?: number;
  }

  interface AnalyticsShareOptions {
    shareType: 1 | 2 | 3;
  }

  interface AnalyticsEventOptions {
    areaId?: string | number;
    roleId?: string | number;
    eventName: string;
    eventObj?: string;
    eventResult?: string;
    eventCode?: string;
    statMode?: 1 | 2;
    extendParamJson?: string;
  }

  interface AnalyticsLogOptions {
    eventId: string;
    subEventId?: string;
    logLevel?: "d" | "e";
    logContent: string;
    accountId?: string | number;
  }

  export default class DHMiniSDK {
    constructor(options: Options);

    readonly version: string;
    readonly requests: Requests;
    readonly env: "develop" | "trial" | "release";
    readonly isShow: boolean;
    readonly system: any;
    readonly networkType: string;
    readonly deviceId: string;
    readonly deviceOS: string;
    readonly launchOptions: any;
    readonly gameAppId: string | number;
    readonly appId: string | number;
    readonly appVersion: string;
    readonly packageName: string;
    readonly channel: string | number;
    readonly mainChannel: string | number;
    readonly secondChannel: string | number;
    readonly userInfo: UserInfo | null;
    readonly userRoleInfo: UserRoleInfo | null;
    readonly heartbeatEnable: boolean;
    readonly reyunAppKey?: string;
    readonly gravityEngineAccessToken?: string;
    readonly gravityEngineDebug?: boolean;
    readonly gravityEnginePayEventEnable?: boolean;
    readonly tencentUserActionId: number;
    readonly tencentSecretKey: string;
    readonly tencentDebug?: boolean;

    readonly login: (options: LoginOptions) => void;
    readonly uploadRoleInfo: (options: UploadRoleInfoOptions, callback?: Callback) => void;
    readonly createUserInfoButton: (options: CreateUserInfoButtonOptions) => UserInfoButton;
    readonly getUserInfo: (options: GetUserInfoOptions) => void;
    readonly pay: (options: PayOptions, settings?: PaySettings) => void;
    readonly createRewardedVideoAd: (options: CreateRewardedVideoAdOptions) => RewardedVideoAd;
    readonly openSurvey: (options: OpenSurveyOptions) => void;
    readonly openCustomerService: (options: OpenCustomerServiceOptions) => void;
    readonly createFeedbackButton: (options: CreateFeedbackButtonOptions) => FeedbackButton;
    readonly openChannelsUserProfile: (options: OpenChannelsUserProfileOptions) => void;
    readonly openChannelsEvent: (options: OpenChannelsEventOptions) => void;
    readonly openChannelsActivity: (options: OpenChannelsActivityOptions) => void;
    readonly openChannelsLive: (options: OpenChannelsLiveOptions) => void;
    readonly reserveChannelsLive: (options: ReserveChannelsLiveOptions) => void;
    readonly getChannelsLiveNoticeInfo: (options: GetChannelsLiveNoticeInfoOptions) => void;
    readonly getChannelsLiveInfo: (options: GetChannelsLiveInfoOptions) => void;
    readonly createGameClubButton: (options: CreateGameClubButtonOptions) => GameClubButton;
    readonly shareImageToGameClub: (options: ShareImageToGameClubOptions) => void;
    readonly shareCanvasToGameClub: (options: ShareCanvasToGameClubOptions) => void;
    readonly getGameClubData: (options: GetGameClubDataOptions) => void;
    readonly getGameRecorder: () => GameRecorder;
    readonly shareGameRecorderVideo: (options: ShareGameRecorderVideoOptions) => void;
    readonly createGameRecorderShareButton: (options: CreateGameRecorderShareButtonOptions) => GameRecorderShareButton;
    readonly setShare: (options: SetShareOptions) => void;
    readonly share: (options: ShareOptions) => void;
    readonly showShareImageMenu: (options: ShowShareImageMenuOptions) => void;
    readonly subscribeMessage: (options: SubscribeMessageOptions) => void;
    readonly subscribeSystemMessage: (options: SubscribeSystemMessageOptions) => void;
    readonly openSetting: (options: OpenSettingOptions) => void;
    readonly getSetting: (options: GetSettingOptions) => void;
    readonly getAccountId: () => string | number | void;
    readonly getOpenId: () => string | number | void;
    readonly isRegister: () => boolean;
    readonly showUpgradeMessage: (message?: string) => void;
    readonly modal: {
      loading: (message: string) => void;
      message: (message: string) => void;
      success: (message: string) => void;
      error: (message: string) => void;
      confirm: (options: ModalConfirmOptions) => void;
    };
    readonly trackEvent: (eventId: string, eventParams: TrackEventEventParams, callback?: Callback) => void;
    readonly analytics: {
      loaded: (callback?: Callback) => void;
      register: (callback?: Callback) => void;
      logged: (callback?: Callback) => void;
      role: (options: AnalyticsRoleOptions, callback?: Callback) => void;
      pay: (options: AnalyticsPayOptions, callback?: Callback) => void;
      ad: (options: AnalyticsAdOptions, callback?: Callback) => void;
      share: (options: AnalyticsShareOptions, callback?: Callback) => void;
      event: (options: AnalyticsEventOptions, callback?: Callback) => void;
      log: (options: AnalyticsLogOptions, callback?: Callback) => void;
    };
  }
}