/** One external entry is shared by login retries; internal restarts never create another entry. */ export default class WucaiEntry { static loginEntryId = ""; static pendingEntryId = ""; private static hidden = false; static captureLaunch(options: any): void { const query = options && options.query || {}; this.hidden = false; this.pendingEntryId = ""; this.loginEntryId = query.from === "wucai" ? String(query.wucai_entry_id || this.newEntryId()) : ""; } static onHide(): void { this.hidden = true; } static captureShow(options: any): boolean { const wasHidden = this.hidden; this.hidden = false; const query = options && options.query || {}; const scene = Number(options && options.scene) || 0; // Cold launch also emits onShow. A normal resume or our own restart is not a new jump. if (!wasHidden || query.from !== "wucai" || query.wucai_entry_id || (scene && scene !== 1037 && scene !== 1038)) return false; this.pendingEntryId = this.newEntryId(); return true; } static restartPath(entryId = ""): string { return entryId ? "?from=wucai&wucai_entry_id=" + encodeURIComponent(entryId) : "?wucai_resume=1"; } private static newEntryId(): string { return Date.now().toString(36) + "-" + Math.random().toString(36).slice(2); } }