Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

torrefy

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

torrefy - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

33

dist/decode.d.ts

@@ -0,1 +1,34 @@

import { BData, BList, BObject } from "./encode.js";
declare enum TokenType {
Integer = "Integer",
ByteString = "ByteString",
ListStart = "ListStart",
ListEnd = "ListEnd",
DictionaryStart = "DictionaryStart",
DictionaryEnd = "DictionaryEnd"
}
interface IntegerToken {
type: TokenType.Integer;
value: Uint8Array;
}
interface ByteStringToken {
type: TokenType.ByteString;
value: Uint8Array;
}
interface ListStartToken {
type: TokenType.ListStart;
}
interface ListEndToken {
type: TokenType.ListEnd;
}
interface DictionaryStartToken {
type: TokenType.DictionaryStart;
}
interface DictionaryEndToken {
type: TokenType.DictionaryEnd;
}
declare type Token<T extends TokenType = TokenType> = T extends TokenType.Integer ? IntegerToken : T extends TokenType.ByteString ? ByteStringToken : T extends TokenType.ListStart ? ListStartToken : T extends TokenType.ListEnd ? ListEndToken : T extends TokenType.DictionaryStart ? DictionaryStartToken : T extends TokenType.DictionaryEnd ? DictionaryEndToken : IntegerToken | ByteStringToken | ListStartToken | ListEndToken | DictionaryStartToken | DictionaryEndToken;
export declare function makeTokenizer(): TransformStream<Uint8Array, IntegerToken | ByteStringToken | ListStartToken | ListEndToken | DictionaryStartToken | DictionaryEndToken>;
export declare function parse(tokenReadableStream: ReadableStream<Token>): Promise<string | number | bigint | BObject | BList | undefined>;
export declare function decode(torrentReadableStream: ReadableStream<Uint8Array>): Promise<BData>;
export {};

1

dist/index.d.ts
export * from "./utils.js";
export * from "./encode.js";
export * from "./decode.js";
export * from "./create.js";

2

dist/index.js

@@ -1,1 +0,1 @@

var t={340:t=>{const e=Symbol("path-store-trunk");class n{constructor(t=[]){this._root=new Map,this._size=0;for(const[e,n]of t)this.set(e,n)}set(t,e){return r.call(this,t,e)}has(t){return o.call(this,t)}get(t){return s.call(this,t)}delete(t){return i.call(this,t)}get size(){return this._size}clear(){this._root.clear(),this._size=0}hasPrefix(t){return u.call(this,t)}get[Symbol.toStringTag](){return"ArrayKeyedMap"}*[Symbol.iterator](){yield*a.call(this)}*entries(){yield*a.call(this)}*keys(){yield*h.call(this)}*values(){yield*c.call(this)}forEach(t,e){f.call(this,t,e)}}function r(t,n){let r=this._root;for(const e of t){let t=r.get(e);t||(t=new Map,r.set(e,t)),r=t}return r.has(e)||(this._size+=1),r.set(e,n),this}function o(t){let n=this._root;for(const e of t){const t=n.get(e);if(!t)return!1;n=t}return n.has(e)}function s(t){let n=this._root;for(const e of t)if(n=n.get(e),!n)return;return n.get(e)}function i(t){let n=this._root;const r=[];for(const e of t){const t=n.get(e);if(!t)return!1;r.unshift({parent:n,child:t,item:e}),n=t}const o=n.delete(e);if(o){this._size-=1;for(const{parent:t,child:e,item:n}of r)0===e.size&&t.delete(n)}return o}function u(t){let e=this._root;for(const n of t)if(e=e.get(n),!e)return!1;return!0}function*a(){const t=[{path:[],map:this._root}];for(;t.length>0;){const{path:n,map:r}=t.pop();for(const[o,s]of r.entries())o===e?yield[n,s]:t.push({path:n.concat([o]),map:s})}}function*h(){for(const[t]of this.entries())yield t}function*c(){for(const[,t]of this.entries())yield t}function f(t,e){for(const[n,r]of this.entries())t.call(e,r,n,this)}t.exports=n},913:()=>{try{self["workbox:core:6.5.3"]&&_()}catch(t){}},1:()=>{try{self["workbox:streams:6.5.3"]&&_()}catch(t){}},211:(t,e,n)=>{n.r(e),n.d(e,{default:()=>g});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function o(t,e,n,r){let o,s,i;const u=e||[0],a=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<t.length;o+=1)i=o+a,s=i>>>2,u.length<=s&&u.push(0),u[s]|=t[o]<<8*(h+r*(i%4));return{value:u,binLen:8*t.length+n}}function s(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let o,s,i,u;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o<t.length;o+=2){if(s=parseInt(t.substr(o,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(u=(o>>>1)+h,i=u>>>2;a.length<=i;)a.push(0);a[i]|=s<<8*(c+r*(u%4))}return{value:a,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,o){return function(t,e,n,r,o){let s,i,u,a,h,c,f,l,p=0;const d=n||[0],w=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===o?3:0,u=0;u<t.length;u+=1)for(s=t.charCodeAt(u),i=[],128>s?i.push(s):2048>s?(i.push(192|s>>>6),i.push(128|63&s)):55296>s||57344<=s?i.push(224|s>>>12,128|s>>>6&63,128|63&s):(u+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(u)),i.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),a=0;a<i.length;a+=1){for(c=p+w,h=c>>>2;d.length<=h;)d.push(0);d[h]|=i[a]<<8*(f+o*(c%4)),p+=1}else for(f=-1===o?2:0,l="UTF16LE"===e&&1!==o||"UTF16LE"!==e&&1===o,u=0;u<t.length;u+=1){for(s=t.charCodeAt(u),!0===l&&(a=255&s,s=a<<8|s>>>8),c=p+w,h=c>>>2;d.length<=h;)d.push(0);d[h]|=s<<8*(f+o*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,o,n)};case"B64":return function(t,e,o){return function(t,e,n,o){let s,i,u,a,h,c,f,l=0;const p=e||[0],d=(n=n||0)>>>3,w=-1===o?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<t.length;i+=4){for(h=t.substr(i,4),a=0,u=0;u<h.length;u+=1)s=r.indexOf(h.charAt(u)),a|=s<<18-6*u;for(u=0;u<h.length-1;u+=1){for(f=l+d,c=f>>>2;p.length<=c;)p.push(0);p[c]|=(a>>>16-8*u&255)<<8*(w+o*(f%4)),l+=1}}return{value:p,binLen:8*l+n}}(t,e,o,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let o,s,i,u;const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(s=0;s<t.length;s+=1)o=t.charCodeAt(s),u=s+h,i=u>>>2,a.length<=i&&a.push(0),a[i]|=o<<8*(c+r*(u%4));return{value:a,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return o(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return o(t,e,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function i(t,e,n,o){switch(t){case"HEX":return function(t){return function(t,e,n,r){const o="0123456789abcdef";let s,i,u="";const a=e/8,h=-1===n?3:0;for(s=0;s<a;s+=1)i=t[s>>>2]>>>8*(h+n*(s%4)),u+=o.charAt(i>>>4&15)+o.charAt(15&i);return r.outputUpper?u.toUpperCase():u}(t,e,n,o)};case"B64":return function(t){return function(t,e,n,o){let s,i,u,a,h,c="";const f=e/8,l=-1===n?3:0;for(s=0;s<f;s+=3)for(a=s+1<f?t[s+1>>>2]:0,h=s+2<f?t[s+2>>>2]:0,u=(t[s>>>2]>>>8*(l+n*(s%4))&255)<<16|(a>>>8*(l+n*((s+1)%4))&255)<<8|h>>>8*(l+n*((s+2)%4))&255,i=0;i<4;i+=1)c+=8*s+6*i<=e?r.charAt(u>>>6*(3-i)&63):o.b64Pad;return c}(t,e,n,o)};case"BYTES":return function(t){return function(t,e,n){let r,o,s="";const i=e/8,u=-1===n?3:0;for(r=0;r<i;r+=1)o=t[r>>>2]>>>8*(u+n*(r%4))&255,s+=String.fromCharCode(o);return s}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=new ArrayBuffer(o),i=new Uint8Array(s),u=-1===n?3:0;for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(u+n*(r%4))&255;return s}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=-1===n?3:0,i=new Uint8Array(o);for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(s+n*(r%4))&255;return i}(t,e,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function u(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}function a(t,e){return t<<e|t>>>32-e}function h(t,e,n){return t^e^n}function c(t,e,n){return t&e^t&n^e&n}function f(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function l(t,e,n,r,o){const s=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&o);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16)+(s>>>16))<<16|65535&s}function p(t){return[1732584193,4023233417,2562383102,271733878,3285377520]}function d(t,e){let n,r,o,s,i,u,p;const d=[];for(n=e[0],r=e[1],o=e[2],s=e[3],i=e[4],p=0;p<80;p+=1)d[p]=p<16?t[p]:a(d[p-3]^d[p-8]^d[p-14]^d[p-16],1),u=p<20?l(a(n,5),(w=r)&o^~w&s,i,1518500249,d[p]):p<40?l(a(n,5),h(r,o,s),i,1859775393,d[p]):p<60?l(a(n,5),c(r,o,s),i,2400959708,d[p]):l(a(n,5),h(r,o,s),i,3395469782,d[p]),i=s,s=o,o=a(r,30),r=n,n=u;var w;return e[0]=f(n,e[0]),e[1]=f(r,e[1]),e[2]=f(o,e[2]),e[3]=f(s,e[3]),e[4]=f(i,e[4]),e}function w(t,e,n,r){let o;const s=15+(e+65>>>9<<4),i=e+n;for(;t.length<=s;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[s]=4294967295&i,t[s-1]=i/4294967296|0,o=0;o<t.length;o+=16)r=d(t.slice(o,o+16),r);return r}class g extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.R=[],this.U=[]}update(t){let e,n=0;const r=this.T>>>5,o=this.F(t,this.h,this.u),s=o.binLen,i=o.value,u=s>>>5;for(e=0;e<u;e+=r)n+this.T<=s&&(this.m=this.g(i.slice(e,e+r),this.m),n+=this.T);return this.A+=n,this.h=i.slice(n>>>5),this.u=s%this.T,this.l=!0,this}getHash(t,e){let n,r,o=this.B;const s=u(e);if(this.v){if(-1===s.outputLen)throw new Error("Output length must be specified in options");o=s.outputLen}const a=i(t,o,this.Y,s);if(this.p&&this.H)return a(this.H(s));for(r=this.C(this.h.slice(),this.u,this.A,this.I(this.m),o),n=1;n<this.numRounds;n+=1)this.v&&o%32!=0&&(r[r.length-1]&=16777215>>>24-o%32),r=this.C(r,o,0,this.L(this.o),o);return a(r)}setHMACKey(t,e,n){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=s(e,(n||{}).encoding||"UTF8",this.Y);this.N(r(t))}N(t){const e=this.T>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.C(t.value,t.binLen,0,this.L(this.o),this.B));t.value.length<=n;)t.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^t.value[r],this.U[r]=1549556828^t.value[r];this.m=this.g(this.R,this.m),this.A=this.T,this.p=!0}getHMAC(t,e){const n=u(e);return i(t,this.B,this.Y,n)(this.S())}S(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.C(this.h.slice(),this.u,this.A,this.I(this.m),this.B);return t=this.g(this.U,this.L(this.o)),t=this.C(e,this.B,this.T,t,this.B),t}}{constructor(t,e,n){if("SHA-1"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.M=!0,this.H=this.S,this.Y=-1,this.F=s(this.t,this.i,this.Y),this.g=d,this.I=function(t){return t.slice()},this.L=p,this.C=w,this.m=[1732584193,4023233417,2562383102,271733878,3285377520],this.T=512,this.B=160,this.v=!1,r.hmacKey&&this.N(function(t,e,n,r){const o="hmacKey must include a value and format";if(!e)throw new Error(o);if(void 0===e.value||!e.format)throw new Error(o);return s(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.Y))}}},673:(t,e,n)=>{n.r(e),n.d(e,{default:()=>E});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function o(t,e,n,r){let o,s,i;const u=e||[0],a=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<t.length;o+=1)i=o+a,s=i>>>2,u.length<=s&&u.push(0),u[s]|=t[o]<<8*(h+r*(i%4));return{value:u,binLen:8*t.length+n}}function s(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let o,s,i,u;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o<t.length;o+=2){if(s=parseInt(t.substr(o,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(u=(o>>>1)+h,i=u>>>2;a.length<=i;)a.push(0);a[i]|=s<<8*(c+r*(u%4))}return{value:a,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,o){return function(t,e,n,r,o){let s,i,u,a,h,c,f,l,p=0;const d=n||[0],w=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===o?3:0,u=0;u<t.length;u+=1)for(s=t.charCodeAt(u),i=[],128>s?i.push(s):2048>s?(i.push(192|s>>>6),i.push(128|63&s)):55296>s||57344<=s?i.push(224|s>>>12,128|s>>>6&63,128|63&s):(u+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(u)),i.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),a=0;a<i.length;a+=1){for(c=p+w,h=c>>>2;d.length<=h;)d.push(0);d[h]|=i[a]<<8*(f+o*(c%4)),p+=1}else for(f=-1===o?2:0,l="UTF16LE"===e&&1!==o||"UTF16LE"!==e&&1===o,u=0;u<t.length;u+=1){for(s=t.charCodeAt(u),!0===l&&(a=255&s,s=a<<8|s>>>8),c=p+w,h=c>>>2;d.length<=h;)d.push(0);d[h]|=s<<8*(f+o*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,o,n)};case"B64":return function(t,e,o){return function(t,e,n,o){let s,i,u,a,h,c,f,l=0;const p=e||[0],d=(n=n||0)>>>3,w=-1===o?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<t.length;i+=4){for(h=t.substr(i,4),a=0,u=0;u<h.length;u+=1)s=r.indexOf(h.charAt(u)),a|=s<<18-6*u;for(u=0;u<h.length-1;u+=1){for(f=l+d,c=f>>>2;p.length<=c;)p.push(0);p[c]|=(a>>>16-8*u&255)<<8*(w+o*(f%4)),l+=1}}return{value:p,binLen:8*l+n}}(t,e,o,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let o,s,i,u;const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(s=0;s<t.length;s+=1)o=t.charCodeAt(s),u=s+h,i=u>>>2,a.length<=i&&a.push(0),a[i]|=o<<8*(c+r*(u%4));return{value:a,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return o(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return o(t,e,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function i(t,e,n,o){switch(t){case"HEX":return function(t){return function(t,e,n,r){const o="0123456789abcdef";let s,i,u="";const a=e/8,h=-1===n?3:0;for(s=0;s<a;s+=1)i=t[s>>>2]>>>8*(h+n*(s%4)),u+=o.charAt(i>>>4&15)+o.charAt(15&i);return r.outputUpper?u.toUpperCase():u}(t,e,n,o)};case"B64":return function(t){return function(t,e,n,o){let s,i,u,a,h,c="";const f=e/8,l=-1===n?3:0;for(s=0;s<f;s+=3)for(a=s+1<f?t[s+1>>>2]:0,h=s+2<f?t[s+2>>>2]:0,u=(t[s>>>2]>>>8*(l+n*(s%4))&255)<<16|(a>>>8*(l+n*((s+1)%4))&255)<<8|h>>>8*(l+n*((s+2)%4))&255,i=0;i<4;i+=1)c+=8*s+6*i<=e?r.charAt(u>>>6*(3-i)&63):o.b64Pad;return c}(t,e,n,o)};case"BYTES":return function(t){return function(t,e,n){let r,o,s="";const i=e/8,u=-1===n?3:0;for(r=0;r<i;r+=1)o=t[r>>>2]>>>8*(u+n*(r%4))&255,s+=String.fromCharCode(o);return s}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=new ArrayBuffer(o),i=new Uint8Array(s),u=-1===n?3:0;for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(u+n*(r%4))&255;return s}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=-1===n?3:0,i=new Uint8Array(o);for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(s+n*(r%4))&255;return i}(t,e,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const u=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function c(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}function f(t,e){return t>>>e|t<<32-e}function l(t,e){return t>>>e}function p(t,e,n){return t&e^~t&n}function d(t,e,n){return t&e^t&n^e&n}function w(t){return f(t,2)^f(t,13)^f(t,22)}function g(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function m(t,e,n,r){const o=(65535&t)+(65535&e)+(65535&n)+(65535&r);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16))<<16|65535&o}function y(t,e,n,r,o){const s=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&o);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16)+(s>>>16))<<16|65535&s}function A(t){return f(t,7)^f(t,18)^l(t,3)}function b(t){return f(t,6)^f(t,11)^f(t,25)}function v(t){let e;return e="SHA-224"==t?a.slice():h.slice(),e}function R(t,e){let n,r,o,s,i,a,h,c,v,R,E;const U=[];for(n=e[0],r=e[1],o=e[2],s=e[3],i=e[4],a=e[5],h=e[6],c=e[7],E=0;E<64;E+=1)U[E]=E<16?t[E]:m(f(T=U[E-2],17)^f(T,19)^l(T,10),U[E-7],A(U[E-15]),U[E-16]),v=y(c,b(i),p(i,a,h),u[E],U[E]),R=g(w(n),d(n,r,o)),c=h,h=a,a=i,i=g(s,v),s=o,o=r,r=n,n=g(v,R);var T;return e[0]=g(n,e[0]),e[1]=g(r,e[1]),e[2]=g(o,e[2]),e[3]=g(s,e[3]),e[4]=g(i,e[4]),e[5]=g(a,e[5]),e[6]=g(h,e[6]),e[7]=g(c,e[7]),e}class E extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.A=!1,this.l=0,this.p=!1,this.R=[],this.U=[]}update(t){let e,n=0;const r=this.T>>>5,o=this.F(t,this.h,this.u),s=o.binLen,i=o.value,u=s>>>5;for(e=0;e<u;e+=r)n+this.T<=s&&(this.m=this.g(i.slice(e,e+r),this.m),n+=this.T);return this.l+=n,this.h=i.slice(n>>>5),this.u=s%this.T,this.A=!0,this}getHash(t,e){let n,r,o=this.B;const s=c(e);if(this.H){if(-1===s.outputLen)throw new Error("Output length must be specified in options");o=s.outputLen}const u=i(t,o,this.v,s);if(this.p&&this.Y)return u(this.Y(s));for(r=this.C(this.h.slice(),this.u,this.l,this.S(this.m),o),n=1;n<this.numRounds;n+=1)this.H&&o%32!=0&&(r[r.length-1]&=16777215>>>24-o%32),r=this.C(r,o,0,this.I(this.o),o);return u(r)}setHMACKey(t,e,n){if(!this.L)throw new Error("Variant does not support HMAC");if(this.A)throw new Error("Cannot set MAC key after calling update");const r=s(e,(n||{}).encoding||"UTF8",this.v);this.M(r(t))}M(t){const e=this.T>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.C(t.value,t.binLen,0,this.I(this.o),this.B));t.value.length<=n;)t.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^t.value[r],this.U[r]=1549556828^t.value[r];this.m=this.g(this.R,this.m),this.l=this.T,this.p=!0}getHMAC(t,e){const n=c(e);return i(t,this.B,this.v,n)(this.N())}N(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.C(this.h.slice(),this.u,this.l,this.S(this.m),this.B);return t=this.g(this.U,this.I(this.o)),t=this.C(e,this.B,this.T,t,this.B),t}}{constructor(t,e,n){if("SHA-224"!==t&&"SHA-256"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.Y=this.N,this.L=!0,this.v=-1,this.F=s(this.t,this.i,this.v),this.g=R,this.S=function(t){return t.slice()},this.I=v,this.C=function(e,n,r,o){return function(t,e,n,r,o){let s,i;const u=15+(e+65>>>9<<4),a=e+n;for(;t.length<=u;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[u]=4294967295&a,t[u-1]=a/4294967296|0,s=0;s<t.length;s+=16)r=R(t.slice(s,s+16),r);return i="SHA-224"===o?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,i}(e,n,r,o,t)},this.m=v(t),this.T=512,this.B="SHA-224"===t?224:256,this.H=!1,r.hmacKey&&this.M(function(t,e,n,r){const o="hmacKey must include a value and format";if(!e)throw new Error(o);if(void 0===e.value||!e.format)throw new Error(o);return s(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.v))}}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};(()=>{n.d(r,{SO:()=>A(),Xz:()=>v,ul:()=>R,zM:()=>b,xI:()=>k,$$:()=>Y,vB:()=>H,wY:()=>m,UQ:()=>p,Ue:()=>D,w6:()=>g,cv:()=>U,Dd:()=>d,sK:()=>a,bX:()=>h,Dc:()=>f,fp:()=>l,xT:()=>w,DN:()=>c,yQ:()=>L,Zk:()=>F,uh:()=>B});const t={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let e;const o=new Uint8Array(16);function s(){if(!e&&(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!e))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(o)}const i=[];for(let t=0;t<256;++t)i.push((t+256).toString(16).slice(1));const u=function(e,n,r){if(t.randomUUID&&!n&&!e)return t.randomUUID();const o=(e=e||{}).random||(e.rng||s)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,n){r=r||0;for(let t=0;t<16;++t)n[r+t]=o[t];return n}return function(t,e=0){return(i[t[e+0]]+i[t[e+1]]+i[t[e+2]]+i[t[e+3]]+"-"+i[t[e+4]]+i[t[e+5]]+"-"+i[t[e+6]]+i[t[e+7]]+"-"+i[t[e+8]]+i[t[e+9]]+"-"+i[t[e+10]]+i[t[e+11]]+i[t[e+12]]+i[t[e+13]]+i[t[e+14]]+i[t[e+15]]).toLowerCase()}(o)};function a(t,e,n){let r=0,o=t.length;for(;r<o;){const s=r+o>>>1;n(t[s],e)<0?r=s+1:o=s}return r}function h(t,e){const n=[];for(const r of t)n.splice(a(n,r,e),0,r);return n}function c(t){let e=[];const n=new WeakMap;for(const r of t){const t=(r.webkitRelativePath||r.name).split("/");t.reduce(((e,o,s)=>{let i=e.find((t=>t[0]===o));if(i)return i[1];const u=a(e,o,((t,e)=>t[0]<e?-1:1));if(s===t.length-1){const t={"":{length:r.size}};n.set(t,r),i=[o,t]}else i=[o,[]];return e.splice(u,0,i),i[1]}),e)}let r;1===e.length&&Array.isArray(e[0][1])&&(r=e[0][0],e=e[0][1]);const o=[];return{fileTree:{*[Symbol.iterator](){for(const t of o)yield t},...function t(e){if(Array.isArray(e)){const n={};for(const r of e)n[r[0]]=t(r[1]);return n}{const t=e;return o.push(t),t}}(e)},fileNodeMap:n,commonDir:r}}async function f(t){const e=new Uint8Array(64);for(;t.length>1;){let n=!1;const r=[];for(const o of t)n?(e.set(o,32),r.push(new Uint8Array(await crypto.subtle.digest("SHA-256",e))),n=!1):(e.set(o),n=!0);t=r}return t[0]}function l(t){return 1<<32-Math.clz32(t-1)}function p(t){if(void 0===t)return;const e=[];for(const n of t)0!==n.length&&e.push(n);return 0!==e.length?e:void 0}function d(t){let e;for(const n of t){const t=(n.webkitRelativePath||n.name).split("/");if(1==t.length||(e??=t[0])!==t[0])return}return e}function w(t,e,n){const r=[],o=t.length-1;for(const[s,i]of t.entries()){if(r.push(i),s===o)break;const t=i.size%e;if(0===t)continue;const u=e-t,a=new File([new ArrayBuffer(u)],`${u}`,{type:"application/octet-stream"}),h=`.pad/${u}`,c=void 0===n?h:`${n}/${h}`;Object.defineProperties(a,{webkitRelativePath:{configurable:!0,enumerable:!0,get:()=>c},padding:{configurable:!0,enumerable:!1,get:()=>!0}}),r.push(a)}return r}function g(t,e,n){return void 0===e&&1===n.length?t=n[0].name:t??=e||u(),t}function m(t,e){return Math.max(e,l(t>>>10))}var y=n(340),A=n.n(y);const b=new Uint8Array([108]),v=new Uint8Array([100]),R=new Uint8Array([101]);class E{textEncoder=new TextEncoder;textDecoder=new TextDecoder;data;hooks;isHooking=!1;path=[];constructor(t,e){this.data=t,this.hooks=e}start(t){this.encode(this.data,t),t.close()}encode(t,e){if(null!=t)if("boolean"==typeof t)this.encode(t?1:0,e);else if("number"==typeof t){const n=Math.round(t);e.enqueue(this.textEncoder.encode(`i${n}e`)),n!==t&&(console.warn(`WARNING: Possible data corruption detected with value "${t}":`,`Bencoding only defines support for integers, value was converted to "${n}"`),console.trace())}else if("bigint"==typeof t)e.enqueue(this.textEncoder.encode(`i${t}e`));else if("string"==typeof t){const n=this.textEncoder.encode(t),r=n.byteLength;e.enqueue(this.textEncoder.encode(`${r}:`)),e.enqueue(n)}else if(t instanceof ArrayBuffer){const n=new Uint8Array(t),r=n.byteLength;e.enqueue(this.textEncoder.encode(`${r}:`)),e.enqueue(n)}else if(Array.isArray(t)){e.enqueue(b);for(let n of t)this.encode(n,e);e.enqueue(R)}else if(t instanceof Map){e.enqueue(v);const n=h(t.keys(),((t,e)=>(t="string"==typeof t?t:this.textDecoder.decode(t))<(e="string"==typeof e?e:this.textDecoder.decode(e))?-1:t>e?1:0));for(const r of n){const n=t.get(r);if(void 0!==n&&null!==t){if(this.path.push(r),this.encode(r,e),this.hooks){const t=this.hooks.get(this.path);if(t){const r=T(e,t);this.encode(n,r),t({value:void 0,done:!0})}else this.encode(n,e)}this.path.pop()}}e.enqueue(R)}else{e.enqueue(v);const n=Object.keys(t).sort();for(const r of n){const n=t[r];if(void 0!==n&&null!==t){if(this.path.push(r),this.encode(r,e),this.hooks){const t=this.hooks.get(this.path);if(t){const r=T(e,t);this.encode(n,r),t({value:void 0,done:!0})}else this.encode(n,e)}this.path.pop()}}e.enqueue(R)}}}function U(t,e){return new ReadableStream(new E(t,e))}function T(t,e){return new Proxy(t,{get:function(t,n,r){return"enqueue"!==n?Reflect.get(t,n,r):(n=>{t.enqueue(n),void 0!==n&&e({value:n,done:!1})}).bind(t)}})}function B(){const t={controller:null};return[new ReadableStream({start(e){t.controller=e}}),({value:e,done:n})=>{null!==t.controller&&(n?t.controller.close():t.controller.enqueue(e))}]}function L(){const[t,e]=B();return[new Response(t).arrayBuffer(),e]}function F(){const[t,e]=B();return[new Response(t).text(),e]}n(913);class C extends Error{constructor(t,e){super(((t,...e)=>{let n=t;return e.length>0&&(n+=` :: ${JSON.stringify(e)}`),n})(t,e)),this.name=t,this.details=e}}class S{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}function M(t){const e=t.map((t=>Promise.resolve(t).then((t=>function(t){if(t instanceof Response){if(t.body)return t.body.getReader();throw new C("opaque-streams-source",{type:t.type})}return t instanceof ReadableStream?t.getReader():new Response(t).body.getReader()}(t))))),n=new S;let r=0;const o=new ReadableStream({pull(t){return e[r].then((t=>t.read())).then((o=>{if(o.done)return r++,r>=e.length?(t.close(),void n.resolve()):this.pull(t);t.enqueue(o.value)})).catch((t=>{throw n.reject(t),t}))},cancel(){n.resolve()}});return{done:n.promise,stream:o}}var H;n(1),function(t){t.V1="v1",t.V2="v2",t.HYBRID="hybrid"}(H||(H={}));const Y=16384;var k;!function(t){t[t["16KB"]=16384]="16KB",t[t["32KB"]=32768]="32KB",t[t["64KB"]=65536]="64KB",t[t["128KB"]=131072]="128KB",t[t["256KB"]=262144]="256KB",t[t["512KB"]=524288]="512KB",t[t["1MB"]=1048576]="1MB",t[t["2MB"]=2097152]="2MB",t[t["4MB"]=4194304]="4MB",t[t["8MB"]=8388608]="8MB",t[t["16MB"]=16777216]="16MB",t[t["32MB"]=33554432]="32MB"}(k||(k={}));const I=new Uint8Array(32),P={type:H.V1,addCreatedBy:!0,addCreationDate:!0,addPaddingFiles:!1,blockLength:Y,sortFiles:!0,isPrivate:!1},N={type:H.V2,addCreatedBy:!0,addCreationDate:!0,blockLength:Y,metaVersion:2,isPrivate:!1},x={type:H.HYBRID,addCreatedBy:!0,addCreationDate:!0,blockLength:Y,metaVersion:2,isPrivate:!1};async function D(t,e={type:H.V1},r=((t,e)=>{})){if(0===t.length)throw new Error("empty file list");let o;switch(e.type){case H.V1:o={...P,...e};break;case H.V2:o={...N,...e};break;case H.HYBRID:o={...x,...e}}o.pieceLength??=m(t.reduce(((t,e)=>t+e.size),0),o.blockLength);let{addCreatedBy:s,addCreationDate:i,blockLength:u,comment:a,isPrivate:h,name:y,pieceLength:A}=o;if(o.type!==H.V1&&A<u)throw new Error(`piece length ${A} is smaller than block length ${u}`);if(0!=(A&A-1))throw new Error(`piece length ${A} is not a power of 2`);const b=A/u;o.announceList=p(o.announceList),void 0===o.announce&&void 0!==o.announceList&&(o.announce=o.announceList[0][0]);const{announce:v,announceList:R}=o,E={...v&&{announce:v},...R&&{"announce-list":R},...a&&{comment:a},...s&&{"created by":"torrefy v2.0.1"},...i&&{"creation date":Date.now()/1e3>>0}};let U,T,B=0,L=t.reduce(((t,e)=>t+Math.ceil(e.size/A)),0);if(o.type===H.V1){const{addPaddingFiles:e,sortFiles:n}=o;let r,s;if(n){const{fileTree:e,fileNodeMap:n,commonDir:r}=c(t);t=[...e].map((t=>n.get(t))),s=r}else s=d(t);if(o.name=y=g(y,s,t),e){const e=t.length-1;r=M(t.map((async(t,n)=>C(t.stream(),{padding:n!==e})))).stream,t=w(t,A,s)}else{L=Math.ceil(t.reduce(((t,e)=>t+e.size),0)/A);const{stream:e}=M(t.map((t=>Promise.resolve(t.stream()))));r=C(e)}U={...E,info:{...t.length>1?{files:t.map((t=>{const e=(t.webkitRelativePath||t.name).split("/");return void 0!==s&&e.shift(),{...t.padding&&{attr:"p"},length:t.size,path:e}}))}:{length:t[0].size},name:y,"piece length":A,pieces:await new Response(r).arrayBuffer(),...h&&{private:1}}}}else if(o.type===H.V2){const{metaVersion:e}=o,{fileTree:n,fileNodeMap:r,commonDir:s}=c(t),i=[...n];t=i.map((t=>r.get(t)));const u=new Map;o.name=y=g(y,s,t),await Promise.all(i.map((async(e,n)=>{const r=t[n];await F(e,r,r.stream(),u)}))),U={...E,info:{"file tree":n,"meta version":e,name:y,"piece length":A,...h&&{private:1}},...u.size>0&&{"piece layers":u}}}else{if(o.type!==H.HYBRID)throw new Error("torrent type is not supported");{const{metaVersion:e}=o,{fileTree:n,fileNodeMap:r,commonDir:s}=c(t),i=[...n];t=i.map((t=>r.get(t)));const u=new Map;o.name=y=g(y,s,t),L*=2;const a=t.length-1,f=[];await Promise.all(i.map((async(e,n)=>{const r=t[n],[o,s]=r.stream().tee();f.push(Promise.resolve(C(o,{padding:n!==a}))),await F(e,r,s,u)})));const l=M(f).stream;t=w(t,A,s),U={...E,info:{"file tree":n,...t.length>1?{files:t.map((t=>{const e=(t.webkitRelativePath||t.name).split("/");return void 0!==s&&e.shift(),{...t.padding&&{attr:"p"},length:t.size,path:e}}))}:{length:t[0].size},"meta version":e,name:y,"piece length":A,pieces:await new Response(l).arrayBuffer(),...h&&{private:1}},...u.size>0&&{"piece layers":u}}}}return U;async function F(t,e,r,o){const[s,i]=function(t){const e=t.pipeThrough(S(u)).pipeThrough(function(){let t=0,e=[];return new TransformStream({transform:async(r,o)=>{let s;++t;try{s=new Uint8Array(await crypto.subtle.digest("SHA-256",r))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,673)),e=new t("SHA-256","UINT8ARRAY");e.update(r),s=e.getHash("UINT8ARRAY")}e.push(s),e.length===b&&(o.enqueue(e),e=[])},flush:async n=>{if(0===t)return;let r=0;if(t<b)r=l(t)-t;else{const e=t%b;e>0&&(r=b-e)}if(r>0)for(let t=0;t<r;++t)e.push(I);e.length>0&&n.enqueue(e)}})}()).pipeThrough(Y(!0)),[r,o]=e.tee();return[o.pipeThrough(k()).pipeThrough(Y()),r]}(r),a=new Response(s).arrayBuffer();if(e.size>A){const t=new Response(i).arrayBuffer();o.set(await a,await t)}e.size>0&&(t[""]["pieces root"]=await a)}function C(t,e={padding:!1}){return t.pipeThrough(S(A,{padding:e.padding})).pipeThrough(function(t=!1){return new TransformStream({transform:async(e,o)=>{let s;try{s=new Uint8Array(await crypto.subtle.digest("SHA-1",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,211)),r=new t("SHA-1","UINT8ARRAY");r.update(e),s=r.getHash("UINT8ARRAY")}o.enqueue(s),t&&r(++B,L)}})}(!0))}function S(t,e={padding:!1}){let n=new Uint8Array(t),r=0;return new TransformStream({transform:(e,o)=>{for(;r+e.length>=t;){const s=t-r;n.set(e.subarray(0,s),r),r=0,o.enqueue(new Uint8Array(n)),e=e.subarray(s)}n.set(e,r),r+=e.length},flush:o=>{r>0&&(e.padding?(n.set(new Uint8Array(t-r),r),o.enqueue(n)):o.enqueue(n.subarray(0,r)))}})}function Y(t=!1){return new TransformStream({transform:async(e,n)=>{n.enqueue(await f(e)),t&&r(++B,L)}})}function k(){let t=0,e=[];return new TransformStream({transform:n=>{++t,e.push(n)},flush:async n=>{const r=l(t)-t;if(r>0){T??=await f(Array(b).fill(new Uint8Array(32)));for(let t=0;t<r;++t)e.push(T)}n.enqueue(e)}})}}})();var o=r.SO,s=r.Xz,i=r.ul,u=r.zM,a=r.xI,h=r.$$,c=r.vB,f=r.wY,l=r.UQ,p=r.Ue,d=r.w6,w=r.cv,g=r.Dd,m=r.sK,y=r.bX,A=r.Dc,b=r.fp,v=r.xT,R=r.DN,E=r.yQ,U=r.Zk,T=r.uh;export{o as ArrayKeyedMap,s as BUFF_D,i as BUFF_E,u as BUFF_L,a as CommonPieceLength,h as DEFAULT_BLOCK_LENGTH,c as TorrentType,f as calculatePieceLength,l as collapseAnnounceList,p as create,d as decideName,w as encode,g as getCommonDir,m as getSortedIndex,y as iterableSort,A as merkleRoot,b as nextPowerOfTwo,v as padFiles,R as parseFileTree,E as useArrayBufferPromiseHook,U as useTextPromiseHook,T as useUint8ArrayStreamHook};
var t={340:t=>{const e=Symbol("path-store-trunk");class n{constructor(t=[]){this._root=new Map,this._size=0;for(const[e,n]of t)this.set(e,n)}set(t,e){return r.call(this,t,e)}has(t){return o.call(this,t)}get(t){return s.call(this,t)}delete(t){return i.call(this,t)}get size(){return this._size}clear(){this._root.clear(),this._size=0}hasPrefix(t){return a.call(this,t)}get[Symbol.toStringTag](){return"ArrayKeyedMap"}*[Symbol.iterator](){yield*u.call(this)}*entries(){yield*u.call(this)}*keys(){yield*h.call(this)}*values(){yield*c.call(this)}forEach(t,e){f.call(this,t,e)}}function r(t,n){let r=this._root;for(const e of t){let t=r.get(e);t||(t=new Map,r.set(e,t)),r=t}return r.has(e)||(this._size+=1),r.set(e,n),this}function o(t){let n=this._root;for(const e of t){const t=n.get(e);if(!t)return!1;n=t}return n.has(e)}function s(t){let n=this._root;for(const e of t)if(n=n.get(e),!n)return;return n.get(e)}function i(t){let n=this._root;const r=[];for(const e of t){const t=n.get(e);if(!t)return!1;r.unshift({parent:n,child:t,item:e}),n=t}const o=n.delete(e);if(o){this._size-=1;for(const{parent:t,child:e,item:n}of r)0===e.size&&t.delete(n)}return o}function a(t){let e=this._root;for(const n of t)if(e=e.get(n),!e)return!1;return!0}function*u(){const t=[{path:[],map:this._root}];for(;t.length>0;){const{path:n,map:r}=t.pop();for(const[o,s]of r.entries())o===e?yield[n,s]:t.push({path:n.concat([o]),map:s})}}function*h(){for(const[t]of this.entries())yield t}function*c(){for(const[,t]of this.entries())yield t}function f(t,e){for(const[n,r]of this.entries())t.call(e,r,n,this)}t.exports=n},913:()=>{try{self["workbox:core:6.5.3"]&&_()}catch(t){}},1:()=>{try{self["workbox:streams:6.5.3"]&&_()}catch(t){}},211:(t,e,n)=>{n.r(e),n.d(e,{default:()=>y});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function o(t,e,n,r){let o,s,i;const a=e||[0],u=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<t.length;o+=1)i=o+u,s=i>>>2,a.length<=s&&a.push(0),a[s]|=t[o]<<8*(h+r*(i%4));return{value:a,binLen:8*t.length+n}}function s(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let o,s,i,a;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const u=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o<t.length;o+=2){if(s=parseInt(t.substr(o,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(a=(o>>>1)+h,i=a>>>2;u.length<=i;)u.push(0);u[i]|=s<<8*(c+r*(a%4))}return{value:u,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,o){return function(t,e,n,r,o){let s,i,a,u,h,c,f,l,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===o?3:0,a=0;a<t.length;a+=1)for(s=t.charCodeAt(a),i=[],128>s?i.push(s):2048>s?(i.push(192|s>>>6),i.push(128|63&s)):55296>s||57344<=s?i.push(224|s>>>12,128|s>>>6&63,128|63&s):(a+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(a)),i.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u<i.length;u+=1){for(c=p+g,h=c>>>2;d.length<=h;)d.push(0);d[h]|=i[u]<<8*(f+o*(c%4)),p+=1}else for(f=-1===o?2:0,l="UTF16LE"===e&&1!==o||"UTF16LE"!==e&&1===o,a=0;a<t.length;a+=1){for(s=t.charCodeAt(a),!0===l&&(u=255&s,s=u<<8|s>>>8),c=p+g,h=c>>>2;d.length<=h;)d.push(0);d[h]|=s<<8*(f+o*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,o,n)};case"B64":return function(t,e,o){return function(t,e,n,o){let s,i,a,u,h,c,f,l=0;const p=e||[0],d=(n=n||0)>>>3,g=-1===o?3:0,y=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==y&&y<t.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<t.length;i+=4){for(h=t.substr(i,4),u=0,a=0;a<h.length;a+=1)s=r.indexOf(h.charAt(a)),u|=s<<18-6*a;for(a=0;a<h.length-1;a+=1){for(f=l+d,c=f>>>2;p.length<=c;)p.push(0);p[c]|=(u>>>16-8*a&255)<<8*(g+o*(f%4)),l+=1}}return{value:p,binLen:8*l+n}}(t,e,o,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let o,s,i,a;const u=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(s=0;s<t.length;s+=1)o=t.charCodeAt(s),a=s+h,i=a>>>2,u.length<=i&&u.push(0),u[i]|=o<<8*(c+r*(a%4));return{value:u,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return o(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return o(t,e,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function i(t,e,n,o){switch(t){case"HEX":return function(t){return function(t,e,n,r){const o="0123456789abcdef";let s,i,a="";const u=e/8,h=-1===n?3:0;for(s=0;s<u;s+=1)i=t[s>>>2]>>>8*(h+n*(s%4)),a+=o.charAt(i>>>4&15)+o.charAt(15&i);return r.outputUpper?a.toUpperCase():a}(t,e,n,o)};case"B64":return function(t){return function(t,e,n,o){let s,i,a,u,h,c="";const f=e/8,l=-1===n?3:0;for(s=0;s<f;s+=3)for(u=s+1<f?t[s+1>>>2]:0,h=s+2<f?t[s+2>>>2]:0,a=(t[s>>>2]>>>8*(l+n*(s%4))&255)<<16|(u>>>8*(l+n*((s+1)%4))&255)<<8|h>>>8*(l+n*((s+2)%4))&255,i=0;i<4;i+=1)c+=8*s+6*i<=e?r.charAt(a>>>6*(3-i)&63):o.b64Pad;return c}(t,e,n,o)};case"BYTES":return function(t){return function(t,e,n){let r,o,s="";const i=e/8,a=-1===n?3:0;for(r=0;r<i;r+=1)o=t[r>>>2]>>>8*(a+n*(r%4))&255,s+=String.fromCharCode(o);return s}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=new ArrayBuffer(o),i=new Uint8Array(s),a=-1===n?3:0;for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(a+n*(r%4))&255;return s}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=-1===n?3:0,i=new Uint8Array(o);for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(s+n*(r%4))&255;return i}(t,e,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function a(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}function u(t,e){return t<<e|t>>>32-e}function h(t,e,n){return t^e^n}function c(t,e,n){return t&e^t&n^e&n}function f(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function l(t,e,n,r,o){const s=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&o);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16)+(s>>>16))<<16|65535&s}function p(t){return[1732584193,4023233417,2562383102,271733878,3285377520]}function d(t,e){let n,r,o,s,i,a,p;const d=[];for(n=e[0],r=e[1],o=e[2],s=e[3],i=e[4],p=0;p<80;p+=1)d[p]=p<16?t[p]:u(d[p-3]^d[p-8]^d[p-14]^d[p-16],1),a=p<20?l(u(n,5),(g=r)&o^~g&s,i,1518500249,d[p]):p<40?l(u(n,5),h(r,o,s),i,1859775393,d[p]):p<60?l(u(n,5),c(r,o,s),i,2400959708,d[p]):l(u(n,5),h(r,o,s),i,3395469782,d[p]),i=s,s=o,o=u(r,30),r=n,n=a;var g;return e[0]=f(n,e[0]),e[1]=f(r,e[1]),e[2]=f(o,e[2]),e[3]=f(s,e[3]),e[4]=f(i,e[4]),e}function g(t,e,n,r){let o;const s=15+(e+65>>>9<<4),i=e+n;for(;t.length<=s;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[s]=4294967295&i,t[s-1]=i/4294967296|0,o=0;o<t.length;o+=16)r=d(t.slice(o,o+16),r);return r}class y extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.R=[],this.U=[]}update(t){let e,n=0;const r=this.T>>>5,o=this.F(t,this.h,this.u),s=o.binLen,i=o.value,a=s>>>5;for(e=0;e<a;e+=r)n+this.T<=s&&(this.m=this.g(i.slice(e,e+r),this.m),n+=this.T);return this.A+=n,this.h=i.slice(n>>>5),this.u=s%this.T,this.l=!0,this}getHash(t,e){let n,r,o=this.B;const s=a(e);if(this.v){if(-1===s.outputLen)throw new Error("Output length must be specified in options");o=s.outputLen}const u=i(t,o,this.Y,s);if(this.p&&this.H)return u(this.H(s));for(r=this.C(this.h.slice(),this.u,this.A,this.I(this.m),o),n=1;n<this.numRounds;n+=1)this.v&&o%32!=0&&(r[r.length-1]&=16777215>>>24-o%32),r=this.C(r,o,0,this.L(this.o),o);return u(r)}setHMACKey(t,e,n){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=s(e,(n||{}).encoding||"UTF8",this.Y);this.N(r(t))}N(t){const e=this.T>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.C(t.value,t.binLen,0,this.L(this.o),this.B));t.value.length<=n;)t.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^t.value[r],this.U[r]=1549556828^t.value[r];this.m=this.g(this.R,this.m),this.A=this.T,this.p=!0}getHMAC(t,e){const n=a(e);return i(t,this.B,this.Y,n)(this.S())}S(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.C(this.h.slice(),this.u,this.A,this.I(this.m),this.B);return t=this.g(this.U,this.L(this.o)),t=this.C(e,this.B,this.T,t,this.B),t}}{constructor(t,e,n){if("SHA-1"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.M=!0,this.H=this.S,this.Y=-1,this.F=s(this.t,this.i,this.Y),this.g=d,this.I=function(t){return t.slice()},this.L=p,this.C=g,this.m=[1732584193,4023233417,2562383102,271733878,3285377520],this.T=512,this.B=160,this.v=!1,r.hmacKey&&this.N(function(t,e,n,r){const o="hmacKey must include a value and format";if(!e)throw new Error(o);if(void 0===e.value||!e.format)throw new Error(o);return s(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.Y))}}},673:(t,e,n)=>{n.r(e),n.d(e,{default:()=>U});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function o(t,e,n,r){let o,s,i;const a=e||[0],u=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<t.length;o+=1)i=o+u,s=i>>>2,a.length<=s&&a.push(0),a[s]|=t[o]<<8*(h+r*(i%4));return{value:a,binLen:8*t.length+n}}function s(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let o,s,i,a;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const u=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o<t.length;o+=2){if(s=parseInt(t.substr(o,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(a=(o>>>1)+h,i=a>>>2;u.length<=i;)u.push(0);u[i]|=s<<8*(c+r*(a%4))}return{value:u,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,o){return function(t,e,n,r,o){let s,i,a,u,h,c,f,l,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===o?3:0,a=0;a<t.length;a+=1)for(s=t.charCodeAt(a),i=[],128>s?i.push(s):2048>s?(i.push(192|s>>>6),i.push(128|63&s)):55296>s||57344<=s?i.push(224|s>>>12,128|s>>>6&63,128|63&s):(a+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(a)),i.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u<i.length;u+=1){for(c=p+g,h=c>>>2;d.length<=h;)d.push(0);d[h]|=i[u]<<8*(f+o*(c%4)),p+=1}else for(f=-1===o?2:0,l="UTF16LE"===e&&1!==o||"UTF16LE"!==e&&1===o,a=0;a<t.length;a+=1){for(s=t.charCodeAt(a),!0===l&&(u=255&s,s=u<<8|s>>>8),c=p+g,h=c>>>2;d.length<=h;)d.push(0);d[h]|=s<<8*(f+o*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,o,n)};case"B64":return function(t,e,o){return function(t,e,n,o){let s,i,a,u,h,c,f,l=0;const p=e||[0],d=(n=n||0)>>>3,g=-1===o?3:0,y=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==y&&y<t.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<t.length;i+=4){for(h=t.substr(i,4),u=0,a=0;a<h.length;a+=1)s=r.indexOf(h.charAt(a)),u|=s<<18-6*a;for(a=0;a<h.length-1;a+=1){for(f=l+d,c=f>>>2;p.length<=c;)p.push(0);p[c]|=(u>>>16-8*a&255)<<8*(g+o*(f%4)),l+=1}}return{value:p,binLen:8*l+n}}(t,e,o,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let o,s,i,a;const u=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(s=0;s<t.length;s+=1)o=t.charCodeAt(s),a=s+h,i=a>>>2,u.length<=i&&u.push(0),u[i]|=o<<8*(c+r*(a%4));return{value:u,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return o(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return o(t,e,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function i(t,e,n,o){switch(t){case"HEX":return function(t){return function(t,e,n,r){const o="0123456789abcdef";let s,i,a="";const u=e/8,h=-1===n?3:0;for(s=0;s<u;s+=1)i=t[s>>>2]>>>8*(h+n*(s%4)),a+=o.charAt(i>>>4&15)+o.charAt(15&i);return r.outputUpper?a.toUpperCase():a}(t,e,n,o)};case"B64":return function(t){return function(t,e,n,o){let s,i,a,u,h,c="";const f=e/8,l=-1===n?3:0;for(s=0;s<f;s+=3)for(u=s+1<f?t[s+1>>>2]:0,h=s+2<f?t[s+2>>>2]:0,a=(t[s>>>2]>>>8*(l+n*(s%4))&255)<<16|(u>>>8*(l+n*((s+1)%4))&255)<<8|h>>>8*(l+n*((s+2)%4))&255,i=0;i<4;i+=1)c+=8*s+6*i<=e?r.charAt(a>>>6*(3-i)&63):o.b64Pad;return c}(t,e,n,o)};case"BYTES":return function(t){return function(t,e,n){let r,o,s="";const i=e/8,a=-1===n?3:0;for(r=0;r<i;r+=1)o=t[r>>>2]>>>8*(a+n*(r%4))&255,s+=String.fromCharCode(o);return s}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=new ArrayBuffer(o),i=new Uint8Array(s),a=-1===n?3:0;for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(a+n*(r%4))&255;return s}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=-1===n?3:0,i=new Uint8Array(o);for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(s+n*(r%4))&255;return i}(t,e,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],u=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function c(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}function f(t,e){return t>>>e|t<<32-e}function l(t,e){return t>>>e}function p(t,e,n){return t&e^~t&n}function d(t,e,n){return t&e^t&n^e&n}function g(t){return f(t,2)^f(t,13)^f(t,22)}function y(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function w(t,e,n,r){const o=(65535&t)+(65535&e)+(65535&n)+(65535&r);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16))<<16|65535&o}function m(t,e,n,r,o){const s=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&o);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16)+(s>>>16))<<16|65535&s}function b(t){return f(t,7)^f(t,18)^l(t,3)}function A(t){return f(t,6)^f(t,11)^f(t,25)}function v(t){let e;return e="SHA-224"==t?u.slice():h.slice(),e}function E(t,e){let n,r,o,s,i,u,h,c,v,E,U;const R=[];for(n=e[0],r=e[1],o=e[2],s=e[3],i=e[4],u=e[5],h=e[6],c=e[7],U=0;U<64;U+=1)R[U]=U<16?t[U]:w(f(S=R[U-2],17)^f(S,19)^l(S,10),R[U-7],b(R[U-15]),R[U-16]),v=m(c,A(i),p(i,u,h),a[U],R[U]),E=y(g(n),d(n,r,o)),c=h,h=u,u=i,i=y(s,v),s=o,o=r,r=n,n=y(v,E);var S;return e[0]=y(n,e[0]),e[1]=y(r,e[1]),e[2]=y(o,e[2]),e[3]=y(s,e[3]),e[4]=y(i,e[4]),e[5]=y(u,e[5]),e[6]=y(h,e[6]),e[7]=y(c,e[7]),e}class U extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.A=!1,this.l=0,this.p=!1,this.R=[],this.U=[]}update(t){let e,n=0;const r=this.T>>>5,o=this.F(t,this.h,this.u),s=o.binLen,i=o.value,a=s>>>5;for(e=0;e<a;e+=r)n+this.T<=s&&(this.m=this.g(i.slice(e,e+r),this.m),n+=this.T);return this.l+=n,this.h=i.slice(n>>>5),this.u=s%this.T,this.A=!0,this}getHash(t,e){let n,r,o=this.B;const s=c(e);if(this.H){if(-1===s.outputLen)throw new Error("Output length must be specified in options");o=s.outputLen}const a=i(t,o,this.v,s);if(this.p&&this.Y)return a(this.Y(s));for(r=this.C(this.h.slice(),this.u,this.l,this.S(this.m),o),n=1;n<this.numRounds;n+=1)this.H&&o%32!=0&&(r[r.length-1]&=16777215>>>24-o%32),r=this.C(r,o,0,this.I(this.o),o);return a(r)}setHMACKey(t,e,n){if(!this.L)throw new Error("Variant does not support HMAC");if(this.A)throw new Error("Cannot set MAC key after calling update");const r=s(e,(n||{}).encoding||"UTF8",this.v);this.M(r(t))}M(t){const e=this.T>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.C(t.value,t.binLen,0,this.I(this.o),this.B));t.value.length<=n;)t.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^t.value[r],this.U[r]=1549556828^t.value[r];this.m=this.g(this.R,this.m),this.l=this.T,this.p=!0}getHMAC(t,e){const n=c(e);return i(t,this.B,this.v,n)(this.N())}N(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.C(this.h.slice(),this.u,this.l,this.S(this.m),this.B);return t=this.g(this.U,this.I(this.o)),t=this.C(e,this.B,this.T,t,this.B),t}}{constructor(t,e,n){if("SHA-224"!==t&&"SHA-256"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.Y=this.N,this.L=!0,this.v=-1,this.F=s(this.t,this.i,this.v),this.g=E,this.S=function(t){return t.slice()},this.I=v,this.C=function(e,n,r,o){return function(t,e,n,r,o){let s,i;const a=15+(e+65>>>9<<4),u=e+n;for(;t.length<=a;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[a]=4294967295&u,t[a-1]=u/4294967296|0,s=0;s<t.length;s+=16)r=E(t.slice(s,s+16),r);return i="SHA-224"===o?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,i}(e,n,r,o,t)},this.m=v(t),this.T=512,this.B="SHA-224"===t?224:256,this.H=!1,r.hmacKey&&this.M(function(t,e,n,r){const o="hmacKey must include a value and format";if(!e)throw new Error(o);if(void 0===e.value||!e.format)throw new Error(o);return s(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.v))}}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};(()=>{n.d(r,{SO:()=>b(),Xz:()=>v,ul:()=>E,zM:()=>A,xI:()=>X,$$:()=>K,vB:()=>_,wY:()=>w,UQ:()=>p,Ue:()=>Z,w6:()=>y,Jx:()=>Y,cv:()=>R,Dd:()=>d,sK:()=>u,bX:()=>h,BO:()=>M,Dc:()=>f,fp:()=>l,xT:()=>g,Qc:()=>H,DN:()=>c,yQ:()=>T,Zk:()=>k,uh:()=>B});const t={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let e;const o=new Uint8Array(16);function s(){if(!e&&(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!e))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(o)}const i=[];for(let t=0;t<256;++t)i.push((t+256).toString(16).slice(1));const a=function(e,n,r){if(t.randomUUID&&!n&&!e)return t.randomUUID();const o=(e=e||{}).random||(e.rng||s)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,n){r=r||0;for(let t=0;t<16;++t)n[r+t]=o[t];return n}return function(t,e=0){return(i[t[e+0]]+i[t[e+1]]+i[t[e+2]]+i[t[e+3]]+"-"+i[t[e+4]]+i[t[e+5]]+"-"+i[t[e+6]]+i[t[e+7]]+"-"+i[t[e+8]]+i[t[e+9]]+"-"+i[t[e+10]]+i[t[e+11]]+i[t[e+12]]+i[t[e+13]]+i[t[e+14]]+i[t[e+15]]).toLowerCase()}(o)};function u(t,e,n){let r=0,o=t.length;for(;r<o;){const s=r+o>>>1;n(t[s],e)<0?r=s+1:o=s}return r}function h(t,e){const n=[];for(const r of t)n.splice(u(n,r,e),0,r);return n}function c(t){let e=[];const n=new WeakMap;for(const r of t){const t=(r.webkitRelativePath||r.name).split("/");t.reduce(((e,o,s)=>{let i=e.find((t=>t[0]===o));if(i)return i[1];const a=u(e,o,((t,e)=>t[0]<e?-1:1));if(s===t.length-1){const t={"":{length:r.size}};n.set(t,r),i=[o,t]}else i=[o,[]];return e.splice(a,0,i),i[1]}),e)}let r;1===e.length&&Array.isArray(e[0][1])&&(r=e[0][0],e=e[0][1]);const o=[];return{fileTree:{*[Symbol.iterator](){for(const t of o)yield t},...function t(e){if(Array.isArray(e)){const n={};for(const r of e)n[r[0]]=t(r[1]);return n}{const t=e;return o.push(t),t}}(e)},fileNodeMap:n,commonDir:r}}async function f(t){const e=new Uint8Array(64);for(;t.length>1;){let n=!1;const r=[];for(const o of t)n?(e.set(o,32),r.push(new Uint8Array(await crypto.subtle.digest("SHA-256",e))),n=!1):(e.set(o),n=!0);t=r}return t[0]}function l(t){return 1<<32-Math.clz32(t-1)}function p(t){if(void 0===t)return;const e=[];for(const n of t)0!==n.length&&e.push(n);return 0!==e.length?e:void 0}function d(t){let e;for(const n of t){const t=(n.webkitRelativePath||n.name).split("/");if(1==t.length||(e??=t[0])!==t[0])return}return e}function g(t,e,n){const r=[],o=t.length-1;for(const[s,i]of t.entries()){if(r.push(i),s===o)break;const t=i.size%e;if(0===t)continue;const a=e-t,u=new File([new ArrayBuffer(a)],`${a}`,{type:"application/octet-stream"}),h=`.pad/${a}`,c=void 0===n?h:`${n}/${h}`;Object.defineProperties(u,{webkitRelativePath:{configurable:!0,enumerable:!0,get:()=>c},padding:{configurable:!0,enumerable:!1,get:()=>!0}}),r.push(u)}return r}function y(t,e,n){return void 0===e&&1===n.length?t=n[0].name:t??=e||a(),t}function w(t,e){return Math.max(e,l(t>>>10))}var m=n(340),b=n.n(m);const A=new Uint8Array([108]),v=new Uint8Array([100]),E=new Uint8Array([101]);class U{textEncoder=new TextEncoder;textDecoder=new TextDecoder;data;hooks;isHooking=!1;path=[];constructor(t,e){this.data=t,this.hooks=e}start(t){this.encode(this.data,t),t.close()}encode(t,e){if(null!=t)if("boolean"==typeof t)this.encode(t?1:0,e);else if("number"==typeof t){const n=Math.round(t);e.enqueue(this.textEncoder.encode(`i${n}e`)),n!==t&&(console.warn(`WARNING: Possible data corruption detected with value "${t}":`,`Bencoding only defines support for integers, value was converted to "${n}"`),console.trace())}else if("bigint"==typeof t)e.enqueue(this.textEncoder.encode(`i${t}e`));else if("string"==typeof t){const n=this.textEncoder.encode(t),r=n.byteLength;e.enqueue(this.textEncoder.encode(`${r}:`)),e.enqueue(n)}else if(t instanceof ArrayBuffer){const n=new Uint8Array(t),r=n.byteLength;e.enqueue(this.textEncoder.encode(`${r}:`)),e.enqueue(n)}else if(Array.isArray(t)){e.enqueue(A);for(let n of t)this.encode(n,e);e.enqueue(E)}else if(t instanceof Map){e.enqueue(v);const n=h(t.keys(),((t,e)=>(t="string"==typeof t?t:this.textDecoder.decode(t))<(e="string"==typeof e?e:this.textDecoder.decode(e))?-1:t>e?1:0));for(const r of n){const n=t.get(r);if(void 0!==n&&null!==t){if(this.path.push(r),this.encode(r,e),this.hooks){const t=this.hooks.get(this.path);if(t){const r=S(e,t);this.encode(n,r),t({value:void 0,done:!0})}else this.encode(n,e)}this.path.pop()}}e.enqueue(E)}else{e.enqueue(v);const n=Object.keys(t).sort();for(const r of n){const n=t[r];if(void 0!==n&&null!==t){if(this.path.push(r),this.encode(r,e),this.hooks){const t=this.hooks.get(this.path);if(t){const r=S(e,t);this.encode(n,r),t({value:void 0,done:!0})}else this.encode(n,e)}this.path.pop()}}e.enqueue(E)}}}function R(t,e){return new ReadableStream(new U(t,e))}function S(t,e){return new Proxy(t,{get:function(t,n,r){return"enqueue"!==n?Reflect.get(t,n,r):(n=>{t.enqueue(n),void 0!==n&&e({value:n,done:!1})}).bind(t)}})}function B(){const t={controller:null};return[new ReadableStream({start(e){t.controller=e}}),({value:e,done:n})=>{null!==t.controller&&(n?t.controller.close():t.controller.enqueue(e))}]}function T(){const[t,e]=B();return[new Response(t).arrayBuffer(),e]}function k(){const[t,e]=B();return[new Response(t).text(),e]}var L;!function(t){t.Integer="Integer",t.ByteString="ByteString",t.ListStart="ListStart",t.ListEnd="ListEnd",t.DictionaryStart="DictionaryStart",t.DictionaryEnd="DictionaryEnd"}(L||(L={}));const F=A[0],x=v[0],C=E[0];class I{endStack=[];token=null;byteStringLength=0;byteStringOffset=0;transform(t,e){this.tokenize(t,e)}flush(){if(this.endStack.length||this.token||this.byteStringLength||this.byteStringOffset)throw new SyntaxError("Incomplete stream")}tokenize(t,e){if(0!==t.byteLength)if(null===this.token&&0===this.byteStringLength){const n=t[0];if(105===n)this.token={type:L.Integer,value:new Uint8Array};else if(D(n))this.byteStringLength=n-48;else if(n===F)this.endStack.push(L.ListEnd),e.enqueue({type:L.ListStart});else if(n===x)this.endStack.push(L.DictionaryEnd),e.enqueue({type:L.DictionaryStart});else{if(n!==C)throw new SyntaxError(`Unexpected byte: ${n}`);{const t=this.endStack.pop();if(!t)throw new SyntaxError("Unbalanced delimiter");e.enqueue({type:t})}}this.tokenize(t.subarray(1),e)}else if(this.token&&0===this.byteStringLength)if(this.token.type===L.Integer){const n=t.indexOf(C);-1===n?this.token.value=this.token.value?z(this.token.value,t):t:(this.token.value=this.token.value?z(this.token.value,t.subarray(0,n)):t.subarray(0,n),e.enqueue(this.token),this.token=null,this.tokenize(t.subarray(n+1),e))}else{if(this.token.type!==L.ByteString)throw new Error("This is a bug");{const n=this.token.value.byteLength-this.byteStringOffset,r=t.byteLength;r<n?(this.token.value.set(t,this.byteStringOffset),this.byteStringOffset+=r):(this.token.value.set(t.subarray(0,n),this.byteStringOffset),this.byteStringOffset=0,e.enqueue(this.token),this.token=null,this.tokenize(t.subarray(n),e))}}else{if(!this.byteStringLength||null!==this.token)throw new Error("This is a bug");{let n=-1;for(const[e,r]of t.entries()){if(!D(r)){if(58===r){n=e;break}throw new SyntaxError(`Unexpected byte: ${r}`)}this.byteStringLength=10*this.byteStringLength-48+r}-1!==n&&(this.token={type:L.ByteString,value:new Uint8Array(this.byteStringLength)},this.byteStringLength=0,this.tokenize(t.subarray(n+1),e))}}}}function M(){return new TransformStream(new I)}async function H(t){let e;const n=[],r=t.getReader();let o;for(;;){const{done:t,value:s}=await r.read();if(t)break;const i=n.at(-1);if(i)if(Array.isArray(i))switch(s.type){case L.Integer:i.push(N(s.value));break;case L.ByteString:i.push(P(s.value));break;case L.DictionaryStart:{const t=Object.create(null);i.push(t),n.push(t);break}case L.ListStart:{const t=[];i.push(t),n.push(t);break}case L.ListEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${s}`)}else if(void 0===o)switch(s.type){case L.ByteString:o=P(s.value);break;case L.DictionaryEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${s}`)}else{switch(s.type){case L.Integer:i[o]=N(s.value);break;case L.ByteString:i[o]=P(s.value);break;case L.DictionaryStart:{const t=Object.create(null);i[o]=t,n.push(t);break}case L.ListStart:{const t=[];i[o]=t,n.push(t);break}default:throw new SyntaxError(`Unexpected token: ${s}`)}o=void 0}else{if(void 0!==e)throw new SyntaxError(`Unexpected token: ${s}`);switch(s.type){case L.Integer:e=N(s.value);break;case L.ByteString:e=P(s.value);break;case L.DictionaryStart:{const t=Object.create(null);n.push(t),e=t;break}case L.ListStart:{const t=[];n.push(t),e=t;break}default:throw new SyntaxError(`Unexpected token: ${s}`)}}}if(n.length)throw new Error("Unexpected end of token stream");return e}async function Y(t){const e=M(),n=t.pipeThrough(e);return await H(n)}function N(t){let e=0,n=!0;for(const[r,o]of t.entries()){if(0===r&&45===o){n=!1;continue}if(1===r&&!n&&48===o)throw new SyntaxError("Negative zero is not a valid integer");if(1===r&&0===e)throw new SyntaxError("Leading zeros are not allowed");if(!D(o))throw new SyntaxError(`Unexpected byte: ${o}`);const t=o-48;(n&&"number"==typeof e&&e>(Number.MAX_SAFE_INTEGER-t)/10||!n&&"number"==typeof e&&e<(Number.MIN_SAFE_INTEGER+t)/10)&&(e=BigInt(e)),e="number"==typeof e?n?10*e+t:10*e-t:n?10n*e+BigInt(t):10n*e-BigInt(t)}return e}function P(t){return(new TextDecoder).decode(t)}function D(t){return t>=48&&t<=57}function z(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.byteLength),0));return t.reduce(((t,n)=>(e.set(n,t),t+n.byteLength)),0),e}n(913);class O extends Error{constructor(t,e){super(((t,...e)=>{let n=t;return e.length>0&&(n+=` :: ${JSON.stringify(e)}`),n})(t,e)),this.name=t,this.details=e}}class q{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}function $(t){const e=t.map((t=>Promise.resolve(t).then((t=>function(t){if(t instanceof Response){if(t.body)return t.body.getReader();throw new O("opaque-streams-source",{type:t.type})}return t instanceof ReadableStream?t.getReader():new Response(t).body.getReader()}(t))))),n=new q;let r=0;const o=new ReadableStream({pull(t){return e[r].then((t=>t.read())).then((o=>{if(o.done)return r++,r>=e.length?(t.close(),void n.resolve()):this.pull(t);t.enqueue(o.value)})).catch((t=>{throw n.reject(t),t}))},cancel(){n.resolve()}});return{done:n.promise,stream:o}}var _;n(1),function(t){t.V1="v1",t.V2="v2",t.HYBRID="hybrid"}(_||(_={}));const K=16384;var X;!function(t){t[t["16KB"]=16384]="16KB",t[t["32KB"]=32768]="32KB",t[t["64KB"]=65536]="64KB",t[t["128KB"]=131072]="128KB",t[t["256KB"]=262144]="256KB",t[t["512KB"]=524288]="512KB",t[t["1MB"]=1048576]="1MB",t[t["2MB"]=2097152]="2MB",t[t["4MB"]=4194304]="4MB",t[t["8MB"]=8388608]="8MB",t[t["16MB"]=16777216]="16MB",t[t["32MB"]=33554432]="32MB"}(X||(X={}));const V=new Uint8Array(32),j={type:_.V1,addCreatedBy:!0,addCreationDate:!0,addPaddingFiles:!1,blockLength:K,sortFiles:!0,isPrivate:!1},Q={type:_.V2,addCreatedBy:!0,addCreationDate:!0,blockLength:K,metaVersion:2,isPrivate:!1},G={type:_.HYBRID,addCreatedBy:!0,addCreationDate:!0,blockLength:K,metaVersion:2,isPrivate:!1};async function Z(t,e={type:_.V1},r=((t,e)=>{})){if(0===t.length)throw new Error("empty file list");let o;switch(e.type){case _.V1:o={...j,...e};break;case _.V2:o={...Q,...e};break;case _.HYBRID:o={...G,...e}}o.pieceLength??=w(t.reduce(((t,e)=>t+e.size),0),o.blockLength);let{addCreatedBy:s,addCreationDate:i,blockLength:a,comment:u,isPrivate:h,name:m,pieceLength:b}=o;if(o.type!==_.V1&&b<a)throw new Error(`piece length ${b} is smaller than block length ${a}`);if(0!=(b&b-1))throw new Error(`piece length ${b} is not a power of 2`);const A=b/a;o.announceList=p(o.announceList),void 0===o.announce&&void 0!==o.announceList&&(o.announce=o.announceList[0][0]);const{announce:v,announceList:E}=o,U={...v&&{announce:v},...E&&{"announce-list":E},...u&&{comment:u},...s&&{"created by":"torrefy v2.0.2"},...i&&{"creation date":Date.now()/1e3>>0}};let R,S,B=0,T=t.reduce(((t,e)=>t+Math.ceil(e.size/b)),0);if(o.type===_.V1){const{addPaddingFiles:e,sortFiles:n}=o;let r,s;if(n){const{fileTree:e,fileNodeMap:n,commonDir:r}=c(t);t=[...e].map((t=>n.get(t))),s=r}else s=d(t);if(o.name=m=y(m,s,t),e){const e=t.length-1;r=$(t.map((async(t,n)=>L(t.stream(),{padding:n!==e})))).stream,t=g(t,b,s)}else{T=Math.ceil(t.reduce(((t,e)=>t+e.size),0)/b);const{stream:e}=$(t.map((t=>Promise.resolve(t.stream()))));r=L(e)}R={...U,info:{...t.length>1?{files:t.map((t=>{const e=(t.webkitRelativePath||t.name).split("/");return void 0!==s&&e.shift(),{...t.padding&&{attr:"p"},length:t.size,path:e}}))}:{length:t[0].size},name:m,"piece length":b,pieces:await new Response(r).arrayBuffer(),...h&&{private:1}}}}else if(o.type===_.V2){const{metaVersion:e}=o,{fileTree:n,fileNodeMap:r,commonDir:s}=c(t),i=[...n];t=i.map((t=>r.get(t)));const a=new Map;o.name=m=y(m,s,t),await Promise.all(i.map((async(e,n)=>{const r=t[n];await k(e,r,r.stream(),a)}))),R={...U,info:{"file tree":n,"meta version":e,name:m,"piece length":b,...h&&{private:1}},...a.size>0&&{"piece layers":a}}}else{if(o.type!==_.HYBRID)throw new Error("torrent type is not supported");{const{metaVersion:e}=o,{fileTree:n,fileNodeMap:r,commonDir:s}=c(t),i=[...n];t=i.map((t=>r.get(t)));const a=new Map;o.name=m=y(m,s,t),T*=2;const u=t.length-1,f=[];await Promise.all(i.map((async(e,n)=>{const r=t[n],[o,s]=r.stream().tee();f.push(Promise.resolve(L(o,{padding:n!==u}))),await k(e,r,s,a)})));const l=$(f).stream;t=g(t,b,s),R={...U,info:{"file tree":n,...t.length>1?{files:t.map((t=>{const e=(t.webkitRelativePath||t.name).split("/");return void 0!==s&&e.shift(),{...t.padding&&{attr:"p"},length:t.size,path:e}}))}:{length:t[0].size},"meta version":e,name:m,"piece length":b,pieces:await new Response(l).arrayBuffer(),...h&&{private:1}},...a.size>0&&{"piece layers":a}}}}return R;async function k(t,e,r,o){const[s,i]=function(t){const e=t.pipeThrough(F(a)).pipeThrough(function(){let t=0,e=[];return new TransformStream({transform:async(r,o)=>{let s;++t;try{s=new Uint8Array(await crypto.subtle.digest("SHA-256",r))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,673)),e=new t("SHA-256","UINT8ARRAY");e.update(r),s=e.getHash("UINT8ARRAY")}e.push(s),e.length===A&&(o.enqueue(e),e=[])},flush:async n=>{if(0===t)return;let r=0;if(t<A)r=l(t)-t;else{const e=t%A;e>0&&(r=A-e)}if(r>0)for(let t=0;t<r;++t)e.push(V);e.length>0&&n.enqueue(e)}})}()).pipeThrough(x(!0)),[r,o]=e.tee();return[o.pipeThrough(C()).pipeThrough(x()),r]}(r),u=new Response(s).arrayBuffer();if(e.size>b){const t=new Response(i).arrayBuffer();o.set(await u,await t)}e.size>0&&(t[""]["pieces root"]=await u)}function L(t,e={padding:!1}){return t.pipeThrough(F(b,{padding:e.padding})).pipeThrough(function(t=!1){return new TransformStream({transform:async(e,o)=>{let s;try{s=new Uint8Array(await crypto.subtle.digest("SHA-1",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,211)),r=new t("SHA-1","UINT8ARRAY");r.update(e),s=r.getHash("UINT8ARRAY")}o.enqueue(s),t&&r(++B,T)}})}(!0))}function F(t,e={padding:!1}){let n=new Uint8Array(t),r=0;return new TransformStream({transform:(e,o)=>{for(;r+e.length>=t;){const s=t-r;n.set(e.subarray(0,s),r),r=0,o.enqueue(new Uint8Array(n)),e=e.subarray(s)}n.set(e,r),r+=e.length},flush:o=>{r>0&&(e.padding?(n.set(new Uint8Array(t-r),r),o.enqueue(n)):o.enqueue(n.subarray(0,r)))}})}function x(t=!1){return new TransformStream({transform:async(e,n)=>{n.enqueue(await f(e)),t&&r(++B,T)}})}function C(){let t=0,e=[];return new TransformStream({transform:n=>{++t,e.push(n)},flush:async n=>{const r=l(t)-t;if(r>0){S??=await f(Array(A).fill(new Uint8Array(32)));for(let t=0;t<r;++t)e.push(S)}n.enqueue(e)}})}}})();var o=r.SO,s=r.Xz,i=r.ul,a=r.zM,u=r.xI,h=r.$$,c=r.vB,f=r.wY,l=r.UQ,p=r.Ue,d=r.w6,g=r.Jx,y=r.cv,w=r.Dd,m=r.sK,b=r.bX,A=r.BO,v=r.Dc,E=r.fp,U=r.xT,R=r.Qc,S=r.DN,B=r.yQ,T=r.Zk,k=r.uh;export{o as ArrayKeyedMap,s as BUFF_D,i as BUFF_E,a as BUFF_L,u as CommonPieceLength,h as DEFAULT_BLOCK_LENGTH,c as TorrentType,f as calculatePieceLength,l as collapseAnnounceList,p as create,d as decideName,g as decode,y as encode,w as getCommonDir,m as getSortedIndex,b as iterableSort,A as makeTokenizer,v as merkleRoot,E as nextPowerOfTwo,U as padFiles,R as parse,S as parseFileTree,B as useArrayBufferPromiseHook,T as useTextPromiseHook,k as useUint8ArrayStreamHook};

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.torrefy=e():t.torrefy=e()}(self,(()=>(()=>{var t={340:t=>{const e=Symbol("path-store-trunk");class n{constructor(t=[]){this._root=new Map,this._size=0;for(const[e,n]of t)this.set(e,n)}set(t,e){return r.call(this,t,e)}has(t){return o.call(this,t)}get(t){return s.call(this,t)}delete(t){return i.call(this,t)}get size(){return this._size}clear(){this._root.clear(),this._size=0}hasPrefix(t){return u.call(this,t)}get[Symbol.toStringTag](){return"ArrayKeyedMap"}*[Symbol.iterator](){yield*a.call(this)}*entries(){yield*a.call(this)}*keys(){yield*h.call(this)}*values(){yield*c.call(this)}forEach(t,e){f.call(this,t,e)}}function r(t,n){let r=this._root;for(const e of t){let t=r.get(e);t||(t=new Map,r.set(e,t)),r=t}return r.has(e)||(this._size+=1),r.set(e,n),this}function o(t){let n=this._root;for(const e of t){const t=n.get(e);if(!t)return!1;n=t}return n.has(e)}function s(t){let n=this._root;for(const e of t)if(n=n.get(e),!n)return;return n.get(e)}function i(t){let n=this._root;const r=[];for(const e of t){const t=n.get(e);if(!t)return!1;r.unshift({parent:n,child:t,item:e}),n=t}const o=n.delete(e);if(o){this._size-=1;for(const{parent:t,child:e,item:n}of r)0===e.size&&t.delete(n)}return o}function u(t){let e=this._root;for(const n of t)if(e=e.get(n),!e)return!1;return!0}function*a(){const t=[{path:[],map:this._root}];for(;t.length>0;){const{path:n,map:r}=t.pop();for(const[o,s]of r.entries())o===e?yield[n,s]:t.push({path:n.concat([o]),map:s})}}function*h(){for(const[t]of this.entries())yield t}function*c(){for(const[,t]of this.entries())yield t}function f(t,e){for(const[n,r]of this.entries())t.call(e,r,n,this)}t.exports=n},913:()=>{"use strict";try{self["workbox:core:6.5.3"]&&_()}catch(t){}},1:()=>{"use strict";try{self["workbox:streams:6.5.3"]&&_()}catch(t){}},211:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>g});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function o(t,e,n,r){let o,s,i;const u=e||[0],a=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<t.length;o+=1)i=o+a,s=i>>>2,u.length<=s&&u.push(0),u[s]|=t[o]<<8*(h+r*(i%4));return{value:u,binLen:8*t.length+n}}function s(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let o,s,i,u;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o<t.length;o+=2){if(s=parseInt(t.substr(o,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(u=(o>>>1)+h,i=u>>>2;a.length<=i;)a.push(0);a[i]|=s<<8*(c+r*(u%4))}return{value:a,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,o){return function(t,e,n,r,o){let s,i,u,a,h,c,f,l,p=0;const d=n||[0],w=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===o?3:0,u=0;u<t.length;u+=1)for(s=t.charCodeAt(u),i=[],128>s?i.push(s):2048>s?(i.push(192|s>>>6),i.push(128|63&s)):55296>s||57344<=s?i.push(224|s>>>12,128|s>>>6&63,128|63&s):(u+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(u)),i.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),a=0;a<i.length;a+=1){for(c=p+w,h=c>>>2;d.length<=h;)d.push(0);d[h]|=i[a]<<8*(f+o*(c%4)),p+=1}else for(f=-1===o?2:0,l="UTF16LE"===e&&1!==o||"UTF16LE"!==e&&1===o,u=0;u<t.length;u+=1){for(s=t.charCodeAt(u),!0===l&&(a=255&s,s=a<<8|s>>>8),c=p+w,h=c>>>2;d.length<=h;)d.push(0);d[h]|=s<<8*(f+o*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,o,n)};case"B64":return function(t,e,o){return function(t,e,n,o){let s,i,u,a,h,c,f,l=0;const p=e||[0],d=(n=n||0)>>>3,w=-1===o?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<t.length;i+=4){for(h=t.substr(i,4),a=0,u=0;u<h.length;u+=1)s=r.indexOf(h.charAt(u)),a|=s<<18-6*u;for(u=0;u<h.length-1;u+=1){for(f=l+d,c=f>>>2;p.length<=c;)p.push(0);p[c]|=(a>>>16-8*u&255)<<8*(w+o*(f%4)),l+=1}}return{value:p,binLen:8*l+n}}(t,e,o,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let o,s,i,u;const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(s=0;s<t.length;s+=1)o=t.charCodeAt(s),u=s+h,i=u>>>2,a.length<=i&&a.push(0),a[i]|=o<<8*(c+r*(u%4));return{value:a,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return o(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return o(t,e,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function i(t,e,n,o){switch(t){case"HEX":return function(t){return function(t,e,n,r){const o="0123456789abcdef";let s,i,u="";const a=e/8,h=-1===n?3:0;for(s=0;s<a;s+=1)i=t[s>>>2]>>>8*(h+n*(s%4)),u+=o.charAt(i>>>4&15)+o.charAt(15&i);return r.outputUpper?u.toUpperCase():u}(t,e,n,o)};case"B64":return function(t){return function(t,e,n,o){let s,i,u,a,h,c="";const f=e/8,l=-1===n?3:0;for(s=0;s<f;s+=3)for(a=s+1<f?t[s+1>>>2]:0,h=s+2<f?t[s+2>>>2]:0,u=(t[s>>>2]>>>8*(l+n*(s%4))&255)<<16|(a>>>8*(l+n*((s+1)%4))&255)<<8|h>>>8*(l+n*((s+2)%4))&255,i=0;i<4;i+=1)c+=8*s+6*i<=e?r.charAt(u>>>6*(3-i)&63):o.b64Pad;return c}(t,e,n,o)};case"BYTES":return function(t){return function(t,e,n){let r,o,s="";const i=e/8,u=-1===n?3:0;for(r=0;r<i;r+=1)o=t[r>>>2]>>>8*(u+n*(r%4))&255,s+=String.fromCharCode(o);return s}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=new ArrayBuffer(o),i=new Uint8Array(s),u=-1===n?3:0;for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(u+n*(r%4))&255;return s}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=-1===n?3:0,i=new Uint8Array(o);for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(s+n*(r%4))&255;return i}(t,e,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function u(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}function a(t,e){return t<<e|t>>>32-e}function h(t,e,n){return t^e^n}function c(t,e,n){return t&e^t&n^e&n}function f(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function l(t,e,n,r,o){const s=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&o);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16)+(s>>>16))<<16|65535&s}function p(t){return[1732584193,4023233417,2562383102,271733878,3285377520]}function d(t,e){let n,r,o,s,i,u,p;const d=[];for(n=e[0],r=e[1],o=e[2],s=e[3],i=e[4],p=0;p<80;p+=1)d[p]=p<16?t[p]:a(d[p-3]^d[p-8]^d[p-14]^d[p-16],1),u=p<20?l(a(n,5),(w=r)&o^~w&s,i,1518500249,d[p]):p<40?l(a(n,5),h(r,o,s),i,1859775393,d[p]):p<60?l(a(n,5),c(r,o,s),i,2400959708,d[p]):l(a(n,5),h(r,o,s),i,3395469782,d[p]),i=s,s=o,o=a(r,30),r=n,n=u;var w;return e[0]=f(n,e[0]),e[1]=f(r,e[1]),e[2]=f(o,e[2]),e[3]=f(s,e[3]),e[4]=f(i,e[4]),e}function w(t,e,n,r){let o;const s=15+(e+65>>>9<<4),i=e+n;for(;t.length<=s;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[s]=4294967295&i,t[s-1]=i/4294967296|0,o=0;o<t.length;o+=16)r=d(t.slice(o,o+16),r);return r}class g extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.R=[],this.U=[]}update(t){let e,n=0;const r=this.T>>>5,o=this.F(t,this.h,this.u),s=o.binLen,i=o.value,u=s>>>5;for(e=0;e<u;e+=r)n+this.T<=s&&(this.m=this.g(i.slice(e,e+r),this.m),n+=this.T);return this.A+=n,this.h=i.slice(n>>>5),this.u=s%this.T,this.l=!0,this}getHash(t,e){let n,r,o=this.B;const s=u(e);if(this.v){if(-1===s.outputLen)throw new Error("Output length must be specified in options");o=s.outputLen}const a=i(t,o,this.Y,s);if(this.p&&this.H)return a(this.H(s));for(r=this.C(this.h.slice(),this.u,this.A,this.I(this.m),o),n=1;n<this.numRounds;n+=1)this.v&&o%32!=0&&(r[r.length-1]&=16777215>>>24-o%32),r=this.C(r,o,0,this.L(this.o),o);return a(r)}setHMACKey(t,e,n){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=s(e,(n||{}).encoding||"UTF8",this.Y);this.N(r(t))}N(t){const e=this.T>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.C(t.value,t.binLen,0,this.L(this.o),this.B));t.value.length<=n;)t.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^t.value[r],this.U[r]=1549556828^t.value[r];this.m=this.g(this.R,this.m),this.A=this.T,this.p=!0}getHMAC(t,e){const n=u(e);return i(t,this.B,this.Y,n)(this.S())}S(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.C(this.h.slice(),this.u,this.A,this.I(this.m),this.B);return t=this.g(this.U,this.L(this.o)),t=this.C(e,this.B,this.T,t,this.B),t}}{constructor(t,e,n){if("SHA-1"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.M=!0,this.H=this.S,this.Y=-1,this.F=s(this.t,this.i,this.Y),this.g=d,this.I=function(t){return t.slice()},this.L=p,this.C=w,this.m=[1732584193,4023233417,2562383102,271733878,3285377520],this.T=512,this.B=160,this.v=!1,r.hmacKey&&this.N(function(t,e,n,r){const o="hmacKey must include a value and format";if(!e)throw new Error(o);if(void 0===e.value||!e.format)throw new Error(o);return s(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.Y))}}},673:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>E});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function o(t,e,n,r){let o,s,i;const u=e||[0],a=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<t.length;o+=1)i=o+a,s=i>>>2,u.length<=s&&u.push(0),u[s]|=t[o]<<8*(h+r*(i%4));return{value:u,binLen:8*t.length+n}}function s(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let o,s,i,u;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o<t.length;o+=2){if(s=parseInt(t.substr(o,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(u=(o>>>1)+h,i=u>>>2;a.length<=i;)a.push(0);a[i]|=s<<8*(c+r*(u%4))}return{value:a,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,o){return function(t,e,n,r,o){let s,i,u,a,h,c,f,l,p=0;const d=n||[0],w=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===o?3:0,u=0;u<t.length;u+=1)for(s=t.charCodeAt(u),i=[],128>s?i.push(s):2048>s?(i.push(192|s>>>6),i.push(128|63&s)):55296>s||57344<=s?i.push(224|s>>>12,128|s>>>6&63,128|63&s):(u+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(u)),i.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),a=0;a<i.length;a+=1){for(c=p+w,h=c>>>2;d.length<=h;)d.push(0);d[h]|=i[a]<<8*(f+o*(c%4)),p+=1}else for(f=-1===o?2:0,l="UTF16LE"===e&&1!==o||"UTF16LE"!==e&&1===o,u=0;u<t.length;u+=1){for(s=t.charCodeAt(u),!0===l&&(a=255&s,s=a<<8|s>>>8),c=p+w,h=c>>>2;d.length<=h;)d.push(0);d[h]|=s<<8*(f+o*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,o,n)};case"B64":return function(t,e,o){return function(t,e,n,o){let s,i,u,a,h,c,f,l=0;const p=e||[0],d=(n=n||0)>>>3,w=-1===o?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<t.length;i+=4){for(h=t.substr(i,4),a=0,u=0;u<h.length;u+=1)s=r.indexOf(h.charAt(u)),a|=s<<18-6*u;for(u=0;u<h.length-1;u+=1){for(f=l+d,c=f>>>2;p.length<=c;)p.push(0);p[c]|=(a>>>16-8*u&255)<<8*(w+o*(f%4)),l+=1}}return{value:p,binLen:8*l+n}}(t,e,o,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let o,s,i,u;const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(s=0;s<t.length;s+=1)o=t.charCodeAt(s),u=s+h,i=u>>>2,a.length<=i&&a.push(0),a[i]|=o<<8*(c+r*(u%4));return{value:a,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return o(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return o(t,e,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function i(t,e,n,o){switch(t){case"HEX":return function(t){return function(t,e,n,r){const o="0123456789abcdef";let s,i,u="";const a=e/8,h=-1===n?3:0;for(s=0;s<a;s+=1)i=t[s>>>2]>>>8*(h+n*(s%4)),u+=o.charAt(i>>>4&15)+o.charAt(15&i);return r.outputUpper?u.toUpperCase():u}(t,e,n,o)};case"B64":return function(t){return function(t,e,n,o){let s,i,u,a,h,c="";const f=e/8,l=-1===n?3:0;for(s=0;s<f;s+=3)for(a=s+1<f?t[s+1>>>2]:0,h=s+2<f?t[s+2>>>2]:0,u=(t[s>>>2]>>>8*(l+n*(s%4))&255)<<16|(a>>>8*(l+n*((s+1)%4))&255)<<8|h>>>8*(l+n*((s+2)%4))&255,i=0;i<4;i+=1)c+=8*s+6*i<=e?r.charAt(u>>>6*(3-i)&63):o.b64Pad;return c}(t,e,n,o)};case"BYTES":return function(t){return function(t,e,n){let r,o,s="";const i=e/8,u=-1===n?3:0;for(r=0;r<i;r+=1)o=t[r>>>2]>>>8*(u+n*(r%4))&255,s+=String.fromCharCode(o);return s}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=new ArrayBuffer(o),i=new Uint8Array(s),u=-1===n?3:0;for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(u+n*(r%4))&255;return s}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,s=-1===n?3:0,i=new Uint8Array(o);for(r=0;r<o;r+=1)i[r]=t[r>>>2]>>>8*(s+n*(r%4))&255;return i}(t,e,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const u=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function c(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}function f(t,e){return t>>>e|t<<32-e}function l(t,e){return t>>>e}function p(t,e,n){return t&e^~t&n}function d(t,e,n){return t&e^t&n^e&n}function w(t){return f(t,2)^f(t,13)^f(t,22)}function g(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function m(t,e,n,r){const o=(65535&t)+(65535&e)+(65535&n)+(65535&r);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16))<<16|65535&o}function y(t,e,n,r,o){const s=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&o);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16)+(s>>>16))<<16|65535&s}function A(t){return f(t,7)^f(t,18)^l(t,3)}function b(t){return f(t,6)^f(t,11)^f(t,25)}function v(t){let e;return e="SHA-224"==t?a.slice():h.slice(),e}function R(t,e){let n,r,o,s,i,a,h,c,v,R,E;const U=[];for(n=e[0],r=e[1],o=e[2],s=e[3],i=e[4],a=e[5],h=e[6],c=e[7],E=0;E<64;E+=1)U[E]=E<16?t[E]:m(f(T=U[E-2],17)^f(T,19)^l(T,10),U[E-7],A(U[E-15]),U[E-16]),v=y(c,b(i),p(i,a,h),u[E],U[E]),R=g(w(n),d(n,r,o)),c=h,h=a,a=i,i=g(s,v),s=o,o=r,r=n,n=g(v,R);var T;return e[0]=g(n,e[0]),e[1]=g(r,e[1]),e[2]=g(o,e[2]),e[3]=g(s,e[3]),e[4]=g(i,e[4]),e[5]=g(a,e[5]),e[6]=g(h,e[6]),e[7]=g(c,e[7]),e}class E extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.A=!1,this.l=0,this.p=!1,this.R=[],this.U=[]}update(t){let e,n=0;const r=this.T>>>5,o=this.F(t,this.h,this.u),s=o.binLen,i=o.value,u=s>>>5;for(e=0;e<u;e+=r)n+this.T<=s&&(this.m=this.g(i.slice(e,e+r),this.m),n+=this.T);return this.l+=n,this.h=i.slice(n>>>5),this.u=s%this.T,this.A=!0,this}getHash(t,e){let n,r,o=this.B;const s=c(e);if(this.H){if(-1===s.outputLen)throw new Error("Output length must be specified in options");o=s.outputLen}const u=i(t,o,this.v,s);if(this.p&&this.Y)return u(this.Y(s));for(r=this.C(this.h.slice(),this.u,this.l,this.S(this.m),o),n=1;n<this.numRounds;n+=1)this.H&&o%32!=0&&(r[r.length-1]&=16777215>>>24-o%32),r=this.C(r,o,0,this.I(this.o),o);return u(r)}setHMACKey(t,e,n){if(!this.L)throw new Error("Variant does not support HMAC");if(this.A)throw new Error("Cannot set MAC key after calling update");const r=s(e,(n||{}).encoding||"UTF8",this.v);this.M(r(t))}M(t){const e=this.T>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.C(t.value,t.binLen,0,this.I(this.o),this.B));t.value.length<=n;)t.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^t.value[r],this.U[r]=1549556828^t.value[r];this.m=this.g(this.R,this.m),this.l=this.T,this.p=!0}getHMAC(t,e){const n=c(e);return i(t,this.B,this.v,n)(this.N())}N(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.C(this.h.slice(),this.u,this.l,this.S(this.m),this.B);return t=this.g(this.U,this.I(this.o)),t=this.C(e,this.B,this.T,t,this.B),t}}{constructor(t,e,n){if("SHA-224"!==t&&"SHA-256"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.Y=this.N,this.L=!0,this.v=-1,this.F=s(this.t,this.i,this.v),this.g=R,this.S=function(t){return t.slice()},this.I=v,this.C=function(e,n,r,o){return function(t,e,n,r,o){let s,i;const u=15+(e+65>>>9<<4),a=e+n;for(;t.length<=u;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[u]=4294967295&a,t[u-1]=a/4294967296|0,s=0;s<t.length;s+=16)r=R(t.slice(s,s+16),r);return i="SHA-224"===o?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,i}(e,n,r,o,t)},this.m=v(t),this.T=512,this.B="SHA-224"===t?224:256,this.H=!1,r.hmacKey&&this.M(function(t,e,n,r){const o="hmacKey must include a value and format";if(!e)throw new Error(o);if(void 0===e.value||!e.format)throw new Error(o);return s(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.v))}}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ArrayKeyedMap:()=>A(),BUFF_D:()=>v,BUFF_E:()=>R,BUFF_L:()=>b,CommonPieceLength:()=>k,DEFAULT_BLOCK_LENGTH:()=>Y,TorrentType:()=>H,calculatePieceLength:()=>m,collapseAnnounceList:()=>p,create:()=>q,decideName:()=>g,encode:()=>U,getCommonDir:()=>d,getSortedIndex:()=>a,iterableSort:()=>h,merkleRoot:()=>f,nextPowerOfTwo:()=>l,padFiles:()=>w,parseFileTree:()=>c,useArrayBufferPromiseHook:()=>L,useTextPromiseHook:()=>F,useUint8ArrayStreamHook:()=>B});const t={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let e;const o=new Uint8Array(16);function s(){if(!e&&(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!e))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(o)}const i=[];for(let t=0;t<256;++t)i.push((t+256).toString(16).slice(1));const u=function(e,n,r){if(t.randomUUID&&!n&&!e)return t.randomUUID();const o=(e=e||{}).random||(e.rng||s)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,n){r=r||0;for(let t=0;t<16;++t)n[r+t]=o[t];return n}return function(t,e=0){return(i[t[e+0]]+i[t[e+1]]+i[t[e+2]]+i[t[e+3]]+"-"+i[t[e+4]]+i[t[e+5]]+"-"+i[t[e+6]]+i[t[e+7]]+"-"+i[t[e+8]]+i[t[e+9]]+"-"+i[t[e+10]]+i[t[e+11]]+i[t[e+12]]+i[t[e+13]]+i[t[e+14]]+i[t[e+15]]).toLowerCase()}(o)};function a(t,e,n){let r=0,o=t.length;for(;r<o;){const s=r+o>>>1;n(t[s],e)<0?r=s+1:o=s}return r}function h(t,e){const n=[];for(const r of t)n.splice(a(n,r,e),0,r);return n}function c(t){let e=[];const n=new WeakMap;for(const r of t){const t=(r.webkitRelativePath||r.name).split("/");t.reduce(((e,o,s)=>{let i=e.find((t=>t[0]===o));if(i)return i[1];const u=a(e,o,((t,e)=>t[0]<e?-1:1));if(s===t.length-1){const t={"":{length:r.size}};n.set(t,r),i=[o,t]}else i=[o,[]];return e.splice(u,0,i),i[1]}),e)}let r;1===e.length&&Array.isArray(e[0][1])&&(r=e[0][0],e=e[0][1]);const o=[];return{fileTree:{*[Symbol.iterator](){for(const t of o)yield t},...function t(e){if(Array.isArray(e)){const n={};for(const r of e)n[r[0]]=t(r[1]);return n}{const t=e;return o.push(t),t}}(e)},fileNodeMap:n,commonDir:r}}async function f(t){const e=new Uint8Array(64);for(;t.length>1;){let n=!1;const r=[];for(const o of t)n?(e.set(o,32),r.push(new Uint8Array(await crypto.subtle.digest("SHA-256",e))),n=!1):(e.set(o),n=!0);t=r}return t[0]}function l(t){return 1<<32-Math.clz32(t-1)}function p(t){if(void 0===t)return;const e=[];for(const n of t)0!==n.length&&e.push(n);return 0!==e.length?e:void 0}function d(t){let e;for(const n of t){const t=(n.webkitRelativePath||n.name).split("/");if(1==t.length||(e??=t[0])!==t[0])return}return e}function w(t,e,n){const r=[],o=t.length-1;for(const[s,i]of t.entries()){if(r.push(i),s===o)break;const t=i.size%e;if(0===t)continue;const u=e-t,a=new File([new ArrayBuffer(u)],`${u}`,{type:"application/octet-stream"}),h=`.pad/${u}`,c=void 0===n?h:`${n}/${h}`;Object.defineProperties(a,{webkitRelativePath:{configurable:!0,enumerable:!0,get:()=>c},padding:{configurable:!0,enumerable:!1,get:()=>!0}}),r.push(a)}return r}function g(t,e,n){return void 0===e&&1===n.length?t=n[0].name:t??=e||u(),t}function m(t,e){return Math.max(e,l(t>>>10))}var y=n(340),A=n.n(y);const b=new Uint8Array([108]),v=new Uint8Array([100]),R=new Uint8Array([101]);class E{textEncoder=new TextEncoder;textDecoder=new TextDecoder;data;hooks;isHooking=!1;path=[];constructor(t,e){this.data=t,this.hooks=e}start(t){this.encode(this.data,t),t.close()}encode(t,e){if(null!=t)if("boolean"==typeof t)this.encode(t?1:0,e);else if("number"==typeof t){const n=Math.round(t);e.enqueue(this.textEncoder.encode(`i${n}e`)),n!==t&&(console.warn(`WARNING: Possible data corruption detected with value "${t}":`,`Bencoding only defines support for integers, value was converted to "${n}"`),console.trace())}else if("bigint"==typeof t)e.enqueue(this.textEncoder.encode(`i${t}e`));else if("string"==typeof t){const n=this.textEncoder.encode(t),r=n.byteLength;e.enqueue(this.textEncoder.encode(`${r}:`)),e.enqueue(n)}else if(t instanceof ArrayBuffer){const n=new Uint8Array(t),r=n.byteLength;e.enqueue(this.textEncoder.encode(`${r}:`)),e.enqueue(n)}else if(Array.isArray(t)){e.enqueue(b);for(let n of t)this.encode(n,e);e.enqueue(R)}else if(t instanceof Map){e.enqueue(v);const n=h(t.keys(),((t,e)=>(t="string"==typeof t?t:this.textDecoder.decode(t))<(e="string"==typeof e?e:this.textDecoder.decode(e))?-1:t>e?1:0));for(const r of n){const n=t.get(r);if(void 0!==n&&null!==t){if(this.path.push(r),this.encode(r,e),this.hooks){const t=this.hooks.get(this.path);if(t){const r=T(e,t);this.encode(n,r),t({value:void 0,done:!0})}else this.encode(n,e)}this.path.pop()}}e.enqueue(R)}else{e.enqueue(v);const n=Object.keys(t).sort();for(const r of n){const n=t[r];if(void 0!==n&&null!==t){if(this.path.push(r),this.encode(r,e),this.hooks){const t=this.hooks.get(this.path);if(t){const r=T(e,t);this.encode(n,r),t({value:void 0,done:!0})}else this.encode(n,e)}this.path.pop()}}e.enqueue(R)}}}function U(t,e){return new ReadableStream(new E(t,e))}function T(t,e){return new Proxy(t,{get:function(t,n,r){return"enqueue"!==n?Reflect.get(t,n,r):(n=>{t.enqueue(n),void 0!==n&&e({value:n,done:!1})}).bind(t)}})}function B(){const t={controller:null};return[new ReadableStream({start(e){t.controller=e}}),({value:e,done:n})=>{null!==t.controller&&(n?t.controller.close():t.controller.enqueue(e))}]}function L(){const[t,e]=B();return[new Response(t).arrayBuffer(),e]}function F(){const[t,e]=B();return[new Response(t).text(),e]}n(913);class C extends Error{constructor(t,e){super(((t,...e)=>{let n=t;return e.length>0&&(n+=` :: ${JSON.stringify(e)}`),n})(t,e)),this.name=t,this.details=e}}class S{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}function M(t){const e=t.map((t=>Promise.resolve(t).then((t=>function(t){if(t instanceof Response){if(t.body)return t.body.getReader();throw new C("opaque-streams-source",{type:t.type})}return t instanceof ReadableStream?t.getReader():new Response(t).body.getReader()}(t))))),n=new S;let r=0;const o=new ReadableStream({pull(t){return e[r].then((t=>t.read())).then((o=>{if(o.done)return r++,r>=e.length?(t.close(),void n.resolve()):this.pull(t);t.enqueue(o.value)})).catch((t=>{throw n.reject(t),t}))},cancel(){n.resolve()}});return{done:n.promise,stream:o}}var H;n(1),function(t){t.V1="v1",t.V2="v2",t.HYBRID="hybrid"}(H||(H={}));const Y=16384;var k;!function(t){t[t["16KB"]=16384]="16KB",t[t["32KB"]=32768]="32KB",t[t["64KB"]=65536]="64KB",t[t["128KB"]=131072]="128KB",t[t["256KB"]=262144]="256KB",t[t["512KB"]=524288]="512KB",t[t["1MB"]=1048576]="1MB",t[t["2MB"]=2097152]="2MB",t[t["4MB"]=4194304]="4MB",t[t["8MB"]=8388608]="8MB",t[t["16MB"]=16777216]="16MB",t[t["32MB"]=33554432]="32MB"}(k||(k={}));const I=new Uint8Array(32),P={type:H.V1,addCreatedBy:!0,addCreationDate:!0,addPaddingFiles:!1,blockLength:Y,sortFiles:!0,isPrivate:!1},N={type:H.V2,addCreatedBy:!0,addCreationDate:!0,blockLength:Y,metaVersion:2,isPrivate:!1},x={type:H.HYBRID,addCreatedBy:!0,addCreationDate:!0,blockLength:Y,metaVersion:2,isPrivate:!1};async function q(t,e={type:H.V1},r=((t,e)=>{})){if(0===t.length)throw new Error("empty file list");let o;switch(e.type){case H.V1:o={...P,...e};break;case H.V2:o={...N,...e};break;case H.HYBRID:o={...x,...e}}o.pieceLength??=m(t.reduce(((t,e)=>t+e.size),0),o.blockLength);let{addCreatedBy:s,addCreationDate:i,blockLength:u,comment:a,isPrivate:h,name:y,pieceLength:A}=o;if(o.type!==H.V1&&A<u)throw new Error(`piece length ${A} is smaller than block length ${u}`);if(0!=(A&A-1))throw new Error(`piece length ${A} is not a power of 2`);const b=A/u;o.announceList=p(o.announceList),void 0===o.announce&&void 0!==o.announceList&&(o.announce=o.announceList[0][0]);const{announce:v,announceList:R}=o,E={...v&&{announce:v},...R&&{"announce-list":R},...a&&{comment:a},...s&&{"created by":"torrefy v2.0.1"},...i&&{"creation date":Date.now()/1e3>>0}};let U,T,B=0,L=t.reduce(((t,e)=>t+Math.ceil(e.size/A)),0);if(o.type===H.V1){const{addPaddingFiles:e,sortFiles:n}=o;let r,s;if(n){const{fileTree:e,fileNodeMap:n,commonDir:r}=c(t);t=[...e].map((t=>n.get(t))),s=r}else s=d(t);if(o.name=y=g(y,s,t),e){const e=t.length-1;r=M(t.map((async(t,n)=>C(t.stream(),{padding:n!==e})))).stream,t=w(t,A,s)}else{L=Math.ceil(t.reduce(((t,e)=>t+e.size),0)/A);const{stream:e}=M(t.map((t=>Promise.resolve(t.stream()))));r=C(e)}U={...E,info:{...t.length>1?{files:t.map((t=>{const e=(t.webkitRelativePath||t.name).split("/");return void 0!==s&&e.shift(),{...t.padding&&{attr:"p"},length:t.size,path:e}}))}:{length:t[0].size},name:y,"piece length":A,pieces:await new Response(r).arrayBuffer(),...h&&{private:1}}}}else if(o.type===H.V2){const{metaVersion:e}=o,{fileTree:n,fileNodeMap:r,commonDir:s}=c(t),i=[...n];t=i.map((t=>r.get(t)));const u=new Map;o.name=y=g(y,s,t),await Promise.all(i.map((async(e,n)=>{const r=t[n];await F(e,r,r.stream(),u)}))),U={...E,info:{"file tree":n,"meta version":e,name:y,"piece length":A,...h&&{private:1}},...u.size>0&&{"piece layers":u}}}else{if(o.type!==H.HYBRID)throw new Error("torrent type is not supported");{const{metaVersion:e}=o,{fileTree:n,fileNodeMap:r,commonDir:s}=c(t),i=[...n];t=i.map((t=>r.get(t)));const u=new Map;o.name=y=g(y,s,t),L*=2;const a=t.length-1,f=[];await Promise.all(i.map((async(e,n)=>{const r=t[n],[o,s]=r.stream().tee();f.push(Promise.resolve(C(o,{padding:n!==a}))),await F(e,r,s,u)})));const l=M(f).stream;t=w(t,A,s),U={...E,info:{"file tree":n,...t.length>1?{files:t.map((t=>{const e=(t.webkitRelativePath||t.name).split("/");return void 0!==s&&e.shift(),{...t.padding&&{attr:"p"},length:t.size,path:e}}))}:{length:t[0].size},"meta version":e,name:y,"piece length":A,pieces:await new Response(l).arrayBuffer(),...h&&{private:1}},...u.size>0&&{"piece layers":u}}}}return U;async function F(t,e,r,o){const[s,i]=function(t){const e=t.pipeThrough(S(u)).pipeThrough(function(){let t=0,e=[];return new TransformStream({transform:async(r,o)=>{let s;++t;try{s=new Uint8Array(await crypto.subtle.digest("SHA-256",r))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,673)),e=new t("SHA-256","UINT8ARRAY");e.update(r),s=e.getHash("UINT8ARRAY")}e.push(s),e.length===b&&(o.enqueue(e),e=[])},flush:async n=>{if(0===t)return;let r=0;if(t<b)r=l(t)-t;else{const e=t%b;e>0&&(r=b-e)}if(r>0)for(let t=0;t<r;++t)e.push(I);e.length>0&&n.enqueue(e)}})}()).pipeThrough(Y(!0)),[r,o]=e.tee();return[o.pipeThrough(k()).pipeThrough(Y()),r]}(r),a=new Response(s).arrayBuffer();if(e.size>A){const t=new Response(i).arrayBuffer();o.set(await a,await t)}e.size>0&&(t[""]["pieces root"]=await a)}function C(t,e={padding:!1}){return t.pipeThrough(S(A,{padding:e.padding})).pipeThrough(function(t=!1){return new TransformStream({transform:async(e,o)=>{let s;try{s=new Uint8Array(await crypto.subtle.digest("SHA-1",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,211)),r=new t("SHA-1","UINT8ARRAY");r.update(e),s=r.getHash("UINT8ARRAY")}o.enqueue(s),t&&r(++B,L)}})}(!0))}function S(t,e={padding:!1}){let n=new Uint8Array(t),r=0;return new TransformStream({transform:(e,o)=>{for(;r+e.length>=t;){const s=t-r;n.set(e.subarray(0,s),r),r=0,o.enqueue(new Uint8Array(n)),e=e.subarray(s)}n.set(e,r),r+=e.length},flush:o=>{r>0&&(e.padding?(n.set(new Uint8Array(t-r),r),o.enqueue(n)):o.enqueue(n.subarray(0,r)))}})}function Y(t=!1){return new TransformStream({transform:async(e,n)=>{n.enqueue(await f(e)),t&&r(++B,L)}})}function k(){let t=0,e=[];return new TransformStream({transform:n=>{++t,e.push(n)},flush:async n=>{const r=l(t)-t;if(r>0){T??=await f(Array(b).fill(new Uint8Array(32)));for(let t=0;t<r;++t)e.push(T)}n.enqueue(e)}})}}})(),r})()));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.torrefy=e():t.torrefy=e()}(self,(()=>(()=>{var t={340:t=>{const e=Symbol("path-store-trunk");class n{constructor(t=[]){this._root=new Map,this._size=0;for(const[e,n]of t)this.set(e,n)}set(t,e){return r.call(this,t,e)}has(t){return o.call(this,t)}get(t){return i.call(this,t)}delete(t){return s.call(this,t)}get size(){return this._size}clear(){this._root.clear(),this._size=0}hasPrefix(t){return u.call(this,t)}get[Symbol.toStringTag](){return"ArrayKeyedMap"}*[Symbol.iterator](){yield*a.call(this)}*entries(){yield*a.call(this)}*keys(){yield*h.call(this)}*values(){yield*c.call(this)}forEach(t,e){f.call(this,t,e)}}function r(t,n){let r=this._root;for(const e of t){let t=r.get(e);t||(t=new Map,r.set(e,t)),r=t}return r.has(e)||(this._size+=1),r.set(e,n),this}function o(t){let n=this._root;for(const e of t){const t=n.get(e);if(!t)return!1;n=t}return n.has(e)}function i(t){let n=this._root;for(const e of t)if(n=n.get(e),!n)return;return n.get(e)}function s(t){let n=this._root;const r=[];for(const e of t){const t=n.get(e);if(!t)return!1;r.unshift({parent:n,child:t,item:e}),n=t}const o=n.delete(e);if(o){this._size-=1;for(const{parent:t,child:e,item:n}of r)0===e.size&&t.delete(n)}return o}function u(t){let e=this._root;for(const n of t)if(e=e.get(n),!e)return!1;return!0}function*a(){const t=[{path:[],map:this._root}];for(;t.length>0;){const{path:n,map:r}=t.pop();for(const[o,i]of r.entries())o===e?yield[n,i]:t.push({path:n.concat([o]),map:i})}}function*h(){for(const[t]of this.entries())yield t}function*c(){for(const[,t]of this.entries())yield t}function f(t,e){for(const[n,r]of this.entries())t.call(e,r,n,this)}t.exports=n},913:()=>{"use strict";try{self["workbox:core:6.5.3"]&&_()}catch(t){}},1:()=>{"use strict";try{self["workbox:streams:6.5.3"]&&_()}catch(t){}},211:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>g});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function o(t,e,n,r){let o,i,s;const u=e||[0],a=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<t.length;o+=1)s=o+a,i=s>>>2,u.length<=i&&u.push(0),u[i]|=t[o]<<8*(h+r*(s%4));return{value:u,binLen:8*t.length+n}}function i(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let o,i,s,u;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o<t.length;o+=2){if(i=parseInt(t.substr(o,2),16),isNaN(i))throw new Error("String of HEX type contains invalid characters");for(u=(o>>>1)+h,s=u>>>2;a.length<=s;)a.push(0);a[s]|=i<<8*(c+r*(u%4))}return{value:a,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,o){return function(t,e,n,r,o){let i,s,u,a,h,c,f,l,p=0;const d=n||[0],y=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===o?3:0,u=0;u<t.length;u+=1)for(i=t.charCodeAt(u),s=[],128>i?s.push(i):2048>i?(s.push(192|i>>>6),s.push(128|63&i)):55296>i||57344<=i?s.push(224|i>>>12,128|i>>>6&63,128|63&i):(u+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(u)),s.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),a=0;a<s.length;a+=1){for(c=p+y,h=c>>>2;d.length<=h;)d.push(0);d[h]|=s[a]<<8*(f+o*(c%4)),p+=1}else for(f=-1===o?2:0,l="UTF16LE"===e&&1!==o||"UTF16LE"!==e&&1===o,u=0;u<t.length;u+=1){for(i=t.charCodeAt(u),!0===l&&(a=255&i,i=a<<8|i>>>8),c=p+y,h=c>>>2;d.length<=h;)d.push(0);d[h]|=i<<8*(f+o*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,o,n)};case"B64":return function(t,e,o){return function(t,e,n,o){let i,s,u,a,h,c,f,l=0;const p=e||[0],d=(n=n||0)>>>3,y=-1===o?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(s=0;s<t.length;s+=4){for(h=t.substr(s,4),a=0,u=0;u<h.length;u+=1)i=r.indexOf(h.charAt(u)),a|=i<<18-6*u;for(u=0;u<h.length-1;u+=1){for(f=l+d,c=f>>>2;p.length<=c;)p.push(0);p[c]|=(a>>>16-8*u&255)<<8*(y+o*(f%4)),l+=1}}return{value:p,binLen:8*l+n}}(t,e,o,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let o,i,s,u;const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<t.length;i+=1)o=t.charCodeAt(i),u=i+h,s=u>>>2,a.length<=s&&a.push(0),a[s]|=o<<8*(c+r*(u%4));return{value:a,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return o(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return o(t,e,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function s(t,e,n,o){switch(t){case"HEX":return function(t){return function(t,e,n,r){const o="0123456789abcdef";let i,s,u="";const a=e/8,h=-1===n?3:0;for(i=0;i<a;i+=1)s=t[i>>>2]>>>8*(h+n*(i%4)),u+=o.charAt(s>>>4&15)+o.charAt(15&s);return r.outputUpper?u.toUpperCase():u}(t,e,n,o)};case"B64":return function(t){return function(t,e,n,o){let i,s,u,a,h,c="";const f=e/8,l=-1===n?3:0;for(i=0;i<f;i+=3)for(a=i+1<f?t[i+1>>>2]:0,h=i+2<f?t[i+2>>>2]:0,u=(t[i>>>2]>>>8*(l+n*(i%4))&255)<<16|(a>>>8*(l+n*((i+1)%4))&255)<<8|h>>>8*(l+n*((i+2)%4))&255,s=0;s<4;s+=1)c+=8*i+6*s<=e?r.charAt(u>>>6*(3-s)&63):o.b64Pad;return c}(t,e,n,o)};case"BYTES":return function(t){return function(t,e,n){let r,o,i="";const s=e/8,u=-1===n?3:0;for(r=0;r<s;r+=1)o=t[r>>>2]>>>8*(u+n*(r%4))&255,i+=String.fromCharCode(o);return i}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,i=new ArrayBuffer(o),s=new Uint8Array(i),u=-1===n?3:0;for(r=0;r<o;r+=1)s[r]=t[r>>>2]>>>8*(u+n*(r%4))&255;return i}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,i=-1===n?3:0,s=new Uint8Array(o);for(r=0;r<o;r+=1)s[r]=t[r>>>2]>>>8*(i+n*(r%4))&255;return s}(t,e,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function u(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}function a(t,e){return t<<e|t>>>32-e}function h(t,e,n){return t^e^n}function c(t,e,n){return t&e^t&n^e&n}function f(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function l(t,e,n,r,o){const i=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&o);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16)+(i>>>16))<<16|65535&i}function p(t){return[1732584193,4023233417,2562383102,271733878,3285377520]}function d(t,e){let n,r,o,i,s,u,p;const d=[];for(n=e[0],r=e[1],o=e[2],i=e[3],s=e[4],p=0;p<80;p+=1)d[p]=p<16?t[p]:a(d[p-3]^d[p-8]^d[p-14]^d[p-16],1),u=p<20?l(a(n,5),(y=r)&o^~y&i,s,1518500249,d[p]):p<40?l(a(n,5),h(r,o,i),s,1859775393,d[p]):p<60?l(a(n,5),c(r,o,i),s,2400959708,d[p]):l(a(n,5),h(r,o,i),s,3395469782,d[p]),s=i,i=o,o=a(r,30),r=n,n=u;var y;return e[0]=f(n,e[0]),e[1]=f(r,e[1]),e[2]=f(o,e[2]),e[3]=f(i,e[3]),e[4]=f(s,e[4]),e}function y(t,e,n,r){let o;const i=15+(e+65>>>9<<4),s=e+n;for(;t.length<=i;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[i]=4294967295&s,t[i-1]=s/4294967296|0,o=0;o<t.length;o+=16)r=d(t.slice(o,o+16),r);return r}class g extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.R=[],this.U=[]}update(t){let e,n=0;const r=this.T>>>5,o=this.F(t,this.h,this.u),i=o.binLen,s=o.value,u=i>>>5;for(e=0;e<u;e+=r)n+this.T<=i&&(this.m=this.g(s.slice(e,e+r),this.m),n+=this.T);return this.A+=n,this.h=s.slice(n>>>5),this.u=i%this.T,this.l=!0,this}getHash(t,e){let n,r,o=this.B;const i=u(e);if(this.v){if(-1===i.outputLen)throw new Error("Output length must be specified in options");o=i.outputLen}const a=s(t,o,this.Y,i);if(this.p&&this.H)return a(this.H(i));for(r=this.C(this.h.slice(),this.u,this.A,this.I(this.m),o),n=1;n<this.numRounds;n+=1)this.v&&o%32!=0&&(r[r.length-1]&=16777215>>>24-o%32),r=this.C(r,o,0,this.L(this.o),o);return a(r)}setHMACKey(t,e,n){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=i(e,(n||{}).encoding||"UTF8",this.Y);this.N(r(t))}N(t){const e=this.T>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.C(t.value,t.binLen,0,this.L(this.o),this.B));t.value.length<=n;)t.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^t.value[r],this.U[r]=1549556828^t.value[r];this.m=this.g(this.R,this.m),this.A=this.T,this.p=!0}getHMAC(t,e){const n=u(e);return s(t,this.B,this.Y,n)(this.S())}S(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.C(this.h.slice(),this.u,this.A,this.I(this.m),this.B);return t=this.g(this.U,this.L(this.o)),t=this.C(e,this.B,this.T,t,this.B),t}}{constructor(t,e,n){if("SHA-1"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.M=!0,this.H=this.S,this.Y=-1,this.F=i(this.t,this.i,this.Y),this.g=d,this.I=function(t){return t.slice()},this.L=p,this.C=y,this.m=[1732584193,4023233417,2562383102,271733878,3285377520],this.T=512,this.B=160,this.v=!1,r.hmacKey&&this.N(function(t,e,n,r){const o="hmacKey must include a value and format";if(!e)throw new Error(o);if(void 0===e.value||!e.format)throw new Error(o);return i(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.Y))}}},673:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>R});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function o(t,e,n,r){let o,i,s;const u=e||[0],a=(n=n||0)>>>3,h=-1===r?3:0;for(o=0;o<t.length;o+=1)s=o+a,i=s>>>2,u.length<=i&&u.push(0),u[i]|=t[o]<<8*(h+r*(s%4));return{value:u,binLen:8*t.length+n}}function i(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let o,i,s,u;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o<t.length;o+=2){if(i=parseInt(t.substr(o,2),16),isNaN(i))throw new Error("String of HEX type contains invalid characters");for(u=(o>>>1)+h,s=u>>>2;a.length<=s;)a.push(0);a[s]|=i<<8*(c+r*(u%4))}return{value:a,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,o){return function(t,e,n,r,o){let i,s,u,a,h,c,f,l,p=0;const d=n||[0],y=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===o?3:0,u=0;u<t.length;u+=1)for(i=t.charCodeAt(u),s=[],128>i?s.push(i):2048>i?(s.push(192|i>>>6),s.push(128|63&i)):55296>i||57344<=i?s.push(224|i>>>12,128|i>>>6&63,128|63&i):(u+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(u)),s.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),a=0;a<s.length;a+=1){for(c=p+y,h=c>>>2;d.length<=h;)d.push(0);d[h]|=s[a]<<8*(f+o*(c%4)),p+=1}else for(f=-1===o?2:0,l="UTF16LE"===e&&1!==o||"UTF16LE"!==e&&1===o,u=0;u<t.length;u+=1){for(i=t.charCodeAt(u),!0===l&&(a=255&i,i=a<<8|i>>>8),c=p+y,h=c>>>2;d.length<=h;)d.push(0);d[h]|=i<<8*(f+o*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,o,n)};case"B64":return function(t,e,o){return function(t,e,n,o){let i,s,u,a,h,c,f,l=0;const p=e||[0],d=(n=n||0)>>>3,y=-1===o?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(s=0;s<t.length;s+=4){for(h=t.substr(s,4),a=0,u=0;u<h.length;u+=1)i=r.indexOf(h.charAt(u)),a|=i<<18-6*u;for(u=0;u<h.length-1;u+=1){for(f=l+d,c=f>>>2;p.length<=c;)p.push(0);p[c]|=(a>>>16-8*u&255)<<8*(y+o*(f%4)),l+=1}}return{value:p,binLen:8*l+n}}(t,e,o,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let o,i,s,u;const a=e||[0],h=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i<t.length;i+=1)o=t.charCodeAt(i),u=i+h,s=u>>>2,a.length<=s&&a.push(0),a[s]|=o<<8*(c+r*(u%4));return{value:a,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return o(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return o(t,e,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function s(t,e,n,o){switch(t){case"HEX":return function(t){return function(t,e,n,r){const o="0123456789abcdef";let i,s,u="";const a=e/8,h=-1===n?3:0;for(i=0;i<a;i+=1)s=t[i>>>2]>>>8*(h+n*(i%4)),u+=o.charAt(s>>>4&15)+o.charAt(15&s);return r.outputUpper?u.toUpperCase():u}(t,e,n,o)};case"B64":return function(t){return function(t,e,n,o){let i,s,u,a,h,c="";const f=e/8,l=-1===n?3:0;for(i=0;i<f;i+=3)for(a=i+1<f?t[i+1>>>2]:0,h=i+2<f?t[i+2>>>2]:0,u=(t[i>>>2]>>>8*(l+n*(i%4))&255)<<16|(a>>>8*(l+n*((i+1)%4))&255)<<8|h>>>8*(l+n*((i+2)%4))&255,s=0;s<4;s+=1)c+=8*i+6*s<=e?r.charAt(u>>>6*(3-s)&63):o.b64Pad;return c}(t,e,n,o)};case"BYTES":return function(t){return function(t,e,n){let r,o,i="";const s=e/8,u=-1===n?3:0;for(r=0;r<s;r+=1)o=t[r>>>2]>>>8*(u+n*(r%4))&255,i+=String.fromCharCode(o);return i}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,i=new ArrayBuffer(o),s=new Uint8Array(i),u=-1===n?3:0;for(r=0;r<o;r+=1)s[r]=t[r>>>2]>>>8*(u+n*(r%4))&255;return i}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const o=e/8,i=-1===n?3:0,s=new Uint8Array(o);for(r=0;r<o;r+=1)s[r]=t[r>>>2]>>>8*(i+n*(r%4))&255;return s}(t,e,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const u=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function c(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}function f(t,e){return t>>>e|t<<32-e}function l(t,e){return t>>>e}function p(t,e,n){return t&e^~t&n}function d(t,e,n){return t&e^t&n^e&n}function y(t){return f(t,2)^f(t,13)^f(t,22)}function g(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function w(t,e,n,r){const o=(65535&t)+(65535&e)+(65535&n)+(65535&r);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16))<<16|65535&o}function m(t,e,n,r,o){const i=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&o);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(o>>>16)+(i>>>16))<<16|65535&i}function b(t){return f(t,7)^f(t,18)^l(t,3)}function A(t){return f(t,6)^f(t,11)^f(t,25)}function v(t){let e;return e="SHA-224"==t?a.slice():h.slice(),e}function E(t,e){let n,r,o,i,s,a,h,c,v,E,R;const U=[];for(n=e[0],r=e[1],o=e[2],i=e[3],s=e[4],a=e[5],h=e[6],c=e[7],R=0;R<64;R+=1)U[R]=R<16?t[R]:w(f(S=U[R-2],17)^f(S,19)^l(S,10),U[R-7],b(U[R-15]),U[R-16]),v=m(c,A(s),p(s,a,h),u[R],U[R]),E=g(y(n),d(n,r,o)),c=h,h=a,a=s,s=g(i,v),i=o,o=r,r=n,n=g(v,E);var S;return e[0]=g(n,e[0]),e[1]=g(r,e[1]),e[2]=g(o,e[2]),e[3]=g(i,e[3]),e[4]=g(s,e[4]),e[5]=g(a,e[5]),e[6]=g(h,e[6]),e[7]=g(c,e[7]),e}class R extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.A=!1,this.l=0,this.p=!1,this.R=[],this.U=[]}update(t){let e,n=0;const r=this.T>>>5,o=this.F(t,this.h,this.u),i=o.binLen,s=o.value,u=i>>>5;for(e=0;e<u;e+=r)n+this.T<=i&&(this.m=this.g(s.slice(e,e+r),this.m),n+=this.T);return this.l+=n,this.h=s.slice(n>>>5),this.u=i%this.T,this.A=!0,this}getHash(t,e){let n,r,o=this.B;const i=c(e);if(this.H){if(-1===i.outputLen)throw new Error("Output length must be specified in options");o=i.outputLen}const u=s(t,o,this.v,i);if(this.p&&this.Y)return u(this.Y(i));for(r=this.C(this.h.slice(),this.u,this.l,this.S(this.m),o),n=1;n<this.numRounds;n+=1)this.H&&o%32!=0&&(r[r.length-1]&=16777215>>>24-o%32),r=this.C(r,o,0,this.I(this.o),o);return u(r)}setHMACKey(t,e,n){if(!this.L)throw new Error("Variant does not support HMAC");if(this.A)throw new Error("Cannot set MAC key after calling update");const r=i(e,(n||{}).encoding||"UTF8",this.v);this.M(r(t))}M(t){const e=this.T>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.C(t.value,t.binLen,0,this.I(this.o),this.B));t.value.length<=n;)t.value.push(0);for(r=0;r<=n;r+=1)this.R[r]=909522486^t.value[r],this.U[r]=1549556828^t.value[r];this.m=this.g(this.R,this.m),this.l=this.T,this.p=!0}getHMAC(t,e){const n=c(e);return s(t,this.B,this.v,n)(this.N())}N(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.C(this.h.slice(),this.u,this.l,this.S(this.m),this.B);return t=this.g(this.U,this.I(this.o)),t=this.C(e,this.B,this.T,t,this.B),t}}{constructor(t,e,n){if("SHA-224"!==t&&"SHA-256"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.Y=this.N,this.L=!0,this.v=-1,this.F=i(this.t,this.i,this.v),this.g=E,this.S=function(t){return t.slice()},this.I=v,this.C=function(e,n,r,o){return function(t,e,n,r,o){let i,s;const u=15+(e+65>>>9<<4),a=e+n;for(;t.length<=u;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[u]=4294967295&a,t[u-1]=a/4294967296|0,i=0;i<t.length;i+=16)r=E(t.slice(i,i+16),r);return s="SHA-224"===o?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,s}(e,n,r,o,t)},this.m=v(t),this.T=512,this.B="SHA-224"===t?224:256,this.H=!1,r.hmacKey&&this.M(function(t,e,n,r){const o="hmacKey must include a value and format";if(!e)throw new Error(o);if(void 0===e.value||!e.format)throw new Error(o);return i(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.v))}}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ArrayKeyedMap:()=>b(),BUFF_D:()=>v,BUFF_E:()=>E,BUFF_L:()=>A,CommonPieceLength:()=>V,DEFAULT_BLOCK_LENGTH:()=>$,TorrentType:()=>K,calculatePieceLength:()=>w,collapseAnnounceList:()=>p,create:()=>Z,decideName:()=>g,decode:()=>Y,encode:()=>U,getCommonDir:()=>d,getSortedIndex:()=>a,iterableSort:()=>h,makeTokenizer:()=>M,merkleRoot:()=>f,nextPowerOfTwo:()=>l,padFiles:()=>y,parse:()=>H,parseFileTree:()=>c,useArrayBufferPromiseHook:()=>T,useTextPromiseHook:()=>k,useUint8ArrayStreamHook:()=>B});const t={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let e;const o=new Uint8Array(16);function i(){if(!e&&(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!e))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(o)}const s=[];for(let t=0;t<256;++t)s.push((t+256).toString(16).slice(1));const u=function(e,n,r){if(t.randomUUID&&!n&&!e)return t.randomUUID();const o=(e=e||{}).random||(e.rng||i)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,n){r=r||0;for(let t=0;t<16;++t)n[r+t]=o[t];return n}return function(t,e=0){return(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase()}(o)};function a(t,e,n){let r=0,o=t.length;for(;r<o;){const i=r+o>>>1;n(t[i],e)<0?r=i+1:o=i}return r}function h(t,e){const n=[];for(const r of t)n.splice(a(n,r,e),0,r);return n}function c(t){let e=[];const n=new WeakMap;for(const r of t){const t=(r.webkitRelativePath||r.name).split("/");t.reduce(((e,o,i)=>{let s=e.find((t=>t[0]===o));if(s)return s[1];const u=a(e,o,((t,e)=>t[0]<e?-1:1));if(i===t.length-1){const t={"":{length:r.size}};n.set(t,r),s=[o,t]}else s=[o,[]];return e.splice(u,0,s),s[1]}),e)}let r;1===e.length&&Array.isArray(e[0][1])&&(r=e[0][0],e=e[0][1]);const o=[];return{fileTree:{*[Symbol.iterator](){for(const t of o)yield t},...function t(e){if(Array.isArray(e)){const n={};for(const r of e)n[r[0]]=t(r[1]);return n}{const t=e;return o.push(t),t}}(e)},fileNodeMap:n,commonDir:r}}async function f(t){const e=new Uint8Array(64);for(;t.length>1;){let n=!1;const r=[];for(const o of t)n?(e.set(o,32),r.push(new Uint8Array(await crypto.subtle.digest("SHA-256",e))),n=!1):(e.set(o),n=!0);t=r}return t[0]}function l(t){return 1<<32-Math.clz32(t-1)}function p(t){if(void 0===t)return;const e=[];for(const n of t)0!==n.length&&e.push(n);return 0!==e.length?e:void 0}function d(t){let e;for(const n of t){const t=(n.webkitRelativePath||n.name).split("/");if(1==t.length||(e??=t[0])!==t[0])return}return e}function y(t,e,n){const r=[],o=t.length-1;for(const[i,s]of t.entries()){if(r.push(s),i===o)break;const t=s.size%e;if(0===t)continue;const u=e-t,a=new File([new ArrayBuffer(u)],`${u}`,{type:"application/octet-stream"}),h=`.pad/${u}`,c=void 0===n?h:`${n}/${h}`;Object.defineProperties(a,{webkitRelativePath:{configurable:!0,enumerable:!0,get:()=>c},padding:{configurable:!0,enumerable:!1,get:()=>!0}}),r.push(a)}return r}function g(t,e,n){return void 0===e&&1===n.length?t=n[0].name:t??=e||u(),t}function w(t,e){return Math.max(e,l(t>>>10))}var m=n(340),b=n.n(m);const A=new Uint8Array([108]),v=new Uint8Array([100]),E=new Uint8Array([101]);class R{textEncoder=new TextEncoder;textDecoder=new TextDecoder;data;hooks;isHooking=!1;path=[];constructor(t,e){this.data=t,this.hooks=e}start(t){this.encode(this.data,t),t.close()}encode(t,e){if(null!=t)if("boolean"==typeof t)this.encode(t?1:0,e);else if("number"==typeof t){const n=Math.round(t);e.enqueue(this.textEncoder.encode(`i${n}e`)),n!==t&&(console.warn(`WARNING: Possible data corruption detected with value "${t}":`,`Bencoding only defines support for integers, value was converted to "${n}"`),console.trace())}else if("bigint"==typeof t)e.enqueue(this.textEncoder.encode(`i${t}e`));else if("string"==typeof t){const n=this.textEncoder.encode(t),r=n.byteLength;e.enqueue(this.textEncoder.encode(`${r}:`)),e.enqueue(n)}else if(t instanceof ArrayBuffer){const n=new Uint8Array(t),r=n.byteLength;e.enqueue(this.textEncoder.encode(`${r}:`)),e.enqueue(n)}else if(Array.isArray(t)){e.enqueue(A);for(let n of t)this.encode(n,e);e.enqueue(E)}else if(t instanceof Map){e.enqueue(v);const n=h(t.keys(),((t,e)=>(t="string"==typeof t?t:this.textDecoder.decode(t))<(e="string"==typeof e?e:this.textDecoder.decode(e))?-1:t>e?1:0));for(const r of n){const n=t.get(r);if(void 0!==n&&null!==t){if(this.path.push(r),this.encode(r,e),this.hooks){const t=this.hooks.get(this.path);if(t){const r=S(e,t);this.encode(n,r),t({value:void 0,done:!0})}else this.encode(n,e)}this.path.pop()}}e.enqueue(E)}else{e.enqueue(v);const n=Object.keys(t).sort();for(const r of n){const n=t[r];if(void 0!==n&&null!==t){if(this.path.push(r),this.encode(r,e),this.hooks){const t=this.hooks.get(this.path);if(t){const r=S(e,t);this.encode(n,r),t({value:void 0,done:!0})}else this.encode(n,e)}this.path.pop()}}e.enqueue(E)}}}function U(t,e){return new ReadableStream(new R(t,e))}function S(t,e){return new Proxy(t,{get:function(t,n,r){return"enqueue"!==n?Reflect.get(t,n,r):(n=>{t.enqueue(n),void 0!==n&&e({value:n,done:!1})}).bind(t)}})}function B(){const t={controller:null};return[new ReadableStream({start(e){t.controller=e}}),({value:e,done:n})=>{null!==t.controller&&(n?t.controller.close():t.controller.enqueue(e))}]}function T(){const[t,e]=B();return[new Response(t).arrayBuffer(),e]}function k(){const[t,e]=B();return[new Response(t).text(),e]}var L;!function(t){t.Integer="Integer",t.ByteString="ByteString",t.ListStart="ListStart",t.ListEnd="ListEnd",t.DictionaryStart="DictionaryStart",t.DictionaryEnd="DictionaryEnd"}(L||(L={}));const F=A[0],C=v[0],I=E[0];class x{endStack=[];token=null;byteStringLength=0;byteStringOffset=0;transform(t,e){this.tokenize(t,e)}flush(){if(this.endStack.length||this.token||this.byteStringLength||this.byteStringOffset)throw new SyntaxError("Incomplete stream")}tokenize(t,e){if(0!==t.byteLength)if(null===this.token&&0===this.byteStringLength){const n=t[0];if(105===n)this.token={type:L.Integer,value:new Uint8Array};else if(D(n))this.byteStringLength=n-48;else if(n===F)this.endStack.push(L.ListEnd),e.enqueue({type:L.ListStart});else if(n===C)this.endStack.push(L.DictionaryEnd),e.enqueue({type:L.DictionaryStart});else{if(n!==I)throw new SyntaxError(`Unexpected byte: ${n}`);{const t=this.endStack.pop();if(!t)throw new SyntaxError("Unbalanced delimiter");e.enqueue({type:t})}}this.tokenize(t.subarray(1),e)}else if(this.token&&0===this.byteStringLength)if(this.token.type===L.Integer){const n=t.indexOf(I);-1===n?this.token.value=this.token.value?z(this.token.value,t):t:(this.token.value=this.token.value?z(this.token.value,t.subarray(0,n)):t.subarray(0,n),e.enqueue(this.token),this.token=null,this.tokenize(t.subarray(n+1),e))}else{if(this.token.type!==L.ByteString)throw new Error("This is a bug");{const n=this.token.value.byteLength-this.byteStringOffset,r=t.byteLength;r<n?(this.token.value.set(t,this.byteStringOffset),this.byteStringOffset+=r):(this.token.value.set(t.subarray(0,n),this.byteStringOffset),this.byteStringOffset=0,e.enqueue(this.token),this.token=null,this.tokenize(t.subarray(n),e))}}else{if(!this.byteStringLength||null!==this.token)throw new Error("This is a bug");{let n=-1;for(const[e,r]of t.entries()){if(!D(r)){if(58===r){n=e;break}throw new SyntaxError(`Unexpected byte: ${r}`)}this.byteStringLength=10*this.byteStringLength-48+r}-1!==n&&(this.token={type:L.ByteString,value:new Uint8Array(this.byteStringLength)},this.byteStringLength=0,this.tokenize(t.subarray(n+1),e))}}}}function M(){return new TransformStream(new x)}async function H(t){let e;const n=[],r=t.getReader();let o;for(;;){const{done:t,value:i}=await r.read();if(t)break;const s=n.at(-1);if(s)if(Array.isArray(s))switch(i.type){case L.Integer:s.push(P(i.value));break;case L.ByteString:s.push(N(i.value));break;case L.DictionaryStart:{const t=Object.create(null);s.push(t),n.push(t);break}case L.ListStart:{const t=[];s.push(t),n.push(t);break}case L.ListEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${i}`)}else if(void 0===o)switch(i.type){case L.ByteString:o=N(i.value);break;case L.DictionaryEnd:n.pop();break;default:throw new SyntaxError(`Unexpected token: ${i}`)}else{switch(i.type){case L.Integer:s[o]=P(i.value);break;case L.ByteString:s[o]=N(i.value);break;case L.DictionaryStart:{const t=Object.create(null);s[o]=t,n.push(t);break}case L.ListStart:{const t=[];s[o]=t,n.push(t);break}default:throw new SyntaxError(`Unexpected token: ${i}`)}o=void 0}else{if(void 0!==e)throw new SyntaxError(`Unexpected token: ${i}`);switch(i.type){case L.Integer:e=P(i.value);break;case L.ByteString:e=N(i.value);break;case L.DictionaryStart:{const t=Object.create(null);n.push(t),e=t;break}case L.ListStart:{const t=[];n.push(t),e=t;break}default:throw new SyntaxError(`Unexpected token: ${i}`)}}}if(n.length)throw new Error("Unexpected end of token stream");return e}async function Y(t){const e=M(),n=t.pipeThrough(e);return await H(n)}function P(t){let e=0,n=!0;for(const[r,o]of t.entries()){if(0===r&&45===o){n=!1;continue}if(1===r&&!n&&48===o)throw new SyntaxError("Negative zero is not a valid integer");if(1===r&&0===e)throw new SyntaxError("Leading zeros are not allowed");if(!D(o))throw new SyntaxError(`Unexpected byte: ${o}`);const t=o-48;(n&&"number"==typeof e&&e>(Number.MAX_SAFE_INTEGER-t)/10||!n&&"number"==typeof e&&e<(Number.MIN_SAFE_INTEGER+t)/10)&&(e=BigInt(e)),e="number"==typeof e?n?10*e+t:10*e-t:n?10n*e+BigInt(t):10n*e-BigInt(t)}return e}function N(t){return(new TextDecoder).decode(t)}function D(t){return t>=48&&t<=57}function z(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.byteLength),0));return t.reduce(((t,n)=>(e.set(n,t),t+n.byteLength)),0),e}n(913);class q extends Error{constructor(t,e){super(((t,...e)=>{let n=t;return e.length>0&&(n+=` :: ${JSON.stringify(e)}`),n})(t,e)),this.name=t,this.details=e}}class O{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}function _(t){const e=t.map((t=>Promise.resolve(t).then((t=>function(t){if(t instanceof Response){if(t.body)return t.body.getReader();throw new q("opaque-streams-source",{type:t.type})}return t instanceof ReadableStream?t.getReader():new Response(t).body.getReader()}(t))))),n=new O;let r=0;const o=new ReadableStream({pull(t){return e[r].then((t=>t.read())).then((o=>{if(o.done)return r++,r>=e.length?(t.close(),void n.resolve()):this.pull(t);t.enqueue(o.value)})).catch((t=>{throw n.reject(t),t}))},cancel(){n.resolve()}});return{done:n.promise,stream:o}}var K;n(1),function(t){t.V1="v1",t.V2="v2",t.HYBRID="hybrid"}(K||(K={}));const $=16384;var V;!function(t){t[t["16KB"]=16384]="16KB",t[t["32KB"]=32768]="32KB",t[t["64KB"]=65536]="64KB",t[t["128KB"]=131072]="128KB",t[t["256KB"]=262144]="256KB",t[t["512KB"]=524288]="512KB",t[t["1MB"]=1048576]="1MB",t[t["2MB"]=2097152]="2MB",t[t["4MB"]=4194304]="4MB",t[t["8MB"]=8388608]="8MB",t[t["16MB"]=16777216]="16MB",t[t["32MB"]=33554432]="32MB"}(V||(V={}));const X=new Uint8Array(32),j={type:K.V1,addCreatedBy:!0,addCreationDate:!0,addPaddingFiles:!1,blockLength:$,sortFiles:!0,isPrivate:!1},G={type:K.V2,addCreatedBy:!0,addCreationDate:!0,blockLength:$,metaVersion:2,isPrivate:!1},W={type:K.HYBRID,addCreatedBy:!0,addCreationDate:!0,blockLength:$,metaVersion:2,isPrivate:!1};async function Z(t,e={type:K.V1},r=((t,e)=>{})){if(0===t.length)throw new Error("empty file list");let o;switch(e.type){case K.V1:o={...j,...e};break;case K.V2:o={...G,...e};break;case K.HYBRID:o={...W,...e}}o.pieceLength??=w(t.reduce(((t,e)=>t+e.size),0),o.blockLength);let{addCreatedBy:i,addCreationDate:s,blockLength:u,comment:a,isPrivate:h,name:m,pieceLength:b}=o;if(o.type!==K.V1&&b<u)throw new Error(`piece length ${b} is smaller than block length ${u}`);if(0!=(b&b-1))throw new Error(`piece length ${b} is not a power of 2`);const A=b/u;o.announceList=p(o.announceList),void 0===o.announce&&void 0!==o.announceList&&(o.announce=o.announceList[0][0]);const{announce:v,announceList:E}=o,R={...v&&{announce:v},...E&&{"announce-list":E},...a&&{comment:a},...i&&{"created by":"torrefy v2.0.2"},...s&&{"creation date":Date.now()/1e3>>0}};let U,S,B=0,T=t.reduce(((t,e)=>t+Math.ceil(e.size/b)),0);if(o.type===K.V1){const{addPaddingFiles:e,sortFiles:n}=o;let r,i;if(n){const{fileTree:e,fileNodeMap:n,commonDir:r}=c(t);t=[...e].map((t=>n.get(t))),i=r}else i=d(t);if(o.name=m=g(m,i,t),e){const e=t.length-1;r=_(t.map((async(t,n)=>L(t.stream(),{padding:n!==e})))).stream,t=y(t,b,i)}else{T=Math.ceil(t.reduce(((t,e)=>t+e.size),0)/b);const{stream:e}=_(t.map((t=>Promise.resolve(t.stream()))));r=L(e)}U={...R,info:{...t.length>1?{files:t.map((t=>{const e=(t.webkitRelativePath||t.name).split("/");return void 0!==i&&e.shift(),{...t.padding&&{attr:"p"},length:t.size,path:e}}))}:{length:t[0].size},name:m,"piece length":b,pieces:await new Response(r).arrayBuffer(),...h&&{private:1}}}}else if(o.type===K.V2){const{metaVersion:e}=o,{fileTree:n,fileNodeMap:r,commonDir:i}=c(t),s=[...n];t=s.map((t=>r.get(t)));const u=new Map;o.name=m=g(m,i,t),await Promise.all(s.map((async(e,n)=>{const r=t[n];await k(e,r,r.stream(),u)}))),U={...R,info:{"file tree":n,"meta version":e,name:m,"piece length":b,...h&&{private:1}},...u.size>0&&{"piece layers":u}}}else{if(o.type!==K.HYBRID)throw new Error("torrent type is not supported");{const{metaVersion:e}=o,{fileTree:n,fileNodeMap:r,commonDir:i}=c(t),s=[...n];t=s.map((t=>r.get(t)));const u=new Map;o.name=m=g(m,i,t),T*=2;const a=t.length-1,f=[];await Promise.all(s.map((async(e,n)=>{const r=t[n],[o,i]=r.stream().tee();f.push(Promise.resolve(L(o,{padding:n!==a}))),await k(e,r,i,u)})));const l=_(f).stream;t=y(t,b,i),U={...R,info:{"file tree":n,...t.length>1?{files:t.map((t=>{const e=(t.webkitRelativePath||t.name).split("/");return void 0!==i&&e.shift(),{...t.padding&&{attr:"p"},length:t.size,path:e}}))}:{length:t[0].size},"meta version":e,name:m,"piece length":b,pieces:await new Response(l).arrayBuffer(),...h&&{private:1}},...u.size>0&&{"piece layers":u}}}}return U;async function k(t,e,r,o){const[i,s]=function(t){const e=t.pipeThrough(F(u)).pipeThrough(function(){let t=0,e=[];return new TransformStream({transform:async(r,o)=>{let i;++t;try{i=new Uint8Array(await crypto.subtle.digest("SHA-256",r))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,673)),e=new t("SHA-256","UINT8ARRAY");e.update(r),i=e.getHash("UINT8ARRAY")}e.push(i),e.length===A&&(o.enqueue(e),e=[])},flush:async n=>{if(0===t)return;let r=0;if(t<A)r=l(t)-t;else{const e=t%A;e>0&&(r=A-e)}if(r>0)for(let t=0;t<r;++t)e.push(X);e.length>0&&n.enqueue(e)}})}()).pipeThrough(C(!0)),[r,o]=e.tee();return[o.pipeThrough(I()).pipeThrough(C()),r]}(r),a=new Response(i).arrayBuffer();if(e.size>b){const t=new Response(s).arrayBuffer();o.set(await a,await t)}e.size>0&&(t[""]["pieces root"]=await a)}function L(t,e={padding:!1}){return t.pipeThrough(F(b,{padding:e.padding})).pipeThrough(function(t=!1){return new TransformStream({transform:async(e,o)=>{let i;try{i=new Uint8Array(await crypto.subtle.digest("SHA-1",e))}catch{const{default:t}=await Promise.resolve().then(n.bind(n,211)),r=new t("SHA-1","UINT8ARRAY");r.update(e),i=r.getHash("UINT8ARRAY")}o.enqueue(i),t&&r(++B,T)}})}(!0))}function F(t,e={padding:!1}){let n=new Uint8Array(t),r=0;return new TransformStream({transform:(e,o)=>{for(;r+e.length>=t;){const i=t-r;n.set(e.subarray(0,i),r),r=0,o.enqueue(new Uint8Array(n)),e=e.subarray(i)}n.set(e,r),r+=e.length},flush:o=>{r>0&&(e.padding?(n.set(new Uint8Array(t-r),r),o.enqueue(n)):o.enqueue(n.subarray(0,r)))}})}function C(t=!1){return new TransformStream({transform:async(e,n)=>{n.enqueue(await f(e)),t&&r(++B,T)}})}function I(){let t=0,e=[];return new TransformStream({transform:n=>{++t,e.push(n)},flush:async n=>{const r=l(t)-t;if(r>0){S??=await f(Array(A).fill(new Uint8Array(32)));for(let t=0;t<r;++t)e.push(S)}n.enqueue(e)}})}}})(),r})()));
{
"name": "torrefy",
"version": "2.0.1",
"version": "2.0.2",
"type": "module",

@@ -23,2 +23,3 @@ "files": [

"http-server": "^14.1.1",
"mocha": "^10.1.0",
"ts-loader": "^9.4.1",

@@ -25,0 +26,0 @@ "tslib": "^2.4.1",

@@ -0,9 +1,17 @@

## This package is still under heavy development. APIs are prone to change. Use with caution!!
<div align="center">
<img width="200" src="https://user-images.githubusercontent.com/10386119/200105371-05832afe-ec19-4373-988c-40c9fa3cf9e7.svg">
<img width="200" src="https://user-images.githubusercontent.com/10386119/200158861-0398b9ce-35f6-4516-a79e-95ed1772b10b.svg">
<h1>torrefy</h1>
<p>
create v1, v2 or hybrid torrents in your browser
An <a href="https://developer.mozilla.org/docs/Web/JavaScript/Guide/Modules">ESM</a> package that uses <a href="https://developer.mozilla.org/docs/Web/API/Streams_API">Web Streams API</a> to create v1, v2 or hybrid torrents in your web browser
</p>
</div>
## Install
```bash
npm i torrefy # or yarn add torrefy
```
## Usage

@@ -14,3 +22,3 @@

```ts
import { create, encode } from "torrefy";
import { create, encode, decode } from "torrefy";

@@ -29,4 +37,10 @@ // create a test file

// consume the readable stream as an array buffer
// tee the readable stream into two readable streams
const [torrentStream1, torrentStream2] = torrentStream.tee();
// consume the first readable stream as an array buffer
const torrentBinary = await new Response(torrentStream).arrayBuffer();
// decode the second readable stream into meta info
const decodedMetaInfo = await decode(torrentStream2);
```

@@ -40,2 +54,3 @@

encode,
decode,
CommonPieceLength,

@@ -89,5 +104,9 @@ TorrentType,

const torrentStream = encode(metaInfo, hooks);
// consume the readable stream as an array buffer
const torrentBinary = await new Response(torrentStream).arrayBuffer();
// tee the readable stream into two readable streams
const [torrentStream1, torrentStream2] = torrentStream.tee();
// consume the first readable stream as an array buffer
const torrentBinary = await new Response(torrentStream1).arrayBuffer();
// get bencoded "info" as an array buffer

@@ -98,2 +117,18 @@ const info = await infoPromise;

const pieces = await piecesPromise;
// decode the second readable stream into meta info
const decodedMetaInfo = await decode(torrentStream2);
```
## Todos
- [x] BDecode implementation
- [ ] Magnet URI scheme (should be trivial)
- [ ] Convert all `makeXXXTransformStream` functional closure states to [`transformer`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream/TransformStream#:~:text=Parameters-,transformer,-Optional) class states (should be trivial)
- [ ] `ArrayKeyedMap` with `ArrayBuffer` keys (use proxy or drop suppport?)
- [ ] Convert typescript `Enum`s to `Union`s (need investigation)
- [ ] Other type related issues (need investigation)
- [ ] Bundleless entry (need investigation)
- [ ] Support other common BEPs (need investigation)
- [ ] Add tests
- [ ] Add demo page
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc