import CSSettingsSDV3 from "../../../FormTable/CSSettingsV3";

export class LanguageManager {
	public static UseLanguageUrlStr: string = null;
	public static get DefaultLanguageFormId(): number { return 3; }
	public static get DefaultSourceIndex(): number { return this.DefaultLanguageFormId - 1; }
	public static get SourceIndex(): number { return this._useFormId - 1; }
	private static _useFormId: number = null;
	private static _msgTableRowName: string = null;
	private static _filePathStr: string = null;

	//=======================================================================================
	public static Init(): void {
		for (let i: number = 1; i < CSSettingsSDV3.Language.Lanuage.Count; i++) {
			let con = CSSettingsSDV3.Language.Lanuage[i];
			if (con.Type == this.UseLanguageUrlStr) {
				this._useFormId = con.Id;
				break;
			}
		}
		if (!this._useFormId) {
			this._useFormId = LanguageManager.Type.ZnTw;
			this.UseLanguageUrlStr = CSSettingsSDV3.Language.Lanuage[this._useFormId].Type;
		}
	}

	public static GetMsgId(): string {
		if (!this._msgTableRowName) {
			this._msgTableRowName = CSSettingsSDV3.Language?.Lanuage
				? CSSettingsSDV3.Language?.Lanuage[this._useFormId]?.Msg ?? 'MsgZnTw'
				: 'MsgZnTw';
		}
		return this._msgTableRowName;
	}

	public static TypePathStr(): string {
		if (!this._filePathStr) {
			this._filePathStr = CSSettingsSDV3.Language.Lanuage[this._useFormId].Path;
		}
		return this._filePathStr;
	}

}

export module LanguageManager {
	export enum Type {
		ZnCh = 0,
		En = 1,
		ZnTw = 2,
		Vi = 3,
		Th = 4,
		Ja = 5
	}

	export enum CommonUIType {
		MAIN_1 = 0,
		FREE_2 = 1,
		BIGWIN_3 = 2,
		JACKPOT_4 = 3,
		TOP_5 = 4,
	}
}