Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
37 kB
1
Indexable
Never
(() => {
    var __webpack_modules__ = {
        279: (module, __unused_webpack_exports, __webpack_require__) => {
            const prom = (() => {
                const e = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : {};

                function t(e, t, s, r) {
                    Object.defineProperty(e, t, {
                        get: s,
                        set: r,
                        enumerable: !0,
                        configurable: !0
                    })
                }
                const s = {};
                const r = {};
                let a = e.parcelRequire599d;
                a == null && ((a = function(e) {
                    if (e in s) return s[e].exports;
                    if (e in r) {
                        const t = r[e];
                        delete r[e];
                        const a = {
                            id: e,
                            exports: {}
                        };
                        return s[e] = a, t.call(a.exports, a, a.exports), a.exports
                    }
                    const i = new Error(`Cannot find module '${e}'`);
                    throw i.code = "MODULE_NOT_FOUND", i
                }).register = function(e, t) {
                    r[e] = t
                }, e.parcelRequire599d = a), a.register("dbipy", ((e, t) => {
                    const s = a("akv27").getValueAsString;

                    function r(e) {
                        return e.replace(/\n/g, "\\n").replace(/\\(?!n)/g, "\\\\")
                    }

                    function i(e) {
                        return typeof e !== "string" ? e : r(e).replace(/"/g, '\\"')
                    }
                    class n {
                        constructor() {
                            this._metrics = {}, this._collectors = [], this._defaultLabels = {}
                        }
                        getMetricsAsArray() {
                            return Object.values(this._metrics)
                        }
                        async getMetricAsPrometheusString(e, t = null) {
                            const a = await e.get();
                            const n = r(a.name);
                            const l = `# HELP ${n} ${r(a.help)}`;
                            const o = `# TYPE ${n} ${a.type}`;
                            const c = Object.keys(this._defaultLabels);
                            let u = "";
                            for (const e of a.values || []) {
                                if (e.labels = e.labels || {}, c.length > 0) {
                                    e.labels = {
                                        ...e.labels
                                    };
                                    for (const t of c) e.labels[t] = e.labels[t] || this._defaultLabels[t]
                                }
                                let r = e.metricName || a.name;
                                const n = Object.keys(e.labels);
                                const l = n.length;
                                if (l > 0) {
                                    let t = "";
                                    let s = 0;
                                    for (; s < l - 1; s++) t += `${n[s]}="${i(e.labels[n[s]])}",`;
                                    t += `${n[s]}="${i(e.labels[n[s]])}"`, r += `{${t}}`
                                }
                                u += `${r} ${s(e.value)}${t?` ${t}`:""}\n`
                            }
                            return `${l}\n${o}\n${u}`.trim()
                        }
                        async metrics(e = null) {
                            const t = [];
                            for (const s of this.getMetricsAsArray()) t.push(this.getMetricAsPrometheusString(s, e));
                            return `${(await Promise.all(t)).join("\n\n")}\n`
                        }
                        registerMetric(e) {
                            if (this._metrics[e.name] && this._metrics[e.name] !== e) throw new Error(`A metric with the name ${e.name} has already been registered.`);
                            this._metrics[e.name] = e
                        }
                        clear() {
                            this._metrics = {}, this._defaultLabels = {}
                        }
                        async getMetricsAsJSON() {
                            const e = [];
                            const t = Object.keys(this._defaultLabels);
                            const s = [];
                            for (const e of this.getMetricsAsArray()) s.push(e.get());
                            const r = await Promise.all(s);
                            for (const s of r) {
                                if (s.values && t.length > 0)
                                    for (const e of s.values) {
                                        e.labels = {
                                            ...e.labels
                                        };
                                        for (const s of t) e.labels[s] = e.labels[s] || this._defaultLabels[s]
                                    }
                                e.push(s)
                            }
                            return e
                        }
                        removeSingleMetric(e) {
                            delete this._metrics[e]
                        }
                        getSingleMetricAsString(e) {
                            return this.getMetricAsPrometheusString(this._metrics[e])
                        }
                        getSingleMetric(e) {
                            return this._metrics[e]
                        }
                        setDefaultLabels(e) {
                            this._defaultLabels = e
                        }
                        resetMetrics() {
                            for (const e in this._metrics) this._metrics[e].reset()
                        }
                        get contentType() {
                            return "text/plain; version=0.0.4; charset=utf-8"
                        }
                        static merge(e) {
                            const t = new n;
                            return e.reduce(((e, t) => e.concat(t.getMetricsAsArray())), []).forEach(t.registerMetric, t), t
                        }
                    }
                    e.exports = n, e.exports.globalRegistry = new n
                })), a.register("akv27", ((s, r) => {
                    let a;
                    let i;
                    let n;
                    let l;
                    let o;
                    let c;
                    let u;
                    t(s.exports, "getValueAsString", (() => a), (e => a = e)), t(s.exports, "hrtime", (() => i), (e => i = e)), t(s.exports, "removeLabels", (() => n), (e => n = e)), t(s.exports, "setValue", (() => l), (e => l = e)), t(s.exports, "getLabels", (() => o), (e => o = e)), t(s.exports, "hashObject", (() => c), (e => c = e)), t(s.exports, "isObject", (() => u), (e => u = e)), a = function(e) {
                        return Number.isNaN(e) ? "Nan" : Number.isFinite(e) ? `${e}` : e < 0 ? "-Inf" : "+Inf"
                    };
                    const h = e.performance || {};
                    const b = h.now || h.mozNow || h.msNow || h.oNow || h.webkitNow || function() {
                        return (new Date).getTime()
                    };

                    function m(e) {
                        let t = Object.keys(e);
                        if (t.length === 0) return "";
                        t.length > 1 && (t = t.sort());
                        let s = "";
                        let r = 0;
                        const a = t.length;
                        for (; r < a - 1; r++) s += `${t[r]}:${e[t[r]]},`;
                        return s += `${t[r]}:${e[t[r]]}`, s
                    }
                    i = function(e) {
                        const t = .001 * b.call(h);
                        let s = Math.floor(t);
                        let r = Math.floor(t % 1 * 1e9);
                        return e && (s -= e[0], r -= e[1], r < 0 && (s--, r += 1e9)), [s, r]
                    }, n = function(e, t) {
                        delete e[m(t)]
                    }, l = function(e, t, s) {
                        return e[m(s)] = {
                            value: typeof t === "number" ? t : 0,
                            labels: s || {}
                        }, e
                    }, o = function(e, t) {
                        if (typeof t[0] === "object") return t[0];
                        if (e.length !== t.length) throw new Error("Invalid number of arguments");
                        const s = {};
                        for (let r = 0; r < e.length; r++) s[e[r]] = t[r];
                        return s
                    }, c = m, u = function(e) {
                        return e === Object(e)
                    };
                    class g extends Map {
                        add(e, t) {
                            this.has(e) ? this.get(e).push(t) : this.set(e, [t])
                        }
                    }
                })), a.register("4jGCD", ((e, s) => {
                    let r;
                    let a;
                    let i;
                    t(e.exports, "validateMetricName", (() => r), (e => r = e)), t(e.exports, "validateLabelName", (() => a), (e => a = e)), t(e.exports, "validateLabel", (() => i), (e => i = e));
                    const n = /^[a-zA-Z_:][a-zA-Z0-9_:]*$/;
                    const l = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
                    r = function(e) {
                        return n.test(e)
                    }, a = function(e = []) {
                        return e.every((e => l.test(e)))
                    }, i = function(e, t) {
                        for (const s in t)
                            if (!e.includes(s)) throw new Error(`Added label "${s}" is not included in initial labelset: ${e}`)
                    }
                })), a.register("lRKyl", ((e, t) => {
                    const s = a("akv27");
                    const r = s.hashObject;
                    const i = s.isObject;
                    const n = s.getLabels;
                    const l = s.removeLabels;
                    const o = a("4jGCD").validateLabel;
                    const c = a("5xkNv").Metric;

                    function u(e, t, s = {}, r = "") {
                        return e[r] ? e[r].value += t : e[r] = {
                            value: t,
                            labels: s
                        }, e
                    }
                    e.exports = class extends c {
                        inc(e, t) {
                            let s;
                            if (i(e) ? (s = r(e), o(this.labelNames, e)) : (t = e, e = {}), t && !Number.isFinite(t)) throw new TypeError(`Value is not a valid number: ${t}`);
                            if (t < 0) throw new Error("It is not possible to decrease a counter");
                            t == null && (t = 1), u(this.hashMap, t, e, s)
                        }
                        reset() {
                            this.hashMap = {}, this.labelNames.length === 0 && u(this.hashMap, 0)
                        }
                        async get() {
                            if (this.collect) {
                                const e = this.collect();
                                e instanceof Promise && await e
                            }
                            return {
                                help: this.help,
                                name: this.name,
                                type: "counter",
                                values: Object.values(this.hashMap),
                                aggregator: this.aggregator
                            }
                        }
                        labels(...e) {
                            const t = n(this.labelNames, e) || {};
                            return {
                                inc: this.inc.bind(this, t)
                            }
                        }
                        remove(...e) {
                            const t = n(this.labelNames, e) || {};
                            return o(this.labelNames, t), l.call(this, this.hashMap, t)
                        }
                    }
                })), a.register("5xkNv", ((e, t) => {
                    const s = a("dbipy").globalRegistry;
                    const r = a("akv27").isObject;
                    const i = a("4jGCD");
                    const n = i.validateMetricName;
                    const l = i.validateLabelName;
                    e.exports = {
                        Metric: class {
                            constructor(e, t = {}) {
                                if (!r(e)) throw new TypeError("constructor expected a config object");
                                if (Object.assign(this, {
                                        labelNames: [],
                                        registers: [s],
                                        aggregator: "sum"
                                    }, t, e), this.registers || (this.registers = [s]), !this.help) throw new Error("Missing mandatory help parameter");
                                if (!this.name) throw new Error("Missing mandatory name parameter");
                                if (!n(this.name)) throw new Error("Invalid metric name");
                                if (!l(this.labelNames)) throw new Error("Invalid label name");
                                if (this.collect && typeof this.collect !== "function") throw new Error('Optional "collect" parameter must be a function');
                                this.reset();
                                for (const e of this.registers) e.registerMetric(this)
                            }
                            reset() {}
                        }
                    }
                })), a.register("jxOKZ", ((e, t) => {
                    const s = a("akv27");
                    const r = s.setValue;
                    const i = s.getLabels;
                    const n = s.hashObject;
                    const l = s.isObject;
                    const o = s.removeLabels;
                    const c = s.hrtime;
                    const u = a("4jGCD").validateLabel;
                    const h = a("5xkNv").Metric;

                    function b(e, t, s) {
                        if (typeof s !== "number") throw new TypeError(`Value is not a valid number: ${s}`);
                        u(e.labelNames, t), r(e.hashMap, s, t)
                    }

                    function m(e) {
                        return l(e) ? e : {}
                    }

                    function g(e, t) {
                        return l(e) ? t : e
                    }
                    e.exports = class extends h {
                        set(e, t) {
                            t = g(e, t), b(this, e = m(e), t)
                        }
                        reset() {
                            this.hashMap = {}, this.labelNames.length === 0 && r(this.hashMap, 0, {})
                        }
                        inc(e, t) {
                            void 0 === (t = g(e, t)) && (t = 1), b(this, e = m(e), this._getValue(e) + t)
                        }
                        dec(e, t) {
                            void 0 === (t = g(e, t)) && (t = 1), b(this, e = m(e), this._getValue(e) - t)
                        }
                        setToCurrentTime(e) {
                            const t = Date.now() / 1e3;
                            void 0 === e ? this.set(t) : this.set(e, t)
                        }
                        startTimer(e) {
                            const t = c();
                            return s => {
                                const r = c(t);
                                const a = r[0] + r[1] / 1e9;
                                return this.set({
                                    ...e,
                                    ...s
                                }, a), a
                            }
                        }
                        async get() {
                            if (this.collect) {
                                const e = this.collect();
                                e instanceof Promise && await e
                            }
                            return {
                                help: this.help,
                                name: this.name,
                                type: "gauge",
                                values: Object.values(this.hashMap),
                                aggregator: this.aggregator
                            }
                        }
                        _getValue(e) {
                            const t = n(e || {});
                            return this.hashMap[t] ? this.hashMap[t].value : 0
                        }
                        labels(...e) {
                            const t = i(this.labelNames, e);
                            return u(this.labelNames, t), {
                                inc: this.inc.bind(this, t),
                                dec: this.dec.bind(this, t),
                                set: this.set.bind(this, t),
                                setToCurrentTime: this.setToCurrentTime.bind(this, t),
                                startTimer: this.startTimer.bind(this, t)
                            }
                        }
                        remove(...e) {
                            const t = i(this.labelNames, e);
                            u(this.labelNames, t), o.call(this, this.hashMap, t)
                        }
                    }
                }));
                const i = a("akv27").getLabels;
                async function n(e = "", t = {}, s = {}) {
                    const r = typeof t === "string";
                    const a = r ? t : JSON.stringify(t);
                    return await fetch(e, {
                        method: "POST",
                        headers: {
                            "Content-Type": r ? "text/plain" : "application/json",
                            "Content-Length": a.length,
                            ...s
                        },
                        body: a
                    })
                }
                const l = {
                    register: a("dbipy").globalRegistry,
                    Registry: a("dbipy"),
                    contentType: a("dbipy").globalRegistry.contentType,
                    validateMetricName: a("4jGCD").validateMetricName,
                    Counter: a("lRKyl"),
                    Gauge: a("jxOKZ"),
                    postData: n,
                    async postWithAuth(e, t, s) {
                        return await n(e, t, {
                            authorization: s
                        })
                    },
                    async pushToVM(e, t) {
                        return await l.postWithAuth(e, await l.register.metrics(), t)
                    }
                };
                const o = server.region + server.id;

                function c(e, t) {
                    return typeof e === "number" ? {
                        labels: {
                            server: o
                        },
                        value: e
                    } : (e ? Array.isArray(e) && !e.includes(o) ? e.push(o) : e.server || (e.server = o) : e = {
                        server: o
                    }, {
                        labels: e,
                        value: t
                    })
                }
                l.ServerCounter = class extends l.Counter {
                    constructor(e) {
                        e || (e = {}), e.labelNames || (e.labelNames = []), e.labelNames.includes("server") || e.labelNames.push("server"), super(e)
                    }
                    inc(e, t) {
                        const {
                            labels: s,
                            value: r
                        } = c(e, t);
                        return super.inc(s, r)
                    }
                    labels(...e) {
                        const t = i(this.labelNames, e) || {};
                        return t.server = o, super.labels(t)
                    }
                    remove(...e) {
                        const t = i(this.labelNames, e) || {};
                        return t.server = o, super.remove(t)
                    }
                }, l.ServerGauge = class extends l.Gauge {
                    constructor(e) {
                        e || (e = {}), e.labelNames || (e.labelNames = []), e.labelNames.includes("server") || e.labelNames.push("server"), super(e)
                    }
                    set(e, t) {
                        const {
                            labels: s,
                            value: r
                        } = c(e, t);
                        return super.set(s, r)
                    }
                    inc(e, t) {
                        const {
                            labels: s,
                            value: r
                        } = c(e, t);
                        return super.inc(s, r)
                    }
                    dec(e, t) {
                        const {
                            labels: s,
                            value: r
                        } = c(e, t);
                        return super.dec(s, r)
                    }
                    labels(...e) {
                        const t = i(this.labelNames, e) || {};
                        return t.server = o, super.labels(t)
                    }
                    remove(...e) {
                        const t = i(this.labelNames, e) || {};
                        return t.server = o, super.remove(t)
                    }
                };
                globalThis.prom = l;
                return globalThis.prom
            })();
            module.exports.h = prom
        }
    };
    var __webpack_module_cache__ = {};

    function __webpack_require__(moduleId) {
        var cachedModule = __webpack_module_cache__[moduleId];
        if (cachedModule !== undefined) {
            return cachedModule.exports
        }
        var module = __webpack_module_cache__[moduleId] = {
            exports: {}
        };
        __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
        return module.exports
    }(() => {
        __webpack_require__.d = (exports, definition) => {
            for (var key in definition) {
                if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
                    Object.defineProperty(exports, key, {
                        enumerable: true,
                        get: definition[key]
                    })
                }
            }
        }
    })();
    (() => {
        __webpack_require__.g = function() {
            if (typeof globalThis === "object") return globalThis;
            try {
                return this || new Function("return this")()
            } catch (e) {
                if (typeof window === "object") return window
            }
        }()
    })();
    (() => {
        __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
    })();
    var __webpack_exports__ = {};
    (() => {
        "use strict";
        var _prom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(279);
        const cumulatedXp = [0, 0, 200, 450, 760, 1140, 1610, 2190, 2910, 3810, 4910, 6210, 7810, 9810, 12310, 15410, 19210, 23910, 29710, 36910, 45910, 56910, 69910, 85910, 105910, 130910, 161910, 199910, 246910, 304910, 376910, 466910, 576910, 706910, 866910, 1066910, 1316910, 1626910, 2006910, 2476910, 3056910, 3776910, 4676910, 5776910, 7076910, 8676910, 10676910, 13176910, 16276910, 20076910, 24776910, 30576910, 37776910, 46776910, 57776910, 70776910, 86776910, 106776910, 131776910, 162776910, 200776910, 247776910, 304776910, 373776910, 457776910, 557776910, 677776910, 817776910, 987776910, 1187776910, 1427776910, 1717776910, 2067776910, 2487776910, 2997776910, 3617776910, 4367776910, 5267776910, 6267776910, 7467776910, 8867776910, 10467776910, 12467776910, 14967776910, 18067776910, 21967776910, 26867776910, 33067776910, 40967776910, 50967776910, 62967776910, 77967776910, 97967776910, 124967776910, 161967776910, 211967776910, 279967776910, 372967776910, 492967776910, 652967776910, 872967776910, 1172967776910, 1502967776910, 1862967776910, 2252967776910, 2672967776910, 3132967776910, 3632967776910, 4182967776910, 4782967776910, 5442967776910, 6162967776910, 6952967776910, 7812967776910, 8752967776910, 9752967776910, 0x9dee74a028e, 0xaf64cdce28e, 0xc24fae6aa8e, 0xd6af1675a8e, 0xec8305ef28e, 17852967776910, 19552967776910, 21352967776910, 23252967776910, 25252967776910, 27452967776910, 29852967776910, 32452967776910, 35252967776910, 38252967776910, 41552967776910, 45152967776910, 49052967776910, 53252967776910, 57852967776910, 62852967776910, 68352967776910, 74352967776910, 80952967776910, 88152967776910, 96052967776910, 0x5f2e6af8128e, 0x67bb06a1428e, 0x70d35513e28e, 0x7ad4782b928e, 0x85be6fe8528e, 0x91913c4a228e, 0x9e4cdd51028e, 0xabf152fcf28e, 0xba7e9d4df28e, 0xc9f4bc44028e, 0xda53afdf228e, 0xeb9b781f528e, 0xfdcc1504928e, 301052967776910, 325052967776910, 351052967776910, 379052967776910, 409052967776910, 442052967776910, 478052967776910, 517052967776910, 559052967776910, 605052967776910, 655052967776910, 710052967776910, 770052967776910, 836052967776910, 908052967776910, 987052967776910, 0x3cfef9cf8328e, 0x4256db194128e, 0x48060c20e528e, 0x4e46c20fb328e, 0x5518fce5ab28e, 0x5c7cbca2cd28e, 0x647201471928e, 0x6cf8cad28f28e, 0x761119452f28e, 0x7fbaec9ef928e, 0x89f644dfed28e, 0x94c322080b28e, 0xa02184175328e, 0xaca2eff4ef28e, 0xba4765a0df28e, 0xc90ee51b2328e, 0xd8f96e63bb28e, 0xea07017aa728e, 0xfcc923471128e, 4807052967776910, 5197052967776910, 5617052967776910, 6077052967776910, 6577052967776910, 7127052967776910, 7727052967776910, 8387052967776910, 9107052967776910, 9897052967776910, 0x26377b90f9728e];
        _prom__WEBPACK_IMPORTED_MODULE_0__.h.register.setDefaultLabels({
            character: "Abuse"
        });
        const char = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Gauge({
            name: "al_character_info",
            help: "Informations regarding the character",
            labelNames: ["name", "class", "owner"]
        });
        char.set({
            name: "Abuse",
            class: "merchant",
            owner: character.owner
        }, 1);
        const serv = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Gauge({
            name: "al_server_info",
            help: "Informations regarding the server",
            labelNames: ["fullname", "mode", "pvp", "region", "id"]
        });
        serv.set({
            fullname: server.region + server.id,
            mode: server.mode,
            pvp: `${server.pvp}`,
            region: server.region,
            id: server.id
        }, 1);
        const kills = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_kills_total",
            help: "How many kills my characters did",
            labelNames: ["enemy"]
        });
        const damage_dealt = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_damage_dealt_total",
            help: "How much damage my characters dealt",
            labelNames: ["damage_type", "monster", "projectile", "source"]
        });
        const damage_received = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_damage_received_total",
            help: "How much damage my characters received",
            labelNames: ["damage_type", "monster", "projectile", "source"]
        });
        const used_skills = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_used_skills_total",
            help: "How many skills my characters used",
            labelNames: ["skill"]
        });
        const deaths = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_deaths_total",
            help: "How many deaths my characters suffered"
        });
        const opened_chests = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_opened_chests_total",
            help: "How many chests did my characters open",
            labelNames: ["skin"]
        });
        const looted_items = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_looted_items_total",
            help: "How many items did my characters loot",
            labelNames: ["item", "level"]
        });
        const looted_gold = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_looted_gold_total",
            help: "How much gold did my characters loot"
        });
        const bought_items = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_bought_items_total",
            help: "How many items I bought",
            labelNames: ["item", "from"]
        });
        const spent_gold = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_spent_gold_total",
            help: "How many gold I spent",
            labelNames: ["for"]
        });
        const sold_items = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_sold_items_total",
            help: "How many items I sold",
            labelNames: ["item", "to"]
        });
        const sales_gold = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerCounter({
            name: "al_sales_gold_total",
            help: "How many gold I gained from sales",
            labelNames: ["to"]
        });
        const ping = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.ServerGauge({
            name: "al_ping_seconds",
            help: "How is the ping with the server",
            collect() {
                this.set(parent.pings.reduce(((a, b) => a + b)) / parent.pings.length / 1e3)
            }
        });
        const level = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Gauge({
            name: "al_level_total",
            help: "How many levels my characters have",
            collect() {
                this.set(character.level)
            }
        });
        const exp = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Gauge({
            name: "al_exp_total",
            help: "How many exp points my characters have",
            collect() {
                this.set(cumulatedXp[character.level] + character.xp)
            }
        });
        const gold = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Gauge({
            name: "al_gold_total",
            help: "How much gold do I have",
            collect() {
                this.set(character.gold)
            }
        });
        const sent_gold = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Counter({
            name: "al_sent_gold_total",
            help: "How much gold have I sent to others",
            labelNames: ["to"]
        });
        const received_gold = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Counter({
            name: "al_received_gold_total",
            help: "How much gold have I received from others",
            labelNames: ["from"]
        });
        const failed_upgrades = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Counter({
            name: "al_failed_upgrades_total",
            help: "How many upgrades I failed",
            labelNames: ["item", "level"]
        });
        const success_upgrades = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Counter({
            name: "al_success_upgrades_total",
            help: "How many upgrades I did successfully",
            labelNames: ["item", "level"]
        });
        const failed_compounds = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Counter({
            name: "al_failed_compounds_total",
            help: "How many compounds I failed",
            labelNames: ["item", "level"]
        });
        const success_compounds = new _prom__WEBPACK_IMPORTED_MODULE_0__.h.Counter({
            name: "al_success_compounds_total",
            help: "How many compounds I did successfully",
            labelNames: ["item", "level"]
        });
        character.on("buy", (data => {
            if (!data.q) {
                data.q = 1
            }
            bought_items.labels({
                item: data.name,
                from: "npc"
            }).inc(data.q);
            spent_gold.labels({
                for: "npc"
            }).inc(data.cost)
        }));
        character.on("sell", (data => {
            if (!data.item.q) {
                data.item.q = 1
            }
            sold_items.labels({
                item: data.item.name,
                to: "npc"
            }).inc(data.item.q);
            sales_gold.labels({
                to: "npc"
            }).inc(data.gold)
        }));
        game.on("sbuy", (({
            name,
            item
        }) => {
            if (name !== "Abuse") {
                return
            }
            if (!item.q) {
                item.q = 1
            }
            delete item.rid;
            bought_items.labels({
                item: item.name,
                from: "ponty"
            }).inc(item.q);
            const ponty_mult = item.cash ? G.multipliers.secondhands_cash_mult : G.multipliers.secondhands_mult;
            spent_gold.labels({
                for: "ponty"
            }).inc(calculate_item_value(item) * ponty_mult)
        }));
        game.on("fbuy", (({
            name,
            item
        }) => {
            if (name !== "Abuse") {
                return
            }
            if (!item.q) {
                item.q = 1
            }
            delete item.rid;
            bought_items.labels({
                item: item.name,
                from: "lost_and_found"
            }).inc(item.q);
            spent_gold.labels({
                for: "lost_and_found"
            }).inc(calculate_item_value(item) * G.multipliers.lostandfound_mult)
        }));
        character.on("gold_sent", (data => {
            if ("response" in data) {
                sent_gold.inc({
                    to: data.name
                }, data.gold)
            }
        }));
        character.on("gold_received", (data => {
            if ("response" in data) {
                received_gold.inc({
                    from: data.name
                }, data.gold)
            }
        }));
        character.on("loot", (data => {
            looted_gold.inc(data.gold);
            if (data.items && data.items.length) {
                for (const item of data.items) {
                    if (item.looter === "Abuse") {
                        looted_items.labels({
                            item: item.name,
                            level: item.level ?? 0
                        }).inc(item.q ?? 1)
                    }
                }
            }
        }));
        character.on("target_hit", (data => {
            const entity = parent.entities[data.target];
            if (data.kill) {
                kills.labels({
                    enemy: entity?.mtype ?? "_unknown"
                }).inc()
            }
            if (typeof data.damage === "number") {
                damage_dealt.labels({
                    damage_type: data.damage_type ?? "_unknown",
                    monster: entity?.mtype ?? "_unknown",
                    projectile: data.projectile ?? "_unknown",
                    source: data.source ?? "_unknown"
                }).inc(data.damage)
            }
        }));
        character.on("hit", (data => {
            const entity = parent.entities[data.actor];
            if (typeof data.damage === "number") {
                damage_received.labels({
                    damage_type: data.damage_type ?? "_unknown",
                    monster: entity?.mtype ?? "_unknown",
                    projectile: data.projectile ?? "_unknown",
                    source: data.source ?? "_unknown"
                }).inc(data.damage)
            }
            if (data.kill) {
                deaths.inc()
            }
        }));
        const PUBLISH_INTERVAL = 1e3 * 1;
        const METRICS_POST_URL = "http://localhost:3000/api/v1/import/prometheus";
        const METRICS_AUTH_TOKEN = "";
        async function publish_metrics() {
            await _prom__WEBPACK_IMPORTED_MODULE_0__.h.pushToVM(METRICS_POST_URL, `Basic ${METRICS_AUTH_TOKEN}`)
        }
        async function loop_publish_metrics() {
            try {
                await publish_metrics()
            } catch (err) {
                log("Error while pushing metrics.")
            }
            setTimeout(loop_publish_metrics, PUBLISH_INTERVAL)
        }
        loop_publish_metrics()
    })()
})();