(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Uint8Varint = factory()}(typeof self !== 'undefined' ? self : this, function () { "use strict";var Uint8Varint=(()=>{var x=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var T=(r,t)=>{for(var n in t)x(r,n,{get:t[n],enumerable:!0})},l=(r,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of N(t))!M.call(r,o)&&o!==n&&x(r,o,{get:()=>t[o],enumerable:!(e=E(t,o))||e.enumerable});return r};var m=r=>l(x({},"__esModule",{value:!0}),r);var C={};T(C,{decode:()=>_,decodeUint8Array:()=>U,decodeUint8ArrayList:()=>y,encode:()=>S,encodeUint8Array:()=>p,encodeUint8ArrayList:()=>A,encodingLength:()=>F});function d(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function g(r=0){return globalThis.Buffer?.allocUnsafe!=null?d(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}var B=Math.pow(2,7),R=Math.pow(2,14),L=Math.pow(2,21),a=Math.pow(2,28),h=Math.pow(2,35),s=Math.pow(2,42),w=Math.pow(2,49),i=128,c=127;function F(r){if(rNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function p(r,t,n=0){switch(F(r)){case 8:t[n++]=r&255|i,r/=128;case 7:t[n++]=r&255|i,r/=128;case 6:t[n++]=r&255|i,r/=128;case 5:t[n++]=r&255|i,r/=128;case 4:t[n++]=r&255|i,r>>>=7;case 3:t[n++]=r&255|i,r>>>=7;case 2:t[n++]=r&255|i,r>>>=7;case 1:{t[n++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function A(r,t,n=0){switch(F(r)){case 8:t.set(n++,r&255|i),r/=128;case 7:t.set(n++,r&255|i),r/=128;case 6:t.set(n++,r&255|i),r/=128;case 5:t.set(n++,r&255|i),r/=128;case 4:t.set(n++,r&255|i),r>>>=7;case 3:t.set(n++,r&255|i),r>>>=7;case 2:t.set(n++,r&255|i),r>>>=7;case 1:{t.set(n++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function U(r,t){let n=r[t],e=0;if(e+=n&c,n