{"version":3,"file":"random.cjs","names":[],"sources":["../src/random/Random.ts"],"sourcesContent":["// NanoID is ESM-only. This unfortunately means we can't offer a CommonJS export for this module.\n// Hence why it is exported under its own subpath (/random);\nimport { customAlphabet, nanoid } from 'nanoid';\n\nexport class IdGenerator {\n    protected readonly alphabets = {\n        id: customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'),\n        reference: customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'),\n        secret: nanoid,\n    }\n    \n    public id({ length = 17 } = {}) {\n        return this.alphabets.id(length);\n    }\n    \n    public secret({ length = 20 } = {}) {\n        return this.alphabets.secret(length);\n    }\n    \n    /**\n     * Short ID to use as a human-readable identifier. Collisions are probable.\n     */\n    public reference({ length = 8, delimiter = '-' } = {}) {\n        const partLength = Math.round(length / 2);\n        const prefix = this.alphabets.reference(partLength);\n        const suffix = this.alphabets.reference(partLength);\n        \n        return `${prefix}${delimiter}${suffix}`;\n    }\n}\n\n// @__NO_SIDE_EFFECTS__\nexport const Random = new IdGenerator();"],"mappings":";;;;AAIA,IAAa,cAAb,MAAyB;CACrB,AAAmB,YAAY;EAC3B,+BAAmB,iEAAiE;EACpF,sCAA0B,uCAAuC;EACjE,QAAQ;EACX;CAED,AAAO,GAAG,EAAE,SAAS,OAAO,EAAE,EAAE;AAC5B,SAAO,KAAK,UAAU,GAAG,OAAO;;CAGpC,AAAO,OAAO,EAAE,SAAS,OAAO,EAAE,EAAE;AAChC,SAAO,KAAK,UAAU,OAAO,OAAO;;;;;CAMxC,AAAO,UAAU,EAAE,SAAS,GAAG,YAAY,QAAQ,EAAE,EAAE;EACnD,MAAM,aAAa,KAAK,MAAM,SAAS,EAAE;AAIzC,SAAO,GAHQ,KAAK,UAAU,UAAU,WAAW,GAGhC,YAFJ,KAAK,UAAU,UAAU,WAAW;;;AAO3D,MAAa,SAAS,IAAI,aAAa"}