{"version":3,"file":"hash.mjs","names":[],"sources":["../../../../src/modules/processor/functions/hash.ts"],"sourcesContent":["const OFFSET_BASIS = 2166136261 as const;\nconst PRIME = 16777619 as const;\n\nconst u32ToBase36 = (number: number): string => {\n    let num: number = number >>> 0;\n\n    let result: string = \"\";\n\n    const digits: string = \"0123456789abcdefghijklmnopqrstuvwxyz\";\n\n    while (num > 0) {\n        const remainder: number = num % 36;\n\n        result += digits[remainder];\n\n        num = Math.floor(num / 36);\n    }\n\n    if (result.length === 0) result = \"0\";\n\n    return result.split(\"\").reverse().join(\"\");\n};\n\nconst fnv1a = (input: string): string => {\n    let result: number = OFFSET_BASIS;\n\n    for (let i: number = 0; i < input.length; i++) {\n        result ^= input.charCodeAt(i);\n\n        result = Math.imul(result, PRIME) >>> 0;\n    }\n\n    return u32ToBase36(result);\n};\n\nconst fixedFnv1a = (input: string, length: number): string => {\n    const hashed: string = fnv1a(input);\n\n    if (hashed.length < length) {\n        return hashed + \"0\".repeat(length - hashed.length);\n    }\n\n    const startLen: number = Math.floor(length / 3);\n\n    const endLen: number = Math.floor(length / 3);\n\n    const centerLen: number = length - startLen - endLen;\n\n    const start: string = hashed.slice(0, startLen);\n\n    const end: string = hashed.slice(hashed.length - endLen);\n\n    const centerStart: number = Math.floor((hashed.length - centerLen) / 2);\n\n    const center: string = hashed.slice(centerStart, centerStart + centerLen);\n\n    return `${start}${center}${end}`;\n};\n\nexport { fixedFnv1a };\n"],"mappings":"AAAA,MAAM,eAAe;AACrB,MAAM,QAAQ;AAEd,MAAM,eAAe,WAA2B;CAC5C,IAAI,MAAc,WAAW;CAE7B,IAAI,SAAiB;CAErB,MAAM,SAAiB;CAEvB,OAAO,MAAM,GAAG;EACZ,MAAM,YAAoB,MAAM;EAEhC,UAAU,OAAO;EAEjB,MAAM,KAAK,MAAM,MAAM,EAAE;CAC7B;CAEA,IAAI,OAAO,WAAW,GAAG,SAAS;CAElC,OAAO,OAAO,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE;AAC7C;AAEA,MAAM,SAAS,UAA0B;CACrC,IAAI,SAAiB;CAErB,KAAK,IAAI,IAAY,GAAG,IAAI,MAAM,QAAQ,KAAK;EAC3C,UAAU,MAAM,WAAW,CAAC;EAE5B,SAAS,KAAK,KAAK,QAAQ,KAAK,MAAM;CAC1C;CAEA,OAAO,YAAY,MAAM;AAC7B;AAEA,MAAM,cAAc,OAAe,WAA2B;CAC1D,MAAM,SAAiB,MAAM,KAAK;CAElC,IAAI,OAAO,SAAS,QAChB,OAAO,SAAS,IAAI,OAAO,SAAS,OAAO,MAAM;CAGrD,MAAM,WAAmB,KAAK,MAAM,SAAS,CAAC;CAE9C,MAAM,SAAiB,KAAK,MAAM,SAAS,CAAC;CAE5C,MAAM,YAAoB,SAAS,WAAW;CAE9C,MAAM,QAAgB,OAAO,MAAM,GAAG,QAAQ;CAE9C,MAAM,MAAc,OAAO,MAAM,OAAO,SAAS,MAAM;CAEvD,MAAM,cAAsB,KAAK,OAAO,OAAO,SAAS,aAAa,CAAC;CAItE,OAAO,GAAG,QAFa,OAAO,MAAM,aAAa,cAAc,SAExC,IAAI;AAC/B"}