Greasy Fork is available in English.

pocketrose assistant

Intercepts and modifies pocketrose CGI requests

// ==UserScript==
// @name         pocketrose assistant
// @namespace    https://pocketrose.itsns.net.cn/
// @description  Intercepts and modifies pocketrose CGI requests
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @license      mit
// @author       xiaohaiz,fugue
// @version      4.2.15
// @grant        unsafeWindow
// @match        *://pocketrose.itsns.net.cn/*
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/echarts/5.4.2/echarts.min.js
// @run-at       document-start
// @unwrap
// ==/UserScript==

/******/ (() => { // webpackBootstrap
/******/ 	var __webpack_modules__ = ([
/* 0 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const PageInterceptorManager_1 = __importDefault(__webpack_require__(1));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const pageInterceptorManager = new PageInterceptorManager_1.default();
$(() => {
    var _a;
    const href = location.href;
    if (href.includes("pocketrose")) {
        let cgi = href;
        if (cgi.includes("/")) {
            cgi = StringUtils_1.default.substringAfterLast(location.href, "/");
        }
        if (cgi.includes("?")) {
            cgi = StringUtils_1.default.substringBefore(cgi, "?");
        }
        (_a = pageInterceptorManager.lookupInterceptor(cgi)) === null || _a === void 0 ? void 0 : _a.intercept();
    }
});


/***/ }),
/* 1 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PageInterceptorManager_interceptors;
const BattlePageInterceptor_1 = __importDefault(__webpack_require__(2));
const CastleBankPageInterceptor_1 = __importDefault(__webpack_require__(86));
const CastleDashboardPageInterceptor_1 = __importDefault(__webpack_require__(90));
const CastlePostHousePageInterceptor_1 = __importDefault(__webpack_require__(94));
const ConversationPageInterceptor_1 = __importDefault(__webpack_require__(108));
const CountryChangePageInterceptor_1 = __importDefault(__webpack_require__(110));
const CountryPalacePageInterceptor_1 = __importDefault(__webpack_require__(112));
const CountryTownStrengthenPageInterceptor_1 = __importDefault(__webpack_require__(114));
const LoginDashboardPageInterceptor_1 = __importDefault(__webpack_require__(116));
const MapDashboardPageInterceptor_1 = __importDefault(__webpack_require__(122));
const MetroDashboardPageInterceptor_1 = __importDefault(__webpack_require__(128));
const NationInformationPageInterceptor_1 = __importDefault(__webpack_require__(131));
const PersonalCareerManagementPageInterceptor_1 = __importDefault(__webpack_require__(133));
const PersonalEquipmentManagementPageInterceptor_1 = __importDefault(__webpack_require__(145));
const PersonalManualPageInterceptor_1 = __importDefault(__webpack_require__(167));
const PersonalPetManagementPageInterceptor_1 = __importDefault(__webpack_require__(169));
const PersonalProfilePageInterceptor_1 = __importDefault(__webpack_require__(180));
const PersonalSetupPageInterceptor_1 = __importDefault(__webpack_require__(187));
const PersonalStatisticsPageInterceptor_1 = __importDefault(__webpack_require__(231));
const PersonalStatusPageInterceptor_1 = __importDefault(__webpack_require__(249));
const PersonalTeamManagementPageInterceptor_1 = __importDefault(__webpack_require__(253));
const PersonalTeamPageInterceptor_1 = __importDefault(__webpack_require__(255));
const RoleInformationPageInterceptor_1 = __importDefault(__webpack_require__(261));
const TangDashboardPageInterceptor_1 = __importDefault(__webpack_require__(263));
const TownAccessoryHousePageInterceptor_1 = __importDefault(__webpack_require__(264));
const TownAdventureGuildPageInterceptor_1 = __importDefault(__webpack_require__(270));
const TownArmorHousePageInterceptor_1 = __importDefault(__webpack_require__(275));
const TownBankPageInterceptor_1 = __importDefault(__webpack_require__(280));
const TownDashboardPageInterceptor_1 = __importDefault(__webpack_require__(282));
const TownForgePageInterceptor_1 = __importDefault(__webpack_require__(304));
const TownGemHousePageInterceptor_1 = __importDefault(__webpack_require__(306));
const TownInformationPageInterceptor_1 = __importDefault(__webpack_require__(316));
const TownInnPageInterceptor_1 = __importDefault(__webpack_require__(318));
const TownItemHousePageInterceptor_1 = __importDefault(__webpack_require__(320));
const TownPetMapHousePageInterceptor_1 = __importDefault(__webpack_require__(325));
const TownPetRankHousePageInterceptor_1 = __importDefault(__webpack_require__(327));
const TownTaskHousePageInterceptor_1 = __importDefault(__webpack_require__(329));
const TownWeaponHousePageInterceptor_1 = __importDefault(__webpack_require__(331));
class PageInterceptorManager {
    constructor() {
        _PageInterceptorManager_interceptors.set(this, void 0);
        __classPrivateFieldSet(this, _PageInterceptorManager_interceptors, [
            new BattlePageInterceptor_1.default(),
            new CastleBankPageInterceptor_1.default(),
            new CastleDashboardPageInterceptor_1.default(),
            new CastlePostHousePageInterceptor_1.default(),
            new ConversationPageInterceptor_1.default(),
            new CountryChangePageInterceptor_1.default(),
            new CountryPalacePageInterceptor_1.default(),
            new CountryTownStrengthenPageInterceptor_1.default(),
            new LoginDashboardPageInterceptor_1.default(),
            new MapDashboardPageInterceptor_1.default(),
            new MetroDashboardPageInterceptor_1.default(),
            new NationInformationPageInterceptor_1.default(),
            new PersonalCareerManagementPageInterceptor_1.default(),
            new PersonalEquipmentManagementPageInterceptor_1.default(),
            new PersonalTeamManagementPageInterceptor_1.default(),
            new PersonalManualPageInterceptor_1.default(),
            new PersonalPetManagementPageInterceptor_1.default(),
            new PersonalProfilePageInterceptor_1.default(),
            new PersonalSetupPageInterceptor_1.default(),
            new PersonalStatisticsPageInterceptor_1.default(),
            new PersonalStatusPageInterceptor_1.default(),
            new PersonalTeamPageInterceptor_1.default(),
            new RoleInformationPageInterceptor_1.default(),
            new TangDashboardPageInterceptor_1.default(),
            new TownAccessoryHousePageInterceptor_1.default(),
            new TownAdventureGuildPageInterceptor_1.default(),
            new TownArmorHousePageInterceptor_1.default(),
            new TownBankPageInterceptor_1.default(),
            new TownDashboardPageInterceptor_1.default(),
            new TownForgePageInterceptor_1.default(),
            new TownGemHousePageInterceptor_1.default(),
            new TownInformationPageInterceptor_1.default(),
            new TownItemHousePageInterceptor_1.default(),
            new TownPetMapHousePageInterceptor_1.default(),
            new TownPetRankHousePageInterceptor_1.default(),
            new TownInnPageInterceptor_1.default(),
            new TownTaskHousePageInterceptor_1.default(),
            new TownWeaponHousePageInterceptor_1.default(),
        ], "f");
    }
    lookupInterceptor(cgi) {
        const pageText = $("body:first").text();
        for (const interceptor of __classPrivateFieldGet(this, _PageInterceptorManager_interceptors, "f")) {
            if (interceptor.accept(cgi, pageText)) {
                return interceptor;
            }
        }
        return null;
    }
}
_PageInterceptorManager_interceptors = new WeakMap();
module.exports = PageInterceptorManager;


/***/ }),
/* 2 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _BattlePageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const BattlePageProcessor_1 = __importDefault(__webpack_require__(12));
const PageProcessorContext_1 = __importDefault(__webpack_require__(85));
class BattlePageInterceptor {
    constructor() {
        _BattlePageInterceptor_processor.set(this, new BattlePageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "battle.cgi") {
            return pageText.includes("<< - 秘宝之岛 - >>") ||
                pageText.includes("<< - 初级之森 - >>") ||
                pageText.includes("<< - 中级之塔 - >>") ||
                pageText.includes("<< - 上级之洞窟 - >>") ||
                pageText.includes("<< - 十二神殿 - >>");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .load()
            .then(machine => {
            machine.start()
                .whenInTown(state => {
                var _a;
                const context = new PageProcessorContext_1.default()
                    .withTownId(state === null || state === void 0 ? void 0 : state.townId)
                    .withBattleCount((_a = state === null || state === void 0 ? void 0 : state.battleCount) === null || _a === void 0 ? void 0 : _a.toString());
                __classPrivateFieldGet(this, _BattlePageInterceptor_processor, "f").process(context);
            })
                .process();
        });
    }
}
_BattlePageInterceptor_processor = new WeakMap();
module.exports = BattlePageInterceptor;


/***/ }),
/* 3 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _RoleStateMachineManager_id;
const lodash_1 = __importDefault(__webpack_require__(4));
const Coordinate_1 = __importDefault(__webpack_require__(5));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const RoleState_1 = __importDefault(__webpack_require__(7));
const RoleStateMachine_1 = __importDefault(__webpack_require__(8));
const RoleStateStorage_1 = __importDefault(__webpack_require__(9));
class RoleStateMachineManager {
    constructor(id) {
        _RoleStateMachineManager_id.set(this, void 0);
        __classPrivateFieldSet(this, _RoleStateMachineManager_id, id, "f");
    }
    static create() {
        const id = $("input:hidden[name='id']:last").val();
        return new RoleStateMachineManager(id);
    }
    inTown() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    const townId = $("input:hidden[name='townid']:last").val();
                    const battleCount = lodash_1.default.parseInt($("input:hidden[name='ktotal']").val());
                    const document = new RoleState_1.default();
                    document.id = __classPrivateFieldGet(this, _RoleStateMachineManager_id, "f");
                    document.location = "TOWN";
                    document.townId = townId;
                    document.battleCount = battleCount;
                    RoleStateStorage_1.default.getInstance()
                        .write(document)
                        .then(() => {
                        resolve(document);
                    });
                });
            })();
        });
    }
    inCastle() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    const castleName = $("table:first")
                        .find("tr:first")
                        .next()
                        .find("td:first")
                        .find("table:first")
                        .find("tr:eq(2)")
                        .find("td:first")
                        .find("table:first")
                        .find("th:first")
                        .text().trim();
                    const document = new RoleState_1.default();
                    document.id = __classPrivateFieldGet(this, _RoleStateMachineManager_id, "f");
                    document.location = "CASTLE";
                    document.castleName = castleName;
                    RoleStateStorage_1.default.getInstance()
                        .write(document)
                        .then(() => {
                        resolve(document);
                    });
                });
            })();
        });
    }
    inMap() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    let s = $("td:contains('现在位置')")
                        .filter(function () {
                        return $(this).text().startsWith("\n      现在位置");
                    })
                        .text();
                    s = StringUtils_1.default.substringBetween(s, "现在位置(", ")");
                    const document = new RoleState_1.default();
                    document.id = __classPrivateFieldGet(this, _RoleStateMachineManager_id, "f");
                    document.location = "WILD";
                    document.coordinate = Coordinate_1.default.parse(s).asText();
                    RoleStateStorage_1.default.getInstance()
                        .write(document)
                        .then(() => {
                        resolve(document);
                    });
                });
            })();
        });
    }
    inMetro() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    let s = $("td:contains('现在位置')")
                        .filter(function () {
                        return $(this).text().startsWith("\n      现在位置");
                    })
                        .text();
                    s = StringUtils_1.default.substringBetween(s, "现在位置(", ")");
                    const document = new RoleState_1.default();
                    document.id = __classPrivateFieldGet(this, _RoleStateMachineManager_id, "f");
                    document.location = "METRO";
                    document.coordinate = Coordinate_1.default.parse(s).asText();
                    RoleStateStorage_1.default.getInstance()
                        .write(document)
                        .then(() => {
                        resolve(document);
                    });
                });
            })();
        });
    }
    inTang() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    let s = $("td:contains('现在位置')")
                        .filter(function () {
                        return $(this).text().startsWith("\n      现在位置");
                    })
                        .text();
                    s = StringUtils_1.default.substringBetween(s, "现在位置(", ")");
                    const document = new RoleState_1.default();
                    document.id = __classPrivateFieldGet(this, _RoleStateMachineManager_id, "f");
                    document.location = "TANG";
                    document.coordinate = Coordinate_1.default.parse(s).asText();
                    RoleStateStorage_1.default.getInstance()
                        .write(document)
                        .then(() => {
                        resolve(document);
                    });
                });
            })();
        });
    }
    load() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    RoleStateStorage_1.default.getInstance()
                        .load(__classPrivateFieldGet(this, _RoleStateMachineManager_id, "f"))
                        .then(state => {
                        const machine = new RoleStateMachine_1.default(state);
                        resolve(machine);
                    });
                });
            })();
        });
    }
}
_RoleStateMachineManager_id = new WeakMap();
module.exports = RoleStateMachineManager;


/***/ }),
/* 4 */
/***/ ((module) => {

"use strict";
module.exports = _;

/***/ }),
/* 5 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const StringUtils_1 = __importDefault(__webpack_require__(6));
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }
    get isAvailable() {
        return this.x >= 0 && this.x <= 15 &&
            this.y >= 0 && this.y <= 15;
    }
    asText() {
        return "(" + this.x + "," + this.y + ")";
    }
    equals(other) {
        return this.x === other.x && this.y === other.y;
    }
    static parse(text) {
        let s = text;
        if (s.includes("(") && s.includes(")")) {
            s = StringUtils_1.default.substringBetween(s, "(", ")");
        }
        const a = StringUtils_1.default.substringBefore(s, ",");
        const b = StringUtils_1.default.substringAfter(s, ",");
        const x = parseInt(a.trim());
        const y = parseInt(b.trim());
        return new Coordinate(x, y);
    }
}
module.exports = Coordinate;


/***/ }),
/* 6 */
/***/ ((module) => {

"use strict";

class StringUtils {
    static substringBefore(text, searchString) {
        const idx = text.indexOf(searchString);
        if (idx === -1) {
            return text;
        }
        return text.substring(0, idx);
    }
    static substringAfter(text, searchString) {
        const idx = text.indexOf(searchString);
        if (idx === -1) {
            return text;
        }
        return text.substring(idx + searchString.length);
    }
    static substringAfterLast(text, searchString) {
        const idx = text.lastIndexOf(searchString);
        if (idx === -1) {
            return text;
        }
        return text.substring(idx + searchString.length);
    }
    static substringBetween(text, leftString, rightString) {
        return StringUtils.substringBefore(StringUtils.substringAfter(text, leftString), rightString);
    }
    static substringBeforeSlash(text) {
        if (text.includes(" /")) {
            return StringUtils.substringBefore(text, " /");
        }
        if (text.includes("/")) {
            return StringUtils.substringBefore(text, "/");
        }
        return text;
    }
    static substringAfterSlash(text) {
        if (text.includes("/ ")) {
            return StringUtils.substringAfter(text, "/ ");
        }
        if (text.includes("/")) {
            return StringUtils.substringAfter(text, "/");
        }
        return text;
    }
    static toTitleString(s) {
        let title = "";
        for (let i = 0; i < s.length; i++) {
            title += s.charAt(i);
            if (i !== s.length - 1) {
                title += " ";
            }
        }
        return title;
    }
}
module.exports = StringUtils;


/***/ }),
/* 7 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Coordinate_1 = __importDefault(__webpack_require__(5));
class RoleState {
    asObject() {
        const data = {
            id: this.id
        };
        if (this.updateTime !== undefined) {
            // @ts-ignore
            data.updateTime = this.updateTime;
        }
        if (this.location !== undefined) {
            // @ts-ignore
            data.location = this.location;
        }
        if (this.townId !== undefined) {
            // @ts-ignore
            data.townId = this.townId;
        }
        if (this.battleCount !== undefined) {
            // @ts-ignore
            data.battleCount = this.battleCount;
        }
        if (this.castleName !== undefined) {
            // @ts-ignore
            data.castleName = this.castleName;
        }
        if (this.coordinate !== undefined) {
            // @ts-ignore
            data.coordinate = this.coordinate;
        }
        return data;
    }
    asCoordinate() {
        if (this.coordinate === undefined) {
            return undefined;
        }
        return Coordinate_1.default.parse(this.coordinate);
    }
}
module.exports = RoleState;


/***/ }),
/* 8 */
/***/ (function(module) {

"use strict";

var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _RoleStateMachine_state, _RoleStateMachine_inTownHandler, _RoleStateMachine_inCastleHandler, _RoleStateMachine_inMapHandler, _RoleStateMachine_inMetroHandler, _RoleStateMachine_inTangHandler;
class RoleStateMachine {
    constructor(state) {
        _RoleStateMachine_state.set(this, void 0);
        _RoleStateMachine_inTownHandler.set(this, void 0);
        _RoleStateMachine_inCastleHandler.set(this, void 0);
        _RoleStateMachine_inMapHandler.set(this, void 0);
        _RoleStateMachine_inMetroHandler.set(this, void 0);
        _RoleStateMachine_inTangHandler.set(this, void 0);
        __classPrivateFieldSet(this, _RoleStateMachine_state, state, "f");
    }
    start() {
        return this;
    }
    whenInTown(value) {
        __classPrivateFieldSet(this, _RoleStateMachine_inTownHandler, value, "f");
        return this;
    }
    whenInCastle(value) {
        __classPrivateFieldSet(this, _RoleStateMachine_inCastleHandler, value, "f");
        return this;
    }
    whenInMap(value) {
        __classPrivateFieldSet(this, _RoleStateMachine_inMapHandler, value, "f");
        return this;
    }
    whenInMetro(value) {
        __classPrivateFieldSet(this, _RoleStateMachine_inMetroHandler, value, "f");
        return this;
    }
    whenInTang(value) {
        __classPrivateFieldSet(this, _RoleStateMachine_inTangHandler, value, "f");
        return this;
    }
    process() {
        var _a, _b, _c, _d, _e;
        if (__classPrivateFieldGet(this, _RoleStateMachine_state, "f") === null) {
            // No RoleState loaded, do nothing and ignore
            return;
        }
        switch (__classPrivateFieldGet(this, _RoleStateMachine_state, "f").location) {
            case "TOWN":
                (_a = __classPrivateFieldGet(this, _RoleStateMachine_inTownHandler, "f")) === null || _a === void 0 ? void 0 : _a.call(this, __classPrivateFieldGet(this, _RoleStateMachine_state, "f"));
                break;
            case "CASTLE":
                (_b = __classPrivateFieldGet(this, _RoleStateMachine_inCastleHandler, "f")) === null || _b === void 0 ? void 0 : _b.call(this, __classPrivateFieldGet(this, _RoleStateMachine_state, "f"));
                break;
            case "WILD":
                (_c = __classPrivateFieldGet(this, _RoleStateMachine_inMapHandler, "f")) === null || _c === void 0 ? void 0 : _c.call(this, __classPrivateFieldGet(this, _RoleStateMachine_state, "f"));
                break;
            case "METRO":
                (_d = __classPrivateFieldGet(this, _RoleStateMachine_inMetroHandler, "f")) === null || _d === void 0 ? void 0 : _d.call(this, __classPrivateFieldGet(this, _RoleStateMachine_state, "f"));
                break;
            case "TANG":
                (_e = __classPrivateFieldGet(this, _RoleStateMachine_inTangHandler, "f")) === null || _e === void 0 ? void 0 : _e.call(this, __classPrivateFieldGet(this, _RoleStateMachine_state, "f"));
                break;
        }
    }
}
_RoleStateMachine_state = new WeakMap(), _RoleStateMachine_inTownHandler = new WeakMap(), _RoleStateMachine_inCastleHandler = new WeakMap(), _RoleStateMachine_inMapHandler = new WeakMap(), _RoleStateMachine_inMetroHandler = new WeakMap(), _RoleStateMachine_inTangHandler = new WeakMap();
module.exports = RoleStateMachine;


/***/ }),
/* 9 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const RoleState_1 = __importDefault(__webpack_require__(7));
class RoleStateStorage {
    static getInstance() {
        return instance;
    }
    load(id) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db
                        .transaction(["RoleState"], "readonly")
                        .objectStore("RoleState")
                        .get(id);
                    request.onerror = reject;
                    request.onsuccess = () => {
                        if (request.result) {
                            const data = new RoleState_1.default();
                            data.id = request.result.id;
                            data.updateTime = request.result.updateTime;
                            data.location = request.result.location;
                            data.townId = request.result.townId;
                            data.battleCount = request.result.battleCount;
                            data.castleName = request.result.castleName;
                            data.coordinate = request.result.coordinate;
                            resolve(data);
                        }
                        else {
                            resolve(null);
                        }
                    };
                });
            })();
        });
    }
    write(document) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const data = document.asObject();
                    // @ts-ignore
                    data.updateTime = new Date().getTime();
                    const request = db
                        .transaction(["RoleState"], "readwrite")
                        .objectStore("RoleState")
                        .put(data);
                    request.onerror = reject;
                    request.onsuccess = () => resolve();
                });
            })();
        });
    }
}
const instance = new RoleStateStorage();
module.exports = RoleStateStorage;


/***/ }),
/* 10 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Constants_1 = __importDefault(__webpack_require__(11));
class PocketDatabase {
}
PocketDatabase.connectDatabase = () => {
    return new Promise((resolve, reject) => {
        const request = window.indexedDB
            .open(Constants_1.default.DATABASE_NAME, Constants_1.default.DATABASE_VERSION);
        request.onerror = reject;
        request.onsuccess = () => {
            resolve(request.result);
        };
        request.onupgradeneeded = event => {
            // @ts-ignore
            const db = event.target.result;
            // ------------------------------------------------------------
            // RoleState
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("RoleState")) {
                db.createObjectStore("RoleState", {
                    keyPath: "id", autoIncrement: false
                });
            }
            // ------------------------------------------------------------
            // BattleRecord
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("BattleRecord")) {
                db.createObjectStore("BattleRecord", {
                    keyPath: "id", autoIncrement: false
                });
            }
            // ------------------------------------------------------------
            // BattleResult
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("BattleResult")) {
                const store = db.createObjectStore("BattleResult", {
                    keyPath: "id", autoIncrement: false
                });
                store.createIndex("roleId", "roleId", {
                    unique: false
                });
                store.createIndex("monster", "monster", {
                    unique: false
                });
            }
            // ------------------------------------------------------------
            // BattleLog
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("BattleLog")) {
                const store = db.createObjectStore("BattleLog", {
                    keyPath: "id", autoIncrement: false
                });
                store.createIndex("createTime", "createTime", {
                    unique: false
                });
                store.createIndex("roleId", "roleId", {
                    unique: false
                });
            }
            // ------------------------------------------------------------
            // BattleScene
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("BattleScene")) {
                db.createObjectStore("BattleScene", {
                    keyPath: "id", autoIncrement: false
                });
            }
            // ------------------------------------------------------------
            // RolePetMap
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("RolePetMap")) {
                db.createObjectStore("RolePetMap", {
                    keyPath: "id", autoIncrement: false
                });
            }
            // ------------------------------------------------------------
            // RolePetStatus
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("RolePetStatus")) {
                db.createObjectStore("RolePetStatus", {
                    keyPath: "id", autoIncrement: false
                });
            }
            // ------------------------------------------------------------
            // RoleEquipmentStatus
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("RoleEquipmentStatus")) {
                db.createObjectStore("RoleEquipmentStatus", {
                    keyPath: "id", autoIncrement: false
                });
            }
            // ------------------------------------------------------------
            // CareerChangeLog
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("CareerChangeLog")) {
                const store = db.createObjectStore("CareerChangeLog", {
                    keyPath: "id", autoIncrement: false
                });
                store.createIndex("roleId", "roleId", {
                    unique: false
                });
                store.createIndex("createTime", "createTime", {
                    unique: false
                });
                store.createIndex("career_1", "career_1", {
                    unique: false
                });
                store.createIndex("career_2", "career_2", {
                    unique: false
                });
            }
            if (db.objectStoreNames.contains("RoleCareerTransfer")) {
                db.deleteObjectStore("RoleCareerTransfer");
            }
            // ------------------------------------------------------------
            // PalaceTask
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("PalaceTask")) {
                db.createObjectStore("PalaceTask", {
                    keyPath: "id", autoIncrement: false
                });
            }
            // ------------------------------------------------------------
            // TaskGuide
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("TaskGuide")) {
                db.createObjectStore("TaskGuide", {
                    keyPath: "id", autoIncrement: false
                });
            }
            // ------------------------------------------------------------
            // LastLogin
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("LastLogin")) {
                db.createObjectStore("LastLogin", {
                    keyPath: "id", autoIncrement: false
                });
            }
            // ------------------------------------------------------------
            // BankRecord
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("BankRecord")) {
                const store = db.createObjectStore("BankRecord", {
                    keyPath: "id", autoIncrement: false
                });
                store.createIndex("recordDate", "recordDate", {
                    unique: false
                });
                store.createIndex("roleId", "roleId", {
                    unique: false
                });
            }
            // ------------------------------------------------------------
            // EquipmentConsecrateLog
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("EquipmentConsecrateLog")) {
                const store = db.createObjectStore("EquipmentConsecrateLog", {
                    keyPath: "id", autoIncrement: false
                });
                store.createIndex("createTime", "createTime", {
                    unique: false
                });
                store.createIndex("roleId", "roleId", {
                    unique: false
                });
            }
            // ------------------------------------------------------------
            // GemFuseLog
            // ------------------------------------------------------------
            if (!db.objectStoreNames.contains("GemFuseLog")) {
                const store = db.createObjectStore("GemFuseLog", {
                    keyPath: "id", autoIncrement: false
                });
                store.createIndex("createTime", "createTime", {
                    unique: false
                });
                store.createIndex("roleId", "roleId", {
                    unique: false
                });
            }
        };
    });
};
module.exports = PocketDatabase;


/***/ }),
/* 11 */
/***/ ((module) => {

"use strict";

class Constants {
}
Constants.POCKET_DOMAIN = "https://pocketrose.itsns.net.cn/pocketrose";
Constants.DATABASE_NAME = "pocketrose";
Constants.DATABASE_VERSION = 15;
Constants.MAX_TEAM_MEMBER_COUNT = 50;
Constants.MAX_NETWORK_FAILURE_RETRIES = 5;
module.exports = Constants;


/***/ }),
/* 12 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const BattleProcessor_1 = __importDefault(__webpack_require__(13));
const BattleReturnInterceptor_1 = __importDefault(__webpack_require__(38));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
const CommentBoard_1 = __importDefault(__webpack_require__(54));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class BattlePageProcessor extends PageProcessorCredentialSupport_1.default {
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            // 解析当前的战数
            const battleCount = parseBattleCount(context);
            if (battleCount === undefined) {
                return;
            }
            // 解析页面的反馈的数据
            const processor = new BattleProcessor_1.default(credential, PageUtils_1.default.currentPageHtml(), battleCount);
            yield processor.doProcess();
            // 开始正式处理战斗页面
            processBattle(credential, processor);
        });
    }
}
function processBattle(credential, processor) {
    // 删除原来所有的表单
    $("form").remove();
    // 在页面中添加隐藏的表格用于准备自定义的表单
    let html = "";
    html += "<tr style='display:none'>";
    html += "<td id='hidden-1'></td>";
    html += "</tr>";
    html += "<tr style='display:none'>";
    html += "<td id='hidden-2'></td>";
    html += "</tr>";
    html += "<tr style='display:none'>";
    html += "<td id='hidden-3'></td>";
    html += "</tr>";
    html += "<tr style='display:none'>";
    html += "<td id='hidden-4'></td>";
    html += "</tr>";
    html += "<tr style='display:none'>";
    html += "<td id='hidden-5'></td>";
    html += "</tr>";
    $("table:first")
        .find("tr:first")
        .after($(html));
    // 准备新的表单
    generateReturnForm(credential);
    generateDepositForm(credential);
    generateRepairForm(credential);
    generateLodgeForm(credential);
    // 准备新的按钮
    $("table:eq(5)")
        .find("td:first")
        .find("center:first")
        .find("h1:first")
        .next()
        .append($("" +
        "<div style='display:none' id='delim'></div>" +
        "<div style='padding-top:10px;padding-bottom:10px'><button role='button' id='returnButton'>返回城市</button></div>" +
        "<div style='padding-top:10px;padding-bottom:10px'><button role='button' id='depositButton'>返回银行</button></div>" +
        "<div style='padding-top:10px;padding-bottom:10px'><button role='button' id='repairButton'>返回修理</button></div>" +
        "<div style='padding-top:10px;padding-bottom:10px'><button role='button' id='lodgeButton'>返回住宿</button></div>" +
        ""));
    // 重新定义按钮的行为
    $("#returnButton").on("click", () => {
        $("#returnButton").prop("disabled", true);
        new BattleReturnInterceptor_1.default(credential, processor.obtainBattleCount)
            .doBeforeReturn()
            .then(() => {
            $("#returnTown").trigger("click");
        });
    });
    $("#depositButton").on("click", () => {
        $("#depositButton").prop("disabled", true);
        new BattleReturnInterceptor_1.default(credential, processor.obtainBattleCount)
            .doBeforeReturn()
            .then(() => {
            $("#deposit").trigger("click");
        });
    });
    $("#repairButton").on("click", () => {
        $("#repairButton").prop("disabled", true);
        new BattleReturnInterceptor_1.default(credential, processor.obtainBattleCount)
            .doBeforeReturn()
            .then(() => {
            $("#repair").trigger("click");
        });
    });
    $("#lodgeButton").on("click", () => {
        $("#lodgeButton").prop("disabled", true);
        new BattleReturnInterceptor_1.default(credential, processor.obtainBattleCount)
            .doBeforeReturn()
            .then(() => {
            $("#lodge").trigger("click");
        });
    });
    // 根据返回方式推荐,设置相关按钮的tab优先级
    const recommendation = processor.obtainRecommendation;
    switch (recommendation) {
        case "修":
            $("#repairButton").attr("tabindex", 1);
            break;
        case "宿":
            $("#lodgeButton").attr("tabindex", 1);
            break;
        case "存":
            $("#depositButton").attr("tabindex", 1);
            break;
        case "回":
            $("#returnButton").attr("tabindex", 1);
            break;
    }
    // 检查是否宠物有技能变化
    let petLearnSpell = false;
    $("#delim")
        .prev()
        .find("> b:first")
        .find("> font:first")
        .find("> font[color='red']")
        .each((idx, font) => {
        const ft = $(font).text();
        if (ft.includes("遗忘了技能") || ft.includes("学会了新技能")) {
            petLearnSpell = true;
            $(font).attr("color", "blue");
        }
    });
    // 入手情况的渲染
    renderHarvestMessage(processor.obtainPage);
    // 强制推荐,则删除其余所有的按钮
    $("button").each((idx, button) => {
        const tabindex = $(button).attr("tabindex");
        if (tabindex !== "1") {
            $(button).parent().remove();
        }
        else {
            $(button).trigger("focus");
        }
    });
    // 战斗页自动触底
    const buttonId = $("button[tabindex='1']").attr("id");
    PageUtils_1.default.scrollIntoView(buttonId);
}
function renderHarvestMessage(page) {
    if (page.harvestList.length === 0) {
        const prompt = SetupLoader_1.default.getNormalBattlePrompt();
        if (prompt["person"] !== undefined && prompt["person"] !== "NONE") {
            let person = prompt["person"];
            let imageHtml;
            if (person === "SELF") {
                imageHtml = PageUtils_1.default.findFirstRoleImageHtml();
            }
            else if (person === "RANDOM") {
                imageHtml = NpcLoader_1.default.randomPlayerImageHtml();
            }
            else {
                imageHtml = NpcLoader_1.default.getNpcImageHtml(person);
            }
            CommentBoard_1.default.createCommentBoard(imageHtml);
            $("#commentBoard")
                .css("text-align", "center")
                .css("background-color", "black")
                .css("color", "greenyellow");
            CommentBoard_1.default.writeMessage(lodash_1.default.escape(prompt["text"]));
        }
    }
    else {
        const prompt = SetupLoader_1.default.getBattleHarvestPrompt();
        if (prompt["person"] !== undefined && prompt["person"] !== "NONE") {
            let person = prompt["person"];
            let imageHtml;
            if (person === "SELF") {
                imageHtml = PageUtils_1.default.findFirstRoleImageHtml();
            }
            else if (person === "RANDOM") {
                imageHtml = NpcLoader_1.default.randomPlayerImageHtml();
            }
            else {
                imageHtml = NpcLoader_1.default.getNpcImageHtml(person);
            }
            CommentBoard_1.default.createCommentBoard(imageHtml);
            $("#commentBoard").css("text-align", "center");
            for (const it of page.harvestList) {
                CommentBoard_1.default.writeMessage("<b style='font-size:150%'>" + it + "</b><br>");
            }
            CommentBoard_1.default.writeMessage(lodash_1.default.escape(prompt["text"]));
        }
    }
}
function parseBattleCount(context) {
    if (context === undefined) {
        return undefined;
    }
    const s = context.get("battleCount");
    if (s === undefined) {
        return undefined;
    }
    return lodash_1.default.parseInt(s) + 1;
}
function generateReturnForm(credential) {
    const form = PageUtils_1.default.generateReturnTownForm(credential);
    $("#hidden-1").html(form);
}
function generateDepositForm(credential) {
    let form = "";
    // noinspection HtmlUnknownTarget
    form += "<form action='town.cgi' method='post'>";
    form += "<input type='hidden' name='id' value='" + credential.id + "'>";
    form += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
    form += "<input type='hidden' name='azukeru' value='all'>";
    form += "<input type='hidden' name='mode' value='BANK_SELL'>";
    form += "<input type='submit' id='deposit'>";
    form += "</form>";
    $("#hidden-2").html(form);
}
function generateRepairForm(credential) {
    let form = "";
    // noinspection HtmlUnknownTarget
    form += "<form action='town.cgi' method='post'>";
    form += "<input type='hidden' name='id' value='" + credential.id + "'>";
    form += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
    form += "<input type='hidden' name='arm_mode' value='all'>";
    form += "<input type='hidden' name='mode' value='MY_ARM2'>";
    form += "<input type='submit' id='repair'>";
    form += "</form>";
    $("#hidden-3").html(form);
}
function generateLodgeForm(credential) {
    let form = "";
    // noinspection HtmlUnknownTarget
    form += "<form action='town.cgi' method='post'>";
    form += "<input type='hidden' name='id' value='" + credential.id + "'>";
    form += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
    form += "<input type='hidden' name='mode' value='RECOVERY'>";
    form += "<input type='submit' id='lodge'>";
    form += "</form>";
    $("#hidden-4").html(form);
}
module.exports = BattlePageProcessor;


/***/ }),
/* 13 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _BattleProcessor_instances, _BattleProcessor_credential, _BattleProcessor_html, _BattleProcessor_battleCount, _BattleProcessor_internalProcess;
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const TreasureLoader_1 = __importDefault(__webpack_require__(16));
const PalaceTaskManager_1 = __importDefault(__webpack_require__(17));
const BattleLog_1 = __importDefault(__webpack_require__(25));
const BattleLogStorage_1 = __importDefault(__webpack_require__(29));
const BattlePageParser_1 = __importDefault(__webpack_require__(30));
const BattleRecommendation_1 = __importDefault(__webpack_require__(33));
const BattleRecord_1 = __importDefault(__webpack_require__(34));
const BattleRecordStorage_1 = __importDefault(__webpack_require__(35));
const BattleResultStorage_1 = __importDefault(__webpack_require__(36));
class BattleProcessor {
    constructor(credential, html, battleCount) {
        _BattleProcessor_instances.add(this);
        _BattleProcessor_credential.set(this, void 0);
        _BattleProcessor_html.set(this, void 0);
        _BattleProcessor_battleCount.set(this, void 0);
        __classPrivateFieldSet(this, _BattleProcessor_credential, credential, "f");
        __classPrivateFieldSet(this, _BattleProcessor_html, html, "f");
        __classPrivateFieldSet(this, _BattleProcessor_battleCount, battleCount, "f");
    }
    get obtainBattleCount() {
        return __classPrivateFieldGet(this, _BattleProcessor_battleCount, "f");
    }
    get obtainPage() {
        return this.page;
    }
    get obtainRecommendation() {
        return this.recommendation;
    }
    doProcess() {
        return __awaiter(this, void 0, void 0, function* () {
            // 解析战斗页面
            this.page = yield BattlePageParser_1.default.parse(__classPrivateFieldGet(this, _BattleProcessor_html, "f"));
            // 确认后续行为
            this.recommendation = yield BattleRecommendation_1.default.analysis(__classPrivateFieldGet(this, _BattleProcessor_battleCount, "f"), this.obtainPage);
            // 检查是否完成了皇宫任务
            if (this.page.monsterTask) {
                yield new PalaceTaskManager_1.default(__classPrivateFieldGet(this, _BattleProcessor_credential, "f")).completeMonsterTask();
            }
            yield __classPrivateFieldGet(this, _BattleProcessor_instances, "m", _BattleProcessor_internalProcess).call(this);
            return yield (() => {
                return new Promise(resolve => resolve());
            })();
        });
    }
}
_BattleProcessor_credential = new WeakMap(), _BattleProcessor_html = new WeakMap(), _BattleProcessor_battleCount = new WeakMap(), _BattleProcessor_instances = new WeakSet(), _BattleProcessor_internalProcess = function _BattleProcessor_internalProcess() {
    return __awaiter(this, void 0, void 0, function* () {
        // 写入战斗记录到DB
        const record = new BattleRecord_1.default();
        record.id = __classPrivateFieldGet(this, _BattleProcessor_credential, "f").id;
        record.html = this.obtainPage.reportHtml;
        yield BattleRecordStorage_1.default.getInstance().write(record);
        // 分析入手的结果
        let catchCount = undefined;
        let photoCount = undefined;
        let treasures = undefined;
        const monster = PageUtils_1.default.convertHtmlToText(this.page.monsterNameHtml);
        if (this.page.harvestList !== undefined && this.page.harvestList.length > 0) {
            for (const harvest of this.page.harvestList) {
                const it = PageUtils_1.default.convertHtmlToText(harvest);
                if (it.includes(monster + "入手")) {
                    if (catchCount === undefined) {
                        catchCount = 0;
                    }
                    catchCount++;
                }
                else if (it.includes("图鉴入手")) {
                    if (photoCount === undefined) {
                        photoCount = 0;
                    }
                    photoCount++;
                }
                else {
                    const treasureName = StringUtils_1.default.substringBefore(it, "入手");
                    const code = TreasureLoader_1.default.getCodeAsString(treasureName);
                    if (treasures === undefined) {
                        treasures = new Map();
                    }
                    const tc = treasures.get(code);
                    if (tc === undefined) {
                        treasures.set(code, 1);
                    }
                    else {
                        treasures.set(code, tc + 1);
                    }
                }
            }
        }
        // 战斗日志
        const log = new BattleLog_1.default();
        log.initialize();
        log.roleId = __classPrivateFieldGet(this, _BattleProcessor_credential, "f").id;
        log.monster = monster;
        log.result = this.page.battleResult;
        log.catch = catchCount;
        log.photo = photoCount;
        log.treasures = treasures;
        yield BattleLogStorage_1.default.getInstance().write(log); // 写入战斗日志
        yield BattleResultStorage_1.default.getInstance().replay(log); // 写入战斗结果
        return yield (() => {
            return new Promise(resolve => resolve());
        })();
    });
};
module.exports = BattleProcessor;


/***/ }),
/* 14 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Constants_1 = __importDefault(__webpack_require__(11));
const Credential_1 = __importDefault(__webpack_require__(15));
const StringUtils_1 = __importDefault(__webpack_require__(6));
class PageUtils {
    static currentPageHtml() {
        return document.documentElement.outerHTML;
    }
    /**
     * Remove unused hyper links from last div element.
     */
    static removeUnusedHyperLinks() {
        const div = $("div:last");
        div.find("a").attr("href", "javascript:void(0)");
        div.find("a").attr("tabIndex", "-1");
    }
    /**
     * Remove last google-analytics script
     */
    static removeGoogleAnalyticsScript() {
        $("script:last").remove();
        $("script")
            .filter(function () {
            // @ts-ignore
            const src = $(this).attr("src");
            return src !== undefined && src.includes("google-analytics");
        })
            .each(function (_idx, script) {
            script.remove();
        });
    }
    static currentCredential() {
        const id = $("input:hidden[name='id']:last").val();
        const pass = $("input:hidden[name='pass']:last").val();
        return new Credential_1.default(id.toString(), pass.toString());
    }
    static parseCredential(pageHtml) {
        const id = $(pageHtml).find("input:hidden[name='id']:last").val();
        const pass = $(pageHtml).find("input:hidden[name='pass']:last").val();
        return new Credential_1.default(id, pass);
    }
    static generateProgressBarHTML(ratio) {
        if (ratio === 0) {
            return "<img src='" + Constants_1.default.POCKET_DOMAIN + "/image/bg/bar2.gif'  height='7' width='50' alt=''>";
        }
        if (ratio === 1) {
            return "<img src='" + Constants_1.default.POCKET_DOMAIN + "/image/bg/bar1.gif'  height='7' width='50' alt=''>";
        }
        const w1 = Math.min(49, Math.ceil(50 * ratio));
        const w2 = 50 - w1;
        return "<img src='" + Constants_1.default.POCKET_DOMAIN + "/image/bg/bar1.gif'  height='7' width='" + w1 + "' alt=''>" +
            "<img src='" + Constants_1.default.POCKET_DOMAIN + "/image/bg/bar2.gif'  height='7' width='" + w2 + "' alt=''>";
    }
    static generateProgressBarWithPercentage(ratio) {
        if (ratio === 0) {
            return "<img src='" + Constants_1.default.POCKET_DOMAIN + "/image/bg/bar2.gif'  height='7' width='50' alt=''>&nbsp;0%";
        }
        if (ratio === 1) {
            return "<img src='" + Constants_1.default.POCKET_DOMAIN + "/image/bg/bar1.gif'  height='7' width='50' alt=''>&nbsp;100%";
        }
        const w1 = Math.min(49, Math.ceil(50 * ratio));
        const w2 = 50 - w1;
        return "<img src='" + Constants_1.default.POCKET_DOMAIN + "/image/bg/bar1.gif'  height='7' width='" + w1 + "' alt=''>" +
            "<img src='" + Constants_1.default.POCKET_DOMAIN + "/image/bg/bar2.gif'  height='7' width='" + w2 + "' alt=''>&nbsp;" + (ratio * 100).toFixed(2) + "%";
    }
    static findFirstRoleImageHtml() {
        let roleImage = "";
        $("img").each(function (_idx, img) {
            if (roleImage === "") {
                const src = $(img).attr("src");
                if (src !== undefined && src.startsWith(Constants_1.default.POCKET_DOMAIN + "/image/head/")) {
                    // 发现了用户头像
                    roleImage = src;
                }
            }
        });
        if (roleImage === "") {
            return null;
        }
        else {
            return "<img src='" + roleImage + "' width='64' height='64' id='roleImage' alt=''>";
        }
    }
    static isColorBlue(id) {
        const color = $("#" + id).css("color");
        return color.toString() === "rgb(0, 0, 255)";
    }
    static isColorGrey(id) {
        const color = $("#" + id).css("color");
        return color.toString() === "rgb(128, 128, 128)";
    }
    static generateInvisibleButton(backgroundColor) {
        return "<input type='button' " +
            "value='  ' " +
            "style='background-color:" + backgroundColor + ";border-width:0' " +
            "tabindex='-1'>";
    }
    static fixCurrentPageBrokenImages() {
        if ($("img").length === 0) {
            return;
        }
        $("img")
            .filter(function () {
            const src = $(this).attr("src");
            return src.startsWith("http://pocketrose.21sun.net:81/pocketrose") ||
                src.startsWith("http://pocketrose.21sun.net/pocketrose");
        })
            .each(function (_idx, img) {
            const src = $(img).attr("src");
            let s = src;
            if (src.includes("http://pocketrose.21sun.net:81/pocketrose")) {
                s = StringUtils_1.default.substringAfter(s, "http://pocketrose.21sun.net:81/pocketrose");
            }
            else if (src.includes("http://pocketrose.21sun.net/pocketrose")) {
                s = StringUtils_1.default.substringAfter(s, "http://pocketrose.21sun.net/pocketrose");
            }
            s = Constants_1.default.POCKET_DOMAIN + s;
            $(img).attr("src", s);
        });
    }
    static fixBrokenImageIfNecessary(s) {
        let t = s;
        if (t.includes("http://pocketrose.21sun.net:81/pocketrose")) {
            t = t.replace("http://pocketrose.21sun.net:81/pocketrose", Constants_1.default.POCKET_DOMAIN);
        }
        if (t.includes("http://pocketrose.21sun.net/pocketrose")) {
            t = t.replace("http://pocketrose.21sun.net/pocketrose", Constants_1.default.POCKET_DOMAIN);
        }
        return t;
    }
    static convertHtmlToText(html) {
        const s = "<td>" + html + "</td>";
        return $(s).text();
    }
    static scrollIntoView(elementId) {
        var _a;
        (_a = document.getElementById(elementId)) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
    }
    static generateReturnTownForm(credential) {
        let html = "";
        // noinspection HtmlUnknownTarget
        html += "<form action='status.cgi' method='post'>";
        html += "<input type='hidden' name='id' value='" + credential.id + "'>";
        html += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
        html += "<input type='hidden' name='mode' value='STATUS'>";
        html += "<input type='submit' id='returnTown'>";
        html += "</form>";
        return html;
    }
    static generateReturnMapForm(credential) {
        let html = "";
        // noinspection HtmlUnknownTarget
        html += "<form action='status.cgi' method='post'>";
        html += "<input type='hidden' name='id' value='" + credential.id + "'>";
        html += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
        html += "<input type='hidden' name='mode' value='STATUS'>";
        html += "<input type='submit' id='returnMap'>";
        html += "</form>";
        return html;
    }
    static generateReturnCastleForm(credential) {
        let html = "";
        // noinspection HtmlUnknownTarget
        html += "<form action='castlestatus.cgi' method='post'>";
        html += "<input type='hidden' name='id' value='" + credential.id + "'>";
        html += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
        html += "<input type='hidden' name='mode' value='CASTLESTATUS'>";
        html += "<input type='submit' id='returnCastle'>";
        html += "</form>";
        return html;
    }
    static generateEquipmentManagementForm(credential) {
        let html = "";
        // noinspection HtmlUnknownTarget
        html += "<form action='mydata.cgi' method='post'>";
        html += "<input type='hidden' name='id' value='" + credential.id + "'>";
        html += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
        html += "<input type='hidden' name='mode' value='USE_ITEM'>";
        html += "<input type='submit' id='openEquipmentManagement'>";
        html += "</form>";
        return html;
    }
    static generatePetManagementForm(credential) {
        let html = "";
        // noinspection HtmlUnknownTarget
        html += "<form action='mydata.cgi' method='post'>";
        html += "<input type='hidden' name='id' value='" + credential.id + "'>";
        html += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
        html += "<input type='hidden' name='mode' value='PETSTATUS'>";
        html += "<input type='submit' id='openPetManagement'>";
        html += "</form>";
        return html;
    }
    static generateCareerManagementForm(credential) {
        let html = "";
        // noinspection HtmlUnknownTarget
        html += "<form action='mydata.cgi' method='post'>";
        html += "<input type='hidden' name='id' value='" + credential.id + "'>";
        html += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
        html += "<input type='hidden' name='mode' value='CHANGE_OCCUPATION'>";
        html += "<input type='submit' id='openCareerManagement'>";
        html += "</form>";
        return html;
    }
    static generateFullRecoveryForm(credential) {
        let form = "";
        // noinspection HtmlUnknownTarget
        form += "<form action='town.cgi' method='post'>";
        form += "<input type='hidden' name='id' value='" + credential.id + "'>";
        form += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
        form += "<input type='hidden' name='mode' value='RECOVERY'>";
        form += "<input type='submit' id='fullRecovery'>";
        form += "</form>";
        return form;
    }
    static unbindEventBySpecifiedClass(className) {
        if ($("." + className).length > 0) {
            $("." + className)
                .off("click")
                .off("mouseenter")
                .off("mouseleave")
                .off("change");
        }
    }
    static onDoubleEscape(handler) {
        if (!handler)
            return;
        let count = 0;
        $(document).off("keydown.city").on("keydown.city", event => {
            const key = event.key;
            if (!key)
                return;
            if (key === "Escape") {
                count++;
                if (count === 2) {
                    count = 0;
                    handler();
                }
            }
            else {
                count = 0;
            }
        });
    }
}
module.exports = PageUtils;


/***/ }),
/* 15 */
/***/ ((module) => {

"use strict";

class Credential {
    constructor(id, pass) {
        this.id = id;
        this.pass = pass;
    }
    asRequest() {
        return { "id": this.id, "pass": this.pass };
    }
    asRequestMap() {
        const request = new Map();
        request.set("id", this.id);
        request.set("pass", this.pass);
        return request;
    }
}
module.exports = Credential;


/***/ }),
/* 16 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
class TreasureLoader {
    static getCode(treasureName) {
        // @ts-ignore
        const code = TREASURES[treasureName];
        return code === undefined ? 0 : code;
    }
    static getCodeAsString(treasureName) {
        let s = TreasureLoader.getCode(treasureName).toString();
        return lodash_1.default.padStart(s, 3, "0");
    }
    static allTreasureNames() {
        return Object.keys(TREASURES);
    }
    static isHint(code) {
        const cn = lodash_1.default.parseInt(code);
        return cn === 50;
    }
    static isTreasure(code) {
        const cn = lodash_1.default.parseInt(code);
        return cn >= 1 && cn <= 49;
    }
    static isUselessTreasure(code) {
        const cn = lodash_1.default.parseInt(code);
        return cn >= 32 && cn <= 49;
    }
    static isGoodPersonCard(code) {
        const cn = lodash_1.default.parseInt(code);
        return cn === 42;
    }
    static findTreasureName(code) {
        if (!code || code === "")
            return null;
        const cn = lodash_1.default.parseInt(code);
        for (const key of Object.keys(TREASURES)) {
            // @ts-ignore
            const c = TREASURES[key];
            if (c === cn) {
                return key;
            }
        }
        return null;
    }
}
// ----------------------------------------------------------------------------
// 顺序不能调整
// ----------------------------------------------------------------------------
const TREASURES = {
    "其他": 0,
    "神枪 永恒": 1,
    "霸邪斧 天煌": 2,
    "魔刀 哭杀": 3,
    "神器 苍穹": 4,
    "魔神器 幻空": 5,
    "真·圣剑 苍白的正义": 6,
    "双经斩": 7,
    "千幻碧水猿洛克奇斯": 8,
    "地纹玄甲龟斯特奥特斯": 9,
    "幽冥黑鳞蟒罗尼科斯": 10,
    "火睛混沌兽哈贝达": 11,
    "羽翅圣光虎阿基勒斯": 12,
    "金翅追日鹰庞塔雷斯": 13,
    "风翼三足凤纳托利斯": 14,
    "圣皇铠甲 天威": 15,
    "薄翼甲": 16,
    "魔盔 虚无": 17,
    "神冠 灵通": 18,
    "龙": 19,
    "王道仙人玉佩": 20,
    "王道倚天玉佩": 21,
    "王道军神玉佩": 22,
    "王道疾风玉佩": 23,
    "王道磐石玉佩": 24,
    "霸者仙人玉佩": 25,
    "霸者倚天玉佩": 26,
    "霸者军神玉佩": 27,
    "霸者疾风玉佩": 28,
    "霸者磐石玉佩": 29,
    "大师球": 30,
    "充满幸福憧憬的婚纱": 31,
    "30T砸屏专用槌": 32,
    "Armani西装": 33,
    "Hermès围巾": 34,
    "PS3": 35,
    "UGG": 36,
    "XBOX360": 37,
    "burberry风衣": 38,
    "ipad4": 39,
    "iphone5": 40,
    "去死去死团团服": 41,
    "好人卡": 42,
    "情人套装(女式)": 43,
    "情人套装(男式)": 44,
    "情侣表(女式)": 45,
    "情侣表(男式)": 46,
    "折凳": 47,
    "蟠龙花瓶": 48,
    "达尔文奖荣誉勋章": 49,
    "藏宝图": 50,
    "威力宝石": 51,
    "重量宝石": 52,
    "幸运宝石": 53,
};
module.exports = TreasureLoader;


/***/ }),
/* 17 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PalaceTaskManager_credential;
const lodash_1 = __importDefault(__webpack_require__(4));
const MonsterProfileLoader_1 = __importDefault(__webpack_require__(18));
const PalaceTaskStorage_1 = __importDefault(__webpack_require__(23));
class PalaceTaskManager {
    constructor(credential) {
        _PalaceTaskManager_credential.set(this, void 0);
        __classPrivateFieldSet(this, _PalaceTaskManager_credential, credential, "f");
    }
    updateMonsterTask(monsterName) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    PalaceTaskStorage_1.default.getInstance()
                        .updateMonsterTask(__classPrivateFieldGet(this, _PalaceTaskManager_credential, "f").id, monsterName)
                        .then(() => resolve());
                });
            })();
        });
    }
    completeMonsterTask() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    PalaceTaskStorage_1.default.getInstance()
                        .completeMonsterTask(__classPrivateFieldGet(this, _PalaceTaskManager_credential, "f").id)
                        .then(() => resolve());
                });
            })();
        });
    }
    finishMonsterTask() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    PalaceTaskStorage_1.default.getInstance()
                        .finishMonsterTask(__classPrivateFieldGet(this, _PalaceTaskManager_credential, "f").id)
                        .then(() => resolve());
                });
            })();
        });
    }
    monsterTaskHtml() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    PalaceTaskStorage_1.default.getInstance()
                        .load(__classPrivateFieldGet(this, _PalaceTaskManager_credential, "f").id)
                        .then(task => {
                        if (task === null) {
                            resolve("");
                            return;
                        }
                        if (task.monster === undefined) {
                            resolve("");
                            return;
                        }
                        const ss = lodash_1.default.split(task.monster, "/");
                        const a = ss[0];
                        const b = ss[1];
                        const profile = MonsterProfileLoader_1.default.load(a);
                        const s1 = profile.nameHtml;
                        const s2 = profile.locationText;
                        const s3 = b === "1" ? "<span style='color:blue'>已完成</span>" : "进行中";
                        const html = "杀怪任务:" + s1 + " (" + s2 + ") " + s3;
                        resolve(html);
                    });
                });
            })();
        });
    }
}
_PalaceTaskManager_credential = new WeakMap();
module.exports = PalaceTaskManager;


/***/ }),
/* 18 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const MonsterProfile_1 = __importDefault(__webpack_require__(19));
const MonsterSpellLoader_1 = __importDefault(__webpack_require__(22));
class MonsterProfileLoader {
    static load(code) {
        if (!code)
            return null;
        let c;
        if (lodash_1.default.isString(code)) {
            let extracted = extractCode(code);
            if (extracted) {
                c = lodash_1.default.parseInt(extracted);
            }
            else {
                // @ts-ignore
                if (isNaN(code)) {
                    c = null; // 不是数字,肯定不认识这个宠物
                }
                else {
                    c = lodash_1.default.parseInt(code); // 数字,按照全国编号来查询
                }
            }
        }
        else {
            c = code;
        }
        if (!c)
            return null;
        // @ts-ignore
        const s = MONSTERS[c];
        return s ? parse(c, s) : null;
    }
    static loadAll() {
        const ps = [];
        for (let c = 1; c <= 493; c++) {
            // @ts-ignore
            const s = MONSTERS[c];
            ps.push(parse(c, s));
        }
        return ps;
    }
    static findBySpellName(name) {
        const profiles = [];
        const id = MonsterSpellLoader_1.default.findBySpellName(name);
        if (!id)
            return profiles;
        MonsterProfileLoader.loadAll()
            .filter(it => it.spellIds)
            .forEach(it => {
            const ids = new Set();
            lodash_1.default.split(it.spellIds, ",").forEach(e => {
                ids.add(lodash_1.default.parseInt(e));
            });
            if (ids.has(id))
                profiles.push(it);
        });
        return profiles;
    }
}
const MONSTERS = {
    "1": "妙蛙种子/203/45/49/49/65/65/45/0/0/0/1/0/0/45/64/1/妙蛙种子/72,512,26,120,27,315,501,31,23,246,128,210,412,438,206,356,417,288,406",
    "2": "妙蛙草/204/60/62/63/80/80/60/0/0/0/1/1/0/45/141/2/妙蛙草/356,210,72,128,438,412,512,206,288,23,406,246,26,31,501,315,27,120,417",
    "3": "妙蛙花/205/80/82/83/100/100/80/0/0/0/2/1/0/45/208/3/妙蛙花/27,356,512,412,206,288,26,120,72,315,128,406,417,438,501,246,23,31,210",
    "4": "小火龙/206/39/52/43/60/50/65/0/0/0/0/0/1/45/65/1/小火龙/47,394,59,138,89,529,100,45,279,186,281,168,296,176,468,289,72,526,293",
    "5": "火恐龙/207/58/64/58/80/65/80/0/0/0/1/0/1/45/142/2/火恐龙/394,59,138,89,279,72,100,47,293,529,45,281,168,296,176,468,289,186,526",
    "6": "喷火龙/208/78/84/78/109/85/100/0/0/0/3/0/0/45/209/3/喷火龙/100,385,45,293,59,138,281,279,526,529,89,289,394,168,72,296,299,468,47,176,186",
    "7": "杰尼龟/209/44/48/65/50/64/43/0/0/1/0/0/0/45/66/1/杰尼龟/507,89,254,450,204,210,127,200,261,355,288,506,477,523,439,373,310,86,327",
    "8": "卡咪龟/210/59/63/80/65/80/58/0/0/1/0/1/0/45/143/2/卡咪龟/355,439,210,507,86,310,200,327,523,477,506,127,89,254,450,261,204,288,373",
    "9": "水箭龟/211/79/83/100/85/105/78/0/0/0/0/3/0/45/210/3/水箭龟/86,288,506,477,327,200,310,355,523,373,204,127,439,210,261,450,254,89,507",
    "10": "绿毛虫/212/45/30/35/20/20/45/1/0/0/0/0/0/255/53/1/绿毛虫/77,210",
    "11": "铁甲蛹/213/50/20/55/25/25/30/0/0/2/0/0/0/120/72/2/铁甲蛹/69",
    "12": "巴大蝴/214/60/45/50/80/80/70/0/0/0/2/1/0/45/160/3/巴大蝶/23,474,356,371,445,518,246,161,448,82",
    "13": "独角虫/215/40/35/30/20/20/50/0/0/0/0/0/1/255/52/1/独角虫/248,77",
    "14": "铁壳昆/216/45/25/50/25/25/35/0/0/2/0/0/0/120/71/2/铁壳蛹/69",
    "15": "大针蜂/217/65/80/40/45/80/75/0/2/0/1/0/0/45/159/3/大针蜂/413,509,131,458,176,62,416,6",
    "16": "波波/218/40/45/40/35/35/56/0/0/0/0/0/1/255/55/1/波波/469,439,21,458,517,509,384,385,82,317,445,184,210,335",
    "17": "比比鸟/219/63/60/55/50/50/71/0/0/0/0/0/2/120/113/2/比比鸟/82,469,439,21,458,517,509,385,335,317,445,184,210,384",
    "18": "比雕/220/83/80/75/70/70/91/0/0/0/0/0/3/45/172/3/大比鸟/335,384,509,517,458,21,439,184,469,82,385,210,445,317",
    "19": "小拉达/221/30/56/35/25/35/72/0/0/0/0/0/1/255/57/1/小拉达/282,413,210,204,317,158,416,89,162,420,436,5,64,444,78,458",
    "20": "拉达/222/55/81/60/50/70/97/0/0/0/0/0/2/127/116/2/拉达/317,436,210,204,168,458,158,413,420,282,5,89,64,444,78,162",
    "21": "烈雀/223/40/60/30/31/31/70/0/0/0/0/0/1/255/58/1/烈雀/509,168,41,359,173,317,21,472,72,303,458,88,6,343,517,1",
    "22": "尖嘴鸟/224/65/90/65/61/61/100/0/0/0/0/0/2/90/162/2/大嘴雀/6,343,88,517,472,72,173,458,359,1,317,168,41,21,509",
    "23": "阿柏蛇/225/35/60/44/40/54/55/0/1/0/0/0/0/255/62/1/阿柏蛇/248,389,100,182,523,392,458,388,275,436,89,49,343,57,424,169",
    "24": "阿柏怪/226/60/85/69/65/79/80/0/2/0/0/0/0/90/147/2/阿柏怪/523,57,49,100,169,458,392,389,89,343,182,248,388,424,436,275",
    "25": "皮卡丘/156/35/55/30/50/40/90/0/0/0/0/0/2/190/82/1/皮卡丘/154,26,444,30,24,353,524,204,481,437,54,182,151,322,72,320,509,317",
    "26": "雷丘/157/60/90/55/90/80/100/0/0/0/0/0/3/75/122/2/雷丘/444,437,154,524,353,30,54,320,24,204,317",
    "27": "穿山鼠/112/50/75/85/20/30/40/0/0/1/0/0/0/255/93/1/穿山鼠/144,356,64,507,138,468,346,47,347,200,186,66,184,248,45,268,5",
    "28": "穿山王/113/75/100/110/45/55/65/0/0/2/0/0/0/90/163/2/穿山王/5,200,47,468,138,507,64,356,144,184,347,66,346,248,45,268,186",
    "29": "尼多兰/227/55/47/52/40/40/41/1/0/0/0/0/0/235/59/1/尼多兰/448,7,64,206,416,369,232,100,186,89,72,90,204,248,146,5,301",
    "30": "尼多莉娜/228/70/62/67/55/55/56/2/0/0/0/0/0/120/117/2/尼多娜/90,64,206,416,369,232,448,100,5,146,89,248,7,72,186,204,301",
    "31": "尼多后/229/90/82/87/75/85/76/3/0/0/0/0/0/45/194/3/尼多后/58,64,206,416,369,232,248,7,204,186,100,426,448",
    "32": "尼多朗/230/46/57/40/40/40/50/0/1/0/0/0/0/235/60/1/尼多朗/135,64,232,448,369,446,100,161,343,301,88,416,7,248,435,146,6",
    "33": "尼多利诺/231/61/72/57/55/55/65/0/2/0/0/0/0/120/118/2/尼多力诺/146,135,161,446,369,448,232,64,100,6,435,248,7,416,88,343,301",
    "34": "尼多王/232/81/92/77/85/75/85/0/3/0/0/0/0/45/195/3/尼多王/232,248,161,446,369,448,100,333,222,7,416,88,64",
    "35": "皮皮/233/70/45/48/60/65/35/2/0/0/0/0/0/150/68/1/皮皮/239,26,178,353,205,227,394,442,437,147,126,67,154,240,524,72,193,224,66,446",
    "36": "皮可西/234/95/70/73/85/90/60/3/0/0/0/0/0/25/129/2/皮可西/394,240,154,67,205,353,446,147,239,437,224",
    "37": "六尾/153/38/41/40/50/65/65/0/0/0/0/0/1/190/63/1/六尾/293,204,397,453,232,169,200,22,21,299,165,356,281,132,166,511,83,289,317",
    "38": "九尾/154/73/76/75/81/100/100/0/0/0/0/1/1/75/178/2/九尾/200,22,299,397,453,232,169,184,21,356,166,317,289",
    "39": "胖丁/138/115/45/20/45/25/20/2/0/0/0/0/0/170/76/1/胖丁/510,18,437,21,353,292,232,403,58,341,276,154,193,66,240,239",
    "40": "胖可丁/139/140/70/45/75/50/45/3/0/0/0/0/0/50/109/2/胖可丁/232,437,21,353,292,66,18,240,154",
    "41": "超音蝠/063/40/45/35/30/40/55/0/0/0/0/0/1/255/54/1/超音蝠/385,49,438,82,445,21,458,317,523,448,522,173,89,335,166,81",
    "42": "大嘴蝠/064/75/80/70/65/75/90/0/0/0/0/0/2/90/171/2/大嘴蝠/166,335,82,445,21,458,317,523,49,438,81,385,89,448,173,522,436",
    "43": "走路草/088/45/50/55/75/65/30/0/0/0/1/0/0/255/78/1/走路草/501,406,206,27,181,200,31,47,275,23,518,246,79,227",
    "44": "臭臭花/089/60/65/70/85/75/40/0/0/0/2/0/0/120/132/2/臭臭花/406,47,31,181,200,246,206,27,275,23,518,501,79,227",
    "45": "霸王花/090/75/80/85/100/90/50/0/0/0/3/0/0/45/184/3/霸王花/332,206,27,200,31,406,181,518,409,79,47",
    "46": "派拉斯/235/35/70/55/45/55/25/0/1/0/0/0/0/190/70/1/派拉斯/200,436,458,501,371,186,518,246,64,418,45,315,11,41,81,26,409",
    "47": "派拉斯特/236/60/95/80/60/80/30/0/2/1/0/0/0/75/128/2/派拉斯特/41,436,64,371,200,26,458,409,518,501,315,45,246,186,81,11,418",
    "48": "毛球/237/60/55/50/40/55/45/0/0/0/0/1/0/190/75/1/毛球/203,371,518,81,246,161,448,439,210,232,372,436,11,17,23",
    "49": "末入蛾/238/70/65/60/90/75/90/0/0/0/1/0/1/75/138/2/摩鲁蛾/445,17,11,436,203,372,371,518,474,246,161,448,439,232,210,81,23",
    "50": "地鼠/239/10/55/25/35/45/95/0/0/0/0/0/1/255/81/1/地鼠/104,138,21,436,59,458,78,265,100,5,197,488,72,184,186,105,45",
    "51": "三地鼠/240/35/80/50/50/70/120/0/0/0/0/0/2/50/153/2/三地鼠/138,21,436,59,458,104,78,197,100,105,45,346,5,72,184,186,1,265,488",
    "52": "喵喵/241/40/45/35/40/40/90/0/0/0/0/0/1/255/69/1/喵喵/45,306,397,446,22,169,420,308,89,206,72,194,21,436,5,186",
    "53": "猫老大/242/65/70/60/65/65/115/0/0/0/0/0/2/90/148/2/猫老大/45,206,306,397,22,169,420,308,186,436,21,194,446,89,72,5",
    "54": "可达鸭/158/50/52/48/65/50/55/0/0/0/1/0/0/190/80/1/可达鸭/22,186,204,232,161,436,397,506,309,371,439,26,231,372,55,373,5",
    "55": "哥达鸭/159/80/82/78/95/80/85/0/0/0/2/0/0/75/174/2/哥达鸭/436,55,372,26,371,22,506,373,397,231,161,232,204,186,309,5,439",
    "56": "猴怪/243/40/80/35/35/45/70/0/1/0/0/0/0/190/74/1/猴怪/222,138,439,311,444,100,55,109,410,64,186,103,416,5,366,451,343,420,436",
    "57": "火爆猴/244/65/105/60/60/70/95/0/2/0/0/0/0/75/149/2/火暴猴/64,186,444,100,109,410,311,451,176,343,439,366,416,103,55,420,436,222,138,5",
    "58": "卡蒂狗/245/55/70/45/70/50/60/0/1/0/0/0/0/190/91/1/卡蒂狗/90,356,299,453,222,343,89,184,58,289,83,94,369,282,146,509,281",
    "59": "风速狗/246/90/110/80/100/80/95/0/2/0/0/0/0/75/213/2/风速狗/58,184,90,453,358,94,289,83,222,299,89,356",
    "60": "蚊香蝌蚪/247/40/50/40/40/40/90/0/0/0/0/0/1/255/77/1/蚊香蝌蚪/147,261,22,254,154,355,58,394,327,262,523,157,309,36,506",
    "61": "蚊香蛙/248/65/65/65/50/50/90/0/0/0/0/0/2/120/131/2/蚊香君/506,523,157,309,36,154,262,327,254,58,355,261,22,394,147",
    "62": "快泳蛙/249/90/85/95/70/90/70/0/0/3/0/0/0/45/185/3/蚊香泳士/157,36,309,523,262,327,102,154,22,254,147",
    "63": "凯西/039/25/20/15/105/55/90/0/0/0/1/0/0/200/73/1/凯西/524,40,482,280,235,344,183",
    "64": "勇吉拉/040/40/35/30/120/70/105/0/0/0/2/0/0/100/145/2/勇基拉/201,235,40,482,183,524,180,372,161,190,280,344,232,371,65,396,231",
    "65": "胡地/041/55/50/45/135/85/120/0/0/0/3/0/0/50/186/3/胡地/65,372,40,482,280,183,235,524,180,161,231,190,342,232,371,396,344",
    "66": "腕力/073/70/80/50/35/35/35/0/1/0/0/0/0/180/88/1/腕力/55,410,524,99,311,26,138,168,64,149,109,439,103,366,416,343,451,305,102",
    "67": "豪力/074/80/100/70/50/60/45/0/2/0/0/0/0/90/146/2/豪力/138,55,305,26,311,99,524,64,102,410,109,439,103,366,416,343,451,149,168",
    "68": "怪力/075/90/130/80/65/85/55/0/3/0/0/0/0/45/193/3/怪力/168,305,26,311,99,524,410,64,416,138,55,102,149,109,439,451,366,103,343",
    "69": "喇叭芽/250/50/75/35/70/30/40/0/1/0/0/0/0/255/84/1/喇叭芽/31,47,512,181,81,27,524,182,315,275,65,518,501,246,23,57,417",
    "70": "口朵花/251/65/90/50/85/45/55/0/2/0/0/0/0/120/151/2/口呆花/524,65,27,518,81,47,512,501,181,57,246,182,315,23,275,31,417",
    "71": "大食花/252/80/105/65/100/60/70/0/3/0/0/0/0/45/191/3/大食花/524,23,181,512,81,27,65,389,392,388,501,417,47,31",
    "72": "玛瑙水母/066/40/40/35/50/100/70/0/0/0/0/1/0/190/105/1/玛瑙水母/235,356,523,507,477,233,166,57,262,275,382,448,248,436,506",
    "73": "毒刺水母/067/80/70/65/80/120/100/0/0/0/0/2/0/60/205/2/毒刺水母/382,506,166,233,436,477,507,356,523,235,262,248,448,275,57",
    "74": "小拳石/057/40/80/100/30/30/20/0/0/1/0/0/0/255/86/1/小拳石/488,138,330,403,114,105,143,400,415,310,66,210,360,276",
    "75": "隆隆石/058/55/95/115/45/45/35/0/0/2/0/0/0/120/134/2/隆隆石/276,138,360,330,403,114,105,143,66,400,210,310,415,488",
    "76": "隆隆岩/059/80/110/130/55/65/45/0/0/3/0/0/0/45/177/3/隆隆岩/138,276,330,403,114,105,143,360,488,415,310,210,66,400",
    "77": "小火马/253/50/85/55/65/65/90/0/0/0/0/0/1/190/152/3/小火马/289,222,7,22,206,403,112,147,509,369,449,204,72,317,210,282,293",
    "78": "烈焰马/254/65/100/70/80/80/105/0/0/0/0/0/2/60/192/3/烈焰马/497,369,282,403,210,206,22,7,222,112,509,293,449,289,204,72,317,6",
    "79": "呆呆兽/255/90/65/65/40/40/15/1/0/0/0/0/0/190/99/1/呆呆兽/161,438,397,525,236,310,449,231,72,356,86,372,446,122,232,254,210,394",
    "80": "呆河马/256/95/75/110/100/80/30/0/0/2/0/0/0/75/164/2/呆壳兽/356,72,438,210,254,161,232,122,446,450,231,397,394,449,310,236,525,86,372",
    "81": "小磁怪/082/25/35/70/95/55/45/0/0/0/1/0/0/190/89/1/小磁怪/490,324,436,268,476,322,448,320,210,465,321",
    "82": "三合一磁怪/083/50/60/95/120/70/70/0/0/0/2/0/0/60/161/2/三合一磁怪/476,490,324,1,321,322,320,448,465,436,210",
    "83": "大葱鸭/257/52/65/55/58/62/60/0/1/0/0/0/0/45/94/1/大葱鸭/454,47,184,45,183,439,200,469,6,343,445,384,317,88,517,41,438,509",
    "84": "嘟嘟/092/35/85/45/35/35/75/0/1/0/0/0/0/190/96/1/嘟嘟/509,200,21,523,448,1,317,413,176,6,458,72,88,78,472",
    "85": "嘟嘟利/093/60/110/70/60/60/100/0/2/0/0/0/0/45/158/2/嘟嘟利/78,413,200,21,523,448,317,472,1,6,458,72,88,176,509",
    "86": "小海狮/258/65/45/55/45/70/45/0/0/0/0/1/0/190/100/1/小海狮/524,135,232,292,401,356,182,369,341,233,72,122,308,35,39,37",
    "87": "白海狮/259/90/70/80/70/95/70/0/0/0/0/2/0/75/176/2/白海狮/381,182,135,232,292,401,356,308,369,35,341,72,17,233,37,122,39,524",
    "88": "臭泥/106/80/80/50/40/50/25/1/0/0/0/0/0/190/90/1/臭泥/523,522,401,132,219,274,114,438,245,436,67,264,232,69,193,267,4",
    "89": "臭臭泥/107/105/105/75/65/100/50/1/1/0/0/0/0/75/157/2/臭臭泥/4,523,114,401,267,438,522,219,245,132,193,69,232,264,67,436,274",
    "90": "大舌贝/260/30/65/100/45/25/40/0/0/1/0/0/0/190/97/1/大舌贝/443,262,448,369,233,127,343,210,39,35,436,507,235,450",
    "91": "铁甲贝/261/50/95/180/85/45/70/0/0/2/0/0/0/60/203/2/刺甲贝/507,436,235,369,262,134,209,127,233,448,450,35",
    "92": "鬼斯/262/30/35/30/100/35/80/0/0/0/1/0/0/190/95/1/鬼斯/166,221,22,401,169,522,438,519,241,499,114,170,376,292,523,173,511,165",
    "93": "鬼斯通/263/45/50/45/115/55/95/0/0/0/2/0/0/90/126/2/鬼斯通/173,241,165,114,511,523,292,170,221,169,22,376,401,499,522,438,519,166,219",
    "94": "耿鬼/264/60/65/60/130/75/110/0/0/0/3/0/0/45/190/3/耿鬼/219,499,401,169,522,438,519,22,511,166,165,173,523,292,376,170,241,221,114",
    "95": "大岩蛇/265/35/45/160/30/45/70/0/0/1/0/0/0/45/108/3/大岩蛇/53,182,200,114,360,403,346,467,347,527,176,415,138,436,210,69",
    "96": "素利普/266/60/48/45/43/90/42/0/0/0/0/1/0/190/102/1/催眠貘/420,122,482,280,201,306,397,372,40,311,235,245,161,232,22,193,231",
    "97": "素利柏/267/85/73/70/73/115/67/0/0/0/0/2/0/75/165/2/引梦貘人/420,40,482,280,201,306,235,397,372,245,311,193,122,170,161,232,22,231",
    "98": "大钳蟹/268/30/105/90/25/25/50/0/1/0/0/0/0/225/115/1/大钳蟹/69,265,449,123,127,446,115,50,343,261,523,200,183,47,197,182",
    "99": "巨钳蟹/269/55/130/115/50/50/75/0/2/0/0/0/0/60/206/2/巨钳蟹/343,183,115,127,50,449,265,69,47,123,261,200,182,446,523,197,468",
    "100": "雷电球/084/40/30/50/55/55/100/0/0/0/0/0/1/190/103/1/霹雳电球/321,114,268,26,400,477,490,436,210,24,276",
    "101": "顽皮蛋/085/60/50/70/80/80/140/0/0/0/0/0/2/60/150/2/顽皮雷弹/400,477,114,268,26,276,321,490,436,24,210",
    "102": "蛋蛋/270/60/40/80/60/45/40/0/0/1/0/0/0/90/98/1/蛋蛋/65,189,22,128,161,518,246,23,120,27,59,397,181,438,78,227",
    "103": "椰蛋树/271/95/95/85/125/65/55/0/0/0/2/0/0/45/212/2/椰蛋树/227,425,449,438,181,397,65,27,161,22,189,59",
    "104": "可拉可拉/272/50/50/95/40/50/35/0/0/1/0/0/0/190/87/1/卡拉卡拉/503,502,292,47,138,343,204,416,41,59,222,122,504,436,72,288,176,394,403",
    "105": "嘎拉嘎拉/273/60/80/110/50/80/45/0/0/2/0/0/0/75/124/2/嘎啦嘎啦/416,72,204,502,122,343,503,176,41,288,138,403,59,436,504,292,222,47,394",
    "106": "沙瓦郎/274/50/120/53/35/110/87/0/2/0/0/0/0/45/139/1/飞腿郎/507,157,496,489,444,329,159,439,416,313,146,99,109,7,311,498",
    "107": "艾比郎/275/50/105/79/35/110/76/0/0/0/0/2/0/45/140/2/快拳郎/280,157,146,489,496,507,64,330,118,40,458,509,456,109,432",
    "108": "大舌头/276/90/55/75/60/75/30/2/0/0/0/0/0/45/127/1/大舌头/236,373,183,66,448,401,57,232,224,436,525,394,488,58,438,410,449,182",
    "109": "瓦斯弹/108/40/65/95/60/45/35/0/0/1/0/0/0/190/114/3/瓦斯弹/523,4,511,44,241,371,376,436,210,245,297,400,264,296,114",
    "110": "双弹瓦斯/109/65/90/120/85/70/60/0/0/2/0/0/0/60/173/3/双弹瓦斯/114,241,371,376,436,4,44,210,523,245,297,400,264,296,511",
    "111": "铁甲犀牛/169/80/85/95/30/30/25/0/0/1/0/0/0/120/135/3/独角犀牛/138,144,438,47,64,444,90,333,449,488,6,143,204,435,135,369,105,168",
    "112": "铁甲暴龙/170/105/130/120/45/45/40/0/2/0/0/0/0/60/204/3/钻角犀兽/105,6,144,438,47,488,64,333,90,204,444,435,369,449,138,168,143,135",
    "113": "吉利蛋/277/250/5/5/35/105/50/2/0/0/0/0/0/30/255/1/吉利蛋/66,193,224,175,205,353,409,26,72,425,240,67,154,314,373,403,204",
    "114": "蔓藤怪/278/65/55/115/100/40/60/0/0/1/0/0/0/45/166/1/蔓藤怪/65,23,382,181,315,398,79,446,332,161,200,182,518,53,417,246,128,198",
    "115": "袋龙/279/105/95/80/40/80/90/2/0/0/0/0/0/45/175/1/袋兽/356,176,330,439,159,232,89,416,308,492,444,64,343,456,144,224,204,449",
    "116": "墨海马/184/30/40/70/70/25/60/0/0/0/1/0/0/225/83/1/墨海马/232,527,526,254,343,261,296,233,530,509,506,529,108,200,147",
    "117": "海刺龙/185/55/65/95/95/45/85/0/0/1/1/0/0/75/155/2/海刺龙/254,530,261,527,343,509,526,232,108,233,200,296,147,529,506",
    "118": "角金鱼/050/45/67/60/35/50/63/0/1/0/0/0/0/225/111/1/角金鱼/305,103,444,21,432,439,146,64,109,159,183,55,184,394,416,368,149,308,82,410,210",
    "119": "金鱼王/051/80/92/65/65/80/68/0/2/0/0/0/0/60/170/2/金鱼王/135,204,310,236,506,523,371,333,509,6,200,435,448,88,309,211",
    "120": "海星星/143/30/45/55/70/55/85/0/0/0/0/0/1/225/106/1/海星星/262,254,506,126,26,67,16,210,507,396,69,268",
    "121": "宝石海星/144/60/75/85/100/85/115/0/0/0/0/0/2/60/207/2/宝石海星/396,268,507,254,166",
    "122": "吸盘魔偶/280/40/45/65/100/120/90/0/0/0/0/2/0/45/136/1/魔墙人偶/524,372,201,180,460,371,308,397,239,22,203,512,161,231,235,65,224,356,311,154,26",
    "123": "飞天螳螂/281/70/110/80/55/80/105/0/1/0/0/0/0/45/187/1/飞天螳螂/454,509,444,26,159,474,203,356,64,480,343,45,151,317,416,458,41,385,47",
    "124": "迷唇姐/282/65/50/35/115/95/95/0/0/0/2/0/0/45/137/2/迷唇姐/397,380,58,437,193,40,223,292,308,18,522,154,172,311,401",
    "125": "电击兽/283/65/83/57/95/85/105/0/0/0/0/0/2/45/156/1/电击兽/55,280,311,99,235,366,481,54,436,268,26,482,343,317,40",
    "126": "鸭嘴火龙/284/65/95/57/100/85/93/0/0/0/2/0/0/45/167/1/鸭嘴火兽/296,166,289,343,297,280,281,217,482,112,366,330,235,436,55",
    "127": "大甲/167/65/125/100/55/70/85/0/2/0/0/0/0/45/200/1/凯罗斯/102,21,41,200,47,50,109,69,103,53,416,123,313,6",
    "128": "肯泰罗/285/75/100/95/40/70/110/0/1/0/0/0/1/45/211/1/肯泰罗/435,210,204,176,168,420,341,222,369,458",
    "129": "鲤鱼王/052/20/10/55/15/20/80/0/0/0/0/0/1/255/20/3/鲤鱼王/147,200,210",
    "130": "暴鲤龙/053/95/125/79/60/100/81/0/2/0/0/0/0/45/214/3/暴鲤龙/529,355,526,506,348,343,89,222,530",
    "131": "拉普拉斯/286/130/85/80/85/95/60/2/0/0/0/0/0/45/219/1/拉普拉斯/166,135,254,72,240,58,236,292,39,355,356,506,381,439,224,198,373,529,438,327",
    "132": "百变怪/287/48/48/48/48/48/48/1/0/0/0/0/0/35/61/1/百变怪/70",
    "133": "伊布/288/55/55/50/45/65/55/0/0/0/0/1/0/45/92/1/伊布/210,204,72,317,89,203,184,206,146,200,159,438,198,437,369",
    "134": "水精灵/289/130/65/60/110/95/65/2/0/0/0/0/0/45/196/2/水伊布/210,204,146,184,254,317,89,437,523,274,506,206,200,159,438,198,233",
    "135": "雷精灵/290/65/65/60/110/95/130/0/0/0/0/0/2/45/197/3/雷伊布/131,322,210,204,146,184,320,317,509,7,437,481,206,200,159,438,198",
    "136": "火精灵/291/65/130/60/95/110/65/0/2/0/0/0/0/45/198/3/火伊布/317,281,184,204,146,289,89,297,210,343",
    "137": "3D龙/292/65/60/70/85/75/40/0/0/0/1/0/0/45/130/3/多边兽/210,136,68,509,371,396,324,460,1,476,137",
    "138": "菊石兽/293/35/40/100/90/55/35/0/0/1/0/0/0/45/120/1/菊石兽/523,59,382,450,89,254,265,343,209,198,506,262,233,182,448,138,127",
    "139": "多刺菊石兽/294/70/60/125/115/70/55/0/0/2/0/0/0/45/199/2/多刺菊石兽/209,265,198,382,450,89,254,127,134,138,59,506,262,233,182,448,523,343",
    "140": "化石盔/295/30/80/90/55/45/55/0/0/1/0/0/0/45/119/3/化石盔/507,159,197,69,79,343,265,200,186,465,332,59,262,233,166,183,184",
    "141": "镰刀盔/296/60/115/105/65/70/80/0/2/0/0/0/0/45/201/3/镰刀盔/183,186,465,69,79,454,343,265,184,166,45,332,59,262,233,507,197,200,159",
    "142": "化石翼龙/297/80/105/65/60/75/130/0/0/0/0/0/2/45/202/1/化石翼龙/168,438,527,469,439,458,82,369,59,448,89,509,385,348",
    "143": "卡比兽/298/160/110/65/65/110/30/2/0/0/0/0/0/25/154/1/卡比兽/224,210,525,379,66,276,403,348,401,206,360,446,394,122,104,341,58,236,438,86",
    "144": "冷冻鸟/299/90/85/100/95/125/85/0/0/0/0/3/0/3/215/1/急冻鸟/381,223,65,39,157,509,327,380,445",
    "145": "闪电鸟/300/90/90/85/125/90/100/0/0/0/3/0/0/3/216/1/闪电鸟/24,26,472,432,509,322,320,88,481",
    "146": "火焰鸟/301/90/100/90/125/85/90/0/0/0/3/0/0/3/217/1/火焰鸟/289,299,356,281,159,293,385,509",
    "147": "迷你龙/302/41/64/45/50/50/50/0/1/0/0/0/0/45/67/1/迷你龙/348,529,57,343,322,530,526,182,509,356,279,26,523,448,327,527",
    "148": "哈克龙/303/61/84/65/70/70/70/0/2/0/0/0/0/45/144/2/哈克龙/348,322,530,526,182,509,57,279,343,26,327,523,448,527,529,356",
    "149": "快龙/304/91/134/95/100/100/80/0/3/0/0/0/0/45/218/3/快龙/448,57,356,385,343,279,529,348,26,327,523,322,182,526,509,527,530",
    "150": "超梦/305/106/110/90/154/90/130/0/0/0/3/0/0/3/220/1/超梦/356,232,235,161,397,268,327,372,396,231,446",
    "151": "梦幻/306/100/100/100/100/100/100/3/0/0/0/0/0/45/64/1/梦幻/205,372,330,70,193,59",
    "152": "奇科莉塔/307/45/49/65/49/65/45/0/0/0/0/1/0/45/64/1/菊草叶/26,417,31,65,246,27,58,120,72,412,356,128,64,59,200,398,181,210",
    "153": "小花兽/308/60/62/80/63/80/60/0/0/1/0/1/0/45/141/2/月桂叶/412,58,27,181,200,59,64,128,417,356,26,246,65,31,72,210,398,120",
    "154": "巨花兽/309/80/82/100/83/100/80/0/0/1/0/2/0/45/208/3/大竺葵/200,412,58,210,72,31,65,246,181,27,398,26,356,120,417,128,64,59",
    "155": "火岚兽/310/39/52/43/60/50/65/0/0/0/0/0/1/45/65/1/火球鼠/439,144,343,296,289,317,282,268,281,5,453,444,222,210,379",
    "156": "熔岩兽/311/58/64/58/80/65/80/0/0/0/1/0/1/45/142/2/火岩鼠/343,296,289,317,282,210,144,281,5,444,222,439,379,453,268",
    "157": "爆风兽/312/78/84/78/109/85/100/0/0/0/3/0/0/45/209/3/火暴兽/268,282,210,343,296,289,5,317,144,281,444,222,439,379,453",
    "158": "诺可鳄/313/50/65/64/44/48/43/0/1/0/0/0/0/45/66/1/小锯鳄/506,45,222,310,138,59,309,436,528,168,89,254,176,343,186,90",
    "159": "艾莉鳄/314/65/80/80/59/63/58/0/1/1/0/0/0/45/143/2/蓝鳄/90,343,176,254,89,168,45,528,506,309,222,59,138,310,186,436",
    "160": "大丹鳄/315/85/105/100/79/83/78/0/2/1/0/0/0/45/210/3/大力鳄/186,528,343,176,254,89,168,310,309,436,506,90,222,59,138,45",
    "161": "立尾鼠/316/35/46/34/35/45/20/0/1/0/0/0/0/255/57/3/尾立/403,186,66,317,5,146,182,442,306,446,458,45,416,444,224,180,341",
    "162": "大立尾鼠/317/85/76/64/45/55/90/0/0/0/0/0/2/90/116/3/大尾立/442,306,182,186,66,317,5,446,146,180,341,403,458,45,416,444,224",
    "163": "呵呵鹰/318/60/30/30/36/56/50/1/0/0/0/0/0/255/58/1/咕咕/369,161,499,359,82,385,21,517,384,65,22,88,439,72,210,448",
    "164": "夜鹰/319/100/50/50/76/96/70/2/0/0/0/0/0/90/162/2/猫头夜鹰/384,161,439,88,22,65,210,369,72,499,517,448,21,385,82,359",
    "165": "金龟虫/320/40/20/30/40/80/55/0/0/0/0/1/0/255/54/1/芭瓢虫/456,474,448,26,356,65,203,268,509,403,371,210,30",
    "166": "金龟战士/321/55/35/50/55/110/85/0/0/0/0/2/0/90/134/2/安瓢虫/448,474,30,371,403,509,268,203,456,26,356,65,210",
    "167": "独角蛛/322/40/60/40/40/40/30/0/1/0/0/0/0/255/54/3/圆丝蛛/371,428,248,77,168,382,519,490,5,17,509,372,232,203,458,81",
    "168": "大独角蛛/323/70/90/70/60/60/40/0/2/0/0/0/0/90/134/3/阿利多斯/382,428,248,77,168,519,5,17,509,372,371,232,490,203,458,81",
    "169": "双翼蝙蝠/065/85/90/80/70/80/130/0/0/0/0/0/3/90/204/3/叉字蝠/522,438,49,523,317,458,21,82,173,335,445,81,89,166,436,448,385",
    "170": "双灯鱼/181/75/38/38/56/56/67/1/0/0/0/0/0/190/90/1/灯笼鱼/322,446,436,200,24,506,369,166,321,254,448,261",
    "171": "大双灯鱼/182/125/58/58/76/76/67/2/0/0/0/0/0/75/156/2/电灯怪/254,261,322,448,369,200,166,321,24,436,446,506",
    "172": "皮丘/155/20/40/15/35/35/60/0/0/0/0/0/1/190/42/3/皮丘/444,24,437,154,524,30,116,322,204,206,320,353",
    "173": "皮/324/50/25/28/45/55/15/0/0/0/0/1/0/150/37/3/皮宝宝/239,205,224,206,524,240,116,353,193,446,394,147,437,512",
    "174": "布布林/137/90/30/15/40/20/15/1/0/0/0/0/0/170/39/3/宝宝丁/193,18,437,21,353,116,66,206,240,292",
    "175": "波克比/325/35/20/65/40/65/20/0/0/0/0/1/0/190/74/1/波克比/439,72,206,205,224,231,442,116,86,524,397,88,437,356,403,203,353,517,59",
    "176": "飞翼兽/326/55/40/85/80/105/40/0/0/0/0/2/0/75/114/2/波克基古/353,88,397,224,439,517,524,512,206,116,442,203,205,231,86,59,437,356,72,403",
    "177": "玩偶鸟/162/40/50/45/70/45/70/0/0/0/1/0/0/190/73/3/天然雀/472,21,88,343,519,344,437,231,166,523,317,397,384,373,372,469",
    "178": "预言鸟/163/65/75/70/95/70/95/0/0/0/1/0/1/75/171/3/天然鸟/523,373,384,397,469,21,472,372,231,437,344,519,343,88,166,317",
    "179": "电电羊/327/55/40/40/65/45/35/0/0/0/1/0/0/235/59/1/咩利羊/436,24,65,356,58,369,481,26,237,322,320,72,210,94",
    "180": "羊咩咩/328/70/55/55/80/60/45/0/0/0/2/0/0/120/117/2/茸茸羊/322,24,94,65,436,356,58,369,481,237,320,72,210,26",
    "181": "电龙/329/90/75/75/115/90/55/0/0/0/3/0/0/45/194/3/电龙/322,94,320,72,210,482,237,26,481,369,58,356,65,24,436",
    "182": "美丽花/091/75/80/85/90/100/50/0/0/0/0/3/0/45/184/3/美丽花/47,181,206,27,200,31,120,406,512,518,79,501",
    "183": "水鼠/055/70/20/50/20/50/40/2/0/0/0/0/0/190/58/1/玛力露/373,182,448,292,394,231,446,353,26,224,262,198,240,204,210,276,66,403,355,506,524,254",
    "184": "大水鼠/056/100/50/80/50/80/50/3/0/0/0/0/0/75/153/2/玛力露丽/182,198,373,224,26,353,446,231,394,448,240,254,292,204,524,262,66,276,403,355,506,210",
    "185": "骗人树/330/70/100/115/30/65/30/0/0/2/0/0/0/65/135/3/树才怪/415,400,403,182,21,360,138,451,200,239",
    "186": "蚊香蛙王/331/90/75/75/90/100/70/0/0/0/0/3/0/45/185/3/蚊香蛙皇/523,36,157,262,147,327,420,292,154,22,254,309",
    "187": "羽毛树/332/35/35/40/35/55/50/0/0/0/0/1/0/255/74/1/毽子草/146,23,65,403,524,161,332,397,128,446,518,246,210,204,27,147,237",
    "188": "波波树/333/55/45/50/45/65/80/0/0/0/0/0/2/120/136/2/毽子花/518,27,204,210,397,146,246,65,23,128,237,332,161,147,524,403,446",
    "189": "棉花树/334/75/55/70/55/85/110/0/0/0/0/0/3/45/176/3/毽子棉/397,146,128,204,210,27,246,147,524,23,237,332,161,446,403,65,518",
    "190": "长尾猴/335/55/70/55/40/55/85/0/0/0/0/0/1/45/94/1/长尾怪手/182,436,186,204,184,173,203,198,100,268,154,509,64,458,169,5",
    "191": "悠闲种子/336/30/30/30/30/30/30/0/0/0/1/0/0/235/52/2/向日种子/413,438,398,128,524,412,11,217,146,181,332,315,79,27",
    "192": "向日葵/337/75/75/55/105/85/30/0/0/0/2/0/0/120/146/3/向日花怪/217,79,315,31,193,361,146,406,120,412,524,128,398,438,181",
    "193": "花羽蜻蜓/338/65/65/45/75/45/95/0/0/0/0/0/2/75/147/3/蜻蜻蜓/444,17,81,432,210,439,317,151,490,385,448,78,82,474,436,22",
    "194": "小嵘/339/55/45/45/25/25/15/1/0/0/0/0/0/255/52/3/乌波/310,327,254,204,182,265,446,86,389,355,392,523,58,59,356,438,388,105",
    "195": "呆呆嵘/340/95/85/85/65/65/35/2/0/0/0/0/0/90/137/3/沼王/438,105,388,310,356,59,58,523,392,355,389,86,446,265,182,204,254,327",
    "196": "艾菲狐/341/65/65/60/130/95/110/0/0/0/2/0/0/45/197/1/太阳伊布/397,210,204,146,184,161,317,437,371,198,372,229,206,200,159,438,268",
    "197": "小黑兔/342/95/65/110/60/130/65/0/0/0/0/2/0/45/197/1/月亮伊布/436,437,210,438,159,204,200,198,227,522,206,21,166,317,184,146,458",
    "198": "夜乌鸦/343/60/85/42/85/42/91/0/0/0/0/0/1/30/107/1/黑暗鸦/472,173,458,523,519,21,196,82,292,517,88,385,359,166,384,522",
    "199": "河马国王/344/95/75/80/100/110/30/0/0/0/0/3/0/70/164/3/呆呆王/310,122,525,236,438,86,210,72,254,161,372,232,449,420,397,356,394,231",
    "200": "梦魔/345/60/60/60/85/85/85/0/0/0/1/1/0/45/147/1/梦妖/169,132,72,376,173,522,371,44,292,165,436,241,397,166",
    "201": "未知/346/48/72/48/72/48/48/0/1/0/1/0/0/225/61/1/未知图腾/433",
    "202": "忍耐龙/161/190/33/58/33/58/33/2/0/0/0/0/0/45/177/1/果然翁/477,356,64,241",
    "203": "麒麟奇/164/70/80/65/90/65/85/0/0/0/2/0/0/60/149/1/麒麟奇/90,369,446,439,173,100,515,231,437,161,210,449,94,397,509,371,203,72",
    "204": "松果怪/347/50/65/90/35/35/15/0/0/1/0/0/0/190/60/1/榛果球/65,369,507,30,114,210,403,400,131,200,268,64,346,127,209",
    "205": "具壳怪/348/75/90/140/60/60/40/0/0/2/0/0/0/75/118/2/佛烈托斯/268,209,400,127,210,507,30,324,114,64,369,200,346,403,65,131",
    "206": "土龙/349/100/70/70/65/65/45/1/0/0/0/0/0/190/75/1/土龙弟弟/173,66,176,413,86,424,169,276,458,436,438,369,200,30,59,138,89,122",
    "207": "大钳虫/350/65/75/105/35/65/85/0/0/0/0/0/1/60/108/1/天蝎/21,346,64,480,385,468,50,45,317,69,184,248,436",
    "208": "钢牙龙/351/75/85/200/55/65/30/0/0/2/0/0/0/25/196/3/大钢蛇/182,527,90,114,200,138,403,347,360,176,69,415,53,436,210,467",
    "209": "布鲁/352/60/80/50/40/40/30/0/1/0/0/0/0/190/63/3/布鲁/410,205,204,206,89,401,83,176,210,90,168,21,65,353,175,525,369",
    "210": "大布鲁/353/90/120/75/60/60/45/0/2/0/0/0/0/75/178/3/布鲁皇/21,168,410,525,175,65,210,353,205,90,369,176,83,401,89,204,206",
    "211": "千针豚/354/65/95/75/55/55/85/0/1/0/0/0/0/45/100/1/千针鱼/506,209,210,248,69,67,254,131,369,173,241,200,523,262,448,109",
    "212": "哈萨姆/355/70/130/100/55/80/65/0/2/0/0/0/0/25/200/2/巨钳螳螂/474,151,47,317,343,416,458,41,509,468,454,45,159,473,64,356,203,480,444,26",
    "213": "洞洞龟/356/20/10/230/10/230/5/0/0/1/0/1/0/190/80/1/壶壶/524,382,450,57,356,341,501,30",
    "214": "大力甲虫/168/80/125/75/40/95/85/0/2/0/0/0/0/45/200/1/赫拉克罗斯/343,200,30,333,41,369,64,313,6,435,210,69,159,444",
    "215": "梦拉/357/55/95/55/35/75/115/0/0/0/0/0/1/60/132/1/狃拉/5,186,343,196,317,21,45,509,37,308,144,89,65,439,169,64,468,100,436",
    "216": "公主熊/358/60/80/50/50/50/40/0/1/0/0/0/0/120/124/2/熊宝宝/86,341,343,369,90,222,525,103,468,64,236,21,18,5,401,186,45",
    "217": "圈圈熊/359/90/130/75/75/75/55/0/2/0/0/0/0/60/189/3/圈圈熊/186,343,401,5,18,21,341,236,525,222,90,369,103,64,468,86,45",
    "218": "无壳蜗牛/103/40/40/40/70/40/20/0/0/0/1/0/0/190/78/1/熔岩虫/289,281,86,274,58,138,446,415,299,297,69",
    "219": "粘液蜗牛/104/50/50/120/80/80/30/0/0/2/0/0/0/75/154/2/熔岩蜗牛/446,299,274,58,138,281,69,415,289,86,297",
    "220": "乌利猪/360/50/50/40/30/30/50/0/1/0/0/0/0/225/78/1/小山猪/223,403,35,265,59,138,58,446,327,369,159,380,94,210,89",
    "221": "伊诺猪/361/100/100/80/60/60/50/1/1/0/0/0/0/75/160/2/长毛猪/327,403,435,94,380,159,369,6,223,89,58,138,59,446,35,265",
    "222": "赛尼珊瑚/180/55/55/85/65/85/35/0/0/1/0/1/0/60/113/1/太阳珊瑚/69,261,396,373,262,134,138,143,436,327,446,235,181,166,35,477,59,210",
    "223": "怪蛙鱼/362/35/65/35/65/35/65/0/0/0/1/0/0/190/78/3/铁炮鱼/448,371,233,262,416,39,108,476,523,436,322,143,254,348",
    "224": "石章鱼/363/75/105/75/105/75/45/0/1/0/1/0/0/75/164/3/章鱼桶/39,108,254,143,322,436,523,348,382,416,448,262,233,371",
    "225": "吉利鸟/364/45/55/45/65/45/75/0/0/0/0/0/1/45/183/3/信使鸟/353,231,36,507,147,317,233",
    "226": "阿扁鱼/365/65/40/70/80/140/70/0/0/0/0/2/0/25/168/1/巨翅飞鱼/253,210,261,448,262,369,138,385,310,166,530,506,523,182,509",
    "227": "巨鸟/115/65/80/140/40/70/70/0/0/2/0/0/0/120/114/1/盔甲鸟/438,458,469,82,472,465,209,6,509,268,184,88,343,359,335",
    "228": "恶魔犬/366/45/60/30/80/50/65/0/0/0/1/0/0/25/168/1/戴鲁比/21,281,343,289,453,297,83,89,90,94,511,293,176,458,64,169,444,100",
    "229": "地狱犬/367/75/90/50/110/80/95/0/0/0/2/0/0/45/204/2/黑鲁加/176,289,444,169,458,293,64,90,511,281,21,94,89,83,100,453,343,297",
    "230": "海马龙/186/75/95/95/95/95/85/0/1/0/1/1/0/45/207/3/刺龙王/527,232,526,147,343,108,233,296,254,530,509,506,529,200,261",
    "231": "芝麻象/165/90/60/60/40/40/40/1/0/0/0/0/0/120/124/3/小小象/369,403,104,64,525,59,58,416,276,200,66,210,94,72,159",
    "232": "大牙象/166/90/120/120/60/60/50/0/1/1/0/0/0/60/189/3/顿甲/507,105,64,525,59,104,416,6,200,66,72,435,94,58,276",
    "233": "3D龙2/368/80/85/80/90/105/95/0/0/0/2/0/0/45/180/3/多边兽2型/324,460,1,476,66,396,371,509,136,210,137",
    "234": "惊角鹿/369/73/95/62/85/65/85/0/1/0/0/0/0/45/165/1/惊角鹿/342,369,210,343,173,22,449,232,201,357,166,169,89,420,397,184",
    "235": "画画犬/370/55/20/35/20/45/75/0/0/0/0/0/1/45/106/3/图图犬/378",
    "236": "巴路奇/371/35/35/35/35/35/35/0/1/0/0/0/0/75/91/3/无畏小子/496,489,157,146,507,210",
    "237": "卡波耶拉/372/50/95/95/35/110/70/0/0/0/0/2/0/45/138/3/战舞郎/2,432,109,99,416,317,507,413,64,509,146,157,489,496,458",
    "238": "大眼娃/373/45/30/15/85/65/65/0/0/0/1/0/0/45/87/3/迷唇娃/308,18,193,401,116,380,161,40,522,437,372,292,223,311,397,240",
    "239": "电力兽/374/45/63/37/65/55/95/0/0/0/0/0/1/45/106/2/电击怪/55,280,317,343,482,26,268,436,54,481,366,235,99,40,311",
    "240": "布比/375/45/75/37/70/55/83/0/0/0/0/0/1/45/117/2/鸭嘴宝宝/366,280,296,217,281,289,112,297,330,235,436,55,482,343,166",
    "241": "牛奶坦克/376/95/80/105/40/70/100/0/0/2/0/0/0/45/200/1/大奶罐/500,276,175,397,438,146,103,159,353,236,72,66,210,449,30,58,444",
    "242": "快乐/377/255/10/10/75/135/55/2/0/0/0/0/0/30/255/2/幸福蛋/425,193,72,204,373,314,154,224,240,66,26,403,353,205,175,409,67",
    "243": "雷虎/378/90/85/75/115/100/115/0/0/0/1/0/2/3/216/1/雷公/83,481,90,65,317,342,320,343,89,321",
    "244": "火狮/379/115/115/85/90/75/100/1/2/0/0/0/0/3/217/1/炎帝/342,112,420,281,449,293,83,289,89,343",
    "245": "水狼/380/100/75/115/90/115/85/0/0/1/0/2/0/3/215/1/水君/262,89,343,355,233,327,477,506,342,445",
    "246": "幼甲龙/381/50/64/50/45/50/41/0/1/0/0/0/0/45/67/1/幼基拉斯/138,89,343,436,90,222,168,438,529,59,416,279,449,458,348,105,347",
    "247": "小甲龙/382/70/84/70/65/70/51/0/2/0/0/0/0/45/144/2/沙基拉斯/168,90,138,416,279,449,458,59,348,529,222,89,343,347,436,105,438",
    "248": "巨大甲龙/383/100/134/110/95/100/61/0/3/0/0/0/0/45/218/3/班基拉斯/105,343,347,89,436,138,222,438,90,348,458,449,279,416,59,529,168",
    "249": "路基亚/384/106/90/130/90/154/110/0/0/0/0/3/0/3/220/1/洛奇亚/506,231,59,364,355,396,445,356,82,268",
    "250": "凤凰/385/106/130/90/110/154/90/0/0/0/0/3/0/3/220/1/凤王/396,231,82,356,445,112,268,101,217,59",
    "251": "雪拉比/386/100/100/100/100/100/100/3/0/0/0/0/0/45/64/1/时拉比/203,161,396,175,356,59,231,292,128",
    "252": "草蜥蜴/001/40/45/35/65/55/70/0/0/0/0/0/1/45/65/1/木守宫/310,193,144,527,413,90,11,432,79,128,343,182,317,458,436,332,509",
    "253": "草青蛙/002/50/65/45/85/65/95/0/0/0/0/0/2/45/141/2/森林蜥蜴/509,90,527,128,310,41,432,182,144,79,43,413,343,317,193,454,458,436",
    "254": "针叶王/003/70/85/65/105/85/120/0/0/0/0/0/3/45/208/3/蜥蜴王/144,458,128,413,310,90,41,432,182,527,193,436,454,317,79,343,509,43",
    "255": "小火鸡/004/45/60/40/70/50/45/0/0/0/1/0/0/45/65/1/火稚鸡/517,281,64,444,159,138,45,420,317,293,184,88,289,416,186,72,410",
    "256": "瓦卡火鸡/005/60/85/60/85/60/55/0/1/0/1/0/0/45/142/2/力壮鸡/118,64,444,159,420,45,410,317,138,289,517,13,416,186,7,88,184,72",
    "257": "火鸡战士/006/80/120/70/110/70/80/0/3/0/0/0/0/45/209/3/火焰鸡/118,304,410,45,517,64,444,159,138,184,420,280,88,7,289,416,72,186,13,317",
    "258": "小水狗/007/50/70/50/50/50/40/0/1/0/0/0/0/45/65/1/水跃鱼/506,413,373,78,438,449,477,369,36,310,439,30,254,265,72,210,277,127",
    "259": "水狗/008/70/85/70/60/70/50/0/2/0/0/0/0/45/143/2/沼跃鱼/369,269,127,413,78,438,449,36,105,477,265,373,254,72,310,30,210,439",
    "260": "水狗王/009/100/110/90/85/90/60/0/3/0/0/0/0/45/210/3/巨沼怪/373,269,127,105,413,78,438,449,477,439,36,72,369,210,310,265,254,30",
    "261": "伯秋狗/010/35/55/35/30/30/35/0/1/0/0/0/0/255/55/1/土狼犬/420,343,379,49,173,334,90,196,86,83,94,89,184,453,210,369,168",
    "262": "恶啸狼/011/70/90/70/60/60/70/0/2/0/0/0/0/127/128/2/大狼犬/343,168,196,90,334,173,379,420,86,49,210,94,89,184,453,83,369",
    "263": "小浣熊/012/38/30/41/30/41/60/0/0/0/0/0/1/255/60/3/蛇纹熊/200,180,341,394,206,458,224,310,198,379,94,184,122,204,72,210,131",
    "264": "小臭釉/013/78/70/61/50/61/100/0/0/0/0/0/2/90/128/3/直冲熊/341,394,206,458,224,379,180,5,198,210,310,94,184,122,204,72,45",
    "265": "红毛虫/014/45/45/35/20/30/20/1/0/0/0/0/0/255/54/1/刺尾虫/248,210,77",
    "266": "刺角蛹/015/50/35/55/25/25/15/0/0/2/0/0/0/120/71/2/甲壳茧/69",
    "267": "吸管蝶/016/60/70/50/90/50/65/0/0/0/3/0/0/45/161/3/狩猎凤蝶/474,445,79,518,11,82,332,229,340",
    "268": "刺角昆/017/50/35/55/25/25/15/0/0/2/0/0/0/120/72/1/盾甲茧/69",
    "269": "半莲毒蛾/018/60/50/70/50/90/65/0/0/0/0/3/0/45/160/2/毒粉蛾/227,48,474,26,371,127,445,161,82",
    "270": "哈斯荷叶/019/40/30/30/40/50/30/0/0/0/0/1/0/255/74/1/莲叶童子/173,27,200,254,128,501,31,332,355,327,398,72,79",
    "271": "哈斯荷童/020/60/50/50/60/70/50/0/0/0/0/2/0/120/141/2/莲帽小童/78,506,254,200,128,501,27,309,173,5,334,308,398,79,72,31",
    "272": "荷叶鸭/021/80/70/70/90/100/70/0/0/0/0/3/0/45/181/3/乐天河童/79,254,200,128,501,31,398,72,173,27",
    "273": "坚果球/022/40/40/50/30/30/30/0/0/1/0/0/0/255/74/1/橡实果/128,30,369,480,317,446,114,217,27,398,69,41,315",
    "274": "坚果怪/023/70/70/40/60/40/60/0/2/0/0/0/0/120/141/2/长鼻叶/420,41,369,480,317,446,128,357,21,191,308,398,315,193,69",
    "275": "木天狗/024/90/100/60/90/60/80/0/3/0/0/0/0/45/181/3/狡猾天狗/398,41,369,480,317,128,315,69,193,446",
    "276": "思巴燕/025/40/55/30/30/30/85/0/0/0/0/0/1/200/59/3/傲骨燕/509,176,359,517,373,448,458,72,303,88,416,317,385,151,413",
    "277": "奥思巴燕/026/60/85/60/50/50/125/0/0/0/0/0/2/45/162/3/大王燕/517,303,176,373,448,458,509,88,151,385,317,416,72,359,413",
    "278": "小海鸥/027/40/30/30/55/30/85/0/0/0/0/0/1/190/64/1/长翅鸥/317,309,445,509,530,327,385,448,254,72,458",
    "279": "大嘴鹈鹕/028/60/50/100/85/75/65/0/0/2/0/0/0/45/164/2/大嘴鸥/445,392,506,327,530,309,254,389,509,72,127,385,448,388",
    "280": "拉托斯/029/28/25/25/45/35/40/0/0/0/1/0/0/235/70/1/拉鲁拉丝/499,232,511,522,241,132,4,372,342,344,151,161,72,231,22",
    "281": "凯利阿/030/38/35/35/65/55/50/0/0/0/2/0/0/120/140/2/奇鲁莉安/372,132,231,22,499,241,511,4,232,72,342,161,151,344,512,522",
    "282": "超能女皇/031/68/65/65/125/115/80/0/0/0/3/0/0/45/208/3/沙奈朵/344,231,241,4,522,511,232,499,22,132,342,151,161,72,372",
    "283": "阿美蛛/032/40/30/32/50/52/65/0/0/0/0/0/1/200/63/1/溜溜糖球/523,506,157,371,265,439,261,327,317,501,309,262,509",
    "284": "阿美蝶/033/70/60/62/80/82/60/0/0/0/1/1/0/75/128/2/雨翅蛾/261,506,518,371,265,439,82,474,157,317,445,309,501,168",
    "285": "凯诺菇/034/60/40/60/40/60/35/1/0/0/0/0/0/255/65/3/蘑蘑菇/418,18,420,206,79,146,246,41,315,122,332,128,518,210,11",
    "286": "凯诺战士/035/60/130/80/60/60/70/0/2/0/0/0/0/90/165/3/斗笠菇/79,210,518,128,332,122,489,64,118,157,305,41,206,18,420,146",
    "287": "小懒熊/036/60/60/60/35/35/30/1/0/0/0/0/0/255/83/1/懒人獭/64,200,438,144,525,58,45,236,86,379,446,21,164,524,458,186",
    "288": "长臂猿/037/80/80/80/55/55/90/0/0/0/0/0/2/120/126/2/过动猿/250,444,458,236,58,438,45,64,144,186,159,5,78,524,416,525",
    "289": "大猩猩/038/150/160/100/95/65/100/3/0/0/0/0/0/45/210/3/请假王/64,458,58,525,144,420,236,200,438,446,21,164,524,86,186,379,45",
    "290": "掘地虫/042/31/45/90/30/30/40/0/0/1/0/0/0/255/65/1/土居忍士/445,265,474,21,159,197,468,41,157,5,184,81,186,69",
    "291": "巨翅蝉/043/61/90/45/50/50/160/0/0/0/0/0/2/120/155/2/铁面忍者/47,45,509,203,159,436,186,21,445,81,454,474,69,184,5,157,151",
    "292": "鬼蝉蛹/044/1/90/45/30/30/40/2/0/0/0/0/0/45/95/3/脱壳忍者/157,445,21,159,165,221,474,169,5,184,81,69,186,166",
    "293": "音波兔/045/64/51/23/51/23/28/1/0/0/0/0/0/190/68/1/咕妞妞/236,449,410,357,420,525,369,510,78,83,173,453,448,341,436,193",
    "294": "圆耳兔/046/84/71/43/71/43/48/2/0/0/0/0/0/120/126/2/吼爆弹/436,83,357,420,525,369,510,236,410,173,193,341,78,453,448,449",
    "295": "噪音王/047/104/91/63/91/63/68/3/0/0/0/0/0/45/184/3/爆音怪/341,348,420,525,369,236,410,83,357,193,449,448,453,173,78,510,436",
    "296": "拳击兔/048/72/60/30/20/30/25/1/0/0/0/0/0/180/87/1/幕下力士/103,21,432,439,146,55,109,64,159,305,184,444,394,416,368,149,308,82,183,410,210",
    "297": "相扑兔/049/144/120/60/40/60/50/2/0/0/0/0/0/200/184/2/铁掌力士/368,439,103,444,21,432,146,55,109,305,159,64,416,308,184,394,210,82,183,410,149",
    "298": "小水鼠/054/50/20/40/20/40/20/1/0/0/0/0/0/150/33/3/露力丽/26,448,292,394,231,182,353,224,198,446,373,147,206,204,261,254,524,240",
    "299": "磁石怪/060/30/45/135/45/90/30/0/0/1/0/0/0/255/108/1/朝北鼻/347,114,276,488,476,210,341,322,360,415,69,138,324",
    "300": "手尾猫/061/50/45/45/35/35/50/0/0/0/0/0/1/255/65/1/向尾喵/198,146,397,78,18,437,224,210,403,203,72,175,340,204,240,154,306,206,21,379",
    "301": "圆环猫/062/70/65/65/55/55/70/1/0/0/0/0/1/60/138/2/优雅猫/146,224,203,437,18,198,397,154,240,340,72,78",
    "302": "地狱超人/068/50/75/75/65/65/50/0/1/1/0/0/0/45/98/1/勾魂眼/432,21,396,397,522,221,166,227,186,183,343,439,519,173,5,308",
    "303": "巨嘴秋/069/50/85/85/55/55/50/0/1/1/0/0/0/45/98/1/大嘴娃/473,388,59,397,49,41,47,392,198,89,389,18,501,123,21,203,90,173",
    "304": "钢甲小子/070/50/70/100/40/40/30/0/0/1/0/0/0/180/96/1/可可多拉/369,467,449,58,413,403,465,410,210,83,473,468,122,265,69,127",
    "305": "钢甲犀牛/071/60/90/140/50/50/40/0/0/2/0/0/0/90/152/2/可多拉/369,467,127,410,403,83,449,465,58,210,473,413,69,265,122,468",
    "306": "钢甲暴龙/072/70/110/180/60/60/50/0/0/3/0/0/0/45/205/3/波士可多拉/473,449,58,413,403,465,127,467,410,69,369,210,83,265,122,468",
    "307": "阿萨那恩/076/30/40/55/40/55/60/0/0/0/0/0/1/180/91/3/玛沙那/397,444,396,280,482,40,439,308,305,203,433,496,311,432,30,420,157,342,161",
    "308": "丘雷姆/077/60/60/75/60/75/80/0/0/0/0/0/2/90/153/3/恰雷姆/397,396,496,444,280,482,40,439,308,305,203,161,30,311,342,432,433,420,157",
    "309": "疾电狗/078/40/45/40/65/40/65/0/0/0/0/0/1/120/104/3/落雷兽/321,268,438,78,122,90,24,481,83,210,94,89,317,453,343,322",
    "310": "电气狗/079/70/75/60/105/60/105/0/0/0/0/0/2/45/168/3/雷电兽/89,481,24,90,122,78,83,268,317,438,321,453,343,322,210,94",
    "311": "正电兔/080/60/50/40/85/75/95/0/0/0/0/0/1/200/120/1/正电拍拍/18,24,224,509,481,437,321,146,317,322,72,203,524",
    "312": "负电兔/081/60/40/50/75/85/95/0/0/0/0/0/1/200/120/1/负电拍拍/509,224,203,481,24,206,321,146,317,322,72,437,524",
    "313": "巴鲁胖蜂/086/65/73/55/47/75/85/0/0/0/0/0/1/150/146/1/电萤虫/17,146,180,474,403,127,317,210,227,203,151,166,414",
    "314": "伊露胖蜂/087/65/47/55/73/75/85/0/0/0/0/0/1/150/146/2/甜甜萤/524,315,474,203,379,301,437,317,227,206,501,210,146",
    "315": "芭蕾玫瑰/094/50/60/45/100/80/65/0/0/0/1/0/0/150/152/3/毒蔷薇/501,48,181,409,27,209,237,131,248,11,315,518,332,128,512,412,406,79",
    "316": "吞食兽/095/70/43/53/43/53/40/1/0/0/0/0/0/225/75/3/溶食兽/48,389,44,297,274,499,267,193,524,446,264,245,86,388,392",
    "317": "吞食王/096/100/73/83/73/83/55/2/0/0/0/0/0/75/168/3/吞食兽/388,392,389,267,499,274,44,264,48,297,193,446,245,86,524,58",
    "318": "三色食人鱼/097/45/90/20/65/20/65/0/1/0/0/0/0/225/88/1/利牙鱼/90,222,403,506,509,420,436,168,416,176,89,343,369",
    "319": "大口食人鲨/098/70/120/40/95/40/95/0/2/0/0/0/0/60/175/2/巨牙鲨/509,436,222,506,288,420,196,45,89,90,403,176,343,416,168",
    "320": "肥波鲸/099/130/70/35/70/35/60/1/0/0/0/0/0/125/137/3/吼吼鲸/446,506,104,438,236,525,420,222,198,277,403,147,91,276,72,173,253,327,341,254",
    "321": "鲸鱼王/100/170/90/45/90/45/60/2/0/0/0/0/0/60/206/3/吼鲸王/222,446,198,506,403,420,525,236,104,91,173,438,72,341,327,147,254,276,277,253",
    "322": "沙漠骆驼/101/60/60/40/65/45/35/0/0/0/1/0/0/255/88/3/呆火驼/446,66,276,58,168,453,403,449,369,416,488,289,210,72,105,281",
    "323": "火山骆驼/102/70/100/70/105/75/40/0/1/0/1/0/0/150/175/3/喷火驼/105,92,104,453,168,58,276,449,66,289,138,210,488,416,369,446,72",
    "324": "熔岩乌龟/105/70/85/140/85/70/20/0/0/2/0/0/0/90/161/3/煤炭龟/446,438,86,236,159,92,299,200,297,281,127,58,289,296,293,473",
    "325": "弹簧小猪/110/60/25/35/70/80/60/0/0/0/0/1/0/255/89/3/跳跳猪/515,372,224,357,231,497,525,147,166,397,371,94,376,180,341",
    "326": "布比猪/111/80/45/65/90/110/80/0/0/0/0/2/0/60/164/3/噗噗猪/372,341,525,497,231,357,224,515,180,147,397,371,94,376,166",
    "327": "圈圈兔/114/60/60/60/60/60/60/0/0/0/1/0/0/255/85/1/晃晃斑/524,200,410,180,437,203,232,138,222,371,403,306,21,22,492,337,210,397,78",
    "328": "拿古拉/116/45/100/45/45/45/10/0/1/0/0/0/0/255/73/1/大颚蚁/90,445,317,416,348,197,346,21,184,89,347",
    "329": "拉巴蜻蜓/117/50/70/50/50/50/70/0/1/0/0/0/1/120/126/2/超音波幼虫/527,21,445,317,416,348,347,436,346,89,90,184",
    "330": "拉巴飞龙/118/80/100/80/80/80/100/0/1/0/0/0/2/45/197/3/沙漠蜻蜓/90,445,317,416,348,347,527,184,346,21,436,89",
    "331": "南瓜仙人球/119/50/85/40/85/40/35/0/0/0/1/0/0/190/97/1/刺球仙人掌/466,237,64,241,275,305,347,209,337,181,131,184,128,315,79,343,248,21,412",
    "332": "塔斯仙人掌/120/70/115/60/115/60/55/0/1/0/1/0/0/60/177/2/梦歌仙人掌/64,209,466,237,347,241,412,275,305,131,337,343,21,248,181,79,315,109,128,184",
    "333": "云彩雀/121/45/40/60/40/75/50/0/0/0/0/1/0/255/74/1/青绵鸟/517,176,458,523,509,292,373,173,6,327,356,88,240,369,72",
    "334": "碧云龙/122/75/70/90/70/105/80/0/0/0/0/2/0/45/188/2/七夕青鸟/373,292,359,509,523,527,176,369,458,173,88,529,72,240,6,356,327",
    "335": "雪山狐猫/123/73/115/60/60/60/90/0/2/0/0/0/0/90/165/1/猫鼬斩/432,196,83,64,480,7,41,438,458,45,454,47,317,343,186,200,144",
    "336": "红牙响尾蛇/124/73/100/60/100/60/65/0/1/0/1/0/0/90/165/1/饭匙蛇/523,58,392,388,420,49,424,436,244,89,401,57,90,389",
    "337": "月亮神石/125/70/55/65/95/85/70/0/0/0/2/0/0/45/150/1/月石/161,114,231,372,126,376,415,69,210,22",
    "338": "太阳神石/126/70/95/85/55/65/70/0/2/0/0/0/0/45/150/1/太阳岩/415,120,138,126,114,161,69,210,376,184",
    "339": "小鲶鱼/127/50/48/43/46/41/60/1/0/0/0/0/0/190/92/1/泥泥鳅/525,321,277,222,104,105,310,231,265,341,309,254,488,446",
    "340": "地震鲶鱼/128/110/78/73/76/71/60/2/0/0/0/0/0/75/158/2/鲶鱼王/341,277,222,104,231,105,525,321,488,254,309,310,265,198,446",
    "341": "双钳龙虾/129/43/80/65/50/35/35/0/1/0/0/0/0/205/111/3/龙虾小兵/59,115,261,47,90,50,310,58,413,343,196,123,262,127,183,69",
    "342": "钢钳龙虾/130/63/120/85/90/55/55/0/2/0/0/0/0/155/161/3/铁螯龙虾/115,196,59,47,90,50,310,58,413,69,183,261,343,123,262,127",
    "343": "土偶怪/131/40/40/55/40/70/55/0/0/0/0/1/0/255/58/1/天秤偶/59,140,114,347,400,265,161,507,69,126,371",
    "344": "三合一土偶/132/60/70/105/70/120/75/0/0/0/0/2/0/90/189/2/念力土偶/140,126,348,347,400,371,265,507,69,161,344,114,59",
    "345": "向日古花/133/66/41/77/61/87/23/0/0/0/0/1/0/45/121/1/触手百合/388,138,477,396,235,389,392,446,166,181,275,173,382,59",
    "346": "噬人古花/134/86/81/97/81/107/43/0/0/0/0/2/0/45/201/2/摇篮百合/166,138,477,396,235,389,392,388,173,181,275,382,446,59",
    "347": "硬甲古蝎/135/45/95/50/40/50/75/0/1/0/0/0/0/45/119/1/太古羽虫/59,143,507,183,47,454,138,127,468,254,310,69,186,45",
    "348": "盔甲蝎/136/75/125/100/70/80/45/0/2/0/0/0/0/45/200/2/太古盔甲/507,138,183,143,45,454,59,127,254,310,69,186,468,47",
    "349": "丑鲤鱼/140/20/15/20/10/55/80/0/0/0/0/0/1/255/61/1/丑丑鱼/310,26,166,22,527,477,200,147,210",
    "350": "美丽龙/141/95/60/79/100/125/81/0/0/0/0/2/0/60/213/2/美纳斯/355,26,22,310,527,477,356,166,396,530,253,373,309,57,254,340,506",
    "351": "天气小子/142/70/70/70/70/70/70/1/0/0/0/0/0/45/145/1/飘浮泡泡/289,397,231,251,38,217,380,254,210,355",
    "352": "隐身龙/145/60/90/70/60/120/40/0/0/0/0/1/0/200/132/2/变隐龙/204,180,515,232,436,59,224,45,5,21,53,186,173,334,401,371",
    "353": "鬼影娃娃/146/44/75/35/63/33/45/0/1/0/0/0/0/225/97/1/怨影娃娃/221,132,173,439,241,232,148,511,169,438,519,436,183,21,165",
    "354": "链嘴幽魂/147/64/115/65/83/63/65/0/2/0/0/0/0/45/179/2/诅咒娃娃/511,21,132,148,165,232,241,173,439,183,169,436,519,438,221",
    "355": "夜游灵/148/20/40/90/30/90/25/0/0/1/0/1/0/190/97/1/夜巡灵/438,231,21,4,165,44,241,132,519,458,166,173,439,232,511,343,522",
    "356": "黑乃伊/149/40/70/130/60/130/25/0/0/1/0/2/0/90/179/2/彷徨夜灵/21,522,132,241,44,4,511,219,165,343,438,231,53,519,232,439,173,166,458",
    "357": "热带雷龙/150/99/68/83/72/87/51/2/0/0/0/0/0/200/169/3/热带龙/120,58,128,480,182,27,398,343,82,501,449,31,315,445,122,512",
    "358": "蓝风铃/151/65/50/70/95/80/65/0/0/0/1/1/0/45/147/1/风铃铃/175,499,372,403,22,173,438,376,86,78,161,72,57,232,369,356",
    "359": "黑面雪狐/152/65/130/60/75/60/75/0/2/0/0/0/0/30/174/2/阿勃梭鲁/203,224,438,515,21,292,231,45,343,403,186,151,196,317,480,89,47",
    "360": "小忍耐龙/160/95/23/48/23/48/23/1/0/0/0/0/0/125/44/2/小果然/147,206,524,64,477,356,241",
    "361": "由基瓦拉/171/50/50/50/50/50/50/1/0/0/0/0/0/190/74/3/雪童子/89,151,37,122,127,90,380,209,343,38,223,360,39",
    "362": "巨头冰怪/172/80/80/80/80/80/80/2/0/0/0/0/0/75/187/3/冰鬼护/90,127,122,37,89,151,380,39,209,360,381,223,38,343",
    "363": "波波海象/173/70/40/50/55/50/25/1/0/0/0/0/0/255/75/1/海豹球/138,438,58,380,72,254,66,104,36,86,233,38,525,223,381,309,388,389,341,524,392",
    "364": "古拉海象/174/90/60/70/75/70/45/2/0/0/0/0/0/120/128/2/海魔狮/104,381,309,388,389,86,438,223,138,380,525,72,254,524,66,341,36,58,233,38,392",
    "365": "海象牙王/175/110/80/90/95/90/65/3/0/0/0/0/0/45/192/3/帝牙海狮/381,309,388,389,392,438,223,138,86,66,525,104,72,380,524,36,58,233,38,341,254",
    "366": "帕鲁蚌/176/35/64/85/74/55/32/0/0/1/0/0/0/255/142/1/珍珠贝/235,448,166,310,373,473,277,443,254,58",
    "367": "巨嘴鳗/177/55/104/105/94/75/52/0/1/1/0/0/0/60/178/2/猎斑鱼/203,166,235,448,58,310,277,506,90,168,253,436,89,373",
    "368": "尖头鳗/178/55/84/105/114/75/52/0/0/0/2/0/0/60/178/3/樱花鱼/235,58,372,203,506,310,448,253,166,446,277,161,509,373",
    "369": "地图石鱼/179/100/90/130/45/65/55/1/0/1/0/0/0/25/198/1/古空棘鱼/236,210,446,403,310,309,288,488,506,138,369,86,140,341,254,59,69",
    "370": "心形鱼/183/43/30/55/40/65/97/0/0/0/0/0/1/225/110/1/爱心鱼/309,448,147,206,356,200,116,340,369,509,254,210,310",
    "371": "塔祖贝龙/187/45/75/60/40/30/50/0/1/0/0/0/0/45/89/1/宝贝龙/527,89,528,122,289,176,168,90,529,530,526,222,506,403,416,343",
    "372": "龙龙贝/188/65/95/100/60/50/50/0/0/2/0/0/0/45/144/2/甲壳龙/168,530,526,222,506,403,90,529,527,127,289,122,343,89,176,416,528",
    "373": "血翼飞龙/189/95/135/80/110/80/100/0/3/0/0/0/0/45/218/3/暴飞龙/530,527,168,495,90,528,403,506,222,529,127,526,176,416,122,343,89,289",
    "374": "独眼达恩/190/40/55/80/35/60/30/0/0/1/0/0/0/3/103/1/铁哑铃/369",
    "375": "双臂恩古/191/60/75/100/55/80/50/0/0/2/0/0/0/3/153/2/金属怪/473,178,348,509,458,168,468,161,369,372",
    "376": "钢铁螃蟹/192/80/135/130/95/90/70/0/0/3/0/0/0/3/210/3/巨金怪/168,348,509,178,473,372,458,161,468,369",
    "377": "岩神柱/193/80/100/200/50/100/50/0/0/3/0/0/0/3/217/1/雷吉洛克/426,473,324,348,59,415,114,476,438",
    "378": "冰神柱/194/80/50/100/100/200/50/0/0/0/0/3/0/3/216/2/雷吉艾斯/476,348,324,446,59,426,37,114,438",
    "379": "钢神柱/195/80/75/150/75/150/50/0/0/1/0/2/0/3/215/3/雷吉斯奇鲁/426,476,324,446,114,59,438,468,348,473",
    "380": "拉迪阿斯/196/80/80/90/110/130/110/0/0/0/0/3/0/3/211/3/拉帝亚斯/206,396,527,372,457,373,309,146,356,376,437",
    "381": "拉迪奥斯/197/80/90/80/130/110/110/0/0/0/3/0/0/3/211/3/拉帝欧斯/356,529,396,372,29,373,527,146,4,376,127",
    "382": "海皇牙/198/100/100/90/150/140/90/0/0/0/3/0/0/5/218/3/盖欧卡/59,39,403,91,381,341,506,58,168,253,342",
    "383": "古拉顿/199/100/150/140/100/90/90/0/3/0/0/0/0/5/218/3/固拉多/59,92,120,104,341,112,105,45,168,265,13",
    "384": "天空之龙/200/105/150/90/150/90/95/0/2/0/1/0/0/3/220/3/烈空坐/529,279,341,495,348,90,59,168,530,528,358",
    "385": "月映兽/201/100/100/100/100/100/100/3/0/0/0/0/0/3/215/3/基拉祈/146,349,126,231,403,341,372,268,161,437,373",
    "386": "迪奥西斯/202/50/150/50/150/50/150/0/1/0/1/0/1/3/215/3/代欧奇希斯/183,374,348,64,396,446,473,126,477,148,458,344,519,57,343,372,209",
    "387": "树苗龟/387/55/68/64/45/55/31/0/1/0/0/0/0/45/64/1/草苗龟/210,383,80,493,438,84,332,128,27,85,11,75,298,315,198,58,403,258,362,222,446,426",
    "388": "树林龟/388/75/89/85/55/65/36/0/1/1/0/0/0/45/141/2/树林龟/210,383,80,493,438,84,332,128,27,85,11,75,298,315,198,58,403,258,362,222,446,426",
    "389": "地壳龟/389/95/109/105/75/85/56/0/2/1/0/0/0/45/208/3/土台龟/230,210,383,80,493,438,84,332,105,128,27,85,11,75,298,315,198,58,403,258,362,222,446,426",
    "390": "火苗猴/390/44/58/44/58/44/61/0/0/0/0/0/1/45/65/1/小火焰猴/187,343,291,196,5,287,484,130,365,285,179,284,489,283,486,63,524,300,387,146,3,290,64",
    "391": "猛火猴/391/64/78/52/78/52/81/0/0/0/1/0/1/45/142/2/猛火猴/187,343,291,196,5,287,14,130,452,285,179,295,283,486,63,524,300,387,146,3,290,64",
    "392": "豪火猴/392/76/104/71/104/71/108/0/1/0/1/0/1/45/209/3/烈焰猴/187,343,291,196,489,5,287,14,174,452,285,32,295,283,486,63,524,300,387,146,3,290,64",
    "393": "侯企鹅/393/53/51/53/61/56/40/0/0/0/1/0/0/45/66/1/波加曼/193,72,261,309,88,30,260,6,270,277,327,472,506,61,448,86,310,208,525,106,509,271",
    "394": "王企鹅/394/64/66/68/81/76/50/0/0/0/0/2/0/45/143/2/波皇子/210,72,261,309,88,470,30,260,6,270,277,327,472,506,61,448,86,310,208,525,106,509,271",
    "395": "皇帝企鹅/395/84/86/88/111/101/60/0/0/0/3/0/0/45/210/3/帝王拿波/210,72,261,47,88,470,420,260,6,270,277,327,472,506,61,448,86,310,208,525,106,509,271",
    "396": "胖胖翁/396/40/55/30/30/30/60/0/0/0/0/0/1/255/56/1/姆克儿/210,72,317,386,151,413,82,303,369,509,411,384,6,458,173,195,439,403",
    "397": "大胖翁/397/55/75/50/40/40/80/0/0/0/0/0/2/120/113/2/姆克鸟/210,72,317,386,151,413,82,303,369,509,411,384,6,458,173,195,439,403",
    "398": "长冠翁/398/85/120/70/50/50/100/0/3/0/0/0/0/45/172/3/姆克鹰/210,72,317,386,151,413,82,303,369,452,509,411,384,6,458,173,195,439,403",
    "399": "钝河狸/399/59/45/40/35/40/31/1/0/0/0/0/0/255/58/1/大牙狸/210,72,66,276,121,447,86,446,369,177,426,309,403,5,94,252",
    "400": "河狸精灵/400/79/85/60/55/60/71/0/2/0/0/0/0/127/116/2/大尾狸/210,72,66,276,254,121,447,86,446,369,177,426,309,403,5,94,252",
    "401": "胖蟋蟀/401/37/25/41/25/41/25/0/0/1/0/0/0/255/54/1/圆法师/72,30",
    "402": "蟋蟀战士/402/77/85/51/66/51/65/0/2/0/0/0/0/45/159/2/音箱蟀/72,30,454,81,87,387,9,96,422,292",
    "403": "小电狮/403/45/65/34/40/34/45/0/1/0/0/0/0/235/60/1/小猫怪/210,343,24,84,321,83,420,85,487,171,214,129,286,317,453,369",
    "404": "电光狮/404/60/85/49/60/49/60/0/2/0/0/0/0/120/117/2/勒克猫/210,343,24,84,321,83,420,85,487,171,214,129,286,317,453,369",
    "405": "雷鸣狮/405/80/120/79/95/79/70/0/3/0/0/0/0/45/194/3/伦琴猫/210,343,24,84,321,83,420,85,487,171,214,129,286,317,453,369",
    "406": "玫瑰花苞/406/40/30/35/50/70/55/0/0/0/1/0/0/255/68/1/含羞苞/80,315,309,332,298,518,27,493,209,494,237,23,157,75,357",
    "407": "万花蔷薇/407/60/70/55/125/105/90/0/0/0/3/0/0/75/204/2/罗丝雷朵/119,248,332,513,407,493,209,494,237,23,157,75,357",
    "408": "小骨龙/408/67/125/40/30/30/58/0/1/0/0/0/0/45/99/1/头盖龙/343,387,171,96,369,121,458,160,59,163,60,85,222,403,71,449,82,462",
    "409": "暴骨龙/409/97/165/60/65/50/58/0/2/0/0/0/0/45/199/2/战槌龙/343,387,171,96,369,121,458,160,59,163,60,85,222,403,71,449,82,462",
    "410": "甲盾兽/410/30/42/118/42/88/30/0/0/1/0/0/0/45/99/3/盾甲龙/210,369,420,59,121,171,403,387,96,58,438,15,196,463,473,159,464,471,143,104",
    "411": "钢盾兽/411/60/52/98/47/78/30/0/0/2/0/0/0/45/199/3/护城龙/210,369,420,59,121,171,403,387,96,58,438,15,196,463,473,159,464,471,143,104,199",
    "412": "蓑衣虫/412/40/29/45/29/45/36/0/0/0/0/1/0/120/61/1/结草儿/210,15,433",
    "413": "叶衣虫/413/60/59/85/79/105/36/0/0/0/2/0/0/45/159/2/结草贵妇/210,15,433,161,493,315,371,405,106,124,375,75",
    "414": "亮翅蛾/414/70/94/50/94/50/66/0/1/0/1/0/0/45/159/1/绅士蛾/210,15,433,161,371,375,216,246,16,475,367,422",
    "415": "三合一蜂巢/415/30/30/42/30/42/70/0/0/0/0/0/1/120/63/2/三蜜蜂/407,216",
    "416": "蜂女皇/416/70/80/102/80/102/40/0/0/1/0/1/0/45/188/3/蜂女王/407,216,405,420,248,458,454,5,73,483,52,98,48,51,212,76",
    "417": "电松鼠/417/60/45/70/45/90/95/0/0/1/0/0/0/200/120/1/帕奇利兹/106,84,321,317,72,30,159,214,206,508,117,177,226,379,18,66,276,301",
    "418": "叉尾鼬/418/55/65/35/60/30/85/0/0/0/0/0/1/190/75/2/泳圈鼬/72,317,458,508,309,277,509,490,254,256,480,208,121,454,5,51,94,455,203",
    "419": "海鼬王/419/85/105/55/85/50/115/0/0/0/0/0/2/75/178/3/浮潜鼬/72,309,490,317,254,458,508,256,480,509,277,85,129,208,121,454,5,51,94,455,203",
    "420": "樱桃芽/420/45/35/45/62/53/35/0/0/0/1/0/0/190/68/1/樱花宝/210,128,315,493,146,513,213,298,369,120,354,407,198,398,412,408",
    "421": "樱桃花/421/70/60/70/87/78/85/0/0/0/2/0/0/75/133/2/樱花儿/210,315,128,146,513,213,406,298,369,120,354,493,407,198,398,412,408",
    "422": "无壳龙/422/76/48/48/57/62/34/1/0/0/0/0/0/190/73/1/无壳海兔/208,310,69,255,266,433,355,58,269,396,64,478,388,390,391,86,4,438,446,104",
    "423": "地贝龙/423/111/83/68/92/82/39/2/0/0/0/0/0/75/176/2/海兔兽/208,310,69,255,266,433,355,58,269,396,64,478,388,390,391,86,4,438,446,104",
    "424": "双尾猴/424/75/100/66/60/66/115/0/0/0/0/0/2/45/186/3/双尾怪手/187,316,195,173,203,198,5,508,96,509,61,188,484,226,64,458,169,71,455,100,3,379,497",
    "425": "气球仔/425/90/50/34/60/44/70/1/0/0/0/0/0/125/127/1/飘飘球/382,67,173,216,387,97,388,390,391,167,203,152,114,4,58,76,232,523,22",
    "426": "幽灵气球/426/150/80/44/90/54/80/2/0/0/0/0/0/60/204/2/随风球/382,67,173,216,387,97,388,390,391,167,203,152,114,4,58,76,232,523,22",
    "427": "棉花兔/427/55/66/44/44/56/85/0/0/0/0/0/1/190/84/1/卷卷耳/147,193,66,439,159,207,317,498,203,509,338,206,497,259,18,3,524,117,61,124,451,56,20,486,33,283",
    "428": "女郎兔/428/65/76/84/54/96/105/0/0/0/0/0/2/60/178/2/长耳兔/478,514,147,193,66,439,159,192,317,498,203,509,338,206,497,259,18,3,524,117,61,124,451,56,20,486,33,283",
    "429": "梦巫/429/60/60/60/105/105/105/0/0/0/1/1/0/45/187/3/梦妖魔/354,513,72,376,169,173,96,76,397,132,4,107,150,438,167",
    "430": "绅士鸦/430/100/125/52/105/52/71/0/2/0/0/0/0/30/187/3/乌鸦头头/173,458,523,386,420,484,440,520,82,472,517,359,73,384,292,377,96,19",
    "431": "旋尾猫/431/49/55/42/42/37/85/0/0/0/0/0/1/190/71/1/魅力喵/3,187,72,22,21,5,206,307,405,51,107,124,84,316,317,195,18,160",
    "432": "胖胖猫/432/71/82/64/64/59/112/0/0/0/0/0/2/75/183/2/东施喵/3,187,72,22,21,5,206,307,405,51,420,58,124,84,316,317,195,18,160",
    "433": "金铃/433/45/30/50/65/50/45/0/0/0/1/0/0/120/74/1/铃铛响/57,72,173,161,78,226,232,438,22,499,437,491,396",
    "434": "毒臭釉/434/63/63/47/41/41/74/0/0/0/0/0/1/225/79/1/臭鼬噗/187,387,249,96,5,296,48,51,440,4,114,458,343,245,403,85,171,173,174",
    "435": "恶毒釉/435/103/93/67/71/61/84/2/0/0/0/0/0/60/209/2/坦克臭鼬/187,387,249,96,5,296,48,51,440,284,4,114,458,343,245,403,85,171,173,174",
    "436": "镜面偶/436/57/24/86/24/86/23/0/0/1/0/0/0/255/72/1/铜镜怪/210,161,22,132,73,357,473,356,431,491,21,97,133",
    "437": "镜面图腾/437/67/89/116/79/116/33/0/0/1/0/0/1/90/188/2/青铜钟/213,355,210,161,22,132,73,357,473,356,431,491,21,97,133",
    "438": "胡说盆栽/438/50/80/95/45/10/10/0/0/1/0/0/0/255/68/3/盆才怪/18,12,106,451,415,239,199,21,139,141,71,107,403,400,121,69,66,276,258",
    "439": "魔尼小丑/439/20/25/45/70/90/60/0/0/0/0/1/0/145/78/3/魔尼尼/198,235,161,12,312,524,356,239,28,65,371,224,460,180,375,201,203,455,491,22,397,3,73,273,339,259,206",
    "440": "兜兜蛋/440/100/5/5/15/65/30/1/0/0/0/0/0/130/255/1/小福蛋/193,206,12,373,117,353,205,325,408,224,64,146,461,226",
    "441": "音符鹉/441/76/65/45/92/42/91/0/1/0/0/0/0/30/107/1/聒噪鸟/88,72,517,87,6,441,196,239,516,78,384,510,524,110,509,484,448",
    "442": "鬼盆栽/442/50/92/108/92/108/35/0/0/1/0/1/0/100/168/3/花岩怪/438,458,73,169,150,21,22,499,167,107,484,4,520,76,326,296,132,165",
    "443": "地龙宝宝/443/58/70/45/40/45/42/0/1/0/0/0/0/45/67/1/圆陆鲨/210,195,526,257,369,258,51,528,197,533,531,459,530,171,403,222,470,58,471",
    "444": "利爪地龙/444/68/90/65/50/55/82/0/2/0/0/0/0/45/144/2/尖牙陆鲨/210,195,526,257,369,258,51,528,197,533,531,459,530,171,403,222,470,58,471",
    "445": "暴地龙/445/108/130/95/80/85/102/0/3/0/0/0/0/45/445/3/烈咬陆鲨/286,210,195,526,257,369,258,51,528,197,85,533,531,459,530,171,403,222,470,58,471",
    "446": "刚比兽/446/135/85/40/40/85/5/1/0/0/0/0/0/50/94/1/小卡比兽/205,94,210,66,446,402,460,96,388,390,58,188,276,399,225,206,403,438,224,82,458,163",
    "447": "鲁力欧/447/40/70/40/35/40/60/0/1/0/0/0/0/75/72/2/利欧路/317,439,159,64,530,14,444,96,12,55,432,84,157,56,496,509,336,85,451,473,290,404",
    "448": "鲁卡力欧/448/70/110/70/115/70/90/0/1/0/1/0/0/45/204/3/路卡利欧/520,317,439,432,470,64,530,14,505,463,25,47,263,452,532,358,55,84,157,56,496,509,336,85,451,473,290,404",
    "449": "沼泽河马/449/68/72/78/38/42/32/0/0/1/0/0/0/140/95/2/沙河马/210,195,84,86,369,258,85,105,403,104,388,390,391,438,179,58",
    "450": "沙河马/450/108/112/118/68/72/47/0/0/2/0/0/0/60/198/3/河马兽/129,286,487,210,195,84,86,369,258,85,105,403,104,388,390,391,438,179,58",
    "451": "幼龙蝎/451/40/50/90/30/55/65/0/0/1/0/0/0/120/114/1/钳尾蝎/84,248,343,494,294,183,171,247,49,85,243,21,96,195,51,73,82,509,458,440",
    "452": "毒龙蝎/452/70/90/110/60/75/95/0/0/2/0/0/0/45/204/3/龙王蝎/487,129,286,84,248,343,494,294,183,171,247,49,85,243,21,96,195,51,73,82,509,458,440",
    "453": "毒蟾斗士/453/48/61/40/61/40/50/0/1/0/0/0/0/140/83/1/不良蛙/173,208,248,196,458,21,109,420,266,107,484,242,267,301,25,14,305,121,336,312,3,273,272,55,404",
    "454": "毒蟾王/454/83/106/65/86/65/85/0/2/0/0/0/0/75/181/3/毒骷蛙/173,208,248,196,458,21,109,420,266,107,484,242,267,301,25,14,305,121,336,312,3,273,272,55,404",
    "455": "噬人怪草/455/74/100/72/90/72/46/0/2/0/0/0/0/200/164/3/尖牙笼/53,315,84,417,407,181,21,388,391,390,85,238,427,23,518,493,71,27",
    "456": "蝶尾鱼/456/49/49/56/49/61/66/0/0/0/0/0/1/190/90/1/荧光鱼/193,254,124,355,216,255,405,356,271,277,429,497,475,117,206,106,252,147,371,198,509",
    "457": "蝶翅鱼/457/69/69/76/69/86/91/0/0/0/0/0/2/75/156/2/霓虹鱼/193,254,124,355,216,255,405,356,271,277,429,497,475,117,206,106,252,147,371,198,509",
    "458": "小球飞鱼/458/45/20/50/60/120/50/0/0/0/0/1/0/25/108/1/小球飞鱼/210,261,448,260,121,509,386,255,369,73,497,271,506,530,523,71,310,141,478,309,147,17",
    "459": "森林雪人/459/60/62/50/62/60/40/0/1/0/0/0/0/120/131/1/雪笠怪/370,343,493,34,412,420,327,181,230,223,381,128,513,362,315,403,449",
    "460": "巨雪人/460/90/92/75/92/85/60/0/1/0/1/0/0/60/214/2/暴雪王/33,370,343,493,34,412,420,327,181,230,223,381,128,513,362,315,403,449",
    "461": "玛纽拉/461/70/120/65/45/85/125/0/1/0/0/0/1/45/199/3/玛狃拉/185,109,160,187,343,196,317,96,21,5,484,34,440,188,470,520,64,169,439,65,84,350,3,61,174,458,33",
    "462": "飞碟磁怪/462/70/70/115/130/90/60/0/0/0/3/3/0/30/211/3/自爆磁怪/478,235,463,210,318,448,490,322,321,476,352,96,214,479,323,431,324",
    "463": "长舌怪/463/110/85/95/80/95/50/3/0/0/0/0/0/30/193/3/大舌舔/402,448,66,183,57,449,232,71,276,25,373,96,427,238,431,395,351,58,438,272,236,525,224,446,462",
    "464": "钻甲暴龙/464/115/140/130/55/55/40/0/3/0/0/0/0/30/217/3/超甲狂犀/242,434,145,449,6,171,143,369,135,462,345,105,331,142,85,444,141,64,351,47,438,350,533,129,286,485",
    "465": "树藤怪/465/100/100/125/110/50/50/0/0/2/0/0/0/30/211/3/巨蔓藤/181,382,23,80,315,246,417,53,332,518,59,183,399,71,198,238,427,199",
    "466": "电击魔/466/75/123/67/95/85/95/0/3/0/0/0/0/30/199/3/电击魔兽/283,317,343,318,451,508,319,28,486,214,54,96,481,10,366,235,99,312,55,33,305",
    "467": "鸭嘴炎龙/467/75/95/67/125/95/83/0/0/0/3/0/0/30/199/3/鸭嘴炎兽/486,245,343,291,296,21,285,73,283,93,284,213,113,348,366,328,235,96,55,489,305,295",
    "468": "波克鸟/468/85/50/95/120/115/80/0/0/0/2/1/0/30/220/1/波克基斯/359,358,263,367,353,517,88,439,491,224,397,484,377,354",
    "469": "古蜻蜓/469/86/76/86/116/56/95/0/2/0/0/0/0/30/198/2/远古巨蜓/440,421,210,439,317,151,490,432,448,78,458,59,51,96,429,367,422,82,444,81,17,475,14,21",
    "470": "叶精灵/470/65/110/130/60/65/95/0/0/2/0/0/0/45/196/1/叶伊布/210,316,146,195,493,317,27,513,11,226,412,213,74,206,106,159,438,198,437,86,18,379",
    "471": "冰精灵/471/65/60/110/130/95/65/0/0/0/2/0/0/45/196/2/冰伊布/210,316,146,195,34,317,84,129,226,12,38,223,205,206,106,159,438,198,437,86",
    "472": "巨飞蝎/472/75/95/125/45/75/95/0/0/2/0/0/0/30/192/2/天蝎王/487,129,286,242,195,69,183,317,454,21,96,440,47,429,9,50,18,379,470,386,480,64,258,509,203,403,14",
    "473": "獠牙猪/473/110/130/80/70/60/80/0/3/0/0/0/0/50/207/3/象牙猪/59,88,94,310,370,208,159,266,38,129,369,61,105,327,223,171,84,58,141,265,35,403",
    "474": "3D龙Z/474/85/80/70/135/75/90/0/0/0/3/0/0/30/158/3/多边兽乙型/419,136,210,484,371,509,396,323,17,185,214,476,1,514,324,348",
    "475": "超能战士/475/68/125/65/65/115/80/0/3/0/0/0/0/45/208/3/艾路雷朵/74,440,343,161,151,344,454,51,47,156,146,14,42,15,452,104,438,232,511,522,4,76,165",
    "476": "红鼻钢/476/60/55/145/75/150/40/0/0/1/0/2/0/60/198/2/大朝北鼻/323,461,210,473,352,199,322,141,257,341,214,345,324,476,111,150,73,351,276,114",
    "477": "夜魔人/477/45/100/135/65/135/45/0/0/1/0/2/0/45/210/2/黑夜魔灵/283,33,486,461,53,343,110,232,439,173,73,150,458,438,511,219,522,97,491,403,199,132,76,326,165,4",
    "478": "雪魔女/478/70/80/70/80/70/110/0/0/0/0/0/2/75/187/2/雪妖女/370,343,151,173,34,73,167,273,405,38,223,76,21,199,209,276,232,30",
    "479": "电磁鬼/479/50/50/77/95/77/91/0/0/0/1/0/1/45/132/1/洛托姆/180,173,322,318,73,78,151,319,167,224,24,214",
    "480": "黄圣菇/480/75/75/130/75/130/95/0/0/2/0/1/0/3/210/1/由克希/341,132,159,161,86,491,446,357,106,399,4",
    "481": "红圣菇/481/80/105/105/105/105/80/0/1/0/1/1/0/3/210/2/艾姆利多/341,132,15,161,354,491,206,357,12,399,259",
    "482": "蓝圣菇/482/75/125/70/125/70/115/0/2/0/1/0/0/3/210/3/亚克诺姆/341,132,432,161,78,491,484,357,226,399,114",
    "483": "迪奥鲁加/483/100/120/120/150/100/90/0/0/0/3/0/0/30/220/3/帝牙卢卡/531,171,470,59,528,218,133,111,51,423,263",
    "484": "帕鲁其亚/484/90/120/100/150/120/100/0/0/0/3/0/0/30/220/3/帕路奇亚/531,171,255,59,528,8,133,111,51,252,263",
    "485": "岩浆巨兽/485/91/90/106/130/106/77/0/0/0/3/0/0/3/215/3/席多蓝恩/59,343,286,463,85,171,93,285,471,111,300,345,302",
    "486": "恩神柱/486/110/160/110/80/110/100/0/3/0/0/0/0/3/220/3/雷吉奇卡斯/283,33,486,328,183,73,449,426,163,202,10",
    "487": "鬼龙/487/150/100/120/100/120/90/3/0/0/0/0/0/3/220/3/骑拉帝纳/531,171,167,59,528,153,133,111,51,220,263",
    "488": "梦兽/488/120/70/120/75/130/85/0/0/0/0/3/0/3/210/3/克雷色利亚/161,151,356,327,234,491,51,228,156,377,215,375",
    "489": "菲奥奈/489/80/80/80/80/80/80/1/0/0/0/0/0/3/165/1/霏欧纳/261,309,206,448,260,430,277,255,271,278,355",
    "490": "玛娜菲/490/100/100/100/100/100/100/3/0/0/0/0/0/3/215/3/玛纳霏/414,261,309,206,448,260,430,277,255,271,278,355,155",
    "491": "暗裂魔/491/70/90/90/135/90/125/0/0/0/2/0/1/3/210/3/达克莱伊/110,232,317,22,458,95,151,523,521,185,499,520",
    "492": "草刺猬/492/100/100/100/100/100/100/3/0/0/0/0/0/45/64/3/谢米/66,513,128,27,407,399,298,408,393,412,354,363",
    "493": "圣灵兽/493/120/120/120/120/120/120/3/0/0/0/0/0/3/255/3/阿尔宙斯/103,125,399,174,461,111,510,358,373,491,396,348,292,46"
};
function parse(c, s) {
    const p = new MonsterProfile_1.default();
    p.code = lodash_1.default.padStart(c.toString(), 3, "0");
    const ss = lodash_1.default.split(s, "/");
    p.name = ss[0] + "(" + p.code + ")";
    p.picture = ss[1].includes(".") ? ss[1] : ss[1] + ".gif";
    p.healthBaseStats = lodash_1.default.parseInt(ss[2]);
    p.attackBaseStats = lodash_1.default.parseInt(ss[3]);
    p.defenseBaseStats = lodash_1.default.parseInt(ss[4]);
    p.specialAttackBaseStats = lodash_1.default.parseInt(ss[5]);
    p.specialDefenseBaseStats = lodash_1.default.parseInt(ss[6]);
    p.speedBaseStats = lodash_1.default.parseInt(ss[7]);
    p.healthEffort = lodash_1.default.parseInt(ss[8]);
    p.attackEffort = lodash_1.default.parseInt(ss[9]);
    p.defenseEffort = lodash_1.default.parseInt(ss[10]);
    p.specialAttackEffort = lodash_1.default.parseInt(ss[11]);
    p.specialDefenseEffort = lodash_1.default.parseInt(ss[12]);
    p.speedEffort = lodash_1.default.parseInt(ss[13]);
    p.catchRatio = lodash_1.default.parseInt(ss[14]);
    p.growExperience = lodash_1.default.parseInt(ss[15]);
    p.location = lodash_1.default.parseInt(ss[16]);
    p.pokemon = ss[17];
    p.spellIds = ss[18];
    return p;
}
function extractCode(name) {
    if (!name)
        return null;
    if (!name.includes("(") || !name.includes(")"))
        return null;
    return StringUtils_1.default.substringBetween(name, "(", ")");
}
module.exports = MonsterProfileLoader;


/***/ }),
/* 19 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const Constants_1 = __importDefault(__webpack_require__(11));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const MonsterSpellLoader_1 = __importDefault(__webpack_require__(22));
class MonsterProfile {
    asText() {
        return StringUtils_1.default.substringBefore(this.name, "(") +
            "/" +
            (lodash_1.default.endsWith(this.picture, ".gif") ? StringUtils_1.default.substringBefore(this.picture, ".gif") : this.picture) +
            "/" +
            this.healthBaseStats +
            "/" +
            this.attackBaseStats +
            "/" +
            this.defenseBaseStats +
            "/" +
            this.specialAttackBaseStats +
            "/" +
            this.specialDefenseBaseStats +
            "/" +
            this.speedBaseStats +
            "/" +
            this.healthEffort +
            "/" +
            this.attackEffort +
            "/" +
            this.defenseEffort +
            "/" +
            this.specialAttackEffort +
            "/" +
            this.specialDefenseEffort +
            "/" +
            this.speedEffort +
            "/" +
            this.catchRatio +
            "/" +
            this.growExperience +
            "/" +
            this.location +
            "/" +
            this.pokemon +
            "/" +
            this.spellIds;
    }
    parseName(name) {
        this.name = name;
        if (name.includes("(") && name.includes(")")) {
            this.code = StringUtils_1.default.substringBetween(name, "(", ")");
        }
    }
    get nameHtml() {
        if (!this.name)
            return this.name;
        if (!this.pokemon)
            return this.name;
        if (!SetupLoader_1.default.isPokemonWikiEnabled())
            return this.name;
        return "<a href='https://wiki.52poke.com/wiki/" + encodeURI(this.pokemon) + "' " +
            "target='_blank' rel='noopener noreferrer'>" +
            this.pokemon + "(" + this.code + ")" +
            "</a>";
    }
    get imageHtml() {
        const src = Constants_1.default.POCKET_DOMAIN + "/image/pet/" + this.picture;
        return "<img src='" + src + "' width='64' height='64' alt='" + this.code + "' style='border-width:0'>";
    }
    get locationText() {
        if (!this.location) {
            return null;
        }
        switch (this.location) {
            case 1:
                return "初森";
            case 2:
                return "中塔";
            case 3:
                return "上洞";
            default:
                return null;
        }
    }
    get spellText() {
        if (!this.spellIds || this.spellIds === "")
            return "";
        const names = [];
        lodash_1.default.split(this.spellIds, ",").forEach(it => {
            const id = lodash_1.default.parseInt(it);
            const name = MonsterSpellLoader_1.default.getSpellName(id);
            if (name)
                names.push(name);
        });
        return lodash_1.default.join(names, " ");
    }
    get totalBaseStats() {
        return this.healthBaseStats +
            this.attackBaseStats +
            this.defenseBaseStats +
            this.specialAttackBaseStats +
            this.specialDefenseBaseStats +
            this.speedBaseStats;
    }
    get totalEffort() {
        return this.healthEffort +
            this.attackEffort +
            this.defenseEffort +
            this.specialAttackEffort +
            this.specialDefenseEffort +
            this.speedEffort;
    }
    get perfectHealth() {
        const max = 20 + (this.healthEffort * 10);
        const init = (this.healthBaseStats * 20) + 40;
        const incr = (max / 2) * 99;
        return Math.ceil(init + incr);
    }
    get perfectAttack() {
        const max = this.attackEffort + 1;
        const init = (this.attackBaseStats * 2) + 40;
        const incr = (max / 2) * 99;
        return Math.ceil(init + incr);
    }
    get perfectDefense() {
        const max = this.defenseEffort + 1;
        const init = (this.defenseBaseStats * 2) + 40;
        const incr = (max / 2) * 99;
        return Math.ceil(init + incr);
    }
    get perfectSpecialAttack() {
        const max = this.specialAttackEffort + 1;
        const init = (this.specialAttackBaseStats * 2) + 40;
        const incr = (max / 2) * 99;
        return Math.ceil(init + incr);
    }
    get perfectSpecialDefense() {
        const max = this.specialDefenseEffort + 1;
        const init = (this.specialDefenseBaseStats * 2) + 40;
        const incr = (max / 2) * 99;
        return Math.ceil(init + incr);
    }
    get perfectSpeed() {
        const max = this.speedEffort + 1;
        const init = (this.speedBaseStats * 2) + 40;
        const incr = (max / 2) * 99;
        return Math.ceil(init + incr);
    }
    get perfectCapacity() {
        return Math.floor(this.perfectHealth / 3) +
            this.perfectAttack +
            this.perfectDefense +
            this.perfectSpecialAttack +
            this.perfectSpecialDefense +
            this.perfectSpeed;
    }
}
module.exports = MonsterProfile;


/***/ }),
/* 20 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const StorageUtils_1 = __importDefault(__webpack_require__(21));
class SetupLoader {
    static isPokemonWikiEnabled() {
        return StorageUtils_1.default.getBoolean("_pa_001");
    }
    static getLodgeHealthLostRatio() {
        return StorageUtils_1.default.getFloat("_pa_002", 0.6);
    }
    static getLodgeManaLostPoint() {
        return StorageUtils_1.default.getInt("_pa_003", 100);
    }
    static getRepairMinLimitation() {
        return StorageUtils_1.default.getInt("_pa_004", 100);
    }
    static getDepositBattleCount() {
        return StorageUtils_1.default.getInt("_pa_005", 10);
    }
    static isCareerTransferEntranceDisabled(id) {
        return StorageUtils_1.default.getBoolean("_pa_014_" + id);
    }
    static loadEquipmentSet_A(id) {
        const s = StorageUtils_1.default.getString("_pa_019_" + id);
        if (s === "") {
            const value = {};
            // @ts-ignore
            value["weaponName"] = "NONE";
            // @ts-ignore
            value["armorName"] = "NONE";
            // @ts-ignore
            value["accessoryName"] = "NONE";
            return value;
        }
        else {
            return JSON.parse(s);
        }
    }
    static loadEquipmentSet_B(id) {
        const s = StorageUtils_1.default.getString("_pa_020_" + id);
        if (s === "") {
            const value = {};
            // @ts-ignore
            value["weaponName"] = "NONE";
            // @ts-ignore
            value["armorName"] = "NONE";
            // @ts-ignore
            value["accessoryName"] = "NONE";
            return value;
        }
        else {
            return JSON.parse(s);
        }
    }
    static loadEquipmentSet_C(id) {
        const s = StorageUtils_1.default.getString("_pa_021_" + id);
        if (s === "") {
            const value = {};
            // @ts-ignore
            value["weaponName"] = "NONE";
            // @ts-ignore
            value["armorName"] = "NONE";
            // @ts-ignore
            value["accessoryName"] = "NONE";
            return value;
        }
        else {
            return JSON.parse(s);
        }
    }
    static loadEquipmentSet_D(id) {
        const s = StorageUtils_1.default.getString("_pa_022_" + id);
        if (s === "") {
            const value = {};
            // @ts-ignore
            value["weaponName"] = "NONE";
            // @ts-ignore
            value["armorName"] = "NONE";
            // @ts-ignore
            value["accessoryName"] = "NONE";
            return value;
        }
        else {
            return JSON.parse(s);
        }
    }
    static loadEquipmentSet_E(id) {
        const s = StorageUtils_1.default.getString("_pa_023_" + id);
        if (s === "") {
            const value = {};
            // @ts-ignore
            value["weaponName"] = "NONE";
            // @ts-ignore
            value["armorName"] = "NONE";
            // @ts-ignore
            value["accessoryName"] = "NONE";
            return value;
        }
        else {
            return JSON.parse(s);
        }
    }
    static getBattleHarvestPrompt() {
        const s = StorageUtils_1.default.getString("_pa_024");
        if (s === "") {
            const value = {};
            // @ts-ignore
            value["person"] = "NONE";
            // @ts-ignore
            value["text"] = "";
            return value;
        }
        else {
            return JSON.parse(s);
        }
    }
    static getNormalBattlePrompt() {
        const s = StorageUtils_1.default.getString("_pa_025");
        if (s === "") {
            const value = {};
            // @ts-ignore
            value["person"] = "NONE";
            // @ts-ignore
            value["text"] = "";
            return value;
        }
        else {
            return JSON.parse(s);
        }
    }
    static isExperienceProgressBarEnabled() {
        return StorageUtils_1.default.getBoolean("_pa_026");
    }
    static isHiddenLeaveAndExitEnabled() {
        return StorageUtils_1.default.getBoolean("_pa_028");
    }
    static isCollectTownTaxDisabled() {
        return StorageUtils_1.default.getBoolean("_pa_030");
    }
    static isAsciiTextButtonEnabled() {
        return StorageUtils_1.default.getBoolean("_pa_035");
    }
    static getEnlargeBattleRatio() {
        return StorageUtils_1.default.getFloat("_pa_036", -1);
    }
    static isConsecrateStateRecognizeEnabled(id) {
        return StorageUtils_1.default.getBoolean("_pa_037_" + id);
    }
    static isEquipmentPetSortEnabled() {
        return StorageUtils_1.default.getBoolean("_pa_038");
    }
    static getTownDashboardShortcutButton() {
        return StorageUtils_1.default.getInt("_pa_041", -1);
    }
    static getTownDashboardMainButton() {
        return StorageUtils_1.default.getInt("_pa_054", 0);
    }
    static getTownDashboardExtensionShortcutButton() {
        return StorageUtils_1.default.getInt("_pa_050", 1);
    }
    static getLoginPageLayout() {
        return StorageUtils_1.default.getInt("_pa_042", 0);
    }
    static isHideCountryInformationEnabled() {
        return StorageUtils_1.default.getBoolean("_pa_043");
    }
    static isOnlyConsecrateInitialPetEnabled() {
        return StorageUtils_1.default.getBoolean("_pa_044");
    }
    static isQiHanTitleEnabled() {
        return StorageUtils_1.default.getBoolean("_pa_048");
    }
}
module.exports = SetupLoader;


/***/ }),
/* 21 */
/***/ ((module) => {

"use strict";

class StorageUtils {
    static set(key, value) {
        localStorage.setItem(key, value);
    }
    static get(key) {
        return localStorage.getItem(key);
    }
    static remove(key) {
        localStorage.removeItem(key);
    }
    static getString(key) {
        const value = StorageUtils.get(key);
        if (value === undefined ||
            value === null ||
            value === "undefined" ||
            value === "null") {
            return "";
        }
        return value;
    }
    static getBoolean(key) {
        const value = StorageUtils.getString(key);
        if (value === "") {
            return false;
        }
        return value !== "0";
    }
    static getInt(key, defaultValue) {
        const value = StorageUtils.getString(key);
        if (value === "") {
            return defaultValue;
        }
        return parseInt(value);
    }
    static getFloat(key, defaultValue) {
        const value = StorageUtils.getString(key);
        if (value === "") {
            return defaultValue;
        }
        return parseFloat(value);
    }
}
module.exports = StorageUtils;


/***/ }),
/* 22 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
class MonsterSpellLoader {
    static getSpellName(id) {
        if (!id)
            return null;
        // @ts-ignore
        const name = SPELLS[id];
        return name ? name : null;
    }
    static findBySpellName(name) {
        if (!name)
            return null;
        let id = null;
        for (const it of Object.keys(SPELLS)) {
            // @ts-ignore
            const value = SPELLS[it];
            if (value === name) {
                id = lodash_1.default.parseInt(it);
                break;
            }
        }
        return id;
    }
}
const SPELLS = {
    1: "三角攻击",
    2: "三连踢",
    3: "下马威",
    4: "临别礼物",
    5: "乱抓",
    6: "乱突",
    7: "二段踢",
    8: "亚空间弹",
    9: "交叉剪",
    10: "亿万冲击波",
    11: "亿万威力吸取",
    12: "仿制",
    13: "体格强化",
    14: "佯攻",
    15: "保护",
    16: "保护色",
    17: "信号光线",
    18: "假哭",
    19: "偷",
    20: "偷换",
    21: "偷袭",
    22: "催眠术",
    23: "催眠粉",
    24: "充电",
    25: "先发制人",
    26: "光之壁",
    27: "光合成",
    28: "光壁",
    29: "光栅净化",
    30: "克制",
    31: "八叶斩",
    32: "冥想",
    33: "冰冻拳",
    34: "冰冻风",
    35: "冰柱针",
    36: "冰球",
    37: "冰结之风",
    38: "冰雹",
    39: "冷冻光线",
    40: "冷冻拳",
    41: "刀背打",
    42: "刀背斩",
    43: "刃叶斩",
    44: "分担痛苦",
    45: "切裂",
    46: "制裁飞砾",
    47: "剑之舞",
    48: "剧毒",
    49: "剧毒之牙",
    50: "剪刀断头台",
    51: "劈斩",
    52: "力量宝石",
    53: "勒住",
    54: "十万伏特",
    55: "十字切",
    56: "升天拳",
    57: "卷紧",
    58: "压制",
    59: "原始力量",
    60: "双刃头槌",
    61: "双重攻击",
    62: "双针",
    63: "双飞踢",
    64: "反击",
    65: "反射盾",
    66: "变圆",
    67: "变小",
    68: "变方",
    69: "变硬",
    70: "变身",
    71: "叩打",
    72: "叫声",
    73: "可疑光",
    74: "叶刃",
    75: "叶暴雨",
    76: "同旅",
    77: "吐丝",
    78: "吵闹",
    79: "吸取",
    80: "吸收",
    81: "吸血",
    82: "吹飞(地球)",
    83: "吼叫(地球)",
    84: "咬咬",
    85: "咬碎",
    86: "哈欠",
    87: "唱歌",
    88: "啄",
    89: "啮咬",
    90: "啮碎",
    91: "喷水",
    92: "喷火",
    93: "喷烟",
    94: "嗅觉",
    95: "噩梦",
    96: "噪音",
    97: "回击",
    98: "回复指令",
    99: "回旋踢",
    100: "围攻",
    101: "圣炎",
    102: "地狱车",
    103: "地球投",
    104: "地裂",
    105: "地震",
    106: "垂死挣扎",
    107: "埋伏",
    108: "墨汁炮",
    109: "复仇",
    110: "夜影",
    111: "大地之力",
    112: "大字火",
    113: "大文字火",
    114: "大爆炸",
    115: "大钳槌",
    116: "天使之吻",
    117: "天使吻",
    118: "天升拳",
    119: "天气球",
    120: "太阳光线",
    121: "头槌",
    122: "头突",
    123: "夹",
    124: "媚惑",
    125: "宇宙力量",
    126: "宇宙能量",
    127: "守护",
    128: "寄生种子",
    129: "寒冰牙",
    130: "寻衅",
    131: "导弹针",
    132: "封印",
    133: "封印回复",
    134: "尖刺加农炮",
    135: "尖角钻",
    136: "属性切换",
    137: "属性切换2",
    138: "岩崩",
    139: "岩石封印",
    140: "岩石封杀",
    141: "岩石崩塌",
    142: "岩石巨炮",
    143: "岩石爆破",
    144: "崩击之爪",
    145: "帅尾",
    146: "帮手",
    147: "弹跳",
    148: "强夺",
    149: "当身投",
    150: "影击",
    151: "影分身",
    152: "影子球",
    153: "影遁",
    154: "往复拍打",
    155: "心灵交换",
    156: "心灵斩",
    157: "心眼",
    158: "必杀门牙",
    159: "忍耐",
    160: "快击",
    161: "念力",
    162: "怒之门牙",
    163: "思念头槌",
    164: "怠惰",
    165: "怨念",
    166: "怪异光",
    167: "怪异旋风",
    168: "恐惧颜",
    169: "恨",
    170: "恶梦",
    171: "恶颜",
    172: "恶魔之吻",
    173: "惊吓",
    174: "惩罚",
    175: "愈之铃",
    176: "愤怒",
    177: "愤怒门牙",
    178: "慧星拳",
    179: "懈怠",
    180: "戏法",
    181: "扎根",
    182: "打倒",
    183: "打落",
    184: "扔沙",
    185: "扣押",
    186: "抓",
    187: "抓击",
    188: "投掷",
    189: "投蛋",
    190: "折弯匙子",
    191: "折磨",
    192: "报恩",
    193: "拍打",
    194: "招财猫",
    195: "拨沙",
    196: "挑拨",
    197: "挖洞(地球)",
    198: "挠痒",
    199: "挡路",
    200: "挣扎",
    201: "换装",
    202: "掐碎",
    203: "接力棒",
    204: "摇尾巴",
    205: "摇手指",
    206: "撒娇",
    207: "撒气",
    208: "撒泥浆",
    209: "撒菱",
    210: "撞击",
    211: "攀瀑(地球)",
    212: "攻击指令",
    213: "放晴",
    214: "放电",
    215: "新月之舞",
    216: "旋风",
    217: "日本晴",
    218: "时间咆哮",
    219: "暗影拳",
    220: "暗影爪",
    221: "暗影球",
    222: "暴走",
    223: "暴风雪",
    224: "替身",
    225: "最终保存",
    226: "最终保留",
    227: "月之光",
    228: "月光",
    229: "朝之阳",
    230: "木叶槌",
    231: "未来预知",
    232: "束缚",
    233: "极光光线",
    234: "极光束",
    235: "栅栏",
    236: "梦话",
    237: "棉花孢子",
    238: "榨取",
    239: "模仿",
    240: "歌唱",
    241: "殊途同归",
    242: "毒刺",
    243: "毒十字斩",
    244: "毒尾巴",
    245: "毒烟",
    246: "毒粉",
    247: "毒菱",
    248: "毒针",
    249: "毒雾",
    250: "气合拳",
    251: "气象球",
    252: "水之尾",
    253: "水之波动",
    254: "水枪",
    255: "水波动",
    256: "水流喷射",
    257: "沙尘暴",
    258: "沙陷阱",
    259: "治愈愿望",
    260: "泡沫光线",
    261: "泡泡",
    262: "泡泡光线",
    263: "波导弹",
    264: "泥攻击",
    265: "泥浆喷射",
    266: "泥浆炸弹",
    267: "泥爆弹",
    268: "流星",
    269: "浊流",
    270: "海潮",
    271: "液体圈",
    272: "清醒",
    273: "清醒击",
    274: "溶化",
    275: "溶解液",
    276: "滚动",
    277: "漩涡",
    278: "潜水",
    279: "激鳞",
    280: "火炎拳",
    281: "火炎放射",
    282: "火炎车",
    283: "火焰拳",
    284: "火焰放射",
    285: "火焰漩涡",
    286: "火焰牙",
    287: "火焰车",
    288: "火箭头突",
    289: "火花",
    290: "火花踢",
    291: "火苗",
    292: "灭亡之歌",
    293: "炎之涡",
    294: "点穴",
    295: "烈焰突击",
    296: "烟幕",
    297: "烟雾",
    298: "烦恼种子",
    299: "热风",
    300: "焚风",
    301: "煽动",
    302: "熔岩风暴",
    303: "燕返",
    304: "爆炎踢",
    305: "爆裂拳",
    306: "猫之手",
    307: "猫手",
    308: "猫袭",
    309: "玩水",
    310: "玩泥",
    311: "瑜珈之形",
    312: "瑜迦姿势",
    313: "瓦割",
    314: "生蛋(地球)",
    315: "生长",
    316: "甩尾",
    317: "电光石火",
    318: "电击",
    319: "电击波",
    320: "电气震",
    321: "电火花",
    322: "电磁波",
    323: "电磁浮游",
    324: "电磁炮",
    325: "痊愈铃",
    326: "痛苦平分",
    327: "白雾",
    328: "百万吨拳击",
    329: "百万吨级强踢",
    330: "百万吨级铁拳",
    331: "百万大角",
    332: "百万威力吸取",
    333: "百万威力角突",
    334: "盗窃",
    335: "真空斩",
    336: "真空波",
    337: "眩晕之舞",
    338: "眩晕拳",
    339: "眩晕舞",
    340: "着迷",
    341: "睡眠",
    342: "瞑想",
    343: "瞪眼",
    344: "瞬间移动(地球)",
    345: "石刃",
    346: "砂地狱",
    347: "砂岚",
    348: "破坏光线",
    349: "破灭之愿",
    350: "破碎爪",
    351: "磁力变化",
    352: "磁力炸弹",
    353: "礼物",
    354: "祈祷",
    355: "祈雨",
    356: "神秘的守护",
    357: "神通力",
    358: "神速",
    359: "神鸟",
    360: "禁止通行(地球)",
    361: "种子机枪",
    362: "种子爆弹",
    363: "种子闪光弹",
    364: "空中爆破",
    365: "空元气",
    366: "空手切",
    367: "空气切",
    368: "突张",
    369: "突进",
    370: "粉雪",
    371: "精神光线",
    372: "精神制动",
    373: "精神回复",
    374: "精神增压",
    375: "精神干扰",
    376: "精神波动",
    377: "精神转移",
    378: "素描",
    379: "索要",
    380: "细雪",
    381: "绝对零度",
    382: "缠绕",
    383: "缩壳",
    384: "羽毛之舞",
    385: "翅膀拍击",
    386: "翅膀攻击",
    387: "聚气",
    388: "能量储存",
    389: "能量吸入",
    390: "能量吸收",
    391: "能量喷发",
    392: "能量放出",
    393: "能量球",
    394: "腹太鼓",
    395: "腹鼓",
    396: "自我再生",
    397: "自我暗示",
    398: "自然力量",
    399: "自然恩惠",
    400: "自爆",
    401: "舌头舔",
    402: "舌舔",
    403: "舍身一击",
    404: "色彩拳",
    405: "色诱幻术",
    406: "花瓣之舞",
    407: "芳香气味",
    408: "芳香治疗",
    409: "芳香疗法",
    410: "苏醒",
    411: "英勇之鸟",
    412: "草笛",
    413: "莽撞",
    414: "萤火",
    415: "落石",
    416: "蓄气",
    417: "蔓藤鞭",
    418: "蘑菇孢子",
    419: "虚伪空间",
    420: "虚张声势",
    421: "虫蛀",
    422: "虫鸣",
    423: "虹彩炮",
    424: "蛇瞪眼",
    425: "蛋蛋爆弹",
    426: "蛮力",
    427: "蛮力藤鞭",
    428: "蜘蛛丝(地球)",
    429: "蜻蜓点水",
    430: "融化",
    431: "螺旋球",
    432: "见切",
    433: "觉醒力量",
    434: "角撞",
    435: "角突",
    436: "讨厌的声音",
    437: "许愿",
    438: "诅咒",
    439: "识破",
    440: "试刃",
    441: "话匣子",
    442: "请别打我",
    443: "贝壳夹",
    444: "起死回生",
    445: "起风",
    446: "超级健忘",
    447: "超级尖牙",
    448: "超音波",
    449: "践踏",
    450: "躲进贝壳",
    451: "过肩摔",
    452: "近身拳",
    453: "远吠",
    454: "连续切",
    455: "连续拍打",
    456: "连续拳",
    457: "迷雾球",
    458: "追击",
    459: "逆鳞",
    460: "道具回收",
    461: "重力场",
    462: "重臂槌",
    463: "金属声音",
    464: "金属爆破",
    465: "金属音",
    466: "针刺臂膀",
    467: "钢之尾",
    468: "钢之爪",
    469: "钢之翼",
    470: "钢爪",
    471: "钢铁头槌",
    472: "钻孔啄",
    473: "铁壁",
    474: "银色之风",
    475: "银色旋风",
    476: "锁定",
    477: "镜像反射",
    478: "镜面反射",
    479: "镜面射击",
    480: "镰鼬",
    481: "闪电",
    482: "闪电拳",
    483: "防御指令",
    484: "阴谋",
    485: "雷典牙",
    486: "雷电拳",
    487: "雷电牙",
    488: "震级变化",
    489: "音速拳",
    490: "音速波",
    491: "预知未来",
    492: "飘飘拳",
    493: "飞叶斩",
    494: "飞弹针",
    495: "飞空(地球)",
    496: "飞膝踢",
    497: "飞跃",
    498: "飞踢",
    499: "食梦",
    500: "饮奶(地球)",
    501: "香甜气息",
    502: "骨头击",
    503: "骨头回旋镖",
    504: "骨头突刺",
    505: "骨头闪",
    506: "高压水泵",
    507: "高速旋转",
    508: "高速星",
    509: "高速移动",
    510: "高音",
    511: "鬼火",
    512: "魔叶斩",
    513: "魔法叶",
    514: "魔法衣",
    515: "魔装反射",
    516: "鸟栖",
    517: "鹦鹉学舌",
    518: "麻痹粉",
    519: "黑夜魔影",
    520: "黑暗波动",
    521: "黑洞",
    522: "黑眼神(地球)",
    523: "黑雾",
    524: "鼓掌",
    525: "鼾声",
    526: "龙之怒",
    527: "龙之息吹",
    528: "龙之爪",
    529: "龙之舞",
    530: "龙卷",
    531: "龙气息",
    532: "龙波动",
    533: "龙遁"
};
module.exports = MonsterSpellLoader;


/***/ }),
/* 23 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PalaceTask_1 = __importDefault(__webpack_require__(24));
class PalaceTaskStorage {
    static getInstance() {
        return instance;
    }
    load(id) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db
                        .transaction(["PalaceTask"], "readonly")
                        .objectStore("PalaceTask")
                        .get(id);
                    request.onerror = reject;
                    request.onsuccess = () => {
                        if (request.result) {
                            const data = new PalaceTask_1.default();
                            data.id = request.result.id;
                            data.updateTime = request.result.updateTime;
                            data.monster = request.result.monster;
                            resolve(data);
                        }
                        else {
                            resolve(null);
                        }
                    };
                });
            })();
        });
    }
    updateMonsterTask(roleId, monsterName) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    this.load(roleId)
                        .then(task => {
                        let data;
                        if (task !== null) {
                            data = task.asObject();
                            // @ts-ignore
                            data.updateTime = new Date().getTime();
                            // @ts-ignore
                            data.monster = monsterName + "/0";
                        }
                        else {
                            data = {
                                id: roleId,
                                updateTime: new Date().getTime(),
                                monster: monsterName + "/0"
                            };
                        }
                        const request = db
                            .transaction(["PalaceTask"], "readwrite")
                            .objectStore("PalaceTask")
                            .put(data);
                        request.onerror = reject;
                        request.onsuccess = () => resolve();
                    });
                });
            })();
        });
    }
    completeMonsterTask(roleId) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    this.load(roleId)
                        .then(task => {
                        if (task !== null) {
                            const data = task.asObject();
                            // @ts-ignore
                            data.updateTime = new Date().getTime();
                            // @ts-ignore
                            const monster = data.monster;
                            const monsterName = StringUtils_1.default.substringBefore(monster, "/");
                            // @ts-ignore
                            data.monster = monsterName + "/1";
                            const request = db
                                .transaction(["PalaceTask"], "readwrite")
                                .objectStore("PalaceTask")
                                .put(data);
                            request.onerror = reject;
                            request.onsuccess = () => resolve();
                        }
                    });
                });
            })();
        });
    }
    finishMonsterTask(roleId) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    this.load(roleId)
                        .then(task => {
                        if (task !== null) {
                            const data = task.asObject();
                            // @ts-ignore
                            data.updateTime = new Date().getTime();
                            // @ts-ignore
                            delete data.monster;
                            const request = db
                                .transaction(["PalaceTask"], "readwrite")
                                .objectStore("PalaceTask")
                                .put(data);
                            request.onerror = reject;
                            request.onsuccess = () => resolve();
                        }
                    });
                });
            })();
        });
    }
}
const instance = new PalaceTaskStorage();
module.exports = PalaceTaskStorage;


/***/ }),
/* 24 */
/***/ ((module) => {

"use strict";

class PalaceTask {
    asObject() {
        const obj = {};
        // @ts-ignore
        obj.id = this.id;
        // @ts-ignore
        obj.updateTime = this.updateTime;
        if (this.monster !== undefined) {
            // @ts-ignore
            obj.monster = this.monster;
        }
        return obj;
    }
}
module.exports = PalaceTask;


/***/ }),
/* 25 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const bson_objectid_1 = __importDefault(__webpack_require__(26));
const MonsterProfileLoader_1 = __importDefault(__webpack_require__(18));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
class BattleLog {
    initialize() {
        if (this.id === undefined) {
            this.id = (0, bson_objectid_1.default)().toHexString();
        }
        if (this.createTime === undefined) {
            this.createTime = new Date().getTime();
        }
        return this;
    }
    asObject() {
        const obj = {};
        // @ts-ignore
        obj.id = this.id;
        // @ts-ignore
        obj.createTime = this.createTime;
        if (this.roleId !== undefined) {
            // @ts-ignore
            obj.roleId = this.roleId;
        }
        if (this.monster !== undefined) {
            // @ts-ignore
            obj.monster = this.monster;
        }
        if (this.result !== undefined) {
            // @ts-ignore
            obj.result = this.result;
        }
        if (this.catch !== undefined) {
            // @ts-ignore
            obj.catch = this.catch;
        }
        if (this.photo !== undefined) {
            // @ts-ignore
            obj.photo = this.photo;
        }
        if (this.treasures !== undefined) {
            // @ts-ignore
            obj.treasures = {};
            this.treasures.forEach((v, k) => {
                // @ts-ignore
                obj.treasures[k] = v;
            });
        }
        return obj;
    }
    get obtainBattleField() {
        var _a;
        if (this.monster === "博丽灵梦") {
            return "上洞";
        }
        if (NpcLoader_1.default.getZodiacNpcNames().includes(this.monster)) {
            return "十二宫";
        }
        let location = (_a = MonsterProfileLoader_1.default.load(this.monster)) === null || _a === void 0 ? void 0 : _a.locationText;
        return location ? location : "未知(" + this.monster + ")";
    }
}
module.exports = BattleLog;


/***/ }),
/* 26 */
/***/ ((module) => {


var MACHINE_ID = Math.floor(Math.random() * 0xFFFFFF);
var index = ObjectID.index = parseInt(Math.random() * 0xFFFFFF, 10);
var pid = (typeof process === 'undefined' || typeof process.pid !== 'number' ? Math.floor(Math.random() * 100000) : process.pid) % 0xFFFF;
// <https://github.com/williamkapke/bson-objectid/pull/51>
// Attempt to fallback Buffer if _Buffer is undefined (e.g. for Node.js).
// Worst case fallback to null and handle with null checking before using.
var BufferCtr = (() => { try { return _Buffer; }catch(_){ try{ return Buffer; }catch(_){ return null; } } })();

/**
 * Determine if an object is Buffer
 *
 * Author:   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
 * License:  MIT
 *
 */
var isBuffer = function (obj) {
  return !!(
  obj != null &&
  obj.constructor &&
  typeof obj.constructor.isBuffer === 'function' &&
  obj.constructor.isBuffer(obj)
  )
};

// Precomputed hex table enables speedy hex string conversion
var hexTable = [];
for (var i = 0; i < 256; i++) {
  hexTable[i] = (i <= 15 ? '0' : '') + i.toString(16);
}

// Regular expression that checks for hex value
var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');

// Lookup tables
var decodeLookup = [];
i = 0;
while (i < 10) decodeLookup[0x30 + i] = i++;
while (i < 16) decodeLookup[0x41 - 10 + i] = decodeLookup[0x61 - 10 + i] = i++;

/**
 * Create a new immutable ObjectID instance
 *
 * @class Represents the BSON ObjectID type
 * @param {String|Number} id Can be a 24 byte hex string, 12 byte binary string or a Number.
 * @return {Object} instance of ObjectID.
 */
function ObjectID(id) {
  if(!(this instanceof ObjectID)) return new ObjectID(id);
  if(id && ((id instanceof ObjectID) || id._bsontype==="ObjectID"))
    return id;

  this._bsontype = 'ObjectID';

  // The most common usecase (blank id, new objectId instance)
  if (id == null || typeof id === 'number') {
    // Generate a new id
    this.id = this.generate(id);
    // Return the object
    return;
  }

  // Check if the passed in id is valid
  var valid = ObjectID.isValid(id);

  // Throw an error if it's not a valid setup
  if (!valid && id != null) {
    throw new Error(
      'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'
    );
  } else if (valid && typeof id === 'string' && id.length === 24) {
    return ObjectID.createFromHexString(id);
  } else if (id != null && id.length === 12) {
    // assume 12 byte string
    this.id = id;
  } else if (id != null && typeof id.toHexString === 'function') {
    // Duck-typing to support ObjectId from different npm packages
    return id;
  } else {
    throw new Error(
      'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'
    );
  }
}
module.exports = ObjectID;
ObjectID.default = ObjectID;

/**
 * Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID.
 *
 * @param {Number} time an integer number representing a number of seconds.
 * @return {ObjectID} return the created ObjectID
 * @api public
 */
ObjectID.createFromTime = function(time){
  time = parseInt(time, 10) % 0xFFFFFFFF;
  return new ObjectID(hex(8,time)+"0000000000000000");
};

/**
 * Creates an ObjectID from a hex string representation of an ObjectID.
 *
 * @param {String} hexString create a ObjectID from a passed in 24 byte hexstring.
 * @return {ObjectID} return the created ObjectID
 * @api public
 */
ObjectID.createFromHexString = function(hexString) {
  // Throw an error if it's not a valid setup
  if (typeof hexString === 'undefined' || (hexString != null && hexString.length !== 24)) {
    throw new Error(
      'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'
    );
  }

  // Calculate lengths
  var data = '';
  var i = 0;

  while (i < 24) {
    data += String.fromCharCode((decodeLookup[hexString.charCodeAt(i++)] << 4) | decodeLookup[hexString.charCodeAt(i++)]);
  }

  return new ObjectID(data);
};

/**
 * Checks if a value is a valid bson ObjectId
 *
 * @param {String} objectid Can be a 24 byte hex string or an instance of ObjectID.
 * @return {Boolean} return true if the value is a valid bson ObjectID, return false otherwise.
 * @api public
 *
 * THE NATIVE DOCUMENTATION ISN'T CLEAR ON THIS GUY!
 * http://mongodb.github.io/node-mongodb-native/api-bson-generated/objectid.html#objectid-isvalid
 */
ObjectID.isValid = function(id) {
  if (id == null) return false;

  if (typeof id === 'number') {
    return true;
  }

  if (typeof id === 'string') {
    return id.length === 12 || (id.length === 24 && checkForHexRegExp.test(id));
  }

  if (id instanceof ObjectID) {
    return true;
  }

  // <https://github.com/williamkapke/bson-objectid/issues/53>
  if (isBuffer(id)) {
    return ObjectID.isValid(id.toString('hex'));
  }

  // Duck-Typing detection of ObjectId like objects
  // <https://github.com/williamkapke/bson-objectid/pull/51>
  if (typeof id.toHexString === 'function') {
    if(
      BufferCtr &&
      (id.id instanceof BufferCtr || typeof id.id === 'string')
    ) {
      return id.id.length === 12 || (id.id.length === 24 && checkForHexRegExp.test(id.id));
    }
  }

  return false;
};

ObjectID.prototype = {
  constructor: ObjectID,

  /**
   * Return the ObjectID id as a 24 byte hex string representation
   *
   * @return {String} return the 24 byte hex string representation.
   * @api public
   */
  toHexString: function() {
    if (!this.id || !this.id.length) {
      throw new Error(
        'invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is [' +
          JSON.stringify(this.id) +
          ']'
      );
    }

    if (this.id.length === 24) {
      return this.id;
    }

    if (isBuffer(this.id)) {
      return this.id.toString('hex')
    }

    var hexString = '';
    for (var i = 0; i < this.id.length; i++) {
      hexString += hexTable[this.id.charCodeAt(i)];
    }

    return hexString;
  },

  /**
   * Compares the equality of this ObjectID with `otherID`.
   *
   * @param {Object} otherId ObjectID instance to compare against.
   * @return {Boolean} the result of comparing two ObjectID's
   * @api public
   */
  equals: function (otherId){
    if (otherId instanceof ObjectID) {
      return this.toString() === otherId.toString();
    } else if (
      typeof otherId === 'string' &&
      ObjectID.isValid(otherId) &&
      otherId.length === 12 &&
      isBuffer(this.id)
    ) {
      return otherId === this.id.toString('binary');
    } else if (typeof otherId === 'string' && ObjectID.isValid(otherId) && otherId.length === 24) {
      return otherId.toLowerCase() === this.toHexString();
    } else if (typeof otherId === 'string' && ObjectID.isValid(otherId) && otherId.length === 12) {
      return otherId === this.id;
    } else if (otherId != null && (otherId instanceof ObjectID || otherId.toHexString)) {
      return otherId.toHexString() === this.toHexString();
    } else {
      return false;
    }
  },

  /**
   * Returns the generation date (accurate up to the second) that this ID was generated.
   *
   * @return {Date} the generation date
   * @api public
   */
  getTimestamp: function(){
    var timestamp = new Date();
    var time;
    if (isBuffer(this.id)) {
      time = this.id[3] | (this.id[2] << 8) | (this.id[1] << 16) | (this.id[0] << 24);
    } else {
      time = this.id.charCodeAt(3) | (this.id.charCodeAt(2) << 8) | (this.id.charCodeAt(1) << 16) | (this.id.charCodeAt(0) << 24);
    }
    timestamp.setTime(Math.floor(time) * 1000);
    return timestamp;
  },

  /**
  * Generate a 12 byte id buffer used in ObjectID's
  *
  * @method
  * @param {number} [time] optional parameter allowing to pass in a second based timestamp.
  * @return {string} return the 12 byte id buffer string.
  */
  generate: function (time) {
    if ('number' !== typeof time) {
      time = ~~(Date.now() / 1000);
    }

    //keep it in the ring!
    time = parseInt(time, 10) % 0xFFFFFFFF;

    var inc = next();

    return String.fromCharCode(
      ((time >> 24) & 0xFF),
      ((time >> 16) & 0xFF),
      ((time >> 8) & 0xFF),
      (time & 0xFF),
      ((MACHINE_ID >> 16) & 0xFF),
      ((MACHINE_ID >> 8) & 0xFF),
      (MACHINE_ID & 0xFF),
      ((pid >> 8) & 0xFF),
      (pid & 0xFF),
      ((inc >> 16) & 0xFF),
      ((inc >> 8) & 0xFF),
      (inc & 0xFF)
    )
  },
};

function next() {
  return index = (index+1) % 0xFFFFFF;
}

function hex(length, n) {
  n = n.toString(16);
  return (n.length===length)? n : "00000000".substring(n.length, length) + n;
}

function buffer(str) {
  var i=0,out=[];

  if(str.length===24)
    for(;i<24; out.push(parseInt(str[i]+str[i+1], 16)),i+=2);

  else if(str.length===12)
    for(;i<12; out.push(str.charCodeAt(i)),i++);

  return out;
}

var inspect = (Symbol && Symbol.for && Symbol.for('nodejs.util.inspect.custom')) || 'inspect';

/**
 * Converts to a string representation of this Id.
 *
 * @return {String} return the 24 byte hex string representation.
 * @api private
 */
ObjectID.prototype[inspect] = function() { return "ObjectID("+this+")" };
ObjectID.prototype.toJSON = ObjectID.prototype.toHexString;
ObjectID.prototype.toString = ObjectID.prototype.toHexString;


/***/ }),
/* 27 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Constants_1 = __importDefault(__webpack_require__(11));
const RandomUtils_1 = __importDefault(__webpack_require__(28));
const StringUtils_1 = __importDefault(__webpack_require__(6));
class NpcLoader {
    static getZodiacNpcNames() {
        return ZODIAC_NPC_LIST;
    }
    static getNpcImageHtml(name) {
        // @ts-ignore
        const image = POCKET_NPC_IMAGES[name];
        if (image === undefined) {
            return null;
        }
        let id;
        if (name.startsWith("M_") || name.startsWith("F_") || name.startsWith("U_")) {
            id = name;
        }
        else {
            let s = StringUtils_1.default.substringAfterLast(image, "/");
            id = StringUtils_1.default.substringBefore(s, ".gif");
            id = "p_" + id;
        }
        return "<img src='" + image + "' width='64' height='64' alt='" + name + "' id='" + id + "'>";
    }
    static randomMaleNpcImageHtml() {
        const names = [];
        Object.keys(POCKET_NPC_IMAGES)
            .filter(value => value.startsWith("M_"))
            .forEach(value => names.push(value));
        const name = RandomUtils_1.default.randomElement(names);
        return NpcLoader.getNpcImageHtml(name);
    }
    static randomFemaleNpcImageHtml() {
        const names = [];
        Object.keys(POCKET_NPC_IMAGES)
            .filter(value => value.startsWith("F_"))
            .forEach(value => names.push(value));
        const name = RandomUtils_1.default.randomElement(names);
        return NpcLoader.getNpcImageHtml(name);
    }
    static randomNpcImageHtml() {
        const names = [];
        Object.keys(POCKET_NPC_IMAGES)
            .filter(value => value.startsWith("M_") || value.startsWith("F_") || value.startsWith("U_"))
            .forEach(value => names.push(value));
        const name = RandomUtils_1.default.randomElement(names);
        return NpcLoader.getNpcImageHtml(name);
    }
    static randomPlayerImageHtml() {
        const names = [];
        Object.keys(POCKET_NPC_IMAGES)
            .filter(value => !value.startsWith("M_") && !value.startsWith("F_") && !value.startsWith("U_"))
            .forEach(value => names.push(value));
        const name = RandomUtils_1.default.randomElement(names);
        return NpcLoader.getNpcImageHtml(name);
    }
    static playerNpcNames() {
        const names = [];
        Object.keys(POCKET_NPC_IMAGES)
            .filter(value => !value.startsWith("M_") && !value.startsWith("F_") && !value.startsWith("U_"))
            .forEach(value => names.push(value));
        return names;
    }
    static getTaskNpcImageHtml(name) {
        // @ts-ignore
        const image = POCKET_TASK_NPC_IMAGES[name];
        if (image === undefined) {
            return null;
        }
        let s = StringUtils_1.default.substringAfterLast(image, "/");
        let id = StringUtils_1.default.substringBefore(s, ".");
        id = "n_" + id;
        return "<img src='" + image + "' width='64' height='64' alt='" + name + "' id='" + id + "'>";
    }
}
const ZODIAC_NPC_LIST = [
    "穆",
    "阿鲁迪巴",
    "撒加",
    "迪斯马斯克",
    "艾欧里亚",
    "沙加",
    "童虎",
    "米罗",
    "艾欧罗斯",
    "修罗",
    "卡妙",
    "阿布罗迪",
];
const POCKET_TASK_NPC_IMAGES = {
    "大司徒": Constants_1.default.POCKET_DOMAIN + "/image/npc/684.jpg",
    "大司马": Constants_1.default.POCKET_DOMAIN + "/image/npc/018.jpg",
    "大司空": Constants_1.default.POCKET_DOMAIN + "/image/npc/669.jpg",
    "大司寇": Constants_1.default.POCKET_DOMAIN + "/image/npc/395.jpg",
    "大司农": Constants_1.default.POCKET_DOMAIN + "/image/npc/348.jpg",
    "瓦格纳": Constants_1.default.POCKET_DOMAIN + "/image/npc/005.jpg",
    "吕布": Constants_1.default.POCKET_DOMAIN + "/image/npc/293.jpg",
    "庞统": Constants_1.default.POCKET_DOMAIN + "/image/npc/348.jpg",
    "司马懿": Constants_1.default.POCKET_DOMAIN + "/image/npc/395.jpg",
    "赵云": Constants_1.default.POCKET_DOMAIN + "/image/npc/657.jpg",
    "诸葛亮": Constants_1.default.POCKET_DOMAIN + "/image/npc/684.jpg",
    "蒋干": Constants_1.default.POCKET_DOMAIN + "/image/npc/211.jpg",
    "黄盖": Constants_1.default.POCKET_DOMAIN + "/image/npc/193.jpg",
    "周瑜": Constants_1.default.POCKET_DOMAIN + "/image/npc/669.jpg",
    "曹操": Constants_1.default.POCKET_DOMAIN + "/image/npc/018.jpg",
    "关羽": Constants_1.default.POCKET_DOMAIN + "/image/npc/142.jpg",
    "吕蒙": Constants_1.default.POCKET_DOMAIN + "/image/npc/299.jpg",
    "徐晃": Constants_1.default.POCKET_DOMAIN + "/image/npc/536.jpg",
    "孟获": Constants_1.default.POCKET_DOMAIN + "/image/npc/326.jpg",
    "董荼那": Constants_1.default.POCKET_DOMAIN + "/image/npc/093.jpg",
    "孟优": Constants_1.default.POCKET_DOMAIN + "/image/npc/327.jpg",
    "带来洞主": Constants_1.default.POCKET_DOMAIN + "/image/npc/070.jpg",
    "祝融": Constants_1.default.POCKET_DOMAIN + "/image/npc/688.jpg",
    "黄忠": Constants_1.default.POCKET_DOMAIN + "/image/npc/197.jpg",
    "张飞": Constants_1.default.POCKET_DOMAIN + "/image/npc/611.jpg",
    "马超": Constants_1.default.POCKET_DOMAIN + "/image/npc/306.jpg",
    "孔秀": Constants_1.default.POCKET_DOMAIN + "/image/npc/699.jpg",
    "孟坦": Constants_1.default.POCKET_DOMAIN + "/image/npc/699.jpg",
    "韩福": Constants_1.default.POCKET_DOMAIN + "/image/npc/699.jpg",
    "卞喜": Constants_1.default.POCKET_DOMAIN + "/image/npc/699.jpg",
    "王植": Constants_1.default.POCKET_DOMAIN + "/image/npc/699.jpg",
    "秦琪": Constants_1.default.POCKET_DOMAIN + "/image/npc/699.jpg",
    "东方不败": Constants_1.default.POCKET_DOMAIN + "/image/npc/dfbb.jpg", // 5,10
};
const POCKET_NPC_IMAGES = {
    "M_000": Constants_1.default.POCKET_DOMAIN + "/image/etc/0.gif",
    "M_001": Constants_1.default.POCKET_DOMAIN + "/image/etc/1.gif",
    "M_002": Constants_1.default.POCKET_DOMAIN + "/image/etc/2.gif",
    "M_003": Constants_1.default.POCKET_DOMAIN + "/image/etc/3.gif",
    "M_004": Constants_1.default.POCKET_DOMAIN + "/image/etc/4.gif",
    "M_005": Constants_1.default.POCKET_DOMAIN + "/image/etc/5.gif",
    "M_006": Constants_1.default.POCKET_DOMAIN + "/image/etc/6.gif",
    "M_007": Constants_1.default.POCKET_DOMAIN + "/image/etc/7.gif",
    "M_008": Constants_1.default.POCKET_DOMAIN + "/image/etc/8.gif",
    "M_009": Constants_1.default.POCKET_DOMAIN + "/image/etc/9.gif",
    "M_011": Constants_1.default.POCKET_DOMAIN + "/image/etc/11.gif",
    "M_012": Constants_1.default.POCKET_DOMAIN + "/image/etc/12.gif",
    "M_013": Constants_1.default.POCKET_DOMAIN + "/image/etc/13.gif",
    "M_014": Constants_1.default.POCKET_DOMAIN + "/image/etc/14.gif",
    "M_015": Constants_1.default.POCKET_DOMAIN + "/image/etc/15.gif",
    "M_016": Constants_1.default.POCKET_DOMAIN + "/image/etc/16.gif",
    "M_017": Constants_1.default.POCKET_DOMAIN + "/image/etc/17.gif",
    "M_018": Constants_1.default.POCKET_DOMAIN + "/image/etc/18.gif",
    "M_019": Constants_1.default.POCKET_DOMAIN + "/image/etc/19.gif",
    "M_020": Constants_1.default.POCKET_DOMAIN + "/image/etc/20.gif",
    "M_021": Constants_1.default.POCKET_DOMAIN + "/image/etc/21.gif",
    "M_022": Constants_1.default.POCKET_DOMAIN + "/image/etc/22.gif",
    "M_023": Constants_1.default.POCKET_DOMAIN + "/image/etc/23.gif",
    "F_026": Constants_1.default.POCKET_DOMAIN + "/image/etc/26.gif",
    "F_027": Constants_1.default.POCKET_DOMAIN + "/image/etc/27.gif",
    "F_028": Constants_1.default.POCKET_DOMAIN + "/image/etc/28.gif",
    "F_030": Constants_1.default.POCKET_DOMAIN + "/image/etc/30.gif",
    "F_031": Constants_1.default.POCKET_DOMAIN + "/image/etc/31.gif",
    "F_032": Constants_1.default.POCKET_DOMAIN + "/image/etc/32.gif",
    "F_037": Constants_1.default.POCKET_DOMAIN + "/image/etc/37.gif",
    "F_039": Constants_1.default.POCKET_DOMAIN + "/image/etc/39.gif",
    "F_040": Constants_1.default.POCKET_DOMAIN + "/image/etc/40.gif",
    "U_041": Constants_1.default.POCKET_DOMAIN + "/image/etc/41.gif",
    "夜三": Constants_1.default.POCKET_DOMAIN + "/image/head/1117.gif",
    "花子": Constants_1.default.POCKET_DOMAIN + "/image/head/1126.gif",
    "骨头": Constants_1.default.POCKET_DOMAIN + "/image/head/1160.gif",
    "狐狸": Constants_1.default.POCKET_DOMAIN + "/image/head/1196.gif",
    "七七": Constants_1.default.POCKET_DOMAIN + "/image/head/1368.gif",
    "豚豚": Constants_1.default.POCKET_DOMAIN + "/image/head/1389.gif",
    "夜九": Constants_1.default.POCKET_DOMAIN + "/image/head/1561.gif",
    "剑心": Constants_1.default.POCKET_DOMAIN + "/image/head/2184.gif",
    "飘雪": Constants_1.default.POCKET_DOMAIN + "/image/head/2196.gif",
    "路路": Constants_1.default.POCKET_DOMAIN + "/image/head/2201.gif",
    "饭饭": Constants_1.default.POCKET_DOMAIN + "/image/head/3139.gif",
    "亲戚": Constants_1.default.POCKET_DOMAIN + "/image/head/3188.gif",
    "马可": Constants_1.default.POCKET_DOMAIN + "/image/head/6169.gif",
    "青鸟": Constants_1.default.POCKET_DOMAIN + "/image/head/7184.gif",
    "小明": Constants_1.default.POCKET_DOMAIN + "/image/head/8166.gif",
    "末末": Constants_1.default.POCKET_DOMAIN + "/image/head/8173.gif",
    "白皇": Constants_1.default.POCKET_DOMAIN + "/image/head/11134.gif",
    "莫莫": Constants_1.default.POCKET_DOMAIN + "/image/head/13165.gif",
    "天翔": Constants_1.default.POCKET_DOMAIN + "/image/head/14129.gif",
};
module.exports = NpcLoader;


/***/ }),
/* 28 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
class RandomUtils {
    static randomElement(list) {
        if (list.length === 0) {
            return null;
        }
        if (list.length === 1) {
            return list[0];
        }
        const idx = lodash_1.default.random(0, list.length - 1);
        return list[idx];
    }
}
module.exports = RandomUtils;


/***/ }),
/* 29 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const BattleLog_1 = __importDefault(__webpack_require__(25));
class BattleLogStorage {
    static getInstance() {
        return instance;
    }
    importDocument(document) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    // @ts-ignore
                    const id = document.id;
                    const store = db
                        .transaction(["BattleLog"], "readwrite")
                        .objectStore("BattleLog");
                    const readRequest = store.get(id);
                    readRequest.onerror = reject;
                    readRequest.onsuccess = () => {
                        if (readRequest.result) {
                            // Battle log already exists, ignore.
                            reject();
                        }
                        else {
                            const writeRequest = store.add(document);
                            writeRequest.onerror = reject;
                            writeRequest.onsuccess = () => resolve();
                        }
                    };
                });
            })();
        });
    }
    write(log) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const document = log.asObject();
                    const request = db
                        .transaction(["BattleLog"], "readwrite")
                        .objectStore("BattleLog")
                        .add(document);
                    request.onerror = reject;
                    request.onsuccess = () => resolve();
                });
            })();
        });
    }
    /**
     * Find battle logs by createTime in specified time range.
     * @param start Start time.
     * @param end End time, use current if not specified.
     */
    findByCreateTime(start, end) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    let range;
                    if (end === undefined) {
                        range = IDBKeyRange.lowerBound(start);
                    }
                    else {
                        range = IDBKeyRange.bound(start, end);
                    }
                    const request = db
                        .transaction(["BattleLog"], "readonly")
                        .objectStore("BattleLog")
                        .index("createTime")
                        .getAll(range);
                    request.onerror = reject;
                    request.onsuccess = () => {
                        const logList = [];
                        if (request.result) {
                            request.result.forEach(it => {
                                const log = new BattleLog_1.default();
                                log.id = it.id;
                                log.createTime = it.createTime;
                                log.roleId = it.roleId;
                                log.monster = it.monster;
                                log.result = it.result;
                                log.catch = it.catch;
                                log.photo = it.photo;
                                if (it.treasures) {
                                    log.treasures = new Map();
                                    Object.keys(it.treasures)
                                        .forEach(code => {
                                        const count = it.treasures[code];
                                        log.treasures.set(code, count);
                                    });
                                }
                                logList.push(log);
                            });
                        }
                        resolve(logList);
                    };
                });
            })();
        });
    }
    clear() {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db
                        .transaction(["BattleLog"], "readwrite")
                        .objectStore("BattleLog")
                        .clear();
                    request.onerror = reject;
                    request.onsuccess = () => resolve();
                });
            })();
        });
    }
}
const instance = new BattleLogStorage();
module.exports = BattleLogStorage;


/***/ }),
/* 30 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const BattleDeclarationManager_1 = __importDefault(__webpack_require__(31));
const BattlePage_1 = __importDefault(__webpack_require__(32));
class BattlePageParser {
    static parse(html) {
        return __awaiter(this, void 0, void 0, function* () {
            const page = new BattlePage_1.default();
            let table = $(html)
                .find("img:first")
                .closest("table")
                .parent()
                .closest("table")
                .parent()
                .closest("table");
            let div = table.prev();
            table.find("> tbody:first")
                .find("> tr:eq(3)")
                .find("> td:first")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:first")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:eq(2)")
                .find("> td:first")
                .next()
                .html((idx, html) => {
                page.roleNameHtml = html;
                return html;
            })
                .prev()
                .html((idx, html) => {
                page.roleImageHtml = $("<td>" + html + "</td>")
                    .find("> img:first")
                    .attr("title", page.roleNameHtml)
                    .parent()
                    .html();
                return html;
            });
            table.find("> tbody:first")
                .find("> tr:eq(4)")
                .find("> td:first")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:first")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:eq(2)")
                .find("> td:first")
                .html((idx, html) => {
                page.monsterNameHtml = html;
                return html;
            })
                .parent()
                .find("> td:last")
                .html((idx, html) => {
                page.monsterImageHtml = $("<td>" + html + "</td>")
                    .find("> img:first")
                    .attr("title", page.monsterNameHtml)
                    .attr("alt", page.monsterNameHtml)
                    .parent()
                    .html();
                return html;
            });
            table.find("> tbody:first")
                .find("> tr:first")
                .find("> td:first")
                .find("> font:first")
                .find("> b:first")
                .each((idx, b) => {
                let battleField = $(b).text();
                page.treasureBattle = battleField.includes("秘宝之岛");
                page.primaryBattle = battleField.includes("初级之森");
                page.juniorBattle = battleField.includes("中级之塔");
                page.seniorBattle = battleField.includes("上级之洞窟");
                page.zodiacBattle = battleField.includes("十二神殿");
            });
            let petName = "";
            const endureList = [];
            for (const s of lodash_1.default.split(div.text(), "\n")) {
                if (lodash_1.default.endsWith(s, "耐久度")) {
                    if (!s.includes("大师球") &&
                        !s.includes("宗师球") &&
                        !s.includes("超力怪兽球") &&
                        !s.includes("宠物蛋")) {
                        let t = StringUtils_1.default.substringBetween(s, "剩余", "耐久度");
                        let n = parseInt(t);
                        endureList.push(n);
                    }
                }
                if (lodash_1.default.endsWith(s, "回)")) {
                    let t = StringUtils_1.default.substringBetween(s, "(剩余", "回)");
                    let n = parseInt(t);
                    endureList.push(n);
                }
                if (s.includes(" 获得 ") && s.includes(" 经验值.")) {
                    // 这一行是宠物获得经验值的那一行
                    // 记录下宠物名
                    petName = StringUtils_1.default.substringBefore(s, " 获得 ");
                }
                if (petName !== "") {
                    const searchString = petName + "等级上升!";
                    if (s.includes(searchString)) {
                        page.petUpgrade = true;
                    }
                }
            }
            if (endureList.length > 0) {
                page.lowestEndure = lodash_1.default.min(endureList);
            }
            let battleTable = table
                .find("> tbody:first")
                .find("> tr:eq(5)")
                .find("> td:first")
                .find("> table:first");
            const imgSrcList = [];
            battleTable
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:first")
                .find("> center:first")
                .find("> h1:eq(1)")
                .find("> font:first")
                .find("> b:first")
                .find("> p:first")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr")
                .filter(idx => idx > 1)
                .find("img")
                .each((idx, img) => {
                const src = $(img).attr("src");
                imgSrcList.push(src);
            });
            if (imgSrcList.length === 3) {
                // 在战斗的第一个回合的表格中找到3张图片,说明有宠物
                const roleImageSrc = $(page.roleImageHtml).attr("src");
                const monsterImageSrc = $(page.monsterImageHtml).attr("src");
                let petImageSrc = "";
                for (const imgSrc of imgSrcList) {
                    // 过滤掉角色图片和怪物图片剩下的就是宠物图片
                    if (imgSrc === roleImageSrc || imgSrc === monsterImageSrc) {
                        continue;
                    }
                    petImageSrc = imgSrc;
                }
                if (petImageSrc === "") {
                    // 没有找到?那说明宠物图片和怪物图片是一个
                    petImageSrc = monsterImageSrc;
                }
                page.petImageHtml = "<img src='" + petImageSrc + "' alt='' width='64' height='64'>";
            }
            battleTable
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:first")
                .find("> center:first")
                .find("> h1:eq(1)")
                .find("> font:first")
                .find("> b:first")
                .find("> p:first")
                .find("> table:eq(1)")
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:first")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:eq(4)")
                .each((idx, tr) => {
                page.petNameHtml = $(tr).find("> td:first").html();
            });
            battleTable
                .find("td:contains('<怪物>')")
                .filter((idx, td) => $(td).text() === "<怪物>")
                .each((idx, td) => {
                let monsterTable = $(td).closest("table");
                let roleTable = monsterTable.parent().prev().find("table:first");
                roleTable
                    .find("tr:first")
                    .next()
                    .next()
                    .find("td:eq(1)")
                    .each((i, td) => {
                    let s = StringUtils_1.default.substringBefore($(td).text(), " / ");
                    page.roleHealth = lodash_1.default.parseInt(s);
                    s = StringUtils_1.default.substringAfter($(td).text(), " / ");
                    page.roleMaxHealth = lodash_1.default.parseInt(s);
                })
                    .next()
                    .each((i, td) => {
                    let s = StringUtils_1.default.substringBefore($(td).text(), " / ");
                    page.roleMana = lodash_1.default.parseInt(s);
                    s = StringUtils_1.default.substringAfter($(td).text(), " / ");
                    page.roleMaxMana = lodash_1.default.parseInt(s);
                });
                monsterTable
                    .find("tr:first")
                    .next()
                    .next()
                    .find("td:eq(1)")
                    .each((i, td) => {
                    let s = StringUtils_1.default.substringBefore($(td).text(), " / ");
                    page.monsterHealth = lodash_1.default.parseInt(s);
                    s = StringUtils_1.default.substringAfter($(td).text(), " / ");
                    page.monsterMaxHealth = lodash_1.default.parseInt(s);
                });
            });
            if (page.roleHealth === 0) {
                page.battleResult = "战败";
            }
            else if (page.monsterHealth === 0) {
                page.battleResult = "战胜";
            }
            else {
                page.battleResult = "平手";
            }
            page.harvestList = [];
            battleTable
                .find("p")
                .filter((idx, p) => $(p).text().includes("入手!"))
                .each((idx, p) => {
                lodash_1.default.split($(p).html(), "<br>").forEach(it => {
                    if (it.endsWith("入手!")) {
                        page.harvestList.push(it);
                    }
                });
            });
            page.eggBorn = html.includes("孵化成功");
            page.monsterTask = html.includes("完成杀怪任务");
            page.petLearnSpell = html.includes("遗忘了技能") || html.includes("学会了新技能");
            generateBattleReport(battleTable, page);
            $(page.reportHtml)
                .find("font[color='orange']")
                .each((idx, font) => {
                let t = $(font).text();
                if (!page.additionalRP && lodash_1.default.startsWith(t, "RP上升1点")) {
                    t = StringUtils_1.default.substringAfter(t, "RP上升1点,达到了");
                    t = StringUtils_1.default.substringBefore(t, "点");
                    page.additionalRP = lodash_1.default.parseInt(t);
                }
            });
            return yield (() => {
                return new Promise(resolve => resolve(page));
            })();
        });
    }
}
function generateBattleReport(battleTable, page) {
    let lastTurnIndex = 0; // 最后一个回合p元素对应的下标
    battleTable
        .find("> tbody:first")
        .find("> tr:first")
        .find("> td:first")
        .find("> center:first")
        .find("> h1:eq(1)")
        .find("> font:first")
        .find("> b:first")
        .find("> p")
        .each((idx, p) => {
        const t = $(p).text();
        if (lodash_1.default.startsWith(t, "第 ") && lodash_1.default.includes(t, " 回合")) {
            lastTurnIndex = idx;
        }
    });
    const pList = [];
    battleTable
        .find("> tbody:first")
        .find("> tr:first")
        .find("> td:first")
        .find("> center:first")
        .find("> h1:eq(1)")
        .find("> font:first")
        .find("> b:first")
        .find("> p")
        .each((idx, p) => {
        if (idx >= lastTurnIndex) {
            pList.push($(p));
        }
    });
    let p1 = pList[0].html();
    p1 = StringUtils_1.default.substringAfterLast(p1, "</tbody></table><br>");
    let p2 = "";
    if (pList.length > 1) {
        p2 = pList[1].html();
    }
    let p3 = battleTable
        .find("> tbody:first")
        .find("> tr:first")
        .find("> td:first")
        .find("> center:first")
        .find("> h1:eq(1)")
        .find("> p:first")
        .html();
    // noinspection HtmlDeprecatedTag,HtmlDeprecatedAttribute,XmlDeprecatedElement
    let report = "<b><font size='3'>" + p1 + "</font></b><br><b><font size='3'>" + p2 + "</font></b><br>" + p3;
    while (true) {
        if (!report.includes("<br><br>")) {
            break;
        }
        report = lodash_1.default.replace(report, "<br><br>", "<br>");
    }
    let brs;
    if (page.battleResult === "战胜") {
        brs = BattleDeclarationManager_1.default.randomWinDeclaration(page.monsterNameHtml);
    }
    else if (page.battleResult === "战败") {
        brs = BattleDeclarationManager_1.default.randomLoseDeclaration(page.monsterNameHtml);
    }
    else {
        brs = BattleDeclarationManager_1.default.randomDrawDeclaration(page.monsterNameHtml);
    }
    // noinspection HtmlDeprecatedTag,HtmlDeprecatedAttribute,XmlDeprecatedElement
    report = "<p style='font-weight:bold'><font size='3'>" + brs + "</font></p>" + report;
    // 展现入手
    if (page.harvestList.length > 0) {
        let harvest = "";
        for (const it of page.harvestList) {
            harvest += "<b>" + it + "</b><br>";
        }
        report = "<p style='font-size:250%'>" + harvest + "</p>" + report;
    }
    // 展现宠物升级
    if (page.petUpgrade && page.petNameHtml !== undefined) {
        let pu = "<span style='color:green'>" + page.petNameHtml + "</span> ";
        if (page.petLearnSpell) {
            pu += "<span style='color:blue'>吐故纳新,扶摇直上!</span>";
        }
        else {
            pu += "<span style='color:indigo'>突飞猛进!</span>";
        }
        // noinspection HtmlDeprecatedTag,HtmlDeprecatedAttribute,XmlDeprecatedElement
        report = "<p style='font-weight:bold'><font size='3'>" + pu + "</font></p>" + report;
    }
    report = "<p>" + page.roleImageHtml +
        (page.petImageHtml === undefined ? "" : page.petImageHtml) +
        "&nbsp;&nbsp;&nbsp;<b style='font-size:300%;color:red'>VS</b>&nbsp;&nbsp;&nbsp;" +
        page.monsterImageHtml + "</p>" + report;
    if (page.battleResult !== "战胜" && page.zodiacBattle) {
        // 十二宫战斗没有取得胜利,显示圣斗士剩余的生命
        report = "<p><b style='color:navy;font-size:120%'>" + page.battleField + "</b></p>" +
            "<p><b style='background-color:lightgreen;font-size:120%'>" + page.monsterHealth + "/" + page.monsterMaxHealth + "</b></p>" +
            "" + report;
    }
    else {
        report = "<p><b style='color:navy;font-size:120%'>" + page.battleField + "</b></p>" + report;
    }
    page.reportHtml = report;
}
module.exports = BattlePageParser;


/***/ }),
/* 31 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const RandomUtils_1 = __importDefault(__webpack_require__(28));
class BattleDeclarationManager {
    static randomWinDeclaration(monster) {
        let foe = monster ? monster : "对手";
        foe = "<span style='color:green'>" + foe + "</span>";
        let t = RandomUtils_1.default.randomElement(WIN_DECLARATIONS);
        t = lodash_1.default.replace(t, "%MONSTER%", foe);
        return "<span style='color:indigo'>" + t + "</span>";
    }
    static randomLoseDeclaration(monster) {
        let foe = monster ? monster : "对手";
        foe = "<span style='color:green'>" + foe + "</span>";
        let t = RandomUtils_1.default.randomElement(LOSE_DECLARATIONS);
        t = lodash_1.default.replace(t, "%MONSTER%", foe);
        return "<span style='color:indigo'>" + t + "</span>";
    }
    static randomDrawDeclaration(monster) {
        let foe = monster ? monster : "对手";
        foe = "<span style='color:green'>" + foe + "</span>";
        let t = RandomUtils_1.default.randomElement(DRAW_DECLARATIONS);
        t = lodash_1.default.replace(t, "%MONSTER%", foe);
        return "<span style='color:indigo'>" + t + "</span>";
    }
}
const WIN_DECLARATIONS = [
    "暴虎冯河,战胜了%MONSTER%!",
    "犁庭扫闾,战胜了%MONSTER%!",
    "封狼居胥,战胜了%MONSTER%!",
    "勒石燕然,战胜了%MONSTER%!",
    "饮马翰海,战胜了%MONSTER%!",
];
const LOSE_DECLARATIONS = [
    "涕泗横流,被%MONSTER%暴揍一顿!",
    "如丧考妣,竟然会败给%MONSTER%!",
    "哀毁骨立,%MONSTER%默默的看着你!",
    "捶胸顿足,%MONSTER%你给我等着!",
    "辙乱旗靡,能逃过%MONSTER%的追杀?",
];
const DRAW_DECLARATIONS = [
    "与%MONSTER%拳来腿往不分高下!",
];
module.exports = BattleDeclarationManager;


/***/ }),
/* 32 */
/***/ ((module) => {

"use strict";

class BattlePage {
    constructor() {
        this.treasureBattle = false;
        this.primaryBattle = false;
        this.juniorBattle = false;
        this.seniorBattle = false;
        this.zodiacBattle = false;
        this.petUpgrade = false;
        this.lowestEndure = 999;
    }
    get battleField() {
        if (this.treasureBattle) {
            return "< 秘 宝 之 岛 >";
        }
        if (this.primaryBattle) {
            return "< 初 级 之 森 >";
        }
        if (this.juniorBattle) {
            return "< 中 级 之 塔 >";
        }
        if (this.seniorBattle) {
            return "< 上 级 之 洞 窟 >";
        }
        if (this.zodiacBattle) {
            return "< 十 二 神 殿 >";
        }
        return "UNKNOWN";
    }
}
module.exports = BattlePage;


/***/ }),
/* 33 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const SetupLoader_1 = __importDefault(__webpack_require__(20));
class BattleRecommendation {
    static analysis(battleCount, battlePage) {
        return __awaiter(this, void 0, void 0, function* () {
            const recommendation = _analysis(battleCount, battlePage);
            return yield (() => {
                return new Promise(resolve => resolve(recommendation));
            })();
        });
    }
}
function _analysis(battleCount, battlePage) {
    if (battleCount % 100 === 0) {
        // 每100战强制修理
        return "修";
    }
    if (battlePage.lowestEndure < SetupLoader_1.default.getRepairMinLimitation()) {
        // 有装备耐久度低于阈值了,强制修理
        return "修";
    }
    if (battlePage.battleResult === "战败") {
        // 战败,转到住宿
        return "宿";
    }
    if (battlePage.zodiacBattle && battlePage.battleResult === "平手") {
        // 十二宫战斗平手,视为战败,转到住宿
        return "宿";
    }
    if (battlePage.zodiacBattle || battlePage.treasureBattle) {
        // 十二宫战胜或者秘宝战胜,转到存钱
        return "存";
    }
    let depositBattleCount = SetupLoader_1.default.getDepositBattleCount();
    if (depositBattleCount > 0 && battleCount % depositBattleCount === 0) {
        // 设置的存钱战数到了
        return "存";
    }
    // 生命力低于最大值的配置比例,住宿推荐
    if (SetupLoader_1.default.getLodgeHealthLostRatio() > 0 &&
        (battlePage.roleHealth <= battlePage.roleMaxHealth * SetupLoader_1.default.getLodgeHealthLostRatio())) {
        return "宿";
    }
    // 如果MANA小于50%并且小于配置点数,住宿推荐
    if (SetupLoader_1.default.getLodgeManaLostPoint() > 0 &&
        (battlePage.roleMana <= battlePage.roleMaxMana * 0.5 && battlePage.roleMana <= SetupLoader_1.default.getLodgeManaLostPoint())) {
        return "宿";
    }
    if (SetupLoader_1.default.getDepositBattleCount() > 0) {
        // 设置了定期存钱,但是没有到战数,那么就直接返回吧
        return "回";
    }
    else {
        // 没有设置定期存钱,那就表示每战都存钱
        return "存";
    }
}
module.exports = BattleRecommendation;


/***/ }),
/* 34 */
/***/ ((module) => {

"use strict";

class BattleRecord {
    asObject() {
        const obj = {};
        // @ts-ignore
        obj.id = this.id;
        // @ts-ignore
        obj.html = this.html;
        return obj;
    }
}
module.exports = BattleRecord;


/***/ }),
/* 35 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const BattleRecord_1 = __importDefault(__webpack_require__(34));
class BattleRecordStorage {
    static getInstance() {
        return instance;
    }
    load(id) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db.transaction(["BattleRecord"], "readonly")
                        .objectStore("BattleRecord")
                        .get(id);
                    request.onerror = reject;
                    request.onsuccess = () => {
                        if (request.result) {
                            const record = new BattleRecord_1.default();
                            record.id = request.result.id;
                            record.html = request.result.html;
                            resolve(record);
                        }
                        else {
                            reject();
                        }
                    };
                });
            })();
        });
    }
    write(record) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db.transaction(["BattleRecord"], "readwrite")
                        .objectStore("BattleRecord")
                        .put(record.asObject());
                    request.onerror = reject;
                    request.onsuccess = () => resolve();
                });
            })();
        });
    }
}
const instance = new BattleRecordStorage();
module.exports = BattleRecordStorage;


/***/ }),
/* 36 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const BattleResult_1 = __importDefault(__webpack_require__(37));
class BattleResultStorage {
    static getInstance() {
        return instance;
    }
    loads() {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db.transaction(["BattleResult"], "readonly")
                        .objectStore("BattleResult")
                        .getAll();
                    request.onerror = reject;
                    request.onsuccess = () => {
                        if (request.result) {
                            const dataList = [];
                            for (const it of request.result) {
                                const data = new BattleResult_1.default();
                                data.id = it.id;
                                data.roleId = it.roleId;
                                data.monster = it.monster;
                                data.winCount = it.winCount;
                                data.loseCount = it.loseCount;
                                data.drawCount = it.drawCount;
                                data.catchCount = it.catchCount;
                                data.photoCount = it.photoCount;
                                if (it.treasures) {
                                    data.treasures = new Map();
                                    Object.keys(it.treasures)
                                        .forEach(code => {
                                        const count = it.treasures[code];
                                        data.treasures.set(code, count);
                                    });
                                }
                                dataList.push(data);
                            }
                            resolve(dataList);
                        }
                        else {
                            reject();
                        }
                    };
                });
            })();
        });
    }
    replay(log) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const id = log.roleId + "/" + log.monster;
                    const store = db
                        .transaction(["BattleResult"], "readwrite")
                        .objectStore("BattleResult");
                    const readRequest = store.get(id);
                    readRequest.onerror = reject;
                    readRequest.onsuccess = () => {
                        if (readRequest.result) {
                            // Update exists battle result.
                            const document = readRequest.result;
                            document.updateTime = log.createTime;
                            switch (log.result) {
                                case "战胜":
                                    let winCount = document.winCount;
                                    winCount = winCount === undefined ? 0 : winCount;
                                    winCount++;
                                    document.winCount = winCount;
                                    break;
                                case "战败":
                                    let loseCount = document.loseCount;
                                    loseCount = loseCount === undefined ? 0 : loseCount;
                                    loseCount++;
                                    document.loseCount = loseCount;
                                    break;
                                case "平手":
                                    let drawCount = document.drawCount;
                                    drawCount = drawCount === undefined ? 0 : drawCount;
                                    drawCount++;
                                    document.drawCount = drawCount;
                                    break;
                            }
                            if (log.catch) {
                                let catchCount = document.catchCount;
                                catchCount = catchCount === undefined ? 0 : catchCount;
                                catchCount += log.catch;
                                document.catchCount = catchCount;
                            }
                            if (log.photo) {
                                let photoCount = document.photoCount;
                                photoCount = photoCount === undefined ? 0 : photoCount;
                                photoCount += log.photo;
                                document.photoCount = photoCount;
                            }
                            if (log.treasures) {
                                if (!document.treasures) {
                                    document.treasures = {};
                                }
                                log.treasures.forEach((count, code) => {
                                    let tc = document.treasures[code];
                                    tc = tc === undefined ? 0 : tc;
                                    tc += count;
                                    document.treasures[code] = tc;
                                });
                            }
                            // Increment revision
                            let revision = document.revision;
                            revision = revision === undefined ? 1 : revision;
                            revision++;
                            document.revision = revision;
                            const writeRequest = store.put(document);
                            writeRequest.onerror = reject;
                            writeRequest.onsuccess = () => resolve();
                        }
                        else {
                            // No battle result exists, create new one.
                            const document = BattleResult_1.default.newInstance(log).asObject();
                            // @ts-ignore
                            document.revision = 1;
                            const writeRequest = store.add(document);
                            writeRequest.onerror = reject;
                            writeRequest.onsuccess = () => resolve();
                        }
                    };
                });
            })();
        });
    }
    clear() {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db
                        .transaction(["BattleResult"], "readwrite")
                        .objectStore("BattleResult")
                        .clear();
                    request.onerror = reject;
                    request.onsuccess = () => {
                        resolve();
                    };
                });
            })();
        });
    }
}
const instance = new BattleResultStorage();
module.exports = BattleResultStorage;


/***/ }),
/* 37 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const MonsterProfileLoader_1 = __importDefault(__webpack_require__(18));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
class BattleResult {
    static newInstance(log) {
        const data = new BattleResult();
        data.id = log.roleId + "/" + log.monster;
        data.updateTime = log.createTime;
        data.roleId = log.roleId;
        data.monster = log.monster;
        switch (log.result) {
            case "战胜":
                data.winCount = 1;
                break;
            case "战败":
                data.loseCount = 1;
                break;
            case "平手":
                data.drawCount = 1;
                break;
        }
        data.catchCount = log.catch;
        data.photoCount = log.photo;
        data.treasures = log.treasures;
        return data;
    }
    asObject() {
        const obj = {};
        // @ts-ignore
        obj.id = this.id;
        if (this.updateTime !== undefined) {
            // @ts-ignore
            obj.updateTime = this.updateTime;
        }
        // @ts-ignore
        obj.roleId = this.roleId;
        // @ts-ignore
        obj.monster = this.monster;
        if (this.winCount !== undefined) {
            // @ts-ignore
            obj.winCount = this.winCount;
        }
        if (this.loseCount !== undefined) {
            // @ts-ignore
            obj.loseCount = this.loseCount;
        }
        if (this.drawCount !== undefined) {
            // @ts-ignore
            obj.drawCount = this.drawCount;
        }
        if (this.catchCount !== undefined) {
            // @ts-ignore
            obj.catchCount = this.catchCount;
        }
        if (this.photoCount !== undefined) {
            // @ts-ignore
            obj.photoCount = this.photoCount;
        }
        if (this.treasures !== undefined) {
            // @ts-ignore
            obj.treasures = {};
            this.treasures.forEach((v, k) => {
                // @ts-ignore
                obj.treasures[k] = v;
            });
        }
        return obj;
    }
    get obtainWinCount() {
        return this.winCount === undefined ? 0 : this.winCount;
    }
    get obtainLoseCount() {
        return this.loseCount === undefined ? 0 : this.loseCount;
    }
    get obtainDrawCount() {
        return this.drawCount === undefined ? 0 : this.drawCount;
    }
    get obtainCatchCount() {
        return this.catchCount === undefined ? 0 : this.catchCount;
    }
    get obtainPhotoCount() {
        return this.photoCount === undefined ? 0 : this.photoCount;
    }
    get obtainTotalCount() {
        return this.obtainWinCount + this.obtainLoseCount + this.obtainDrawCount;
    }
    get obtainTreasureCount() {
        if (this.treasures === undefined) {
            return 0;
        }
        let treasureCount = 0;
        this.treasures.forEach((v, k) => {
            const code = lodash_1.default.parseInt(k);
            if (code >= 1 && code <= 49) {
                treasureCount += v;
            }
        });
        return treasureCount;
    }
    get obtainTreasureHintCount() {
        if (this.treasures === undefined) {
            return 0;
        }
        let treasureHintCount = 0;
        this.treasures.forEach((v, k) => {
            const code = lodash_1.default.parseInt(k);
            if (code === 50) {
                treasureHintCount += v;
            }
        });
        return treasureHintCount;
    }
    get obtainGemCount() {
        if (this.treasures === undefined) {
            return 0;
        }
        let gemCount = 0;
        this.treasures.forEach((v, k) => {
            const code = lodash_1.default.parseInt(k);
            if (code >= 51 && code <= 53) {
                gemCount += v;
            }
        });
        return gemCount;
    }
    get obtainBattleField() {
        var _a;
        if (this.monster === "博丽灵梦") {
            return "上洞";
        }
        if (NpcLoader_1.default.getZodiacNpcNames().includes(this.monster)) {
            return "十二宫";
        }
        const location = (_a = MonsterProfileLoader_1.default.load(this.monster)) === null || _a === void 0 ? void 0 : _a.locationText;
        return location ? location : "未知(" + this.monster + ")";
    }
}
module.exports = BattleResult;


/***/ }),
/* 38 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _BattleReturnInterceptor_credential, _BattleReturnInterceptor_battleCount;
const BankRecordManager_1 = __importDefault(__webpack_require__(39));
const EquipmentLocalStorage_1 = __importDefault(__webpack_require__(53));
const PetLocalStorage_1 = __importDefault(__webpack_require__(67));
class BattleReturnInterceptor {
    constructor(credential, battleCount) {
        _BattleReturnInterceptor_credential.set(this, void 0);
        _BattleReturnInterceptor_battleCount.set(this, void 0);
        __classPrivateFieldSet(this, _BattleReturnInterceptor_credential, credential, "f");
        __classPrivateFieldSet(this, _BattleReturnInterceptor_battleCount, battleCount, "f");
    }
    doBeforeReturn() {
        return __awaiter(this, void 0, void 0, function* () {
            yield Promise.all([
                new BankRecordManager_1.default(__classPrivateFieldGet(this, _BattleReturnInterceptor_credential, "f")).triggerUpdateBankRecord(__classPrivateFieldGet(this, _BattleReturnInterceptor_battleCount, "f")),
                new PetLocalStorage_1.default(__classPrivateFieldGet(this, _BattleReturnInterceptor_credential, "f")).triggerUpdatePetMap(__classPrivateFieldGet(this, _BattleReturnInterceptor_battleCount, "f")),
                new PetLocalStorage_1.default(__classPrivateFieldGet(this, _BattleReturnInterceptor_credential, "f")).triggerUpdatePetStatus(__classPrivateFieldGet(this, _BattleReturnInterceptor_battleCount, "f")),
                new EquipmentLocalStorage_1.default(__classPrivateFieldGet(this, _BattleReturnInterceptor_credential, "f")).triggerUpdateEquipmentStatus(__classPrivateFieldGet(this, _BattleReturnInterceptor_battleCount, "f")),
            ]);
            return yield (() => {
                return new Promise(resolve => {
                    resolve();
                });
            })();
        });
    }
}
_BattleReturnInterceptor_credential = new WeakMap(), _BattleReturnInterceptor_battleCount = new WeakMap();
module.exports = BattleReturnInterceptor;


/***/ }),
/* 39 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _BankRecordManager_credential;
const lodash_1 = __importDefault(__webpack_require__(4));
const DayRange_1 = __importDefault(__webpack_require__(40));
const BankRecord_1 = __importDefault(__webpack_require__(41));
const BankRecordStorage_1 = __importDefault(__webpack_require__(42));
const TownBank_1 = __importDefault(__webpack_require__(43));
class BankRecordManager {
    constructor(credential) {
        _BankRecordManager_credential.set(this, void 0);
        __classPrivateFieldSet(this, _BankRecordManager_credential, credential, "f");
    }
    triggerUpdateBankRecord(battleCount) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    // 战数尾数为79时,触发资产更新
                    const doUpdate = (battleCount % 100 === 79);
                    if (doUpdate) {
                        this.updateBankRecord().then(() => resolve());
                    }
                    else {
                        resolve();
                    }
                });
            })();
        });
    }
    updateBankRecord() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    new TownBank_1.default(__classPrivateFieldGet(this, _BankRecordManager_credential, "f")).load().then(account => {
                        if (lodash_1.default.isNaN(account.cash) || lodash_1.default.isNaN(account.saving)) {
                            // Do nothing and return
                            resolve();
                        }
                        else {
                            const data = new BankRecord_1.default();
                            data.roleId = __classPrivateFieldGet(this, _BankRecordManager_credential, "f").id;
                            data.recordDate = DayRange_1.default.current().asText();
                            data.cash = account.cash;
                            data.saving = account.saving;
                            BankRecordStorage_1.default.getInstance().upsert(data).then(() => resolve());
                        }
                    });
                });
            })();
        });
    }
    static importFromJson(json) {
        return __awaiter(this, void 0, void 0, function* () {
            const documentList = JSON.parse(json);
            $("#bankRecordCount").html(documentList.length);
            if (documentList.length > 0)
                doImport(0, documentList);
        });
    }
}
_BankRecordManager_credential = new WeakMap();
function doImport(index, documentList) {
    const document = documentList[index];
    if (!document) {
        return;
    }
    const data = new BankRecord_1.default();
    // @ts-ignore
    data.id = document.id;
    // @ts-ignore
    data.roleId = document.roleId;
    // @ts-ignore
    data.createTime = document.createTime;
    // @ts-ignore
    data.updateTime = document.updateTime;
    // @ts-ignore
    data.recordDate = document.recordDate;
    // @ts-ignore
    data.cash = document.cash;
    // @ts-ignore
    data.saving = document.saving;
    // @ts-ignore
    data.revision = document.revision;
    BankRecordStorage_1.default.getInstance().replay(data)
        .then(() => {
        let c = lodash_1.default.parseInt($("#importedBankRecordCount").text());
        c++;
        $("#importedBankRecordCount").text(c);
        doImport(index + 1, documentList);
    })
        .catch(() => {
        let c = lodash_1.default.parseInt($("#duplicatedBankRecordCount").text());
        c++;
        $("#duplicatedBankRecordCount").text(c);
        doImport(index + 1, documentList);
    });
}
module.exports = BankRecordManager;


/***/ }),
/* 40 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
class DayRange {
    constructor(time) {
        let timeForUse;
        if (time) {
            timeForUse = time;
        }
        else {
            timeForUse = Date.now();
        }
        const startInstant = new Date(timeForUse);
        startInstant.setHours(0, 0, 0, 0);
        this.start = startInstant.getTime();
        this.end = this.start + 86400000 - 1;
    }
    asText() {
        const instant = new Date(this.start);
        let year = instant.getFullYear();
        let month = instant.getMonth() + 1;
        let day = instant.getDate();
        return year + lodash_1.default.padStart(month.toString(), 2, "0") + lodash_1.default.padStart(day.toString(), 2, "0");
    }
    toString() {
        return "[" + new Date(this.start).toLocaleString() + "] - [" + new Date(this.end).toLocaleString() + "]";
    }
    previous() {
        return new DayRange(this.start - 1);
    }
    next() {
        return new DayRange(this.end + 1);
    }
    static current() {
        return new DayRange();
    }
}
module.exports = DayRange;


/***/ }),
/* 41 */
/***/ ((module) => {

"use strict";

class BankRecord {
    asDocument() {
        const document = {};
        if (this.id) {
            // @ts-ignore
            document.id = this.id;
        }
        if (this.roleId) {
            // @ts-ignore
            document.roleId = this.roleId;
        }
        if (this.createTime !== undefined) {
            // @ts-ignore
            document.createTime = this.createTime;
        }
        if (this.updateTime !== undefined) {
            // @ts-ignore
            document.updateTime = this.updateTime;
        }
        if (this.recordDate) {
            // @ts-ignore
            document.recordDate = this.recordDate;
        }
        if (this.cash !== undefined) {
            // @ts-ignore
            document.cash = this.cash;
        }
        if (this.saving !== undefined) {
            // @ts-ignore
            document.saving = this.saving;
        }
        if (this.revision !== undefined) {
            // @ts-ignore
            document.revision = this.revision;
        }
        return document;
    }
}
module.exports = BankRecord;


/***/ }),
/* 42 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const BankRecord_1 = __importDefault(__webpack_require__(41));
class BankRecordStorage {
    static getInstance() {
        return instance;
    }
    loads() {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return new Promise((resolve, reject) => {
                const request = db
                    .transaction(["BankRecord"], "readonly")
                    .objectStore("BankRecord")
                    .getAll();
                request.onerror = reject;
                request.onsuccess = () => {
                    const dataList = [];
                    if (request.result && request.result.length > 0) {
                        request.result.forEach(it => {
                            const data = new BankRecord_1.default();
                            data.id = it.id;
                            data.roleId = it.roleId;
                            data.createTime = it.createTime;
                            data.updateTime = it.updateTime;
                            data.recordDate = it.recordDate;
                            data.cash = it.cash;
                            data.saving = it.saving;
                            data.revision = it.revision;
                            dataList.push(data);
                        });
                    }
                    resolve(dataList);
                };
            });
        });
    }
    load(roleId) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const store = db
                        .transaction(["BankRecord"], "readonly")
                        .objectStore("BankRecord");
                    const indexRequest = store.index("roleId")
                        .getAllKeys(roleId);
                    indexRequest.onerror = reject;
                    indexRequest.onsuccess = () => {
                        if (!indexRequest.result || indexRequest.result.length === 0) {
                            resolve(null);
                        }
                        else {
                            const recordDate = indexRequest.result
                                .map(it => it.toString())
                                .map(it => StringUtils_1.default.substringAfter(it, "/"))
                                .sort()
                                .reverse()[0];
                            const id = roleId + "/" + recordDate;
                            const dataRequest = store.get(id);
                            dataRequest.onerror = reject;
                            dataRequest.onsuccess = () => {
                                if (!dataRequest.result) {
                                    resolve(null);
                                }
                                else {
                                    const data = new BankRecord_1.default();
                                    data.id = dataRequest.result.id;
                                    data.roleId = dataRequest.result.roleId;
                                    data.createTime = dataRequest.result.createTime;
                                    data.updateTime = dataRequest.result.updateTime;
                                    data.recordDate = dataRequest.result.recordDate;
                                    data.cash = dataRequest.result.cash;
                                    data.saving = dataRequest.result.saving;
                                    data.revision = dataRequest.result.revision;
                                    resolve(data);
                                }
                            };
                        }
                    };
                });
            })();
        });
    }
    upsert(data) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const id = data.roleId + "/" + data.recordDate;
                    const store = db
                        .transaction(["BankRecord"], "readwrite")
                        .objectStore("BankRecord");
                    const readRequest = store.get(id);
                    readRequest.onerror = reject;
                    readRequest.onsuccess = () => {
                        if (readRequest.result) {
                            const document = readRequest.result;
                            document.updateTime = Date.now();
                            // Increment revision
                            let revision = document.revision;
                            revision = revision === undefined ? 1 : revision;
                            revision++;
                            document.revision = revision;
                            if (data.cash !== undefined) {
                                document.cash = data.cash;
                            }
                            if (data.saving !== undefined) {
                                document.saving = data.saving;
                            }
                            const writeRequest = store.put(document);
                            writeRequest.onerror = reject;
                            writeRequest.onsuccess = () => resolve();
                        }
                        else {
                            const current = Date.now();
                            const document = data.asDocument();
                            // @ts-ignore
                            document.id = id;
                            // @ts-ignore
                            document.createTime = current;
                            // @ts-ignore
                            document.updateTime = current;
                            // @ts-ignore
                            document.revision = 1;
                            const writeRequest = store.add(document);
                            writeRequest.onerror = reject;
                            writeRequest.onsuccess = () => resolve();
                        }
                    };
                });
            })();
        });
    }
    replay(data) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return new Promise((resolve, reject) => {
                const id = data.roleId + "/" + data.recordDate;
                const store = db
                    .transaction(["BankRecord"], "readwrite")
                    .objectStore("BankRecord");
                const readRequest = store.get(id);
                readRequest.onerror = reject;
                readRequest.onsuccess = () => {
                    if (readRequest.result) {
                        const document = readRequest.result;
                        if (document.updateTime >= data.updateTime) {
                            reject();
                        }
                        else {
                            document.updateTime = data.updateTime;
                            // Increment revision
                            let revision = document.revision;
                            revision = revision === undefined ? 1 : revision;
                            revision++;
                            document.revision = revision;
                            document.cash = data.cash;
                            document.saving = data.saving;
                            const writeRequest = store.put(document);
                            writeRequest.onerror = reject;
                            writeRequest.onsuccess = () => resolve();
                        }
                    }
                    else {
                        const document = data.asDocument();
                        const writeRequest = store.add(document);
                        writeRequest.onerror = reject;
                        writeRequest.onsuccess = () => resolve();
                    }
                };
            });
        });
    }
    clear() {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return new Promise((resolve, reject) => {
                const request = db
                    .transaction(["BankRecord"], "readwrite")
                    .objectStore("BankRecord")
                    .clear();
                request.onerror = reject;
                request.onsuccess = () => resolve();
            });
        });
    }
}
const instance = new BankRecordStorage();
module.exports = BankRecordStorage;


/***/ }),
/* 43 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _TownBank_credential, _TownBank_townId;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const PocketUtils_1 = __importDefault(__webpack_require__(46));
const TownLoader_1 = __importDefault(__webpack_require__(47));
const TownBankPageParser_1 = __importDefault(__webpack_require__(49));
class TownBank {
    constructor(credential, townId) {
        _TownBank_credential.set(this, void 0);
        _TownBank_townId.set(this, void 0);
        __classPrivateFieldSet(this, _TownBank_credential, credential, "f");
        __classPrivateFieldSet(this, _TownBank_townId, townId, "f");
    }
    get bankTitle() {
        if (__classPrivateFieldGet(this, _TownBank_townId, "f") === undefined) {
            return "口袋银行";
        }
        else {
            const town = TownLoader_1.default.load(__classPrivateFieldGet(this, _TownBank_townId, "f"));
            return town.name + "分行";
        }
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _TownBank_credential, "f").asRequestMap();
                    request.set("con_str", "50");
                    request.set("mode", "BANK");
                    if (__classPrivateFieldGet(this, _TownBank_townId, "f") !== undefined) {
                        request.set("town", __classPrivateFieldGet(this, _TownBank_townId, "f"));
                    }
                    NetworkUtils_1.default.post("town.cgi", request).then(html => {
                        new TownBankPageParser_1.default().parse(html).then(page => resolve(page));
                    });
                });
            };
            return yield action();
        });
    }
    load() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise(resolve => {
                    this.open().then(page => {
                        resolve(page.account);
                    });
                });
            };
            return yield action();
        });
    }
    withdraw(amount) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise((resolve, reject) => {
                    if (!PocketUtils_1.default.checkAmount(amount)) {
                        MessageBoard_1.default.publishWarning("无效的金额,必须是零或者正整数!");
                        reject();
                    }
                    else {
                        if (amount === 0) {
                            resolve();
                        }
                        else {
                            const request = __classPrivateFieldGet(this, _TownBank_credential, "f").asRequestMap();
                            request.set("dasu", amount.toString());
                            request.set("mode", "BANK_BUY");
                            NetworkUtils_1.default.post("town.cgi", request).then(html => {
                                if (html.includes("您在钱庄里没那么多存款")) {
                                    MessageBoard_1.default.publishWarning("并没有那么多存款!");
                                    reject();
                                }
                                else {
                                    MessageBoard_1.default.publishMessage("从" + this.bankTitle + "取现了" + amount + "万现金。");
                                    resolve();
                                }
                            });
                        }
                    }
                });
            };
            return yield action();
        });
    }
    deposit(amount) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise((resolve, reject) => {
                    const request = __classPrivateFieldGet(this, _TownBank_credential, "f").asRequestMap();
                    if (amount === undefined) {
                        request.set("azukeru", "all");
                        request.set("mode", "BANK_SELL");
                        NetworkUtils_1.default.post("town.cgi", request).then(() => {
                            MessageBoard_1.default.publishMessage("在" + this.bankTitle + "存入了所有现金。");
                            resolve();
                        });
                    }
                    else {
                        if (!PocketUtils_1.default.checkAmount(amount)) {
                            MessageBoard_1.default.publishWarning("无效的金额,必须是零或者正整数!");
                            reject();
                        }
                        else {
                            if (amount === 0) {
                                resolve();
                            }
                            else {
                                request.set("azukeru", amount.toString());
                                request.set("mode", "BANK_SELL");
                                NetworkUtils_1.default.post("town.cgi", request).then(html => {
                                    if (html.includes("所持金不足")) {
                                        MessageBoard_1.default.publishWarning("并没有那么多现金!");
                                        reject();
                                    }
                                    else {
                                        MessageBoard_1.default.publishMessage("在" + this.bankTitle + "存入了" + amount + "万现金。");
                                        resolve();
                                    }
                                });
                            }
                        }
                    }
                });
            };
            return yield action();
        });
    }
}
_TownBank_credential = new WeakMap(), _TownBank_townId = new WeakMap();
module.exports = TownBank;


/***/ }),
/* 44 */
/***/ ((module) => {

"use strict";

class MessageBoard {
    static createMessageBoard(containerId, imageHtml) {
        let html = "";
        html += "<table style='background-color:#888888;border-width:0;width:100%'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0' id='messageBoardManager'>" + imageHtml + "</td>";
        html += "<td style='background-color:#F8F0E0;width:100%' id='messageBoard'></td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#" + containerId).html(html);
    }
    static createMessageBoardStyleB(containerId, imageHtml) {
        let html = "";
        html += "<table style='background-color:#888888;border-width:0;width:100%'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;width:100%' id='messageBoard'></td>";
        html += "<td style='background-color:#F8F0E0' id='messageBoardManager'>" + imageHtml + "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#" + containerId).html(html);
    }
    static createMessageBoardStyleC(containerId) {
        let html = "";
        html += "<table style='background-color:#888888;border-width:0;width:100%'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:black;width:100%;color:white' id='messageBoard'></td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#" + containerId).html(html);
    }
    static resetMessageBoard(message) {
        if ($("#messageBoard").length === 0) {
            return;
        }
        $("#messageBoard").html(message);
    }
    static publishMessage(message) {
        if ($("#messageBoard").length > 0) {
            let html = $("#messageBoard").html();
            const now = new Date();
            const timeHtml = "<span style='color:forestgreen'>(" + now.toLocaleString() + ")</span>";
            html = html + "<li>" + timeHtml + " " + message + "</li>";
            $("#messageBoard").html(html);
        }
    }
    static publishWarning(message) {
        if ($("#messageBoard").length > 0) {
            let html = $("#messageBoard").html();
            const now = new Date();
            const timeHtml = "<span style='color:forestgreen'>(" + now.toLocaleString() + ")</span>";
            const messageHtml = "<span style='color:red'>" + message + "</span>";
            html = html + "<li>" + timeHtml + " " + messageHtml + "</li>";
            $("#messageBoard").html(html);
        }
    }
    static processResponseMessage(html) {
        if ($(html).text().includes("ERROR !")) {
            const errorMessage = $(html).find("font b").text();
            MessageBoard.publishMessage("<b style='color:red'>" + errorMessage + "</b>");
        }
        else {
            $(html).find("h2").each(function (_idx, h2) {
                let successMessage = $(h2).html();
                successMessage = successMessage.replace("<br>", "");
                successMessage = "<td>" + successMessage + "</td>";
                MessageBoard.publishMessage($(successMessage).text());
            });
        }
    }
}
module.exports = MessageBoard;


/***/ }),
/* 45 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Constants_1 = __importDefault(__webpack_require__(11));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const PocketUtils_1 = __importDefault(__webpack_require__(46));
class NetworkUtils {
    static sendGetRequest(cgi, handler) {
        __internalSendGetRequest(0, cgi, handler);
    }
    static sendPostRequest(cgi, request, handler) {
        __internalSendPostRequest(0, cgi, request, handler);
    }
    static get(cgi) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    NetworkUtils.sendGetRequest(cgi, function (html) {
                        resolve(html);
                    });
                });
            })();
        });
    }
    static post(cgi, request) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (cgi, request) => {
                return new Promise(resolve => {
                    const body = PocketUtils_1.default.asRequest(request);
                    NetworkUtils.sendPostRequest(cgi, body, function (html) {
                        resolve(html);
                    });
                });
            };
            return yield action(cgi, request);
        });
    }
}
function __internalSendGetRequest(count, cgi, handler) {
    if (count === Constants_1.default.MAX_NETWORK_FAILURE_RETRIES) {
        MessageBoard_1.default.publishWarning("请求" + cgi + "达到最大重试次数,依然失败,看起来口袋出问题了,请联系GM!");
        return;
    }
    fetch(cgi, { method: "GET" })
        .then((response) => {
        if (!response.ok) {
            MessageBoard_1.default.publishWarning("请求" + cgi + "时返回错误[status=" + response.status + "],尝试重试!");
            throw new Error("RESPONSE was not ok");
        }
        if (count !== 0) {
            MessageBoard_1.default.publishMessage("第" + count + "次重试请求" + cgi + "成功。");
        }
        return response.arrayBuffer();
    })
        .then((arrayBuffer) => {
        const decoder = new TextDecoder("gb2312");
        const html = decoder.decode(new Uint8Array(arrayBuffer));
        if (handler !== undefined) {
            handler(html);
        }
    })
        .catch(() => {
        __internalSendGetRequest(count + 1, cgi, handler);
    });
}
function __internalSendPostRequest(count, cgi, request, handler) {
    if (count === 3) {
        MessageBoard_1.default.publishWarning("请求" + cgi + "达到最大重试次数,依然失败,看起来口袋出问题了,请联系GM!");
        return;
    }
    fetch(cgi, {
        method: "POST",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
        body: new URLSearchParams(request),
    })
        .then((response) => {
        if (!response.ok) {
            // @ts-ignore
            const mode = request.mode;
            if (mode) {
                MessageBoard_1.default.publishWarning("请求" + cgi + "时返回错误[mode=" + mode + ",status=" + response.status + "],尝试重试!");
            }
            else {
                MessageBoard_1.default.publishWarning("请求" + cgi + "时返回错误[status=" + response.status + "],尝试重试!");
            }
            throw new Error("RESPONSE was not ok");
        }
        if (count !== 0) {
            MessageBoard_1.default.publishMessage("第" + count + "次重试请求" + cgi + "成功。");
        }
        return response.arrayBuffer();
    })
        .then((arrayBuffer) => {
        const decoder = new TextDecoder("gb2312");
        const html = decoder.decode(new Uint8Array(arrayBuffer));
        if (handler !== undefined) {
            handler(html);
        }
    })
        .catch(() => {
        __internalSendPostRequest(count + 1, cgi, request, handler);
    });
}
module.exports = NetworkUtils;


/***/ }),
/* 46 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
class PocketUtils {
    static asRequest(map) {
        const result = {};
        map.forEach(function (value, key) {
            // @ts-ignore
            result[key] = value;
        });
        return result;
    }
    static checkAmount(amount) {
        if (lodash_1.default.isNaN(amount)) {
            return false;
        }
        if (!lodash_1.default.isInteger(amount)) {
            return false;
        }
        return amount >= 0;
    }
    static calculateCashDifferenceAmount(cash, expect) {
        if (cash >= expect) {
            return 0;
        }
        return Math.ceil((expect - cash) / 10000);
    }
}
module.exports = PocketUtils;


/***/ }),
/* 47 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const Coordinate_1 = __importDefault(__webpack_require__(5));
const Town_1 = __importDefault(__webpack_require__(48));
class TownLoader {
    static load(s) {
        if (!s)
            return null;
        if (s instanceof Coordinate_1.default) {
            for (const it of TownLoader.getTownList()) {
                if (it.coordinate.equals(s)) {
                    return it;
                }
            }
            return null;
        }
        const id = lodash_1.default.isNumber(s) ? s.toString() : s;
        // @ts-ignore
        const town = TOWN_DEFINITION[id];
        if (town)
            return town;
        for (const it of TownLoader.getTownList()) {
            if (id.startsWith(it.name)) {
                return it;
            }
        }
        return null;
    }
    static getTownList() {
        return Object.values(TOWN_DEFINITION);
    }
}
const TOWN_DEFINITION = {
    "1": new Town_1.default("1", "贤者之城", "精灵族的王都,在精灵语中意为山谷中的隐居之城,因数位异族出身的贤者都选择在此谢世而得名。种植着珍贵草药的山谷另一端有巨大的水坝,传说曾三次以毁灭性方式成功驱赶妄图入侵的军队。", new Coordinate_1.default(14, 0)),
    "2": new Town_1.default("2", "翡冷翠", "大陆西海岸城市,著名的纺织业都市,也有可耕作的土地以及贸易的港口,农业和商业都比较发达,故而坎德人的事业长存。", new Coordinate_1.default(1, 11)),
    "3": new Town_1.default("3", "诺曼", "滨海城市,曾是大陆最大的造船业基地,后因战火而数度覆没,现在虽然仍建造船只,但规模远逊昔日。", new Coordinate_1.default(2, 12)),
    "4": new Town_1.default("4", "潘帕斯", "肥沃的土地,丰富的水源,传统型农业都市也一直是粮棉产地和经济发达地区。素有“大陆粮仓”及“天府之国”之称。自古有在二月举行祭拜农神五旬节庆典。而九月举行的大型农牧业交易会也是整个大陆最繁盛的聚会之一。", new Coordinate_1.default(3, 8)),
    "5": new Town_1.default("5", "卡鲁", "山顶矮人的重要居城要塞,依山而筑坚固无比,在这里曾掀起过高山矮人和丘陵矮人手足阋墙的矮人门战役。", new Coordinate_1.default(1, 6)),
    "6": new Town_1.default("6", "格林尼治", "自称是人类最古老的村落,因临近矮人王国而时常成为斗争的前源,传统上从事护送商队穿越沙漠的工作,但信誉始终是最大问题。", new Coordinate_1.default(1, 3)),
    "7": new Town_1.default("7", "萨拉镇", "多种族混居的城市,各种珍稀物品的输入输出地,唯一即使在战争中也会全年都对其他种族开放的城市,尽管如此,仍然能感到某种难以言明的不调合感。", new Coordinate_1.default(3, 5)),
    "8": new Town_1.default("8", "海文", "矮人族连接山区和草原的重要中转站,春季会在附近原野举行大型交易会,是无论什么种族也会受到平等接待的地方。", new Coordinate_1.default(4, 11)),
    "9": new Town_1.default("9", "黄昏之都", "精灵们称呼此地为“艾本德”精灵语意为“神圣的黄昏”。据说环绕城市的一草一木都是古代精灵的化身,在此地时常可见到上年纪的精灵,足以证明精灵并非不老不死,在精灵族的传说中,此地将是本族最终安睡之地。", new Coordinate_1.default(5, 14)),
    "10": new Town_1.default("10", "圣克鲁斯堡", "旧神殿所在之地,新旧城都充满魅力,既是著名观光都市,也是重要的宗教圣地,这里有着全大陆信仰的中心“光之神殿”。", new Coordinate_1.default(5, 6)),
    "11": new Town_1.default("11", "泰法城", "精灵所修建的完整灌溉系统的农业城市,重要的粮食蔬果生产地,此地出产的各种水果酒都享有盛名,每年夏末举行的祭典会有限制的邀请其他种族成员参加,这对向来以自傲排他的精灵传统而言已经是相当开放的行为了。", new Coordinate_1.default(5, 8)),
    "12": new Town_1.default("12", "枫丹", "原帝国冬都,又名白露城,号称四百年无战之都。大陆联合商会所在地,无数传说的源头,号称大冒险大恋爱的起点。", new Coordinate_1.default(6, 10)),
    "13": new Town_1.default("13", "自由港_赞特", "大陆南岸著名的自由城市,也是全大陆最大的贸易港。不属于大陆任何势力,由当地人组成的三级议会管理着城市,拥有绝对的自治。自古就流传着在此能通过各种渠道买到各种你所能想象以及想象不到的东西。", new Coordinate_1.default(5, 0)),
    "14": new Town_1.default("14", "火之都", "军事化气氛浓厚的矮人都市,热火朝天的锻造之城,因为临近火山口,故得此名,囤积的兵器充斥山腹改造的仓库。", new Coordinate_1.default(5, 2)),
    "15": new Town_1.default("15", "土之域", "山中小都市,露出地面的矮人都市,传说为人类遗留,但地点却远离人类文明影响的范围,接近地精族,故而专攻兵器装饰用宝石的研磨。", new Coordinate_1.default(10, 2)),
    "16": new Town_1.default("16", "瓦伦要塞", "边境要塞, 因邻接半兽人土地,军事化气氛浓厚,几乎是全男子编制的要塞都市,但重要的食粮输入也是通 过此地进行,所以时常充满着怪异的紧张气氛。", new Coordinate_1.default(11, 11)),
    "17": new Town_1.default("17", "梵", "居住着人马族重要长老的小城,洋溢着仿佛时光停滞般悠闲气氛的山中秘境,人马族的贤者之塔也建造在此,因为其中藏着重要的预言书,故而对其他种族严格戒备。", new Coordinate_1.default(7, 3)),
    "18": new Town_1.default("18", "日尔曼尼亚", "野蛮人重要的据点,虽然生活着半数以上的平民,同时也是半军事化的壁垒,秋季有长达半个月的狩猎大会。", new Coordinate_1.default(7, 8)),
    "19": new Town_1.default("19", "水之城", "又称“废弃的水之城壁”,在与大湖连接的村子里,有着明显是人类遗迹的建筑,被当作是便利的集会场所使用着,传说这里有半兽人唯一的藏书室。", new Coordinate_1.default(9, 5)),
    "20": new Town_1.default("20", "埃达", "防备着矮人城市圈的小型要塞,地震曾多次摧毁整个城市,目前的城市建造在矮人族废弃的矿洞之中,大概会因为维持费过高被放弃吧。", new Coordinate_1.default(11, 5)),
    "21": new Town_1.default("21", "柯利亚", "和矮人都市圈连接的小城市,农耕传统悠久,盛产香菜之类的烹饪用料,饮食业发达,目前正致力推广清淡素食。", new Coordinate_1.default(12, 4)),
    "22": new Town_1.default("22", "格兰特", "人马族密语中伟大的意思,是极为独特的人马族栖息之地,宁静的学问之都,有整个大陆最大的图书馆和第 一代大魔法师爱德华的陵墓,发现温泉后,也逐渐发展起疗养旅游业。", new Coordinate_1.default(11, 7)),
    "23": new Town_1.default("23", "斯坎", "最靠近食人魔所在的城市,由纯法师血统者构成的研究者群体建造,为的是就近监视、研究最古老的食人魔 种族,又称\"性格扭曲者之城\"。", new Coordinate_1.default(10, 8)),
    "24": new Town_1.default("24", "龙牙堡", "又名龙之牙,野蛮人,人类和其他种族战争中建立的要塞,城市盘踞建造在山岩上,因地势险要,历来在此发生的战斗不计其数。死伤者鲜血早已渗透了要塞附近的土壤,远远望去,裸露的岩石形貌狰狞,周围隐透血色,宛如泣血龙牙。", new Coordinate_1.default(8, 9)),
    "25": new Town_1.default("25", "海布里", "半兽人 贝里萨利乌斯族生活的集落,是半兽人中最为勇猛、尚武的一支,如今正遭遇百年不遇的人口锐减,百年前曾和人类共同作战,据信村中仍有混血的后代,出产美酒,被誉为大陆第一的珍酿。", new Coordinate_1.default(7, 11)),
    "26": new Town_1.default("26", "风之谷", "又一邻接人马族据点的村落,非常偏僻隐蔽,传说中三族勇者用来存放光明神器的地点,唯有神器仍在,才能镇丄压黑暗势力卷土重来,奇妙的是矮人族却将此地视为不祥之地。", new Coordinate_1.default(8, 12)),
    "27": new Town_1.default("27", "不归森林", "传说最初是吞噬无数人性命的黑色森林,又传是埋葬着化身为魔的战败神的坟墓,但是真相已经湮没在历史和频繁发生的地震中,因为设有保护性禁制结界,所以体力系和黑暗系在此地进行战斗会很吃亏。", new Coordinate_1.default(9, 13)),
    "28": new Town_1.default("28", "特罗尔", "以神话中的食人巨妖命名的城市,地处沙漠区内最外侧绿州边缘,是唯一非人类占多数的人类都市,又称暗 之都,在食人魔的势力圈里奇妙地存在着,流行着既非人类又非食人魔共存不可思议的生活方式。", new Coordinate_1.default(13, 14))
};
module.exports = TownLoader;


/***/ }),
/* 48 */
/***/ ((module) => {

"use strict";

class Town {
    constructor(id, name, description, coordinate) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.coordinate = coordinate;
    }
    asText() {
        return "(" + this.id + ") " + this.name + " " + this.coordinate.asText();
    }
    get nameTitle() {
        let title = "";
        for (let i = 0; i < this.name.length; i++) {
            title += this.name.charAt(i);
            if (i !== this.name.length - 1) {
                title += " ";
            }
        }
        return title;
    }
}
module.exports = Town;


/***/ }),
/* 49 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const StringUtils_1 = __importDefault(__webpack_require__(6));
const Role_1 = __importDefault(__webpack_require__(50));
const BankAccount_1 = __importDefault(__webpack_require__(51));
const TownBankPage_1 = __importDefault(__webpack_require__(52));
class TownBankPageParser {
    parse(html) {
        return __awaiter(this, void 0, void 0, function* () {
            const page = new TownBankPage_1.default(new Role_1.default(), new BankAccount_1.default());
            const table = $(html).find("td:contains('姓名')")
                .filter((_idx, td) => {
                return $(td).text() === "姓名";
            })
                .closest("table");
            table.find("tr:first")
                .next()
                .find("td:first")
                .filter((_idx, td) => {
                page.role.name = $(td).text();
                return true;
            })
                .next()
                .filter((_idx, td) => {
                page.role.level = parseInt($(td).text());
                return true;
            })
                .next()
                .filter((_idx, td) => {
                page.role.attribute = StringUtils_1.default.substringBefore($(td).text(), "属");
                return true;
            })
                .next()
                .filter((_idx, td) => {
                page.role.career = $(td).text();
                return true;
            })
                .parent()
                .next()
                .find("td:first")
                .next()
                .filter((_idx, td) => {
                page.role.cash = parseInt(StringUtils_1.default.substringBefore($(td).text(), " GOLD"));
                return true;
            });
            const font = $(html).find("font:contains('现在的所持金')")
                .filter((_idx, font) => {
                const s = $(font).text();
                return s.startsWith(" ") && s.includes("现在的所持金");
            });
            let s = font.text();
            s = StringUtils_1.default.substringBefore(s, "现在的所持金");
            page.account.name = s.substring(1);
            page.account.cash = parseInt($(font).find("font:first").text());
            page.account.saving = parseInt($(font).find("font:last").text());
            return page;
        });
    }
}
module.exports = TownBankPageParser;


/***/ }),
/* 50 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Constants_1 = __importDefault(__webpack_require__(11));
const StringUtils_1 = __importDefault(__webpack_require__(6));
class Role {
    get imageHtml() {
        const src = Constants_1.default.POCKET_DOMAIN + "/image/head/" + this.image;
        return "<img src='" + src + "' alt='" + this.name + "' width='64' height='64' id='roleImage'>";
    }
    get experienceHtml() {
        if (this.experience >= 14900) {
            return "MAX";
        }
        else {
            return this.experience.toString();
        }
    }
    parseHealth(s) {
        if (s.includes("/")) {
            this.health = parseInt(StringUtils_1.default.substringBeforeSlash(s));
            this.maxHealth = parseInt(StringUtils_1.default.substringAfterSlash(s));
        }
        else {
            this.health = parseInt(s);
        }
    }
    parseMana(s) {
        if (s.includes("/")) {
            this.mana = parseInt(StringUtils_1.default.substringBeforeSlash(s));
            this.maxMana = parseInt(StringUtils_1.default.substringAfterSlash(s));
        }
        else {
            this.mana = parseInt(s);
        }
    }
    asShortText() {
        return this.name + " " + this.level +
            " " + this.health + "/" + this.maxHealth +
            " " + this.mana + "/" + this.maxMana +
            " " + this.attack +
            " " + this.defense +
            " " + this.specialAttack +
            " " + this.specialDefense +
            " " + this.speed;
    }
}
module.exports = Role;


/***/ }),
/* 51 */
/***/ ((module) => {

"use strict";

class BankAccount {
    get total() {
        return this.cash + this.saving;
    }
}
module.exports = BankAccount;


/***/ }),
/* 52 */
/***/ ((module) => {

"use strict";

class TownBankPage {
    constructor(role, account) {
        this.role = role;
        this.account = account;
    }
}
module.exports = TownBankPage;


/***/ }),
/* 53 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _EquipmentLocalStorage_credential;
const lodash_1 = __importDefault(__webpack_require__(4));
const CommentBoard_1 = __importDefault(__webpack_require__(54));
const CastleInformation_1 = __importDefault(__webpack_require__(55));
const CastleWarehouse_1 = __importDefault(__webpack_require__(58));
const PersonalEquipmentManagement_1 = __importDefault(__webpack_require__(61));
const RoleEquipmentStatusStorage_1 = __importDefault(__webpack_require__(63));
const TreasureBag_1 = __importDefault(__webpack_require__(65));
class EquipmentLocalStorage {
    constructor(credential) {
        _EquipmentLocalStorage_credential.set(this, void 0);
        __classPrivateFieldSet(this, _EquipmentLocalStorage_credential, credential, "f");
    }
    triggerUpdateEquipmentStatus(battleCount) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    // 自动保存启用时,战数尾数为97时,触发装备保存
                    const doStorage = (battleCount % 100 === 97);
                    if (doStorage) {
                        CommentBoard_1.default.writeMessage("<br>开始更新装备状态......");
                        this.updateEquipmentStatus().then(() => resolve());
                    }
                    else {
                        resolve();
                    }
                });
            })();
        });
    }
    updateEquipmentStatus() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    findAllEquipments(__classPrivateFieldGet(this, _EquipmentLocalStorage_credential, "f")).then(equipmentList => {
                        const equipmentStatusList = [];
                        for (const equipment of equipmentList) {
                            if (equipment.isItem && (equipment.name !== "宠物蛋" && equipment.name !== "藏宝图" && equipment.name !== "威力宝石")) {
                                continue;
                            }
                            let s = "";
                            s += lodash_1.default.escape(equipment.fullName);
                            s += "/";
                            s += equipment.category;
                            s += "/";
                            s += equipment.power;
                            s += "/";
                            s += equipment.weight;
                            s += "/";
                            s += equipment.endure;
                            s += "/";
                            s += equipment.additionalPower;
                            s += "/";
                            s += equipment.additionalWeight;
                            s += "/";
                            s += equipment.additionalLuck;
                            s += "/";
                            s += equipment.experience;
                            s += "/";
                            s += equipment.location;
                            equipmentStatusList.push(s);
                        }
                        RoleEquipmentStatusStorage_1.default.getInstance()
                            .write(__classPrivateFieldGet(this, _EquipmentLocalStorage_credential, "f").id, JSON.stringify(equipmentStatusList))
                            .then(() => {
                            resolve();
                        });
                    });
                });
            })();
        });
    }
}
_EquipmentLocalStorage_credential = new WeakMap();
function findAllEquipments(credential) {
    return __awaiter(this, void 0, void 0, function* () {
        return yield (() => {
            return new Promise(resolve => {
                const allEquipments = [];
                new PersonalEquipmentManagement_1.default(credential).open().then(equipmentPage => {
                    const roleName = equipmentPage.role.name;
                    new CastleInformation_1.default().load(roleName)
                        .then(castle => {
                        // Castle found
                        parseEquipments(credential, allEquipments, equipmentPage, castle, () => resolve(allEquipments));
                    })
                        .catch(() => {
                        // No castle found
                        parseEquipments(credential, allEquipments, equipmentPage, null, () => resolve(allEquipments));
                    });
                });
            });
        })();
    });
}
function parseEquipments(credential, allEquipments, equipmentPage, castle, handler) {
    lodash_1.default.forEach(equipmentPage.equipmentList, it => {
        it.location = "P";
        allEquipments.push(it);
    });
    const bag = equipmentPage.findTreasureBag();
    if (bag !== null) {
        new TreasureBag_1.default(credential).open(bag.index).then(bagPage => {
            lodash_1.default.forEach(bagPage.equipmentList, it => {
                it.location = "B";
                allEquipments.push(it);
            });
            parseWarehouseEquipments(credential, allEquipments, castle, handler);
        });
    }
    else {
        parseWarehouseEquipments(credential, allEquipments, castle, handler);
    }
}
function parseWarehouseEquipments(credential, allEquipments, castle, handler) {
    if (castle === null) {
        handler();
    }
    else {
        new CastleWarehouse_1.default(credential).open().then(warehousePage => {
            lodash_1.default.forEach(warehousePage.storageEquipmentList, it => {
                it.location = "W";
                allEquipments.push(it);
            });
            handler();
        });
    }
}
module.exports = EquipmentLocalStorage;


/***/ }),
/* 54 */
/***/ ((module) => {

"use strict";

class CommentBoard {
    static createCommentBoard(imageHtml) {
        if ($("#commentBoard").length > 0) {
            return;
        }
        let html = "";
        html += "<table style='background-color:#888888;border-width:0;width:100%'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0' id='commentBoardManager'>" + imageHtml + "</td>";
        html += "<td style='background-color:#F8F0E0;width:100%' id='commentBoard'></td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("body:first").find("div:last").before($("<div id='commentBoardContainer'></div>"));
        $("#commentBoardContainer").html(html);
    }
    static writeMessage(message) {
        if ($("#commentBoard").length > 0) {
            let html = $("#commentBoard").html();
            html += message;
            $("#commentBoard").html(html);
        }
    }
}
module.exports = CommentBoard;


/***/ }),
/* 55 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Coordinate_1 = __importDefault(__webpack_require__(5));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const Castle_1 = __importDefault(__webpack_require__(56));
const CastleInformationPage_1 = __importDefault(__webpack_require__(57));
class CastleInformation {
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    NetworkUtils_1.default.get("castle_print.cgi").then(html => {
                        const page = CastleInformation.parsePage(html);
                        resolve(page);
                    });
                });
            })();
        });
    }
    load(roleName) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise((resolve, reject) => {
                    this.open().then(page => {
                        const castle = page.findByRoleName(roleName);
                        if (castle === null) {
                            reject();
                        }
                        else {
                            resolve(castle);
                        }
                    });
                });
            })();
        });
    }
    static parsePage(html) {
        const castleList = [];
        $(html).find("td").each(function (_idx, td) {
            const text = $(td).text();
            if (text.endsWith(" (自购)")) {
                const name = $(td).prev().text();
                const owner = text.substring(0, text.indexOf(" (自购)"));
                let location = $(td).next().text();
                location = StringUtils_1.default.substringBetween(location, "(", ")");
                let x = StringUtils_1.default.substringBefore(location, ",");
                let y = StringUtils_1.default.substringAfter(location, ",");
                const coordinate = new Coordinate_1.default(parseInt(x), parseInt(y));
                const castle = new Castle_1.default();
                castle.name = name;
                castle.owner = owner;
                castle.coordinate = coordinate;
                castleList.push(castle);
            }
        });
        const page = new CastleInformationPage_1.default();
        page.castleList = castleList;
        return page;
    }
}
module.exports = CastleInformation;


/***/ }),
/* 56 */
/***/ ((module) => {

"use strict";

class Castle {
}
module.exports = Castle;


/***/ }),
/* 57 */
/***/ ((module) => {

"use strict";

class CastleInformationPage {
    findByRoleName(roleName) {
        for (const castle of this.castleList) {
            if (castle.owner === roleName) {
                return castle;
            }
        }
        return null;
    }
}
module.exports = CastleInformationPage;


/***/ }),
/* 58 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastleWarehouse_credential;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const CastleWarehousePage_1 = __importDefault(__webpack_require__(59));
const Equipment_1 = __importDefault(__webpack_require__(60));
class CastleWarehouse {
    constructor(credential) {
        _CastleWarehouse_credential.set(this, void 0);
        __classPrivateFieldSet(this, _CastleWarehouse_credential, credential, "f");
    }
    static parsePage(pageHtml) {
        return doParsePage(pageHtml);
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential) => {
                return new Promise(resolve => {
                    const request = credential.asRequestMap();
                    request.set("mode", "CASTLE_ITEM");
                    NetworkUtils_1.default.post("castle.cgi", request)
                        .then(pageHtml => {
                        const page = CastleWarehouse.parsePage(pageHtml);
                        resolve(page);
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _CastleWarehouse_credential, "f"));
        });
    }
    putInto(indexList) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise((resolve, reject) => {
                    if (indexList.length === 0) {
                        reject();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _CastleWarehouse_credential, "f").asRequestMap();
                    for (const index of indexList) {
                        request.set("item" + index, index.toString());
                    }
                    request.set("chara", "1");
                    request.set("mode", "CASTLE_ITEMSTORE");
                    NetworkUtils_1.default.post("castle.cgi", request).then(html => {
                        MessageBoard_1.default.processResponseMessage(html);
                        resolve();
                    });
                });
            };
            return yield action();
        });
    }
    takeOut(indexList) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise((resolve, reject) => {
                    if (indexList.length === 0) {
                        reject();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _CastleWarehouse_credential, "f").asRequestMap();
                    for (const index of indexList) {
                        request.set("item" + index, index.toString());
                    }
                    request.set("chara", "1");
                    request.set("mode", "CASTLE_ITEMWITHDRAW");
                    NetworkUtils_1.default.post("castle.cgi", request).then(html => {
                        MessageBoard_1.default.processResponseMessage(html);
                        resolve();
                    });
                });
            };
            return yield action();
        });
    }
}
_CastleWarehouse_credential = new WeakMap();
function doParsePage(pageHtml) {
    const page = new CastleWarehousePage_1.default();
    const s = $(pageHtml).find("td:contains('所持金')")
        .filter(function () {
        return $(this).text() === "所持金";
    })
        .next()
        .text();
    page.roleCash = parseInt(StringUtils_1.default.substringBefore(s, " GOLD"));
    page.personalEquipmentList = __parseCastleWareHousePersonalEquipmentList(pageHtml);
    page.storageEquipmentList = __parseCastleWareHouseStorageEquipmentList(pageHtml);
    return page;
}
function __parseCastleWareHousePersonalEquipmentList(pageHtml) {
    const equipmentList = [];
    $(pageHtml).find("table")
        .filter(function (_idx) {
        return _idx == 2;
    })
        .each(function (_idx, element) {
        $(element).find("input:checkbox")
            .each(function (_idx, checkbox) {
            const c0 = $(checkbox).parent();
            const c1 = c0.next();
            const c2 = c1.next();
            const c3 = c2.next();
            const c4 = c3.next();
            const c5 = c4.next();
            const c6 = c5.next();
            const c7 = c6.next();
            const c8 = c7.next();
            const c9 = c8.next();
            const c10 = c9.next();
            const c11 = c10.next();
            const c12 = c11.next();
            const c13 = c12.next();
            const c14 = c13.next();
            const c15 = c14.next();
            const c16 = c15.next();
            const c17 = c16.next();
            const equipment = new Equipment_1.default();
            equipment.index = parseInt($(checkbox).val());
            equipment.selectable = !$(checkbox).prop("disabled");
            equipment.using = c1.text() === "★";
            equipment.parseName(c2.html());
            equipment.category = c3.text();
            equipment.power = parseInt(c4.text());
            equipment.weight = parseInt(c5.text());
            equipment.parseEndure(c6.text());
            equipment.requiredCareer = c7.text();
            equipment.requiredAttack = parseInt(c8.text());
            equipment.requiredDefense = parseInt(c9.text());
            equipment.requiredSpecialAttack = parseInt(c10.text());
            equipment.requiredSpecialDefense = parseInt(c11.text());
            equipment.requiredSpeed = parseInt(c12.text());
            equipment.additionalPower = parseInt(c13.text());
            equipment.additionalWeight = parseInt(c14.text());
            equipment.additionalLuck = parseInt(c15.text());
            equipment.experience = parseInt(c16.text());
            equipment.attribute = c17.text();
            equipmentList.push(equipment);
        });
    });
    return equipmentList;
}
function __parseCastleWareHouseStorageEquipmentList(pageHtml) {
    const equipmentList = [];
    $(pageHtml).find("table")
        .filter(function (_idx) {
        return _idx == 3;
    })
        .each(function (_idx, element) {
        $(element).find("input:checkbox")
            .each(function (_idx, checkbox) {
            const c1 = $(checkbox).parent();
            const c2 = $(c1).next();
            const c3 = $(c2).next();
            const c4 = $(c3).next();
            const c5 = $(c4).next();
            const c6 = $(c5).next();
            const c7 = $(c6).next();
            const c8 = $(c7).next();
            const c9 = $(c8).next();
            const c10 = $(c9).next();
            const c11 = $(c10).next();
            const c12 = $(c11).next();
            const c13 = $(c12).next();
            const c14 = $(c13).next();
            const c15 = $(c14).next();
            const c16 = $(c15).next();
            const c17 = $(c16).next();
            const c18 = $(c17).next();
            const equipment = new Equipment_1.default();
            equipment.index = parseInt($(checkbox).val());
            equipment.selectable = true;
            equipment.using = false;
            equipment.parseName($(c3).html());
            equipment.category = $(c4).text();
            equipment.power = parseInt($(c5).text());
            equipment.weight = parseInt($(c6).text());
            equipment.parseEndure($(c7).text());
            equipment.requiredCareer = $(c8).text();
            equipment.requiredAttack = parseInt($(c9).text());
            equipment.requiredDefense = parseInt($(c10).text());
            equipment.requiredSpecialAttack = parseInt($(c11).text());
            equipment.requiredSpecialDefense = parseInt($(c12).text());
            equipment.requiredSpeed = parseInt($(c13).text());
            equipment.additionalPower = parseInt($(c14).text());
            equipment.additionalWeight = parseInt($(c15).text());
            equipment.additionalLuck = parseInt($(c16).text());
            equipment.experience = parseInt($(c17).text());
            equipment.attribute = $(c18).text();
            equipmentList.push(equipment);
        });
    });
    return equipmentList;
}
module.exports = CastleWarehouse;


/***/ }),
/* 59 */
/***/ ((module) => {

"use strict";

class CastleWarehousePage {
}
module.exports = CastleWarehousePage;


/***/ }),
/* 60 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const Coordinate_1 = __importDefault(__webpack_require__(5));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const TownLoader_1 = __importDefault(__webpack_require__(47));
const PROHIBIT_SELLING_ITEM_LIST = [
    "千与千寻",
    "勿忘我",
    "神枪 永恒",
    "霸邪斧 天煌",
    "魔刀 哭杀",
    "神器 苍穹",
    "魔神器 幻空",
    "真·圣剑 苍白的正义",
    "双经斩",
    "千幻碧水猿洛克奇斯",
    "地纹玄甲龟斯特奥特斯",
    "幽冥黑鳞蟒罗尼科斯",
    "火睛混沌兽哈贝达",
    "羽翅圣光虎阿基勒斯",
    "金翅追日鹰庞塔雷斯",
    "风翼三足凤纳托利斯",
    "圣皇铠甲 天威",
    "薄翼甲",
    "魔盔 虚无",
    "神冠 灵通",
    "龙",
    "玉佩",
    "宠物蛋"
];
const NO_EXPERIENCE_ITEM_LIST = [
    "大师球",
    "宗师球",
    "超力怪兽球",
    "宠物蛋"
];
const NONE_REPAIRABLE_ITEM_LIST = [
    "大师球",
    "宗师球",
    "超力怪兽球",
    "宠物蛋"
];
const ATTRIBUTE_HEAVY_ARMOR_ITEM_LIST = [
    "千幻碧水猿洛克奇斯",
    "地纹玄甲龟斯特奥特斯",
    "幽冥黑鳞蟒罗尼科斯",
    "火睛混沌兽哈贝达",
    "羽翅圣光虎阿基勒斯",
    "金翅追日鹰庞塔雷斯",
    "风翼三足凤纳托利斯"
];
class Equipment {
    static parse(text) {
        const ss = lodash_1.default.split(text, "/");
        const equipment = new Equipment();
        equipment.parseName(lodash_1.default.unescape(ss[0]));
        equipment.category = ss[1];
        equipment.power = lodash_1.default.parseInt(ss[2]);
        equipment.weight = lodash_1.default.parseInt(ss[3]);
        equipment.endure = lodash_1.default.parseInt(ss[4]);
        equipment.additionalPower = lodash_1.default.parseInt(ss[5]);
        equipment.additionalWeight = lodash_1.default.parseInt(ss[6]);
        equipment.additionalLuck = lodash_1.default.parseInt(ss[7]);
        equipment.experience = lodash_1.default.parseInt(ss[8]);
        equipment.location = ss[9];
        return equipment;
    }
    parseName(nameHtml) {
        this.nameHTML = PageUtils_1.default.fixBrokenImageIfNecessary(nameHtml);
        const s = PageUtils_1.default.convertHtmlToText(this.nameHTML);
        if (s.startsWith("齐心★")) {
            this.star = true;
            this.name = StringUtils_1.default.substringAfter(s, "齐心★");
        }
        else {
            this.star = false;
            this.name = s;
        }
    }
    parseEndure(endureText) {
        if (endureText.includes("/")) {
            const a = StringUtils_1.default.substringBeforeSlash(endureText);
            const b = StringUtils_1.default.substringAfterSlash(endureText);
            this.endure = parseInt(a);
            this.maxEndure = parseInt(b);
        }
        else {
            this.endure = parseInt(endureText);
        }
    }
    parseGemCount(gemCountText) {
        if (gemCountText.includes("/")) {
            const a = StringUtils_1.default.substringBeforeSlash(gemCountText);
            const b = StringUtils_1.default.substringAfterSlash(gemCountText);
            this.gemCount = parseInt(a);
            this.maxGemCount = parseInt(b);
        }
        else {
            this.endure = parseInt(gemCountText);
        }
    }
    parsePrice(priceHtml) {
        this.priceHTML = priceHtml;
        let s = PageUtils_1.default.convertHtmlToText(priceHtml);
        if (s.includes(" ")) {
            s = StringUtils_1.default.substringBefore(s, " ");
        }
        this.price = parseInt(s);
    }
    get locationOrder() {
        switch (this.location) {
            case "P":
                return 1;
            case "B":
                return 2;
            case "W":
                return 3;
            default:
                return 0;
        }
    }
    get nameOrder() {
        if (this.star) {
            return 0;
        }
        else if (lodash_1.default.startsWith(this.name, "20")) {
            return 1;
        }
        else {
            return 2;
        }
    }
    get categoryOrder() {
        if (this.isWeapon) {
            return 1;
        }
        if (this.isArmor) {
            return 2;
        }
        if (this.isAccessory) {
            return 3;
        }
        if (this.isItem) {
            return 4;
        }
        return 0;
    }
    get isWeapon() {
        return this.category === "武器";
    }
    get isArmor() {
        return this.category === "防具";
    }
    get isAccessory() {
        return this.category === "饰品";
    }
    get isItem() {
        return this.category === "物品";
    }
    get isTreasureBag() {
        return this.isItem && this.name === "百宝袋";
    }
    get isGoldenCage() {
        return this.isItem && this.name === "黄金笼子";
    }
    get isSellable() {
        if (this.selectable !== undefined && !this.selectable) {
            return false;
        }
        if (this.using !== undefined && this.using) {
            return false;
        }
        for (const it of PROHIBIT_SELLING_ITEM_LIST) {
            if (this.name.endsWith(it)) {
                return false;
            }
        }
        return true;
    }
    get isRepairable() {
        if (this.isItem) {
            return this.name.includes("(自动)");
        }
        else {
            return !NONE_REPAIRABLE_ITEM_LIST.includes(this.name);
        }
    }
    get isStorable() {
        if (this.using) {
            return false;
        }
        if (this.isItem) {
            return false;
        }
        return !NONE_REPAIRABLE_ITEM_LIST.includes(this.name);
    }
    get fullExperienceRatio() {
        if (this.isItem) {
            return -1;
        }
        if (NO_EXPERIENCE_ITEM_LIST.includes(this.name)) {
            return -1;
        }
        let maxExperience = 0;
        if (isAttributeHeavyArmor(this.name)) {
            // 属性重铠满级经验为76000
            maxExperience = 76000;
        }
        else if (this.power !== 0) {
            const powerForUse = Math.abs(this.power);
            maxExperience = Math.floor(powerForUse * 0.2) * 1000;
        }
        if (maxExperience === 0) {
            return -1;
        }
        if (this.experience >= maxExperience) {
            return 1;
        }
        if (this.experience === 0) {
            return 0;
        }
        return this.experience / maxExperience;
    }
    get checkboxHTML() {
        if (this.selectable) {
            return "<input type='checkbox' name='item" + this.index + "' value='" + this.index + "' class='personal_checkbox'>";
        }
        else {
            return "";
        }
    }
    get usingHTML() {
        if (!this.using) {
            return "";
        }
        if (this.experience === undefined) {
            return "★";
        }
        const ratio = this.fullExperienceRatio;
        if (ratio === 1 || ratio < 0) {
            return "<span title='装备中' style='color:red'>★</span>";
        }
        else {
            return "<span title='装备中'>★</span>";
        }
    }
    get experienceHTML() {
        if (this.isItem) {
            if (this.name === "藏宝图") {
                const coordinate = new Coordinate_1.default(this.power, this.weight);
                if (!coordinate.isAvailable) {
                    return "<b style='color:red'>活动图</b>";
                }
                const town = TownLoader_1.default.load(coordinate);
                if (town !== null) {
                    return "<b style='color:red'>" + town.name + "</b>";
                }
                else {
                    return "-";
                }
            }
            else {
                return "-";
            }
        }
        const ratio = this.fullExperienceRatio;
        if (ratio < 0) {
            return "-";
        }
        if (ratio === 1) {
            return "<span style='color:red' title='" + this.experience + "'>MAX</span>";
        }
        if (SetupLoader_1.default.isExperienceProgressBarEnabled()) {
            const progressBar = PageUtils_1.default.generateProgressBarHTML(ratio);
            return "<span title='" + this.experience + " (" + (ratio * 100).toFixed(2) + "%)'>" + progressBar + "</span>";
        }
        else {
            return this.experience.toString();
        }
    }
    get fullName() {
        if (this.star) {
            return "齐心★" + this.name;
        }
        else {
            return this.name;
        }
    }
    get endureHtml() {
        if (this.isItem && !this.name.includes("自动")) {
            return "-";
        }
        if (this.maxEndure === undefined) {
            return this.endure.toString();
        }
        else {
            return this.endure + "/" + this.maxEndure;
        }
    }
    get gemCountHtml() {
        if (this.maxGemCount === undefined) {
            if (this.gemCount === undefined || this.gemCount === 0) {
                return "-";
            }
            else {
                return this.gemCount.toString();
            }
        }
        else {
            return "<span style='color:red'>" + this.gemCount + "</span> / <span style='color:red'>" + this.maxGemCount + "</span>";
        }
    }
    get requiredCareerHtml() {
        if (this.requiredCareer === undefined || this.requiredCareer === "所有职业") {
            return "-";
        }
        return this.requiredCareer;
    }
    get requiredAttackHtml() {
        if (this.requiredAttack === undefined || this.requiredAttack === 0) {
            return "-";
        }
        return this.requiredAttack.toString();
    }
    get requiredDefenseHtml() {
        if (this.requiredDefense === undefined || this.requiredDefense === 0) {
            return "-";
        }
        return this.requiredDefense.toString();
    }
    get requiredSpecialAttackHtml() {
        if (this.requiredSpecialAttack === undefined || this.requiredSpecialAttack === 0) {
            return "-";
        }
        return this.requiredSpecialAttack.toString();
    }
    get requiredSpecialDefenseHtml() {
        if (this.requiredSpecialDefense === undefined || this.requiredSpecialDefense === 0) {
            return "-";
        }
        return this.requiredSpecialDefense.toString();
    }
    get requiredSpeedHtml() {
        if (this.requiredSpeed === undefined || this.requiredSpeed === 0) {
            return "-";
        }
        return this.requiredSpeed.toString();
    }
    get additionalPowerHtml() {
        if (this.additionalPower === undefined || this.additionalPower === 0) {
            return "-";
        }
        return this.additionalPower.toString();
    }
    get additionalWeightHtml() {
        if (this.additionalWeight === undefined || this.additionalWeight === 0) {
            return "-";
        }
        return this.additionalWeight.toString();
    }
    get additionalLuckHtml() {
        if (this.additionalLuck === undefined || this.additionalLuck === 0) {
            return "-";
        }
        return this.additionalLuck.toString();
    }
    get attributeHtml() {
        if (this.attribute === undefined || this.attribute === "无") {
            return "-";
        }
        return this.attribute;
    }
    get buttonTitle() {
        if (this.isItem) {
            return "使用";
        }
        let title = "装备";
        if (this.using) {
            title = "卸下";
        }
        return title;
    }
    static sortEquipmentList(source) {
        const target = lodash_1.default.clone(source);
        target.sort(Equipment.sorter);
        return target;
    }
    static sorter(a, b) {
        if (!SetupLoader_1.default.isEquipmentPetSortEnabled()) {
            return 0;
        }
        let ret = a.locationOrder - b.locationOrder;
        if (ret !== 0)
            return ret;
        ret = a.nameOrder - b.nameOrder;
        if (ret !== 0)
            return ret;
        ret = (a.requiredCareer !== "所有职业" ? 0 : 1) - (b.requiredCareer !== "所有职业" ? 0 : 1);
        if (ret !== 0)
            return ret;
        let ca = (a.requiredCareer === "所有职业") ? "" : a.requiredCareer;
        ca = ca ? ca : "";
        let cb = (b.requiredCareer === "所有职业") ? "" : b.requiredCareer;
        cb = cb ? cb : "";
        ret = cb.localeCompare(ca);
        if (ret !== 0)
            return ret;
        ret = a.categoryOrder - b.categoryOrder;
        if (ret !== 0)
            return ret;
        let a1 = a.star ? 1 : 0;
        let b1 = b.star ? 1 : 0;
        ret = a1 - b1;
        if (ret !== 0) {
            return ret;
        }
        ret = b.power - a.power;
        if (ret !== 0) {
            return ret;
        }
        ret = a.fullName.localeCompare(b.fullName);
        if (ret !== 0) {
            return ret;
        }
        return b.additionalPower - a.additionalPower;
    }
}
function isAttributeHeavyArmor(name) {
    for (const it of ATTRIBUTE_HEAVY_ARMOR_ITEM_LIST) {
        if (name.endsWith(it)) {
            return true;
        }
    }
    return false;
}
module.exports = Equipment;


/***/ }),
/* 61 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalEquipmentManagement_credential, _PersonalEquipmentManagement_townId;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const Role_1 = __importDefault(__webpack_require__(50));
const Equipment_1 = __importDefault(__webpack_require__(60));
const PersonalEquipmentManagementPage_1 = __importDefault(__webpack_require__(62));
class PersonalEquipmentManagement {
    constructor(credential, townId) {
        _PersonalEquipmentManagement_credential.set(this, void 0);
        _PersonalEquipmentManagement_townId.set(this, void 0);
        __classPrivateFieldSet(this, _PersonalEquipmentManagement_credential, credential, "f");
        __classPrivateFieldSet(this, _PersonalEquipmentManagement_townId, townId, "f");
    }
    static parsePage(html) {
        return __parsePage(html);
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _PersonalEquipmentManagement_credential, "f").asRequestMap();
                    request.set("mode", "USE_ITEM");
                    if (__classPrivateFieldGet(this, _PersonalEquipmentManagement_townId, "f") !== undefined) {
                        request.set("town", __classPrivateFieldGet(this, _PersonalEquipmentManagement_townId, "f"));
                    }
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        const page = PersonalEquipmentManagement.parsePage(html);
                        resolve(page);
                    });
                });
            };
            return yield action();
        });
    }
    use(indexList) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise((resolve, reject) => {
                    if (indexList.length === 0) {
                        reject();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _PersonalEquipmentManagement_credential, "f").asRequestMap();
                    request.set("chara", "1");
                    for (const index of indexList) {
                        request.set("item" + index, index.toString());
                    }
                    request.set("word", "");
                    request.set("mode", "USE");
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        MessageBoard_1.default.processResponseMessage(html);
                        resolve();
                    });
                });
            })();
        });
    }
}
_PersonalEquipmentManagement_credential = new WeakMap(), _PersonalEquipmentManagement_townId = new WeakMap();
function __parsePage(html) {
    const role = new Role_1.default();
    $(html).find("td:contains('LV')")
        .filter((idx, td) => $(td).text() === "LV")
        .closest("tr")
        .next()
        .find("td:first")
        .each((idx, td) => {
        role.name = $(td).text();
    })
        .next()
        .each((idx, td) => {
        let s = $(td).text();
        role.level = parseInt(s);
    })
        .next()
        .each((idx, td) => {
        let s = $(td).text();
        role.parseHealth(s);
    })
        .next()
        .each((idx, td) => {
        let s = $(td).text();
        role.parseMana(s);
    })
        .next()
        .each((idx, td) => {
        role.attribute = $(td).text();
    })
        .next()
        .each((idx, td) => {
        role.career = $(td).text();
    })
        .parent()
        .next()
        .find("td:first")
        .next()
        .each((idx, td) => {
        let s = $(td).text();
        s = StringUtils_1.default.substringBefore(s, " GOLD");
        role.cash = parseInt(s);
    });
    const page = new PersonalEquipmentManagementPage_1.default();
    page.role = role;
    page.equipmentList = __parseEquipmentList(html);
    return page;
}
function __parseEquipmentList(html) {
    const equipmentList = [];
    $(html).find("input:checkbox").each(function (_idx, checkbox) {
        const equipment = new Equipment_1.default();
        const tr = $(checkbox).parent().parent();
        // index & selectable
        equipment.index = parseInt($(checkbox).val());
        equipment.selectable = !$(checkbox).prop("disabled");
        // using
        let s = $(tr).find("th:first").text();
        equipment.using = (s === "★");
        // name & star
        equipment.parseName($(tr).find("td:eq(1)").html());
        // category
        s = $(tr).find("td:eq(2)").text();
        equipment.category = s;
        // power & weight & endure
        s = $(tr).find("td:eq(3)").text();
        equipment.power = parseInt(s);
        s = $(tr).find("td:eq(4)").text();
        equipment.weight = parseInt(s);
        s = $(tr).find("td:eq(5)").text();
        equipment.endure = parseInt(s);
        // required career
        s = $(tr).find("td:eq(6)").text();
        equipment.requiredCareer = s;
        // required stats
        s = $(tr).find("td:eq(7)").text();
        equipment.requiredAttack = parseInt(s);
        s = $(tr).find("td:eq(8)").text();
        equipment.requiredDefense = parseInt(s);
        s = $(tr).find("td:eq(9)").text();
        equipment.requiredSpecialAttack = parseInt(s);
        s = $(tr).find("td:eq(10)").text();
        equipment.requiredSpecialDefense = parseInt(s);
        s = $(tr).find("td:eq(11)").text();
        equipment.requiredSpeed = parseInt(s);
        // additional
        s = $(tr).find("td:eq(12)").text();
        equipment.additionalPower = parseInt(s);
        s = $(tr).find("td:eq(13)").text();
        equipment.additionalWeight = parseInt(s);
        s = $(tr).find("td:eq(14)").text();
        equipment.additionalLuck = parseInt(s);
        // experience
        s = $(tr).find("td:eq(15)").text();
        equipment.experience = parseInt(s);
        // attribute
        s = $(tr).find("td:eq(16)").text();
        equipment.attribute = s;
        equipmentList.push(equipment);
    });
    return equipmentList;
}
module.exports = PersonalEquipmentManagement;


/***/ }),
/* 62 */
/***/ ((module) => {

"use strict";

class PersonalEquipmentManagementPage {
    get spaceCount() {
        return 20 - this.equipmentList.length;
    }
    findEquipment(index) {
        for (const equipment of this.equipmentList) {
            if (equipment.index === index) {
                return equipment;
            }
        }
        return null;
    }
    findTreasureBag() {
        for (const equipment of this.equipmentList) {
            if (equipment.isTreasureBag) {
                return equipment;
            }
        }
        return null;
    }
    findGoldenCage() {
        for (const equipment of this.equipmentList) {
            if (equipment.isGoldenCage) {
                return equipment;
            }
        }
        return null;
    }
}
module.exports = PersonalEquipmentManagementPage;


/***/ }),
/* 63 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const RoleEquipmentStatus_1 = __importDefault(__webpack_require__(64));
class RoleEquipmentStatusStorage {
    static getInstance() {
        return instance;
    }
    loads(idList) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db.transaction(["RoleEquipmentStatus"], "readonly")
                        .objectStore("RoleEquipmentStatus")
                        .getAll(); // Bad usage here
                    request.onerror = reject;
                    request.onsuccess = () => {
                        if (request.result) {
                            const dataMap = new Map();
                            for (const it of request.result) {
                                const data = new RoleEquipmentStatus_1.default();
                                data.id = it.id;
                                data.json = it.json;
                                data.updateTime = it.updateTime;
                                if (idList.includes(data.id)) {
                                    dataMap.set(data.id, data);
                                }
                            }
                            resolve(dataMap);
                        }
                        else {
                            reject();
                        }
                    };
                });
            })();
        });
    }
    write(id, json) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const document = {};
                    // @ts-ignore
                    document.id = id;
                    // @ts-ignore
                    document.json = json;
                    // @ts-ignore
                    document.updateTime = new Date().getTime();
                    const request = db.transaction(["RoleEquipmentStatus"], "readwrite")
                        .objectStore("RoleEquipmentStatus")
                        .put(document);
                    request.onerror = reject;
                    request.onsuccess = () => resolve();
                });
            })();
        });
    }
}
const instance = new RoleEquipmentStatusStorage();
module.exports = RoleEquipmentStatusStorage;


/***/ }),
/* 64 */
/***/ ((module) => {

"use strict";

class RoleEquipmentStatus {
}
module.exports = RoleEquipmentStatus;


/***/ }),
/* 65 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _TreasureBag_credential;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const Equipment_1 = __importDefault(__webpack_require__(60));
const TreasureBagPage_1 = __importDefault(__webpack_require__(66));
class TreasureBag {
    constructor(credential) {
        _TreasureBag_credential.set(this, void 0);
        __classPrivateFieldSet(this, _TreasureBag_credential, credential, "f");
    }
    static parsePage(html) {
        const equipmentList = [];
        $(html).find("input:checkbox").each(function (_idx, checkbox) {
            const equipment = new Equipment_1.default();
            const tr = $(checkbox).parent().parent();
            // index & selectable
            equipment.index = parseInt($(checkbox).val());
            equipment.selectable = true;
            // name & star
            equipment.parseName($(tr).find("td:eq(1)").html());
            // category
            let s = $(tr).find("td:eq(2)").text();
            equipment.category = s;
            // power & weight & endure
            s = $(tr).find("td:eq(3)").text();
            equipment.power = parseInt(s);
            s = $(tr).find("td:eq(4)").text();
            equipment.weight = parseInt(s);
            s = $(tr).find("td:eq(5)").text();
            equipment.endure = parseInt(s);
            // additional
            s = $(tr).find("td:eq(6)").text();
            equipment.additionalPower = parseInt(s);
            s = $(tr).find("td:eq(7)").text();
            equipment.additionalWeight = parseInt(s);
            s = $(tr).find("td:eq(8)").text();
            equipment.additionalLuck = parseInt(s);
            // experience
            s = $(tr).find("td:eq(9)").text();
            equipment.experience = parseInt(s);
            equipmentList.push(equipment);
        });
        const page = new TreasureBagPage_1.default();
        page.equipmentList = equipmentList;
        return page;
    }
    open(bagIndex) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise((resolve, reject) => {
                    if (bagIndex < 0) {
                        reject();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _TreasureBag_credential, "f").asRequestMap();
                    request.set("chara", "1");
                    request.set("item" + bagIndex, bagIndex.toString());
                    request.set("mode", "USE");
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        const page = TreasureBag.parsePage(html);
                        resolve(page);
                    });
                });
            };
            return yield action();
        });
    }
    putInto(indexList) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise((resolve, reject) => {
                    if (indexList.length === 0) {
                        reject();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _TreasureBag_credential, "f").asRequestMap();
                    request.set("chara", "1");
                    request.set("mode", "PUTINBAG");
                    for (const index of indexList) {
                        request.set("item" + index, index.toString());
                    }
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        MessageBoard_1.default.processResponseMessage(html);
                        resolve();
                    });
                });
            };
            return yield action();
        });
    }
    takeOut(indexList) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise((resolve, reject) => {
                    if (indexList.length === 0) {
                        reject();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _TreasureBag_credential, "f").asRequestMap();
                    request.set("mode", "GETOUTBAG");
                    for (const index of indexList) {
                        request.set("item" + index, index.toString());
                    }
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        MessageBoard_1.default.processResponseMessage(html);
                        resolve();
                    });
                });
            };
            return yield action();
        });
    }
    tryTakeOut(count) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise((resolve, reject) => {
                    if (count <= 0) {
                        reject();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _TreasureBag_credential, "f").asRequestMap();
                    request.set("mode", "GETOUTBAG");
                    for (let i = 0; i < count; i++) {
                        request.set("item" + i, i.toString());
                    }
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        MessageBoard_1.default.processResponseMessage(html);
                        resolve();
                    });
                });
            })();
        });
    }
}
_TreasureBag_credential = new WeakMap();
module.exports = TreasureBag;


/***/ }),
/* 66 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Equipment_1 = __importDefault(__webpack_require__(60));
class TreasureBagPage {
    get sortedEquipmentList() {
        return Equipment_1.default.sortEquipmentList(this.equipmentList);
    }
    get spaceCount() {
        return 50 - this.equipmentList.length;
    }
}
module.exports = TreasureBagPage;


/***/ }),
/* 67 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PetLocalStorage_instances, _PetLocalStorage_credential, _PetLocalStorage_findAllPets;
const lodash_1 = __importDefault(__webpack_require__(4));
const CommentBoard_1 = __importDefault(__webpack_require__(54));
const CastleInformation_1 = __importDefault(__webpack_require__(55));
const PersonalEquipmentManagement_1 = __importDefault(__webpack_require__(61));
const CastleRanch_1 = __importDefault(__webpack_require__(68));
const GoldenCage_1 = __importDefault(__webpack_require__(71));
const PersonalPetManagement_1 = __importDefault(__webpack_require__(74));
const RolePetMapStorage_1 = __importDefault(__webpack_require__(76));
const RolePetStatusStorage_1 = __importDefault(__webpack_require__(78));
const TownPetMapHouse_1 = __importDefault(__webpack_require__(80));
class PetLocalStorage {
    constructor(credential) {
        _PetLocalStorage_instances.add(this);
        _PetLocalStorage_credential.set(this, void 0);
        __classPrivateFieldSet(this, _PetLocalStorage_credential, credential, "f");
    }
    triggerUpdatePetMap(battleCount) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    // 自动保存启用时,战数尾数为83时,触发图鉴保存
                    const doStorage = (battleCount % 100 === 83);
                    if (doStorage) {
                        CommentBoard_1.default.writeMessage("<br>开始更新宠物图鉴......");
                        this.updatePetMap().then(() => resolve());
                    }
                    else {
                        resolve();
                    }
                });
            })();
        });
    }
    triggerUpdatePetStatus(battleCount) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    // 自动保存启用时,战数尾数为89时,触发宠物保存
                    const doStorage = (battleCount % 100 === 89);
                    if (doStorage) {
                        CommentBoard_1.default.writeMessage("<br>开始更新宠物状态......");
                        this.updatePetStatus().then(() => resolve());
                    }
                    else {
                        resolve();
                    }
                });
            })();
        });
    }
    updatePetMap() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    new TownPetMapHouse_1.default(__classPrivateFieldGet(this, _PetLocalStorage_credential, "f")).open().then(page => {
                        const json = page.asJson();
                        RolePetMapStorage_1.default.getInstance()
                            .write(__classPrivateFieldGet(this, _PetLocalStorage_credential, "f").id, json)
                            .then(() => {
                            resolve();
                        });
                    });
                });
            })();
        });
    }
    updatePetStatus() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    __classPrivateFieldGet(this, _PetLocalStorage_instances, "m", _PetLocalStorage_findAllPets).call(this).then(petList => {
                        const petStatusList = [];
                        for (const pet of petList) {
                            let s = "";
                            s += lodash_1.default.escape(pet.name);
                            s += "/";
                            s += pet.gender;
                            s += "/";
                            s += pet.level;
                            s += "/";
                            s += pet.maxHealth;
                            s += "/";
                            s += pet.attack;
                            s += "/";
                            s += pet.defense;
                            s += "/";
                            s += pet.specialAttack;
                            s += "/";
                            s += pet.specialDefense;
                            s += "/";
                            s += pet.speed;
                            s += "/";
                            s += pet.location;
                            petStatusList.push(s);
                        }
                        RolePetStatusStorage_1.default.getInstance()
                            .write(__classPrivateFieldGet(this, _PetLocalStorage_credential, "f").id, JSON.stringify(petStatusList))
                            .then(() => {
                            resolve();
                        });
                    });
                });
            })();
        });
    }
}
_PetLocalStorage_credential = new WeakMap(), _PetLocalStorage_instances = new WeakSet(), _PetLocalStorage_findAllPets = function _PetLocalStorage_findAllPets() {
    return __awaiter(this, void 0, void 0, function* () {
        return yield (() => {
            return new Promise(resolve => {
                const allPetList = [];
                new PersonalEquipmentManagement_1.default(__classPrivateFieldGet(this, _PetLocalStorage_credential, "f")).open().then(equipmentPage => {
                    const roleName = equipmentPage.role.name;
                    const goldenCage = equipmentPage.findGoldenCage();
                    new CastleInformation_1.default().load(roleName)
                        .then(castle => {
                        __parsePersonalPets(__classPrivateFieldGet(this, _PetLocalStorage_credential, "f"), allPetList, goldenCage, castle, () => {
                            resolve(allPetList);
                        });
                    })
                        .catch(() => {
                        __parsePersonalPets(__classPrivateFieldGet(this, _PetLocalStorage_credential, "f"), allPetList, goldenCage, null, () => {
                            resolve(allPetList);
                        });
                    });
                });
            });
        })();
    });
};
function __parsePersonalPets(credential, allPetList, goldenCage, castle, handler) {
    new PersonalPetManagement_1.default(credential).open().then(petPage => {
        for (const pet of petPage.petList) {
            pet.location = "P";
            allPetList.push(pet);
        }
        __parseCagePets(credential, allPetList, goldenCage, castle, handler);
    });
}
function __parseCagePets(credential, allPetList, goldenCage, castle, handler) {
    if (goldenCage === null) {
        __parseRanchPets(credential, allPetList, castle, handler);
    }
    else {
        new GoldenCage_1.default(credential).open(goldenCage.index).then(cagePage => {
            for (const pet of cagePage.petList) {
                pet.location = "C";
                allPetList.push(pet);
            }
            __parseRanchPets(credential, allPetList, castle, handler);
        });
    }
}
function __parseRanchPets(credential, allPetList, castle, handler) {
    if (castle === null) {
        handler();
    }
    else {
        new CastleRanch_1.default(credential).enter().then(ranchPage => {
            for (const pet of ranchPage.ranchPetList) {
                pet.location = "R";
                allPetList.push(pet);
            }
            handler();
        });
    }
}
module.exports = PetLocalStorage;


/***/ }),
/* 68 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastleRanch_credential;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const CastleRanchPage_1 = __importDefault(__webpack_require__(69));
const Pet_1 = __importDefault(__webpack_require__(70));
class CastleRanch {
    constructor(credential) {
        _CastleRanch_credential.set(this, void 0);
        __classPrivateFieldSet(this, _CastleRanch_credential, credential, "f");
    }
    static parseCastleRanchStatus(pageHtml) {
        const personalPetList = doParsePersonalPetList(pageHtml);
        const ranchPetList = doParseRanchPetList(pageHtml);
        const page = new CastleRanchPage_1.default();
        page.personalPetList = personalPetList;
        page.ranchPetList = ranchPetList;
        return page;
    }
    enter() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential) => {
                return new Promise(resolve => {
                    const request = credential.asRequest();
                    // @ts-ignore
                    request.mode = "CASTLE_PET";
                    NetworkUtils_1.default.sendPostRequest("castle.cgi", request, function (pageHtml) {
                        const ranchStatus = CastleRanch.parseCastleRanchStatus(pageHtml);
                        resolve(ranchStatus);
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _CastleRanch_credential, "f"));
        });
    }
    graze(index) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential, index) => {
                return new Promise(resolve => {
                    const request = credential.asRequest();
                    // @ts-ignore
                    request.select = index;
                    // @ts-ignore
                    request.mode = "CASTLE_PETSTORE";
                    NetworkUtils_1.default.sendPostRequest("castle.cgi", request, function (pageHtml) {
                        MessageBoard_1.default.processResponseMessage(pageHtml);
                        resolve();
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _CastleRanch_credential, "f"), index);
        });
    }
    summon(index) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential, index) => {
                return new Promise(resolve => {
                    const request = credential.asRequest();
                    // @ts-ignore
                    request.select = index;
                    // @ts-ignore
                    request.mode = "CASTLE_PETWITHDRAW";
                    NetworkUtils_1.default.sendPostRequest("castle.cgi", request, function (pageHtml) {
                        MessageBoard_1.default.processResponseMessage(pageHtml);
                        resolve();
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _CastleRanch_credential, "f"), index);
        });
    }
}
_CastleRanch_credential = new WeakMap();
function doParsePersonalPetList(pageHtml) {
    const petList = [];
    $(pageHtml).find("td:contains('放入城堡牧场')")
        .filter(function () {
        return $(this).text() === "放入城堡牧场";
    })
        .closest("table")
        .find("input:radio")
        .each(function (_idx, radio) {
        const c0 = $(radio).parent();
        const c1 = c0.next();
        const c2 = c1.next();
        const c3 = c2.next();
        const c4 = c3.next();
        const c5 = c4.next();
        const c6 = c5.next();
        const c7 = c6.next();
        const c8 = c7.next();
        const c9 = c8.next();
        const c10 = c9.next();
        const c11 = c10.next();
        const pet = new Pet_1.default();
        pet.index = parseInt($(radio).val());
        pet.selectable = !$(radio).prop("disabled");
        pet.using = c1.text() === "★使用";
        pet.name = c2.text();
        pet.level = parseInt(c3.text());
        let s = c4.text();
        pet.health = parseInt(StringUtils_1.default.substringBeforeSlash(s));
        pet.maxHealth = parseInt(StringUtils_1.default.substringAfterSlash(s));
        pet.attack = parseInt(c5.text());
        pet.defense = parseInt(c6.text());
        pet.specialAttack = parseInt(c7.text());
        pet.specialDefense = parseInt(c8.text());
        pet.speed = parseInt(c9.text());
        pet.experience = parseInt(c10.text());
        pet.gender = c11.text();
        petList.push(pet);
    });
    return petList;
}
function doParseRanchPetList(pageHtml) {
    const petList = [];
    $(pageHtml).find("td:contains('从城堡仓库取出')")
        .filter(function () {
        return $(this).text() === "从城堡仓库取出";
    })
        .closest("table")
        .find("input:radio")
        .each(function (_idx, radio) {
        const c0 = $(radio).parent();
        const c1 = c0.next();
        const c2 = c1.next();
        const c3 = c2.next();
        const c4 = c3.next();
        const c5 = c4.next();
        const c6 = c5.next();
        const c7 = c6.next();
        const c8 = c7.next();
        const c9 = c8.next();
        const c10 = c9.next();
        const pet = new Pet_1.default();
        pet.index = parseInt($(radio).val());
        pet.selectable = true;
        pet.name = c1.text();
        pet.level = parseInt(c2.text());
        let s = c3.text();
        pet.health = parseInt(StringUtils_1.default.substringBeforeSlash(s));
        pet.maxHealth = parseInt(StringUtils_1.default.substringAfterSlash(s));
        pet.attack = parseInt(c4.text());
        pet.defense = parseInt(c5.text());
        pet.specialAttack = parseInt(c6.text());
        pet.specialDefense = parseInt(c7.text());
        pet.speed = parseInt(c8.text());
        pet.experience = parseInt(c9.text());
        pet.gender = c10.text();
        petList.push(pet);
    });
    return petList;
}
module.exports = CastleRanch;


/***/ }),
/* 69 */
/***/ ((module) => {

"use strict";

class CastleRanchPage {
}
module.exports = CastleRanchPage;


/***/ }),
/* 70 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const Constants_1 = __importDefault(__webpack_require__(11));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const MonsterProfileLoader_1 = __importDefault(__webpack_require__(18));
class Pet {
    get nameHtml() {
        const profile = MonsterProfileLoader_1.default.load(this.name);
        return profile ? profile.nameHtml : this.name;
    }
    get raceHtml() {
        const profile = MonsterProfileLoader_1.default.load(this.race);
        return profile ? profile.nameHtml : this.race;
    }
    get beforeHtml() {
        const profile = MonsterProfileLoader_1.default.load(this.before);
        return profile ? profile.nameHtml : this.before;
    }
    get afterHtml() {
        const profile = MonsterProfileLoader_1.default.load(this.after);
        return profile ? profile.nameHtml : this.after;
    }
    get imageHtml() {
        const src = Constants_1.default.POCKET_DOMAIN + "/image/pet/" + this.picture;
        return "<img src='" + src + "' width='64' height='64' alt='" + this.race + "' style='border-width:0'>";
    }
    get usingHtml() {
        return this.using ? "★" : "";
    }
    get levelHtml() {
        if (!SetupLoader_1.default.isExperienceProgressBarEnabled()) {
            return this.level.toString();
        }
        if (this.level === 100) {
            return "<span title='满级' style='color:red'>MAX</span>";
        }
        const ratio = this.level / 100;
        const progressBar = PageUtils_1.default.generateProgressBarHTML(ratio);
        return "<span title='" + ("LV " + this.level) + "'>" + progressBar + "</span>&nbsp;<span>" + lodash_1.default.padStart(this.level.toString(), 2, "0") + "</span>";
    }
    get healthHtml() {
        return this.health + "/" + this.maxHealth;
    }
    get attackHtml() {
        if (this.attack >= 375) {
            return "<span title='倚天' style='color:red;font-weight:bold'>" + this.attack + "</span>";
        }
        else {
            return this.attack.toString();
        }
    }
    get defenseHtml() {
        if (this.defense >= 375) {
            return "<span title='磐石' style='color:red;font-weight:bold'>" + this.defense + "</span>";
        }
        else {
            return this.defense.toString();
        }
    }
    get specialAttackHtml() {
        if (this.specialAttack >= 375) {
            return "<span title='仙人' style='color:red;font-weight:bold'>" + this.specialAttack + "</span>";
        }
        else {
            return this.specialAttack.toString();
        }
    }
    get specialDefenseHtml() {
        if (this.specialDefense >= 375) {
            return "<span title='军神' style='color:red;font-weight:bold'>" + this.specialDefense + "</span>";
        }
        else {
            return this.specialDefense.toString();
        }
    }
    get speedHtml() {
        if (this.speed >= 375) {
            return "<span title='疾风' style='color:red;font-weight:bold'>" + this.speed + "</span>";
        }
        else {
            return this.speed.toString();
        }
    }
    get experienceHtml() {
        if (!SetupLoader_1.default.isExperienceProgressBarEnabled()) {
            return this.experience.toString();
        }
        if (this.level === 100) {
            return "<span title='满级' style='color:red'>MAX</span>";
        }
        const nextLevel = this.level + 1;
        const maxExperience = (Math.pow(nextLevel / 100, 2) * 1000000);
        const ratio = this.experience / maxExperience;
        const progressBar = PageUtils_1.default.generateProgressBarHTML(ratio);
        return "<span title='" + this.experience + "'>" + progressBar + "</span>";
    }
    get beforeCode() {
        return StringUtils_1.default.substringBetween(this.before, "(", ")");
    }
    get afterCode() {
        return StringUtils_1.default.substringBetween(this.after, "(", ")");
    }
    get capacity() {
        return Math.floor(this.maxHealth / 3) +
            this.attack +
            this.defense +
            this.specialAttack +
            this.specialDefense +
            this.speed;
    }
    get locationOrder() {
        switch (this.location) {
            case "P":
                return 1;
            case "C":
                return 2;
            case "R":
                return 3;
            default:
                return 0;
        }
    }
    static parse(text) {
        const ss = lodash_1.default.split(text, "/");
        const pet = new Pet();
        pet.name = lodash_1.default.unescape(ss[0]);
        pet.gender = ss[1];
        pet.level = lodash_1.default.parseInt(ss[2]);
        pet.maxHealth = lodash_1.default.parseInt(ss[3]);
        pet.attack = lodash_1.default.parseInt(ss[4]);
        pet.defense = lodash_1.default.parseInt(ss[5]);
        pet.specialAttack = lodash_1.default.parseInt(ss[6]);
        pet.specialDefense = lodash_1.default.parseInt(ss[7]);
        pet.speed = lodash_1.default.parseInt(ss[8]);
        pet.location = ss[9];
        return pet;
    }
    static sortPetList(source) {
        const target = lodash_1.default.clone(source);
        target.sort(Pet.sorter);
        return target;
    }
    static sorter(a, b) {
        if (!SetupLoader_1.default.isEquipmentPetSortEnabled()) {
            return 0;
        }
        let ret = a.locationOrder - b.locationOrder;
        if (ret !== 0) {
            return ret;
        }
        ret = b.level - a.level;
        if (ret !== 0) {
            return ret;
        }
        let a1 = (a.name.includes("(") && a.name.includes(")")) ? 0 : 1;
        let b1 = (b.name.includes("(") && b.name.includes(")")) ? 0 : 1;
        ret = a1 - b1;
        if (ret !== 0) {
            return ret;
        }
        let a2 = (a.name.includes("(") && a.name.includes(")")) ?
            StringUtils_1.default.substringBetween(a.name, "(", ")") : a.name;
        let b2 = (b.name.includes("(") && b.name.includes(")")) ?
            StringUtils_1.default.substringBetween(b.name, "(", ")") : b.name;
        return a2.localeCompare(b2);
    }
}
module.exports = Pet;


/***/ }),
/* 71 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _GoldenCage_credential;
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const NumberUtils_1 = __importDefault(__webpack_require__(72));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const GoldenCagePage_1 = __importDefault(__webpack_require__(73));
const Pet_1 = __importDefault(__webpack_require__(70));
class GoldenCage {
    constructor(credential) {
        _GoldenCage_credential.set(this, void 0);
        __classPrivateFieldSet(this, _GoldenCage_credential, credential, "f");
    }
    open(cageIndex) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise((resolve, reject) => {
                    if (!NumberUtils_1.default.isIndexNumber(cageIndex)) {
                        reject();
                    }
                    else {
                        const request = __classPrivateFieldGet(this, _GoldenCage_credential, "f").asRequestMap();
                        request.set("chara", "1");
                        request.set("item" + cageIndex, cageIndex.toString());
                        request.set("mode", "USE");
                        NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                            const page = GoldenCage.parsePage(html);
                            resolve(page);
                        });
                    }
                });
            })();
        });
    }
    static parsePage(pageHtml) {
        const petList = [];
        $(pageHtml)
            .find("input:radio")
            .each(function (_idx, radio) {
            const c0 = $(radio).parent();
            const c1 = $(c0).next();
            const c2 = $(c1).next();
            const c3 = $(c2).next();
            const c4 = $(c3).next();
            const c5 = $(c4).next();
            const c6 = $(c5).next();
            const c7 = $(c6).next();
            const c8 = $(c7).next();
            const c9 = $(c8).next();
            const c10 = $(c9).next();
            const pet = new Pet_1.default();
            pet.index = parseInt($(radio).val());
            pet.name = $(c1).text();
            pet.level = parseInt($(c2).text());
            let s = $(c3).text();
            pet.health = parseInt(StringUtils_1.default.substringBeforeSlash(s));
            pet.maxHealth = parseInt(StringUtils_1.default.substringAfterSlash(s));
            pet.attack = parseInt($(c4).text());
            pet.defense = parseInt($(c5).text());
            pet.specialAttack = parseInt($(c6).text());
            pet.specialDefense = parseInt($(c7).text());
            pet.speed = parseInt($(c8).text());
            pet.experience = parseInt($(c9).text());
            pet.gender = $(c10).text();
            petList.push(pet);
        });
        const page = new GoldenCagePage_1.default();
        page.petList = petList;
        return page;
    }
}
_GoldenCage_credential = new WeakMap();
module.exports = GoldenCage;


/***/ }),
/* 72 */
/***/ ((module) => {

"use strict";

class NumberUtils {
    static isIndexNumber(n) {
        if (Number.isNaN(n)) {
            return false;
        }
        if (!Number.isInteger(n)) {
            return false;
        }
        return n >= 0;
    }
}
module.exports = NumberUtils;


/***/ }),
/* 73 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Pet_1 = __importDefault(__webpack_require__(70));
class GoldenCagePage {
    get sortedPetList() {
        return Pet_1.default.sortPetList(this.petList);
    }
    get spaceCount() {
        return 20 - this.petList.length;
    }
}
module.exports = GoldenCagePage;


/***/ }),
/* 74 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalPetManagement_credential, _PersonalPetManagement_townId;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PersonalPetManagementPage_1 = __importDefault(__webpack_require__(75));
const Pet_1 = __importDefault(__webpack_require__(70));
class PersonalPetManagement {
    constructor(credential, townId) {
        _PersonalPetManagement_credential.set(this, void 0);
        _PersonalPetManagement_townId.set(this, void 0);
        __classPrivateFieldSet(this, _PersonalPetManagement_credential, credential, "f");
        __classPrivateFieldSet(this, _PersonalPetManagement_townId, townId, "f");
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _PersonalPetManagement_credential, "f").asRequestMap();
                    if (__classPrivateFieldGet(this, _PersonalPetManagement_townId, "f") !== undefined) {
                        request.set("town", __classPrivateFieldGet(this, _PersonalPetManagement_townId, "f"));
                    }
                    request.set("mode", "PETSTATUS");
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        const page = PersonalPetManagement.parsePage(html);
                        resolve(page);
                    });
                });
            })();
        });
    }
    set(index) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _PersonalPetManagement_credential, "f").asRequestMap();
                    request.set("select", index.toString());
                    request.set("mode", "CHOOSEPET");
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        MessageBoard_1.default.processResponseMessage(html);
                        resolve();
                    });
                });
            })();
        });
    }
    static parsePage(html) {
        const petList = [];
        $(html).find("input:radio[name='select']").each(function (_idx, radio) {
            const index = $(radio).val();
            if (parseInt(index) >= 0) {
                // index为-1的意味着“无宠物”那个选项
                const table = $(radio).closest("table");
                // pet index & using
                const pet = new Pet_1.default();
                pet.index = parseInt(index);
                const usingText = radio.nextSibling.nodeValue;
                if (usingText === "未使用") {
                    pet.using = false;
                }
                if (usingText === "★使用") {
                    pet.using = true;
                }
                __parsePet(pet, table);
                petList.push(pet);
            }
        });
        const studyStatus = [];
        $(html).find("input:checkbox:checked").each(function (_idx, checkbox) {
            const name = $(checkbox).attr("name");
            if (name.startsWith("study")) {
                studyStatus.push(parseInt($(checkbox).val()));
            }
        });
        const page = new PersonalPetManagementPage_1.default();
        page.petList = petList;
        page.petStudyStatus = studyStatus;
        return page;
    }
}
_PersonalPetManagement_credential = new WeakMap(), _PersonalPetManagement_townId = new WeakMap();
function __parsePet(pet, table) {
    // pet name & gender
    const nameCell = table.find("td:first");
    let petNameText = nameCell.find("b").text();
    petNameText = petNameText.substring(1);
    pet.name = petNameText.substring(0, petNameText.length - 1);
    let fullNameText = nameCell.text();
    if (fullNameText.endsWith("(公)")) {
        pet.gender = "公";
    }
    else if (fullNameText.endsWith("(母)")) {
        pet.gender = "母";
    }
    else if (fullNameText.endsWith("(无性)")) {
        pet.gender = "无性";
    }
    // pet level
    let s = table.find("tr:eq(1) td:first").text();
    pet.level = parseInt(StringUtils_1.default.substringAfter(s, "Lv"));
    // pet picture & health
    s = table.find("tr:eq(2) td:eq(0) img").attr("src");
    pet.picture = s.substring(s.lastIndexOf("/") + 1);
    s = table.find("tr:eq(2) td:eq(2)").text();
    pet.health = parseInt(StringUtils_1.default.substringBeforeSlash(s));
    pet.maxHealth = parseInt(StringUtils_1.default.substringAfterSlash(s));
    // pet spells
    s = table.find("tr:eq(3) td:eq(1)").text();
    pet.spell1 = StringUtils_1.default.substringBefore(s, "(威力:");
    pet.usingSpell1 = s.includes("(使用中)");
    pet.spell1Description = s;
    pet.spell1Description += " " + table.find("tr:eq(4) td:eq(1)").text();
    s = table.find("tr:eq(5) td:eq(1)").text();
    pet.spell2 = StringUtils_1.default.substringBefore(s, "(威力:");
    pet.usingSpell2 = s.includes("(使用中)");
    pet.spell2Description = s;
    pet.spell2Description += " " + table.find("tr:eq(6) td:eq(1)").text();
    s = table.find("tr:eq(7) td:eq(1)").text();
    pet.spell3 = StringUtils_1.default.substringBefore(s, "(威力:");
    pet.usingSpell3 = s.includes("(使用中)");
    pet.spell3Description = s;
    pet.spell3Description += " " + table.find("tr:eq(8) td:eq(1)").text();
    s = table.find("tr:eq(9) td:eq(1)").text();
    pet.spell4 = StringUtils_1.default.substringBefore(s, "(威力:");
    pet.usingSpell4 = s.includes("(使用中)");
    pet.spell4Description = s;
    pet.spell4Description += " " + table.find("tr:eq(10) td:eq(1)").text();
    // pet attack & defense
    s = table.find("tr:eq(11) td:eq(1)").text();
    pet.attack = parseInt(s);
    s = table.find("tr:eq(11) td:eq(3)").text();
    pet.defense = parseInt(s);
    // pet specialAttack & specialDefense
    s = table.find("tr:eq(12) td:eq(1)").text();
    pet.specialAttack = parseInt(s);
    s = table.find("tr:eq(12) td:eq(3)").text();
    pet.specialDefense = parseInt(s);
    // pet speed & love
    s = table.find("tr:eq(13) td:eq(1)").text();
    pet.speed = parseInt(s);
    s = table.find("tr:eq(13) td:eq(3)").text();
    pet.love = parseFloat(s);
    // pet attributes
    pet.attribute1 = table.find("tr:eq(14) td:eq(1)").text();
    pet.attribute2 = table.find("tr:eq(14) td:eq(3)").text();
    // pet race & code
    s = table.find("tr:eq(16) td:eq(3)").text();
    pet.race = s;
    pet.code = StringUtils_1.default.substringBetween(s, "(", ")");
}
module.exports = PersonalPetManagement;


/***/ }),
/* 75 */
/***/ ((module) => {

"use strict";

class PersonalPetManagementPage {
    findPet(index) {
        for (const pet of this.petList) {
            if (pet.index === index) {
                return pet;
            }
        }
        return null;
    }
}
module.exports = PersonalPetManagementPage;


/***/ }),
/* 76 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const RolePetMap_1 = __importDefault(__webpack_require__(77));
class RolePetMapStorage {
    static getInstance() {
        return instance;
    }
    loads(idList) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db.transaction(["RolePetMap"], "readonly")
                        .objectStore("RolePetMap")
                        .getAll(); // Bad usage here
                    request.onerror = reject;
                    request.onsuccess = () => {
                        if (request.result) {
                            const dataMap = new Map();
                            for (const it of request.result) {
                                const data = new RolePetMap_1.default();
                                data.id = it.id;
                                data.json = it.json;
                                data.updateTime = it.updateTime;
                                if (idList.includes(data.id)) {
                                    dataMap.set(data.id, data);
                                }
                            }
                            resolve(dataMap);
                        }
                        else {
                            reject();
                        }
                    };
                });
            })();
        });
    }
    load(id) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db.transaction(["RolePetMap"], "readonly")
                        .objectStore("RolePetMap")
                        .get(id);
                    request.onerror = reject;
                    request.onsuccess = () => {
                        if (request.result) {
                            const data = new RolePetMap_1.default();
                            data.id = request.result.id;
                            data.json = request.result.json;
                            data.updateTime = request.result.updateTime;
                            resolve(data);
                        }
                        else {
                            reject();
                        }
                    };
                });
            })();
        });
    }
    write(id, json) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const document = {};
                    // @ts-ignore
                    document.id = id;
                    // @ts-ignore
                    document.json = json;
                    // @ts-ignore
                    document.updateTime = new Date().getTime();
                    const request = db.transaction(["RolePetMap"], "readwrite")
                        .objectStore("RolePetMap")
                        .put(document);
                    request.onerror = reject;
                    request.onsuccess = () => resolve();
                });
            })();
        });
    }
}
const instance = new RolePetMapStorage();
module.exports = RolePetMapStorage;


/***/ }),
/* 77 */
/***/ ((module) => {

"use strict";

class RolePetMap {
}
module.exports = RolePetMap;


/***/ }),
/* 78 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const RolePetStatus_1 = __importDefault(__webpack_require__(79));
class RolePetStatusStorage {
    static getInstance() {
        return instance;
    }
    loads(idList) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db.transaction(["RolePetStatus"], "readonly")
                        .objectStore("RolePetStatus")
                        .getAll(); // Bad usage here
                    request.onerror = reject;
                    request.onsuccess = () => {
                        if (request.result) {
                            const dataMap = new Map();
                            for (const it of request.result) {
                                const data = new RolePetStatus_1.default();
                                data.id = it.id;
                                data.json = it.json;
                                data.updateTime = it.updateTime;
                                if (idList.includes(data.id)) {
                                    dataMap.set(data.id, data);
                                }
                            }
                            resolve(dataMap);
                        }
                        else {
                            reject();
                        }
                    };
                });
            })();
        });
    }
    write(id, json) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const document = {};
                    // @ts-ignore
                    document.id = id;
                    // @ts-ignore
                    document.json = json;
                    // @ts-ignore
                    document.updateTime = new Date().getTime();
                    const request = db.transaction(["RolePetStatus"], "readwrite")
                        .objectStore("RolePetStatus")
                        .put(document);
                    request.onerror = reject;
                    request.onsuccess = () => resolve();
                });
            })();
        });
    }
}
const instance = new RolePetStatusStorage();
module.exports = RolePetStatusStorage;


/***/ }),
/* 79 */
/***/ ((module) => {

"use strict";

class RolePetStatus {
}
module.exports = RolePetStatus;


/***/ }),
/* 80 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _TownPetMapHouse_credential, _TownPetMapHouse_townId;
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const Role_1 = __importDefault(__webpack_require__(50));
const PetMap_1 = __importDefault(__webpack_require__(81));
const TownPetMapHousePage_1 = __importDefault(__webpack_require__(82));
class TownPetMapHouse {
    constructor(credential, townId) {
        _TownPetMapHouse_credential.set(this, void 0);
        _TownPetMapHouse_townId.set(this, void 0);
        __classPrivateFieldSet(this, _TownPetMapHouse_credential, credential, "f");
        __classPrivateFieldSet(this, _TownPetMapHouse_townId, townId, "f");
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _TownPetMapHouse_credential, "f").asRequestMap();
                    if (__classPrivateFieldGet(this, _TownPetMapHouse_townId, "f") !== undefined) {
                        request.set("town", __classPrivateFieldGet(this, _TownPetMapHouse_townId, "f"));
                    }
                    request.set("con_str", "50");
                    request.set("mode", "PETMAP");
                    NetworkUtils_1.default.post("town.cgi", request).then(html => {
                        const page = TownPetMapHouse.parsePage(html);
                        resolve(page);
                    });
                });
            })();
        });
    }
    static parsePage(html) {
        const role = new Role_1.default();
        $(html).find("td:contains('LV')")
            .filter((idx, td) => $(td).text() === "LV")
            .parent()
            .next()
            .find("td:first")
            .each((idx, td) => {
            role.name = $(td).text();
        })
            .next()
            .each((idx, td) => {
            role.level = parseInt($(td).text());
        })
            .next()
            .each((idx, td) => {
            let s = $(td).text();
            role.attribute = StringUtils_1.default.substringBefore(s, "属");
        })
            .next()
            .each((idx, td) => {
            role.career = $(td).text();
        })
            .parent()
            .next()
            .find("td:first")
            .next()
            .each((idx, td) => {
            let s = $(td).text();
            s = StringUtils_1.default.substringBefore(s, " GOLD");
            role.cash = parseInt(s);
        });
        const petMapList = [];
        $(html).find("td")
            .each(function (idx, td) {
            const img = $(td).find("img:first");
            if (img.length > 0) {
                const src = img.attr("src");
                if (src.includes("/386/")) {
                    const code = img.attr("alt");
                    const picture = StringUtils_1.default.substringAfterLast(src, "/");
                    const count = parseInt($(td).next().text());
                    const pm = new PetMap_1.default();
                    pm.code = code;
                    pm.picture = picture;
                    pm.count = count;
                    petMapList.push(pm);
                }
            }
        });
        const page = new TownPetMapHousePage_1.default();
        page.role = role;
        page.petMapList = petMapList;
        return page;
    }
}
_TownPetMapHouse_credential = new WeakMap(), _TownPetMapHouse_townId = new WeakMap();
module.exports = TownPetMapHouse;


/***/ }),
/* 81 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Constants_1 = __importDefault(__webpack_require__(11));
class PetMap {
    get imageHtml() {
        const src = Constants_1.default.POCKET_DOMAIN + "/image/386/" + this.picture;
        return "<img src='" + src + "' alt='" + this.code + "'>";
    }
}
module.exports = PetMap;


/***/ }),
/* 82 */
/***/ ((module) => {

"use strict";

class TownPetMapHousePage {
    asText() {
        let s = "";
        for (const pm of this.petMapList) {
            s += pm.code;
            s += "/";
            s += pm.count;
            s += "  ";
        }
        return s;
    }
    asJson() {
        const list = [];
        for (const pm of this.petMapList) {
            const it = {};
            // @ts-ignore
            it.code = pm.code;
            // @ts-ignore
            it.count = pm.count;
            list.push(it);
        }
        return JSON.stringify(list);
    }
}
module.exports = TownPetMapHousePage;


/***/ }),
/* 83 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const ButtonUtils_1 = __importDefault(__webpack_require__(84));
const Credential_1 = __importDefault(__webpack_require__(15));
const PageUtils_1 = __importDefault(__webpack_require__(14));
class PageProcessorCredentialSupport {
    process(context) {
        const buttons = this.doLoadButtonStyles();
        if (buttons.length > 0) {
            for (const button of buttons) {
                ButtonUtils_1.default.loadButtonStyle(button);
            }
        }
        PageUtils_1.default.fixCurrentPageBrokenImages();
        PageUtils_1.default.removeUnusedHyperLinks();
        PageUtils_1.default.removeGoogleAnalyticsScript();
        const id = $("input:hidden[name='id']:last").val();
        const pass = $("input:hidden[name='pass']:last").val();
        if (id === undefined || pass === undefined) {
            return;
        }
        const credential = new Credential_1.default(id.toString(), pass.toString());
        this.doProcess(credential, context).then();
    }
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
        });
    }
    doLoadButtonStyles() {
        return [];
    }
}
module.exports = PageProcessorCredentialSupport;


/***/ }),
/* 84 */
/***/ ((module) => {

"use strict";

class ButtonUtils {
    static loadButtonStyle(code) {
        const key = code.toString();
        // @ts-ignore
        if (BUTTON_STYLES[key] !== undefined) {
            let s = $("style[type='text/css']").html();
            s = s.replace("-->", "\n");
            // @ts-ignore
            s += BUTTON_STYLES[key];
            s += "-->";
            $("style[type='text/css']").html(s);
        }
    }
}
const BUTTON_STYLES = {
    "10005": ".button-10005 {\n" +
        "  align-items: center;\n" +
        "  background-clip: padding-box;\n" +
        "  background-color: #fa6400;\n" +
        "  border: 1px solid transparent;\n" +
        "  border-radius: .25rem;\n" +
        "  box-shadow: rgba(0, 0, 0, 0.02) 0 1px 3px 0;\n" +
        "  box-sizing: border-box;\n" +
        "  color: #fff;\n" +
        "  cursor: pointer;\n" +
        "  display: inline-flex;\n" +
        "  font-size: 100%;\n" +
        "  font-weight: 600;\n" +
        "  justify-content: center;\n" +
        "  line-height: 1.25;\n" +
        "  margin: 0;\n" +
        "  min-height: 0;\n" +
        "  padding: 2px 2px;\n" +
        "  position: relative;\n" +
        "  text-decoration: none;\n" +
        "  transition: all 250ms;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "  vertical-align: baseline;\n" +
        "  /* width: 100%;\n */" +
        "}\n" +
        "\n" +
        ".button-10005:hover,\n" +
        ".button-10005:focus {\n" +
        "  background-color: #fb8332;\n" +
        "  box-shadow: rgba(0, 0, 0, 0.1) 0 4px 12px;\n" +
        "}\n" +
        "\n" +
        ".button-10005:hover {\n" +
        "  transform: translateY(-1px);\n" +
        "}\n" +
        "\n" +
        ".button-10005:active {\n" +
        "  background-color: #c85000;\n" +
        "  box-shadow: rgba(0, 0, 0, .06) 0 2px 4px;\n" +
        "  transform: translateY(0);\n" +
        "}\n",
    "10007": ".button-10007 {\n" +
        "  background-color: #0095ff;\n" +
        "  border: 1px solid transparent;\n" +
        "  border-radius: 3px;\n" +
        "  box-shadow: rgba(255, 255, 255, .4) 0 1px 0 0 inset;\n" +
        "  box-sizing: border-box;\n" +
        "  color: #fff;\n" +
        "  cursor: pointer;\n" +
        "  display: inline-block;\n" +
        "  font-size: 100%;\n" +
        "  font-weight: 400;\n" +
        "  line-height: 1.15385;\n" +
        "  margin: 0;\n" +
        "  outline: none;\n" +
        "  padding: 2px 2px;\n" +
        "  position: relative;\n" +
        "  text-align: center;\n" +
        "  text-decoration: none;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "  vertical-align: baseline;\n" +
        "  white-space: nowrap;\n" +
        "  /* width: 100%;\n */" +
        "}\n" +
        "\n" +
        ".button-10007:hover,\n" +
        ".button-10007:focus {\n" +
        "  background-color: #07c;\n" +
        "}\n" +
        "\n" +
        ".button-10007:focus {\n" +
        "  box-shadow: 0 0 0 4px rgba(0, 149, 255, .15);\n" +
        "}\n" +
        "\n" +
        ".button-10007:active {\n" +
        "  background-color: #0064bd;\n" +
        "  box-shadow: none;\n" +
        "}\n",
    "10008": ".button-10008 {\n" +
        "  background-color: #e1ecf4;\n" +
        "  border-radius: 3px;\n" +
        "  border: 1px solid #7aa7c7;\n" +
        "  box-shadow: rgba(255, 255, 255, .7) 0 1px 0 0 inset;\n" +
        "  box-sizing: border-box;\n" +
        "  color: #39739d;\n" +
        "  cursor: pointer;\n" +
        "  display: inline-block;\n" +
        "  font-size: 100%;\n" +
        "  font-weight: 400;\n" +
        "  line-height: 1.15385;\n" +
        "  margin: 0;\n" +
        "  outline: none;\n" +
        "  padding: 2px 2px;\n" +
        "  position: relative;\n" +
        "  text-align: center;\n" +
        "  text-decoration: none;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "  vertical-align: baseline;\n" +
        "  white-space: nowrap;\n" +
        "  /* width: 100%;\n */" +
        "}\n" +
        "\n" +
        ".button-10008:hover,\n" +
        ".button-10008:focus {\n" +
        "  background-color: #b3d3ea;\n" +
        "  color: #2c5777;\n" +
        "}\n" +
        "\n" +
        ".button-10008:focus {\n" +
        "  box-shadow: 0 0 0 4px rgba(0, 149, 255, .15);\n" +
        "}\n" +
        "\n" +
        ".button-10008:active {\n" +
        "  background-color: #a0c7e4;\n" +
        "  box-shadow: none;\n" +
        "  color: #2c5777;\n" +
        "}\n",
    "10016": ".button-10016 {\n" +
        "  background-color: #f8f9fa;\n" +
        "  border: 1px solid #f8f9fa;\n" +
        "  border-radius: 4px;\n" +
        "  color: #3c4043;\n" +
        "  cursor: pointer;\n" +
        "  font-size: 100%;\n" +
        "  /* height: 36px;\n */" +
        "  /* line-height: 27px;\n */" +
        "  min-width: 0px;\n" +
        "  padding: 2px 2px;\n */" +
        "  min-width: 0px;\n" +
        "  padding: 2px 2px;\n" +
        "  text-align: center;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "  white-space: pre;\n" +
        "  /* width: 100%;\n */" +
        "}\n" +
        "\n" +
        ".button-10016:hover {\n" +
        "  border-color: #dadce0;\n" +
        "  box-shadow: rgba(0, 0, 0, .1) 0 1px 1px;\n" +
        "  color: #202124;\n" +
        "}\n" +
        "\n" +
        ".button-10016:focus {\n" +
        "  border-color: #4285f4;\n" +
        "  outline: none;\n" +
        "}\n",
    "10024": ".button-10024 {\n" +
        "  background: #FF4742;\n" +
        "  border: 1px solid #FF4742;\n" +
        "  border-radius: 6px;\n" +
        "  box-shadow: rgba(0, 0, 0, 0.1) 1px 2px 4px;\n" +
        "  box-sizing: border-box;\n" +
        "  color: #FFFFFF;\n" +
        "  cursor: pointer;\n" +
        "  display: inline-block;\n" +
        "  font-size: 100%;\n" +
        "  font-weight: 800;\n" +
        "  /* line-height: 16px;\n */" +
        "  min-height: 0px;\n" +
        "  outline: 0;\n" +
        "  padding: 2px 2px;\n" +
        "  text-align: center;\n" +
        "  text-rendering: geometricprecision;\n" +
        "  text-transform: none;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "  vertical-align: middle;\n" +
        "  /* width: 100%;\n */" +
        "}\n" +
        "\n" +
        ".button-10024:hover,\n" +
        ".button-10024:active {\n" +
        "  background-color: initial;\n" +
        "  background-position: 0 0;\n" +
        "  color: #FF4742;\n" +
        "}\n" +
        "\n" +
        ".button-10024:active {\n" +
        "  opacity: .5;\n" +
        "}\n",
    "10028": ".button-10028 {\n" +
        "  appearance: none;\n" +
        "  background-color: transparent;\n" +
        "  border: 2px solid #1A1A1A;\n" +
        "  border-radius: 15px;\n" +
        "  box-sizing: border-box;\n" +
        "  color: #3B3B3B;\n" +
        "  cursor: pointer;\n" +
        "  display: inline-block;\n" +
        "  font-size: 100%;\n" +
        "  font-weight: 600;\n" +
        "  line-height: normal;\n" +
        "  margin: 0;\n" +
        "  min-height: 0;\n" +
        "  min-width: 0;\n" +
        "  outline: none;\n" +
        "  padding: 2px 2px;\n" +
        "  text-align: center;\n" +
        "  text-decoration: none;\n" +
        "  transition: all 300ms cubic-bezier(.23, 1, 0.32, 1);\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "  /* width: 100%;\n */" +
        "  will-change: transform;\n" +
        "}\n" +
        "\n" +
        ".button-10028:disabled {\n" +
        "  pointer-events: none;\n" +
        "}\n" +
        "\n" +
        ".button-10028:hover {\n" +
        "  color: #fff;\n" +
        "  background-color: #1A1A1A;\n" +
        "  box-shadow: rgba(0, 0, 0, 0.25) 0 8px 15px;\n" +
        "  transform: translateY(-2px);\n" +
        "}\n" +
        "\n" +
        ".button-10028:active {\n" +
        "  box-shadow: none;\n" +
        "  transform: translateY(0);\n" +
        "}\n",
    "10032": ".button-10032 {\n" +
        "  background-color: #fff000;\n" +
        "  border-radius: 12px;\n" +
        "  color: #000;\n" +
        "  cursor: pointer;\n" +
        "  font-weight: bold;\n" +
        "  padding: 2px 2px;\n" +
        "  text-align: center;\n" +
        "  transition: 200ms;\n" +
        "  /* width: 100%;\n */" +
        "  box-sizing: border-box;\n" +
        "  border: 0;\n" +
        "  font-size: 100%;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "}\n" +
        "\n" +
        ".button-10032:not(:disabled):hover,\n" +
        ".button-10032:not(:disabled):focus {\n" +
        "  outline: 0;\n" +
        "  background: #f4e603;\n" +
        "  box-shadow: 0 0 0 2px rgba(0,0,0,.2), 0 3px 8px 0 rgba(0,0,0,.15);\n" +
        "}\n" +
        "\n" +
        ".button-10032:disabled {\n" +
        "  filter: saturate(0.2) opacity(0.5);\n" +
        "  -webkit-filter: saturate(0.2) opacity(0.5);\n" +
        "  cursor: not-allowed;\n" +
        "}\n",
    "10033": ".button-10033 {\n" +
        "  background-color: #c2fbd7;\n" +
        "  border-radius: 12px;\n" +
        "  box-shadow: rgba(44, 187, 99, .2) 0 -25px 18px -14px inset,rgba(44, 187, 99, .15) 0 1px 2px,rgba(44, 187, 99, .15) 0 2px 4px,rgba(44, 187, 99, .15) 0 4px 8px,rgba(44, 187, 99, .15) 0 8px 16px,rgba(44, 187, 99, .15) 0 16px 32px;\n" +
        "  color: green;\n" +
        "  cursor: pointer;\n" +
        "  display: inline-block;\n" +
        "  padding: 2px 2px;\n" +
        "  text-align: center;\n" +
        "  text-decoration: none;\n" +
        "  transition: all 250ms;\n" +
        "  border: 0;\n" +
        "  font-size: 16px;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "  /* width: 100%;\n */" +
        "}\n" +
        "\n" +
        ".button-10033:hover {\n" +
        "  box-shadow: rgba(44,187,99,.35) 0 -25px 18px -14px inset,rgba(44,187,99,.25) 0 1px 2px,rgba(44,187,99,.25) 0 2px 4px,rgba(44,187,99,.25) 0 4px 8px,rgba(44,187,99,.25) 0 8px 16px,rgba(44,187,99,.25) 0 16px 32px;\n" +
        "  transform: scale(1.05) rotate(-1deg);\n" +
        "}\n",
    "10035": ".button-10035 {\n" +
        "  align-items: center;\n" +
        "  background-color: #fff;\n" +
        "  border-radius: 12px;\n" +
        "  box-shadow: transparent 0 0 0 3px,rgba(18, 18, 18, .1) 0 6px 20px;\n" +
        "  box-sizing: border-box;\n" +
        "  color: #121212;\n" +
        "  cursor: pointer;\n" +
        "  display: inline-flex;\n" +
        "  flex: 1 1 auto;\n" +
        "  font-size: 100%;\n" +
        "  font-weight: 700;\n" +
        "  justify-content: center;\n" +
        "  line-height: 1;\n" +
        "  margin: 0;\n" +
        "  outline: none;\n" +
        "  padding: 2px 2px;\n" +
        "  text-align: center;\n" +
        "  text-decoration: none;\n" +
        "  transition: box-shadow .2s,-webkit-box-shadow .2s;\n" +
        "  white-space: nowrap;\n" +
        "  border: 0;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "  /* width: 100%;\n */" +
        "}\n" +
        "\n" +
        ".button-10035:hover {\n" +
        "  box-shadow: #121212 0 0 0 3px, transparent 0 0 0 0;\n" +
        "}\n",
    "10062": ".button-10062 {\n" +
        "  background: linear-gradient(to bottom right, #EF4765, #FF9A5A);\n" +
        "  border: 0;\n" +
        "  border-radius: 12px;\n" +
        "  color: #FFFFFF;\n" +
        "  cursor: pointer;\n" +
        "  display: inline-block;\n" +
        "  font-size: 100%;\n" +
        "  font-weight: 500;\n" +
        "  /* line-height: 2.5;\n */" +
        "  outline: transparent;\n" +
        "  padding: 2px 2px;\n" +
        "  text-align: center;\n" +
        "  text-decoration: none;\n" +
        "  transition: box-shadow .2s ease-in-out;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "  white-space: nowrap;\n" +
        "  /* width: 100%;\n */" +
        "}\n" +
        "\n" +
        ".button-10062:not([disabled]):focus {\n" +
        "  box-shadow: 0 0 .25rem rgba(0, 0, 0, 0.5), -.125rem -.125rem 1rem rgba(239, 71, 101, 0.5), .125rem .125rem 1rem rgba(255, 154, 90, 0.5);\n" +
        "}\n" +
        "\n" +
        ".button-10062:not([disabled]):hover {\n" +
        "  box-shadow: 0 0 .25rem rgba(0, 0, 0, 0.5), -.125rem -.125rem 1rem rgba(239, 71, 101, 0.5), .125rem .125rem 1rem rgba(255, 154, 90, 0.5);\n" +
        "}\n",
    "10132": ".button-10132 {\n" +
        "  background-color: #f8f0e0;\n" +
        "  border-radius: 4px;\n" +
        "  color: #000;\n" +
        "  cursor: pointer;\n" +
        "  font-weight: bold;\n" +
        "  padding: 2px 2px;\n" +
        "  text-align: center;\n" +
        "  transition: 200ms;\n" +
        "  /* width: 100%;\n */" +
        "  box-sizing: border-box;\n" +
        "  border: 0;\n" +
        "  font-size: 100%;\n" +
        "  user-select: none;\n" +
        "  -webkit-user-select: none;\n" +
        "  touch-action: manipulation;\n" +
        "}\n" +
        "\n" +
        ".button-10132:not(:disabled):hover,\n" +
        ".button-10132:not(:disabled):focus {\n" +
        "  outline: 0;\n" +
        "  background: #e8e8d0;\n" +
        "  box-shadow: 0 0 0 2px rgba(0,0,0,.2), 0 3px 8px 0 rgba(0,0,0,.15);\n" +
        "}\n" +
        "\n" +
        ".button-10132:disabled {\n" +
        "  filter: saturate(0.2) opacity(0.5);\n" +
        "  -webkit-filter: saturate(0.2) opacity(0.5);\n" +
        "  cursor: not-allowed;\n" +
        "}\n",
};
module.exports = ButtonUtils;


/***/ }),
/* 85 */
/***/ (function(module) {

"use strict";

var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _PageProcessorContext_context;
class PageProcessorContext {
    constructor() {
        _PageProcessorContext_context.set(this, void 0);
        __classPrivateFieldSet(this, _PageProcessorContext_context, new Map(), "f");
    }
    set(key, value) {
        if (value !== undefined) {
            __classPrivateFieldGet(this, _PageProcessorContext_context, "f").set(key, value);
        }
        return this;
    }
    get(key) {
        return __classPrivateFieldGet(this, _PageProcessorContext_context, "f").get(key);
    }
    withTownId(townId) {
        if (townId !== undefined) {
            this.set("townId", townId);
        }
        return this;
    }
    withBattleCount(battleCount) {
        if (battleCount !== undefined) {
            this.set("battleCount", battleCount);
        }
        return this;
    }
    withCastleName(castleName) {
        if (castleName !== undefined) {
            this.set("castleName", castleName);
        }
        return this;
    }
    withCoordinate(coordinate) {
        if (coordinate !== undefined) {
            this.set("coordinate", coordinate);
        }
        return this;
    }
}
_PageProcessorContext_context = new WeakMap();
module.exports = PageProcessorContext;


/***/ }),
/* 86 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastleBankPageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const CastleBankPageProcessor_1 = __importDefault(__webpack_require__(87));
const PageProcessorContext_1 = __importDefault(__webpack_require__(85));
class CastleBankPageInterceptor {
    constructor() {
        _CastleBankPageInterceptor_processor.set(this, new CastleBankPageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "castle.cgi") {
            return pageText.includes("存入或取出请输入数额后按下确认键");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .load()
            .then(machine => {
            machine.start()
                .whenInCastle(state => {
                const context = new PageProcessorContext_1.default();
                context.withCastleName(state === null || state === void 0 ? void 0 : state.castleName);
                __classPrivateFieldGet(this, _CastleBankPageInterceptor_processor, "f").process(context);
            })
                .process();
        });
    }
}
_CastleBankPageInterceptor_processor = new WeakMap();
module.exports = CastleBankPageInterceptor;


/***/ }),
/* 87 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastleBankPageProcessor_instances, _CastleBankPageProcessor_createImmutablePage, _CastleBankPageProcessor_renderMutablePage, _CastleBankPageProcessor_refresh, _CastleBankPageProcessor_bindDepositAllButton, _CastleBankPageProcessor_bindDepositButton, _CastleBankPageProcessor_bindWithdrawButton, _CastleBankPageProcessor_bindTransferButton;
const CastleBank_1 = __importDefault(__webpack_require__(88));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const PocketUtils_1 = __importDefault(__webpack_require__(46));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class CastleBankPageProcessor extends PageProcessorCredentialSupport_1.default {
    constructor() {
        super(...arguments);
        _CastleBankPageProcessor_instances.add(this);
    }
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            const page = CastleBank_1.default.parsePage(PageUtils_1.default.currentPageHtml());
            const castleName = context.get("castleName");
            __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_createImmutablePage).call(this, credential, castleName);
            __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_renderMutablePage).call(this, credential, page);
            PageUtils_1.default.onDoubleEscape(() => $("#returnButton").trigger("click"));
        });
    }
}
_CastleBankPageProcessor_instances = new WeakSet(), _CastleBankPageProcessor_createImmutablePage = function _CastleBankPageProcessor_createImmutablePage(credential, castleName) {
    $("form").remove();
    $("table:eq(1)")
        .attr("id", "t1")
        .find("td:first")
        .attr("id", "pageTitle")
        .removeAttr("bgcolor")
        .removeAttr("width")
        .removeAttr("height")
        .css("text-align", "center")
        .css("font-size", "150%")
        .css("font-weight", "bold")
        .css("background-color", "navy")
        .css("color", "yellowgreen")
        .text("<<  城 堡 银 行 " + StringUtils_1.default.toTitleString(castleName) + " 支 行  >>");
    $("#pageTitle")
        .parent()
        .attr("id", "tr0")
        .next()
        .attr("id", "tr1")
        .find("td:first")
        .find("table:first")
        .find("tr:first")
        .find("td:first")
        .next()
        .next()
        .next()
        .find("table:first")
        .find("tr:first")
        .find("td:first")
        .find("table:first")
        .find("tr:first")
        .next()
        .next()
        .find("td:last")
        .attr("id", "roleCash");
    $("#tr1")
        .next()
        .attr("id", "tr2")
        .find("td:first")
        .find("table:first")
        .find("tr:first")
        .find("td:first")
        .attr("id", "messageBoard")
        .removeAttr("width")
        .removeAttr("bgcolor")
        .css("width", "100%")
        .css("background-color", "black")
        .css("color", "wheat")
        .next()
        .attr("id", "messageBoardManager");
    let html = "";
    html += "<tr id='tr3' style='display:none'>";
    html += "<td id='hiddenFormContainer'></td>";
    html += "</tr>";
    html += "<tr id='tr4'>";
    html += "<td style='background-color:#F8F0E0;text-align:center;width:100%'>";
    html += "<input type='button' id='refreshButton' value='刷新" + castleName + "银行'>";
    html += "<input type='button' id='returnButton' value='离开" + castleName + "银行'>";
    html += "</td>";
    html += "</tr>";
    $("#tr2").after($(html));
    $("#hiddenFormContainer").html(PageUtils_1.default.generateReturnCastleForm(credential));
    html = "";
    html += "<p id='p1'>";
    html += "<input type='button' id='depositAllButton' value='全部存入' class='dynamicButton'>";
    html += "</p>";
    html += "<p id='p2'>";
    html += "<input type='text' id='depositAmount' value='' size='3' style='text-align:right'>0000 Gold&nbsp;&nbsp;&nbsp;";
    html += "<input type='button' id='depositButton' value='金存入' class='dynamicButton'>";
    html += "</p>";
    html += "<p id='p3'>";
    html += "<input type='text' id='withdrawAmount' value='' size='3' style='text-align:right'>0000 Gold&nbsp;&nbsp;&nbsp;";
    html += "<input type='button' id='withdrawButton' value='金取出' class='dynamicButton'>";
    html += "</p>";
    $("#tr4")
        .next()
        .attr("id", "tr5")
        .find("td:first")
        .find("p:first")
        .attr("id", "p0")
        .after($(html));
    $("#p0")
        .prev()
        .find("font:first")
        .attr("id", "accountCash")
        .next()
        .attr("id", "accountSaving");
    html = "";
    html += "<tr id='tr6'>";
    html += "<td style='background-color:darkred;width:100%;text-align:center;font-weight:bold;color:aliceblue'>";
    html += "< 转 账 通 道 >";
    html += "</td>";
    html += "</tr>";
    html += "<tr id='tr7'>";
    html += "<td style='background-color:#F8F0E0;width:100%;text-align:center'>";
    html += "<input type='text' id='searchName' size='15' maxlength='20'>";
    html += "<input type='button' id='searchButton' value='找人'>";
    html += "<select id='peopleSelect'><option value=''>选择发送对象</select>";
    html += "<input type='text' id='transferAmount' value='' size='3' style='text-align:right'>0000 Gold&nbsp;&nbsp;&nbsp;";
    html += "<input type='button' id='transferButton' value='转账' class='dynamicButton'>";
    html += "</td>";
    html += "</tr>";
    $("#tr5").after($(html));
    html = "";
    html += "<tr id='tr8'>";
    html += "<td style='background-color:darkred;width:100%;text-align:center;font-weight:bold;color:aliceblue'>";
    html += "< 领 取 俸 禄 >";
    html += "</td>";
    html += "</tr>";
    html += "<tr id='tr9'>";
    html += "<td style='background-color:#F8F0E0;width:100%;text-align:center'>";
    html += "<input type='button' id='salaryButton' value='发薪' class='dynamicButton'>";
    html += "</td>";
    html += "</tr>";
    $("#tr7").after($(html));
    // Bind immutable buttons
    $("#refreshButton").on("click", () => {
        MessageBoard_1.default.resetMessageBoard("请管理您的账户吧!");
        $("#messageBoardManager").html(NpcLoader_1.default.randomNpcImageHtml);
        __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_refresh).call(this, credential);
    });
    $("#returnButton").on("click", () => {
        $("#returnCastle").trigger("click");
    });
    $("#searchButton").on("click", () => {
        const s = $("#searchName").val();
        if (s === undefined || s.trim() === "") {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("请正确输入人名!");
            return;
        }
        const searchName = s.trim();
        const request = credential.asRequestMap();
        request.set("mode", "CASTLE_SENDMONEY");
        // noinspection JSDeprecatedSymbols
        request.set("serch", escape(searchName));
        NetworkUtils_1.default.post("castle.cgi", request).then(html => {
            const options = $(html).find("select[name='eid']").html();
            $("#peopleSelect").html(options);
        });
    });
}, _CastleBankPageProcessor_renderMutablePage = function _CastleBankPageProcessor_renderMutablePage(credential, page) {
    __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_bindDepositAllButton).call(this, credential, page.account);
    __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_bindDepositButton).call(this, credential, page.account);
    __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_bindWithdrawButton).call(this, credential, page.account);
    __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_bindTransferButton).call(this, credential, page.account);
    $("#salaryButton").on("click", () => {
        const request = credential.asRequestMap();
        request.set("mode", "SALARY");
        NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
            MessageBoard_1.default.processResponseMessage(html);
            if (html.includes("下次领取俸禄还需要等待")) {
                PageUtils_1.default.scrollIntoView("pageTitle");
                return;
            }
            new CastleBank_1.default(credential).deposit().then(() => {
                __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_refresh).call(this, credential);
            });
        });
    });
}, _CastleBankPageProcessor_refresh = function _CastleBankPageProcessor_refresh(credential) {
    PageUtils_1.default.scrollIntoView("pageTitle");
    new CastleBank_1.default(credential).open().then(page => {
        $("#roleCash").text(page.role.cash + " GOLD");
        $("#accountCash").text(page.account.cash.toString());
        $("#accountSaving").text(page.account.saving.toString());
        $("#depositAmount").val("");
        $("#withdrawAmount").val("");
        $("#transferAmount").val("");
        $(".dynamicButton").off("click");
        __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_renderMutablePage).call(this, credential, page);
    });
}, _CastleBankPageProcessor_bindDepositAllButton = function _CastleBankPageProcessor_bindDepositAllButton(credential, account) {
    $("#depositAllButton").on("click", () => {
        if (account.cash < 10000) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("没觉得你身上有啥值得存入的现金!");
            return;
        }
        new CastleBank_1.default(credential).deposit().then(() => {
            __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_refresh).call(this, credential);
        });
    });
}, _CastleBankPageProcessor_bindDepositButton = function _CastleBankPageProcessor_bindDepositButton(credential, account) {
    $("#depositButton").on("click", () => {
        const text = $("#depositAmount").val();
        if (text === undefined || text.trim() === "") {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("没有输入存入的金额!");
            return;
        }
        const amount = parseInt(text.trim());
        if (isNaN(amount) || !Number.isInteger(amount) || amount <= 0) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("非法输入金额!");
            return;
        }
        if (amount * 10000 > account.cash) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning(amount + "万!真逗,搞得你好像有这么多现金似得!");
            return;
        }
        new CastleBank_1.default(credential).deposit(amount).then(() => {
            __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_refresh).call(this, credential);
        });
    });
}, _CastleBankPageProcessor_bindWithdrawButton = function _CastleBankPageProcessor_bindWithdrawButton(credential, account) {
    $("#withdrawButton").on("click", () => {
        const text = $("#withdrawAmount").val();
        if (text === undefined || text.trim() === "") {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("没有输入取出的金额!");
            return;
        }
        const amount = parseInt(text.trim());
        if (isNaN(amount) || !Number.isInteger(amount) || amount <= 0) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("非法输入金额!");
            return;
        }
        if (amount * 10000 > account.saving) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning(amount + "万!真逗,搞得你好像有这么多存款似得!");
            return;
        }
        new CastleBank_1.default(credential).withdraw(amount).then(() => {
            __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_refresh).call(this, credential);
        });
    });
}, _CastleBankPageProcessor_bindTransferButton = function _CastleBankPageProcessor_bindTransferButton(credential, account) {
    $("#transferButton").on("click", () => {
        const s = $("#peopleSelect").val();
        if (s === undefined || s.trim() === "") {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("没有选择转账对象!");
            return;
        }
        const text = $("#transferAmount").val();
        if (text === undefined || text.trim() === "") {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("没有输入取出的金额!");
            return;
        }
        const amount = parseInt(text.trim());
        if (isNaN(amount) || !Number.isInteger(amount) || amount <= 0) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("非法输入金额!");
            return;
        }
        if ((amount + 10) * 10000 > account.total) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("很遗憾,你压根就没有这么多钱!");
            return;
        }
        const target = $("#peopleSelect").find("option:selected").text();
        if (!confirm("请您确认向" + target + "转账" + amount + "万GOLD?")) {
            return;
        }
        const delta = PocketUtils_1.default.calculateCashDifferenceAmount(account.cash, (amount + 10) * 10000);
        const bank = new CastleBank_1.default(credential);
        bank.withdraw(delta).then(() => {
            const request = credential.asRequestMap();
            request.set("gold", (amount * 10).toString()); // 送钱的接口单位是K
            request.set("eid", s.trim());
            request.set("mode", "CASTLE_SENDMONEY2");
            NetworkUtils_1.default.post("castle.cgi", request).then(html => {
                MessageBoard_1.default.processResponseMessage(html);
                bank.deposit().then(() => {
                    __classPrivateFieldGet(this, _CastleBankPageProcessor_instances, "m", _CastleBankPageProcessor_refresh).call(this, credential);
                });
            });
        });
    });
};
module.exports = CastleBankPageProcessor;


/***/ }),
/* 88 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastleBank_credential;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const PocketUtils_1 = __importDefault(__webpack_require__(46));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const Role_1 = __importDefault(__webpack_require__(50));
const BankAccount_1 = __importDefault(__webpack_require__(51));
const CastleBankPage_1 = __importDefault(__webpack_require__(89));
class CastleBank {
    constructor(credential) {
        _CastleBank_credential.set(this, void 0);
        __classPrivateFieldSet(this, _CastleBank_credential, credential, "f");
    }
    static parsePage(html) {
        return doParsePage(html);
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _CastleBank_credential, "f").asRequestMap();
                    request.set("mode", "CASTLE_BANK");
                    NetworkUtils_1.default.post("castle.cgi", request)
                        .then(html => {
                        const page = CastleBank.parsePage(html);
                        resolve(page);
                    });
                });
            };
            return yield action();
        });
    }
    load() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise(resolve => {
                    this.open().then(page => {
                        resolve(page.account);
                    });
                });
            };
            return yield action();
        });
    }
    deposit(amount) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = __classPrivateFieldGet(this, _CastleBank_credential, "f").asRequestMap();
                    if (amount === undefined) {
                        // deposit all
                        request.set("azukeru", "all");
                        request.set("mode", "CASTLEBANK_SELL");
                        NetworkUtils_1.default.post("castle.cgi", request)
                            .then(() => {
                            MessageBoard_1.default.publishMessage("在城堡支行存入全部现金。");
                            resolve();
                        });
                    }
                    else {
                        // deposit specified amount
                        if (!PocketUtils_1.default.checkAmount(amount)) {
                            MessageBoard_1.default.publishWarning("非法的金额" + amount + "!");
                            reject();
                        }
                        else if (amount === 0) {
                            // 真逗,没钱凑什么热闹。
                            resolve();
                        }
                        else {
                            request.set("azukeru", amount.toString());
                            request.set("mode", "CASTLEBANK_SELL");
                            NetworkUtils_1.default.post("castle.cgi", request)
                                .then(() => {
                                MessageBoard_1.default.publishMessage("在城堡支行存入了" + amount + "万现金。");
                                resolve();
                            });
                        }
                    }
                });
            })();
        });
    }
    withdraw(amount) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise((resolve, reject) => {
                    if (isNaN(amount) || !Number.isInteger(amount) || amount < 0) {
                        reject();
                        return;
                    }
                    if (amount === 0) {
                        resolve();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _CastleBank_credential, "f").asRequestMap();
                    request.set("dasu", amount.toString());
                    request.set("mode", "CASTLEBANK_BUY");
                    NetworkUtils_1.default.post("castle.cgi", request)
                        .then(html => {
                        if ($(html).text().includes("您在钱庄里没那么多存款")) {
                            MessageBoard_1.default.publishWarning("真可怜,银行里面连" + amount + "万存款都没有!");
                            reject();
                        }
                        else {
                            MessageBoard_1.default.publishMessage("从城堡支行里提取了" + amount + "万现金。");
                            resolve();
                        }
                    });
                });
            };
            return yield action();
        });
    }
}
_CastleBank_credential = new WeakMap();
function doParsePage(html) {
    const table = $(html).find("td:contains('姓名')")
        .filter((_idx, td) => {
        return $(td).text() === "姓名";
    })
        .closest("table");
    const role = new Role_1.default();
    table.find("tr:first")
        .next()
        .find("td:first")
        .filter((_idx, td) => {
        role.name = $(td).text();
        return true;
    })
        .next()
        .filter((_idx, td) => {
        role.level = parseInt($(td).text());
        return true;
    })
        .next()
        .filter((_idx, td) => {
        role.attribute = StringUtils_1.default.substringBefore($(td).text(), "属");
        return true;
    })
        .next()
        .filter((_idx, td) => {
        role.career = $(td).text();
        return true;
    })
        .parent()
        .next()
        .find("td:first")
        .next()
        .filter((_idx, td) => {
        role.cash = parseInt(StringUtils_1.default.substringBefore($(td).text(), " GOLD"));
        return true;
    });
    const font = $(html).find("font:contains('现在的所持金')")
        .filter((_idx, font) => {
        const s = $(font).text();
        return s.startsWith(" ") && s.includes("现在的所持金");
    });
    let s = font.text();
    s = StringUtils_1.default.substringBefore(s, "现在的所持金");
    const account = new BankAccount_1.default();
    account.name = s.substring(1);
    account.cash = parseInt($(font).find("font:first").text());
    account.saving = parseInt($(font).find("font:last").text());
    const page = new CastleBankPage_1.default();
    page.role = role;
    page.account = account;
    return page;
}
module.exports = CastleBank;


/***/ }),
/* 89 */
/***/ ((module) => {

"use strict";

class CastleBankPage {
}
module.exports = CastleBankPage;


/***/ }),
/* 90 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastleDashboardPageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const CastleDashboardPageProcessor_1 = __importDefault(__webpack_require__(91));
class CastleDashboardPageInterceptor {
    constructor() {
        _CastleDashboardPageInterceptor_processor.set(this, new CastleDashboardPageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "castle.cgi" || cgi === "castlestatus.cgi") {
            return pageText.includes("城堡的情報");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .inCastle()
            .then(() => {
            __classPrivateFieldGet(this, _CastleDashboardPageInterceptor_processor, "f").process();
        });
    }
}
_CastleDashboardPageInterceptor_processor = new WeakMap();
module.exports = CastleDashboardPageInterceptor;


/***/ }),
/* 91 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastleDashboardPageProcessor_instances, _CastleDashboardPageProcessor_renderMenu, _CastleDashboardPageProcessor_renderRankTitle, _CastleDashboardPageProcessor_renderExperience, _CastleDashboardPageProcessor_renderEventBoard;
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const EventHandler_1 = __importDefault(__webpack_require__(92));
const RankTitleLoader_1 = __importDefault(__webpack_require__(93));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
class CastleDashboardPageProcessor {
    constructor() {
        _CastleDashboardPageProcessor_instances.add(this);
    }
    process() {
        PageUtils_1.default.fixCurrentPageBrokenImages();
        PageUtils_1.default.removeUnusedHyperLinks();
        PageUtils_1.default.removeGoogleAnalyticsScript();
        __classPrivateFieldGet(this, _CastleDashboardPageProcessor_instances, "m", _CastleDashboardPageProcessor_renderMenu).call(this);
        __classPrivateFieldGet(this, _CastleDashboardPageProcessor_instances, "m", _CastleDashboardPageProcessor_renderRankTitle).call(this);
        __classPrivateFieldGet(this, _CastleDashboardPageProcessor_instances, "m", _CastleDashboardPageProcessor_renderExperience).call(this);
        __classPrivateFieldGet(this, _CastleDashboardPageProcessor_instances, "m", _CastleDashboardPageProcessor_renderEventBoard).call(this);
    }
}
_CastleDashboardPageProcessor_instances = new WeakSet(), _CastleDashboardPageProcessor_renderMenu = function _CastleDashboardPageProcessor_renderMenu() {
    $("option[value='CASTLE_BANK']")
        .text("口袋银行城堡支行");
    $("option[value='CASTLE_SENDMONEY']").remove();
    $("option[value='SALARY']").remove();
    $("option[value='CASTLE_BUILDMACHINE']")
        .text("城堡驿站");
    $("option[value='LETTER']")
        .text("口袋助手设置");
    $("option[value='USE_ITEM']").text("装备管理");
    $("option[value='CASTLE_ITEM']").remove();
    $("option[value='CASTLE_SENDITEM']").remove();
    $("option[value='PETSTATUS']").text("宠物管理");
    $("option[value='CASTLE_PET']").remove();
    $("option[value='CASTLE_SENDPET']").remove();
    $("option[value='PETBORN']").remove();
    $("option[value='CHANGE_OCCUPATION']").text("职业管理");
    $("option[value='MAGIC']").remove();
    $("option[value='DIANMING']").text("统计报告");
}, _CastleDashboardPageProcessor_renderRankTitle = function _CastleDashboardPageProcessor_renderRankTitle() {
    if (!SetupLoader_1.default.isQiHanTitleEnabled()) {
        return;
    }
    $("td:contains('身份')")
        .filter((idx, td) => $(td).text() === "身份")
        .next()
        .each((idx, th) => {
        let c = $(th).text();
        c = StringUtils_1.default.substringAfterLast(c, " ");
        c = RankTitleLoader_1.default.transformTitle(c);
        $(th).text(c);
    });
}, _CastleDashboardPageProcessor_renderExperience = function _CastleDashboardPageProcessor_renderExperience() {
    if (SetupLoader_1.default.isExperienceProgressBarEnabled()) {
        $("td:contains('经验值')")
            .filter(function () {
            return $(this).text() === "经验值";
        })
            .next()
            .each(function (_idx, th) {
            const expText = $(th).text();
            const experience = parseInt(StringUtils_1.default.substringBefore(expText, " EX"));
            if (experience >= 14900) {
                $(th).css("color", "blue").text("MAX");
            }
            else {
                const level = Math.ceil(experience / 100) + 1;
                const ratio = level / 150;
                const progressBar = PageUtils_1.default.generateProgressBarHTML(ratio);
                $(th).html("<span title='" + expText + "'>" + progressBar + "</span>");
            }
        });
    }
}, _CastleDashboardPageProcessor_renderEventBoard = function _CastleDashboardPageProcessor_renderEventBoard() {
    $("td:contains('最近发生的事件')")
        .filter(function () {
        return $(this).text() === "最近发生的事件";
    })
        .parent()
        .next()
        .find("td:first")
        .attr("id", "eventBoard");
    const eventHtmlList = [];
    $("#eventBoard").html()
        .split("<br>")
        .filter(it => it.endsWith(")"))
        .map(function (it) {
        // noinspection HtmlDeprecatedTag,XmlDeprecatedElement,HtmlDeprecatedAttribute
        const header = "<font color=\"navy\">●</font>";
        return StringUtils_1.default.substringAfter(it, header);
    })
        .map(function (it) {
        return EventHandler_1.default.handleWithEventHtml(it);
    })
        .forEach(it => eventHtmlList.push(it));
    let html = "";
    html += "<table style='border-width:0;width:100%;height:100%;margin:auto'>";
    html += "<tbody>";
    eventHtmlList.forEach(it => {
        html += "<tr>";
        html += "<th style='color:navy;vertical-align:top'>●</th>";
        html += "<td style='width:100%'>";
        html += it;
        html += "</td>";
        html += "</tr>";
    });
    html += "</tbody>";
    html += "</table>";
    $("#eventBoard").html(html);
};
module.exports = CastleDashboardPageProcessor;


/***/ }),
/* 92 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Coordinate_1 = __importDefault(__webpack_require__(5));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const TownLoader_1 = __importDefault(__webpack_require__(47));
class EventHandler {
    static handleWithEventHtml(eventHtml) {
        if (eventHtml.includes("[萝莉失踪]")) {
            const eventText = PageUtils_1.default.convertHtmlToText(eventHtml);
            const secret = StringUtils_1.default.substringBetween(eventText, "[萝莉失踪]据说在印有", "描述的城市附近有萝莉失踪!");
            return doProcessRescueHostage(eventHtml, eventText, secret);
        }
        if (eventHtml.includes("[正太失踪]")) {
            const eventText = PageUtils_1.default.convertHtmlToText(eventHtml);
            const secret = StringUtils_1.default.substringBetween(eventText, "[正太失踪]据说在印有", "描述的城市附近有正太失踪!");
            return doProcessRescueHostage(eventHtml, eventText, secret);
        }
        return eventHtml;
    }
}
function doProcessRescueHostage(eventHtml, eventText, secret) {
    const candidates = doFindTownBySecret(secret);
    let recommendation = "";
    if (candidates.length === 0) {
        recommendation = "没有发现推荐的城市?检查一下城市字典吧,密字[" + secret + "]。";
    }
    else {
        recommendation = "可能失踪的城市是:";
        for (let i = 0; i < candidates.length; i++) {
            const town = candidates[i];
            recommendation += "<b style='color:red'>" + town.name + "</b>";
            recommendation += doGenerateSuspectCoordinate(town);
            if (i !== candidates.length - 1) {
                recommendation += ",";
            }
            else {
                recommendation += "。";
            }
        }
    }
    let p1 = StringUtils_1.default.substringBefore(eventHtml, "失踪!");
    let p2 = "失踪!";
    let p3 = StringUtils_1.default.substringAfter(eventHtml, "失踪!");
    return p1 + p2 + recommendation + p3;
}
function doFindTownBySecret(secret) {
    const candidates = [];
    for (const town of TownLoader_1.default.getTownList()) {
        if (town.description.includes(secret)) {
            candidates.push(town);
        }
    }
    return candidates;
}
function doGenerateSuspectCoordinate(town) {
    const locations = [];
    locations.push(new Coordinate_1.default(town.coordinate.x, town.coordinate.y + 1));
    locations.push(new Coordinate_1.default(town.coordinate.x, town.coordinate.y - 1));
    locations.push(new Coordinate_1.default(town.coordinate.x - 1, town.coordinate.y));
    locations.push(new Coordinate_1.default(town.coordinate.x + 1, town.coordinate.y));
    let s = "";
    for (const location of locations) {
        if (location.isAvailable) {
            s += location.asText();
        }
    }
    return "<span style='color:blue'>" + s + "</span>";
}
module.exports = EventHandler;


/***/ }),
/* 93 */
/***/ ((module) => {

"use strict";

const POCKET_RANK_TITLES = {
    "流浪者": 0,
    "平民": 1,
    "公民": 2,
    "侍": 3,
    "骑士": 4,
    "保民官": 5,
    "市政官": 6,
    "执政官": 7,
    "行省总督": 8,
    "领主": 9,
    "勋爵": 10,
    "从男爵": 11,
    "男爵": 12,
    "子爵": 13,
    "伯爵": 14,
    "侯爵": 15,
    "公爵": 16,
    "大公": 17,
    "选帝候": 18,
    "亲王": 19,
    "皇族": 20,
};
const RANK_TITLES = [
    "流民",
    "公士",
    "上造",
    "簪袅",
    "不更",
    "大夫",
    "官大夫",
    "公大夫",
    "公乘",
    "五大夫",
    "左庶长",
    "右庶长",
    "左更",
    "中更",
    "右更",
    "少上造",
    "大上造",
    "驷车庶长",
    "大庶长",
    "关内侯",
    "彻侯"
];
class RankTitleLoader {
    static getAllRankTitles() {
        return Object.keys(POCKET_RANK_TITLES);
    }
    static transformTitle(title) {
        // @ts-ignore
        const index = POCKET_RANK_TITLES[title];
        return RANK_TITLES[index];
    }
    static calculateTitle(contribution) {
        let idx = Math.ceil(contribution / 500);
        idx = Math.max(idx, 0);
        idx = Math.min(idx, 20);
        return RANK_TITLES[idx];
    }
}
module.exports = RankTitleLoader;


/***/ }),
/* 94 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastlePostHousePageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const CastlePostHousePageProcessor_1 = __importDefault(__webpack_require__(95));
class CastlePostHousePageInterceptor {
    constructor() {
        _CastlePostHousePageInterceptor_processor.set(this, new CastlePostHousePageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "castle.cgi") {
            return pageText.includes("<< * 机车建造厂 *>>");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .load()
            .then(machine => {
            machine.start()
                .whenInCastle(state => {
                __classPrivateFieldGet(this, _CastlePostHousePageInterceptor_processor, "f").process();
            })
                .process();
        });
    }
}
_CastlePostHousePageInterceptor_processor = new WeakMap();
module.exports = CastlePostHousePageInterceptor;


/***/ }),
/* 95 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const CastleBank_1 = __importDefault(__webpack_require__(88));
const TownBank_1 = __importDefault(__webpack_require__(43));
const CastleEntrance_1 = __importDefault(__webpack_require__(96));
const MapBuilder_1 = __importDefault(__webpack_require__(99));
const TravelPlanExecutor_1 = __importDefault(__webpack_require__(103));
const PersonalStatus_1 = __importDefault(__webpack_require__(105));
const TownEntrance_1 = __importDefault(__webpack_require__(107));
const TownLoader_1 = __importDefault(__webpack_require__(47));
const Coordinate_1 = __importDefault(__webpack_require__(5));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class CastlePostHousePageProcessor extends PageProcessorCredentialSupport_1.default {
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            doProcess(credential);
            PageUtils_1.default.onDoubleEscape(() => $("#returnButton").trigger("click"));
        });
    }
}
function doProcess(credential) {
    const t0 = $("table:first");
    const t2 = $("table:eq(2)");
    const t3 = $("table:eq(3)");
    $(t0).removeAttr("height");
    // 修改标题
    let td = $(t0).find("tr:first td:first");
    $(td).removeAttr("bgcolor");
    $(td).removeAttr("width");
    $(td).removeAttr("height");
    $(td).css("text-align", "center");
    $(td).css("font-size", "150%");
    $(td).css("font-weight", "bold");
    $(td).css("background-color", "navy");
    $(td).css("color", "yellowgreen");
    $(td).attr("id", "title");
    $(td).text("<<  城 堡 驿 站  >>");
    // 现金栏、坐标点、计时器
    td = $(t2).find("tr:eq(2) td:last");
    $(td).attr("id", "roleCash");
    let tr = $(t2).find("tr:eq(3)");
    td = $(tr).find("td:first");
    $(td).text("坐标点");
    td = $(tr).find("td:last");
    $(td).attr("id", "roleLocation");
    $(td).text("-");
    $(tr).after($("<tr>" +
        "<td style='background-color:#E0D0B0'>计时器</td>" +
        "<td style='background-color:#E8E8D0;color:red;font-weight:bold;text-align:right' id='countDownTimer' colspan='2'>-</td>" +
        "</tr>"));
    // 消息面板
    td = $(t3).find("td:first");
    $(td).attr("id", "messageBoard");
    $(td).css("color", "white");
    MessageBoard_1.default.resetMessageBoard("如您所愿,我们已经降废弃的机车建造厂改造成了城堡驿站。");
    // 删除不需要的页面内容
    tr = $(t3).parent().parent();
    $(tr).next().remove();
    // 绘制驿站的新页面
    $(tr).after($("" +
        "<tr style='display:none'>" +
        "<td id='eden'></td>" +
        "</tr>" +
        "<tr>" +
        "<td id='menu' style='background-color:#F8F0E0;text-align:center'></td>" +
        "</tr>" +
        "<tr style='display:none'>" +
        "<td id='map' style='background-color:#F8F0E0;text-align:center'></td>" +
        "</tr>" +
        ""));
    doRenderEden(credential);
    doRenderMenu();
    doRenderMap(credential);
}
function doRenderEden(credential) {
    let html = "";
    // noinspection HtmlUnknownTarget
    html += "<form action='castlestatus.cgi' method='post' id='returnForm'>";
    html += "<input type='hidden' name='id' value='" + credential.id + "'>";
    html += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
    html += "<input type='hidden' name='mode' value='CASTLESTATUS'>";
    html += "<input type='submit' id='returnSubmit'>";
    $("#eden").html(html);
}
function doRenderMenu() {
    $("#menu").html("" +
        "<input type='button' id='returnButton' value='返回城堡'>");
    $("#returnButton").on("click", function () {
        $("#returnSubmit").trigger("click");
    });
}
function doRenderMap(credential) {
    const html = MapBuilder_1.default.buildMapTable();
    $("#map").html(html);
    MapBuilder_1.default.updateTownBackgroundColor();
    new PersonalStatus_1.default(credential).load()
        .then(role => {
        const castle = role.castle;
        const buttonId = "location_" + castle.coordinate.x + "_" + castle.coordinate.y;
        $("#" + buttonId)
            .closest("td")
            .css("background-color", "black")
            .css("color", "yellow")
            .css("text-align", "center")
            .html("堡");
        $(".location_button_class")
            .on("mouseenter", function () {
            $(this).css("background-color", "red");
        })
            .on("mouseleave", function () {
            const s = $(this).parent().attr("class");
            const c = StringUtils_1.default.substringAfter(s, "_");
            if (c !== "none") {
                $(this).css("background-color", c);
            }
            else {
                $(this).removeAttr("style");
            }
        });
        $("#map").parent().show();
        doBindMapButton(credential);
    });
}
function doBindMapButton(credential) {
    $(".location_button_class").on("click", function () {
        var _a;
        const title = $(this).parent().attr("title");
        const ss = $(this).attr("id").split("_");
        const x = parseInt(ss[1]);
        const y = parseInt(ss[2]);
        const coordinate = new Coordinate_1.default(x, y);
        let townName = "";
        let confirmation = false;
        if (title.startsWith("城市")) {
            townName = StringUtils_1.default.substringAfterLast(title, " ");
            confirmation = confirm("确认移动到" + townName + "?");
        }
        else if (title.startsWith("坐标")) {
            confirmation = confirm("确认移动到坐标" + coordinate.asText() + "?");
        }
        if (!confirmation) {
            return;
        }
        // 准备切换到移动模式
        (_a = document.getElementById("title")) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
        MessageBoard_1.default.resetMessageBoard("我们将实时为你播报旅途的动态:<br>");
        $("#returnButton")
            .prop("disabled", true)
            .val("旅途中请耐心等候......");
        $(".location_button_class")
            .prop("disabled", true)
            .off("mouseenter")
            .off("mouseleave");
        if (townName !== "") {
            const town = TownLoader_1.default.load(coordinate);
            doTravelToTown(credential, town);
        }
        else {
            doTravelToLocation(credential, coordinate);
        }
    });
}
function doTravelToTown(credential, town) {
    MessageBoard_1.default.publishMessage("目的地城市:<span style='color:greenyellow'>" + town.name + "</span>");
    MessageBoard_1.default.publishMessage("目的地坐标:<span style='color:greenyellow'>" + town.coordinate.asText() + "</span>");
    const castleBank = new CastleBank_1.default(credential);
    castleBank.withdraw(10)
        .then(() => {
        castleBank.load()
            .then(account => {
            $("#roleCash").text(account.cash + " GOLD");
        });
        new CastleEntrance_1.default(credential).leave()
            .then(plan => {
            plan.destination = town.coordinate;
            new TravelPlanExecutor_1.default(plan).execute()
                .then(() => {
                new TownEntrance_1.default(credential).enter(town.id)
                    .then(() => {
                    const bank = new TownBank_1.default(credential);
                    bank.deposit().then(() => {
                        bank.load().then(account => {
                            $("#roleCash").text(account.cash + " GOLD");
                        });
                        MessageBoard_1.default.publishMessage("旅途愉快,下次再见。");
                        $("#returnForm")
                            .attr("action", "status.cgi")
                            .find("input:hidden[name='mode']")
                            .val("STATUS");
                        $("#returnButton")
                            .prop("disabled", false)
                            .val(town.name + "欢迎您");
                    });
                });
            });
        });
    })
        .catch(() => {
        MessageBoard_1.default.publishWarning("因为没有足够的保证金,旅途被中断!");
        MessageBoard_1.default.publishMessage("回去吧,没钱就别来了。");
        $("#returnButton")
            .prop("disabled", false)
            .val("真可怜钱不够");
    });
}
function doTravelToLocation(credential, location) {
    MessageBoard_1.default.publishMessage("目的地坐标:<span style='color:greenyellow'>" + location.asText() + "</span>");
    new CastleEntrance_1.default(credential).leave()
        .then(plan => {
        plan.destination = location;
        const executor = new TravelPlanExecutor_1.default(plan);
        executor.execute()
            .then(() => {
            MessageBoard_1.default.publishMessage("旅途愉快,下次再见。");
            $("#returnForm")
                .attr("action", "status.cgi")
                .find("input:hidden[name='mode']")
                .val("STATUS");
            $("#returnButton")
                .prop("disabled", false)
                .val("到达了目的地" + location.asText());
        });
    });
}
module.exports = CastlePostHousePageProcessor;


/***/ }),
/* 96 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastleEntrance_credential;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const TravelPlanBuilder_1 = __importDefault(__webpack_require__(97));
class CastleEntrance {
    constructor(credential) {
        _CastleEntrance_credential.set(this, void 0);
        __classPrivateFieldSet(this, _CastleEntrance_credential, credential, "f");
    }
    enter() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential) => {
                return new Promise(resolve => {
                    const request = credential.asRequest();
                    // @ts-ignore
                    request["mode"] = "CASTLE_ENTRY";
                    NetworkUtils_1.default.sendPostRequest("map.cgi", request, function () {
                        MessageBoard_1.default.publishMessage("进入了城堡。");
                        resolve();
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _CastleEntrance_credential, "f"));
        });
    }
    leave() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential) => {
                return new Promise(resolve => {
                    const request = credential.asRequest();
                    // @ts-ignore
                    request["navi"] = "on";
                    // @ts-ignore
                    request["out"] = "1";
                    // @ts-ignore
                    request["mode"] = "MAP_MOVE";
                    NetworkUtils_1.default.sendPostRequest("map.cgi", request, function (html) {
                        MessageBoard_1.default.publishMessage("已经离开了城堡。");
                        const plan = TravelPlanBuilder_1.default.initializeTravelPlan(html);
                        plan.credential = credential;
                        resolve(plan);
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _CastleEntrance_credential, "f"));
        });
    }
}
_CastleEntrance_credential = new WeakMap();
module.exports = CastleEntrance;


/***/ }),
/* 97 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Coordinate_1 = __importDefault(__webpack_require__(5));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const TownLoader_1 = __importDefault(__webpack_require__(47));
const TravelPlan_1 = __importDefault(__webpack_require__(98));
class TravelPlanBuilder {
    static initializeTravelPlan(pageHtml) {
        let s = $(pageHtml)
            .find("select[name='chara_m']")
            .find("option:last")
            .val();
        const scope = parseInt(s);
        let mode = "ROOK";
        $(pageHtml).find("input:submit").each(function (_idx, input) {
            const v = $(input).val();
            const d = $(input).attr("disabled");
            if (v === "↖" && d === undefined) {
                mode = "QUEEN";
            }
        });
        let source = new Coordinate_1.default(-1, -1);
        $(pageHtml)
            .find("td")
            .each(function (_idx, td) {
            const text = $(td).text();
            if (text.includes("现在位置(") && text.endsWith(")")) {
                const s = StringUtils_1.default.substringBetween(text, "(", ")");
                const x = StringUtils_1.default.substringBefore(s, ",");
                const y = StringUtils_1.default.substringAfter(s, ",");
                source = new Coordinate_1.default(parseInt(x), parseInt(y));
            }
        });
        MessageBoard_1.default.publishMessage("移动范围:<span style='color:greenyellow'>" + scope + "</span>");
        MessageBoard_1.default.publishMessage("移动模式:<span style='color:greenyellow'>" + mode + "</span>");
        MessageBoard_1.default.publishMessage("当前坐标:<span style='color:greenyellow'>" + source.asText() + "</span>");
        if ($("#roleLocation").length > 0) {
            let roleLocation = source.asText();
            const town = TownLoader_1.default.load(source);
            if (town) {
                roleLocation = town.name + " " + roleLocation;
            }
            $("#roleLocation").text(roleLocation);
        }
        const mapId = "location_" + source.x + "_" + source.y;
        if ($("#" + mapId).length > 0) {
            $("#" + mapId).css("background-color", "red");
        }
        const plan = new TravelPlan_1.default();
        plan.scope = scope;
        plan.mode = mode;
        plan.source = source;
        return plan;
    }
}
module.exports = TravelPlanBuilder;


/***/ }),
/* 98 */
/***/ ((module) => {

"use strict";

class TravelPlan {
}
module.exports = TravelPlan;


/***/ }),
/* 99 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Coordinate_1 = __importDefault(__webpack_require__(5));
const TownInformation_1 = __importDefault(__webpack_require__(100));
const TownLoader_1 = __importDefault(__webpack_require__(47));
class MapBuilder {
    static buildBlankMapTable() {
        let html = "";
        html += "<table style='background-color:#888888;margin:auto;border-width:0'>";
        html += "<tbody style='background-color:#F8F0E0'>";
        html += "<tr>";
        html += "<td></td>";
        html += "<td>0</td>";
        html += "<td>1</td>";
        html += "<td>2</td>";
        html += "<td>3</td>";
        html += "<td>4</td>";
        html += "<td>5</td>";
        html += "<td>6</td>";
        html += "<td>7</td>";
        html += "<td>8</td>";
        html += "<td>9</td>";
        html += "<td>10</td>";
        html += "<td>11</td>";
        html += "<td>12</td>";
        html += "<td>13</td>";
        html += "<td>14</td>";
        html += "<td>15</td>";
        html += "</tr>";
        for (let y = 15; y >= 0; y--) {
            html += "<tr>";
            html += "<td>" + y + "</td>";
            for (let x = 0; x <= 15; x++) {
                const coordinate = new Coordinate_1.default(x, y);
                let buttonValue = " ";
                let buttonTitle = "坐标" + coordinate.asText();
                html += "<td>";
                html += "<span title='" + buttonTitle + "' class='color_none'>";
                html += "<input type='button' value='" + buttonValue + "' " +
                    "class='location_button_class' " +
                    "id='location_" + x + "_" + y + "'>";
                html += "</span>";
                html += "</td>";
            }
            html += "</tr>";
        }
        html += "</tbody>";
        html += "</table>";
        return html;
    }
    static buildMapTable() {
        let html = "";
        html += "<table style='background-color:#888888;margin:auto;border-width:0'>";
        html += "<tbody style='background-color:#F8F0E0'>";
        html += "<tr>";
        html += "<td></td>";
        html += "<td>0</td>";
        html += "<td>1</td>";
        html += "<td>2</td>";
        html += "<td>3</td>";
        html += "<td>4</td>";
        html += "<td>5</td>";
        html += "<td>6</td>";
        html += "<td>7</td>";
        html += "<td>8</td>";
        html += "<td>9</td>";
        html += "<td>10</td>";
        html += "<td>11</td>";
        html += "<td>12</td>";
        html += "<td>13</td>";
        html += "<td>14</td>";
        html += "<td>15</td>";
        html += "</tr>";
        for (let y = 15; y >= 0; y--) {
            html += "<tr>";
            html += "<td>" + y + "</td>";
            for (let x = 0; x <= 15; x++) {
                const coordinate = new Coordinate_1.default(x, y);
                let buttonValue = " ";
                let buttonTitle = "坐标" + coordinate.asText();
                const town = TownLoader_1.default.load(coordinate);
                if (town) {
                    buttonValue = town.name.substring(0, 1);
                    buttonTitle = "城市" + coordinate.asText() + " " + town.name;
                }
                html += "<td>";
                if (buttonValue === " ") {
                    html += "<span title='" + buttonTitle + "' class='color_none'>";
                    html += "<input type='button' value='" + buttonValue + "' " +
                        "class='location_button_class' " +
                        "id='location_" + x + "_" + y + "'>";
                    html += "</span>";
                }
                else {
                    html += "<span title='" + buttonTitle + "' class='color_yellow'>";
                    html += "<input type='button' value='" + buttonValue + "' " +
                        "class='location_button_class' " +
                        "id='location_" + x + "_" + y + "' " +
                        "style='background-color:yellow'>";
                    html += "</span>";
                }
                html += "</td>";
            }
            html += "</tr>";
        }
        html += "</tbody>";
        html += "</table>";
        return html;
    }
    static updateTownBackgroundColor() {
        new TownInformation_1.default().open().then(page => {
            for (const status of page.statusList) {
                const town = TownLoader_1.default.load(status.name);
                const x = town.coordinate.x;
                const y = town.coordinate.y;
                const buttonId = "location_" + x + "_" + y;
                $("#" + buttonId)
                    .css("background-color", status.color)
                    .css("color", "white")
                    .parent()
                    .attr("class", "color_" + status.color);
            }
        });
    }
}
module.exports = MapBuilder;


/***/ }),
/* 100 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const TownStatus_1 = __importDefault(__webpack_require__(101));
const TownInformationPage_1 = __importDefault(__webpack_require__(102));
class TownInformation {
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    NetworkUtils_1.default.get("town_print.cgi").then(html => {
                        const page = TownInformation.parsePage(html);
                        resolve(page);
                    });
                });
            })();
        });
    }
    static parsePage(html) {
        const statusList = [];
        $(html).find("tr")
            .filter(function (_idx) {
            return _idx > 0;
        })
            .each(function (_idx, tr) {
            const c0 = $(tr).find("td:first");
            const c1 = c0.next();
            const c2 = c1.next();
            const c3 = c2.next();
            const status = new TownStatus_1.default();
            let s = c0.text();
            if (s !== undefined && s.trim() !== "") {
                // 神奇啊,城市被多弄出来一个?不知道怎么回事,先过滤吧
                if (s.endsWith(" 首都")) {
                    status.name = StringUtils_1.default.substringBefore(s, " 首都");
                }
                else {
                    status.name = s;
                }
                status.color = c0.find("font:first").attr("color");
                status.country = c1.text();
                s = c2.text();
                status.tax = parseInt(StringUtils_1.default.substringBefore(s, " GOLD"));
                status.attribute = c3.text();
                statusList.push(status);
            }
        });
        const page = new TownInformationPage_1.default();
        page.statusList = statusList;
        return page;
    }
}
module.exports = TownInformation;


/***/ }),
/* 101 */
/***/ ((module) => {

"use strict";

class TownStatus {
}
module.exports = TownStatus;


/***/ }),
/* 102 */
/***/ ((module) => {

"use strict";

class TownInformationPage {
}
module.exports = TownInformationPage;


/***/ }),
/* 103 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _TravelPlanExecutor_plan;
const Coordinate_1 = __importDefault(__webpack_require__(5));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const TimeoutUtils_1 = __importDefault(__webpack_require__(104));
const TownLoader_1 = __importDefault(__webpack_require__(47));
class TravelPlanExecutor {
    constructor(plan) {
        _TravelPlanExecutor_plan.set(this, void 0);
        __classPrivateFieldSet(this, _TravelPlanExecutor_plan, plan, "f");
    }
    execute() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (plan) => {
                return new Promise(resolve => {
                    const pathList = calculatePath(plan.source, plan.destination, plan.scope, plan.mode);
                    if (pathList.length > 1) {
                        MessageBoard_1.default.publishMessage("旅途路径已经计算完毕,总共需要次移动" + (pathList.length - 1) + "步。");
                        let msg = "旅途路径规划:";
                        for (let i = 0; i < pathList.length; i++) {
                            let node = pathList[i];
                            msg += node.asText();
                            if (i !== pathList.length - 1) {
                                msg += "=>";
                            }
                        }
                        MessageBoard_1.default.publishMessage(msg);
                    }
                    doMoveOnPath(plan.credential, pathList, 0, function () {
                        resolve();
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _TravelPlanExecutor_plan, "f"));
        });
    }
}
_TravelPlanExecutor_plan = new WeakMap();
function doMoveOnPath(credential, pathList, index, callback) {
    if (pathList.length === 1 || index === pathList.length - 1) {
        // 路径中只有一个点,表示起点和终点是一个点,直接结束
        // 已经移动到最后一个点
        callback();
    }
    else {
        MessageBoard_1.default.publishMessage("等待移动冷却中......(约55秒)");
        TimeoutUtils_1.default.execute(55000, function () {
            const from = pathList[index];
            const to = pathList[index + 1];
            const direction = calculateDirection(from, to);
            const distance = calculateDistance(from, to);
            const request = credential.asRequest();
            // @ts-ignore
            request["con"] = "2";
            // @ts-ignore
            request["navi"] = "on";
            // @ts-ignore
            request["mode"] = "CHARA_MOVE";
            // @ts-ignore
            request["direct"] = escape(direction);
            // @ts-ignore
            request["chara_m"] = distance;
            NetworkUtils_1.default.sendPostRequest("map.cgi", request, function () {
                MessageBoard_1.default.publishMessage("<span style='color:greenyellow'>" + direction + "</span>移动" + distance + "格,到达" + to.asText() + "。");
                if ($("#roleLocation").length > 0) {
                    let roleLocation = to.asText();
                    const town = TownLoader_1.default.load(to);
                    if (town) {
                        roleLocation = town.name + " " + roleLocation;
                    }
                    $("#roleLocation").text(roleLocation);
                }
                let mapId = "location_" + from.x + "_" + from.y;
                if ($("#" + mapId).length > 0) {
                    const s = $("#" + mapId).parent().attr("class");
                    const c = StringUtils_1.default.substringAfter(s, "_");
                    if (c !== "none") {
                        $("#" + mapId).css("background-color", c);
                    }
                    else {
                        $("#" + mapId).removeAttr("style");
                    }
                }
                mapId = "location_" + to.x + "_" + to.y;
                if ($("#" + mapId).length > 0) {
                    $("#" + mapId).css("background-color", "red");
                }
                doMoveOnPath(credential, pathList, index + 1, callback);
            });
        });
    }
}
function calculatePath(source, destination, scope, mode) {
    const pathList = [];
    if (source.equals(destination)) {
        pathList.push(source);
        return pathList;
    }
    const milestone = calculateMilestone(source, destination, mode);
    if (milestone !== undefined) {
        const p1 = calculateMilestonePath(source, milestone, scope);
        const p2 = calculateMilestonePath(milestone, destination, scope);
        pathList.push(...p1);
        pathList.push(...p2);
        pathList.push(destination);
    }
    else {
        const p = calculateMilestonePath(source, destination, scope);
        pathList.push(...p);
        pathList.push(destination);
    }
    return pathList;
}
function calculateMilestone(from, to, mode) {
    if (mode === "ROOK") {
        if (from.x === to.x || from.y === to.y) {
            return undefined;
        }
        return new Coordinate_1.default(from.x, to.y);
    }
    if (mode === "QUEEN") {
        if (from.x === to.x || from.y === to.y) {
            return undefined;
        }
        const xDelta = Math.abs(from.x - to.x);
        const yDelta = Math.abs(from.y - to.y);
        if (xDelta === yDelta) {
            return undefined;
        }
        const delta = Math.min(xDelta, yDelta);
        let x = from.x;
        let y = from.y;
        if (to.x > from.x) {
            x = x + delta;
        }
        else {
            x = x - delta;
        }
        if (to.y > from.y) {
            y = y + delta;
        }
        else {
            y = y - delta;
        }
        return new Coordinate_1.default(x, y);
    }
    return undefined;
}
function calculateMilestonePath(from, to, scope) {
    const nodeList = [];
    nodeList.push(from);
    if (from.x === to.x) {
        // 一条竖线上
        const step = Math.ceil(Math.abs(from.y - to.y) / scope);
        for (let i = 1; i <= step - 1; i++) {
            if (to.y > from.y) {
                nodeList.push(new Coordinate_1.default(from.x, from.y + (i * scope)));
            }
            else {
                nodeList.push(new Coordinate_1.default(from.x, from.y - (i * scope)));
            }
        }
    }
    else if (from.y === to.y) {
        // 一条横线上
        const step = Math.ceil(Math.abs(from.x - to.x) / scope);
        for (let i = 1; i <= step - 1; i++) {
            if (to.x > from.x) {
                nodeList.push(new Coordinate_1.default(from.x + (i * scope), from.y));
            }
            else {
                nodeList.push(new Coordinate_1.default(from.x - (i * scope), from.y));
            }
        }
    }
    else {
        // 一条斜线上
        const step = Math.ceil(Math.abs(from.x - to.x) / scope);
        for (let i = 1; i <= step - 1; i++) {
            let x = from.x;
            if (to.x > from.x) {
                x = x + (i * scope);
            }
            else {
                x = x - (i * scope);
            }
            let y = from.y;
            if (to.y > from.y) {
                y = y + (i * scope);
            }
            else {
                y = y - (i * scope);
            }
            nodeList.push(new Coordinate_1.default(x, y));
        }
    }
    return nodeList;
}
function calculateDirection(from, to) {
    const x1 = from.x;
    const y1 = from.y;
    const x2 = to.x;
    const y2 = to.y;
    let direction = "";
    if (x1 === x2) {
        // 上或者下
        if (y2 > y1) {
            direction = "↑";
        }
        else {
            direction = "↓";
        }
    }
    else if (y1 === y2) {
        // 左或者右
        if (x2 > x1) {
            direction = "→";
        }
        else {
            direction = "←";
        }
    }
    else {
        // 4种斜向移动
        if (x2 > x1 && y2 > y1) {
            direction = "↗";
        }
        if (x2 > x1 && y2 < y1) {
            direction = "↘";
        }
        if (x2 < x1 && y2 > y1) {
            direction = "↖";
        }
        if (x2 < x1 && y2 < y1) {
            direction = "↙";
        }
    }
    return direction;
}
function calculateDistance(from, to) {
    const x1 = from.x;
    const y1 = from.y;
    const x2 = to.x;
    const y2 = to.y;
    return Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2));
}
module.exports = TravelPlanExecutor;


/***/ }),
/* 104 */
/***/ ((module) => {

"use strict";

class TimeoutUtils {
    static execute(timeoutInMillis, handler) {
        if ($("#countDownTimer").length > 0) {
            let count = timeoutInMillis / 1000;
            const timer = setInterval(function () {
                $("#countDownTimer").text(Math.max(count--, 0));
            }, 1000);
            setTimeout(function () {
                clearInterval(timer);
                $("#countDownTimer").text("-");
                handler();
            }, timeoutInMillis);
        }
        else {
            setTimeout(handler, timeoutInMillis);
        }
    }
}
module.exports = TimeoutUtils;


/***/ }),
/* 105 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalStatus_credential, _PersonalStatus_townId;
const Coordinate_1 = __importDefault(__webpack_require__(5));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const Castle_1 = __importDefault(__webpack_require__(56));
const TownLoader_1 = __importDefault(__webpack_require__(47));
const PersonalStatusPage_1 = __importDefault(__webpack_require__(106));
const Role_1 = __importDefault(__webpack_require__(50));
class PersonalStatus {
    constructor(credential, townId) {
        _PersonalStatus_credential.set(this, void 0);
        _PersonalStatus_townId.set(this, void 0);
        __classPrivateFieldSet(this, _PersonalStatus_credential, credential, "f");
        __classPrivateFieldSet(this, _PersonalStatus_townId, townId, "f");
    }
    static parsePage(pageHtml) {
        return doParsePage(pageHtml);
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential) => {
                return new Promise(resolve => {
                    const request = credential.asRequestMap();
                    if (__classPrivateFieldGet(this, _PersonalStatus_townId, "f") !== undefined) {
                        request.set("town", __classPrivateFieldGet(this, _PersonalStatus_townId, "f"));
                    }
                    request.set("mode", "STATUS_PRINT");
                    NetworkUtils_1.default.post("mydata.cgi", request)
                        .then(pageHtml => {
                        const page = PersonalStatus.parsePage(pageHtml);
                        resolve(page);
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _PersonalStatus_credential, "f"));
        });
    }
    load() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = () => {
                return new Promise(resolve => {
                    this.open().then(page => {
                        resolve(page.role);
                    });
                });
            };
            return yield action();
        });
    }
}
_PersonalStatus_credential = new WeakMap(), _PersonalStatus_townId = new WeakMap();
function doParsePage(pageHtml) {
    const role = new Role_1.default();
    const table = $(pageHtml).find("table:eq(1)");
    let s = $(table).find("tr:first td:first").text();
    role.name = StringUtils_1.default.substringBetween(s, "姓名 : ", " (");
    let t = StringUtils_1.default.substringBetween(s, "(", ")");
    role.race = StringUtils_1.default.substringBefore(t, " ");
    role.gender = StringUtils_1.default.substringAfter(t, " ");
    let tr = $(table).find("tr:eq(1)");
    let td = $(tr).find("td:first");
    s = $(td).text();
    role.level = parseInt(StringUtils_1.default.substringAfter(s, "Lv"));
    td = $(tr).find("td:eq(1)");
    s = $(td).text();
    role.country = StringUtils_1.default.substringBetween(s, "所属:", "(");
    role.unit = StringUtils_1.default.substringBetween(s, "(", " 部队)");
    tr = $(table).find("tr:eq(2)");
    td = $(tr).find("td:first");
    s = $(td).find("img:first").attr("src");
    role.image = StringUtils_1.default.substringAfterLast(s, "/");
    td = $(tr).find("td:eq(2)");
    s = $(td).text();
    role.health = parseInt(StringUtils_1.default.substringBeforeSlash(s));
    role.maxHealth = parseInt(StringUtils_1.default.substringAfterSlash(s));
    td = $(tr).find("td:eq(4)");
    s = $(td).text();
    role.mana = parseInt(StringUtils_1.default.substringBeforeSlash(s));
    role.maxMana = parseInt(StringUtils_1.default.substringAfterSlash(s));
    tr = $(table).find("tr:eq(3)");
    td = $(tr).find("td:eq(1)");
    s = $(td).text();
    role.spell = StringUtils_1.default.substringBefore(s, "(");
    tr = $(table).find("tr:eq(5)");
    td = $(tr).find("td:eq(1)");
    s = $(td).text();
    role.attack = parseInt(s);
    td = $(tr).find("td:eq(3)");
    s = $(td).text();
    role.defense = parseInt(s);
    tr = $(table).find("tr:eq(6)");
    td = $(tr).find("td:eq(1)");
    s = $(td).text();
    role.specialAttack = parseInt(s);
    td = $(tr).find("td:eq(3)");
    s = $(td).text();
    role.specialDefense = parseInt(s);
    tr = $(table).find("tr:eq(7)");
    td = $(tr).find("td:eq(1)");
    s = $(td).text();
    role.speed = parseInt(s);
    td = $(tr).find("td:eq(3)");
    role.pet = $(td).text();
    tr = $(table).find("tr:eq(9)");
    td = $(tr).find("td:eq(1)");
    role.attribute = $(td).text();
    td = $(tr).find("td:eq(3)");
    s = $(td).text();
    if (s === "野外") {
        role.location = "WILD";
    }
    else if (s === "地铁区域") {
        role.location = "METRO";
    }
    else if (s === "唐朝") {
    }
    else if (s.includes("(") && s.includes(")")) {
        role.location = "CASTLE";
        const castle = new Castle_1.default();
        castle.name = StringUtils_1.default.substringBefore(s, " (");
        castle.owner = role.name;
        s = StringUtils_1.default.substringBetween(s, "(", ")");
        const x = parseInt(StringUtils_1.default.substringBefore(s, ","));
        const y = parseInt(StringUtils_1.default.substringAfter(s, ","));
        castle.coordinate = new Coordinate_1.default(x, y);
        role.castle = castle;
    }
    else {
        const town = TownLoader_1.default.load(s);
        if (town) {
            role.location = "TOWN";
            role.town = town;
        }
    }
    tr = $(table).find("tr:eq(10)");
    td = $(tr).find("td:eq(3)");
    s = $(td).text();
    role.additionalLuck = parseInt(s);
    tr = $(table).find("tr:eq(11)");
    td = $(tr).find("td:eq(1)");
    role.task = $(td).text();
    tr = $(table).find("tr:eq(14)");
    td = $(tr).find("td:eq(1)");
    role.consecrateRP = parseInt($(td).text());
    td = $(tr).find("td:eq(3)");
    role.additionalRP = parseInt($(td).text());
    tr = $(table).find("tr:eq(15)");
    td = $(tr).find("td:eq(1)");
    role.mirrorIndex = parseInt($(td).text());
    td = $(tr).find("td:eq(3)");
    role.mirrorCount = parseInt($(td).text());
    tr = $(table).find("tr:eq(16)");
    td = $(tr).find("td:first");
    s = $(td).text();
    role.battleCount = parseInt(StringUtils_1.default.substringBefore(s, " 战"));
    role.battleWinCount = parseInt(StringUtils_1.default.substringBetween(s, "战 ", " 胜"));
    td = $(tr).find("td:eq(2)");
    role.experience = parseInt($(td).text());
    td = $(tr).find("td:eq(4)");
    s = $(td).text();
    role.cash = parseInt(StringUtils_1.default.substringBefore(s, " G"));
    tr = $(table).find("tr:eq(21)");
    td = $(tr).find("td:first");
    s = $(td).text();
    role.career = StringUtils_1.default.substringAfter(s, "职业:");
    role.masterCareerList = [];
    tr = $(table).find("tr:eq(22)");
    td = $(tr).find("td:first");
    s = $(td).text();
    s = StringUtils_1.default.substringAfter(s, "掌握职业:");
    for (const it of s.split("】【")) {
        const career = StringUtils_1.default.substringBetween(it, "【", "】");
        role.masterCareerList.push(career);
    }
    role.treasureList = [];
    tr = $(table).find("tr:eq(23)");
    td = $(tr).find("td:first");
    s = $(td).text();
    s = StringUtils_1.default.substringAfter(s, "仙人的宝物:");
    for (const it of s.split(" ")) {
        if (it !== "") {
            role.treasureList.push(it);
        }
    }
    role.hasMirror = role.mirrorCount > 0;
    const page = new PersonalStatusPage_1.default();
    page.role = role;
    return page;
}
module.exports = PersonalStatus;


/***/ }),
/* 106 */
/***/ ((module) => {

"use strict";

class PersonalStatusPage {
}
module.exports = PersonalStatusPage;


/***/ }),
/* 107 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _TownEntrance_credential;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const TimeoutUtils_1 = __importDefault(__webpack_require__(104));
const TravelPlanBuilder_1 = __importDefault(__webpack_require__(97));
const TownLoader_1 = __importDefault(__webpack_require__(47));
class TownEntrance {
    constructor(credential) {
        _TownEntrance_credential.set(this, void 0);
        __classPrivateFieldSet(this, _TownEntrance_credential, credential, "f");
    }
    enter(townId) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential, townId) => {
                return new Promise(resolve => {
                    MessageBoard_1.default.publishMessage("等待进城冷却中......(约55秒)");
                    TimeoutUtils_1.default.execute(55000, function () {
                        const request = credential.asRequest();
                        // @ts-ignore
                        request["townid"] = townId;
                        // @ts-ignore
                        request["mode"] = "MOVE";
                        NetworkUtils_1.default.sendPostRequest("status.cgi", request, function (html) {
                            if ($(html).text().includes("进入方法选择")) {
                                MessageBoard_1.default.publishMessage("与门卫交涉中......");
                                const request = credential.asRequest();
                                // @ts-ignore
                                request["townid"] = townId;
                                // @ts-ignore
                                request["givemoney"] = "1";
                                // @ts-ignore
                                request["mode"] = "MOVE";
                                NetworkUtils_1.default.sendPostRequest("status.cgi", request, function () {
                                    MessageBoard_1.default.publishMessage("门卫通情达理的收取了入城费用放你入城。");
                                    const town = TownLoader_1.default.load(townId);
                                    MessageBoard_1.default.publishMessage("进入了<span style='color:greenyellow'>" + town.name + "</span>。");
                                    resolve();
                                });
                            }
                            else {
                                const town = TownLoader_1.default.load(townId);
                                MessageBoard_1.default.publishMessage("进入了<span style='color:greenyellow'>" + town.name + "</span>。");
                                resolve();
                            }
                        });
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _TownEntrance_credential, "f"), townId);
        });
    }
    leave() {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential) => {
                return new Promise(resolve => {
                    const request = credential.asRequest();
                    // @ts-ignore
                    request["navi"] = "on";
                    // @ts-ignore
                    request["out"] = "1";
                    // @ts-ignore
                    request["mode"] = "MAP_MOVE";
                    NetworkUtils_1.default.sendPostRequest("map.cgi", request, function (html) {
                        MessageBoard_1.default.publishMessage("离开了当前所在城市。");
                        const plan = TravelPlanBuilder_1.default.initializeTravelPlan(html);
                        plan.credential = credential;
                        resolve(plan);
                    });
                });
            };
            return yield action(__classPrivateFieldGet(this, _TownEntrance_credential, "f"));
        });
    }
}
_TownEntrance_credential = new WeakMap();
module.exports = TownEntrance;


/***/ }),
/* 108 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _ConversationPageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const ConversationPageProcessor_1 = __importDefault(__webpack_require__(109));
class ConversationPageInterceptor {
    constructor() {
        _ConversationPageInterceptor_processor.set(this, new ConversationPageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "messe_print.cgi") {
            return pageText.includes("全员的留言");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .load()
            .then(machine => {
            machine.start()
                .whenInTown(() => {
                __classPrivateFieldGet(this, _ConversationPageInterceptor_processor, "f").process();
            })
                .process();
        });
    }
}
_ConversationPageInterceptor_processor = new WeakMap();
module.exports = ConversationPageInterceptor;


/***/ }),
/* 109 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const EventHandler_1 = __importDefault(__webpack_require__(92));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class ConversationPageProcessor extends PageProcessorCredentialSupport_1.default {
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            $("table:first")
                .next()
                .find("> tbody:first")
                .find("> tr:eq(1)")
                .find("> td:first")
                .attr("id", "eventBoard")
                .each((idx, td) => {
                const eventHtmlList = [];
                $(td).html()
                    .split("<br>")
                    .filter(it => it.endsWith(")"))
                    .map(function (it) {
                    // noinspection HtmlDeprecatedTag,XmlDeprecatedElement,HtmlDeprecatedAttribute
                    const header = "<font color=\"green\">●</font>";
                    return StringUtils_1.default.substringAfter(it, header);
                })
                    .map(function (it) {
                    return EventHandler_1.default.handleWithEventHtml(it);
                })
                    .forEach(it => eventHtmlList.push(it));
                let html = "";
                html += "<table style='border-width:0;width:100%;height:100%;margin:auto'>";
                html += "<tbody>";
                eventHtmlList.forEach(it => {
                    html += "<tr>";
                    html += "<th style='color:green;vertical-align:top'>●</th>";
                    html += "<td style='width:100%'>";
                    html += it;
                    html += "</td>";
                    html += "</tr>";
                });
                html += "</tbody>";
                html += "</table>";
                $(td).html(html);
            });
        });
    }
}
module.exports = ConversationPageProcessor;


/***/ }),
/* 110 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CountryChangePageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const CountryChangePageProcessor_1 = __importDefault(__webpack_require__(111));
const PageProcessorContext_1 = __importDefault(__webpack_require__(85));
class CountryChangePageInterceptor {
    constructor() {
        _CountryChangePageInterceptor_processor.set(this, new CountryChangePageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "country.cgi") {
            return pageText.includes("<< * 仕 官 和 下 野 *>>");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .load()
            .then(machine => {
            machine.start()
                .whenInTown(state => {
                const context = new PageProcessorContext_1.default();
                context.withTownId(state === null || state === void 0 ? void 0 : state.townId);
                __classPrivateFieldGet(this, _CountryChangePageInterceptor_processor, "f").process(context);
            })
                .process();
        });
    }
}
_CountryChangePageInterceptor_processor = new WeakMap();
module.exports = CountryChangePageInterceptor;


/***/ }),
/* 111 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
const PersonalStatus_1 = __importDefault(__webpack_require__(105));
const RankTitleLoader_1 = __importDefault(__webpack_require__(93));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class CountryChangePageProcessor extends PageProcessorCredentialSupport_1.default {
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            $("table:first")
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:first")
                .attr("id", "pageTitle")
                .each((idx, td) => {
                const text = $(td).text();
                $(td)
                    .removeAttr("bgcolor")
                    .removeAttr("width")
                    .removeAttr("height")
                    .css("text-align", "center")
                    .css("font-size", "150%")
                    .css("font-weight", "bold")
                    .css("background-color", "navy")
                    .css("color", "yellowgreen")
                    .text(lodash_1.default.trim(text));
            })
                .parent()
                .next()
                .find("> td:first")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:last")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:eq(1)")
                .find("> td:first")
                .each((idx, td) => {
                new PersonalStatus_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId")).load().then(role => {
                    $(td).text(role.name);
                });
            });
            $("table:first")
                .find("> tbody:first")
                .find("> tr:eq(2)")
                .find("> td:first")
                .attr("id", "messageBoardContainer")
                .each((idx, td) => {
                const html = $(td).html();
                const imageHtml = NpcLoader_1.default.randomNpcImageHtml();
                MessageBoard_1.default.createMessageBoardStyleB("messageBoardContainer", imageHtml);
                $("#messageBoard")
                    .css("background-color", "black")
                    .css("color", "white")
                    .html(html);
            });
            $("table:first")
                .find("> tbody:first")
                .find("> tr:eq(3)")
                .find("> td:first")
                .css("text-align", "center")
                .find("> p:first")
                .find("> table:first")
                .css("margin", "auto")
                .find("> tbody:first")
                .find("> tr")
                .filter(idx => idx > 0)
                .each((idx, tr) => {
                const country = $(tr)
                    .find("> td:first")
                    .find("> font:first")
                    .text();
                if (country === "在野") {
                    $(tr).hide();
                }
                else {
                    const font = $(tr)
                        .find("> td:eq(1)")
                        .find("> font:first");
                    if (SetupLoader_1.default.isQiHanTitleEnabled()) {
                        const text = font.text();
                        let a1 = StringUtils_1.default.substringAfterLast(text, "(");
                        let a0 = StringUtils_1.default.substringBefore(text, "(" + a1);
                        a1 = StringUtils_1.default.substringBefore(a1, ")");
                        let r0 = "";
                        let r1 = "";
                        for (const it of RankTitleLoader_1.default.getAllRankTitles()) {
                            r0 = " " + it + " ";
                            if (a1.includes(r0)) {
                                r1 = " " + RankTitleLoader_1.default.transformTitle(it) + " ";
                                break;
                            }
                        }
                        if (r1 !== "") {
                            a1 = lodash_1.default.replace(a1, r0, r1);
                            font.text(a0 + "(" + a1 + ")");
                        }
                    }
                }
            });
        });
    }
}
module.exports = CountryChangePageProcessor;


/***/ }),
/* 112 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CountryPalacePageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const CountryPalacePageProcessor_1 = __importDefault(__webpack_require__(113));
const PageProcessorContext_1 = __importDefault(__webpack_require__(85));
class CountryPalacePageInterceptor {
    constructor() {
        _CountryPalacePageInterceptor_processor.set(this, new CountryPalacePageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "country.cgi") {
            return pageText.includes("<< * ") && pageText.includes("皇宫 *>>");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .load()
            .then(machine => {
            machine.start()
                .whenInTown(state => {
                const context = new PageProcessorContext_1.default();
                context.withTownId(state === null || state === void 0 ? void 0 : state.townId);
                __classPrivateFieldGet(this, _CountryPalacePageInterceptor_processor, "f").process(context);
            })
                .process();
        });
    }
}
_CountryPalacePageInterceptor_processor = new WeakMap();
module.exports = CountryPalacePageInterceptor;


/***/ }),
/* 113 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CountryPalacePageProcessor_instances, _CountryPalacePageProcessor_welcomeMessageHtml;
const lodash_1 = __importDefault(__webpack_require__(4));
const TownBank_1 = __importDefault(__webpack_require__(43));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
const PersonalStatus_1 = __importDefault(__webpack_require__(105));
const PalaceTaskManager_1 = __importDefault(__webpack_require__(17));
const TownLoader_1 = __importDefault(__webpack_require__(47));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const TimeoutUtils_1 = __importDefault(__webpack_require__(104));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class CountryPalacePageProcessor extends PageProcessorCredentialSupport_1.default {
    constructor() {
        super(...arguments);
        _CountryPalacePageProcessor_instances.add(this);
    }
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            $("table[height='100%']").removeAttr("height");
            const pageTitle = $("table:first")
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:first")
                .attr("id", "pageTitle")
                .text();
            $("#pageTitle")
                .removeAttr("bgcolor")
                .removeAttr("width")
                .removeAttr("height")
                .css("text-align", "center")
                .css("font-size", "150%")
                .css("font-weight", "bold")
                .css("background-color", "navy")
                .css("color", "yellowgreen")
                .text(lodash_1.default.trim(pageTitle));
            $("#pageTitle")
                .parent()
                .next()
                .find("> td:first")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:last")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:eq(1)")
                .find("> td:first")
                .each((i, td) => {
                new PersonalStatus_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId")).load().then(role => {
                    $(td).text(role.name);
                });
            })
                .parent()
                .next()
                .find("> td:last")
                .attr("id", "roleCash")
                .parent()
                .each((i, tr) => {
                let html = "";
                html += "<tr>";
                html += "<td style='background-color:#E0D0B0'>计时器</td>";
                html += "<td style='background-color:#E8E8D0;color:red;text-align:right;font-weight:bold' " +
                    "colspan='3' id='countDownTimer'>-</td>";
                html += "</tr>";
                $(tr).after($(html));
            });
            $("#pageTitle")
                .parent()
                .next()
                .next()
                .find("> td:first")
                .attr("id", "messageBoardContainer")
                .html("")
                .each((i, td) => {
                const containerId = $(td).attr("id");
                const imageHtml = NpcLoader_1.default.randomNpcImageHtml();
                MessageBoard_1.default.createMessageBoardStyleB(containerId, imageHtml);
                $("#messageBoard")
                    .css("background-color", "black")
                    .css("color", "white")
                    .html(__classPrivateFieldGet(this, _CountryPalacePageProcessor_instances, "m", _CountryPalacePageProcessor_welcomeMessageHtml).call(this));
            });
            $("table:first")
                .find("> tbody:first")
                .find("> tr:last")
                .find("> td:first")
                .attr("id", "hidden-0")
                .parent()
                .hide()
                .each((i, tr) => {
                let html = "";
                html += "<tr style='display:none'>";
                html += "<td id='hidden-1'></td>";
                html += "</tr>";
                html += "<tr style='display:none'>";
                html += "<td id='hidden-2'></td>";
                html += "</tr>";
                html += "<tr style='display:none'>";
                html += "<td id='hidden-3'></td>";
                html += "</tr>";
                html += "<tr style='display:none'>";
                html += "<td id='prompt' style='background-color:#D4D4D4;font-weight:bold;text-align:center'></td>";
                html += "</tr>";
                html += "<tr>";
                html += "<td id='task' style='background-color:#F8F0E0;text-align:center'></td>";
                html += "</tr>";
                html += "<tr>";
                html += "<td id='menu' style='background-color:#F8F0E0;text-align:center'></td>";
                html += "</tr>";
                $(tr).after($(html));
            });
            renderMenu(context);
            renderTask(credential, context);
            renderPrompt(credential);
            PageUtils_1.default.onDoubleEscape(() => $("#returnButton").trigger("click"));
        });
    }
}
_CountryPalacePageProcessor_instances = new WeakSet(), _CountryPalacePageProcessor_welcomeMessageHtml = function _CountryPalacePageProcessor_welcomeMessageHtml() {
    return "<b style='color:whitesmoke;font-size:120%'>" +
        "秋风起兮白云飞,草木黄落兮雁南归。兰有秀兮菊有芳,怀佳人兮不能忘。<br>" +
        "泛楼船兮济汾河,横中流兮扬素波。萧鼓鸣兮发棹歌,欢乐极兮哀情多。<br>" +
        "少壮几时兮奈老何。" +
        "</b>";
};
function renderMenu(context) {
    $("#menu")
        .each((i, td) => {
        const town = TownLoader_1.default.load(context === null || context === void 0 ? void 0 : context.get("townId"));
        let html = "";
        html += "<table style='background-color:transparent;border-width:unset;border-spacing:unset;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td>";
        html += "<button role='button' class='palaceButton' id='returnButton'>返回" + (town === null || town === void 0 ? void 0 : town.name) + "</button>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $(td).html(html);
        $("#returnButton").on("click", () => {
            $("input:submit[value='返回城市']").trigger("click");
        });
    });
}
function renderTask(credential, context) {
    let html = "";
    html += "<table style='background-color:#888888;margin:auto;text-align:center'>";
    html += "<tbody style='background-color:#F8F0E0'>";
    html += "<tr style='background-color:red;color:white'>";
    html += "<th>内阁</th>";
    html += "<th>官职</th>";
    html += "<th>任务</th>";
    html += "<th>接受</th>";
    html += "<th>完成</th>";
    html += "<th>花</th>";
    html += "</tr>";
    $("#hidden-0")
        .find("> center:first")
        .find("> form:first")
        .find("> table:first")
        .find("> tbody:first")
        .find("> tr")
        .filter(i => i > 1)
        .each((i, tr) => {
        const c1 = $(tr).find("> td:first");
        const c2 = c1.next();
        const c3 = c2.next();
        const c4 = c3.next();
        const c5 = c4.next();
        const radio = c1.find("> input:radio");
        const index = lodash_1.default.parseInt(radio.val());
        const title = c3.text();
        const task = c4.text();
        const flower = c5.text();
        html += "<tr>";
        html += "<td style='width:64px;height:64px'>" + NpcLoader_1.default.getTaskNpcImageHtml(title) + "</td>";
        html += "<td>" + title + "</td>";
        html += "<td>" + task + "</td>";
        if (!radio.prop("disabled")) {
            html += "<td><button role='button' class='palaceButton acceptButton' id='accept-" + index + "'>接受任务</button></td>";
            html += "<td><button role='button' class='palaceButton finishButton' id='finish-" + index + "'>完成任务</button></td>";
        }
        else {
            html += "<td><button role='button' id='accept-" + index + "' disabled>接受任务</button></td>";
            html += "<td><button role='button' id='finish-" + index + "' disabled>完成任务</button></td>";
        }
        html += "<td>" + flower + "</td>";
        html += "</tr>";
    });
    html += "<tr>";
    html += "<td colspan='6'>";
    html += "<button role='button' class='palaceButton' id='cancel' style='width:100%;background-color:red;color:white;font-weight:bold'>取 消 任 务</button>";
    html += "</td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    $("#task").html(html);
    bindTaskButton(credential, context);
}
function renderPrompt(credential) {
    new PalaceTaskManager_1.default(credential)
        .monsterTaskHtml()
        .then(html => {
        if (html === "") {
            $("#prompt").html("").parent().hide();
        }
        else {
            $("#prompt").html(html).parent().show();
        }
    });
}
function bindTaskButton(credential, context) {
    $(".acceptButton").on("click", event => {
        PageUtils_1.default.scrollIntoView("pageTitle");
        const buttonId = $(event.target).attr("id");
        const index = lodash_1.default.parseInt(lodash_1.default.split(buttonId, "-")[1]);
        const noWait = confirm("请确认您当前是否已经读秒冷却完成了?如果取消会自动开始读秒。");
        let timeout = 0;
        if (!noWait) {
            MessageBoard_1.default.publishMessage("请耐心等待计时器冷却...");
            timeout = 55000;
        }
        $(".palaceButton").prop("disabled", true);
        TimeoutUtils_1.default.execute(timeout, () => {
            if (index !== 4) {
                $("input:radio[value='" + index + "']").prop("checked", true);
                $("option[value='ACCEPTTASK']").prop("selected", true);
                $("input:submit[value='OK']").trigger("click");
            }
            else {
                const request = credential.asRequestMap();
                request.set("governid", "4");
                request.set("mode", "ACCEPTTASK");
                NetworkUtils_1.default.post("country.cgi", request).then(html => {
                    MessageBoard_1.default.processResponseMessage(html);
                    if (html.includes("请去战斗场所消灭")) {
                        const monsterName = $(html)
                            .find("h2:first")
                            .find("> font:first")
                            .text();
                        new PalaceTaskManager_1.default(credential)
                            .updateMonsterTask(monsterName)
                            .then(() => {
                            $(".palaceButton").prop("disabled", false);
                            renderPrompt(credential);
                        });
                    }
                    else if (html.includes("您当前的任务是杀掉")) {
                        // 当前已经接受了任务
                        const monsterName = $(html)
                            .find("h3:first")
                            .next()
                            .find("> font:first")
                            .find("> b:first")
                            .find("> font:first")
                            .text();
                        new PalaceTaskManager_1.default(credential)
                            .updateMonsterTask(monsterName)
                            .then(() => {
                            $(".palaceButton").prop("disabled", false);
                            renderPrompt(credential);
                        });
                    }
                });
            }
        });
    });
    $(".finishButton").on("click", event => {
        PageUtils_1.default.scrollIntoView("pageTitle");
        const buttonId = $(event.target).attr("id");
        const index = lodash_1.default.parseInt(lodash_1.default.split(buttonId, "-")[1]);
        const noWait = confirm("请确认您当前是否已经读秒冷却完成了?如果取消会自动开始读秒。");
        let timeout = 0;
        if (!noWait) {
            MessageBoard_1.default.publishMessage("请耐心等待计时器冷却...");
            timeout = 55000;
        }
        $(".palaceButton").prop("disabled", true);
        TimeoutUtils_1.default.execute(timeout, () => {
            if (index !== 4) {
                $("input:radio[value='" + index + "']").prop("checked", true);
                $("option[value='COMPLETETASK']").prop("selected", true);
                $("input:submit[value='OK']").trigger("click");
            }
            else {
                const request = credential.asRequestMap();
                request.set("governid", "4");
                request.set("mode", "COMPLETETASK");
                NetworkUtils_1.default.post("country.cgi", request).then(html => {
                    MessageBoard_1.default.processResponseMessage(html);
                    if (html.includes("你还没有完成杀掉")) {
                        const monsterName = $(html)
                            .find("h3:first")
                            .next()
                            .find("> font:first")
                            .find("> b:first")
                            .find("> font:first")
                            .text();
                        new PalaceTaskManager_1.default(credential)
                            .updateMonsterTask(monsterName)
                            .then(() => {
                            $(".palaceButton").prop("disabled", false);
                            renderPrompt(credential);
                        });
                    }
                    else {
                        // 完成了
                        new PalaceTaskManager_1.default(credential)
                            .finishMonsterTask()
                            .then(() => {
                            $(".palaceButton").prop("disabled", false);
                            renderPrompt(credential);
                        });
                    }
                });
            }
        });
    });
    $("#cancel").on("click", () => {
        if (!confirm("请确认要取消所有的任务么?")) {
            return;
        }
        PageUtils_1.default.scrollIntoView("pageTitle");
        $(".palaceButton").prop("disabled", true);
        const bank = new TownBank_1.default(credential, context.get("townId"));
        bank.withdraw(10).then(() => {
            bank.load().then(account => {
                $("#roleCash").text(account.cash + " GOLD");
            });
            MessageBoard_1.default.publishMessage("请耐心等待计时器冷却...");
            TimeoutUtils_1.default.execute(55000, () => {
                const request = credential.asRequestMap();
                request.set("mode", "CANCELTASK");
                NetworkUtils_1.default.post("country.cgi", request).then(html => {
                    MessageBoard_1.default.processResponseMessage(html);
                    new PalaceTaskManager_1.default(credential)
                        .finishMonsterTask()
                        .then(() => {
                        bank.deposit().then(() => {
                            bank.load().then(account => {
                                $("#roleCash").text(account.cash + " GOLD");
                            });
                            $(".palaceButton").prop("disabled", false);
                            renderPrompt(credential);
                        });
                    });
                });
            });
        });
    });
}
module.exports = CountryPalacePageProcessor;


/***/ }),
/* 114 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CountryTownStrengthenPageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const CountryTownStrengthenPageProcessor_1 = __importDefault(__webpack_require__(115));
const PageProcessorContext_1 = __importDefault(__webpack_require__(85));
class CountryTownStrengthenPageInterceptor {
    constructor() {
        _CountryTownStrengthenPageInterceptor_processor.set(this, new CountryTownStrengthenPageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "country.cgi") {
            return pageText.includes("<< * 国家.内政.强化.指令 *>>");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .load()
            .then(machine => {
            machine.start()
                .whenInCastle(state => {
                const context = new PageProcessorContext_1.default();
                context.withTownId(state === null || state === void 0 ? void 0 : state.townId);
                __classPrivateFieldGet(this, _CountryTownStrengthenPageInterceptor_processor, "f").process(context);
            })
                .process();
        });
    }
}
_CountryTownStrengthenPageInterceptor_processor = new WeakMap();
module.exports = CountryTownStrengthenPageInterceptor;


/***/ }),
/* 115 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CountryTownStrengthenPageProcessor_instances, _CountryTownStrengthenPageProcessor_welcomeMessageHtml;
const lodash_1 = __importDefault(__webpack_require__(4));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
const PersonalStatus_1 = __importDefault(__webpack_require__(105));
const TownLoader_1 = __importDefault(__webpack_require__(47));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class CountryTownStrengthenPageProcessor extends PageProcessorCredentialSupport_1.default {
    constructor() {
        super(...arguments);
        _CountryTownStrengthenPageProcessor_instances.add(this);
    }
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            $("table[height='100%']").removeAttr("height");
            $("form[action='status.cgi']").hide();
            $("table:first")
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:first")
                .attr("id", "pageTitle")
                .removeAttr("bgcolor")
                .removeAttr("width")
                .removeAttr("height")
                .css("text-align", "center")
                .css("font-size", "150%")
                .css("font-weight", "bold")
                .css("background-color", "navy")
                .css("color", "yellowgreen")
                .each((i, td) => {
                const pageTitle = $(td).text();
                $(td).text(lodash_1.default.trim(pageTitle));
            })
                .parent()
                .next()
                .find("> td:first")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:first")
                .find("> td:eq(1)")
                .find("> table:first")
                .find("> tbody:first")
                .find("> tr:eq(1)")
                .find("> td:first")
                .each((i, td) => {
                new PersonalStatus_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId")).load().then(role => {
                    $(td).text(role.name);
                });
            });
            $("table:first")
                .find("> tbody:first")
                .find("> tr:eq(2)")
                .find("> td:first")
                .attr("id", "messageBoardContainer")
                .html("")
                .each((i, td) => {
                const containerId = $(td).attr("id");
                const imageHtml = NpcLoader_1.default.randomNpcImageHtml();
                MessageBoard_1.default.createMessageBoardStyleB(containerId, imageHtml);
                $("#messageBoard")
                    .css("background-color", "black")
                    .css("color", "white")
                    .html(__classPrivateFieldGet(this, _CountryTownStrengthenPageProcessor_instances, "m", _CountryTownStrengthenPageProcessor_welcomeMessageHtml).call(this));
            });
            $("table:first")
                .find("> tbody:first")
                .find("> tr:eq(3)")
                .find("> td:first")
                .find("> center:first")
                .find("> p:first")
                .hide()
                .next()
                .find("> p:first")
                .hide()
                .next()
                .hide();
            $("table:first")
                .find("> tbody:first")
                .find("> tr:eq(3)")
                .each((i, tr) => {
                const town = TownLoader_1.default.load(context === null || context === void 0 ? void 0 : context.get("townId"));
                let html = "";
                html += "<tr>";
                html += "<td id='instruction' style='text-align:center'></td>";
                html += "</tr>";
                html += "<tr>";
                html += "<td id='menu' style='text-align:center'>";
                html += "<button role='button' id='returnButton'>返回" + (town === null || town === void 0 ? void 0 : town.name) + "</button>";
                html += "</td>";
                html += "</tr>";
                $(tr).after($(html));
                $("#returnButton").on("click", () => {
                    $("input:submit[value='返回城市']").trigger("click");
                });
            });
            let html = "";
            html += "<table style='background-color:#888888;margin:auto'>";
            html += "<tbody>";
            html += "<tr style='background-color:red;color:white'>";
            html += "<th>内阁</th>";
            html += "<th>指令</th>";
            html += "<th>内容</th>";
            html += "<th>发布</th>";
            html += "<tr>";
            html += "<tr>";
            html += "<td style='background-color:#E8E8D0'>" +
                NpcLoader_1.default.getTaskNpcImageHtml("诸葛亮") +
                "</td>";
            html += "<td style='background-color:#E8E8D0'>国家动员指令</td>";
            html += "<td style='background-color:#E8E8D0'>" +
                "<input type='text' id='m1' size='40'>" +
                "</td>";
            html += "<td style='background-color:#E8E8D0'>" +
                "<button role='button' id='p1'>下达</button>" +
                "</td>";
            html += "<tr>";
            html += "<tr>";
            html += "<td style='background-color:#E8E8D0'>" +
                NpcLoader_1.default.getTaskNpcImageHtml("司马懿") +
                "</td>";
            html += "<td style='background-color:#E8E8D0'>在野招募告示</td>";
            html += "<td style='background-color:#E8E8D0'>" +
                "<input type='text' id='m2' size='40'>" +
                "</td>";
            html += "<td style='background-color:#E8E8D0'>" +
                "<button role='button' id='p2'>发布</button>" +
                "</td>";
            html += "<tr>";
            html += "</tbody>";
            html += "</table>";
            $("#instruction").html(html);
            doBindPublishButton(credential);
            PageUtils_1.default.onDoubleEscape(() => $("#returnButton").trigger("click"));
        });
    }
}
_CountryTownStrengthenPageProcessor_instances = new WeakSet(), _CountryTownStrengthenPageProcessor_welcomeMessageHtml = function _CountryTownStrengthenPageProcessor_welcomeMessageHtml() {
    return "<b style='color:whitesmoke;font-size:120%'>" +
        "军民团结如一人,试看天下谁能敌!" +
        "</b>";
};
function doBindPublishButton(credential) {
    $("#p1").on("click", () => {
        PageUtils_1.default.scrollIntoView("pageTitle");
        const msg = $("#m1").val();
        if (msg === undefined || lodash_1.default.trim(msg) === "") {
            MessageBoard_1.default.publishWarning("没有输入指令内容!");
            return;
        }
        const msgForPublish = lodash_1.default.trim(msg);
        const request = credential.asRequestMap();
        request.set("m_0", "1");
        request.set("azukeru", "1");
        // noinspection JSDeprecatedSymbols
        request.set("ins", escape(msgForPublish));
        request.set("ins2", "");
        request.set("mode", "COUNTRY_STR");
        NetworkUtils_1.default.post("country.cgi", request).then(html => {
            MessageBoard_1.default.processResponseMessage(html);
        });
    });
    $("#p2").on("click", () => {
        PageUtils_1.default.scrollIntoView("pageTitle");
        const msg = $("#m2").val();
        if (msg === undefined || lodash_1.default.trim(msg) === "") {
            MessageBoard_1.default.publishWarning("没有输入指令内容!");
            return;
        }
        const msgForPublish = lodash_1.default.trim(msg);
        const request = credential.asRequestMap();
        request.set("m_0", "1");
        request.set("azukeru", "1");
        request.set("ins", "");
        // noinspection JSDeprecatedSymbols
        request.set("ins2", escape(msgForPublish));
        request.set("mode", "COUNTRY_STR");
        NetworkUtils_1.default.post("country.cgi", request).then(html => {
            MessageBoard_1.default.processResponseMessage(html);
        });
    });
}
module.exports = CountryTownStrengthenPageProcessor;


/***/ }),
/* 116 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _LoginDashboardPageInterceptor_processor;
const TeamMemberLoader_1 = __importDefault(__webpack_require__(117));
const LoginDashboardPageProcessor_1 = __importDefault(__webpack_require__(119));
class LoginDashboardPageInterceptor {
    constructor() {
        _LoginDashboardPageInterceptor_processor.set(this, new LoginDashboardPageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "contnue.cgi") {
            return pageText.includes("继续游戏");
        }
        return false;
    }
    intercept() {
        if (TeamMemberLoader_1.default.loadTeamMembers().length > 0) {
            __classPrivateFieldGet(this, _LoginDashboardPageInterceptor_processor, "f").process();
        }
    }
}
_LoginDashboardPageInterceptor_processor = new WeakMap();
module.exports = LoginDashboardPageInterceptor;


/***/ }),
/* 117 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Constants_1 = __importDefault(__webpack_require__(11));
const StorageUtils_1 = __importDefault(__webpack_require__(21));
const TeamMember_1 = __importDefault(__webpack_require__(118));
class TeamMemberLoader {
    static loadTeamMember(index) {
        if (index === null || index === undefined)
            return null;
        const config = _load(index);
        const member = new TeamMember_1.default();
        member.index = index;
        // @ts-ignore
        member.name = config.name;
        // @ts-ignore
        member.id = config.id;
        // @ts-ignore
        member.pass = config.pass;
        // @ts-ignore
        member.master = config.master;
        // @ts-ignore
        member.external = config.external;
        return member.available ? member : null;
    }
    static loadTeamMembers() {
        const memberList = [];
        for (let i = 0; i < Constants_1.default.MAX_TEAM_MEMBER_COUNT; i++) {
            const member = TeamMemberLoader.loadTeamMember(i);
            if (member)
                memberList.push(member);
        }
        return memberList;
    }
    static loadInternalIds() {
        return TeamMemberLoader.loadTeamMembers().filter(it => !it.external).map(it => it.id);
    }
    static isMaster(id) {
        if (!id)
            return false;
        const member = TeamMemberLoader.loadTeamMembers().find(it => it.id === id);
        if (!member)
            return false;
        return member.master !== undefined && member.master;
    }
}
function _load(index) {
    if (index === null || index === undefined)
        return {};
    if (index < 0 || index >= Constants_1.default.MAX_TEAM_MEMBER_COUNT)
        return {};
    const key = "_fl_" + index;
    const s = StorageUtils_1.default.getString(key);
    return s === "" ? {} : JSON.parse(s);
}
module.exports = TeamMemberLoader;


/***/ }),
/* 118 */
/***/ ((module) => {

"use strict";

class TeamMember {
    get available() {
        return this.name !== undefined && this.id !== undefined && this.pass !== undefined;
    }
    asObject() {
        const obj = {};
        if (this.name) {
            // @ts-ignore
            obj.name = this.name;
        }
        if (this.id) {
            // @ts-ignore
            obj.id = this.id;
        }
        if (this.pass) {
            // @ts-ignore
            obj.pass = this.pass;
        }
        if (this.external) {
            // @ts-ignore
            obj.external = this.external;
        }
        if (this.master) {
            // @ts-ignore
            obj.master = this.master;
        }
        return obj;
    }
}
module.exports = TeamMember;


/***/ }),
/* 119 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const LastLoginStorage_1 = __importDefault(__webpack_require__(120));
const TeamMemberLoader_1 = __importDefault(__webpack_require__(117));
const ButtonUtils_1 = __importDefault(__webpack_require__(84));
const PageUtils_1 = __importDefault(__webpack_require__(14));
class LoginDashboardPageProcessor {
    process() {
        ButtonUtils_1.default.loadButtonStyle(10028);
        PageUtils_1.default.fixCurrentPageBrokenImages();
        PageUtils_1.default.removeUnusedHyperLinks();
        PageUtils_1.default.removeGoogleAnalyticsScript();
        $("table")
            .each((idx, table) => {
            const tableId = "t" + idx;
            $(table).attr("id", tableId);
        });
        $("img:first")
            .attr("width", "64")
            .attr("height", "48");
        const layout = SetupLoader_1.default.getLoginPageLayout();
        switch (layout) {
            case 1:
                $("#t0")
                    .find("td:first")
                    .css("vertical-align", "top");
                $("#t1")
                    .css("margin", "0px auto auto auto");
                break;
            case 2:
                $("#t0")
                    .find("td:first")
                    .css("vertical-align", "bottom");
                $("#t1")
                    .css("margin", "auto auto 0px auto");
                break;
            case 3:
                $("#t1")
                    .css("margin", "auto auto auto 0px");
                break;
            case 4:
                $("#t1")
                    .css("margin", "auto 0px auto auto");
                break;
            case 5:
                $("#t0")
                    .find("td:first")
                    .css("vertical-align", "top");
                $("#t1")
                    .css("margin", "0px auto auto 0px");
                break;
            case 6:
                $("#t0")
                    .find("td:first")
                    .css("vertical-align", "bottom");
                $("#t1")
                    .css("margin", "auto auto 0px 0px");
                break;
            case 7:
                $("#t0")
                    .find("td:first")
                    .css("vertical-align", "top");
                $("#t1")
                    .css("margin", "0px 0px auto auto");
                break;
            case 8:
                $("#t0")
                    .find("td:first")
                    .css("vertical-align", "bottom");
                $("#t1")
                    .css("margin", "auto 0px 0px auto");
                break;
        }
        doProcess();
    }
}
function doProcess() {
    const members = new Map();
    TeamMemberLoader_1.default.loadTeamMembers().forEach(it => members.set(it.index, it));
    if (members.size === 0)
        return;
    $("input:text[name='id']").attr("id", "loginId");
    $("input:password[name='pass']").attr("id", "loginPass");
    $("input:submit[value='登陆']").attr("id", "loginButton");
    $("form").attr("id", "loginForm");
    let html = "";
    html += "<tr>";
    html += "<td id='fastLogin' style='background-color:#E8E8D0;text-align:center' colspan='2'></td>";
    html += "</tr>";
    $("#loginButton")
        .closest("tr")
        .after($(html));
    LastLoginStorage_1.default.getInstance()
        .load()
        .then(lastLogin => {
        doRender(members, lastLogin);
    });
}
function doRender(members, lastLogin) {
    const fastLoginCounts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    let html = "";
    html += "<table style='border-width:0;margin:auto;text-align:center;width:100%'>";
    html += "<tbody>";
    html += "</tbody>";
    html += "<tr>";
    html += "<td colspan='5' style='color:navy;font-weight:bold'>快速登陆时请自行输入图形验证码</td>";
    html += "</tr>";
    html += "<tr id='tr1'>";
    for (let i = 0; i < 5; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[0]++;
        });
    }
    html += "</tr>";
    html += "<tr id='tr2'>";
    for (let i = 5; i < 10; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[1]++;
        });
    }
    html += "</tr>";
    html += "<tr id='tr3'>";
    for (let i = 10; i < 15; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[2]++;
        });
    }
    html += "</tr>";
    html += "<tr id='tr4'>";
    for (let i = 15; i < 20; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[3]++;
        });
    }
    html += "</tr>";
    html += "<tr id='tr5'>";
    for (let i = 20; i < 25; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[4]++;
        });
    }
    html += "</tr>";
    html += "<tr id='tr6'>";
    for (let i = 25; i < 30; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[5]++;
        });
    }
    html += "</tr>";
    html += "<tr id='tr7'>";
    for (let i = 30; i < 35; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[6]++;
        });
    }
    html += "</tr>";
    html += "<tr id='tr8'>";
    for (let i = 35; i < 40; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[7]++;
        });
    }
    html += "</tr>";
    html += "<tr id='tr9'>";
    for (let i = 40; i < 45; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[8]++;
        });
    }
    html += "</tr>";
    html += "<tr id='tr10'>";
    for (let i = 45; i < 50; i++) {
        html += doGenerateCell(lastLogin, members, i, () => {
            fastLoginCounts[9]++;
        });
    }
    html += "</tr>";
    html += "</table>";
    $("#fastLogin").html(html);
    for (let i = 0; i < fastLoginCounts.length; i++) {
        const fastLoginCount = fastLoginCounts[i];
        if (fastLoginCount === 0) {
            $("#tr" + (i + 1)).hide();
        }
    }
    doBindFastLoginButton();
}
function doGenerateCell(lastLogin, members, code, handler) {
    let count = 0;
    let html = "";
    let lastRoleId = "";
    if (lastLogin !== null) {
        lastRoleId = lastLogin.roleId;
    }
    html += "<td style='background-color:#E8E8D0;width:20%;height:32px'>";
    let member = members.get(code);
    if (member) {
        count++;
        const name = member.name;
        if (lastRoleId === member.id) {
            html += "<input type='button' class='fastLoginButton button-10028' " +
                "id='fastLogin_" + code + "' value='" + name + "' " +
                "style='color:red;width:100%'>";
        }
        else {
            html += "<input type='button' class='fastLoginButton button-10028' " +
                "id='fastLogin_" + code + "' value='" + name + "' " +
                "style='width:100%'>";
        }
    }
    html += "</td>";
    if (count > 0 && handler !== undefined) {
        handler();
    }
    return html;
}
function doBindFastLoginButton() {
    $(".fastLoginButton").on("click", event => {
        const s = lodash_1.default.split($(event.target).attr("id"), "_");
        const index = lodash_1.default.parseInt(s[1]);
        const member = TeamMemberLoader_1.default.loadTeamMember(index);
        if (!member)
            return;
        // 记录最后一次使用快速登陆的id
        const lastRoleId = member.id;
        LastLoginStorage_1.default.getInstance()
            .write(lastRoleId)
            .then(() => {
            $("#loginId").val(member.id);
            $("#loginPass").val(member.pass);
            $("#loginForm").removeAttr("onsubmit");
            $("#loginButton").trigger("click");
        });
    });
}
module.exports = LoginDashboardPageProcessor;


/***/ }),
/* 120 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const LastLogin_1 = __importDefault(__webpack_require__(121));
class LastLoginStorage {
    static getInstance() {
        return instance;
    }
    load() {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const request = db
                        .transaction(["LastLogin"], "readonly")
                        .objectStore("LastLogin")
                        .get(1);
                    request.onerror = reject;
                    request.onsuccess = () => {
                        if (request.result) {
                            const data = new LastLogin_1.default();
                            data.id = request.result.id;
                            data.updateTime = request.result.updateTime;
                            data.roleId = request.result.roleId;
                            resolve(data);
                        }
                        else {
                            resolve(null);
                        }
                    };
                });
            })();
        });
    }
    write(roleId) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return yield (() => {
                return new Promise((resolve, reject) => {
                    const data = {
                        id: 1,
                        updateTime: new Date().getTime(),
                        roleId: roleId
                    };
                    const request = db
                        .transaction(["LastLogin"], "readwrite")
                        .objectStore("LastLogin")
                        .put(data);
                    request.onerror = reject;
                    request.onsuccess = () => resolve();
                });
            })();
        });
    }
}
const instance = new LastLoginStorage();
module.exports = LastLoginStorage;


/***/ }),
/* 121 */
/***/ ((module) => {

"use strict";

class LastLogin {
}
module.exports = LastLogin;


/***/ }),
/* 122 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _MapDashboardPageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const MapDashboardPageProcessor_1 = __importDefault(__webpack_require__(123));
const PageProcessorContext_1 = __importDefault(__webpack_require__(85));
class MapDashboardPageInterceptor {
    constructor() {
        _MapDashboardPageInterceptor_processor.set(this, new MapDashboardPageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "map.cgi" || cgi === "status.cgi") {
            return pageText.includes("请选择移动的格数") && !pageText.includes("迪斯尼乐园");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .inMap()
            .then(state => {
            var _a;
            const context = new PageProcessorContext_1.default();
            context.set("coordinate", (_a = state.asCoordinate()) === null || _a === void 0 ? void 0 : _a.asText());
            __classPrivateFieldGet(this, _MapDashboardPageInterceptor_processor, "f").process(context);
        });
    }
}
_MapDashboardPageInterceptor_processor = new WeakMap();
module.exports = MapDashboardPageInterceptor;


/***/ }),
/* 123 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _MapDashboardPageProcessor_instances, _MapDashboardPageProcessor_bindLocationButtons, _MapDashboardPageProcessor_renderRankTitle, _MapDashboardPageProcessor_renderExperience, _MapDashboardPageProcessor_renderEventBoard, _MapDashboardPageProcessor_doTravelToLocation;
const lodash_1 = __importDefault(__webpack_require__(4));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const CastleInformation_1 = __importDefault(__webpack_require__(55));
const MapDashboardPage_1 = __importDefault(__webpack_require__(124));
const EventHandler_1 = __importDefault(__webpack_require__(92));
const MapBuilder_1 = __importDefault(__webpack_require__(99));
const TravelPlanBuilder_1 = __importDefault(__webpack_require__(97));
const TravelPlanExecutor_1 = __importDefault(__webpack_require__(103));
const RankTitleLoader_1 = __importDefault(__webpack_require__(93));
const TaskGuideManager_1 = __importDefault(__webpack_require__(125));
const Coordinate_1 = __importDefault(__webpack_require__(5));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class MapDashboardPageProcessor extends PageProcessorCredentialSupport_1.default {
    constructor() {
        super(...arguments);
        _MapDashboardPageProcessor_instances.add(this);
    }
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            const page = MapDashboardPage_1.default.parse(PageUtils_1.default.currentPageHtml());
            $("center:first")
                .attr("id", "systemAnnouncement");
            $("#systemAnnouncement")
                .after($("<div id='version' style='color:navy;font-weight:bold;text-align:center;width:100%'></div>"));
            // @ts-ignore
            $("#version").html("Pocketrose Assistant (4.2.15) Build: 2023/7/3 08:41:38");
            if (SetupLoader_1.default.isQiHanTitleEnabled()) {
                $("table:first")
                    .find("> tbody:first")
                    .find("> tr:eq(1)")
                    .find("> td:first")
                    .find("> form:first")
                    .find("> font:first")
                    .each((idx, font) => {
                    let c = $(font).text();
                    let b = StringUtils_1.default.substringAfterLast(c, "(");
                    let a = StringUtils_1.default.substringBefore(c, "(" + b);
                    b = StringUtils_1.default.substringBefore(b, ")");
                    const ss = lodash_1.default.split(b, " ");
                    const b1 = lodash_1.default.replace(ss[0], "部队", "");
                    const b2 = RankTitleLoader_1.default.transformTitle(ss[1]);
                    const b3 = ss[2];
                    const s = a + "(" + b1 + " " + b2 + " " + b3 + ")";
                    $(font).text(s);
                });
            }
            $("table:first")
                .find("tbody:first")
                .find("> tr:eq(2)")
                .attr("id", "mapRow");
            let travelJournals = $("#mapRow")
                .find("> td:last")
                .html();
            $("#mapRow").html("" +
                "<td colspan='2'>" +
                "<table style='background-color:transparent;margin:auto;width:100%'>" +
                "<tbody>" +
                "<tr>" +
                "<td id='map' style='background-color:#F8F0E0'></td>" +
                "<td id='travelJournals' style='background-color:#EFE0C0;width:100%'></td>" +
                "</tr>" +
                "</tbody>" +
                "</table>" +
                "</td>");
            $("#map").html(MapBuilder_1.default.buildMapTable());
            $("#travelJournals").html(travelJournals);
            MapBuilder_1.default.updateTownBackgroundColor();
            const roleTask = yield new TaskGuideManager_1.default(credential).currentTask();
            if (roleTask === null || roleTask === "") {
                // 如果有必要的话绘制城堡
                new CastleInformation_1.default()
                    .load(page.role.name)
                    .then(castle => {
                    const coordinate = castle.coordinate;
                    const buttonId = "location_" + coordinate.x + "_" + coordinate.y;
                    $("#" + buttonId)
                        .attr("value", "堡")
                        .css("background-color", "fuchsia")
                        .parent()
                        .attr("title", "城堡" + coordinate.asText() + " " + castle.name)
                        .attr("class", "color_fuchsia");
                });
            }
            const coordinate = Coordinate_1.default.parse(context.get("coordinate"));
            const buttonId = "location_" + coordinate.x + "_" + coordinate.y;
            $("#" + buttonId)
                .closest("td")
                .css("background-color", "black")
                .css("color", "yellow")
                .css("text-align", "center")
                .html($("#" + buttonId).val());
            if (roleTask === null || roleTask === "") {
                __classPrivateFieldGet(this, _MapDashboardPageProcessor_instances, "m", _MapDashboardPageProcessor_bindLocationButtons).call(this, credential);
            }
            else {
                processTask(credential, roleTask);
            }
            __classPrivateFieldGet(this, _MapDashboardPageProcessor_instances, "m", _MapDashboardPageProcessor_renderRankTitle).call(this);
            __classPrivateFieldGet(this, _MapDashboardPageProcessor_instances, "m", _MapDashboardPageProcessor_renderExperience).call(this);
            __classPrivateFieldGet(this, _MapDashboardPageProcessor_instances, "m", _MapDashboardPageProcessor_renderEventBoard).call(this);
        });
    }
}
_MapDashboardPageProcessor_instances = new WeakSet(), _MapDashboardPageProcessor_bindLocationButtons = function _MapDashboardPageProcessor_bindLocationButtons(credential) {
    const instance = this;
    $(".location_button_class")
        .on("mouseenter", function () {
        $(this).css("background-color", "red");
    })
        .on("mouseleave", function () {
        const s = $(this).parent().attr("class");
        const c = StringUtils_1.default.substringAfter(s, "_");
        if (c !== "none") {
            $(this).css("background-color", c);
        }
        else {
            $(this).removeAttr("style");
        }
    });
    $(".location_button_class").on("click", function () {
        const ss = $(this).attr("id").split("_");
        const x = parseInt(ss[1]);
        const y = parseInt(ss[2]);
        const coordinate = new Coordinate_1.default(x, y);
        const confirmation = confirm("确认移动到坐标" + coordinate.asText() + "?");
        if (!confirmation) {
            return;
        }
        $("#mapRow")
            .next().hide()
            .next().hide()
            .next().hide()
            .next().hide();
        MessageBoard_1.default.createMessageBoardStyleC("travelJournals");
        $("#messageBoard")
            .closest("table")
            .css("height", "100%");
        $("#messageBoard")
            .parent()
            .before($("<tr style='background-color:#EFE0C0'>" +
            "<td style='text-align:left'>坐标点:<span id='roleLocation' style='color:red'>-</span></td>" +
            "</tr>" +
            "<tr style='background-color:#EFE0C0'>" +
            "<td style='text-align:left'>计时器:<span id='countDownTimer' style='color:red'>-</span></td>" +
            "</tr>"));
        $("#messageBoard")
            .parent()
            .after($("<tr style='background-color:#EFE0C0'>" +
            "<td style='text-align:center'><button role='button' id='refreshButton' disabled>移动中......</button></td>" +
            "</tr>"));
        MessageBoard_1.default.resetMessageBoard("实时旅途动态播报:<br>");
        $(".location_button_class")
            .prop("disabled", true)
            .off("mouseenter")
            .off("mouseleave");
        __classPrivateFieldGet(instance, _MapDashboardPageProcessor_instances, "m", _MapDashboardPageProcessor_doTravelToLocation).call(instance, credential, coordinate);
    });
}, _MapDashboardPageProcessor_renderRankTitle = function _MapDashboardPageProcessor_renderRankTitle() {
    if (!SetupLoader_1.default.isQiHanTitleEnabled()) {
        return;
    }
    $("td:contains('身份')")
        .filter((idx, td) => $(td).text() === "身份")
        .next()
        .each((idx, th) => {
        let c = $(th).text();
        c = RankTitleLoader_1.default.transformTitle(c);
        $(th).text(c);
    });
}, _MapDashboardPageProcessor_renderExperience = function _MapDashboardPageProcessor_renderExperience() {
    if (!SetupLoader_1.default.isExperienceProgressBarEnabled()) {
        return;
    }
    $("td:contains('经验值')")
        .filter(function () {
        return $(this).text() === "经验值";
    })
        .next()
        .each(function (_idx, th) {
        const expText = $(th).text();
        const experience = parseInt(StringUtils_1.default.substringBefore(expText, " EX"));
        if (experience >= 14900) {
            $(th).css("color", "blue").text("MAX");
        }
        else {
            const level = Math.ceil(experience / 100) + 1;
            const ratio = level / 150;
            const progressBar = PageUtils_1.default.generateProgressBarHTML(ratio);
            $(th).html("<span title='" + expText + "'>" + progressBar + "</span>");
        }
    });
}, _MapDashboardPageProcessor_renderEventBoard = function _MapDashboardPageProcessor_renderEventBoard() {
    $("td:contains('最近发生的事件')")
        .filter(function () {
        return $(this).text() === "最近发生的事件";
    })
        .parent()
        .next()
        .find("td:first")
        .attr("id", "eventBoard");
    const eventHtmlList = [];
    $("#eventBoard").html()
        .split("<br>")
        .filter(it => it.endsWith(")"))
        .map(function (it) {
        // noinspection HtmlDeprecatedTag,XmlDeprecatedElement,HtmlDeprecatedAttribute
        const header = "<font color=\"navy\">●</font>";
        return StringUtils_1.default.substringAfter(it, header);
    })
        .map(function (it) {
        return EventHandler_1.default.handleWithEventHtml(it);
    })
        .forEach(it => eventHtmlList.push(it));
    let html = "";
    html += "<table style='border-width:0;width:100%;height:100%;margin:auto'>";
    html += "<tbody>";
    eventHtmlList.forEach(it => {
        html += "<tr>";
        html += "<th style='color:navy;vertical-align:top'>●</th>";
        html += "<td style='width:100%'>";
        html += it;
        html += "</td>";
        html += "</tr>";
    });
    html += "</tbody>";
    html += "</table>";
    $("#eventBoard").html(html);
}, _MapDashboardPageProcessor_doTravelToLocation = function _MapDashboardPageProcessor_doTravelToLocation(credential, location) {
    MessageBoard_1.default.publishMessage("目的地坐标:<span style='color:greenyellow'>" + location.asText() + "</span>");
    const plan = TravelPlanBuilder_1.default.initializeTravelPlan(PageUtils_1.default.currentPageHtml());
    plan.destination = location;
    plan.credential = credential;
    const executor = new TravelPlanExecutor_1.default(plan);
    executor.execute()
        .then(() => {
        MessageBoard_1.default.publishMessage("旅途愉快,下次再见。");
        $("#refreshButton")
            .prop("disabled", false)
            .text("到达了目的地" + location.asText())
            .on("click", () => {
            $("input:submit[value='更新']").trigger("click");
        });
    });
};
function processTask(credential, roleTask) {
    // 当前有任务
    let html = "";
    html += "<table style='background-color:transparent;margin:auto;width:100%;height:100%'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<td style='text-align:center;font-weight:bold;background-color:navy;color:yellowgreen'>" + roleTask + "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:left;background-color:#D4D4D4' id='walkthrough'></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:left'>坐标点:<span id='roleLocation' style='color:red'>-</span></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:left'>计时器:<span id='countDownTimer' style='color:red'>-</span></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td id='messageBoardContainer'></td>";
    html += "</tr>";
    html += "<tr style='display:none;text-align:center'>";
    html += "<td><button role='button' id='refreshButton' disabled>移动中......</button></td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    $("#travelJournals").html(html);
    MessageBoard_1.default.createMessageBoardStyleC("messageBoardContainer");
    switch (roleTask) {
        case "新手任务":
            doRenderTask1();
            break;
        case "落凤坡":
            doRenderTask2();
            break;
        case "辕门射戟":
            doRenderTask3();
            break;
        case "葵花宝典":
            doRenderTask4();
            break;
        case "五丈原":
            doRenderTask5();
            break;
        case "赤壁之战":
            doRenderTask6();
            break;
        case "走麦城":
            doRenderTask7();
            break;
        case "三顾茅庐":
            doRenderTask8();
            break;
        case "过五关斩六将":
            doRenderTask9();
            break;
        case "七擒孟获":
            doRenderTask10();
            break;
        case "游五岳":
            doRenderTask11();
            break;
        case "五虎将":
            doRenderTask12();
            break;
    }
    doBindLocationButton(credential);
}
function doBindLocationButton(credential) {
    $(".location_button_class")
        .on("mouseenter", function () {
        $(this).css("background-color", "red");
    })
        .on("mouseleave", function () {
        const s = $(this).parent().attr("class");
        const c = StringUtils_1.default.substringAfter(s, "_");
        if (c !== "none") {
            $(this).css("background-color", c);
        }
        else {
            $(this).removeAttr("style");
        }
    });
    $(".location_button_class").on("click", function () {
        const ss = $(this).attr("id").split("_");
        const x = parseInt(ss[1]);
        const y = parseInt(ss[2]);
        const coordinate = new Coordinate_1.default(x, y);
        const confirmation = confirm("确认移动到坐标" + coordinate.asText() + "?");
        if (!confirmation) {
            return;
        }
        $("#mapRow")
            .next().hide()
            .next().hide()
            .next().hide()
            .next().hide();
        $("#refreshButton").parent().parent().show();
        MessageBoard_1.default.resetMessageBoard("实时旅途动态播报:<br>");
        $(".location_button_class")
            .prop("disabled", true)
            .off("mouseenter")
            .off("mouseleave");
        doTravelToLocation(credential, coordinate);
    });
}
function doTravelToLocation(credential, location) {
    MessageBoard_1.default.publishMessage("目的地坐标:<span style='color:greenyellow'>" + location.asText() + "</span>");
    const plan = TravelPlanBuilder_1.default.initializeTravelPlan(PageUtils_1.default.currentPageHtml());
    plan.destination = location;
    plan.credential = credential;
    const executor = new TravelPlanExecutor_1.default(plan);
    executor.execute()
        .then(() => {
        MessageBoard_1.default.publishMessage("旅途愉快,下次再见。");
        $("#refreshButton")
            .prop("disabled", false)
            .text("到达了目的地" + location.asText())
            .on("click", () => {
            $("input:submit[value='更新']").trigger("click");
        });
    });
}
function doRenderTask1() {
    let html = "";
    html += "<li>(7,10)找瓦格纳对话,答题,答完后找他要奖励(每人只能做一次)</li>";
    html += "<li>关于雷姆力亚的问题;你知道个人天真报名时间吗?:除周三外</li>";
    html += "<li>本游戏是否允许注册多ID?:不允许</li>";
    html += "<li>回答完毕返回,然后再次拜访 瓦格纳 选择 索取奖励</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_7_10";
    $("#" + buttonId)
        .attr("value", "瓦")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "瓦格纳")
        .attr("class", "color_yellow");
}
function doRenderTask2() {
    let html = "";
    html += "<li>(6,6)找诸葛亮问落凤坡</li>";
    html += "<li>(7,7)打庞统,打完问庞统搞定</li>";
    html += "<li>(6,6)问诸葛亮完工</li>";
    html += "<li>好处:可以修改人物属性</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_6_6";
    $("#" + buttonId)
        .attr("value", "诸")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "诸葛亮")
        .attr("class", "color_yellow");
    buttonId = "location_7_7";
    $("#" + buttonId)
        .attr("value", "庞")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "庞统")
        .attr("class", "color_yellow");
}
function doRenderTask3() {
    let html = "";
    html += "<li>(8,11)打吕布,可以无限次做这个任务</li>";
    html += "<li>好处:得到饰品超力怪兽球20 5</li>";
    html += "<li>(宠物捕获率*2)但是只能使用100次,不能修,不能卖</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_8_11";
    $("#" + buttonId)
        .attr("value", "吕")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "吕布")
        .attr("class", "color_yellow");
}
function doRenderTask4() {
    let html = "";
    html += "<li>(5,10)找东方不败对话,战斗,搞定</li>";
    html += "<li>好处:[书籍]葵花宝典(变性)</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_5_10";
    $("#" + buttonId)
        .attr("value", "东")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "东方不败")
        .attr("class", "color_yellow");
}
function doRenderTask5() {
    let html = "";
    html += "<li>【剑圣】第一次转剑圣时接到任务</li>";
    html += "<li>(3,11)找司马懿对话,然后战斗,打赢后再对话</li>";
    html += "<li>好处:百宝袋(可以放更多东西)</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_3_11";
    $("#" + buttonId)
        .attr("value", "司")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "司马懿")
        .attr("class", "color_yellow");
}
function doRenderTask6() {
    let html = "";
    html += "<li>【龙战士】第一次转龙战士时接到任务</li>";
    html += "<li>(8,5)找蒋干对话</li>";
    html += "<li>(6,6)找诸葛亮对话</li>";
    html += "<li>(8,5)找黄盖对话</li>";
    html += "<li>(7,7)找庞统对话</li>";
    html += "<li>(6,6)找诸葛亮对话</li>";
    html += "<li>(8,5)找周瑜对话,打赢周瑜</li>";
    html += "<li>(8,5)找曹操对话,打赢曹操</li>";
    html += "<li>(8,5)找曹操对话</li>";
    html += "<li>好处:移动力+2</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_8_5";
    $("#" + buttonId)
        .attr("value", "群")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "群")
        .attr("class", "color_yellow");
    buttonId = "location_6_6";
    $("#" + buttonId)
        .attr("value", "诸")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "诸葛亮")
        .attr("class", "color_yellow");
    buttonId = "location_7_7";
    $("#" + buttonId)
        .attr("value", "庞")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "庞统")
        .attr("class", "color_yellow");
}
function doRenderTask7() {
    let html = "";
    html += "<li>【拳王】第一次转拳王时接到任务</li>";
    html += "<li>(5,5)问关羽</li>";
    html += "<li>(5,5)打吕蒙</li>";
    html += "<li>(5,5)打徐晃</li>";
    html += "<li>好处:移动力+1</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_5_5";
    $("#" + buttonId)
        .attr("value", "群")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "群")
        .attr("class", "color_yellow");
}
function doRenderTask8() {
    let html = "";
    html += "<li>【大魔导师】第一次转大魔导师时接到任务</li>";
    html += "<li>(6,6)找诸葛亮对话,然后战斗,打赢后再对话</li>";
    html += "<li>(6,6)好处:国资金+100w</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_6_6";
    $("#" + buttonId)
        .attr("value", "诸")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "诸葛亮")
        .attr("class", "color_yellow");
}
function doRenderTask9() {
    let html = "";
    html += "<li>【贤者】第一次转贤者时接到任务</li>";
    html += "<li>(7,9)问、杀、问</li>";
    html += "<li>(6,9)问、杀、问</li>";
    html += "<li>(7,10)问、杀、问</li>";
    html += "<li>(8,10)问、杀、问</li>";
    html += "<li>(9,10)问、杀、问</li>";
    html += "<li>好处:黄金笼子(可以存放更多宠物)</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_7_9";
    $("#" + buttonId)
        .attr("value", "孔")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "孔秀")
        .attr("class", "color_yellow");
    buttonId = "location_6_9";
    $("#" + buttonId)
        .attr("value", "群")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "群")
        .attr("class", "color_yellow");
    buttonId = "location_7_10";
    $("#" + buttonId)
        .attr("value", "卞")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "卞喜")
        .attr("class", "color_yellow");
    buttonId = "location_8_10";
    $("#" + buttonId)
        .attr("value", "王")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "王植")
        .attr("class", "color_yellow");
    buttonId = "location_9_10";
    $("#" + buttonId)
        .attr("value", "秦")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "秦琪")
        .attr("class", "color_yellow");
}
function doRenderTask10() {
    let html = "";
    html += "<li>【狙击手】第一次转狙击手时接到任务</li>";
    html += "<li>(0,4)问孟获一次按提示顺序依次打一个,每次打前都要问孟获,打完后问</li>";
    html += "<li>好处:移动力+2</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_0_4";
    $("#" + buttonId)
        .attr("value", "群")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "群")
        .attr("class", "color_yellow");
}
function doRenderTask11() {
    let html = "";
    html += "<li>【吟游诗人】 第一次转吟游诗人时接到任务</li>";
    html += "<li>(9,10)探索</li>";
    html += "<li>(6,9)探索</li>";
    html += "<li>(6,4)探索</li>";
    html += "<li>(7,10)探索</li>";
    html += "<li>(10,6)探索</li>";
    html += "<li>好处:移动力+1</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_9_10";
    $("#" + buttonId)
        .attr("value", "岳")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "岳")
        .attr("class", "color_yellow");
    buttonId = "location_6_9";
    $("#" + buttonId)
        .attr("value", "岳")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "岳")
        .attr("class", "color_yellow");
    buttonId = "location_6_4";
    $("#" + buttonId)
        .attr("value", "岳")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "岳")
        .attr("class", "color_yellow");
    buttonId = "location_7_10";
    $("#" + buttonId)
        .attr("value", "岳")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "岳")
        .attr("class", "color_yellow");
    buttonId = "location_10_6";
    $("#" + buttonId)
        .attr("value", "岳")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "岳")
        .attr("class", "color_yellow");
}
function doRenderTask12() {
    let html = "";
    html += "<li>【天位】第一次转天位时接到任务</li>";
    html += "<li>(5,5)关羽 问打问</li>";
    html += "<li>(7,4)黄忠 问打问</li>";
    html += "<li>(10,7)张飞 问打问</li>";
    html += "<li>(8,11)赵云 问打问</li>";
    html += "<li>(1,14)马超 问打问</li>";
    html += "<li>好处:移动力+1</li>";
    $("#walkthrough").html(html);
    let buttonId = "location_5_5";
    $("#" + buttonId)
        .attr("value", "关")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "关羽")
        .attr("class", "color_yellow");
    buttonId = "location_7_4";
    $("#" + buttonId)
        .attr("value", "黄")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "黄忠")
        .attr("class", "color_yellow");
    buttonId = "location_10_7";
    $("#" + buttonId)
        .attr("value", "张")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "张飞")
        .attr("class", "color_yellow");
    buttonId = "location_8_11";
    $("#" + buttonId)
        .attr("value", "赵")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "赵云")
        .attr("class", "color_yellow");
    buttonId = "location_1_14";
    $("#" + buttonId)
        .attr("value", "马")
        .css("background-color", "yellow")
        .parent()
        .attr("title", "马超")
        .attr("class", "color_yellow");
}
module.exports = MapDashboardPageProcessor;


/***/ }),
/* 124 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const Role_1 = __importDefault(__webpack_require__(50));
class MapDashboardPage {
    static parse(html) {
        const role = new Role_1.default();
        $(html)
            .find("td:contains('HP')")
            .filter((idx, td) => $(td).text() === "HP")
            .closest("table")
            .find("tr:first")
            .find("th:first")
            .each((idx, th) => {
            let s = $(th).text();
            role.name = StringUtils_1.default.substringBefore(s, "(");
        })
            .parent()
            .next()
            .find("td:first")
            .next()
            .each((idx, th) => {
            let s = $(th).text();
            role.parseHealth(s);
        })
            .next()
            .next()
            .each((idx, th) => {
            let s = $(th).text();
            role.parseMana(s);
        })
            .parent()
            .next()
            .find("td:first")
            .next()
            .each((idx, th) => {
            let s = $(th).text();
            s = StringUtils_1.default.substringBefore(s, " Gold");
            role.cash = lodash_1.default.parseInt(s);
        });
        const page = new MapDashboardPage();
        page.role = role;
        return page;
    }
}
module.exports = MapDashboardPage;


/***/ }),
/* 125 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _TaskGuideManager_credential;
const TaskGuide_1 = __importDefault(__webpack_require__(126));
const TaskGuideStorage_1 = __importDefault(__webpack_require__(127));
class TaskGuideManager {
    constructor(credential) {
        _TaskGuideManager_credential.set(this, void 0);
        __classPrivateFieldSet(this, _TaskGuideManager_credential, credential, "f");
    }
    setTask(task) {
        return __awaiter(this, void 0, void 0, function* () {
            const data = new TaskGuide_1.default();
            data.id = __classPrivateFieldGet(this, _TaskGuideManager_credential, "f").id;
            data.task = task;
            yield TaskGuideStorage_1.default.getInstance().insert(data);
        });
    }
    finishTask() {
        return __awaiter(this, void 0, void 0, function* () {
            yield TaskGuideStorage_1.default.getInstance().delete(__classPrivateFieldGet(this, _TaskGuideManager_credential, "f").id);
        });
    }
    currentTask() {
        return __awaiter(this, void 0, void 0, function* () {
            let task = null;
            const data = yield TaskGuideStorage_1.default.getInstance().load(__classPrivateFieldGet(this, _TaskGuideManager_credential, "f").id);
            (data && data.task) && (task = data.task);
            return task;
        });
    }
}
_TaskGuideManager_credential = new WeakMap();
module.exports = TaskGuideManager;


/***/ }),
/* 126 */
/***/ ((module) => {

"use strict";

class TaskGuide {
    asDocument() {
        const document = {};
        // @ts-ignore
        this.id && (document.id = this.id);
        // @ts-ignore
        this.task && (document.task = this.task);
        // @ts-ignore
        (this.createTime !== undefined) && (document.createTime = this.createTime);
        return document;
    }
}
module.exports = TaskGuide;


/***/ }),
/* 127 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const TaskGuide_1 = __importDefault(__webpack_require__(126));
class TaskGuideStorage {
    static getInstance() {
        return instance;
    }
    load(id) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return new Promise((resolve, reject) => {
                const request = db
                    .transaction(["TaskGuide"], "readonly")
                    .objectStore("TaskGuide")
                    .get(id);
                request.onerror = reject;
                request.onsuccess = () => {
                    let data = null;
                    if (request.result) {
                        data = new TaskGuide_1.default();
                        data.id = request.result.id;
                        data.task = request.result.task;
                        data.createTime = request.result.createTime;
                    }
                    resolve(data);
                };
            });
        });
    }
    insert(data) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            const document = data.asDocument();
            // @ts-ignore
            document.createTime = Date.now();
            return new Promise((resolve, reject) => {
                const request = db
                    .transaction(["TaskGuide"], "readwrite")
                    .objectStore("TaskGuide")
                    .add(document);
                request.onerror = reject;
                request.onsuccess = () => resolve();
            });
        });
    }
    delete(id) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return new Promise((resolve, reject) => {
                const request = db
                    .transaction(["TaskGuide"], "readwrite")
                    .objectStore("TaskGuide")
                    .delete(id);
                request.onerror = reject;
                request.onsuccess = () => resolve();
            });
        });
    }
}
const instance = new TaskGuideStorage();
module.exports = TaskGuideStorage;


/***/ }),
/* 128 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _MetroDashboardPageInterceptor_processor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const MetroDashboardPageProcessor_1 = __importDefault(__webpack_require__(129));
class MetroDashboardPageInterceptor {
    constructor() {
        _MetroDashboardPageInterceptor_processor.set(this, new MetroDashboardPageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "map.cgi" || cgi === "status.cgi") {
            return pageText.includes("请选择移动的格数") && pageText.includes("迪斯尼乐园");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .inMetro()
            .then(() => {
            __classPrivateFieldGet(this, _MetroDashboardPageInterceptor_processor, "f").process();
        });
    }
}
_MetroDashboardPageInterceptor_processor = new WeakMap();
module.exports = MetroDashboardPageInterceptor;


/***/ }),
/* 129 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const MetroDashboardPage_1 = __importDefault(__webpack_require__(130));
const EventHandler_1 = __importDefault(__webpack_require__(92));
const MapBuilder_1 = __importDefault(__webpack_require__(99));
const TravelPlan_1 = __importDefault(__webpack_require__(98));
const TravelPlanExecutor_1 = __importDefault(__webpack_require__(103));
const RankTitleLoader_1 = __importDefault(__webpack_require__(93));
const Coordinate_1 = __importDefault(__webpack_require__(5));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class MetroDashboardPageProcessor extends PageProcessorCredentialSupport_1.default {
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            const page = MetroDashboardPage_1.default.parse(PageUtils_1.default.currentPageHtml());
            renderAnnouncement();
            renderMobilization();
            renderRoleStatus();
            renderEventBoard();
            renderMetroMap(credential, page);
        });
    }
}
function renderAnnouncement() {
    // --------------------------------------------------------------------
    // 系统公告
    // --------------------------------------------------------------------
    $("center:first")
        .attr("id", "systemAnnouncement");
    $("#systemAnnouncement")
        .after($("<div id='version' style='color:navy;font-weight:bold;text-align:center;width:100%'></div>"));
    // @ts-ignore
    $("#version").html("Pocketrose Assistant (4.2.15) Build: 2023/7/3 08:41:38");
}
function renderMobilization() {
    // --------------------------------------------------------------------
    // 国家动员指令
    // --------------------------------------------------------------------
    if (SetupLoader_1.default.isQiHanTitleEnabled()) {
        $("table:first")
            .find("> tbody:first")
            .find("> tr:eq(1)")
            .find("> td:first")
            .find("> form:first")
            .find("> font:first")
            .each((idx, font) => {
            let c = $(font).text();
            let b = StringUtils_1.default.substringAfterLast(c, "(");
            let a = StringUtils_1.default.substringBefore(c, "(" + b);
            b = StringUtils_1.default.substringBefore(b, ")");
            const ss = lodash_1.default.split(b, " ");
            const b1 = lodash_1.default.replace(ss[0], "部队", "");
            const b2 = RankTitleLoader_1.default.transformTitle(ss[1]);
            const b3 = ss[2];
            const s = a + "(" + b1 + " " + b2 + " " + b3 + ")";
            $(font).text(s);
        });
    }
}
function renderRoleStatus() {
    // --------------------------------------------------------------------
    // 身份
    // --------------------------------------------------------------------
    if (SetupLoader_1.default.isQiHanTitleEnabled()) {
        $("td:contains('身份')")
            .filter((idx, td) => $(td).text() === "身份")
            .next()
            .each((idx, th) => {
            let c = $(th).text();
            c = RankTitleLoader_1.default.transformTitle(c);
            $(th).text(c);
        });
    }
    // --------------------------------------------------------------------
    // 经验值
    // --------------------------------------------------------------------
    if (SetupLoader_1.default.isExperienceProgressBarEnabled()) {
        $("td:contains('经验值')")
            .filter(function () {
            return $(this).text() === "经验值";
        })
            .next()
            .each(function (_idx, th) {
            const expText = $(th).text();
            const experience = parseInt(StringUtils_1.default.substringBefore(expText, " EX"));
            if (experience >= 14900) {
                $(th).css("color", "blue").text("MAX");
            }
            else {
                const level = Math.ceil(experience / 100) + 1;
                const ratio = level / 150;
                const progressBar = PageUtils_1.default.generateProgressBarHTML(ratio);
                $(th).html("<span title='" + expText + "'>" + progressBar + "</span>");
            }
        });
    }
}
function renderEventBoard() {
    $("td:contains('最近发生的事件')")
        .filter(function () {
        return $(this).text() === "最近发生的事件";
    })
        .parent()
        .next()
        .find("td:first")
        .attr("id", "eventBoard");
    const eventHtmlList = [];
    $("#eventBoard").html()
        .split("<br>")
        .filter(it => it.endsWith(")"))
        .map(function (it) {
        // noinspection HtmlDeprecatedTag,XmlDeprecatedElement,HtmlDeprecatedAttribute
        const header = "<font color=\"navy\">●</font>";
        return StringUtils_1.default.substringAfter(it, header);
    })
        .map(function (it) {
        return EventHandler_1.default.handleWithEventHtml(it);
    })
        .forEach(it => eventHtmlList.push(it));
    let html = "";
    html += "<table style='border-width:0;width:100%;height:100%;margin:auto'>";
    html += "<tbody>";
    eventHtmlList.forEach(it => {
        html += "<tr>";
        html += "<th style='color:navy;vertical-align:top'>●</th>";
        html += "<td style='width:100%'>";
        html += it;
        html += "</td>";
        html += "</tr>";
    });
    html += "</tbody>";
    html += "</table>";
    $("#eventBoard").html(html);
}
function renderMetroMap(credential, page) {
    $("table:first")
        .find("tbody:first")
        .find("> tr:eq(2)")
        .html("" +
        "<td colspan='2' id='mapContainer'>" +
        "<table style='background-color:transparent;margin:auto;width:100%'>" +
        "<tbody>" +
        "<tr>" +
        "<td id='map' style='background-color:#F8F0E0'></td>" +
        "<td id='menu' style='background-color:#EFE0C0;width:100%'></td>" +
        "</tr>" +
        "</tbody>" +
        "</table>" +
        "</td>");
    $("#map").html(MapBuilder_1.default.buildBlankMapTable());
    let buttonId = "location_" + page.coordinate.x + "_" + page.coordinate.y;
    $("#" + buttonId)
        .closest("td")
        .css("background-color", "black")
        .css("color", "yellow")
        .css("text-align", "center")
        .html("你");
    buttonId = "location_8_9";
    $("#" + buttonId)
        .attr("value", "雪")
        .css("background-color", "fuchsia")
        .parent()
        .attr("title", "白雪公主和小矮人")
        .attr("class", "color_fuchsia");
    buttonId = "location_10_10";
    $("#" + buttonId)
        .attr("value", "匹")
        .css("background-color", "fuchsia")
        .parent()
        .attr("title", "匹诺曹")
        .attr("class", "color_fuchsia");
    let html = "";
    html += "<table style='background-color:transparent;margin:auto;width:100%'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<td style='text-align:left' id='walkthrough'></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:left'>坐标点:<span id='roleLocation' style='color:red'>" + page.coordinate.asText() + "</span></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:left'>计时器:<span id='countDownTimer' style='color:red'>-</span></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td id='messageBoardContainer'></td>";
    html += "</tr>";
    html += "<tr style='display:none;text-align:center'>";
    html += "<td><button role='button' id='refreshButton' disabled>移动中......</button></td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    $("#menu").html(html);
    html = "";
    html += "<b style='color:navy'>感谢末末倾情提供的齐心丹攻略</b><br>";
    html += "<li>在(8,9)和白雪公主问话,选择‘齐心丹’</li>";
    html += "<li>去(10,10),选择据点转移</li>";
    html += "<li>重装跟匹诺曹战斗,失败的话吃药补HP和MP,继续跟匹诺曹战斗,直到打赢</li>";
    html += "<li>打赢后跟比诺曹谈话,选择‘抓住你了’</li>";
    html += "<li>点击回到枫丹按钮</li>";
    html += "<li>去客栈住宿补满HP和MP,换好打葫芦娃的7hit装和面具,设置打葫芦娃的血宠</li>";
    html += "<li>回到迪士尼</li>";
    html += "<li>在(8,9)和白雪公主问话,选择‘匹诺曹抓来了’</li>";
    html += "<li>在(8,9)和七个小矮人问话,选择‘把心都交出来炼齐心丹’</li>";
    html += "<li>跟七个小矮人战斗。失败的话,就返回住宿,然后继续从枫丹到迪斯尼乐园,跟七个小矮人战斗,直到打赢</li>";
    html += "<li>打赢后跟小矮人谈话,七心宝石入手</li>";
    $("#walkthrough").html(html);
    MessageBoard_1.default.createMessageBoardStyleC("messageBoardContainer");
    $("#messageBoard")
        .closest("table")
        .css("height", "100%");
    doBindLocationButton(credential, page);
}
function doBindLocationButton(credential, page) {
    $(".location_button_class")
        .on("mouseenter", function () {
        $(this).css("background-color", "red");
    })
        .on("mouseleave", function () {
        const s = $(this).parent().attr("class");
        const c = StringUtils_1.default.substringAfter(s, "_");
        if (c !== "none") {
            $(this).css("background-color", c);
        }
        else {
            $(this).removeAttr("style");
        }
    });
    $(".location_button_class").on("click", function () {
        const ss = $(this).attr("id").split("_");
        const x = parseInt(ss[1]);
        const y = parseInt(ss[2]);
        const coordinate = new Coordinate_1.default(x, y);
        const confirmation = confirm("确认移动到坐标" + coordinate.asText() + "?");
        if (!confirmation) {
            return;
        }
        $("#mapContainer")
            .parent()
            .next().hide()
            .next().hide()
            .next().hide()
            .next().hide();
        $("#refreshButton").parent().parent().show();
        MessageBoard_1.default.resetMessageBoard("实时旅途动态播报:<br>");
        $(".location_button_class")
            .prop("disabled", true)
            .off("mouseenter")
            .off("mouseleave");
        doTravelToLocation(credential, page, coordinate);
    });
}
function doTravelToLocation(credential, page, location) {
    MessageBoard_1.default.publishMessage("目的地坐标:<span style='color:greenyellow'>" + location.asText() + "</span>");
    const plan = new TravelPlan_1.default();
    plan.scope = page.scope;
    plan.mode = page.mode;
    plan.source = page.coordinate;
    plan.destination = location;
    plan.credential = credential;
    const executor = new TravelPlanExecutor_1.default(plan);
    executor.execute()
        .then(() => {
        MessageBoard_1.default.publishMessage("旅途愉快,下次再见。");
        $("#refreshButton")
            .prop("disabled", false)
            .text("到达了目的地" + location.asText())
            .on("click", () => {
            $("input:submit[value='更新']").trigger("click");
        });
    });
}
module.exports = MetroDashboardPageProcessor;


/***/ }),
/* 130 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(__webpack_require__(4));
const Coordinate_1 = __importDefault(__webpack_require__(5));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const Role_1 = __importDefault(__webpack_require__(50));
class MetroDashboardPage {
    static parse(html) {
        const role = new Role_1.default();
        $(html)
            .find("td:contains('HP')")
            .filter((idx, td) => $(td).text() === "HP")
            .closest("table")
            .find("tr:first")
            .find("th:first")
            .each((idx, th) => {
            let s = $(th).text();
            role.name = StringUtils_1.default.substringBefore(s, "(");
        })
            .parent()
            .next()
            .find("td:first")
            .next()
            .each((idx, th) => {
            let s = $(th).text();
            role.parseHealth(s);
        })
            .next()
            .next()
            .each((idx, th) => {
            let s = $(th).text();
            role.parseMana(s);
        })
            .parent()
            .next()
            .find("td:first")
            .next()
            .each((idx, th) => {
            let s = $(th).text();
            s = StringUtils_1.default.substringBefore(s, " Gold");
            role.cash = lodash_1.default.parseInt(s);
        });
        let s = $(html)
            .find("select[name='chara_m']")
            .find("option:last")
            .val();
        const scope = parseInt(s);
        let mode = "ROOK";
        $(html).find("input:submit").each(function (_idx, input) {
            const v = $(input).val();
            const d = $(input).attr("disabled");
            if (v === "↖" && d === undefined) {
                mode = "QUEEN";
            }
        });
        let source = new Coordinate_1.default(-1, -1);
        $(html)
            .find("td")
            .each(function (_idx, td) {
            const text = $(td).text();
            if (text.includes("现在位置(") && text.endsWith(")")) {
                const s = StringUtils_1.default.substringBetween(text, "(", ")");
                const x = StringUtils_1.default.substringBefore(s, ",");
                const y = StringUtils_1.default.substringAfter(s, ",");
                source = new Coordinate_1.default(parseInt(x), parseInt(y));
            }
        });
        const page = new MetroDashboardPage();
        page.role = role;
        page.scope = scope;
        page.mode = mode;
        page.coordinate = source;
        return page;
    }
}
module.exports = MetroDashboardPage;


/***/ }),
/* 131 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _NationInformationPageInterceptor_processor;
const NationalInformationPageProcessor_1 = __importDefault(__webpack_require__(132));
class NationInformationPageInterceptor {
    constructor() {
        _NationInformationPageInterceptor_processor.set(this, new NationalInformationPageProcessor_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "map.cgi") {
            return pageText.includes("各国资料");
        }
        return false;
    }
    intercept() {
        __classPrivateFieldGet(this, _NationInformationPageInterceptor_processor, "f").process();
    }
}
_NationInformationPageInterceptor_processor = new WeakMap();
module.exports = NationInformationPageInterceptor;


/***/ }),
/* 132 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _NationalInformationPageProcessor_instances, _NationalInformationPageProcessor_renderEventBoard;
const EventHandler_1 = __importDefault(__webpack_require__(92));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
class NationalInformationPageProcessor {
    constructor() {
        _NationalInformationPageProcessor_instances.add(this);
    }
    process() {
        PageUtils_1.default.fixCurrentPageBrokenImages();
        PageUtils_1.default.removeUnusedHyperLinks();
        PageUtils_1.default.removeGoogleAnalyticsScript();
        __classPrivateFieldGet(this, _NationalInformationPageProcessor_instances, "m", _NationalInformationPageProcessor_renderEventBoard).call(this);
    }
}
_NationalInformationPageProcessor_instances = new WeakSet(), _NationalInformationPageProcessor_renderEventBoard = function _NationalInformationPageProcessor_renderEventBoard() {
    $("table:eq(3) tr:eq(1) td:first")
        .attr("id", "eventBoard");
    const eventHtmlList = [];
    $("#eventBoard").html()
        .split("<br>")
        .filter(it => it.endsWith(")"))
        .map(function (it) {
        // noinspection HtmlDeprecatedTag,XmlDeprecatedElement,HtmlDeprecatedAttribute
        const header = "<font color=\"green\">●</font>";
        return StringUtils_1.default.substringAfter(it, header);
    })
        .map(function (it) {
        return EventHandler_1.default.handleWithEventHtml(it);
    })
        .forEach(it => eventHtmlList.push(it));
    let html = "";
    html += "<table style='border-width:0;width:100%;height:100%;margin:auto'>";
    html += "<tbody>";
    eventHtmlList.forEach(it => {
        html += "<tr>";
        html += "<th style='color:green;vertical-align:top'>●</th>";
        html += "<td style='width:100%'>";
        html += it;
        html += "</td>";
        html += "</tr>";
    });
    html += "</tbody>";
    html += "</table>";
    $("#eventBoard").html(html);
};
module.exports = NationalInformationPageProcessor;


/***/ }),
/* 133 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalCareerManagementPageInterceptor_inTownProcessor, _PersonalCareerManagementPageInterceptor_inCastleProcessor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const PersonalCareerManagementPageProcessor_Castle_1 = __importDefault(__webpack_require__(134));
const PersonalCareerManagementPageProcessor_Town_1 = __importDefault(__webpack_require__(144));
const PageProcessorContext_1 = __importDefault(__webpack_require__(85));
class PersonalCareerManagementPageInterceptor {
    constructor() {
        _PersonalCareerManagementPageInterceptor_inTownProcessor.set(this, new PersonalCareerManagementPageProcessor_Town_1.default());
        _PersonalCareerManagementPageInterceptor_inCastleProcessor.set(this, new PersonalCareerManagementPageProcessor_Castle_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "mydata.cgi") {
            return pageText.includes("* 转职神殿 *");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .load()
            .then(machine => {
            machine.start()
                .whenInTown(state => {
                const context = new PageProcessorContext_1.default()
                    .withTownId(state === null || state === void 0 ? void 0 : state.townId);
                __classPrivateFieldGet(this, _PersonalCareerManagementPageInterceptor_inTownProcessor, "f").process(context);
            })
                .whenInCastle(state => {
                const context = new PageProcessorContext_1.default()
                    .withCastleName(state === null || state === void 0 ? void 0 : state.castleName);
                __classPrivateFieldGet(this, _PersonalCareerManagementPageInterceptor_inCastleProcessor, "f").process(context);
            })
                .process();
        });
    }
}
_PersonalCareerManagementPageInterceptor_inTownProcessor = new WeakMap(), _PersonalCareerManagementPageInterceptor_inCastleProcessor = new WeakMap();
module.exports = PersonalCareerManagementPageInterceptor;


/***/ }),
/* 134 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const CareerLoader_1 = __importDefault(__webpack_require__(135));
const PersonalCareerManagement_1 = __importDefault(__webpack_require__(136));
const PersonalSpell_1 = __importDefault(__webpack_require__(140));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
const PersonalStatus_1 = __importDefault(__webpack_require__(105));
const CommentBoard_1 = __importDefault(__webpack_require__(54));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const PersonalCareerManagementPageProcessor_1 = __importDefault(__webpack_require__(143));
class PersonalCareerManagementPageProcessor_Castle extends PersonalCareerManagementPageProcessor_1.default {
    doProcessPageParsed(credential, page, context) {
        const candidateList = page.careerList;
        doProcess(credential, candidateList);
    }
}
function doProcess(credential, candidateList) {
    $("table:first td:first").removeAttr("bgcolor");
    $("table:first td:first").removeAttr("height");
    $("table:first td:first").css("text-align", "center");
    $("table:first td:first").css("font-size", "150%");
    $("table:first td:first").css("font-weight", "bold");
    $("table:first td:first").css("background-color", "navy");
    $("table:first td:first").css("color", "greenyellow");
    $("table:first td:first").text("<<  职 业 管 理  >>");
    $("table:first tr:first").next().find("table:first td:first")
        .next().next().next().attr("id", "roleStatus");
    $("img[alt='神官']").parent().prev().attr("id", "messageBoard");
    $("img[alt='神官']").parent().prev().css("color", "white");
    $("table:first").removeAttr("height");
    $("table:first tr:first")
        .next().next().next()
        .html("<td style='background-color:#F8F0E0'>" +
        "<div id='CareerUI'></div><div id='Eden' style='display:none'></div>" +
        "</td>");
    $("#Eden").html("" +
        "<form action='' method='post' id='edenForm'>" +
        "        <input type='hidden' name='id' value='" + credential.id + "'>" +
        "        <input type='hidden' name='pass' value='" + credential.pass + "'>" +
        "        <div id='edenFormPayload' style='display:none'></div>" +
        "        <input type='submit' id='edenSubmit'>" +
        "</form>");
    $("table:first tr:first")
        .next().next().next()
        .after($("<tr><td style='background-color:#F8F0E0;text-align:center'>" +
        "<input type='button' value='返回城堡' id='returnButton'>" +
        "<input type='button' value='装备管理' id='itemManagementButton'>" +
        "</td></tr>"));
    $("#returnButton").on("click", function () {
        $("#edenForm").attr("action", "castlestatus.cgi");
        $("#edenFormPayload").html("<input type='hidden' name='mode' value='CASTLESTATUS'>");
        $("#edenSubmit").trigger("click");
    });
    $("#itemManagementButton").on("click", function () {
        $("#edenForm").attr("action", "mydata.cgi");
        $("#edenFormPayload").html("<input type='hidden' name='mode' value='USE_ITEM'>");
        $("#edenSubmit").trigger("click");
    });
    const imageHtml = NpcLoader_1.default.getNpcImageHtml("白皇");
    CommentBoard_1.default.createCommentBoard(imageHtml);
    CommentBoard_1.default.writeMessage("是的,你没有看错,换人了,某幕后黑手不愿意出镜。不过请放心,转职方面我是专业的,毕竟我一直制霸钉耙榜。<br>");
    CommentBoard_1.default.writeMessage("蓝色的职业代表你已经掌握了。我会把为你推荐的职业红色加深标识出来,当然,前提是如果有能推荐的。<br>");
    doRender(credential, candidateList);
}
function doRender(credential, candidateList) {
    let html = "";
    html += "<table style='background-color:#888888;width:100%;text-align:center'>";
    html += "<tbody style='background-color:#F8F0E0'>";
    html += "<tr>";
    html += "<td id='spellCell'>";
    html += "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td id='careerCell'>";
    html += "</td>";
    html += "</tr>";
    html += "</toby>";
    html += "</table>";
    $("#CareerUI").html(html);
    new PersonalStatus_1.default(credential).load().then(role => {
        if (role.task !== "没有任务!") {
            MessageBoard_1.default.publishMessage("当前任务:<b style='color:yellow;font-size:150%'>" + role.task + "</b>");
        }
        doRenderRoleStatus(role);
        if (role.level > 50) {
            doRenderCareer(credential, role, candidateList);
            doBindCareerButton(credential);
        }
        new PersonalSpell_1.default(credential).open().then(spellPage => {
            const spellList = spellPage.spellList;
            doRenderSpell(credential, role, spellList);
            doBindSpellButton(credential, spellList);
        });
    });
}
function doRenderRoleStatus(role) {
    let html = "";
    html += "<table style='background-color:#888888;border-width:0'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>姓名</th>";
    html += "<th style='background-color:#E0D0B0'>LV</th>";
    html += "<th style='background-color:#EFE0C0'>HP</th>";
    html += "<th style='background-color:#E8E8D0'>MP</th>";
    html += "<th style='background-color:#EFE0C0'>攻击</th>";
    html += "<th style='background-color:#EFE0C0'>防御</th>";
    html += "<th style='background-color:#EFE0C0'>智力</th>";
    html += "<th style='background-color:#EFE0C0'>精神</th>";
    html += "<th style='background-color:#EFE0C0'>速度</th>";
    html += "<th style='background-color:#E0D0B0'>属性</th>";
    html += "<th style='background-color:#E8E8D0'>职业</th>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='background-color:#E8E8D0'>" + role.name + "</td>";
    html += "<td style='background-color:#E0D0B0'>" + role.level + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.health + "/" + role.maxHealth + "</td>";
    html += "<td style='background-color:#E8E8D0'>" + role.mana + "/" + role.maxMana + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.attack + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.defense + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.specialAttack + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.specialDefense + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.speed + "</td>";
    html += "<td style='background-color:#E0D0B0'>" + role.attribute + "</td>";
    html += "<td style='background-color:#E8E8D0'>" + role.career + "</td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    $("#roleStatus").html(html);
}
function doRenderCareer(credential, role, careerCandidateList) {
    let html = "";
    html += "<table style='background-color:#888888;width:100%;text-align:center'>";
    html += "<tbody style='background-color:#F8F0E0'>";
    html += "<tr>";
    html += "<th colspan='7' style='background-color:#E8E8D0;color:navy;text-align:center;font-weight:bold;font-size:120%'><< 选 择 新 的 职 业 >></th>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>战士系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_0' value='兵士'>" +
        "<input type='button' class='CareerUIButton' id='career_1' value='武士'>" +
        "<input type='button' class='CareerUIButton' id='career_2' value='剑客'>" +
        "<input type='button' class='CareerUIButton' id='career_3' value='剑侠'>" +
        "<input type='button' class='CareerUIButton' id='career_4' value='魔法剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_5' value='暗黑剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_6' value='奥法剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_7' value='魔导剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_8' value='神圣剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_9' value='圣殿武士'>" +
        "<input type='button' class='CareerUIButton' id='career_10' value='剑圣'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>枪系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_11' value='枪战士'>" +
        "<input type='button' class='CareerUIButton' id='career_12' value='重战士'>" +
        "<input type='button' class='CareerUIButton' id='career_13' value='狂战士'>" +
        "<input type='button' class='CareerUIButton' id='career_14' value='龙战士'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>格斗系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_15' value='武僧'>" +
        "<input type='button' class='CareerUIButton' id='career_16' value='决斗家'>" +
        "<input type='button' class='CareerUIButton' id='career_17' value='拳王'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>魔术系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_18' value='术士'>" +
        "<input type='button' class='CareerUIButton' id='career_19' value='魔法师'>" +
        "<input type='button' class='CareerUIButton' id='career_20' value='咒灵师'>" +
        "<input type='button' class='CareerUIButton' id='career_21' value='大魔导士'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>祭司系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_22' value='牧师'>" +
        "<input type='button' class='CareerUIButton' id='career_23' value='德鲁伊'>" +
        "<input type='button' class='CareerUIButton' id='career_24' value='贤者'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>弓矢系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_25' value='弓箭士'>" +
        "<input type='button' class='CareerUIButton' id='career_26' value='魔弓手'>" +
        "<input type='button' class='CareerUIButton' id='career_27' value='狙击手'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>游侠系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_28' value='游侠'>" +
        "<input type='button' class='CareerUIButton' id='career_29' value='巡林客'>" +
        "<input type='button' class='CareerUIButton' id='career_30' value='吟游诗人'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>天位系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_31' value='小天位'>" +
        "<input type='button' class='CareerUIButton' id='career_32' value='强天位'>" +
        "<input type='button' class='CareerUIButton' id='career_33' value='斋天位'>" +
        "<input type='button' class='CareerUIButton' id='career_34' value='太天位'>" +
        "<input type='button' class='CareerUIButton' id='career_35' value='终极'>" +
        "</td>";
    html += "</tr>";
    html += "</toby>";
    html += "</table>";
    $("#careerCell").html(html);
    // 已经掌握的职业用蓝色标记
    // 没有掌握的职业用红色标记(满级的情况下)
    // 不在转职列表中的按钮删除
    // 当前职业绿色显示
    if (role.masterCareerList.includes("小天位")) {
        $("#career_32").css("color", "blue");
        $("#career_33").css("color", "blue");
        $("#career_34").css("color", "blue");
        $("#career_35").css("color", "blue");
    }
    const careerNames = Object.keys(CareerLoader_1.default.loadCareers());
    for (let i = 0; i < careerNames.length; i++) {
        const careerName = careerNames[i];
        // @ts-ignore
        const careerId = CareerLoader_1.default.loadCareers()[careerName]["id"];
        const buttonId = "career_" + careerId;
        if (role.masterCareerList.includes(careerName)) {
            $("#" + buttonId).css("color", "blue");
        }
        else {
            if (role.level >= 150) {
                if (careerName === role.career) {
                    $("#" + buttonId).css("color", "green");
                    $("#" + buttonId).css("font-weight", "bold");
                }
                else {
                    $("#" + buttonId).css("color", "red");
                    $("#" + buttonId).css("font-weight", "bold");
                }
            }
        }
        if (!careerCandidateList.includes(careerName)) {
            $("#" + buttonId).prop("disabled", true);
            $("#" + buttonId).css("color", "grey");
            $("#" + buttonId).css("font-weight", "normal");
        }
    }
    // 推荐计算
    const recommendations = doCalculateRecommendationCareers(role, careerCandidateList);
    if (recommendations.length > 0) {
        for (const recommendation of recommendations) {
            // @ts-ignore
            const careerId = CareerLoader_1.default.loadCareers()[recommendation]["id"];
            const buttonId = "career_" + careerId;
            if (recommendation === role.career) {
                $("#" + buttonId).css("color", "green");
                $("#" + buttonId).css("font-weight", "bold");
            }
            else {
                $("#" + buttonId).css("color", "red");
                $("#" + buttonId).css("font-weight", "bold");
            }
        }
    }
    if (SetupLoader_1.default.isCareerTransferEntranceDisabled(credential.id)) {
        // 转职入口被关闭了,那就禁止所有的转职按钮。
        for (let i = 0; i < careerNames.length; i++) {
            const careerName = careerNames[i];
            // @ts-ignore
            const careerId = CareerLoader_1.default.loadCareers()[careerName]["id"];
            const buttonId = "career_" + careerId;
            $("#" + buttonId).prop("disabled", true);
            $("#" + buttonId).css("color", "grey");
            $("#" + buttonId).css("font-weight", "normal");
        }
    }
}
function doRenderSpell(credential, role, spellList) {
    let html = "";
    html += "<table style='background-color:#888888;width:100%;text-align:center'>";
    html += "<tbody style='background-color:#F8F0E0'>";
    html += "<tr>";
    html += "<th colspan='7' style='background-color:#E8E8D0;color:navy;text-align:center;font-weight:bold;font-size:120%'><< 设 置 技 能 >></th>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>使用</th>";
    html += "<th style='background-color:#EFE0C0'>技能</th>";
    html += "<th style='background-color:#E0D0B0'>威力</th>";
    html += "<th style='background-color:#EFE0C0'>确率</th>";
    html += "<th style='background-color:#E0D0B0'>PP</th>";
    html += "<th style='background-color:#EFE0C0'>评分</th>";
    html += "<th style='background-color:#E0D0B0'>设置</th>";
    html += "</tr>";
    for (const spell of spellList) {
        const using = spell.name === role.spell;
        html += "<tr>";
        html += "<td style='background-color:#E8E8D0'>" + (using ? "★" : "") + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + spell.name + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + spell.power + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + spell.accuracy + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + spell.pp + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + spell.score + "</td>";
        html += "<td style='background-color:#E0D0B0'>" +
            "<input type='button' class='CareerUIButton' id='set_spell_" + spell.id + "' value='选择'>" +
            "</td>";
        html += "</tr>";
    }
    html += "</toby>";
    html += "</table>";
    $("#spellCell").html(html);
    for (const spell of spellList) {
        const using = spell.name === role.spell;
        if (using) {
            const buttonId = "set_spell_" + spell.id;
            $("#" + buttonId).prop("disabled", true);
        }
    }
}
function doRefresh(credential) {
    new PersonalCareerManagement_1.default(credential).open().then(page => {
        const careerCandidateList = page.careerList;
        $(".CareerUIButton").off("click");
        $("#CareerUI").html("");
        doRender(credential, careerCandidateList);
    });
}
function doBindCareerButton(credential) {
    const careerNames = Object.keys(CareerLoader_1.default.loadCareers());
    for (let i = 0; i < careerNames.length; i++) {
        const careerName = careerNames[i];
        // @ts-ignore
        const careerId = CareerLoader_1.default.loadCareers()[careerName]["id"];
        const buttonId = "career_" + careerId;
        if ($("#" + buttonId).length > 0 && !$("#" + buttonId).prop("disabled")) {
            $("#" + buttonId).on("click", function () {
                const careerId = parseInt($(this).attr("id").split("_")[1]);
                const careerName = CareerLoader_1.default.findCareerById(careerId);
                if (!confirm("请确认要转职到" + careerName + "?")) {
                    return;
                }
                new PersonalCareerManagement_1.default(credential)
                    .transfer(careerId)
                    .then(() => {
                    doRefresh(credential);
                });
            });
        }
    }
}
function doBindSpellButton(credential, spellList) {
    for (const spell of spellList) {
        const buttonId = "set_spell_" + spell.id;
        if ($("#" + buttonId).length > 0 && !$("#" + buttonId).prop("disabled")) {
            $("#" + buttonId).on("click", function () {
                const spellId = $(this).attr("id").split("_")[2];
                const request = credential.asRequest();
                // @ts-ignore
                request["mode"] = "MAGIC_SET";
                // @ts-ignore
                request["ktec_no"] = spellId;
                NetworkUtils_1.default.sendPostRequest("mydata.cgi", request, function (html) {
                    MessageBoard_1.default.processResponseMessage(html);
                    doRefresh(credential);
                });
            });
        }
    }
}
function doCalculateRecommendationCareers(role, careerCandidateList) {
    // 没有满级,不推荐
    if (role.level < 150) {
        return [];
    }
    // 没有掌握全部职业,不推荐
    if (role.masterCareerList.length !== 32) {
        return [];
    }
    const recommendations = [];
    const targetCareerNames = Object.keys(CareerLoader_1.default.loadCareerTransferRequirements());
    for (let i = 0; i < targetCareerNames.length; i++) {
        const name = targetCareerNames[i];
        // @ts-ignore
        const requirement = CareerLoader_1.default.loadCareerTransferRequirements()[name];
        if (role.maxMana >= requirement[0] &&
            role.attack >= requirement[1] &&
            role.defense >= requirement[2] &&
            role.specialAttack >= requirement[3] &&
            role.specialDefense >= requirement[4] &&
            role.speed >= requirement[5]) {
            // 发现了可以推荐的职业
            recommendations.push(name);
        }
    }
    if (recommendations.length === 0) {
        // 没有推荐出来,那么就推荐转职列表中的最后一个吧
        recommendations.push(careerCandidateList[careerCandidateList.length - 1]);
    }
    return recommendations;
}
module.exports = PersonalCareerManagementPageProcessor_Castle;


/***/ }),
/* 135 */
/***/ ((module) => {

"use strict";

class CareerLoader {
    static findCareerById(id) {
        const careerNames = Object.keys(CAREERS);
        for (let i = 0; i < careerNames.length; i++) {
            const careerName = careerNames[i];
            // @ts-ignore
            if (CAREERS[careerName]["id"] === id) {
                return careerName;
            }
        }
        return null;
    }
    static loadCareers() {
        return CAREERS;
    }
    static loadCareerTransferRequirements() {
        return CAREER_TRANSFER_REQUIREMENTS;
    }
}
const CAREERS = {
    "兵士": { "id": 0 },
    "武士": { "id": 1 },
    "剑客": { "id": 2 },
    "剑侠": { "id": 3 },
    "魔法剑士": { "id": 4 },
    "暗黑剑士": { "id": 5 },
    "奥法剑士": { "id": 6 },
    "魔导剑士": { "id": 7 },
    "神圣剑士": { "id": 8 },
    "圣殿武士": { "id": 9 },
    "剑圣": { "id": 10 },
    "枪战士": { "id": 11 },
    "重战士": { "id": 12 },
    "狂战士": { "id": 13 },
    "龙战士": { "id": 14 },
    "武僧": { "id": 15 },
    "决斗家": { "id": 16 },
    "拳王": { "id": 17 },
    "术士": { "id": 18 },
    "魔法师": { "id": 19 },
    "咒灵师": { "id": 20 },
    "大魔导士": { "id": 21 },
    "牧师": { "id": 22 },
    "德鲁伊": { "id": 23 },
    "贤者": { "id": 24 },
    "弓箭士": { "id": 25 },
    "魔弓手": { "id": 26 },
    "狙击手": { "id": 27 },
    "游侠": { "id": 28 },
    "巡林客": { "id": 29 },
    "吟游诗人": { "id": 30 },
    "小天位": { "id": 31 },
    "强天位": { "id": 32 },
    "斋天位": { "id": 33 },
    "太天位": { "id": 34 },
    "终极": { "id": 35 }
};
const CAREER_TRANSFER_REQUIREMENTS = {
    '圣殿武士': [900, 225, 225, 325, 225, 275],
    '剑圣': [900, 225, 275, 225, 275, 225],
    '龙战士': [900, 225, 225, 325, 325, 225],
    '拳王': [900, 225, 225, 325, 225, 275],
    '咒灵师': [900, 325, 275, 225, 225, 325],
    '大魔导士': [900, 275, 275, 225, 225, 275],
    '贤者': [900, 275, 225, 225, 275, 325],
    '狙击手': [900, 225, 325, 325, 225, 225],
    '吟游诗人': [900, 225, 325, 225, 325, 225]
};
module.exports = CareerLoader;


/***/ }),
/* 136 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalCareerManagement_instances, _PersonalCareerManagement_credential, _PersonalCareerManagement_townId, _PersonalCareerManagement_postTransfer;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PersonalStatus_1 = __importDefault(__webpack_require__(105));
const Role_1 = __importDefault(__webpack_require__(50));
const CareerChangeLog_1 = __importDefault(__webpack_require__(137));
const CareerChangeLogStorage_1 = __importDefault(__webpack_require__(138));
const PersonalCareerManagementPage_1 = __importDefault(__webpack_require__(139));
class PersonalCareerManagement {
    constructor(credential, townId) {
        _PersonalCareerManagement_instances.add(this);
        _PersonalCareerManagement_credential.set(this, void 0);
        _PersonalCareerManagement_townId.set(this, void 0);
        __classPrivateFieldSet(this, _PersonalCareerManagement_credential, credential, "f");
        __classPrivateFieldSet(this, _PersonalCareerManagement_townId, townId, "f");
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _PersonalCareerManagement_credential, "f").asRequestMap();
                    if (__classPrivateFieldGet(this, _PersonalCareerManagement_townId, "f") !== undefined) {
                        request.set("town", __classPrivateFieldGet(this, _PersonalCareerManagement_townId, "f"));
                    }
                    request.set("mode", "CHANGE_OCCUPATION");
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        const page = PersonalCareerManagement.parsePage(html);
                        resolve(page);
                    });
                });
            })();
        });
    }
    transfer(careerId) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    new PersonalStatus_1.default(__classPrivateFieldGet(this, _PersonalCareerManagement_credential, "f"), __classPrivateFieldGet(this, _PersonalCareerManagement_townId, "f"))
                        .load()
                        .then(before => {
                        const request = __classPrivateFieldGet(this, _PersonalCareerManagement_credential, "f").asRequestMap();
                        request.set("chara", "1");
                        request.set("mode", "JOB_CHANGE");
                        request.set("syoku_no", careerId.toString());
                        NetworkUtils_1.default.post("mydata.cgi", request)
                            .then(html => {
                            MessageBoard_1.default.processResponseMessage(html);
                            new PersonalStatus_1.default(__classPrivateFieldGet(this, _PersonalCareerManagement_credential, "f"), __classPrivateFieldGet(this, _PersonalCareerManagement_townId, "f"))
                                .load()
                                .then(after => {
                                __classPrivateFieldGet(this, _PersonalCareerManagement_instances, "m", _PersonalCareerManagement_postTransfer).call(this, before, after, () => resolve());
                            });
                        });
                    });
                });
            })();
        });
    }
    static parsePage(html) {
        const role = new Role_1.default();
        $(html).find("input:radio:first")
            .parent()
            .next() // name
            .each((idx, td) => {
            role.name = $(td).text();
        })
            .next() // level
            .each((idx, td) => {
            role.level = parseInt($(td).text());
        })
            .next() // health
            .each((idx, td) => {
            role.parseHealth($(td).text());
        })
            .next() // mana
            .each((idx, td) => {
            role.parseMana($(td).text());
        })
            .next() // attribute
            .each((idx, td) => {
            role.attribute = $(td).text();
        })
            .next() // career
            .each((idx, td) => {
            role.career = $(td).text();
        })
            .parent()
            .find("td:first")
            .next() // cash
            .each((idx, td) => {
            let s = $(td).text();
            s = StringUtils_1.default.substringBefore(s, " GOLD");
            role.cash = parseInt(s);
        });
        const careerCandidateList = [];
        $(html)
            .find("select[name='syoku_no']")
            .find("option")
            .each(function (_idx, option) {
            const value = $(option).val();
            if (value !== "") {
                const career = $(option).text().trim();
                careerCandidateList.push(career);
            }
        });
        const page = new PersonalCareerManagementPage_1.default();
        page.role = role;
        page.careerList = careerCandidateList;
        return page;
    }
}
_PersonalCareerManagement_credential = new WeakMap(), _PersonalCareerManagement_townId = new WeakMap(), _PersonalCareerManagement_instances = new WeakSet(), _PersonalCareerManagement_postTransfer = function _PersonalCareerManagement_postTransfer(before, after, handler) {
    if (before.level !== after.level && after.level === 1) {
        // 成功完成了转职操作
        const data = new CareerChangeLog_1.default();
        data.roleId = __classPrivateFieldGet(this, _PersonalCareerManagement_credential, "f").id;
        data.career_1 = before.career;
        data.level_1 = before.level;
        data.health_1 = before.maxHealth;
        data.mana_1 = before.maxMana;
        data.attack_1 = before.attack;
        data.defense_1 = before.defense;
        data.specialAttack_1 = before.specialAttack;
        data.specialDefense_1 = before.specialDefense;
        data.speed_1 = before.speed;
        data.career_2 = after.career;
        data.level_2 = after.level;
        data.health_2 = after.maxHealth;
        data.mana_2 = after.maxMana;
        data.attack_2 = after.attack;
        data.defense_2 = after.defense;
        data.specialAttack_2 = after.specialAttack;
        data.specialDefense_2 = after.specialDefense;
        data.speed_2 = after.speed;
        // 保存转职的记录
        CareerChangeLogStorage_1.default.getInstance().insert(data).then(() => handler());
    }
    else {
        // 没有转职,大概率是由于需要转职任务引发的
        handler();
    }
};
module.exports = PersonalCareerManagement;


/***/ }),
/* 137 */
/***/ (function(module) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _CareerChangeLog_instances, _CareerChangeLog_formatRatio;
class CareerChangeLog {
    constructor() {
        _CareerChangeLog_instances.add(this);
    }
    asDocument() {
        const document = {};
        // @ts-ignore
        this.id && (document.id = this.id);
        // @ts-ignore
        this.roleId && (document.roleId = this.roleId);
        // @ts-ignore
        (this.createTime !== undefined) && (document.createTime = this.createTime);
        // @ts-ignore
        this.career_1 && (document.career_1 = this.career_1);
        // @ts-ignore
        (this.level_1 !== undefined) && (document.level_1 = this.level_1);
        // @ts-ignore
        (this.health_1 !== undefined) && (document.health_1 = this.health_1);
        // @ts-ignore
        (this.mana_1 !== undefined) && (document.mana_1 = this.mana_1);
        // @ts-ignore
        (this.attack_1 !== undefined) && (document.attack_1 = this.attack_1);
        // @ts-ignore
        (this.defense_1 !== undefined) && (document.defense_1 = this.defense_1);
        // @ts-ignore
        (this.specialAttack_1 !== undefined) && (document.specialAttack_1 = this.specialAttack_1);
        // @ts-ignore
        (this.specialDefense_1 !== undefined) && (document.specialDefense_1 = this.specialDefense_1);
        // @ts-ignore
        (this.speed_1 !== undefined) && (document.speed_1 = this.speed_1);
        // @ts-ignore
        this.career_2 && (document.career_2 = this.career_2);
        // @ts-ignore
        (this.level_2 !== undefined) && (document.level_2 = this.level_2);
        // @ts-ignore
        (this.health_2 !== undefined) && (document.health_2 = this.health_2);
        // @ts-ignore
        (this.mana_2 !== undefined) && (document.mana_2 = this.mana_2);
        // @ts-ignore
        (this.attack_2 !== undefined) && (document.attack_2 = this.attack_2);
        // @ts-ignore
        (this.defense_2 !== undefined) && (document.defense_2 = this.defense_2);
        // @ts-ignore
        (this.specialAttack_2 !== undefined) && (document.specialAttack_2 = this.specialAttack_2);
        // @ts-ignore
        (this.specialDefense_2 !== undefined) && (document.specialDefense_2 = this.specialDefense_2);
        // @ts-ignore
        (this.speed_2 !== undefined) && (document.speed_2 = this.speed_2);
        return document;
    }
    get healthInherit() {
        const ratio = this.health_2 / this.health_1;
        return __classPrivateFieldGet(this, _CareerChangeLog_instances, "m", _CareerChangeLog_formatRatio).call(this, ratio);
    }
    get manaInherit() {
        const ratio = this.mana_2 / this.mana_1;
        return __classPrivateFieldGet(this, _CareerChangeLog_instances, "m", _CareerChangeLog_formatRatio).call(this, ratio);
    }
    get attackInherit() {
        const ratio = this.attack_2 / this.attack_1;
        return __classPrivateFieldGet(this, _CareerChangeLog_instances, "m", _CareerChangeLog_formatRatio).call(this, ratio);
    }
    get defenseInherit() {
        const ratio = this.defense_2 / this.defense_1;
        return __classPrivateFieldGet(this, _CareerChangeLog_instances, "m", _CareerChangeLog_formatRatio).call(this, ratio);
    }
    get specialAttackInherit() {
        const ratio = this.specialAttack_2 / this.specialAttack_1;
        return __classPrivateFieldGet(this, _CareerChangeLog_instances, "m", _CareerChangeLog_formatRatio).call(this, ratio);
    }
    get specialDefenseInherit() {
        const ratio = this.specialDefense_2 / this.specialDefense_1;
        return __classPrivateFieldGet(this, _CareerChangeLog_instances, "m", _CareerChangeLog_formatRatio).call(this, ratio);
    }
    get speedInherit() {
        const ratio = this.speed_2 / this.speed_1;
        return __classPrivateFieldGet(this, _CareerChangeLog_instances, "m", _CareerChangeLog_formatRatio).call(this, ratio);
    }
}
_CareerChangeLog_instances = new WeakSet(), _CareerChangeLog_formatRatio = function _CareerChangeLog_formatRatio(ratio) {
    const r = Math.max(0, Math.min(ratio, 1));
    let color;
    if (r < 0.6) {
        color = "red";
    }
    else if (r < 0.8) {
        color = "green";
    }
    else {
        color = "blue";
    }
    return "<span style='color:" + color + "'>" + r.toFixed(2) + "</span>";
};
module.exports = CareerChangeLog;


/***/ }),
/* 138 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const bson_objectid_1 = __importDefault(__webpack_require__(26));
const lodash_1 = __importDefault(__webpack_require__(4));
const PocketDatabase_1 = __importDefault(__webpack_require__(10));
const CareerChangeLog_1 = __importDefault(__webpack_require__(137));
class CareerChangeLogStorage {
    static getInstance() {
        return instance;
    }
    insert(data) {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            const document = data.asDocument();
            // @ts-ignore
            document.id = (0, bson_objectid_1.default)().toHexString();
            // @ts-ignore
            document.createTime = Date.now();
            return new Promise((resolve, reject) => {
                const request = db
                    .transaction(["CareerChangeLog"], "readwrite")
                    .objectStore("CareerChangeLog")
                    .add(document);
                request.onerror = reject;
                request.onsuccess = () => resolve();
            });
        });
    }
    loads() {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return new Promise((resolve, reject) => {
                const request = db
                    .transaction(["CareerChangeLog"], "readonly")
                    .objectStore("CareerChangeLog")
                    .getAll();
                request.onerror = reject;
                request.onsuccess = () => {
                    const dataList = [];
                    if (request.result) {
                        for (const it of request.result) {
                            const data = new CareerChangeLog_1.default();
                            data.id = it.id;
                            data.roleId = it.roleId;
                            data.createTime = it.createTime;
                            data.career_1 = it.career_1;
                            data.level_1 = it.level_1;
                            data.health_1 = it.health_1;
                            data.mana_1 = it.mana_1;
                            data.attack_1 = it.attack_1;
                            data.defense_1 = it.defense_1;
                            data.specialAttack_1 = it.specialAttack_1;
                            data.specialDefense_1 = it.specialDefense_1;
                            data.speed_1 = it.speed_1;
                            data.career_2 = it.career_2;
                            data.level_2 = it.level_2;
                            data.health_2 = it.health_2;
                            data.mana_2 = it.mana_2;
                            data.attack_2 = it.attack_2;
                            data.defense_2 = it.defense_2;
                            data.specialAttack_2 = it.specialAttack_2;
                            data.specialDefense_2 = it.specialDefense_2;
                            data.speed_2 = it.speed_2;
                            dataList.push(data);
                        }
                    }
                    resolve(dataList);
                };
            });
        });
    }
    clear() {
        return __awaiter(this, void 0, void 0, function* () {
            const db = yield PocketDatabase_1.default.connectDatabase();
            return new Promise((resolve, reject) => {
                const request = db
                    .transaction(["CareerChangeLog"], "readwrite")
                    .objectStore("CareerChangeLog")
                    .clear();
                request.onerror = reject;
                request.onsuccess = () => resolve();
            });
        });
    }
    importFromJson(json) {
        return __awaiter(this, void 0, void 0, function* () {
            const documentList = JSON.parse(json);
            $("#careerChangeCount").html(documentList.length);
            if (documentList.length === 0)
                return;
            for (const document of documentList) {
                yield this.importDocument(document);
            }
        });
    }
    importDocument(document) {
        return __awaiter(this, void 0, void 0, function* () {
            // @ts-ignore
            const id = document.id;
            const db = yield PocketDatabase_1.default.connectDatabase();
            return new Promise((resolve, reject) => {
                const readRequest = db
                    .transaction(["CareerChangeLog"], "readwrite")
                    .objectStore("CareerChangeLog")
                    .get(id);
                readRequest.onerror = reject;
                readRequest.onsuccess = () => {
                    if (readRequest.result) {
                        let c = lodash_1.default.parseInt($("#duplicatedCareerChangeCount").text());
                        c++;
                        $("#duplicatedCareerChangeCount").text(c);
                        resolve();
                    }
                    else {
                        const writeRequest = db
                            .transaction(["CareerChangeLog"], "readwrite")
                            .objectStore("CareerChangeLog")
                            .add(document);
                        writeRequest.onerror = reject;
                        writeRequest.onsuccess = () => {
                            let c = lodash_1.default.parseInt($("#importedCareerChangeCount").text());
                            c++;
                            $("#importedCareerChangeCount").text(c);
                            resolve();
                        };
                    }
                };
            });
        });
    }
}
const instance = new CareerChangeLogStorage();
module.exports = CareerChangeLogStorage;


/***/ }),
/* 139 */
/***/ ((module) => {

"use strict";

class PersonalCareerManagementPage {
}
module.exports = PersonalCareerManagementPage;


/***/ }),
/* 140 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalSpell_credential, _PersonalSpell_townId;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PersonalSpellPage_1 = __importDefault(__webpack_require__(141));
const Spell_1 = __importDefault(__webpack_require__(142));
class PersonalSpell {
    constructor(credential, townId) {
        _PersonalSpell_credential.set(this, void 0);
        _PersonalSpell_townId.set(this, void 0);
        __classPrivateFieldSet(this, _PersonalSpell_credential, credential, "f");
        __classPrivateFieldSet(this, _PersonalSpell_townId, townId, "f");
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _PersonalSpell_credential, "f").asRequestMap();
                    if (__classPrivateFieldGet(this, _PersonalSpell_townId, "f") !== undefined) {
                        request.set("town", __classPrivateFieldGet(this, _PersonalSpell_townId, "f"));
                    }
                    request.set("mode", "MAGIC");
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        const page = PersonalSpell.parsePage(html);
                        resolve(page);
                    });
                });
            })();
        });
    }
    set(spellId) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _PersonalSpell_credential, "f").asRequestMap();
                    request.set("ktec_no", spellId);
                    request.set("mode", "MAGIC_SET");
                    NetworkUtils_1.default.post("mydata.cgi", request).then(html => {
                        MessageBoard_1.default.processResponseMessage(html);
                        resolve();
                    });
                });
            })();
        });
    }
    static parsePage(html) {
        const spellList = [];
        const select = $(html).find("select[name='ktec_no']");
        $(select).find("option").each(function (_idx, option) {
            const spell = new Spell_1.default();
            const id = $(option).val();
            if (id !== "") {
                spell.id = id;
                let s = $(option).text().trim();
                spell.name = StringUtils_1.default.substringBefore(s, "(");
                s = StringUtils_1.default.substringBetween(s, "(", ")");
                const ss = s.split(" | ");
                spell.power = parseInt(StringUtils_1.default.substringAfter(ss[0], "威力:"));
                spell.accuracy = parseInt(StringUtils_1.default.substringAfter(ss[1], "确率:"));
                spell.pp = parseInt(StringUtils_1.default.substringAfter(ss[2], "消费MP:"));
                spellList.push(spell);
            }
        });
        const page = new PersonalSpellPage_1.default();
        page.spellList = spellList;
        return page;
    }
}
_PersonalSpell_credential = new WeakMap(), _PersonalSpell_townId = new WeakMap();
module.exports = PersonalSpell;


/***/ }),
/* 141 */
/***/ ((module) => {

"use strict";

class PersonalSpellPage {
}
module.exports = PersonalSpellPage;


/***/ }),
/* 142 */
/***/ ((module) => {

"use strict";

class Spell {
    get score() {
        return this.power * this.accuracy;
    }
}
module.exports = Spell;


/***/ }),
/* 143 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const PersonalCareerManagement_1 = __importDefault(__webpack_require__(136));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class PersonalCareerManagementPageProcessor extends PageProcessorCredentialSupport_1.default {
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            const page = PersonalCareerManagement_1.default.parsePage(PageUtils_1.default.currentPageHtml());
            this.doProcessPageParsed(credential, page, context);
            PageUtils_1.default.onDoubleEscape(() => $("#returnButton").trigger("click"));
        });
    }
}
module.exports = PersonalCareerManagementPageProcessor;


/***/ }),
/* 144 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const CareerLoader_1 = __importDefault(__webpack_require__(135));
const PersonalCareerManagement_1 = __importDefault(__webpack_require__(136));
const PersonalSpell_1 = __importDefault(__webpack_require__(140));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
const PersonalStatus_1 = __importDefault(__webpack_require__(105));
const CommentBoard_1 = __importDefault(__webpack_require__(54));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const PersonalCareerManagementPageProcessor_1 = __importDefault(__webpack_require__(143));
class PersonalCareerManagementPageProcessor_Town extends PersonalCareerManagementPageProcessor_1.default {
    doProcessPageParsed(credential, page, context) {
        const candidateList = page.careerList;
        doProcess(credential, candidateList);
    }
}
function doProcess(credential, candidateList) {
    $("table:first td:first").removeAttr("bgcolor");
    $("table:first td:first").removeAttr("height");
    $("table:first td:first").css("text-align", "center");
    $("table:first td:first").css("font-size", "150%");
    $("table:first td:first").css("font-weight", "bold");
    $("table:first td:first").css("background-color", "navy");
    $("table:first td:first").css("color", "greenyellow");
    $("table:first td:first").text("<<  职 业 管 理  >>");
    $("table:first tr:first").next().find("table:first td:first")
        .next().next().next().attr("id", "roleStatus");
    $("img[alt='神官']").parent().prev().attr("id", "messageBoard");
    $("img[alt='神官']").parent().prev().css("color", "white");
    $("table:first").removeAttr("height");
    $("table:first tr:first")
        .next().next().next()
        .html("<td style='background-color:#F8F0E0'>" +
        "<div id='CareerUI'></div><div id='Eden' style='display:none'></div>" +
        "</td>");
    $("#Eden").html("" +
        "<form action='' method='post' id='edenForm'>" +
        "        <input type='hidden' name='id' value='" + credential.id + "'>" +
        "        <input type='hidden' name='pass' value='" + credential.pass + "'>" +
        "        <div id='edenFormPayload' style='display:none'></div>" +
        "        <input type='submit' id='edenSubmit'>" +
        "</form>");
    $("table:first tr:first")
        .next().next().next()
        .after($("<tr><td style='background-color:#F8F0E0;text-align:center'>" +
        "<input type='button' value='返回城市' id='returnButton'>" +
        "<input type='button' value='装备管理' id='itemManagementButton'>" +
        "</td></tr>"));
    $("#returnButton").on("click", function () {
        $("#edenForm").attr("action", "status.cgi");
        $("#edenFormPayload").html("<input type='hidden' name='mode' value='STATUS'>");
        $("#edenSubmit").trigger("click");
    });
    $("#itemManagementButton").on("click", function () {
        $("#edenForm").attr("action", "mydata.cgi");
        $("#edenFormPayload").html("<input type='hidden' name='mode' value='USE_ITEM'>");
        $("#edenSubmit").trigger("click");
    });
    const imageHtml = NpcLoader_1.default.getNpcImageHtml("白皇");
    CommentBoard_1.default.createCommentBoard(imageHtml);
    CommentBoard_1.default.writeMessage("是的,你没有看错,换人了,某幕后黑手不愿意出镜。不过请放心,转职方面我是专业的,毕竟我一直制霸钉耙榜。<br>");
    CommentBoard_1.default.writeMessage("蓝色的职业代表你已经掌握了。我会把为你推荐的职业红色加深标识出来,当然,前提是如果有能推荐的。<br>");
    doRender(credential, candidateList);
}
function doRender(credential, candidateList) {
    let html = "";
    html += "<table style='background-color:#888888;width:100%;text-align:center'>";
    html += "<tbody style='background-color:#F8F0E0'>";
    html += "<tr>";
    html += "<td id='spellCell'>";
    html += "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td id='careerCell'>";
    html += "</td>";
    html += "</tr>";
    html += "</toby>";
    html += "</table>";
    $("#CareerUI").html(html);
    new PersonalStatus_1.default(credential).load().then(role => {
        if (role.task !== "没有任务!") {
            MessageBoard_1.default.publishMessage("当前任务:<b style='color:yellow;font-size:150%'>" + role.task + "</b>");
        }
        doRenderRoleStatus(role);
        if (role.level > 50) {
            doRenderCareer(credential, role, candidateList);
            doBindCareerButton(credential);
        }
        new PersonalSpell_1.default(credential).open().then(spellPage => {
            const spellList = spellPage.spellList;
            doRenderSpell(credential, role, spellList);
            doBindSpellButton(credential, spellList);
        });
    });
}
function doRenderRoleStatus(role) {
    let html = "";
    html += "<table style='background-color:#888888;border-width:0'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>姓名</th>";
    html += "<th style='background-color:#E0D0B0'>LV</th>";
    html += "<th style='background-color:#EFE0C0'>HP</th>";
    html += "<th style='background-color:#E8E8D0'>MP</th>";
    html += "<th style='background-color:#EFE0C0'>攻击</th>";
    html += "<th style='background-color:#EFE0C0'>防御</th>";
    html += "<th style='background-color:#EFE0C0'>智力</th>";
    html += "<th style='background-color:#EFE0C0'>精神</th>";
    html += "<th style='background-color:#EFE0C0'>速度</th>";
    html += "<th style='background-color:#E0D0B0'>属性</th>";
    html += "<th style='background-color:#E8E8D0'>职业</th>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='background-color:#E8E8D0'>" + role.name + "</td>";
    html += "<td style='background-color:#E0D0B0'>" + role.level + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.health + "/" + role.maxHealth + "</td>";
    html += "<td style='background-color:#E8E8D0'>" + role.mana + "/" + role.maxMana + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.attack + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.defense + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.specialAttack + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.specialDefense + "</td>";
    html += "<td style='background-color:#EFE0C0'>" + role.speed + "</td>";
    html += "<td style='background-color:#E0D0B0'>" + role.attribute + "</td>";
    html += "<td style='background-color:#E8E8D0'>" + role.career + "</td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    $("#roleStatus").html(html);
}
function doRenderCareer(credential, role, careerCandidateList) {
    let html = "";
    html += "<table style='background-color:#888888;width:100%;text-align:center'>";
    html += "<tbody style='background-color:#F8F0E0'>";
    html += "<tr>";
    html += "<th colspan='7' style='background-color:#E8E8D0;color:navy;text-align:center;font-weight:bold;font-size:120%'><< 选 择 新 的 职 业 >></th>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>战士系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_0' value='兵士'>" +
        "<input type='button' class='CareerUIButton' id='career_1' value='武士'>" +
        "<input type='button' class='CareerUIButton' id='career_2' value='剑客'>" +
        "<input type='button' class='CareerUIButton' id='career_3' value='剑侠'>" +
        "<input type='button' class='CareerUIButton' id='career_4' value='魔法剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_5' value='暗黑剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_6' value='奥法剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_7' value='魔导剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_8' value='神圣剑士'>" +
        "<input type='button' class='CareerUIButton' id='career_9' value='圣殿武士'>" +
        "<input type='button' class='CareerUIButton' id='career_10' value='剑圣'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>枪系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_11' value='枪战士'>" +
        "<input type='button' class='CareerUIButton' id='career_12' value='重战士'>" +
        "<input type='button' class='CareerUIButton' id='career_13' value='狂战士'>" +
        "<input type='button' class='CareerUIButton' id='career_14' value='龙战士'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>格斗系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_15' value='武僧'>" +
        "<input type='button' class='CareerUIButton' id='career_16' value='决斗家'>" +
        "<input type='button' class='CareerUIButton' id='career_17' value='拳王'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>魔术系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_18' value='术士'>" +
        "<input type='button' class='CareerUIButton' id='career_19' value='魔法师'>" +
        "<input type='button' class='CareerUIButton' id='career_20' value='咒灵师'>" +
        "<input type='button' class='CareerUIButton' id='career_21' value='大魔导士'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>祭司系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_22' value='牧师'>" +
        "<input type='button' class='CareerUIButton' id='career_23' value='德鲁伊'>" +
        "<input type='button' class='CareerUIButton' id='career_24' value='贤者'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>弓矢系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_25' value='弓箭士'>" +
        "<input type='button' class='CareerUIButton' id='career_26' value='魔弓手'>" +
        "<input type='button' class='CareerUIButton' id='career_27' value='狙击手'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>游侠系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_28' value='游侠'>" +
        "<input type='button' class='CareerUIButton' id='career_29' value='巡林客'>" +
        "<input type='button' class='CareerUIButton' id='career_30' value='吟游诗人'>" +
        "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>天位系</th>";
    html += "<td style='background-color:#EFE0C0;text-align:left'>" +
        "<input type='button' class='CareerUIButton' id='career_31' value='小天位'>" +
        "<input type='button' class='CareerUIButton' id='career_32' value='强天位'>" +
        "<input type='button' class='CareerUIButton' id='career_33' value='斋天位'>" +
        "<input type='button' class='CareerUIButton' id='career_34' value='太天位'>" +
        "<input type='button' class='CareerUIButton' id='career_35' value='终极'>" +
        "</td>";
    html += "</tr>";
    html += "</toby>";
    html += "</table>";
    $("#careerCell").html(html);
    // 已经掌握的职业用蓝色标记
    // 没有掌握的职业用红色标记(满级的情况下)
    // 不在转职列表中的按钮删除
    // 当前职业绿色显示
    if (role.masterCareerList.includes("小天位")) {
        $("#career_32").css("color", "blue");
        $("#career_33").css("color", "blue");
        $("#career_34").css("color", "blue");
        $("#career_35").css("color", "blue");
    }
    const careerNames = Object.keys(CareerLoader_1.default.loadCareers());
    for (let i = 0; i < careerNames.length; i++) {
        const careerName = careerNames[i];
        // @ts-ignore
        const careerId = CareerLoader_1.default.loadCareers()[careerName]["id"];
        const buttonId = "career_" + careerId;
        if (role.masterCareerList.includes(careerName)) {
            $("#" + buttonId).css("color", "blue");
        }
        else {
            if (role.level >= 150) {
                if (careerName === role.career) {
                    $("#" + buttonId).css("color", "green");
                    $("#" + buttonId).css("font-weight", "bold");
                }
                else {
                    $("#" + buttonId).css("color", "red");
                    $("#" + buttonId).css("font-weight", "bold");
                }
            }
        }
        if (!careerCandidateList.includes(careerName)) {
            $("#" + buttonId).prop("disabled", true);
            $("#" + buttonId).css("color", "grey");
            $("#" + buttonId).css("font-weight", "normal");
        }
    }
    // 推荐计算
    const recommendations = doCalculateRecommendationCareers(role, careerCandidateList);
    if (recommendations.length > 0) {
        for (const recommendation of recommendations) {
            // @ts-ignore
            const careerId = CareerLoader_1.default.loadCareers()[recommendation]["id"];
            const buttonId = "career_" + careerId;
            if (recommendation === role.career) {
                $("#" + buttonId).css("color", "green");
                $("#" + buttonId).css("font-weight", "bold");
            }
            else {
                $("#" + buttonId).css("color", "red");
                $("#" + buttonId).css("font-weight", "bold");
            }
        }
    }
    if (SetupLoader_1.default.isCareerTransferEntranceDisabled(credential.id)) {
        // 转职入口被关闭了,那就禁止所有的转职按钮。
        for (let i = 0; i < careerNames.length; i++) {
            const careerName = careerNames[i];
            // @ts-ignore
            const careerId = CareerLoader_1.default.loadCareers()[careerName]["id"];
            const buttonId = "career_" + careerId;
            $("#" + buttonId).prop("disabled", true);
            $("#" + buttonId).css("color", "grey");
            $("#" + buttonId).css("font-weight", "normal");
        }
    }
}
function doRenderSpell(credential, role, spellList) {
    let html = "";
    html += "<table style='background-color:#888888;width:100%;text-align:center'>";
    html += "<tbody style='background-color:#F8F0E0'>";
    html += "<tr>";
    html += "<th colspan='7' style='background-color:#E8E8D0;color:navy;text-align:center;font-weight:bold;font-size:120%'><< 设 置 技 能 >></th>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>使用</th>";
    html += "<th style='background-color:#EFE0C0'>技能</th>";
    html += "<th style='background-color:#E0D0B0'>威力</th>";
    html += "<th style='background-color:#EFE0C0'>确率</th>";
    html += "<th style='background-color:#E0D0B0'>PP</th>";
    html += "<th style='background-color:#EFE0C0'>评分</th>";
    html += "<th style='background-color:#E0D0B0'>设置</th>";
    html += "</tr>";
    for (const spell of spellList) {
        const using = spell.name === role.spell;
        html += "<tr>";
        html += "<td style='background-color:#E8E8D0'>" + (using ? "★" : "") + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + spell.name + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + spell.power + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + spell.accuracy + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + spell.pp + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + spell.score + "</td>";
        html += "<td style='background-color:#E0D0B0'>" +
            "<input type='button' class='CareerUIButton' id='set_spell_" + spell.id + "' value='选择'>" +
            "</td>";
        html += "</tr>";
    }
    html += "</toby>";
    html += "</table>";
    $("#spellCell").html(html);
    for (const spell of spellList) {
        const using = spell.name === role.spell;
        if (using) {
            const buttonId = "set_spell_" + spell.id;
            $("#" + buttonId).prop("disabled", true);
        }
    }
}
function doRefresh(credential) {
    new PersonalCareerManagement_1.default(credential).open().then(page => {
        const careerCandidateList = page.careerList;
        $(".CareerUIButton").off("click");
        $("#CareerUI").html("");
        doRender(credential, careerCandidateList);
    });
}
function doBindCareerButton(credential) {
    const careerNames = Object.keys(CareerLoader_1.default.loadCareers());
    for (let i = 0; i < careerNames.length; i++) {
        const careerName = careerNames[i];
        // @ts-ignore
        const careerId = CareerLoader_1.default.loadCareers()[careerName]["id"];
        const buttonId = "career_" + careerId;
        if ($("#" + buttonId).length > 0 && !$("#" + buttonId).prop("disabled")) {
            $("#" + buttonId).on("click", function () {
                const careerId = parseInt($(this).attr("id").split("_")[1]);
                const careerName = CareerLoader_1.default.findCareerById(careerId);
                if (!confirm("请确认要转职到" + careerName + "?")) {
                    return;
                }
                new PersonalCareerManagement_1.default(credential)
                    .transfer(careerId)
                    .then(() => {
                    doRefresh(credential);
                });
            });
        }
    }
}
function doBindSpellButton(credential, spellList) {
    for (const spell of spellList) {
        const buttonId = "set_spell_" + spell.id;
        if ($("#" + buttonId).length > 0 && !$("#" + buttonId).prop("disabled")) {
            $("#" + buttonId).on("click", function () {
                const spellId = $(this).attr("id").split("_")[2];
                const request = credential.asRequest();
                // @ts-ignore
                request["mode"] = "MAGIC_SET";
                // @ts-ignore
                request["ktec_no"] = spellId;
                NetworkUtils_1.default.sendPostRequest("mydata.cgi", request, function (html) {
                    MessageBoard_1.default.processResponseMessage(html);
                    doRefresh(credential);
                });
            });
        }
    }
}
function doCalculateRecommendationCareers(role, careerCandidateList) {
    // 没有满级,不推荐
    if (role.level < 150) {
        return [];
    }
    // 没有掌握全部职业,不推荐
    if (role.masterCareerList.length !== 32) {
        return [];
    }
    const recommendations = [];
    const targetCareerNames = Object.keys(CareerLoader_1.default.loadCareerTransferRequirements());
    for (let i = 0; i < targetCareerNames.length; i++) {
        const name = targetCareerNames[i];
        // @ts-ignore
        const requirement = CareerLoader_1.default.loadCareerTransferRequirements()[name];
        if (role.maxMana >= requirement[0] &&
            role.attack >= requirement[1] &&
            role.defense >= requirement[2] &&
            role.specialAttack >= requirement[3] &&
            role.specialDefense >= requirement[4] &&
            role.speed >= requirement[5]) {
            // 发现了可以推荐的职业
            recommendations.push(name);
        }
    }
    if (recommendations.length === 0) {
        // 没有推荐出来,那么就推荐转职列表中的最后一个吧
        recommendations.push(careerCandidateList[careerCandidateList.length - 1]);
    }
    return recommendations;
}
module.exports = PersonalCareerManagementPageProcessor_Town;


/***/ }),
/* 145 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalEquipmentManagementPageInterceptor_inTownProcessor, _PersonalEquipmentManagementPageInterceptor_inCastleProcessor, _PersonalEquipmentManagementPageInterceptor_inMapProcessor, _PersonalEquipmentManagementPageInterceptor_inMetroProcessor;
const RoleStateMachineManager_1 = __importDefault(__webpack_require__(3));
const PersonalEquipmentManagementPageProcessor_Castle_1 = __importDefault(__webpack_require__(146));
const PersonalEquipmentManagementPageProcessor_Map_1 = __importDefault(__webpack_require__(150));
const PersonalEquipmentManagementPageProcessor_Metro_1 = __importDefault(__webpack_require__(153));
const PersonalEquipmentManagementPageProcessor_Town_1 = __importDefault(__webpack_require__(154));
const PageProcessorContext_1 = __importDefault(__webpack_require__(85));
class PersonalEquipmentManagementPageInterceptor {
    constructor() {
        _PersonalEquipmentManagementPageInterceptor_inTownProcessor.set(this, new PersonalEquipmentManagementPageProcessor_Town_1.default());
        _PersonalEquipmentManagementPageInterceptor_inCastleProcessor.set(this, new PersonalEquipmentManagementPageProcessor_Castle_1.default());
        _PersonalEquipmentManagementPageInterceptor_inMapProcessor.set(this, new PersonalEquipmentManagementPageProcessor_Map_1.default());
        _PersonalEquipmentManagementPageInterceptor_inMetroProcessor.set(this, new PersonalEquipmentManagementPageProcessor_Metro_1.default());
    }
    accept(cgi, pageText) {
        if (cgi === "mydata.cgi") {
            return pageText.includes("<< ||| 物品使用.装备 ||| >>");
        }
        return false;
    }
    intercept() {
        RoleStateMachineManager_1.default.create()
            .load()
            .then(machine => {
            machine.start()
                .whenInTown(state => {
                const context = new PageProcessorContext_1.default();
                context.withTownId(state === null || state === void 0 ? void 0 : state.townId);
                __classPrivateFieldGet(this, _PersonalEquipmentManagementPageInterceptor_inTownProcessor, "f").process(context);
            })
                .whenInCastle(state => {
                const context = new PageProcessorContext_1.default();
                context.withCastleName(state === null || state === void 0 ? void 0 : state.castleName);
                __classPrivateFieldGet(this, _PersonalEquipmentManagementPageInterceptor_inCastleProcessor, "f").process(context);
            })
                .whenInMap(state => {
                var _a;
                const context = new PageProcessorContext_1.default();
                context.withCoordinate((_a = state === null || state === void 0 ? void 0 : state.asCoordinate()) === null || _a === void 0 ? void 0 : _a.asText());
                __classPrivateFieldGet(this, _PersonalEquipmentManagementPageInterceptor_inMapProcessor, "f").process(context);
            })
                .whenInMetro(() => {
                __classPrivateFieldGet(this, _PersonalEquipmentManagementPageInterceptor_inMetroProcessor, "f").process();
            })
                .process();
        });
    }
}
_PersonalEquipmentManagementPageInterceptor_inTownProcessor = new WeakMap(), _PersonalEquipmentManagementPageInterceptor_inCastleProcessor = new WeakMap(), _PersonalEquipmentManagementPageInterceptor_inMapProcessor = new WeakMap(), _PersonalEquipmentManagementPageInterceptor_inMetroProcessor = new WeakMap();
module.exports = PersonalEquipmentManagementPageInterceptor;


/***/ }),
/* 146 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalEquipmentManagementPageProcessor_Castle_instances, _PersonalEquipmentManagementPageProcessor_Castle_renderPersonalUI, _PersonalEquipmentManagementPageProcessor_Castle_renderBagUI, _PersonalEquipmentManagementPageProcessor_Castle_renderWarehouseUI;
const CastleBank_1 = __importDefault(__webpack_require__(88));
const CastleEquipmentExpressHouse_1 = __importDefault(__webpack_require__(147));
const CastleWarehouse_1 = __importDefault(__webpack_require__(58));
const Equipment_1 = __importDefault(__webpack_require__(60));
const PersonalEquipmentManagement_1 = __importDefault(__webpack_require__(61));
const TreasureBag_1 = __importDefault(__webpack_require__(65));
const PersonalStatus_1 = __importDefault(__webpack_require__(105));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PersonalEquipmentManagementPageProcessor_1 = __importDefault(__webpack_require__(149));
class PersonalEquipmentManagementPageProcessor_Castle extends PersonalEquipmentManagementPageProcessor_1.default {
    constructor() {
        super(...arguments);
        _PersonalEquipmentManagementPageProcessor_Castle_instances.add(this);
    }
    doGeneratePageTitleHtml(context) {
        if (context === undefined) {
            return "<<  装 备 管 理 ( 城 堡 模 式 )  >>";
        }
        else {
            const castleName = context.get("castleName");
            return "<<  装 备 管 理 ( " + StringUtils_1.default.toTitleString(castleName) + " 城 堡 )  >>";
        }
    }
    doGenerateRoleLocationHtml(context) {
        if (context === undefined) {
            return "城堡";
        }
        else {
            return context.get("castleName");
        }
    }
    doGenerateWelcomeMessageHtml() {
        return "<b style='font-size:120%;color:wheat'>又来管理您的装备来啦?真是一刻不得闲啊。</b>";
    }
    doBindReturnButton(credential) {
        const html = PageUtils_1.default.generateReturnCastleForm(credential);
        $("#hiddenFormContainer").html(html);
        $("#returnButton").on("click", () => {
            $("#returnCastle").trigger("click");
        });
    }
    doRenderMutablePage(credential, page, context) {
        const bag = page.findTreasureBag();
        if (bag !== null) {
            __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Castle_instances, "m", _PersonalEquipmentManagementPageProcessor_Castle_renderPersonalUI).call(this, credential, page, bag.index, context);
        }
        else {
            // 已经掌握了剑圣职业,说明应该有百宝袋,但是因为某些bug导致百宝袋不可见了,
            // 还是提供有限的百宝袋功能吧,能够放入、取出,但是不能浏览了。
            // 如果有分身了,那也说明曾经掌握过剑圣职业,就算有百宝袋了
            new PersonalStatus_1.default(credential).load().then(role => {
                if (role.masterCareerList.includes("剑圣") || role.hasMirror) {
                    // 真的曾经拥有百宝袋,但是又因为某些bug失去了
                    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Castle_instances, "m", _PersonalEquipmentManagementPageProcessor_Castle_renderPersonalUI).call(this, credential, page, -1, context);
                }
                else {
                    // 是真的没有百宝袋
                    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Castle_instances, "m", _PersonalEquipmentManagementPageProcessor_Castle_renderPersonalUI).call(this, credential, page, -99, context);
                }
            });
        }
    }
}
_PersonalEquipmentManagementPageProcessor_Castle_instances = new WeakSet(), _PersonalEquipmentManagementPageProcessor_Castle_renderPersonalUI = function _PersonalEquipmentManagementPageProcessor_Castle_renderPersonalUI(credential, page, bagIndex, context) {
    $("#bagIndex").text(bagIndex);
    let html = "";
    html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<td style='background-color:darkred;color:wheat;font-weight:bold;font-size:120%;text-align:center' " +
        "colspan='22'>< 随 身 装 备 ></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>选择</th>";
    html += "<th style='background-color:#EFE0C0'>装备</th>";
    html += "<th style='background-color:#E0D0B0'>名字</th>";
    html += "<th style='background-color:#EFE0C0'>种类</th>";
    html += "<th style='background-color:#E0D0B0'>效果</th>";
    html += "<th style='background-color:#EFE0C0'>重量</th>";
    html += "<th style='background-color:#EFE0C0'>耐久</th>";
    html += "<th style='background-color:#E0D0B0'>职需</th>";
    html += "<th style='background-color:#E0D0B0'>攻需</th>";
    html += "<th style='background-color:#E0D0B0'>防需</th>";
    html += "<th style='background-color:#E0D0B0'>智需</th>";
    html += "<th style='background-color:#E0D0B0'>精需</th>";
    html += "<th style='background-color:#E0D0B0'>速需</th>";
    html += "<th style='background-color:#EFE0C0'>威+</th>";
    html += "<th style='background-color:#EFE0C0'>重+</th>";
    html += "<th style='background-color:#EFE0C0'>幸+</th>";
    html += "<th style='background-color:#E0D0B0'>经验</th>";
    html += "<th style='background-color:#EFE0C0'>属性</th>";
    html += "<th style='background-color:#E8E8D0'>使用</th>";
    html += "<th style='background-color:#E8E8D0'>入袋</th>";
    html += "<th style='background-color:#E8E8D0'>入库</th>";
    html += "<th style='background-color:#E8E8D0'>发送</th>";
    html += "</tr>";
    for (const equipment of page.equipmentList) {
        if (equipment.isGoldenCage || equipment.isTreasureBag) {
            continue;
        }
        html += "<tr>";
        html += "<td style='background-color:#E8E8D0'>";
        if (equipment.selectable) {
            html += "<input type='button' value='选择' " +
                "style='color:grey' " +
                "class='mutableButton-1 select-1' " +
                "id='select1_" + equipment.index + "'>";
        }
        html += "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.usingHTML + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.nameHTML + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.category + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.power + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.weight + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.endureHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredCareerHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredAttackHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredDefenseHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialAttackHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialDefenseHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpeedHtml + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.additionalPowerHtml + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.additionalWeightHtml + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.additionalLuckHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.experienceHTML + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.attributeHtml + "</td>";
        html += "<td style='background-color:#E8E8D0'>";
        if (equipment.selectable) {
            html += "<input type='button' value='" + equipment.buttonTitle + "' " +
                "class='mutableButton-1 use-1' " +
                "id='use1_" + equipment.index + "'>";
        }
        html += "</td>";
        html += "<td style='background-color:#E8E8D0'>";
        if (equipment.selectable && !equipment.using && bagIndex >= -1) {
            html += "<input type='button' value='入袋' " +
                "class='mutableButton-1 putIntoBag-1' " +
                "id='putIntoBag1_" + equipment.index + "'>";
        }
        html += "</td>";
        html += "<td style='background-color:#E8E8D0'>";
        if (!equipment.using) {
            html += "<input type='button' value='入库' " +
                "class='mutableButton-1 putIntoWarehouse-1' " +
                "id='putIntoWarehouse1_" + equipment.index + "'>";
        }
        html += "</td>";
        html += "<td style='background-color:#E8E8D0'>";
        html += "<input type='button' value='发送' " +
            "class='mutableButton-1 send-1' " +
            "id='send1_" + equipment.index + "' disabled style='display:none'>";
        html += "</td>";
        html += "</tr>";
    }
    // ------------------------------------------------------------------------
    // 装备菜单栏
    // ------------------------------------------------------------------------
    html += "<tr>";
    html += "<td style='background-color:#F8F0E0;text-align:center' colspan='22'>";
    html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<td style='text-align:center;font-weight:bold' colspan='2'>";
    html += "<span style='color:navy'>目前剩余空位数:</span><span style='color:red'>" + page.spaceCount + "</span>";
    html += "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:left'>";
    html += "<input type='button' id='use1' class='mutableButton-1' value='使用装备'>";
    html += "<input type='button' id='putIntoBag1' class='mutableButton-1' value='放入百宝袋' disabled style='display:none'>";
    html += "<input type='button' id='putIntoWarehouse1' class='mutableButton-1' value='放入仓库'>";
    html += "</td>";
    html += "<td style='text-align:right'>";
    html += "<input type='button' id='openBag' class='mutableButton-1' value='打开百宝袋' disabled style='display:none'>";
    html += "<input type='button' id='closeBag' class='mutableButton-1' value='关闭百宝袋' disabled style='display:none'>";
    html += "<input type='button' id='openWarehouse' class='mutableButton-1' value='打开仓库'>";
    html += "<input type='button' id='closeWarehouse' class='mutableButton-1' value='关闭仓库'>";
    html += "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:left' colspan='2'>";
    html += "<input type='text' id='searchName' size='15' maxlength='20'>";
    html += "<input type='button' id='searchButton' class='mutableButton-1' value='找人'>";
    html += "<select id='peopleSelect'><option value=''>选择发送对象</select>";
    html += "<input type='button' id='sendButton' class='mutableButton-1' value='发送'>";
    html += "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:right' colspan='2'>";
    if (bagIndex >= 0) {
        html += "<input type='button' id='takeGemsOutFromBag' class='mutableButton-1' value='取出袋中全部宝石'>";
    }
    html += "<input type='button' id='putGemsIntoWarehouse' class='mutableButton-1' value='随身宝石全部入库'>";
    html += "</td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    html += "</td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    $("#equipmentList").html(html).parent().show();
    new CastleEquipmentExpressHouse_1.default(credential).open().then(expressPage => {
        for (const equipment of expressPage.equipmentList) {
            const index = equipment.index;
            if (equipment.selectable) {
                $("#send1_" + index).prop("disabled", false).show();
            }
            else {
                $("#send1_" + index).remove();
            }
        }
        $(".send-1").on("click", event => {
            const buttonId = $(event.target).attr("id");
            const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
            const s = $("#peopleSelect").val();
            if (s === undefined || s.trim() === "") {
                this.doScrollToPageTitle();
                MessageBoard_1.default.publishWarning("没有选择发送对象!");
                return;
            }
            const bank = new CastleBank_1.default(credential);
            bank.withdraw(10).then(() => {
                new CastleEquipmentExpressHouse_1.default(credential).send(s, [index]).then(() => {
                    bank.deposit().then(() => {
                        this.doRefreshMutablePage(credential, context);
                    });
                });
            });
        });
    });
    // Bind select buttons
    $(".select-1").on("click", event => {
        const buttonId = $(event.target).attr("id");
        if (PageUtils_1.default.isColorGrey(buttonId)) {
            $(event.target).css("color", "blue");
        }
        else if (PageUtils_1.default.isColorBlue(buttonId)) {
            $(event.target).css("color", "grey");
        }
    });
    // Bind use buttons
    $(".use-1").on("click", event => {
        const buttonId = $(event.target).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
        new PersonalEquipmentManagement_1.default(credential).use([index]).then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    // Bind put into bag buttons
    $(".putIntoBag-1").on("click", event => {
        const buttonId = $(event.target).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
        new TreasureBag_1.default(credential).putInto([index]).then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    // Bind put into warehouse buttons
    $(".putIntoWarehouse-1").on("click", event => {
        const buttonId = $(event.target).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
        new CastleWarehouse_1.default(credential).putInto([index]).then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    // Bind use button
    $("#use1").on("click", () => {
        const indexList = [];
        $(".select-1").each((idx, button) => {
            const buttonId = $(button).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            this.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有选择物品或装备!");
            return;
        }
        new PersonalEquipmentManagement_1.default(credential).use(indexList).then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    // Put into bag
    if (bagIndex >= -1) {
        $("#putIntoBag1").prop("disabled", false).show();
        $("#putIntoBag1").on("click", () => {
            const indexList = [];
            $(".select-1").each((idx, button) => {
                const buttonId = $(button).attr("id");
                if (PageUtils_1.default.isColorBlue(buttonId)) {
                    const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                    indexList.push(index);
                }
            });
            if (indexList.length === 0) {
                this.doScrollToPageTitle();
                MessageBoard_1.default.publishWarning("没有选择物品或装备!");
                return;
            }
            new TreasureBag_1.default(credential).putInto(indexList).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
    }
    // Put into warehouse
    $("#putIntoWarehouse1").on("click", () => {
        const indexList = [];
        $(".select-1").each((idx, button) => {
            const buttonId = $(button).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            this.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有选择物品或装备!");
            return;
        }
        new CastleWarehouse_1.default(credential).putInto(indexList).then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    // Bind open/close bag buttons
    if (bagIndex >= -1) {
        $("#openBag").prop("disabled", false).show();
        $("#closeBag").prop("disabled", false).show();
        $("#openBag").on("click", () => {
            if ($("#bagState").text() === "on") {
                return;
            }
            $("#bagState").text("on");
            __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Castle_instances, "m", _PersonalEquipmentManagementPageProcessor_Castle_renderBagUI).call(this, credential, page, bagIndex, context);
        });
        $("#closeBag").on("click", () => {
            if ($("#bagState").text() === "off") {
                return;
            }
            $("#bagState").text("off");
            PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-2");
            $("#bagList").html("").parent().hide();
        });
    }
    // Bind open/close warehouse buttons
    $("#openWarehouse").on("click", () => {
        if ($("#warehouseState").text() === "on") {
            return;
        }
        $("#warehouseState").text("on");
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Castle_instances, "m", _PersonalEquipmentManagementPageProcessor_Castle_renderWarehouseUI).call(this, credential, page, context);
    });
    $("#closeWarehouse").on("click", () => {
        if ($("#warehouseState").text() === "off") {
            return;
        }
        $("#warehouseState").text("off");
        PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-3");
        $("#warehouseList").html("").parent().hide();
    });
    $("#searchButton").on("click", () => {
        const s = $("#searchName").val();
        if (s === undefined || s.trim() === "") {
            this.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有正确输入人名!");
            return;
        }
        new CastleEquipmentExpressHouse_1.default(credential).search(s).then(optionListHtml => {
            $("#peopleSelect").html(optionListHtml);
        });
    });
    $("#sendButton").on("click", () => {
        const indexList = [];
        $(".select-1").each((idx, button) => {
            const buttonId = $(button).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            this.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有选择物品或装备!");
            return;
        }
        const s = $("#peopleSelect").val();
        if (s === undefined || s.trim() === "") {
            this.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有选择发送对象!");
            return;
        }
        const bank = new CastleBank_1.default(credential);
        bank.withdraw(10).then(() => {
            new CastleEquipmentExpressHouse_1.default(credential).send(s, indexList).then(() => {
                bank.deposit().then(() => {
                    this.doRefreshMutablePage(credential, context);
                });
            });
        });
    });
    $("#takeGemsOutFromBag").on("click", () => {
        const bag = new TreasureBag_1.default(credential);
        bag.open(bagIndex).then(bagPage => {
            let count = 0;
            const indexList = [];
            for (const equipment of bagPage.equipmentList) {
                if (equipment.name.endsWith("宝石")) {
                    count++;
                    if (count <= page.spaceCount) {
                        indexList.push(equipment.index);
                    }
                }
            }
            if (indexList.length === 0) {
                // Nothing found, ignore
                return;
            }
            bag.takeOut(indexList).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
    });
    $("#putGemsIntoWarehouse").on("click", () => {
        $(".select-1").each((idx, button) => {
            const buttonId = $(button).attr("id");
            const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
            const equipment = page.findEquipment(index);
            if (equipment !== null && equipment.name.endsWith("宝石")) {
                $("#" + buttonId).css("color", "blue");
            }
            else {
                $("#" + buttonId).css("color", "grey");
            }
        });
        $("#putIntoWarehouse1").trigger("click");
    });
    // Render bag or warehouse if necessary
    if ($("#bagState").text() === "on") {
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Castle_instances, "m", _PersonalEquipmentManagementPageProcessor_Castle_renderBagUI).call(this, credential, page, bagIndex, context);
    }
    if ($("#warehouseState").text() === "on") {
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Castle_instances, "m", _PersonalEquipmentManagementPageProcessor_Castle_renderWarehouseUI).call(this, credential, page, context);
    }
}, _PersonalEquipmentManagementPageProcessor_Castle_renderBagUI = function _PersonalEquipmentManagementPageProcessor_Castle_renderBagUI(credential, page, bagIndex, context) {
    if (bagIndex < 0) {
        let html = "";
        html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:darkgreen;color:wheat;font-weight:bold;font-size:120%;text-align:center'>< 百 宝 袋 ></td>";
        html += "</tr>";
        html += "<tr>";
        html += "<th style='background-color:#E8E8D0;text-align:center;color:navy;font-weight:bold'>百宝袋丢失了呀?那只能为您提供受限的功能了。</th>";
        html += "</tr>";
        // ----------------------------------------------------------------
        // 百宝袋菜单栏
        // ----------------------------------------------------------------
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;text-align:center'>";
        html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='text-align:left'>";
        if (page.spaceCount > 0) {
            html += "<input type='button' class='mutableButton-2' " +
                "id='tryTakeOutFromBag2' " +
                "value='从百宝袋中盲取'>";
        }
        html += "</td>";
        html += "<td style='text-align:right'>";
        html += "<input type='button' id='closeBag2' class='mutableButton-2' value='关闭百宝袋'>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#bagList").html(html).parent().show();
        $("#tryTakeOutFromBag2").on("click", () => {
            new TreasureBag_1.default(credential).tryTakeOut(page.spaceCount).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
        $("#closeBag2").on("click", () => {
            if ($("#bagState").text() === "off") {
                return;
            }
            $("#bagState").text("off");
            PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-2");
            $("#bagList").html("").parent().hide();
        });
        return;
    }
    new TreasureBag_1.default(credential).open(bagIndex).then(bagPage => {
        const equipmentList = bagPage.sortedEquipmentList;
        let html = "";
        html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:darkgreen;color:wheat;font-weight:bold;font-size:120%;text-align:center' colspan='11'>< 百 宝 袋 ></td>";
        html += "</tr>";
        html += "<tr>";
        html += "<th style='background-color:#E8E8D0'>选择</th>";
        html += "<th style='background-color:#E0D0B0'>名字</th>";
        html += "<th style='background-color:#EFE0C0'>种类</th>";
        html += "<th style='background-color:#E0D0B0'>效果</th>";
        html += "<th style='background-color:#EFE0C0'>重量</th>";
        html += "<th style='background-color:#EFE0C0'>耐久</th>";
        html += "<th style='background-color:#EFE0C0'>威+</th>";
        html += "<th style='background-color:#EFE0C0'>重+</th>";
        html += "<th style='background-color:#EFE0C0'>幸+</th>";
        html += "<th style='background-color:#E0D0B0'>经验</th>";
        html += "<th style='background-color:#E8E8D0'>取出</th>";
        html += "</tr>";
        for (const equipment of equipmentList) {
            html += "<tr>";
            html += "<td style='background-color:#E8E8D0'>";
            if (page.spaceCount > 0) {
                html += "<input type='button' value='选择' " +
                    "style='color:grey' " +
                    "class='mutableButton-2 select-2' " +
                    "id='select2_" + equipment.index + "'>";
            }
            html += "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.nameHTML + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.category + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.power + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.weight + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.endureHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalPowerHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalWeightHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalLuckHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.experienceHTML + "</td>";
            html += "<td style='background-color:#E8E8D0'>";
            if (page.spaceCount > 0) {
                html += "<input type='button' value='出袋' " +
                    "class='mutableButton-2 takeOutBag-2' " +
                    "id='takeOutBag1_" + equipment.index + "'>";
            }
            html += "</td>";
            html += "</tr>";
        }
        // ----------------------------------------------------------------
        // 百宝袋菜单栏
        // ----------------------------------------------------------------
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;text-align:center' colspan='11'>";
        html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='text-align:left'>";
        if (page.spaceCount > 0) {
            html += "<input type='button' class='mutableButton-2' " +
                "id='takeOutFromBag2' " +
                "value='从百宝袋中取出'>";
        }
        html += "</td>";
        html += "<td style='text-align:right'>";
        html += "<input type='button' id='closeBag2' class='mutableButton-2' value='关闭百宝袋'>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#bagList").html(html).parent().show();
        // Bind select buttons
        $(".select-2").on("click", event => {
            const buttonId = $(event.target).attr("id");
            if (PageUtils_1.default.isColorGrey(buttonId)) {
                $(event.target).css("color", "blue");
            }
            else if (PageUtils_1.default.isColorBlue(buttonId)) {
                $(event.target).css("color", "grey");
            }
        });
        // Bind take out buttons
        $(".takeOutBag-2").on("click", event => {
            const buttonId = $(event.target).attr("id");
            const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
            new TreasureBag_1.default(credential).takeOut([index]).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
        $("#takeOutFromBag2").on("click", () => {
            const indexList = [];
            $(".select-2").each((idx, button) => {
                const buttonId = $(button).attr("id");
                if (PageUtils_1.default.isColorBlue(buttonId)) {
                    const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                    indexList.push(index);
                }
            });
            if (indexList.length === 0) {
                this.doScrollToPageTitle();
                MessageBoard_1.default.publishWarning("没有选择百宝袋中的物品或装备!");
                return;
            }
            new TreasureBag_1.default(credential).takeOut(indexList).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
        $("#closeBag2").on("click", () => {
            if ($("#bagState").text() === "off") {
                return;
            }
            $("#bagState").text("off");
            PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-2");
            $("#bagList").html("").parent().hide();
        });
    });
}, _PersonalEquipmentManagementPageProcessor_Castle_renderWarehouseUI = function _PersonalEquipmentManagementPageProcessor_Castle_renderWarehouseUI(credential, page, context) {
    new CastleWarehouse_1.default(credential).open().then(warehousePage => {
        const equipmentList = Equipment_1.default.sortEquipmentList(warehousePage.storageEquipmentList);
        let html = "";
        html += "<table style='border-width:0;background-color:#888888;margin:auto;width:100%'>";
        html += "<tbody style='background-color:#F8F0E0;text-align:center'>";
        html += "<tr>";
        html += "<td style='background-color:darkred;color:wheat;font-weight:bold' " +
            "colspan='18'>";
        html += "< 城 堡 仓 库 >";
        html += "</td>";
        html += "<tr>";
        html += "<th style='background-color:#E8E8D0'>选择</th>";
        html += "<th style='background-color:#E8E8D0'>名字</th>";
        html += "<th style='background-color:#EFE0C0'>种类</th>";
        html += "<th style='background-color:#E0D0B0'>效果</th>";
        html += "<th style='background-color:#EFE0C0'>重量</th>";
        html += "<th style='background-color:#E0D0B0'>耐久</th>";
        html += "<th style='background-color:#EFE0C0'>职业</th>";
        html += "<th style='background-color:#E0D0B0'>攻击</th>";
        html += "<th style='background-color:#E0D0B0'>防御</th>";
        html += "<th style='background-color:#E0D0B0'>智力</th>";
        html += "<th style='background-color:#E0D0B0'>精神</th>";
        html += "<th style='background-color:#E0D0B0'>速度</th>";
        html += "<th style='background-color:#EFE0C0'>威力</th>";
        html += "<th style='background-color:#EFE0C0'>重量</th>";
        html += "<th style='background-color:#EFE0C0'>幸运</th>";
        html += "<th style='background-color:#E0D0B0'>经验</th>";
        html += "<th style='background-color:#E0D0B0'>属性</th>";
        html += "<th style='background-color:#E8E8D0'>取出</th>";
        html += "</tr>";
        for (const equipment of equipmentList) {
            html += "<tr>";
            html += "<td style='background-color:#E8E8D0'>";
            if (page.spaceCount > 0) {
                if (page.spaceCount > 0) {
                    html += "<input type='button' value='选择' " +
                        "style='color:grey' " +
                        "class='mutableButton-3 select-3' " +
                        "id='select3_" + equipment.index + "'>";
                }
            }
            html += "</td>";
            html += "<td style='background-color:#E8E8D0'>" + equipment.nameHTML + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.category + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.power + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.weight + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.endureHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.requiredCareerHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredAttackHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredDefenseHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialAttackHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialDefenseHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpeedHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalPowerHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalWeightHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalLuckHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.experienceHTML + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.attributeHtml + "</td>";
            html += "<td style='background-color:#E8E8D0'>";
            if (page.spaceCount > 0) {
                html += "<input type='button' class='mutableButton-3 takeOutFromWarehouse-3' " +
                    "id='takeOutFromWarehouse3_" + equipment.index + "' value='出库'>";
            }
            html += "</td>";
            html += "</tr>";
        }
        // ----------------------------------------------------------------
        // 城堡仓库菜单栏
        // ----------------------------------------------------------------
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;text-align:center' colspan='18'>";
        html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='text-align:left'>";
        if (page.spaceCount > 0) {
            html += "<input type='button' class='mutableButton-3' " +
                "id='takeOutFromWarehouse3' " +
                "value='从仓库中取出'>";
        }
        html += "</td>";
        html += "<td style='text-align:right'>";
        html += "<input type='button' id='closeWarehouse3' class='mutableButton-3' value='关闭仓库'>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#warehouseList").html(html).parent().show();
        // Bind select buttons
        $(".select-3").on("click", event => {
            const buttonId = $(event.target).attr("id");
            if (PageUtils_1.default.isColorGrey(buttonId)) {
                $(event.target).css("color", "blue");
            }
            else if (PageUtils_1.default.isColorBlue(buttonId)) {
                $(event.target).css("color", "grey");
            }
        });
        // Bind take out buttons
        $(".takeOutFromWarehouse-3").on("click", event => {
            const buttonId = $(event.target).attr("id");
            const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
            new CastleWarehouse_1.default(credential).takeOut([index]).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
        $("#takeOutFromWarehouse3").on("click", () => {
            const indexList = [];
            $(".select-3").each((idx, button) => {
                const buttonId = $(button).attr("id");
                if (PageUtils_1.default.isColorBlue(buttonId)) {
                    const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                    indexList.push(index);
                }
            });
            if (indexList.length === 0) {
                this.doScrollToPageTitle();
                MessageBoard_1.default.publishWarning("没有选择仓库中的物品或装备!");
                return;
            }
            new CastleWarehouse_1.default(credential).takeOut(indexList).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
        $("#closeWarehouse3").on("click", () => {
            if ($("#warehouseState").text() === "off") {
                return;
            }
            $("#warehouseState").text("off");
            PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-3");
            $("#warehouseList").html("").parent().hide();
        });
    });
};
module.exports = PersonalEquipmentManagementPageProcessor_Castle;


/***/ }),
/* 147 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _CastleEquipmentExpressHouse_credential;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const Role_1 = __importDefault(__webpack_require__(50));
const CastleEquipmentExpressHousePage_1 = __importDefault(__webpack_require__(148));
const Equipment_1 = __importDefault(__webpack_require__(60));
class CastleEquipmentExpressHouse {
    constructor(credential) {
        _CastleEquipmentExpressHouse_credential.set(this, void 0);
        __classPrivateFieldSet(this, _CastleEquipmentExpressHouse_credential, credential, "f");
    }
    open() {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise(resolve => {
                    const request = __classPrivateFieldGet(this, _CastleEquipmentExpressHouse_credential, "f").asRequestMap();
                    request.set("mode", "CASTLE_SENDITEM");
                    NetworkUtils_1.default.post("castle.cgi", request).then(html => {
                        const page = CastleEquipmentExpressHouse.parsePage(html);
                        resolve(page);
                    });
                });
            })();
        });
    }
    search(name) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise((resolve, reject) => {
                    if (name.trim() === "") {
                        reject();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _CastleEquipmentExpressHouse_credential, "f").asRequestMap();
                    request.set("mode", "CASTLE_SENDITEM");
                    // noinspection JSDeprecatedSymbols
                    request.set("serch", escape(name.trim()));
                    NetworkUtils_1.default.post("castle.cgi", request).then(html => {
                        const optionListHtml = $(html).find("select:first").html();
                        resolve(optionListHtml);
                    });
                });
            })();
        });
    }
    send(target, indexList) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield (() => {
                return new Promise((resolve, reject) => {
                    if (target.trim() === "" || indexList.length === 0) {
                        reject();
                        return;
                    }
                    const request = __classPrivateFieldGet(this, _CastleEquipmentExpressHouse_credential, "f").asRequestMap();
                    request.set("mode", "CASTLE_SENDITEM2");
                    request.set("eid", target.trim());
                    for (const index of indexList) {
                        request.set("item" + index, index.toString());
                    }
                    NetworkUtils_1.default.post("castle.cgi", request).then(html => {
                        if (html.includes("所持金不足")) {
                            reject();
                        }
                        else {
                            MessageBoard_1.default.processResponseMessage(html);
                            resolve();
                        }
                    });
                });
            })();
        });
    }
    static parsePage(html) {
        const role = new Role_1.default();
        $(html).find("td:contains('LV')")
            .filter((idx, td) => $(td).text() === "LV")
            .closest("tr")
            .next()
            .find("td:first")
            .each((idx, td) => {
            role.name = $(td).text();
        })
            .next()
            .each((idx, td) => {
            role.level = parseInt($(td).text());
        })
            .next()
            .each((idx, td) => {
            let s = $(td).text();
            role.attribute = StringUtils_1.default.substringBefore(s, "属");
        })
            .next()
            .each((idx, td) => {
            role.career = $(td).text();
        })
            .parent()
            .next()
            .find("td:first")
            .next()
            .each((idx, td) => {
            let s = $(td).text();
            s = StringUtils_1.default.substringBefore(s, " GOLD");
            role.cash = parseInt(s);
        });
        const equipmentList = [];
        $(html).find("input:checkbox")
            .each((idx, checkbox) => {
            const equipment = new Equipment_1.default();
            let s = $(checkbox).val();
            equipment.index = parseInt(s);
            equipment.selectable = !$(checkbox).prop("disabled");
            const c1 = $(checkbox).parent();
            const c2 = c1.next();
            const c3 = c2.next();
            const c4 = c3.next();
            const c5 = c4.next();
            const c6 = c5.next();
            equipment.using = c2.text() === "★";
            equipment.parseName(c3.html());
            equipment.category = c4.text();
            equipment.power = parseInt(c5.text());
            equipment.weight = parseInt(c6.text());
            equipmentList.push(equipment);
        });
        const page = new CastleEquipmentExpressHousePage_1.default();
        page.role = role;
        page.equipmentList = equipmentList;
        return page;
    }
}
_CastleEquipmentExpressHouse_credential = new WeakMap();
module.exports = CastleEquipmentExpressHouse;


/***/ }),
/* 148 */
/***/ ((module) => {

"use strict";

class CastleEquipmentExpressHousePage {
    canSend(index) {
        for (const equipment of this.equipmentList) {
            if (equipment.index === index) {
                return equipment.selectable;
            }
        }
        return false;
    }
}
module.exports = CastleEquipmentExpressHousePage;


/***/ }),
/* 149 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalEquipmentManagementPageProcessor_instances, _PersonalEquipmentManagementPageProcessor_renderImmutablePage, _PersonalEquipmentManagementPageProcessor_bindImmutableButtons;
const PersonalEquipmentManagement_1 = __importDefault(__webpack_require__(61));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const PageProcessorCredentialSupport_1 = __importDefault(__webpack_require__(83));
class PersonalEquipmentManagementPageProcessor extends PageProcessorCredentialSupport_1.default {
    constructor() {
        super(...arguments);
        _PersonalEquipmentManagementPageProcessor_instances.add(this);
    }
    doProcess(credential, context) {
        return __awaiter(this, void 0, void 0, function* () {
            const page = PersonalEquipmentManagement_1.default.parsePage(PageUtils_1.default.currentPageHtml());
            __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_instances, "m", _PersonalEquipmentManagementPageProcessor_renderImmutablePage).call(this, credential, page, context);
            PageUtils_1.default.onDoubleEscape(() => $("#returnButton").trigger("click"));
        });
    }
    doRefreshMutablePage(credential, context) {
        PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-1");
        PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-2");
        PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-3");
        $("#equipmentList").html("").parent().hide();
        $("#bagList").html("").parent().hide();
        $("#warehouseList").html("").parent().hide();
        let townId = undefined;
        if (context !== undefined) {
            townId = context.get("townId");
        }
        new PersonalEquipmentManagement_1.default(credential, townId).open().then(page => {
            this.doRenderRole(page.role);
            this.doRenderMutablePage(credential, page, context);
        });
    }
    doScrollToPageTitle() {
        PageUtils_1.default.scrollIntoView("pageTitle");
    }
    doRenderRole(role) {
        if (role !== undefined) {
            $("#roleHealth").text(role.health + "/" + role.maxHealth);
            $("#roleMana").text(role.mana + "/" + role.maxMana);
            $("#roleCash").text(role.cash + " GOLD");
        }
    }
    doBindSelectButtons(className) {
        $("." + className).on("click", event => {
            const buttonId = $(event.target).attr("id");
            if (PageUtils_1.default.isColorGrey(buttonId)) {
                $(event.target).css("color", "blue");
            }
            else if (PageUtils_1.default.isColorBlue(buttonId)) {
                $(event.target).css("color", "grey");
            }
        });
    }
    doCheckSetConfiguration(config) {
        if (config === null) {
            return false;
        }
        // @ts-ignore
        const a = config["weaponName"];
        // @ts-ignore
        const b = config["armorName"];
        // @ts-ignore
        const c = config["accessoryName"];
        return (a !== undefined && a !== "NONE") || (b !== undefined && b !== "NONE") || (c !== undefined && c !== "NONE");
    }
    doBeforeRenderMutablePage(credential, context) {
    }
}
_PersonalEquipmentManagementPageProcessor_instances = new WeakSet(), _PersonalEquipmentManagementPageProcessor_renderImmutablePage = function _PersonalEquipmentManagementPageProcessor_renderImmutablePage(credential, page, context) {
    // 删除不必要的属性,可能会造成显示格式混乱。
    $("table[height='100%']").removeAttr("height");
    // 定位第一个表格
    const t0 = $("table:first")
        .attr("id", "t0");
    // 标题栏 : pageTitle
    t0.find("tr:first")
        .attr("id", "tr0")
        .find("td:first")
        .attr("id", "pageTitle")
        .removeAttr("width")
        .removeAttr("height")
        .removeAttr("bgcolor")
        .css("text-align", "center")
        .css("font-size", "150%")
        .css("font-weight", "bold")
        .css("background-color", "navy")
        .css("color", "yellowgreen")
        .html(this.doGeneratePageTitleHtml(context));
    $("#tr0")
        .next()
        .attr("id", "tr1")
        .find("td:first")
        .find("table:first")
        .find("tr:first")
        .find("td:first")
        .attr("id", "roleImage")
        .next()
        .removeAttr("width")
        .css("width", "100%")
        .next().remove();
    $("#roleImage")
        .next()
        .find("table:first")
        .find("tr:first")
        .next()
        .find("td:eq(2)")
        .attr("id", "roleHealth")
        .next()
        .attr("id", "roleMana")
        .parent()
        .next()
        .find("td:last")
        .attr("id", "roleCash")
        .parent()
        .after($("" +
        "<tr>" +
        "<td style='background-color:#E0D0B0'>坐标点</td>" +
        "<td style='background-color:#E8E8D0;text-align:right;font-weight:bold;color:red' " +
        "colspan='5' id='roleLocation'>" + this.doGenerateRoleLocationHtml(context) + "</td>" +
        "</tr>" +
        ""));
    // ------------------------------------------------------------------------
    // 消息面板栏
    // ------------------------------------------------------------------------
    $("#tr1")
        .next()
        .attr("id", "tr2")
        .find("td:first")
        .attr("id", "messageBoardContainer")
        .removeAttr("height");
    MessageBoard_1.default.createMessageBoardStyleB("messageBoardContainer", NpcLoader_1.default.randomNpcImageHtml());
    $("#messageBoard")
        .css("background-color", "black")
        .css("color", "wheat");
    MessageBoard_1.default.resetMessageBoard(this.doGenerateWelcomeMessageHtml());
    // ------------------------------------------------------------------------
    // 隐藏表单栏
    // ------------------------------------------------------------------------
    let html = "";
    html += "<tr id='tr3' style='display:none'>";
    html += "<td id='hiddenFormContainer'>";
    html += "</td>";
    html += "</tr>";
    $("#tr2").after($(html));
    // ------------------------------------------------------------------------
    // 主菜单栏
    // ------------------------------------------------------------------------
    html = "";
    html += "<tr id='tr4'>";
    html += "<td style='background-color:#F8F0E0;text-align:center'>";
    html += "<input type='button' id='refreshButton' value='刷新装备管理'>&nbsp;&nbsp;&nbsp;";
    html += "<input type='button' id='returnButton' value='退出装备管理'>";
    html += "</td>";
    html += "</tr>";
    $("#tr3").after($(html));
    // ------------------------------------------------------------------------
    // 用于保存百宝袋和仓库的状态
    // ------------------------------------------------------------------------
    html = "";
    html += "<tr id='tr5' style='display:none'>";
    html += "<td>";
    html += "<div id='bagIndex'>-99</div>";
    html += "<div id='bagState'>off</div>"; // 仅限有百宝袋
    html += "<div id='warehouseState'>off</div>"; // 仅限城堡
    html += "</td>";
    html += "</tr>";
    $("#tr4").after($(html));
    // ------------------------------------------------------------------------
    // 装备栏目
    // ------------------------------------------------------------------------
    html = "";
    html += "<tr id='tr6' style='display:none'>";
    html += "<td id='equipmentList'></td>";
    html += "</tr>";
    $("#tr5").after($(html));
    // ------------------------------------------------------------------------
    // 百宝袋栏目(仅限有百宝袋)
    // ------------------------------------------------------------------------
    html = "";
    html += "<tr id='tr7' style='display:none'>";
    html += "<td id='bagList'></td>";
    html += "</tr>";
    $("#tr6").after($(html));
    // ------------------------------------------------------------------------
    // 仓库栏目(仅限城堡)
    // ------------------------------------------------------------------------
    html = "";
    html += "<tr id='tr8' style='display:none'>";
    html += "<td id='warehouseList'></td>";
    html += "</tr>";
    $("#tr7").after($(html));
    html = "";
    html += "<tr id='tr9' style='display:none'>";
    html += "<td id='consecrateFormContainer'></td>";
    html += "</tr>";
    $("#tr8").after($(html));
    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_instances, "m", _PersonalEquipmentManagementPageProcessor_bindImmutableButtons).call(this, credential, context);
    this.doBeforeRenderMutablePage(credential, context);
    this.doRenderMutablePage(credential, page, context);
}, _PersonalEquipmentManagementPageProcessor_bindImmutableButtons = function _PersonalEquipmentManagementPageProcessor_bindImmutableButtons(credential, context) {
    this.doBindReturnButton(credential);
    $("#refreshButton").on("click", () => {
        this.doScrollToPageTitle();
        $("#messageBoardManager").html(NpcLoader_1.default.randomNpcImageHtml());
        MessageBoard_1.default.resetMessageBoard(this.doGenerateWelcomeMessageHtml());
        this.doRefreshMutablePage(credential, context);
    });
};
module.exports = PersonalEquipmentManagementPageProcessor;


/***/ }),
/* 150 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalEquipmentManagementPageProcessor_Map_instances, _PersonalEquipmentManagementPageProcessor_Map_bindSelectPersonalButton, _PersonalEquipmentManagementPageProcessor_Map_bindUseButton, _PersonalEquipmentManagementPageProcessor_Map_bindStoreButton, _PersonalEquipmentManagementPageProcessor_Map_bindOpenBagButton, _PersonalEquipmentManagementPageProcessor_Map_bindCloseBagButton, _PersonalEquipmentManagementPageProcessor_Map_doRenderStorageEquipmentList, _PersonalEquipmentManagementPageProcessor_Map_bindSelectStorageButton, _PersonalEquipmentManagementPageProcessor_Map_bindTakeOutButton, _PersonalEquipmentManagementPageProcessor_Map_bindSetButton;
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const EquipmentSet_1 = __importDefault(__webpack_require__(151));
const EquipmentSetLoader_1 = __importDefault(__webpack_require__(152));
const PersonalEquipmentManagement_1 = __importDefault(__webpack_require__(61));
const TreasureBag_1 = __importDefault(__webpack_require__(65));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PersonalEquipmentManagementPageProcessor_1 = __importDefault(__webpack_require__(149));
class PersonalEquipmentManagementPageProcessor_Map extends PersonalEquipmentManagementPageProcessor_1.default {
    constructor() {
        super(...arguments);
        _PersonalEquipmentManagementPageProcessor_Map_instances.add(this);
    }
    doGeneratePageTitleHtml(context) {
        return "<<  装 备 管 理 ( 地 图 模 式 )  >>";
    }
    doGenerateRoleLocationHtml(context) {
        if (context === undefined) {
            return "野外";
        }
        else {
            return context.get("coordinate");
        }
    }
    doGenerateWelcomeMessageHtml() {
        return "<b style='font-size:120%;color:wheat'>真是难为您了,在野外还不忘捯饬您这些破烂。</b>";
    }
    doBindReturnButton(credential) {
        const html = PageUtils_1.default.generateReturnMapForm(credential);
        $("#hiddenFormContainer").html(html);
        $("#returnButton").on("click", () => {
            $("#returnMap").trigger("click");
        });
    }
    doRenderMutablePage(credential, page, context) {
        const treasureBag = page.findTreasureBag();
        let html = "";
        html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:darkred;color:wheat;font-weight:bold;font-size:120%;text-align:center' colspan='20'>< 随 身 装 备 ></td>";
        html += "</tr>";
        html += "<tr>";
        html += "<th style='background-color:#E8E8D0'>选择</th>";
        html += "<th style='background-color:#EFE0C0'>装备</th>";
        html += "<th style='background-color:#E0D0B0'>名字</th>";
        html += "<th style='background-color:#EFE0C0'>种类</th>";
        html += "<th style='background-color:#E0D0B0'>效果</th>";
        html += "<th style='background-color:#EFE0C0'>重量</th>";
        html += "<th style='background-color:#EFE0C0'>耐久</th>";
        html += "<th style='background-color:#E0D0B0'>职需</th>";
        html += "<th style='background-color:#E0D0B0'>攻需</th>";
        html += "<th style='background-color:#E0D0B0'>防需</th>";
        html += "<th style='background-color:#E0D0B0'>智需</th>";
        html += "<th style='background-color:#E0D0B0'>精需</th>";
        html += "<th style='background-color:#E0D0B0'>速需</th>";
        html += "<th style='background-color:#EFE0C0'>威+</th>";
        html += "<th style='background-color:#EFE0C0'>重+</th>";
        html += "<th style='background-color:#EFE0C0'>幸+</th>";
        html += "<th style='background-color:#E0D0B0'>经验</th>";
        html += "<th style='background-color:#EFE0C0'>属性</th>";
        html += "<th style='background-color:#E8E8D0'>使用</th>";
        html += "<th style='background-color:#E8E8D0'>入袋</th>";
        html += "</tr>";
        for (const equipment of page.equipmentList) {
            if (equipment.isGoldenCage || equipment.isTreasureBag) {
                continue;
            }
            html += "<tr>";
            html += "<td style='background-color:#E8E8D0'>";
            if (equipment.selectable) {
                html += "<input type='button' " +
                    "value='选择' " +
                    "style='color:grey' " +
                    "id='selectPersonal_" + equipment.index + "' " +
                    "class='mutableButton-1'>";
            }
            html += "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.usingHTML + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.nameHTML + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.category + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.power + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.weight + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.endureHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredCareerHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredAttackHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredDefenseHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialAttackHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialDefenseHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpeedHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalPowerHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalWeightHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalLuckHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.experienceHTML + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.attributeHtml + "</td>";
            html += "<td style='background-color:#E8E8D0'>";
            if (equipment.selectable) {
                html += "<input type='button' " +
                    "value='" + equipment.buttonTitle + "' " +
                    "id='use_" + equipment.index + "' " +
                    "class='mutableButton-1'>";
            }
            html += "</td>";
            html += "<td style='background-color:#E8E8D0'>";
            if (treasureBag !== null && equipment.selectable && !equipment.using) {
                html += "<input type='button' " +
                    "value='入袋' " +
                    "id='store_" + equipment.index + "' " +
                    "class='mutableButton-1'>";
            }
            html += "</td>";
            html += "</tr>";
        }
        // ------------------------------------------------------------------------
        // 装备菜单栏
        // ------------------------------------------------------------------------
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;text-align:center' colspan='20'>";
        html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='text-align:left'>";
        html += "<input type='button' id='use' class='mutableButton-1' value='使用装备'>";
        html += "<input type='button' id='bag' class='mutableButton-1' value='放入百宝袋'>";
        html += "</td>";
        html += "<td style='text-align:right'>";
        html += "<input type='button' id='openBag' class='mutableButton-1' value='打开百宝袋'>";
        html += "<input type='button' id='closeBag' class='mutableButton-1' value='关闭百宝袋'>";
        html += "</td>";
        html += "</tr>";
        html += "<tr>";
        html += "<td style='text-align:right' colspan='2'>";
        html += "<input type='button' class='mutableButton-1' id='setButton_A' value='套装A' disabled>";
        html += "<input type='button' class='mutableButton-1' id='setButton_B' value='套装B' disabled>";
        html += "<input type='button' class='mutableButton-1' id='setButton_C' value='套装C' disabled>";
        html += "<input type='button' class='mutableButton-1' id='setButton_D' value='套装D' disabled>";
        html += "<input type='button' class='mutableButton-1' id='setButton_E' value='套装E' disabled>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#equipmentList").html(html).parent().show();
        if (treasureBag === null) {
            $("#bag").prop("disabled", true).hide();
            $("#openBag").prop("disabled", true).hide();
            $("#closeBag").prop("disabled", true).hide();
        }
        else {
            if ($("#bagState").text() === "on") {
                $("#openBag").prop("disabled", true);
            }
            else {
                $("#closeBag").prop("disabled", true);
            }
        }
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindSelectPersonalButton).call(this);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindUseButton).call(this, credential, context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindStoreButton).call(this, credential, treasureBag, context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindOpenBagButton).call(this, credential, context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindCloseBagButton).call(this, credential, context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindSetButton).call(this, credential, page, "A", context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindSetButton).call(this, credential, page, "B", context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindSetButton).call(this, credential, page, "C", context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindSetButton).call(this, credential, page, "D", context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindSetButton).call(this, credential, page, "E", context);
        if (treasureBag !== null && $("#bagState").text() === "on") {
            __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_doRenderStorageEquipmentList).call(this, credential, treasureBag, context);
        }
    }
}
_PersonalEquipmentManagementPageProcessor_Map_instances = new WeakSet(), _PersonalEquipmentManagementPageProcessor_Map_bindSelectPersonalButton = function _PersonalEquipmentManagementPageProcessor_Map_bindSelectPersonalButton() {
    $("input:button[value='选择']")
        .filter(function () {
        const buttonId = $(this).attr("id");
        return buttonId.startsWith("selectPersonal_");
    })
        .on("click", function () {
        const buttonId = $(this).attr("id");
        if (PageUtils_1.default.isColorGrey(buttonId)) {
            $(this).css("color", "blue");
        }
        else if (PageUtils_1.default.isColorBlue(buttonId)) {
            $(this).css("color", "grey");
        }
    });
}, _PersonalEquipmentManagementPageProcessor_Map_bindUseButton = function _PersonalEquipmentManagementPageProcessor_Map_bindUseButton(credential, context) {
    const instance = this;
    for (let i = 0; i < 20; i++) {
        const buttonId = "use_" + i;
        if ($("#" + buttonId).length === 0) {
            continue;
        }
        $("#" + buttonId).on("click", function () {
            new PersonalEquipmentManagement_1.default(credential)
                .use([i])
                .then(() => {
                instance.doRefreshMutablePage(credential, context);
            });
        });
    }
    $("#use").on("click", function () {
        const indexList = [];
        $("input:button[value='选择']")
            .filter(function () {
            const buttonId = $(this).attr("id");
            return buttonId.startsWith("selectPersonal_");
        })
            .each(function (_idx, input) {
            const buttonId = $(input).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("没有选择装备或者物品!");
            return;
        }
        new PersonalEquipmentManagement_1.default(credential)
            .use(indexList)
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
}, _PersonalEquipmentManagementPageProcessor_Map_bindStoreButton = function _PersonalEquipmentManagementPageProcessor_Map_bindStoreButton(credential, treasureBag, context) {
    if (treasureBag === null) {
        return;
    }
    const instance = this;
    $("input:button[value='入袋']").on("click", function () {
        const buttonId = $(this).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
        new TreasureBag_1.default(credential)
            .putInto([index])
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
    $("#bag").on("click", function () {
        const indexList = [];
        $("input:button[value='选择']")
            .filter(function () {
            const buttonId = $(this).attr("id");
            return buttonId.startsWith("selectPersonal_");
        })
            .each(function (_idx, input) {
            const buttonId = $(input).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("没有选择装备或者物品!");
            return;
        }
        new TreasureBag_1.default(credential)
            .putInto(indexList)
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
}, _PersonalEquipmentManagementPageProcessor_Map_bindOpenBagButton = function _PersonalEquipmentManagementPageProcessor_Map_bindOpenBagButton(credential, context) {
    if ($("#openBag").prop("disabled")) {
        return;
    }
    const instance = this;
    $("#openBag").on("click", function () {
        $("#bagState").text("on");
        instance.doRefreshMutablePage(credential, context);
    });
}, _PersonalEquipmentManagementPageProcessor_Map_bindCloseBagButton = function _PersonalEquipmentManagementPageProcessor_Map_bindCloseBagButton(credential, context) {
    if ($("#closeBag").prop("disabled")) {
        return;
    }
    const instance = this;
    $("#closeBag").on("click", function () {
        $("#bagState").text("off");
        instance.doRefreshMutablePage(credential, context);
    });
}, _PersonalEquipmentManagementPageProcessor_Map_doRenderStorageEquipmentList = function _PersonalEquipmentManagementPageProcessor_Map_doRenderStorageEquipmentList(credential, treasureBag, context) {
    new TreasureBag_1.default(credential)
        .open(treasureBag.index)
        .then(bagPage => {
        const equipmentList = bagPage.sortedEquipmentList;
        if (equipmentList.length === 0) {
            // Nothing found in bag.
            return;
        }
        let html = "";
        html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:darkgreen;color:wheat;font-weight:bold;font-size:120%;text-align:center' colspan='11'>< 百 宝 袋 ></td>";
        html += "</tr>";
        html += "<tr>";
        html += "<th style='background-color:#E8E8D0'>选择</th>";
        html += "<th style='background-color:#E0D0B0'>名字</th>";
        html += "<th style='background-color:#EFE0C0'>种类</th>";
        html += "<th style='background-color:#E0D0B0'>效果</th>";
        html += "<th style='background-color:#EFE0C0'>重量</th>";
        html += "<th style='background-color:#EFE0C0'>耐久</th>";
        html += "<th style='background-color:#EFE0C0'>威+</th>";
        html += "<th style='background-color:#EFE0C0'>重+</th>";
        html += "<th style='background-color:#EFE0C0'>幸+</th>";
        html += "<th style='background-color:#E0D0B0'>经验</th>";
        html += "<th style='background-color:#E8E8D0'>取出</th>";
        html += "</tr>";
        for (const equipment of equipmentList) {
            html += "<tr>";
            html += "<td style='background-color:#E8E8D0'>";
            html += "<input type='button' " +
                "value='选择' " +
                "style='color:grey' " +
                "id='selectStorage_" + equipment.index + "' " +
                "class='mutableElement'>";
            html += "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.nameHTML + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.category + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.power + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.weight + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.endureHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalPowerHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalWeightHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalLuckHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.experienceHTML + "</td>";
            html += "<td style='background-color:#E8E8D0'>";
            html += "<input type='button' " +
                "value='取出' " +
                "id='takeOut_" + equipment.index + "' " +
                "class='mutableElement'>";
            html += "</td>";
            html += "</tr>";
        }
        // ----------------------------------------------------------------
        // 百宝袋菜单栏
        // ----------------------------------------------------------------
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;text-align:center' colspan='11'>";
        html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='text-align:left'>";
        html += "<input type='button' id='takeOut' class='mutableElement' value='取出百宝袋'>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#bagList").html(html).parent().show();
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindSelectStorageButton).call(this);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Map_instances, "m", _PersonalEquipmentManagementPageProcessor_Map_bindTakeOutButton).call(this, credential, treasureBag, context);
    });
}, _PersonalEquipmentManagementPageProcessor_Map_bindSelectStorageButton = function _PersonalEquipmentManagementPageProcessor_Map_bindSelectStorageButton() {
    $("input:button[value='选择']")
        .filter(function () {
        const buttonId = $(this).attr("id");
        return buttonId.startsWith("selectStorage_");
    })
        .on("click", function () {
        const buttonId = $(this).attr("id");
        if (PageUtils_1.default.isColorGrey(buttonId)) {
            $(this).css("color", "blue");
        }
        else if (PageUtils_1.default.isColorBlue(buttonId)) {
            $(this).css("color", "grey");
        }
    });
}, _PersonalEquipmentManagementPageProcessor_Map_bindTakeOutButton = function _PersonalEquipmentManagementPageProcessor_Map_bindTakeOutButton(credential, treasureBag, context) {
    const instance = this;
    $("input:button[value='取出']").on("click", function () {
        const buttonId = $(this).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
        new TreasureBag_1.default(credential)
            .takeOut([index])
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
    $("#takeOut").on("click", function () {
        const indexList = [];
        $("input:button[value='选择']")
            .filter(function () {
            const buttonId = $(this).attr("id");
            return buttonId.startsWith("selectStorage_");
        })
            .each(function (_idx, input) {
            const buttonId = $(input).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            instance.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有选择装备或者物品!");
            return;
        }
        new TreasureBag_1.default(credential)
            .takeOut(indexList)
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
}, _PersonalEquipmentManagementPageProcessor_Map_bindSetButton = function _PersonalEquipmentManagementPageProcessor_Map_bindSetButton(credential, page, setId, context) {
    let setConfig = null;
    switch (setId) {
        case "A":
            setConfig = SetupLoader_1.default.loadEquipmentSet_A(credential.id);
            break;
        case "B":
            setConfig = SetupLoader_1.default.loadEquipmentSet_B(credential.id);
            break;
        case "C":
            setConfig = SetupLoader_1.default.loadEquipmentSet_C(credential.id);
            break;
        case "D":
            setConfig = SetupLoader_1.default.loadEquipmentSet_D(credential.id);
            break;
        case "E":
            setConfig = SetupLoader_1.default.loadEquipmentSet_E(credential.id);
            break;
        default:
            break;
    }
    if (!this.doCheckSetConfiguration(setConfig)) {
        return;
    }
    const buttonId = "setButton_" + setId;
    $("#" + buttonId).prop("disabled", false);
    // @ts-ignore
    if (setConfig["alias"] !== undefined) {
        // @ts-ignore
        $("#" + buttonId).val(setConfig["alias"]);
    }
    $("#" + buttonId).on("click", () => {
        const set = new EquipmentSet_1.default();
        set.initialize();
        // @ts-ignore
        set.weaponName = setConfig["weaponName"];
        // @ts-ignore
        if (setConfig["weaponStar"] !== undefined && setConfig["weaponStar"]) {
            set.weaponName = "齐心★" + set.weaponName;
        }
        // @ts-ignore
        set.armorName = setConfig["armorName"];
        // @ts-ignore
        if (setConfig["armorStar"] !== undefined && setConfig["armorStar"]) {
            set.armorName = "齐心★" + set.armorName;
        }
        // @ts-ignore
        set.accessoryName = setConfig["accessoryName"];
        // @ts-ignore
        if (setConfig["accessoryStar"] !== undefined && setConfig["accessoryStar"]) {
            set.accessoryName = "齐心★" + set.accessoryName;
        }
        new EquipmentSetLoader_1.default(credential, page.equipmentList).load(set)
            .then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
};
module.exports = PersonalEquipmentManagementPageProcessor_Map;


/***/ }),
/* 151 */
/***/ ((module) => {

"use strict";

class EquipmentSet {
    initialize() {
        this.weaponName = undefined;
        this.weaponIndex = undefined;
        this.weaponUsing = undefined;
        this.armorName = undefined;
        this.armorIndex = undefined;
        this.armorUsing = undefined;
        this.accessoryName = undefined;
        this.accessoryIndex = undefined;
        this.accessoryUsing = undefined;
        this.treasureBagIndex = undefined;
    }
    get isAllFound() {
        if (this.weaponName !== undefined && this.weaponIndex === undefined) {
            return false;
        }
        if (this.armorName !== undefined && this.armorIndex === undefined) {
            return false;
        }
        return !(this.accessoryName !== undefined && this.accessoryIndex === undefined);
    }
}
module.exports = EquipmentSet;


/***/ }),
/* 152 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _EquipmentSetLoader_credential, _EquipmentSetLoader_equipmentList;
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const NetworkUtils_1 = __importDefault(__webpack_require__(45));
const PersonalEquipmentManagement_1 = __importDefault(__webpack_require__(61));
const TreasureBag_1 = __importDefault(__webpack_require__(65));
class EquipmentSetLoader {
    constructor(credential, equipmentList) {
        _EquipmentSetLoader_credential.set(this, void 0);
        _EquipmentSetLoader_equipmentList.set(this, void 0);
        __classPrivateFieldSet(this, _EquipmentSetLoader_credential, credential, "f");
        __classPrivateFieldSet(this, _EquipmentSetLoader_equipmentList, equipmentList, "f");
    }
    load(set) {
        return __awaiter(this, void 0, void 0, function* () {
            const action = (credential, equipmentList, set) => {
                return new Promise(resolve => {
                    set = doScanEquipmentSet(equipmentList, set);
                    // 在自身完成了检索
                    if (!set.isAllFound && set.treasureBagIndex !== undefined) {
                        // 没有找全,有百宝袋,进继续找。
                        const treasureBag = new TreasureBag_1.default(credential);
                        treasureBag.open(set.treasureBagIndex)
                            .then(bagPage => {
                            const bagEquipmentList = bagPage.equipmentList;
                            const candidateIndexList = [];
                            if (set.weaponName !== undefined && set.weaponIndex === undefined) {
                                for (const bit of bagEquipmentList) {
                                    if (bit.isWeapon && bit.fullName === set.weaponName) {
                                        MessageBoard_1.default.publishMessage("在百宝袋中找到了武器:" + bit.nameHTML);
                                        candidateIndexList.push(bit.index);
                                        break;
                                    }
                                }
                            }
                            if (set.armorName !== undefined && set.armorIndex === undefined) {
                                for (const bit of bagEquipmentList) {
                                    if (bit.isArmor && bit.fullName === set.armorName) {
                                        MessageBoard_1.default.publishMessage("在百宝袋中找到了防具:" + bit.nameHTML);
                                        candidateIndexList.push(bit.index);
                                        break;
                                    }
                                }
                            }
                            if (set.accessoryName !== undefined && set.accessoryIndex === undefined) {
                                for (const bit of bagEquipmentList) {
                                    if (bit.isAccessory && bit.fullName === set.accessoryName) {
                                        MessageBoard_1.default.publishMessage("在百宝袋中找到了饰品:" + bit.nameHTML);
                                        candidateIndexList.push(bit.index);
                                        break;
                                    }
                                }
                            }
                            if (candidateIndexList.length > 0) {
                                // 在百宝袋中找到了需要的装备,准备拿出来
                                treasureBag.takeOut(candidateIndexList).then(() => {
                                    new PersonalEquipmentManagement_1.default(credential).open().then(newPage => {
                                        const newEquipmentList = newPage.equipmentList;
                                        set = doScanEquipmentSet(newEquipmentList, set);
                                        doLoadEquipmentSet(credential, set, resolve);
                                    });
                                });
                            }
                            else {
                                // 在百宝袋中没有找到需要的装备
                                doLoadEquipmentSet(credential, set, resolve);
                            }
                        });
                    }
                    else {
                        doLoadEquipmentSet(credential, set, resolve);
                    }
                });
            };
            return yield action(__classPrivateFieldGet(this, _EquipmentSetLoader_credential, "f"), __classPrivateFieldGet(this, _EquipmentSetLoader_equipmentList, "f"), set);
        });
    }
}
_EquipmentSetLoader_credential = new WeakMap(), _EquipmentSetLoader_equipmentList = new WeakMap();
function doScanEquipmentSet(equipmentList, set) {
    for (const it of equipmentList) {
        if (it.isTreasureBag) {
            set.treasureBagIndex = it.index;
        }
        if (set.weaponName !== undefined) {
            if (it.isWeapon && it.fullName === set.weaponName) {
                MessageBoard_1.default.publishMessage("在身上找到了武器:" + it.nameHTML);
                set.weaponIndex = it.index;
                set.weaponUsing = it.using;
            }
        }
        if (set.armorName !== undefined) {
            if (it.isArmor && it.fullName === set.armorName) {
                MessageBoard_1.default.publishMessage("在身上找到了防具:" + it.nameHTML);
                set.armorIndex = it.index;
                set.armorUsing = it.using;
            }
        }
        if (set.accessoryName !== undefined) {
            if (it.isAccessory && it.fullName === set.accessoryName) {
                MessageBoard_1.default.publishMessage("在身上找到了饰品:" + it.nameHTML);
                set.accessoryIndex = it.index;
                set.accessoryUsing = it.using;
            }
        }
    }
    return set;
}
function doLoadEquipmentSet(credential, set, resolve) {
    const request = credential.asRequest();
    // @ts-ignore
    request["chara"] = "1";
    // @ts-ignore
    request["mode"] = "USE";
    let count = 0;
    if (set.weaponIndex !== undefined && set.weaponUsing !== undefined && !set.weaponUsing) {
        count++;
        // @ts-ignore
        request["item" + set.weaponIndex] = set.weaponIndex;
    }
    if (set.armorIndex !== undefined && set.armorUsing !== undefined && !set.armorUsing) {
        count++;
        // @ts-ignore
        request["item" + set.armorIndex] = set.armorIndex;
    }
    if (set.accessoryIndex !== undefined && set.accessoryUsing !== undefined && !set.accessoryUsing) {
        count++;
        // @ts-ignore
        request["item" + set.accessoryIndex] = set.accessoryIndex;
    }
    if (count === 0) {
        MessageBoard_1.default.publishMessage("没有找到对应的装备或者正在装备中,忽略。");
        resolve();
    }
    else {
        NetworkUtils_1.default.sendPostRequest("mydata.cgi", request, function (html) {
            MessageBoard_1.default.processResponseMessage(html);
            resolve();
        });
    }
}
module.exports = EquipmentSetLoader;


/***/ }),
/* 153 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalEquipmentManagementPageProcessor_Metro_instances, _PersonalEquipmentManagementPageProcessor_Metro_bindSelectPersonalButton, _PersonalEquipmentManagementPageProcessor_Metro_bindUseButton, _PersonalEquipmentManagementPageProcessor_Metro_bindStoreButton, _PersonalEquipmentManagementPageProcessor_Metro_bindOpenBagButton, _PersonalEquipmentManagementPageProcessor_Metro_bindCloseBagButton, _PersonalEquipmentManagementPageProcessor_Metro_doRenderStorageEquipmentList, _PersonalEquipmentManagementPageProcessor_Metro_bindSelectStorageButton, _PersonalEquipmentManagementPageProcessor_Metro_bindTakeOutButton, _PersonalEquipmentManagementPageProcessor_Metro_bindSetButton;
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const EquipmentSet_1 = __importDefault(__webpack_require__(151));
const EquipmentSetLoader_1 = __importDefault(__webpack_require__(152));
const PersonalEquipmentManagement_1 = __importDefault(__webpack_require__(61));
const TreasureBag_1 = __importDefault(__webpack_require__(65));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PersonalEquipmentManagementPageProcessor_1 = __importDefault(__webpack_require__(149));
class PersonalEquipmentManagementPageProcessor_Metro extends PersonalEquipmentManagementPageProcessor_1.default {
    constructor() {
        super(...arguments);
        _PersonalEquipmentManagementPageProcessor_Metro_instances.add(this);
    }
    doGeneratePageTitleHtml(context) {
        return "<<  装 备 管 理 ( 地 铁 区 域 )  >>";
    }
    doGenerateRoleLocationHtml(context) {
        return "地铁区域";
    }
    doGenerateWelcomeMessageHtml() {
        return "<b style='font-size:120%;color:wheat'>真是难为您了,在野外还不忘捯饬您这些破烂。</b>";
    }
    doBindReturnButton(credential) {
        const html = PageUtils_1.default.generateReturnMapForm(credential);
        $("#hiddenFormContainer").html(html);
        $("#returnButton").on("click", () => {
            $("#returnMap").trigger("click");
        });
    }
    doRenderMutablePage(credential, page, context) {
        const treasureBag = page.findTreasureBag();
        let html = "";
        html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:darkred;color:wheat;font-weight:bold;font-size:120%;text-align:center' colspan='20'>< 随 身 装 备 ></td>";
        html += "</tr>";
        html += "<tr>";
        html += "<th style='background-color:#E8E8D0'>选择</th>";
        html += "<th style='background-color:#EFE0C0'>装备</th>";
        html += "<th style='background-color:#E0D0B0'>名字</th>";
        html += "<th style='background-color:#EFE0C0'>种类</th>";
        html += "<th style='background-color:#E0D0B0'>效果</th>";
        html += "<th style='background-color:#EFE0C0'>重量</th>";
        html += "<th style='background-color:#EFE0C0'>耐久</th>";
        html += "<th style='background-color:#E0D0B0'>职需</th>";
        html += "<th style='background-color:#E0D0B0'>攻需</th>";
        html += "<th style='background-color:#E0D0B0'>防需</th>";
        html += "<th style='background-color:#E0D0B0'>智需</th>";
        html += "<th style='background-color:#E0D0B0'>精需</th>";
        html += "<th style='background-color:#E0D0B0'>速需</th>";
        html += "<th style='background-color:#EFE0C0'>威+</th>";
        html += "<th style='background-color:#EFE0C0'>重+</th>";
        html += "<th style='background-color:#EFE0C0'>幸+</th>";
        html += "<th style='background-color:#E0D0B0'>经验</th>";
        html += "<th style='background-color:#EFE0C0'>属性</th>";
        html += "<th style='background-color:#E8E8D0'>使用</th>";
        html += "<th style='background-color:#E8E8D0'>入袋</th>";
        html += "</tr>";
        for (const equipment of page.equipmentList) {
            if (equipment.isGoldenCage || equipment.isTreasureBag) {
                continue;
            }
            html += "<tr>";
            html += "<td style='background-color:#E8E8D0'>";
            if (equipment.selectable) {
                html += "<input type='button' " +
                    "value='选择' " +
                    "style='color:grey' " +
                    "id='selectPersonal_" + equipment.index + "' " +
                    "class='mutableButton-1'>";
            }
            html += "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.usingHTML + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.nameHTML + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.category + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.power + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.weight + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.endureHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredCareerHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredAttackHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredDefenseHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialAttackHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialDefenseHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpeedHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalPowerHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalWeightHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalLuckHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.experienceHTML + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.attributeHtml + "</td>";
            html += "<td style='background-color:#E8E8D0'>";
            if (equipment.selectable) {
                html += "<input type='button' " +
                    "value='" + equipment.buttonTitle + "' " +
                    "id='use_" + equipment.index + "' " +
                    "class='mutableButton-1'>";
            }
            html += "</td>";
            html += "<td style='background-color:#E8E8D0'>";
            if (treasureBag !== null && equipment.selectable && !equipment.using) {
                html += "<input type='button' " +
                    "value='入袋' " +
                    "id='store_" + equipment.index + "' " +
                    "class='mutableButton-1'>";
            }
            html += "</td>";
            html += "</tr>";
        }
        // ------------------------------------------------------------------------
        // 装备菜单栏
        // ------------------------------------------------------------------------
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;text-align:center' colspan='20'>";
        html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='text-align:left'>";
        html += "<input type='button' id='use' class='mutableButton-1' value='使用装备'>";
        html += "<input type='button' id='bag' class='mutableButton-1' value='放入百宝袋'>";
        html += "</td>";
        html += "<td style='text-align:right'>";
        html += "<input type='button' id='openBag' class='mutableButton-1' value='打开百宝袋'>";
        html += "<input type='button' id='closeBag' class='mutableButton-1' value='关闭百宝袋'>";
        html += "</td>";
        html += "</tr>";
        html += "<tr>";
        html += "<td style='text-align:right' colspan='2'>";
        html += "<input type='button' class='mutableButton-1' id='setButton_A' value='套装A' disabled>";
        html += "<input type='button' class='mutableButton-1' id='setButton_B' value='套装B' disabled>";
        html += "<input type='button' class='mutableButton-1' id='setButton_C' value='套装C' disabled>";
        html += "<input type='button' class='mutableButton-1' id='setButton_D' value='套装D' disabled>";
        html += "<input type='button' class='mutableButton-1' id='setButton_E' value='套装E' disabled>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#equipmentList").html(html).parent().show();
        if (treasureBag === null) {
            $("#bag").prop("disabled", true).hide();
            $("#openBag").prop("disabled", true).hide();
            $("#closeBag").prop("disabled", true).hide();
        }
        else {
            if ($("#bagState").text() === "on") {
                $("#openBag").prop("disabled", true);
            }
            else {
                $("#closeBag").prop("disabled", true);
            }
        }
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindSelectPersonalButton).call(this);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindUseButton).call(this, credential, context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindStoreButton).call(this, credential, treasureBag, context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindOpenBagButton).call(this, credential, context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindCloseBagButton).call(this, credential, context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindSetButton).call(this, credential, page, "A", context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindSetButton).call(this, credential, page, "B", context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindSetButton).call(this, credential, page, "C", context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindSetButton).call(this, credential, page, "D", context);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindSetButton).call(this, credential, page, "E", context);
        if (treasureBag !== null && $("#bagState").text() === "on") {
            __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_doRenderStorageEquipmentList).call(this, credential, treasureBag, context);
        }
    }
}
_PersonalEquipmentManagementPageProcessor_Metro_instances = new WeakSet(), _PersonalEquipmentManagementPageProcessor_Metro_bindSelectPersonalButton = function _PersonalEquipmentManagementPageProcessor_Metro_bindSelectPersonalButton() {
    $("input:button[value='选择']")
        .filter(function () {
        const buttonId = $(this).attr("id");
        return buttonId.startsWith("selectPersonal_");
    })
        .on("click", function () {
        const buttonId = $(this).attr("id");
        if (PageUtils_1.default.isColorGrey(buttonId)) {
            $(this).css("color", "blue");
        }
        else if (PageUtils_1.default.isColorBlue(buttonId)) {
            $(this).css("color", "grey");
        }
    });
}, _PersonalEquipmentManagementPageProcessor_Metro_bindUseButton = function _PersonalEquipmentManagementPageProcessor_Metro_bindUseButton(credential, context) {
    const instance = this;
    for (let i = 0; i < 20; i++) {
        const buttonId = "use_" + i;
        if ($("#" + buttonId).length === 0) {
            continue;
        }
        $("#" + buttonId).on("click", function () {
            new PersonalEquipmentManagement_1.default(credential)
                .use([i])
                .then(() => {
                instance.doRefreshMutablePage(credential, context);
            });
        });
    }
    $("#use").on("click", function () {
        const indexList = [];
        $("input:button[value='选择']")
            .filter(function () {
            const buttonId = $(this).attr("id");
            return buttonId.startsWith("selectPersonal_");
        })
            .each(function (_idx, input) {
            const buttonId = $(input).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("没有选择装备或者物品!");
            return;
        }
        new PersonalEquipmentManagement_1.default(credential)
            .use(indexList)
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
}, _PersonalEquipmentManagementPageProcessor_Metro_bindStoreButton = function _PersonalEquipmentManagementPageProcessor_Metro_bindStoreButton(credential, treasureBag, context) {
    if (treasureBag === null) {
        return;
    }
    const instance = this;
    $("input:button[value='入袋']").on("click", function () {
        const buttonId = $(this).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
        new TreasureBag_1.default(credential)
            .putInto([index])
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
    $("#bag").on("click", function () {
        const indexList = [];
        $("input:button[value='选择']")
            .filter(function () {
            const buttonId = $(this).attr("id");
            return buttonId.startsWith("selectPersonal_");
        })
            .each(function (_idx, input) {
            const buttonId = $(input).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            PageUtils_1.default.scrollIntoView("pageTitle");
            MessageBoard_1.default.publishWarning("没有选择装备或者物品!");
            return;
        }
        new TreasureBag_1.default(credential)
            .putInto(indexList)
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
}, _PersonalEquipmentManagementPageProcessor_Metro_bindOpenBagButton = function _PersonalEquipmentManagementPageProcessor_Metro_bindOpenBagButton(credential, context) {
    if ($("#openBag").prop("disabled")) {
        return;
    }
    const instance = this;
    $("#openBag").on("click", function () {
        $("#bagState").text("on");
        instance.doRefreshMutablePage(credential, context);
    });
}, _PersonalEquipmentManagementPageProcessor_Metro_bindCloseBagButton = function _PersonalEquipmentManagementPageProcessor_Metro_bindCloseBagButton(credential, context) {
    if ($("#closeBag").prop("disabled")) {
        return;
    }
    const instance = this;
    $("#closeBag").on("click", function () {
        $("#bagState").text("off");
        instance.doRefreshMutablePage(credential, context);
    });
}, _PersonalEquipmentManagementPageProcessor_Metro_doRenderStorageEquipmentList = function _PersonalEquipmentManagementPageProcessor_Metro_doRenderStorageEquipmentList(credential, treasureBag, context) {
    new TreasureBag_1.default(credential)
        .open(treasureBag.index)
        .then(bagPage => {
        const equipmentList = bagPage.sortedEquipmentList;
        if (equipmentList.length === 0) {
            // Nothing found in bag.
            return;
        }
        let html = "";
        html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:darkgreen;color:wheat;font-weight:bold;font-size:120%;text-align:center' colspan='11'>< 百 宝 袋 ></td>";
        html += "</tr>";
        html += "<tr>";
        html += "<th style='background-color:#E8E8D0'>选择</th>";
        html += "<th style='background-color:#E0D0B0'>名字</th>";
        html += "<th style='background-color:#EFE0C0'>种类</th>";
        html += "<th style='background-color:#E0D0B0'>效果</th>";
        html += "<th style='background-color:#EFE0C0'>重量</th>";
        html += "<th style='background-color:#EFE0C0'>耐久</th>";
        html += "<th style='background-color:#EFE0C0'>威+</th>";
        html += "<th style='background-color:#EFE0C0'>重+</th>";
        html += "<th style='background-color:#EFE0C0'>幸+</th>";
        html += "<th style='background-color:#E0D0B0'>经验</th>";
        html += "<th style='background-color:#E8E8D0'>取出</th>";
        html += "</tr>";
        for (const equipment of equipmentList) {
            html += "<tr>";
            html += "<td style='background-color:#E8E8D0'>";
            html += "<input type='button' " +
                "value='选择' " +
                "style='color:grey' " +
                "id='selectStorage_" + equipment.index + "' " +
                "class='mutableElement'>";
            html += "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.nameHTML + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.category + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.power + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.weight + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.endureHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalPowerHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalWeightHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalLuckHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.experienceHTML + "</td>";
            html += "<td style='background-color:#E8E8D0'>";
            html += "<input type='button' " +
                "value='取出' " +
                "id='takeOut_" + equipment.index + "' " +
                "class='mutableElement'>";
            html += "</td>";
            html += "</tr>";
        }
        // ----------------------------------------------------------------
        // 百宝袋菜单栏
        // ----------------------------------------------------------------
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;text-align:center' colspan='11'>";
        html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='text-align:left'>";
        html += "<input type='button' id='takeOut' class='mutableElement' value='取出百宝袋'>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#bagList").html(html).parent().show();
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindSelectStorageButton).call(this);
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Metro_instances, "m", _PersonalEquipmentManagementPageProcessor_Metro_bindTakeOutButton).call(this, credential, treasureBag, context);
    });
}, _PersonalEquipmentManagementPageProcessor_Metro_bindSelectStorageButton = function _PersonalEquipmentManagementPageProcessor_Metro_bindSelectStorageButton() {
    $("input:button[value='选择']")
        .filter(function () {
        const buttonId = $(this).attr("id");
        return buttonId.startsWith("selectStorage_");
    })
        .on("click", function () {
        const buttonId = $(this).attr("id");
        if (PageUtils_1.default.isColorGrey(buttonId)) {
            $(this).css("color", "blue");
        }
        else if (PageUtils_1.default.isColorBlue(buttonId)) {
            $(this).css("color", "grey");
        }
    });
}, _PersonalEquipmentManagementPageProcessor_Metro_bindTakeOutButton = function _PersonalEquipmentManagementPageProcessor_Metro_bindTakeOutButton(credential, treasureBag, context) {
    const instance = this;
    $("input:button[value='取出']").on("click", function () {
        const buttonId = $(this).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
        new TreasureBag_1.default(credential)
            .takeOut([index])
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
    $("#takeOut").on("click", function () {
        const indexList = [];
        $("input:button[value='选择']")
            .filter(function () {
            const buttonId = $(this).attr("id");
            return buttonId.startsWith("selectStorage_");
        })
            .each(function (_idx, input) {
            const buttonId = $(input).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfter(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            instance.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有选择装备或者物品!");
            return;
        }
        new TreasureBag_1.default(credential)
            .takeOut(indexList)
            .then(() => {
            instance.doRefreshMutablePage(credential, context);
        });
    });
}, _PersonalEquipmentManagementPageProcessor_Metro_bindSetButton = function _PersonalEquipmentManagementPageProcessor_Metro_bindSetButton(credential, page, setId, context) {
    let setConfig = null;
    switch (setId) {
        case "A":
            setConfig = SetupLoader_1.default.loadEquipmentSet_A(credential.id);
            break;
        case "B":
            setConfig = SetupLoader_1.default.loadEquipmentSet_B(credential.id);
            break;
        case "C":
            setConfig = SetupLoader_1.default.loadEquipmentSet_C(credential.id);
            break;
        case "D":
            setConfig = SetupLoader_1.default.loadEquipmentSet_D(credential.id);
            break;
        case "E":
            setConfig = SetupLoader_1.default.loadEquipmentSet_E(credential.id);
            break;
        default:
            break;
    }
    if (!this.doCheckSetConfiguration(setConfig)) {
        return;
    }
    const buttonId = "setButton_" + setId;
    $("#" + buttonId).prop("disabled", false);
    // @ts-ignore
    if (setConfig["alias"] !== undefined) {
        // @ts-ignore
        $("#" + buttonId).val(setConfig["alias"]);
    }
    $("#" + buttonId).on("click", () => {
        const set = new EquipmentSet_1.default();
        set.initialize();
        // @ts-ignore
        set.weaponName = setConfig["weaponName"];
        // @ts-ignore
        if (setConfig["weaponStar"] !== undefined && setConfig["weaponStar"]) {
            set.weaponName = "齐心★" + set.weaponName;
        }
        // @ts-ignore
        set.armorName = setConfig["armorName"];
        // @ts-ignore
        if (setConfig["armorStar"] !== undefined && setConfig["armorStar"]) {
            set.armorName = "齐心★" + set.armorName;
        }
        // @ts-ignore
        set.accessoryName = setConfig["accessoryName"];
        // @ts-ignore
        if (setConfig["accessoryStar"] !== undefined && setConfig["accessoryStar"]) {
            set.accessoryName = "齐心★" + set.accessoryName;
        }
        new EquipmentSetLoader_1.default(credential, page.equipmentList).load(set)
            .then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
};
module.exports = PersonalEquipmentManagementPageProcessor_Metro;


/***/ }),
/* 154 */
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _PersonalEquipmentManagementPageProcessor_Town_instances, _PersonalEquipmentManagementPageProcessor_Town_renderPersonalUI, _PersonalEquipmentManagementPageProcessor_Town_renderBagUI, _PersonalEquipmentManagementPageProcessor_Town_renderLostBagUI, _PersonalEquipmentManagementPageProcessor_Town_renderNormalBagUI, _PersonalEquipmentManagementPageProcessor_Town_bindSetButton, _PersonalEquipmentManagementPageProcessor_Town_renderWarehouseUI;
const TownBank_1 = __importDefault(__webpack_require__(43));
const SetupLoader_1 = __importDefault(__webpack_require__(20));
const CastleInformation_1 = __importDefault(__webpack_require__(55));
const TownDashboard_1 = __importDefault(__webpack_require__(155));
const CastleEquipmentExpressHouse_1 = __importDefault(__webpack_require__(147));
const CastleWarehouse_1 = __importDefault(__webpack_require__(58));
const Equipment_1 = __importDefault(__webpack_require__(60));
const EquipmentConsecrateManager_1 = __importDefault(__webpack_require__(160));
const EquipmentSet_1 = __importDefault(__webpack_require__(151));
const EquipmentSetLoader_1 = __importDefault(__webpack_require__(152));
const PersonalEquipmentManagement_1 = __importDefault(__webpack_require__(61));
const TownEquipmentExpressHouse_1 = __importDefault(__webpack_require__(163));
const TreasureBag_1 = __importDefault(__webpack_require__(65));
const TownForgeHouse_1 = __importDefault(__webpack_require__(165));
const NpcLoader_1 = __importDefault(__webpack_require__(27));
const PersonalStatus_1 = __importDefault(__webpack_require__(105));
const TeamMemberLoader_1 = __importDefault(__webpack_require__(117));
const TownLoader_1 = __importDefault(__webpack_require__(47));
const CommentBoard_1 = __importDefault(__webpack_require__(54));
const MessageBoard_1 = __importDefault(__webpack_require__(44));
const PageUtils_1 = __importDefault(__webpack_require__(14));
const StringUtils_1 = __importDefault(__webpack_require__(6));
const PersonalEquipmentManagementPageProcessor_1 = __importDefault(__webpack_require__(149));
class PersonalEquipmentManagementPageProcessor_Town extends PersonalEquipmentManagementPageProcessor_1.default {
    constructor() {
        super(...arguments);
        _PersonalEquipmentManagementPageProcessor_Town_instances.add(this);
    }
    doGeneratePageTitleHtml(context) {
        if (context === undefined) {
            return "<<  装 备 管 理 ( 城 市 模 式 )  >>";
        }
        else {
            const townId = context.get("townId");
            const town = TownLoader_1.default.load(townId);
            return "<<  装 备 管 理 ( " + (town === null || town === void 0 ? void 0 : town.nameTitle) + " )  >>";
        }
    }
    doGenerateRoleLocationHtml(context) {
        if (context === undefined) {
            return "城市";
        }
        else {
            const townId = context.get("townId");
            const town = TownLoader_1.default.load(townId);
            return town.name;
        }
    }
    doGenerateWelcomeMessageHtml() {
        return "<b style='font-size:120%;color:wheat'>又来管理您的装备来啦?就这点破烂折腾来折腾去的,您累不累啊。</b>";
    }
    doBindReturnButton(credential) {
        const html = PageUtils_1.default.generateReturnTownForm(credential);
        $("#hiddenFormContainer").html(html);
        $("#returnButton").on("click", () => {
            $("#returnTown").trigger("click");
        });
    }
    doBeforeRenderMutablePage(credential, context) {
        let html = "";
        // noinspection HtmlUnknownTarget
        html += "<form action='mydata.cgi' method='post'>";
        html += "<input type='hidden' name='id' value='" + credential.id + "'>";
        html += "<input type='hidden' name='pass' value='" + credential.pass + "'>";
        html += "<input type='hidden' name='chara' value='1'>";
        html += "<input type='hidden' name='mode' value='CONSECRATE'>";
        html += "<div id='consecrateItems'></div>";
        html += "<input type='submit' id='consecrateSubmit'>";
        html += "</form>";
        $("#consecrateFormContainer").html(html);
        CommentBoard_1.default.createCommentBoard(NpcLoader_1.default.getNpcImageHtml("饭饭"));
        CommentBoard_1.default.writeMessage("我就要一键祭奠,就要,就要!");
        CommentBoard_1.default.writeMessage("<input type='button' id='consecrateButton' value='祭奠选择的装备'>");
        $("#consecrateButton").hide();
        const instance = this;
        $("#consecrateButton").on("click", function () {
            const consecrateCandidates = [];
            const consecrateCandidateNames = [];
            $(".selectButton-1")
                .each(function (_idx, button) {
                const buttonId = $(button).attr("id");
                const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                if (PageUtils_1.default.isColorBlue(buttonId)) {
                    const c0 = $(button).parent();
                    const c1 = c0.next();
                    const c2 = c1.next();
                    const c3 = c2.next();
                    let s = c3.text().trim();
                    if (s === "武器" || s === "防具" || s === "饰品") {
                        s = c1.text().trim();
                        if (s !== "★") {
                            s = c2.text().trim();
                            consecrateCandidates.push(index);
                            consecrateCandidateNames.push(s);
                        }
                    }
                }
            });
            if (consecrateCandidates.length === 0) {
                MessageBoard_1.default.publishWarning("没有选择能够祭奠的装备!");
                return;
            }
            if (!confirm("请务必确认你将要祭奠的这些装备:" + consecrateCandidateNames.join())) {
                return;
            }
            const bank = new TownBank_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId"));
            bank.withdraw(100).then(() => {
                const ecm = new EquipmentConsecrateManager_1.default(credential);
                ecm.consecrate(consecrateCandidates, consecrateCandidateNames)
                    .then(() => {
                    bank.deposit().then(() => {
                        instance.doRefreshMutablePage(credential, context);
                    });
                });
            });
        });
        $("#p_3139").on("click", function () {
            $("#p_3139").off("click");
            new TownDashboard_1.default(credential).open().then(dashboardPage => {
                if (dashboardPage.role.canConsecrate) {
                    $("#consecrateButton").show();
                }
                else {
                    MessageBoard_1.default.publishWarning("祭奠还在冷却中!");
                }
            });
        });
    }
    doRenderMutablePage(credential, page, context) {
        const bag = page.findTreasureBag();
        if (bag !== null) {
            __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_renderPersonalUI).call(this, credential, page, bag.index, context);
        }
        else {
            // 已经掌握了剑圣职业,说明应该有百宝袋,但是因为某些bug导致百宝袋不可见了,
            // 还是提供有限的百宝袋功能吧,能够放入、取出,但是不能浏览了。
            // 如果有分身了,那也说明曾经掌握过剑圣职业,就算有百宝袋了
            new PersonalStatus_1.default(credential).load().then(role => {
                if (role.masterCareerList.includes("剑圣") || role.hasMirror) {
                    // 真的曾经拥有百宝袋,但是又因为某些bug失去了
                    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_renderPersonalUI).call(this, credential, page, -1, context);
                }
                else {
                    // 是真的没有百宝袋
                    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_renderPersonalUI).call(this, credential, page, -99, context);
                }
            });
        }
    }
}
_PersonalEquipmentManagementPageProcessor_Town_instances = new WeakSet(), _PersonalEquipmentManagementPageProcessor_Town_renderPersonalUI = function _PersonalEquipmentManagementPageProcessor_Town_renderPersonalUI(credential, page, bagIndex, context) {
    $("#bagIndex").text(bagIndex);
    let html = "";
    html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<td style='background-color:darkred;color:wheat;font-weight:bold;font-size:120%;text-align:center' " +
        "colspan='22'>< 随 身 装 备 ></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0'>选择</th>";
    html += "<th style='background-color:#EFE0C0'>装备</th>";
    html += "<th style='background-color:#E0D0B0'>名字</th>";
    html += "<th style='background-color:#EFE0C0'>种类</th>";
    html += "<th style='background-color:#E0D0B0'>效果</th>";
    html += "<th style='background-color:#EFE0C0'>重量</th>";
    html += "<th style='background-color:#EFE0C0'>耐久</th>";
    html += "<th style='background-color:#E0D0B0'>职需</th>";
    html += "<th style='background-color:#E0D0B0'>攻需</th>";
    html += "<th style='background-color:#E0D0B0'>防需</th>";
    html += "<th style='background-color:#E0D0B0'>智需</th>";
    html += "<th style='background-color:#E0D0B0'>精需</th>";
    html += "<th style='background-color:#E0D0B0'>速需</th>";
    html += "<th style='background-color:#EFE0C0'>威+</th>";
    html += "<th style='background-color:#EFE0C0'>重+</th>";
    html += "<th style='background-color:#EFE0C0'>幸+</th>";
    html += "<th style='background-color:#E0D0B0'>经验</th>";
    html += "<th style='background-color:#EFE0C0'>属性</th>";
    html += "<th style='background-color:#E8E8D0'>使用</th>";
    html += "<th style='background-color:#E8E8D0'>修理</th>";
    html += "<th style='background-color:#E8E8D0'>入袋</th>";
    html += "<th style='background-color:#E8E8D0'>发送</th>";
    html += "</tr>";
    for (const equipment of page.equipmentList) {
        if (equipment.isGoldenCage || equipment.isTreasureBag) {
            continue;
        }
        html += "<tr>";
        html += "<td style='background-color:#E8E8D0'>";
        if (equipment.selectable) {
            html += "<input type='button' value='选择' " +
                "style='color:grey' " +
                "class='mutableButton-1 selectButton-1' " +
                "id='selectButton_1_" + equipment.index + "'>";
        }
        html += "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.usingHTML + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.nameHTML + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.category + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.power + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.weight + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.endureHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredCareerHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredAttackHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredDefenseHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialAttackHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpecialDefenseHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.requiredSpeedHtml + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.additionalPowerHtml + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.additionalWeightHtml + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.additionalLuckHtml + "</td>";
        html += "<td style='background-color:#E0D0B0'>" + equipment.experienceHTML + "</td>";
        html += "<td style='background-color:#EFE0C0'>" + equipment.attributeHtml + "</td>";
        html += "<td style='background-color:#E8E8D0'>";
        if (equipment.selectable) {
            html += "<input type='button' value='" + equipment.buttonTitle + "' " +
                "class='mutableButton-1 useButton-1' " +
                "id='useButton_1_" + equipment.index + "'>";
        }
        html += "</td>";
        html += "<td style='background-color:#E8E8D0'>";
        if (equipment.isRepairable) {
            html += "<input type='button' value='修理' " +
                "class='mutableButton-1 repairButton-1' " +
                "id='repairButton_1_" + equipment.index + "'>";
        }
        html += "</td>";
        html += "<td style='background-color:#E8E8D0'>";
        if (equipment.selectable && !equipment.using && bagIndex >= -1) {
            html += "<input type='button' value='入袋' " +
                "class='mutableButton-1 storeButton-1' " +
                "id='storeButton_1_" + equipment.index + "'>";
        }
        html += "</td>";
        html += "<td style='background-color:#E8E8D0'>";
        html += "<input type='button' value='发送' " +
            "class='mutableButton-1 sendButton-1' " +
            "id='sendButton_1_" + equipment.index + "' disabled style='display:none'>";
        html += "</td>";
        html += "</tr>";
    }
    // ------------------------------------------------------------------------
    // 装备菜单栏
    // ------------------------------------------------------------------------
    html += "<tr>";
    html += "<td style='background-color:#F8F0E0;text-align:center' colspan='22'>";
    html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<td style='text-align:center;font-weight:bold' colspan='2'>";
    html += "<span style='color:navy'>目前剩余空位数:</span><span style='color:red'>" + page.spaceCount + "</span>";
    html += "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:left'>";
    html += "<input type='button' id='useButton' class='mutableButton-1' value='使用装备'>";
    html += "<input type='button' id='storeButton' class='mutableButton-1' value='放入百宝袋' disabled style='display:none'>";
    html += "</td>";
    html += "<td style='text-align:right'>";
    html += "<input type='button' id='openBagButton' class='mutableButton-1' value='打开百宝袋' disabled style='display:none'>";
    html += "<input type='button' id='closeBagButton' class='mutableButton-1' value='关闭百宝袋' disabled style='display:none'>";
    html += "<input type='button' id='openWarehouse' class='mutableButton-1' value='打开仓库' disabled style='display:none'>";
    html += "<input type='button' id='closeWarehouse' class='mutableButton-1' value='关闭仓库' disabled style='display:none'>";
    html += "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:right' colspan='2'>";
    const fastNames = TeamMemberLoader_1.default.loadTeamMembers().map(it => it.name);
    if (fastNames.length > 0) {
        html += "<select id='fastNameSelect' class='mutableButton-1'>";
        html += "<option value=''>快速选人</option>";
        for (const fastName of fastNames) {
            // noinspection JSDeprecatedSymbols
            const v = "fastName_" + escape(fastName);
            html += "<option value='" + v + "'>" + fastName + "</option>";
        }
        html += "</select>";
    }
    html += "<input type='text' id='searchName' size='15' maxlength='20'>";
    html += "<input type='button' id='searchButton' class='mutableButton-1' value='找人'>";
    html += "<select id='peopleSelect'><option value=''>选择发送对象</select>";
    html += "<input type='button' id='sendButton' class='mutableButton-1' value='发送'>";
    html += "</td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='text-align:right' colspan='2'>";
    html += "<input type='button' class='mutableButton-1' id='luckCharmButton' value='千与千寻' style='color:blue'>";
    html += "<input type='button' class='mutableButton-1' id='dontForgetMeButton' value='勿忘我' style='color:red'>";
    html += "<input type='button' class='mutableButton-1' id='magicBallButton' value='魔法使的闪光弹' style='color:green'>";
    html += "<input type='button' class='mutableButton-1' id='setButton_A' value='套装A' disabled>";
    html += "<input type='button' class='mutableButton-1' id='setButton_B' value='套装B' disabled>";
    html += "<input type='button' class='mutableButton-1' id='setButton_C' value='套装C' disabled>";
    html += "<input type='button' class='mutableButton-1' id='setButton_D' value='套装D' disabled>";
    html += "<input type='button' class='mutableButton-1' id='setButton_E' value='套装E' disabled>";
    html += "</td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    html += "</td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    $("#equipmentList").html(html).parent().show();
    if ($("#fastNameSelect").length > 0) {
        $("#fastNameSelect").on("change", () => {
            let s = $("#fastNameSelect").val();
            if (s === "") {
                return;
            }
            s = StringUtils_1.default.substringAfter(s, "fastName_");
            // noinspection JSDeprecatedSymbols
            s = unescape(s);
            $("#searchName").val(s);
            $("#searchButton").trigger("click");
        });
    }
    new CastleInformation_1.default().load(page.role.name).then(() => {
        $("#openWarehouse").prop("disabled", false).show();
        $("#closeWarehouse").prop("disabled", false).show();
        $("#openWarehouse").on("click", () => {
            if ($("#warehouseState").text() === "on") {
                return;
            }
            $("#warehouseState").text("on");
            __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_renderWarehouseUI).call(this, credential, page, context);
        });
        $("#closeWarehouse").on("click", () => {
            if ($("#warehouseState").text() === "off") {
                return;
            }
            $("#warehouseState").text("off");
            PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-3");
            $("#warehouseList").html("").parent().hide();
        });
    });
    // --------------------------------------------------------------------
    // 发送
    // --------------------------------------------------------------------
    new TownEquipmentExpressHouse_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId")).open().then(expressPage => {
        for (const equipment of expressPage.equipmentList) {
            const index = equipment.index;
            if (equipment.selectable) {
                $("#sendButton_1_" + index).prop("disabled", false).show();
            }
            else {
                $("#sendButton_1_" + index).remove();
            }
        }
        $(".sendButton-1").on("click", event => {
            const buttonId = $(event.target).attr("id");
            const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
            const s = $("#peopleSelect").val();
            if (s === undefined || s.trim() === "") {
                this.doScrollToPageTitle();
                MessageBoard_1.default.publishWarning("没有选择发送对象!");
                return;
            }
            const bank = new TownBank_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId"));
            bank.withdraw(10).then(() => {
                new TownEquipmentExpressHouse_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId")).send(s, [index]).then(() => {
                    bank.deposit().then(() => {
                        this.doRefreshMutablePage(credential, context);
                    });
                });
            });
        });
    });
    // --------------------------------------------------------------------
    // 选择
    // --------------------------------------------------------------------
    this.doBindSelectButtons("selectButton-1");
    // --------------------------------------------------------------------
    // 使用
    // --------------------------------------------------------------------
    $(".useButton-1").on("click", event => {
        const buttonId = $(event.target).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
        new PersonalEquipmentManagement_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId")).use([index]).then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    // --------------------------------------------------------------------
    // 修理
    // --------------------------------------------------------------------
    $(".repairButton-1").on("click", event => {
        const buttonId = $(event.target).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
        new TownForgeHouse_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId")).repair(index).then(() => {
            const equipment = page.findEquipment(index);
            MessageBoard_1.default.publishMessage("修理了" + equipment.fullName + "。");
            this.doRefreshMutablePage(credential, context);
        });
    });
    // --------------------------------------------------------------------
    // 入袋
    // --------------------------------------------------------------------
    $(".storeButton-1").on("click", event => {
        const buttonId = $(event.target).attr("id");
        const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
        new TreasureBag_1.default(credential).putInto([index]).then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    // --------------------------------------------------------------------
    // 找人
    // --------------------------------------------------------------------
    $("#searchButton").on("click", () => {
        const s = $("#searchName").val();
        if (s === undefined || s.trim() === "") {
            this.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有正确输入人名!");
            return;
        }
        new TownEquipmentExpressHouse_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId")).search(s).then(optionListHtml => {
            $("#peopleSelect").html(optionListHtml);
        });
    });
    // --------------------------------------------------------------------
    // 打开百宝袋 / 关闭百宝袋
    // --------------------------------------------------------------------
    if (bagIndex >= -1) {
        $("#openBagButton").prop("disabled", false).show();
        $("#closeBagButton").prop("disabled", false).show();
        $("#openBagButton").on("click", () => {
            if ($("#bagState").text() === "on") {
                return;
            }
            $("#bagState").text("on");
            __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_renderBagUI).call(this, credential, page, bagIndex, context);
        });
        $("#closeBagButton").on("click", () => {
            if ($("#bagState").text() === "off") {
                return;
            }
            $("#bagState").text("off");
            PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-2");
            $("#bagList").html("").parent().hide();
        });
    }
    // --------------------------------------------------------------------
    // 使用
    // --------------------------------------------------------------------
    $("#useButton").on("click", () => {
        const indexList = [];
        $(".selectButton-1").each((idx, button) => {
            const buttonId = $(button).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            this.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有选择物品或装备!");
            return;
        }
        new PersonalEquipmentManagement_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId")).use(indexList).then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    // --------------------------------------------------------------------
    // 放入百宝袋
    // --------------------------------------------------------------------
    if (bagIndex >= -1) {
        $("#storeButton").prop("disabled", false).show();
        $("#storeButton").on("click", () => {
            const indexList = [];
            $(".selectButton-1").each((idx, button) => {
                const buttonId = $(button).attr("id");
                if (PageUtils_1.default.isColorBlue(buttonId)) {
                    const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                    indexList.push(index);
                }
            });
            if (indexList.length === 0) {
                this.doScrollToPageTitle();
                MessageBoard_1.default.publishWarning("没有选择物品或装备!");
                return;
            }
            new TreasureBag_1.default(credential).putInto(indexList).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
    }
    // --------------------------------------------------------------------
    // 发送
    // --------------------------------------------------------------------
    $("#sendButton").on("click", () => {
        const indexList = [];
        $(".selectButton-1").each((idx, button) => {
            const buttonId = $(button).attr("id");
            if (PageUtils_1.default.isColorBlue(buttonId)) {
                const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                indexList.push(index);
            }
        });
        if (indexList.length === 0) {
            this.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有选择物品或装备!");
            return;
        }
        const s = $("#peopleSelect").val();
        if (s === undefined || s.trim() === "") {
            this.doScrollToPageTitle();
            MessageBoard_1.default.publishWarning("没有选择发送对象!");
            return;
        }
        const bank = new TownBank_1.default(credential, context === null || context === void 0 ? void 0 : context.get("townId"));
        bank.withdraw(10).then(() => {
            new CastleEquipmentExpressHouse_1.default(credential).send(s, indexList).then(() => {
                bank.deposit().then(() => {
                    this.doRefreshMutablePage(credential, context);
                });
            });
        });
    });
    $("#luckCharmButton").on("click", () => {
        const set = new EquipmentSet_1.default();
        set.initialize();
        set.accessoryName = "千与千寻";
        new EquipmentSetLoader_1.default(credential, page.equipmentList).load(set)
            .then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    $("#dontForgetMeButton").on("click", () => {
        const set = new EquipmentSet_1.default();
        set.initialize();
        set.accessoryName = "勿忘我";
        new EquipmentSetLoader_1.default(credential, page.equipmentList).load(set)
            .then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    $("#magicBallButton").on("click", () => {
        const set = new EquipmentSet_1.default();
        set.initialize();
        set.accessoryName = "魔法使的闪光弹";
        new EquipmentSetLoader_1.default(credential, page.equipmentList).load(set)
            .then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_bindSetButton).call(this, credential, page, "A", context);
    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_bindSetButton).call(this, credential, page, "B", context);
    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_bindSetButton).call(this, credential, page, "C", context);
    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_bindSetButton).call(this, credential, page, "D", context);
    __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_bindSetButton).call(this, credential, page, "E", context);
    if ($("#bagState").text() === "on") {
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_renderBagUI).call(this, credential, page, bagIndex, context);
    }
    if ($("#warehouseState").text() === "on") {
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_renderWarehouseUI).call(this, credential, page, context);
    }
}, _PersonalEquipmentManagementPageProcessor_Town_renderBagUI = function _PersonalEquipmentManagementPageProcessor_Town_renderBagUI(credential, page, bagIndex, context) {
    if (bagIndex < 0) {
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_renderLostBagUI).call(this, credential, page, context);
    }
    else {
        __classPrivateFieldGet(this, _PersonalEquipmentManagementPageProcessor_Town_instances, "m", _PersonalEquipmentManagementPageProcessor_Town_renderNormalBagUI).call(this, credential, page, bagIndex, context);
    }
}, _PersonalEquipmentManagementPageProcessor_Town_renderLostBagUI = function _PersonalEquipmentManagementPageProcessor_Town_renderLostBagUI(credential, page, context) {
    let html = "";
    html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<td style='background-color:darkgreen;color:wheat;font-weight:bold;font-size:120%;text-align:center'>< 百 宝 袋 ></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<th style='background-color:#E8E8D0;text-align:center;color:navy;font-weight:bold'>百宝袋丢失了呀?那只能为您提供受限的功能了。</th>";
    html += "</tr>";
    // ----------------------------------------------------------------
    // 百宝袋菜单栏
    // ----------------------------------------------------------------
    html += "<tr>";
    html += "<td style='background-color:#F8F0E0;text-align:center'>";
    html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
    html += "<tbody>";
    html += "<tr>";
    html += "<td style='text-align:left'>";
    if (page.spaceCount > 0) {
        html += "<input type='button' class='mutableButton-2' " +
            "id='takeOutButton' " +
            "value='从百宝袋中盲取'>";
    }
    html += "</td>";
    html += "<td style='text-align:right'>";
    html += "<input type='button' id='closeBagButton_2' class='mutableButton-2' value='关闭百宝袋'>";
    html += "</td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    html += "</td>";
    html += "</tr>";
    html += "</tbody>";
    html += "</table>";
    $("#bagList").html(html).parent().show();
    $("#takeOutButton").on("click", () => {
        new TreasureBag_1.default(credential).tryTakeOut(page.spaceCount).then(() => {
            this.doRefreshMutablePage(credential, context);
        });
    });
    $("#closeBagButton_2").on("click", () => {
        if ($("#bagState").text() === "off") {
            return;
        }
        $("#bagState").text("off");
        PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-2");
        $("#bagList").html("").parent().hide();
    });
}, _PersonalEquipmentManagementPageProcessor_Town_renderNormalBagUI = function _PersonalEquipmentManagementPageProcessor_Town_renderNormalBagUI(credential, page, bagIndex, context) {
    new TreasureBag_1.default(credential).open(bagIndex).then(bagPage => {
        const equipmentList = bagPage.sortedEquipmentList;
        let html = "";
        html += "<table style='border-width:0;background-color:#888888;text-align:center;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='background-color:darkgreen;color:wheat;font-weight:bold;font-size:120%;text-align:center' colspan='12'>< 百 宝 袋 ></td>";
        html += "</tr>";
        html += "<tr>";
        html += "<th style='background-color:#E0D0B0'>序号</th>";
        html += "<th style='background-color:#E8E8D0'>选择</th>";
        html += "<th style='background-color:#E0D0B0'>名字</th>";
        html += "<th style='background-color:#EFE0C0'>种类</th>";
        html += "<th style='background-color:#E0D0B0'>效果</th>";
        html += "<th style='background-color:#EFE0C0'>重量</th>";
        html += "<th style='background-color:#EFE0C0'>耐久</th>";
        html += "<th style='background-color:#EFE0C0'>威+</th>";
        html += "<th style='background-color:#EFE0C0'>重+</th>";
        html += "<th style='background-color:#EFE0C0'>幸+</th>";
        html += "<th style='background-color:#E0D0B0'>经验</th>";
        html += "<th style='background-color:#E8E8D0'>取出</th>";
        html += "</tr>";
        let sequence = 1;
        for (const equipment of equipmentList) {
            html += "<tr>";
            html += "<th style='background-color:#E0D0B0'>" + (sequence++) + "</th>";
            html += "<td style='background-color:#E8E8D0'>";
            if (page.spaceCount > 0) {
                html += "<input type='button' value='选择' " +
                    "style='color:grey' " +
                    "class='mutableButton-2 selectButton-2' " +
                    "id='selectButton_2_" + equipment.index + "'>";
            }
            html += "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.nameHTML + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.category + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.power + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.weight + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.endureHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalPowerHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalWeightHtml + "</td>";
            html += "<td style='background-color:#EFE0C0'>" + equipment.additionalLuckHtml + "</td>";
            html += "<td style='background-color:#E0D0B0'>" + equipment.experienceHTML + "</td>";
            html += "<td style='background-color:#E8E8D0'>";
            if (page.spaceCount > 0) {
                html += "<input type='button' value='出袋' " +
                    "class='mutableButton-2 takeOutButton-2' " +
                    "id='takeOutButton_2_" + equipment.index + "'>";
            }
            html += "</td>";
            html += "</tr>";
        }
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;text-align:center' colspan='12'>";
        html += "<b style='color:navy'>目前剩余空位数:</b><b style='color:red'>" + bagPage.spaceCount + "</b>";
        html += "</td>";
        html += "</tr>";
        // ----------------------------------------------------------------
        // 百宝袋菜单栏
        // ----------------------------------------------------------------
        html += "<tr>";
        html += "<td style='background-color:#F8F0E0;text-align:center' colspan='12'>";
        html += "<table style='border-width:0;background-color:#F8F0E0;width:100%;margin:auto'>";
        html += "<tbody>";
        html += "<tr>";
        html += "<td style='text-align:left'>";
        if (page.spaceCount > 0) {
            html += "<input type='button' class='mutableButton-2' " +
                "id='takeOutButton' " +
                "value='从百宝袋中取出'>";
        }
        html += "</td>";
        html += "<td style='text-align:right'>";
        html += "<input type='button' id='closeBagButton_2' class='mutableButton-2' value='关闭百宝袋'>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        html += "</td>";
        html += "</tr>";
        html += "</tbody>";
        html += "</table>";
        $("#bagList").html(html).parent().show();
        this.doBindSelectButtons("selectButton-2");
        $(".takeOutButton-2").on("click", event => {
            const buttonId = $(event.target).attr("id");
            const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
            new TreasureBag_1.default(credential).takeOut([index]).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
        $("#takeOutButton").on("click", () => {
            const indexList = [];
            $(".selectButton-2").each((idx, button) => {
                const buttonId = $(button).attr("id");
                if (PageUtils_1.default.isColorBlue(buttonId)) {
                    const index = parseInt(StringUtils_1.default.substringAfterLast(buttonId, "_"));
                    indexList.push(index);
                }
            });
            if (indexList.length === 0) {
                this.doScrollToPageTitle();
                MessageBoard_1.default.publishWarning("没有选择百宝袋中的物品或装备!");
                return;
            }
            new TreasureBag_1.default(credential).takeOut(indexList).then(() => {
                this.doRefreshMutablePage(credential, context);
            });
        });
        $("#closeBagButton_2").on("click", () => {
            if ($("#bagState").text() === "off") {
                return;
            }
            $("#bagState").text("off");
            PageUtils_1.default.unbindEventBySpecifiedClass("mutableButton-2");
            $("#bagList").html("").parent().hide();
        });
    });
}, _PersonalEquipmentManagementPageProcessor_Town_bindSetButton = function _PersonalEquipmentManagementPageProcessor_Town_bindSetButton(credential, page, setId, context) {
    let setConfig = null;
    switch (setId) {
        case "A":
            setConfig = SetupLoader_1.default.loadEquipmentSet_A(credential.id);
            break;
        case "B":
            setConfig = SetupLoader_1.default.loadEquipmentSet_B(credential.id);
            break;
        case "C":
            setConfig = SetupLoader_1.default.loadEquipmentSet_C(credential.id);
            break;
        case "D":
            setConfig = SetupLoader_1.default.loadEquipmentSet_D(credential.id);
            break;
        case "E":
            setConfig = SetupLoader_1.default.loadEquipmentSet_E(credential.id);
            break;
        default:
            break;
    }
    if (!this.doCheckSetConfiguration(setConfig)) {
        return;
    }
    const buttonId = "setBu