UNPKG

@jwooky/base62-uuid

Version:

Base62 encoder / decoder and UUID generator (RFC4122)

3 lines (2 loc) 47 kB
"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var r=function t(){var r=!1;try{r=this instanceof t}catch{}return r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),r}var r={},n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)};function f(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function s(t,e,r,n){var o,i=arguments.length,f=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)f=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(f=(i<3?o(f):i>3?o(e,r,f):o(e,r))||f);return i>3&&f&&Object.defineProperty(e,r,f),f}function u(t,e){return function(r,n){e(r,n,t)}}function a(t,e,r,n,o,i){function f(t){if(void 0!==t&&"function"!=typeof t)throw new TypeError("Function expected");return t}for(var s,u=n.kind,a="getter"===u?"get":"setter"===u?"set":"value",c=!e&&t?n.static?t:t.prototype:null,l=e||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),h=!1,p=r.length-1;p>=0;p--){var y={};for(var g in n)y[g]="access"===g?{}:n[g];for(var g in n.access)y.access[g]=n.access[g];y.addInitializer=function(t){if(h)throw new TypeError("Cannot add initializers after decoration has completed");i.push(f(t||null))};var d=(0,r[p])("accessor"===u?{get:l.get,set:l.set}:l[a],y);if("accessor"===u){if(void 0===d)continue;if(null===d||"object"!=typeof d)throw new TypeError("Object expected");(s=f(d.get))&&(l.get=s),(s=f(d.set))&&(l.set=s),(s=f(d.init))&&o.unshift(s)}else(s=f(d))&&("field"===u?o.unshift(s):l[a]=s)}c&&Object.defineProperty(c,n.name,l),h=!0}function c(t,e,r){for(var n=arguments.length>2,o=0;o<e.length;o++)r=n?e[o].call(t,r):e[o].call(t);return n?r:void 0}function l(t){return"symbol"==typeof t?t:"".concat(t)}function h(t,e,r){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function p(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function y(t,e,r,n){return new(r||(r=Promise))(function(o,i){function f(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(f,s)}u((n=n.apply(t,e||[])).next())})}function g(t,e){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},f=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return f.next=s(0),f.throw=s(1),f.return=s(2),"function"==typeof Symbol&&(f[Symbol.iterator]=function(){return this}),f;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;f&&(f=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var d=Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]};function w(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||d(e,t,r)}function v(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),f=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)f.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return f}function b(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(_(arguments[e]));return t}function m(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],f=0,s=i.length;f<s;f++,o++)n[o]=i[f];return n}function E(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function A(t){return this instanceof A?(this.v=t,this):new A(t)}function U(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(t,e||[]),i=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),f("next"),f("throw"),f("return",function(t){return function(e){return Promise.resolve(e).then(t,a)}}),n[Symbol.asyncIterator]=function(){return this},n;function f(t,e){o[t]&&(n[t]=function(e){return new Promise(function(r,n){i.push([t,e,r,n])>1||s(t,e)})},e&&(n[t]=e(n[t])))}function s(t,e){try{(r=o[t](e)).value instanceof A?Promise.resolve(r.value.v).then(u,a):c(i[0][2],r)}catch(t){c(i[0][3],t)}var r}function u(t){s("next",t)}function a(t){s("throw",t)}function c(t,e){t(e),i.shift(),i.length&&s(i[0][0],i[0][1])}}function P(t){var e,r;return e={},n("next"),n("throw",function(t){throw t}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,o){e[n]=t[n]?function(e){return(r=!r)?{value:A(t[n](e)),done:!1}:o?o(e):e}:o}}function R(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=v(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise(function(n,o){(function(t,e,r,n){Promise.resolve(n).then(function(e){t({value:e,done:r})},e)})(n,o,(e=t[r](e)).done,e.value)})}}}function O(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var T=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e},S=function(t){return S=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},S(t)};function I(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=S(t),n=0;n<r.length;n++)"default"!==r[n]&&d(e,t,r[n]);return T(e,t),e}function j(t){return t&&t.__esModule?t:{default:t}}function D(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}function B(t,e,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(t,r):o?o.value=r:e.set(t,r),r}function x(t,e){if(null===e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof t?e===t:t.has(e)}function M(t,e,r){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var n,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],r&&(o=n)}if("function"!=typeof n)throw new TypeError("Object not disposable.");o&&(n=function(){try{o.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:n,async:r})}else r&&t.stack.push({async:!0});return e}var Y="function"==typeof SuppressedError?SuppressedError:function(t,e,r){var n=new Error(r);return n.name="SuppressedError",n.error=t,n.suppressed=e,n};function C(t){function e(e){t.error=t.hasError?new Y(e,t.error,"An error was suppressed during disposal."):e,t.hasError=!0}var r,n=0;return function o(){for(;r=t.stack.pop();)try{if(!r.async&&1===n)return n=0,t.stack.push(r),Promise.resolve().then(o);if(r.dispose){var i=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(i).then(o,function(t){return e(t),o()})}else n|=1}catch(t){e(t)}if(1===n)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}()}function L(t,e){return"string"==typeof t&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,n,o,i){return r?e?".jsx":".js":!n||o&&i?n+o+"."+i.toLowerCase()+"js":t}):t}var k,N={__extends:o,__assign:i,__rest:f,__decorate:s,__param:u,__esDecorate:a,__runInitializers:c,__propKey:l,__setFunctionName:h,__metadata:p,__awaiter:y,__generator:g,__createBinding:d,__exportStar:w,__values:v,__read:_,__spread:b,__spreadArrays:m,__spreadArray:E,__await:A,__asyncGenerator:U,__asyncDelegator:P,__asyncValues:R,__makeTemplateObject:O,__importStar:I,__importDefault:j,__classPrivateFieldGet:D,__classPrivateFieldSet:B,__classPrivateFieldIn:x,__addDisposableResource:M,__disposeResources:C,__rewriteRelativeImportExtension:L},z=e(Object.freeze({__proto__:null,__addDisposableResource:M,get __assign(){return i},__asyncDelegator:P,__asyncGenerator:U,__asyncValues:R,__await:A,__awaiter:y,__classPrivateFieldGet:D,__classPrivateFieldIn:x,__classPrivateFieldSet:B,__createBinding:d,__decorate:s,__disposeResources:C,__esDecorate:a,__exportStar:w,__extends:o,__generator:g,__importDefault:j,__importStar:I,__makeTemplateObject:O,__metadata:p,__param:u,__propKey:l,__read:_,__rest:f,__rewriteRelativeImportExtension:L,__runInitializers:c,__setFunctionName:h,__spread:b,__spreadArray:E,__spreadArrays:m,__values:v,default:N})),F={};var q="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},V=[],$=[],G="undefined"!=typeof Uint8Array?Uint8Array:Array,K=!1;function X(){K=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)V[e]=t[e],$[t.charCodeAt(e)]=e;$["-".charCodeAt(0)]=62,$["_".charCodeAt(0)]=63}function J(t){return V[t>>18&63]+V[t>>12&63]+V[t>>6&63]+V[63&t]}function Z(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(J(n));return o.join("")}function H(t){var e;K||X();for(var r=t.length,n=r%3,o="",i=[],f=16383,s=0,u=r-n;s<u;s+=f)i.push(Z(t,s,s+f>u?u:s+f));return 1===n?(e=t[r-1],o+=V[e>>2],o+=V[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=V[e>>10],o+=V[e>>4&63],o+=V[e<<2&63],o+="="),i.push(o),i.join("")}function Q(t,e,r,n,o){var i,f,s=8*o-n-1,u=(1<<s)-1,a=u>>1,c=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=h,c-=8);for(f=i&(1<<-c)-1,i>>=-c,c+=n;c>0;f=256*f+t[e+l],l+=h,c-=8);if(0===i)i=1-a;else{if(i===u)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),i-=a}return(p?-1:1)*f*Math.pow(2,i-n)}function W(t,e,r,n,o,i){var f,s,u,a=8*i-o-1,c=(1<<a)-1,l=c>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,f=c):(f=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-f))<1&&(f--,u*=2),(e+=f+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(f++,u/=2),f+l>=c?(s=0,f=c):f+l>=1?(s=(e*u-1)*Math.pow(2,o),f+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),f=0));o>=8;t[r+p]=255&s,p+=y,s/=256,o-=8);for(f=f<<o|s,a+=o;a>0;t[r+p]=255&f,p+=y,f/=256,a-=8);t[r+p-y]|=128*g}var tt={}.toString,et=Array.isArray||function(t){return"[object Array]"==tt.call(t)};it.TYPED_ARRAY_SUPPORT=void 0===q.TYPED_ARRAY_SUPPORT||q.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return it.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ot(t,e){if(nt()<e)throw new RangeError("Invalid typed array length");return it.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=it.prototype:(null===t&&(t=new it(e)),t.length=e),t}function it(t,e,r){if(!(it.TYPED_ARRAY_SUPPORT||this instanceof it))return new it(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return ut(this,t)}return ft(this,t,e,r)}function ft(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);it.TYPED_ARRAY_SUPPORT?(t=e).__proto__=it.prototype:t=at(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!it.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|ht(e,r);t=ot(t,n);var o=t.write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(lt(e)){var r=0|ct(e.length);return 0===(t=ot(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?ot(t,0):at(t,e);if("Buffer"===e.type&&et(e.data))return at(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function st(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function ut(t,e){if(st(e),t=ot(t,e<0?0:0|ct(e)),!it.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function at(t,e){var r=e.length<0?0:0|ct(e.length);t=ot(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function ct(t){if(t>=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|t}function lt(t){return!(null==t||!t._isBuffer)}function ht(t,e){if(lt(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return kt(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Nt(t).length;default:if(n)return kt(t).length;e=(""+e).toLowerCase(),n=!0}}function pt(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return Tt(this,e,r);case"utf8":case"utf-8":return Ut(this,e,r);case"ascii":return Rt(this,e,r);case"latin1":case"binary":return Ot(this,e,r);case"base64":return At(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return St(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function yt(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function gt(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=it.from(e,n)),lt(e))return 0===e.length?-1:dt(t,e,r,n,o);if("number"==typeof e)return e&=255,it.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):dt(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function dt(t,e,r,n,o){var i,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;f=2,s/=2,u/=2,r/=2}function a(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(o){var c=-1;for(i=r;i<s;i++)if(a(t,i)===a(e,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===u)return c*f}else-1!==c&&(i-=i-c),c=-1}else for(r+u>s&&(r=s-u),i=r;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(a(t,i+h)!==a(e,h)){l=!1;break}if(l)return i}return-1}function wt(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var f=0;f<n;++f){var s=parseInt(e.substr(2*f,2),16);if(isNaN(s))return f;t[r+f]=s}return f}function vt(t,e,r,n){return zt(kt(e,t.length-r),t,r,n)}function _t(t,e,r,n){return zt(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function bt(t,e,r,n){return _t(t,e,r,n)}function mt(t,e,r,n){return zt(Nt(e),t,r,n)}function Et(t,e,r,n){return zt(function(t,e){for(var r,n,o,i=[],f=0;f<t.length&&!((e-=2)<0);++f)n=(r=t.charCodeAt(f))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function At(t,e,r){return 0===e&&r===t.length?H(t):H(t.slice(e,r))}function Ut(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,f,s,u,a=t[o],c=null,l=a>239?4:a>223?3:a>191?2:1;if(o+l<=r)switch(l){case 1:a<128&&(c=a);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&a)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],f=t[o+2],128==(192&i)&&128==(192&f)&&(u=(15&a)<<12|(63&i)<<6|63&f)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],f=t[o+2],s=t[o+3],128==(192&i)&&128==(192&f)&&128==(192&s)&&(u=(15&a)<<18|(63&i)<<12|(63&f)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=Pt)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Pt));return r}(n)}it.poolSize=8192,it._augment=function(t){return t.__proto__=it.prototype,t},it.from=function(t,e,r){return ft(null,t,e,r)},it.TYPED_ARRAY_SUPPORT&&(it.prototype.__proto__=Uint8Array.prototype,it.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&it[Symbol.species]),it.alloc=function(t,e,r){return function(t,e,r,n){return st(e),e<=0?ot(t,e):void 0!==r?"string"==typeof n?ot(t,e).fill(r,n):ot(t,e).fill(r):ot(t,e)}(null,t,e,r)},it.allocUnsafe=function(t){return ut(null,t)},it.allocUnsafeSlow=function(t){return ut(null,t)},it.isBuffer=Ft,it.compare=function(t,e){if(!lt(t)||!lt(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},it.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},it.concat=function(t,e){if(!et(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return it.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=it.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var i=t[r];if(!lt(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},it.byteLength=ht,it.prototype._isBuffer=!0,it.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)yt(this,e,e+1);return this},it.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)yt(this,e,e+3),yt(this,e+1,e+2);return this},it.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)yt(this,e,e+7),yt(this,e+1,e+6),yt(this,e+2,e+5),yt(this,e+3,e+4);return this},it.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?Ut(this,0,t):pt.apply(this,arguments)},it.prototype.equals=function(t){if(!lt(t))throw new TypeError("Argument must be a Buffer");return this===t||0===it.compare(this,t)},it.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},it.prototype.compare=function(t,e,r,n,o){if(!lt(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0),s=Math.min(i,f),u=this.slice(n,o),a=t.slice(e,r),c=0;c<s;++c)if(u[c]!==a[c]){i=u[c],f=a[c];break}return i<f?-1:f<i?1:0},it.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},it.prototype.indexOf=function(t,e,r){return gt(this,t,e,r,!0)},it.prototype.lastIndexOf=function(t,e,r){return gt(this,t,e,r,!1)},it.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return wt(this,t,e,r);case"utf8":case"utf-8":return vt(this,t,e,r);case"ascii":return _t(this,t,e,r);case"latin1":case"binary":return bt(this,t,e,r);case"base64":return mt(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},it.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Pt=4096;function Rt(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function Ot(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function Tt(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=Lt(t[i]);return o}function St(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function It(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function jt(t,e,r,n,o,i){if(!lt(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function Dt(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function Bt(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function xt(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Mt(t,e,r,n,o){return o||xt(t,0,r,4),W(t,e,r,n,23,4),r+4}function Yt(t,e,r,n,o){return o||xt(t,0,r,8),W(t,e,r,n,52,8),r+8}it.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),it.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=it.prototype;else{var o=e-t;r=new it(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},it.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||It(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},it.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||It(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},it.prototype.readUInt8=function(t,e){return e||It(t,1,this.length),this[t]},it.prototype.readUInt16LE=function(t,e){return e||It(t,2,this.length),this[t]|this[t+1]<<8},it.prototype.readUInt16BE=function(t,e){return e||It(t,2,this.length),this[t]<<8|this[t+1]},it.prototype.readUInt32LE=function(t,e){return e||It(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},it.prototype.readUInt32BE=function(t,e){return e||It(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},it.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||It(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},it.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||It(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},it.prototype.readInt8=function(t,e){return e||It(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},it.prototype.readInt16LE=function(t,e){e||It(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},it.prototype.readInt16BE=function(t,e){e||It(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},it.prototype.readInt32LE=function(t,e){return e||It(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},it.prototype.readInt32BE=function(t,e){return e||It(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},it.prototype.readFloatLE=function(t,e){return e||It(t,4,this.length),Q(this,t,!0,23,4)},it.prototype.readFloatBE=function(t,e){return e||It(t,4,this.length),Q(this,t,!1,23,4)},it.prototype.readDoubleLE=function(t,e){return e||It(t,8,this.length),Q(this,t,!0,52,8)},it.prototype.readDoubleBE=function(t,e){return e||It(t,8,this.length),Q(this,t,!1,52,8)},it.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||jt(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},it.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||jt(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},it.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,1,255,0),it.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},it.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,2,65535,0),it.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Dt(this,t,e,!0),e+2},it.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,2,65535,0),it.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Dt(this,t,e,!1),e+2},it.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,4,4294967295,0),it.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):Bt(this,t,e,!0),e+4},it.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,4,4294967295,0),it.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Bt(this,t,e,!1),e+4},it.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);jt(this,t,e,r,o-1,-o)}var i=0,f=1,s=0;for(this[e]=255&t;++i<r&&(f*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/f|0)-s&255;return e+r},it.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);jt(this,t,e,r,o-1,-o)}var i=r-1,f=1,s=0;for(this[e+i]=255&t;--i>=0&&(f*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/f|0)-s&255;return e+r},it.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,1,127,-128),it.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},it.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,2,32767,-32768),it.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Dt(this,t,e,!0),e+2},it.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,2,32767,-32768),it.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Dt(this,t,e,!1),e+2},it.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,4,2147483647,-2147483648),it.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Bt(this,t,e,!0),e+4},it.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||jt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),it.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Bt(this,t,e,!1),e+4},it.prototype.writeFloatLE=function(t,e,r){return Mt(this,t,e,!0,r)},it.prototype.writeFloatBE=function(t,e,r){return Mt(this,t,e,!1,r)},it.prototype.writeDoubleLE=function(t,e,r){return Yt(this,t,e,!0,r)},it.prototype.writeDoubleBE=function(t,e,r){return Yt(this,t,e,!1,r)},it.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!it.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},it.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!it.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var f=lt(t)?t:kt(new it(t,n).toString()),s=f.length;for(i=0;i<r-e;++i)this[i+e]=f[i%s]}return this};var Ct=/[^+\/0-9A-Za-z-_]/g;function Lt(t){return t<16?"0"+t.toString(16):t.toString(16)}function kt(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],f=0;f<n;++f){if((r=t.charCodeAt(f))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function Nt(t){return function(t){var e,r,n,o,i,f;K||X();var s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===t[s-2]?2:"="===t[s-1]?1:0,f=new G(3*s/4-i),n=i>0?s-4:s;var u=0;for(e=0,r=0;e<n;e+=4,r+=3)o=$[t.charCodeAt(e)]<<18|$[t.charCodeAt(e+1)]<<12|$[t.charCodeAt(e+2)]<<6|$[t.charCodeAt(e+3)],f[u++]=o>>16&255,f[u++]=o>>8&255,f[u++]=255&o;return 2===i?(o=$[t.charCodeAt(e)]<<2|$[t.charCodeAt(e+1)]>>4,f[u++]=255&o):1===i&&(o=$[t.charCodeAt(e)]<<10|$[t.charCodeAt(e+1)]<<4|$[t.charCodeAt(e+2)]>>2,f[u++]=o>>8&255,f[u++]=255&o),f}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(Ct,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function zt(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function Ft(t){return null!=t&&(!!t._isBuffer||qt(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&qt(t.slice(0,0))}(t))}function qt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var Vt=e(Object.freeze({__proto__:null,Buffer:it,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),it.alloc(+t)},isBuffer:Ft,kMaxLength:rt})),$t=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Gt(t){return"string"==typeof t&&$t.test(t)}function Kt(t){if(!Gt(t))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(t.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,255&e,(e=parseInt(t.slice(9,13),16))>>>8,255&e,(e=parseInt(t.slice(14,18),16))>>>8,255&e,(e=parseInt(t.slice(19,23),16))>>>8,255&e,(e=parseInt(t.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,255&e)}const Xt=[];for(let t=0;t<256;++t)Xt.push((t+256).toString(16).slice(1));function Jt(t,e=0){return(Xt[t[e+0]]+Xt[t[e+1]]+Xt[t[e+2]]+Xt[t[e+3]]+"-"+Xt[t[e+4]]+Xt[t[e+5]]+"-"+Xt[t[e+6]]+Xt[t[e+7]]+"-"+Xt[t[e+8]]+Xt[t[e+9]]+"-"+Xt[t[e+10]]+Xt[t[e+11]]+Xt[t[e+12]]+Xt[t[e+13]]+Xt[t[e+14]]+Xt[t[e+15]]).toLowerCase()}let Zt;const Ht=new Uint8Array(16);function Qt(){if(!Zt){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Zt=crypto.getRandomValues.bind(crypto)}return Zt(Ht)}const Wt={};function te(t,e,r){let n;const o=t?._v6??!1;if(t){const e=Object.keys(t);1===e.length&&"_v6"===e[0]&&(t=void 0)}if(t)n=ee(t.random??t.rng?.()??Qt(),t.msecs,t.nsecs,t.clockseq,t.node,e,r);else{const t=Date.now(),i=Qt();!function(t,e,r){t.msecs??=-1/0,t.nsecs??=0,e===t.msecs?(t.nsecs++,t.nsecs>=1e4&&(t.node=void 0,t.nsecs=0)):e>t.msecs?t.nsecs=0:e<t.msecs&&(t.node=void 0);t.node||(t.node=r.slice(10,16),t.node[0]|=1,t.clockseq=16383&(r[8]<<8|r[9]));t.msecs=e}(Wt,t,i),n=ee(i,Wt.msecs,Wt.nsecs,o?void 0:Wt.clockseq,o?void 0:Wt.node,e,r)}return e??Jt(n)}function ee(t,e,r,n,o,i,f=0){if(t.length<16)throw new Error("Random bytes length must be >= 16");if(i){if(f<0||f+16>i.length)throw new RangeError(`UUID byte range ${f}:${f+15} is out of buffer bounds`)}else i=new Uint8Array(16),f=0;e??=Date.now(),r??=0,n??=16383&(t[8]<<8|t[9]),o??=t.slice(10,16);const s=(1e4*(268435455&(e+=122192928e5))+r)%4294967296;i[f++]=s>>>24&255,i[f++]=s>>>16&255,i[f++]=s>>>8&255,i[f++]=255&s;const u=e/4294967296*1e4&268435455;i[f++]=u>>>8&255,i[f++]=255&u,i[f++]=u>>>24&15|16,i[f++]=u>>>16&255,i[f++]=n>>>8|128,i[f++]=255&n;for(let t=0;t<6;++t)i[f++]=o[t];return i}function re(t){const e=function(t){return Uint8Array.of((15&t[6])<<4|t[7]>>4&15,(15&t[7])<<4|(240&t[4])>>4,(15&t[4])<<4|(240&t[5])>>4,(15&t[5])<<4|(240&t[0])>>4,(15&t[0])<<4|(240&t[1])>>4,(15&t[1])<<4|(240&t[2])>>4,96|15&t[2],t[3],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}("string"==typeof t?Kt(t):t);return"string"==typeof t?Jt(e):e}function ne(t){return function(t){const e=new Uint8Array(4*t.length);for(let r=0;r<4*t.length;r++)e[r]=t[r>>2]>>>r%4*8&255;return e}(function(t,e){const r=new Uint32Array(oe(e)).fill(0);r.set(t),r[e>>5]|=128<<e%32,r[r.length-1]=e,t=r;let n=1732584193,o=-271733879,i=-1732584194,f=271733878;for(let e=0;e<t.length;e+=16){const r=n,s=o,u=i,a=f;n=se(n,o,i,f,t[e],7,-680876936),f=se(f,n,o,i,t[e+1],12,-389564586),i=se(i,f,n,o,t[e+2],17,606105819),o=se(o,i,f,n,t[e+3],22,-1044525330),n=se(n,o,i,f,t[e+4],7,-176418897),f=se(f,n,o,i,t[e+5],12,1200080426),i=se(i,f,n,o,t[e+6],17,-1473231341),o=se(o,i,f,n,t[e+7],22,-45705983),n=se(n,o,i,f,t[e+8],7,1770035416),f=se(f,n,o,i,t[e+9],12,-1958414417),i=se(i,f,n,o,t[e+10],17,-42063),o=se(o,i,f,n,t[e+11],22,-1990404162),n=se(n,o,i,f,t[e+12],7,1804603682),f=se(f,n,o,i,t[e+13],12,-40341101),i=se(i,f,n,o,t[e+14],17,-1502002290),o=se(o,i,f,n,t[e+15],22,1236535329),n=ue(n,o,i,f,t[e+1],5,-165796510),f=ue(f,n,o,i,t[e+6],9,-1069501632),i=ue(i,f,n,o,t[e+11],14,643717713),o=ue(o,i,f,n,t[e],20,-373897302),n=ue(n,o,i,f,t[e+5],5,-701558691),f=ue(f,n,o,i,t[e+10],9,38016083),i=ue(i,f,n,o,t[e+15],14,-660478335),o=ue(o,i,f,n,t[e+4],20,-405537848),n=ue(n,o,i,f,t[e+9],5,568446438),f=ue(f,n,o,i,t[e+14],9,-1019803690),i=ue(i,f,n,o,t[e+3],14,-187363961),o=ue(o,i,f,n,t[e+8],20,1163531501),n=ue(n,o,i,f,t[e+13],5,-1444681467),f=ue(f,n,o,i,t[e+2],9,-51403784),i=ue(i,f,n,o,t[e+7],14,1735328473),o=ue(o,i,f,n,t[e+12],20,-1926607734),n=ae(n,o,i,f,t[e+5],4,-378558),f=ae(f,n,o,i,t[e+8],11,-2022574463),i=ae(i,f,n,o,t[e+11],16,1839030562),o=ae(o,i,f,n,t[e+14],23,-35309556),n=ae(n,o,i,f,t[e+1],4,-1530992060),f=ae(f,n,o,i,t[e+4],11,1272893353),i=ae(i,f,n,o,t[e+7],16,-155497632),o=ae(o,i,f,n,t[e+10],23,-1094730640),n=ae(n,o,i,f,t[e+13],4,681279174),f=ae(f,n,o,i,t[e],11,-358537222),i=ae(i,f,n,o,t[e+3],16,-722521979),o=ae(o,i,f,n,t[e+6],23,76029189),n=ae(n,o,i,f,t[e+9],4,-640364487),f=ae(f,n,o,i,t[e+12],11,-421815835),i=ae(i,f,n,o,t[e+15],16,530742520),o=ae(o,i,f,n,t[e+2],23,-995338651),n=ce(n,o,i,f,t[e],6,-198630844),f=ce(f,n,o,i,t[e+7],10,1126891415),i=ce(i,f,n,o,t[e+14],15,-1416354905),o=ce(o,i,f,n,t[e+5],21,-57434055),n=ce(n,o,i,f,t[e+12],6,1700485571),f=ce(f,n,o,i,t[e+3],10,-1894986606),i=ce(i,f,n,o,t[e+10],15,-1051523),o=ce(o,i,f,n,t[e+1],21,-2054922799),n=ce(n,o,i,f,t[e+8],6,1873313359),f=ce(f,n,o,i,t[e+15],10,-30611744),i=ce(i,f,n,o,t[e+6],15,-1560198380),o=ce(o,i,f,n,t[e+13],21,1309151649),n=ce(n,o,i,f,t[e+4],6,-145523070),f=ce(f,n,o,i,t[e+11],10,-1120210379),i=ce(i,f,n,o,t[e+2],15,718787259),o=ce(o,i,f,n,t[e+9],21,-343485551),n=ie(n,r),o=ie(o,s),i=ie(i,u),f=ie(f,a)}return Uint32Array.of(n,o,i,f)}(function(t){if(0===t.length)return new Uint32Array;const e=new Uint32Array(oe(8*t.length)).fill(0);for(let r=0;r<t.length;r++)e[r>>2]|=(255&t[r])<<r%4*8;return e}(t),8*t.length))}function oe(t){return 14+(t+64>>>9<<4)+1}function ie(t,e){const r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function fe(t,e,r,n,o,i){return ie((f=ie(ie(e,t),ie(n,i)))<<(s=o)|f>>>32-s,r);var f,s}function se(t,e,r,n,o,i,f){return fe(e&r|~e&n,t,e,o,i,f)}function ue(t,e,r,n,o,i,f){return fe(e&n|r&~n,t,e,o,i,f)}function ae(t,e,r,n,o,i,f){return fe(e^r^n,t,e,o,i,f)}function ce(t,e,r,n,o,i,f){return fe(r^(e|~n),t,e,o,i,f)}const le="6ba7b810-9dad-11d1-80b4-00c04fd430c8",he="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function pe(t,e,r,n,o,i){const f="string"==typeof r?function(t){t=unescape(encodeURIComponent(t));const e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r);return e}(r):r,s="string"==typeof n?Kt(n):n;if("string"==typeof n&&(n=Kt(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+f.length);if(u.set(s),u.set(f,s.length),u=e(u),u[6]=15&u[6]|t,u[8]=63&u[8]|128,o){i=i||0;for(let t=0;t<16;++t)o[i+t]=u[t];return o}return Jt(u)}function ye(t,e,r,n){return pe(48,ne,t,e,r,n)}ye.DNS=le,ye.URL=he;var ge={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function de(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function we(t,e){return t<<e|t>>>32-e}function ve(t){const e=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(t.length+1);n.set(t),n[t.length]=128;const o=(t=n).length/4+2,i=Math.ceil(o/16),f=new Array(i);for(let e=0;e<i;++e){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=t[64*e+4*n]<<24|t[64*e+4*n+1]<<16|t[64*e+4*n+2]<<8|t[64*e+4*n+3];f[e]=r}f[i-1][14]=8*(t.length-1)/Math.pow(2,32),f[i-1][14]=Math.floor(f[i-1][14]),f[i-1][15]=8*(t.length-1)&4294967295;for(let t=0;t<i;++t){const n=new Uint32Array(80);for(let e=0;e<16;++e)n[e]=f[t][e];for(let t=16;t<80;++t)n[t]=we(n[t-3]^n[t-8]^n[t-14]^n[t-16],1);let o=r[0],i=r[1],s=r[2],u=r[3],a=r[4];for(let t=0;t<80;++t){const r=Math.floor(t/20),f=we(o,5)+de(r,i,s,u)+a+e[r]+n[t]>>>0;a=u,u=s,s=we(i,30)>>>0,i=o,o=f}r[0]=r[0]+o>>>0,r[1]=r[1]+i>>>0,r[2]=r[2]+s>>>0,r[3]=r[3]+u>>>0,r[4]=r[4]+a>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function _e(t,e,r,n){return pe(80,ve,t,e,r,n)}_e.DNS=le,_e.URL=he;const be={};function me(t,e,r,n,o=0){if(t.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(o<0||o+16>n.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else n=new Uint8Array(16),o=0;return e??=Date.now(),r??=127*t[6]<<24|t[7]<<16|t[8]<<8|t[9],n[o++]=e/1099511627776&255,n[o++]=e/4294967296&255,n[o++]=e/16777216&255,n[o++]=e/65536&255,n[o++]=e/256&255,n[o++]=255&e,n[o++]=112|r>>>28&15,n[o++]=r>>>20&255,n[o++]=128|r>>>14&63,n[o++]=r>>>6&255,n[o++]=r<<2&255|3&t[10],n[o++]=t[11],n[o++]=t[12],n[o++]=t[13],n[o++]=t[14],n[o++]=t[15],n}var Ee,Ae=Object.freeze({__proto__:null,MAX:"ffffffff-ffff-ffff-ffff-ffffffffffff",NIL:"00000000-0000-0000-0000-000000000000",parse:Kt,stringify:function(t,e=0){const r=Jt(t,e);if(!Gt(r))throw TypeError("Stringified UUID is invalid");return r},v1:te,v1ToV6:re,v3:ye,v4:function(t,e,r){if(ge.randomUUID&&!e&&!t)return ge.randomUUID();const n=(t=t||{}).random??t.rng?.()??Qt();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){if((r=r||0)<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[r+t]=n[t];return e}return Jt(n)},v5:_e,v6:function(t,e,r){t??={},r??=0;let n=te({...t,_v6:!0},new Uint8Array(16));if(n=re(n),e){for(let t=0;t<16;t++)e[r+t]=n[t];return e}return Jt(n)},v6ToV1:function(t){const e=function(t){return Uint8Array.of((15&t[3])<<4|t[4]>>4&15,(15&t[4])<<4|(240&t[5])>>4,(15&t[5])<<4|15&t[6],t[7],(15&t[1])<<4|(240&t[2])>>4,(15&t[2])<<4|(240&t[3])>>4,16|(240&t[0])>>4,(15&t[0])<<4|(240&t[1])>>4,t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}("string"==typeof t?Kt(t):t);return"string"==typeof t?Jt(e):e},v7:function(t,e,r){let n;if(t)n=me(t.random??t.rng?.()??Qt(),t.msecs,t.seq,e,r);else{const t=Date.now(),o=Qt();!function(t,e,r){t.msecs??=-1/0,t.seq??=0,e>t.msecs?(t.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],t.msecs=e):(t.seq=t.seq+1|0,0===t.seq&&t.msecs++)}(be,t,o),n=me(o,be.msecs,be.seq,e,r)}return e??Jt(n)},validate:Gt,version:function(t){if(!Gt(t))throw TypeError("Invalid UUID");return parseInt(t.slice(14,15),16)}}),Ue=e(Ae);var Pe=function(){if(Ee)return r;Ee=1,Object.defineProperty(r,"__esModule",{value:!0});const t=z.__importDefault((k||(k=1,Object.defineProperty(F,"__esModule",{value:!0}),F.default=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<t.length;r++){const n=t.charAt(r),o=n.charCodeAt(0);if(255!==e[o])throw new TypeError(n+" is ambiguous");e[o]=r}const r=t.length,n=t.charAt(0),o=Math.log(r)/Math.log(256),i=Math.log(256)/Math.log(r);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let i=0,f=0,s=0;for(;t[i]===n;)f++,i++;const u=(t.length-i)*o+1>>>0,a=new Uint8Array(u);for(;i<t.length;){const n=t.charCodeAt(i);if(n>255)return;let o=e[n];if(255===o)return;let f=0;for(let t=u-1;(0!==o||f<s)&&-1!==t;t--,f++)o+=r*a[t]>>>0,a[t]=o%256>>>0,o=o/256>>>0;if(0!==o)throw new Error("Non-zero carry");s=f,i++}let c=u-s;for(;c!==u&&0===a[c];)c++;const l=new Uint8Array(f+(u-c));let h=f;for(;c!==u;)l[h++]=a[c++];return l}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let o=0,f=0,s=0;const u=e.length;for(;s!==u&&0===e[s];)s++,o++;const a=(u-s)*i+1>>>0,c=new Uint8Array(a);for(;s!==u;){let t=e[s],n=0;for(let e=a-1;(0!==t||n<f)&&-1!==e;e--,n++)t+=256*c[e]>>>0,c[e]=t%r>>>0,t=t/r>>>0;if(0!==t)throw new Error("Non-zero carry");f=n,s++}let l=a-f;for(;l!==a&&0===c[l];)l++;let h=n.repeat(o);for(;l<a;++l)h+=t.charAt(c[l]);return h},decodeUnsafe:f,decode:function(t){const e=f(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}),F)),e=Vt,n=Ue,o=(0,n.v4)(),i=(0,n.v4)(),f=(0,t.default)("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),s=(t="v4")=>{const e=t.split("");return[8,13,18,23].forEach(t=>{e.splice(t,0,"-")}),e.join("")},u=(t,e)=>(t+="").length<e?a(t,e):t.length>e?c(t,e):t,a=(t,e)=>{let r="";for(let n=(t+="").length;n<e;n++)r+="0";return r+t},c=(t,e)=>{t+="";let r=0;for(;"0"===t[r]&&t.length-r>=e;)r++;return t.slice(r)};return r.default=class{constructor(t="v4"){this.version="v4",this.currentId="",this.version=t}uuid(t=""){this.version=t||"v4";const e=this.versionedUUID(this.version);return e instanceof Error?"":e}v1(t=""){const e=t||(0,n.v1)();return this.encode(e)}v4(t=""){const e=t||(0,n.v4)();return this.encode(e)}v5(t=""){const e=t||(0,n.v5)(i,o);return this.encode(e)}v6(t=""){const e=t||(0,n.v6)();return this.encode(e)}v7(t=""){const e=t||(0,n.v7)();return this.encode(e)}encode(t=""){const r=t||(0,n.v4)(),o=e.Buffer.from(r.replace(/-/g,""),"hex"),i=f.encode(o);return u(i,22)}decode(t=""){const r=f.decode(t),n=e.Buffer.from(r).toString("hex"),o=u(n,32),i=32!=o.length?"0"+o:o;return s(i)}versionedUUID(t="v4"){return"v1"==t?(0,n.v1)():"v4"==t?(0,n.v4)():"v5"==t?(0,n.v5)(i,o):"v6"==t?(0,n.v6)():"v7"==t?(0,n.v7)():new Error("Invalid UUID Version: must be [v1, v4, v5, v6 or v7")}},r}(),Re=t(Pe);module.exports=Re; //# sourceMappingURL=base62-uuid.cjs.js.map