import sortedLastIndexBy from "lodash/sortedLastIndexBy";
/**
 * eventKey. Make a unique and sortable identifier string for an event
 * Used by poolClient.ts lines 166, 246
 *
 * @param {Event} event
 * @returns {string} - the unique id
 */
export function eventKey(event) {
    var _a;
    return [
        // we pad these because numbers of varying lengths will not sort correctly, ie "10" will incorrectly sort before "9", but "09" will be correct.
        event.blockNumber.toString().padStart(16, "0"),
        event.transactionIndex.toString().padStart(16, "0"),
        (_a = event.logIndex) === null || _a === void 0 ? void 0 : _a.toString().padStart(16, "0"),
        // ~ is the last printable ascii char, so it does not interfere with sorting
    ].join("~");
}
/**
 * insertOrdered. Inserts items in an array maintaining sorted order, in this case lowest to highest. Does not check duplicates.
 * Mainly used for caching all known events, in order of oldest to newest.
 * Used by poolClient.ts line 181
 *
 * @param {T[]} array
 * @param {T} element
 * @param {Function} orderBy
 */
export function insertOrderedAscending(array, element, orderBy) {
    var index = sortedLastIndexBy(array, element, orderBy);
    array.splice(index, 0, element);
    return array;
}
//# sourceMappingURL=utils.js.map