"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uuidNotIn = exports.uuid = exports.uuidIdNotInSet = exports.randomIdNotInSet = exports.randomIdNotIn = exports.randomId = void 0;
function randomId() {
    return Math.random()
        .toString(36)
        .replace(/[^a-z]+/g, '')
        .substr(0, 9);
}
exports.randomId = randomId;
function randomIdNotIn(obj) {
    let id;
    do {
        id = randomId();
    } while (obj[id]);
    return id;
}
exports.randomIdNotIn = randomIdNotIn;
function randomIdNotInSet(obj) {
    let id;
    do {
        id = randomId();
    } while (obj.has(id));
    return id;
}
exports.randomIdNotInSet = randomIdNotInSet;
function uuidIdNotInSet(obj) {
    let id;
    do {
        id = uuid();
    } while (obj.has(id));
    return id;
}
exports.uuidIdNotInSet = uuidIdNotInSet;
function uuid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        const r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
        return v.toString(16);
    });
}
exports.uuid = uuid;
function uuidNotIn(obj) {
    let id;
    do {
        id = uuid();
    } while (obj[id]);
    return id;
}
exports.uuidNotIn = uuidNotIn;
//# sourceMappingURL=id.js.map