import{createHash as e}from"node:crypto";const t=`JKMNPQRTX1234OABCDFG56789H`,n=t=>{let n=e(`md5`);return n.update(t),n.digest()};function r(e){return i(e)^a(e)^o(e)}function i(e){return a(o(s(e)))}function a(e){return o(s(e))}function o(e){return s(e)^e}function s(e){return e&128?255&(e<<1^27):e<<1}const c=e=>[r(e[0])^i(e[1])^a(e[2])^o(e[3]),o(e[0])^r(e[1])^i(e[2])^a(e[3]),a(e[0])^o(e[1])^r(e[2])^i(e[3]),i(e[0])^a(e[1])^o(e[2])^r(e[3])].reduce((e,t)=>e+t)%100,l=(e,r=0,i=``)=>{r||=Math.trunc(Date.now()/1e3),i||=n(Math.random().toString()).toString(`hex`).toUpperCase();let{pathname:a}=new URL(e),o=r+1,s=`/`+a.split(`/`).filter(Boolean).join(`/`)+`/`,l=``,u=n((i+t).replaceAll(/\D/g,``)).toString(`hex`).toLowerCase(),d=n(o+s+u).toString(`hex`).replaceAll(/\D/g,``).slice(0,9).padEnd(9,`0`);for(let e=+d,n=0;n<5;n++){let n=e%26;e=Math.trunc(e/26),l+=t[n]}let f=c([...l].slice(-4).map(e=>e.codePointAt(0))).toString().padStart(2,`0`),p=`hkey=${l}${f}&_time=${r}&nonce=${i}`,m=new URL(e);return m.search+=m.search?`&`+p:p,m.toString()};export{l as t};