UNPKG

399 kBJavaScriptView Raw
1/*! OpenPGP.js v5.0.0-1 - 2021-03-03 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2const e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:e=>`Symbol(${e})`;function r(){}const n=Number.isNaN||function(e){return e!=e},i=r;function a(e){return"object"==typeof e&&null!==e||"function"==typeof e}function s(e){return e.slice()}function o(e){return!1!==function(e){if("number"!=typeof e)return!1;if(n(e))return!1;if(e<0)return!1;return!0}(e)&&e!==1/0}function c(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function u(e,t,r,n){const i=e[t];if(void 0!==i){if("function"!=typeof i)throw new TypeError(i+" is not a method");switch(r){case 0:return()=>h(i,e,n);case 1:return t=>{const r=[t].concat(n);return h(i,e,r)}}}return()=>b(void 0)}function l(e,t,r){const n=e[t];if(void 0!==n)return c(n,e,r)}function h(e,t,r){try{return b(c(e,t,r))}catch(e){return _(e)}}function d(e){if(n(e=Number(e))||e<0)throw new RangeError("highWaterMark property of a queuing strategy must be non-negative and non-NaN");return e}function f(e){if(void 0===e)return()=>1;if("function"!=typeof e)throw new TypeError("size property of a queuing strategy must be a function");return t=>e(t)}const y=Promise,p=Promise.prototype.then,g=Promise.resolve.bind(y),m=Promise.reject.bind(y);function w(e){return new y(e)}function b(e){return g(e)}function _(e){return m(e)}function v(e,t,r){return p.call(e,t,r)}function k(e,t,r){v(v(e,t,r),void 0,i)}function A(e,t){k(e,t)}function S(e,t){k(e,void 0,t)}function E(e,t,r){return v(e,t,r)}function P(e){v(e,void 0,i)}class x{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(e){const t=this._back;let r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let n=r+1;const i=e._elements,a=i[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),i[r]=void 0,a}forEach(e){let t=this._cursor,r=this._front,n=r._elements;for(;!(t===n.length&&void 0===r._next||t===n.length&&(r=r._next,n=r._elements,t=0,0===n.length));)e(n[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}function K(e,t,r){let n=null;!0===r&&(n=Object.prototype);const i=Object.create(n);return i.value=e,i.done=t,i}function C(e,t){e._forAuthorCode=!0,e._ownerReadableStream=t,t._reader=e,"readable"===t._state?D(e):"closed"===t._state?function(e){D(e),z(e)}(e):I(e,t._storedError)}function U(e,t){return qt(e._ownerReadableStream,t)}function R(e){"readable"===e._ownerReadableStream._state?B(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,t){I(e,t)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function T(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function D(e){e._closedPromise=w((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function I(e,t){D(e),B(e,t)}function B(e,t){P(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function z(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}const O=t("[[CancelSteps]]"),q=t("[[PullSteps]]");function N(e,t=!1){const r=new H(e);return r._forAuthorCode=t,r}function M(e){return w((t,r)=>{const n={_resolve:t,_reject:r};e._reader._readRequests.push(n)})}function L(e,t,r){const n=e._reader;n._readRequests.shift()._resolve(K(t,r,n._forAuthorCode))}function j(e){return e._reader._readRequests.length}function F(e){const t=e._reader;return void 0!==t&&!!W(t)}class H{constructor(e){if(!1===zt(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===Ot(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");C(this,e),this._readRequests=new x}get closed(){return W(this)?this._closedPromise:_(V("closed"))}cancel(e){return W(this)?void 0===this._ownerReadableStream?_(T("cancel")):U(this,e):_(V("cancel"))}read(){return W(this)?void 0===this._ownerReadableStream?_(T("read from")):G(this):_(V("read"))}releaseLock(){if(!W(this))throw V("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");R(this)}}}function W(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function G(e){const t=e._ownerReadableStream;return t._disturbed=!0,"closed"===t._state?b(K(void 0,!0,e._forAuthorCode)):"errored"===t._state?_(t._storedError):t._readableStreamController[q]()}function V(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}let $;"symbol"==typeof t.asyncIterator&&($={[t.asyncIterator](){return this}},Object.defineProperty($,t.asyncIterator,{enumerable:!1}));const Y={next(){if(!1===Z(this))return _(Q("next"));const e=this._asyncIteratorReader;return void 0===e._ownerReadableStream?_(T("iterate")):E(G(e),t=>{const r=t.done;return r&&R(e),K(t.value,r,!0)})},return(e){if(!1===Z(this))return _(Q("next"));const t=this._asyncIteratorReader;if(void 0===t._ownerReadableStream)return _(T("finish iterating"));if(t._readRequests.length>0)return _(new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled"));if(!1===this._preventCancel){const r=U(t,e);return R(t),E(r,()=>K(e,!0,!0))}return R(t),b(K(e,!0,!0))}};function Z(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorReader")}function Q(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}function X(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function J(e,t,r){if(!o(r=Number(r)))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function ee(e){e._queue=new x,e._queueTotalSize=0}void 0!==$&&Object.setPrototypeOf(Y,$),Object.defineProperty(Y,"next",{enumerable:!1}),Object.defineProperty(Y,"return",{enumerable:!1});const te=t("[[AbortSteps]]"),re=t("[[ErrorSteps]]");class ne{constructor(e={},t={}){ae(this);const r=t.size;let n=t.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");const i=f(r);void 0===n&&(n=1),n=d(n),function(e,t,r,n){const i=Object.create(Ae.prototype);const a=u(t,"write",1,[i]),s=u(t,"close",0,[]),o=u(t,"abort",1,[]);Se(e,i,(function(){return l(t,"start",[i])}),a,s,o,r,n)}(this,e,n,i)}get locked(){if(!1===se(this))throw Re("locked");return oe(this)}abort(e){return!1===se(this)?_(Re("abort")):!0===oe(this)?_(new TypeError("Cannot abort a stream that already has a writer")):ce(this,e)}close(){return!1===se(this)?_(Re("close")):!0===oe(this)?_(new TypeError("Cannot close a stream that already has a writer")):!0===fe(this)?_(new TypeError("Cannot close an already-closing stream")):ue(this)}getWriter(){if(!1===se(this))throw Re("getWriter");return ie(this)}}function ie(e){return new ge(e)}function ae(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new x,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function se(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function oe(e){return void 0!==e._writer}function ce(e,t){const r=e._state;if("closed"===r||"errored"===r)return b(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let n=!1;"erroring"===r&&(n=!0,t=void 0);const i=w((r,i)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:i,_reason:t,_wasAlreadyErroring:n}});return e._pendingAbortRequest._promise=i,!1===n&&he(e,t),i}function ue(e){const t=e._state;if("closed"===t||"errored"===t)return _(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=w((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n}),n=e._writer;var i;return void 0!==n&&!0===e._backpressure&&"writable"===t&&je(n),J(i=e._writableStreamController,"close",0),xe(i),r}function le(e,t){"writable"!==e._state?de(e):he(e,t)}function he(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&_e(n,t),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===r._started&&de(e)}function de(e){e._state="errored",e._writableStreamController[re]();const t=e._storedError;if(e._writeRequests.forEach(e=>{e._reject(t)}),e._writeRequests=new x,void 0===e._pendingAbortRequest)return void ye(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,!0===r._wasAlreadyErroring)return r._reject(t),void ye(e);k(e._writableStreamController[te](r._reason),()=>{r._resolve(),ye(e)},t=>{r._reject(t),ye(e)})}function fe(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function ye(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&ze(t,e._storedError)}function pe(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(!0===t?function(e){qe(e)}(r):je(r)),e._backpressure=t}class ge{constructor(e){if(!1===se(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===oe(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!1===fe(e)&&!0===e._backpressure?qe(this):Me(this),Ie(this);else if("erroring"===t)Ne(this,e._storedError),Ie(this);else if("closed"===t)Me(this),Ie(r=this),Oe(r);else{const t=e._storedError;Ne(this,t),Be(this,t)}var r}get closed(){return!1===me(this)?_(Te("closed")):this._closedPromise}get desiredSize(){if(!1===me(this))throw Te("desiredSize");if(void 0===this._ownerWritableStream)throw De("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;if("errored"===r||"erroring"===r)return null;if("closed"===r)return 0;return Pe(t._writableStreamController)}(this)}get ready(){return!1===me(this)?_(Te("ready")):this._readyPromise}abort(e){return!1===me(this)?_(Te("abort")):void 0===this._ownerWritableStream?_(De("abort")):function(e,t){return ce(e._ownerWritableStream,t)}(this,e)}close(){if(!1===me(this))return _(Te("close"));const e=this._ownerWritableStream;return void 0===e?_(De("close")):!0===fe(e)?_(new TypeError("Cannot close an already-closing stream")):we(this)}releaseLock(){if(!1===me(this))throw Te("releaseLock");void 0!==this._ownerWritableStream&&ve(this)}write(e){return!1===me(this)?_(Te("write")):void 0===this._ownerWritableStream?_(De("write to")):ke(this,e)}}function me(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function we(e){return ue(e._ownerWritableStream)}function be(e,t){"pending"===e._closedPromiseState?ze(e,t):function(e,t){Be(e,t)}(e,t)}function _e(e,t){"pending"===e._readyPromiseState?Le(e,t):function(e,t){Ne(e,t)}(e,t)}function ve(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");_e(e,r),be(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function ke(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,i=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Ke(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return _(De("write to"));const a=r._state;if("errored"===a)return _(r._storedError);if(!0===fe(r)||"closed"===a)return _(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===a)return _(r._storedError);const s=function(e){return w((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)})}(r);return function(e,t,r){const n={chunk:t};try{J(e,n,r)}catch(t){return void Ke(e,t)}const i=e._controlledWritableStream;if(!1===fe(i)&&"writable"===i._state){const t=Ce(e);pe(i,t)}xe(e)}(n,t,i),s}class Ae{constructor(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}error(e){if(!1===function(e){if(!a(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream"))return!1;return!0}(this))throw new TypeError("WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController");"writable"===this._controlledWritableStream._state&&Ue(this,e)}[te](e){const t=this._abortAlgorithm(e);return Ee(this),t}[re](){ee(this)}}function Se(e,t,r,n,i,a,s,o){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,ee(t),t._started=!1,t._strategySizeAlgorithm=o,t._strategyHWM=s,t._writeAlgorithm=n,t._closeAlgorithm=i,t._abortAlgorithm=a;const c=Ce(t);pe(e,c),k(b(r()),()=>{t._started=!0,xe(t)},r=>{t._started=!0,le(e,r)})}function Ee(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Pe(e){return e._strategyHWM-e._queueTotalSize}function xe(e){const t=e._controlledWritableStream;if(!1===e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void de(t);if(0===e._queue.length)return;const r=e._queue.peek().value;"close"===r?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),X(e);const r=e._closeAlgorithm();Ee(e),k(r,()=>{!function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&Oe(t)}(t)},e=>{!function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),le(e,t)}(t,e)})}(e):function(e,t){const r=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(r),k(e._writeAlgorithm(t),()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(X(e),!1===fe(r)&&"writable"===t){const t=Ce(e);pe(r,t)}xe(e)},t=>{"writable"===r._state&&Ee(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,le(e,t)}(r,t)})}(e,r.chunk)}function Ke(e,t){"writable"===e._controlledWritableStream._state&&Ue(e,t)}function Ce(e){return Pe(e)<=0}function Ue(e,t){const r=e._controlledWritableStream;Ee(e),he(r,t)}function Re(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function Te(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function De(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Ie(e){e._closedPromise=w((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function Be(e,t){Ie(e),ze(e,t)}function ze(e,t){P(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function Oe(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}function qe(e){e._readyPromise=w((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function Ne(e,t){qe(e),Le(e,t)}function Me(e){qe(e),je(e)}function Le(e,t){P(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function je(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}function Fe(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}const He="undefined"!=typeof DOMException?DOMException:void 0;const We=function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;try{return new e,!0}catch(e){return!1}}(He)?He:function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return Object.defineProperty(e.prototype=Object.create(Error.prototype),"constructor",{value:e,writable:!0,configurable:!0}),e}();function Ge(e,t,n,i,a,s){const o=N(e),c=ie(t);e._disturbed=!0;let u=!1,l=b(void 0);return w((h,d)=>{let f;if(void 0!==s){if(f=()=>{const r=new We("Aborted","AbortError"),n=[];!1===i&&n.push(()=>"writable"===t._state?ce(t,r):b(void 0)),!1===a&&n.push(()=>"readable"===e._state?qt(e,r):b(void 0)),g(()=>Promise.all(n.map(e=>e())),!0,r)},!0===s.aborted)return void f();s.addEventListener("abort",f)}if(p(e,o._closedPromise,e=>{!1===i?g(()=>ce(t,e),!0,e):m(!0,e)}),p(t,c._closedPromise,t=>{!1===a?g(()=>qt(e,t),!0,t):m(!0,t)}),function(e,t,r){"closed"===e._state?r():A(t,r)}(e,o._closedPromise,()=>{!1===n?g(()=>function(e){const t=e._ownerWritableStream,r=t._state;return!0===fe(t)||"closed"===r?b(void 0):"errored"===r?_(t._storedError):we(e)}(c)):m()}),!0===fe(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");!1===a?g(()=>qt(e,t),!0,t):m(!0,t)}function y(){const e=l;return v(l,()=>e!==l?y():void 0)}function p(e,t,r){"errored"===e._state?r(e._storedError):S(t,r)}function g(e,r,n){function i(){k(e(),()=>E(r,n),e=>E(!0,e))}!0!==u&&(u=!0,"writable"===t._state&&!1===fe(t)?A(y(),i):i())}function m(e,r){!0!==u&&(u=!0,"writable"===t._state&&!1===fe(t)?A(y(),()=>E(e,r)):E(e,r))}function E(e,t){ve(c),R(o),void 0!==s&&s.removeEventListener("abort",f),e?d(t):h(void 0)}P(w((e,t)=>{!function n(i){i?e():v(!0===u?b(!0):v(c._readyPromise,()=>v(G(o),e=>!0===e.done||(l=v(ke(c,e.value),void 0,r),!1))),n,t)}(!1)}))})}class Ve{constructor(){throw new TypeError}get desiredSize(){if(!1===$e(this))throw it("desiredSize");return tt(this)}close(){if(!1===$e(this))throw it("close");if(!1===rt(this))throw new TypeError("The stream is not in a state that permits close");Xe(this)}enqueue(e){if(!1===$e(this))throw it("enqueue");if(!1===rt(this))throw new TypeError("The stream is not in a state that permits enqueue");return Je(this,e)}error(e){if(!1===$e(this))throw it("error");et(this,e)}[O](e){ee(this);const t=this._cancelAlgorithm(e);return Qe(this),t}[q](){const e=this._controlledReadableStream;if(this._queue.length>0){const t=X(this);return!0===this._closeRequested&&0===this._queue.length?(Qe(this),Nt(e)):Ye(this),b(K(t,!1,e._reader._forAuthorCode))}const t=M(e);return Ye(this),t}}function $e(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function Ye(e){!1!==Ze(e)&&(!0!==e._pulling?(e._pulling=!0,k(e._pullAlgorithm(),()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,Ye(e))},t=>{et(e,t)})):e._pullAgain=!0)}function Ze(e){const t=e._controlledReadableStream;return!1!==rt(e)&&(!1!==e._started&&(!0===Ot(t)&&j(t)>0||tt(e)>0))}function Qe(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Xe(e){const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Qe(e),Nt(t))}function Je(e,t){const r=e._controlledReadableStream;if(!0===Ot(r)&&j(r)>0)L(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw et(e,t),t}try{J(e,t,r)}catch(t){throw et(e,t),t}}Ye(e)}function et(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(ee(e),Qe(e),Mt(r,t))}function tt(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function rt(e){const t=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===t}function nt(e,t,r,n,i,a,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,ee(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=s,t._strategyHWM=a,t._pullAlgorithm=n,t._cancelAlgorithm=i,e._readableStreamController=t,k(b(r()),()=>{t._started=!0,Ye(t)},e=>{et(t,e)})}function it(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}const at=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};class st{constructor(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}get view(){if(!1===ut(this))throw Et("view");return this._view}respond(e){if(!1===ut(this))throw Et("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,function(e,t){if(!1===o(t=Number(t)))throw new RangeError("bytesWritten must be a finite");bt(e,t)}(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!1===ut(this))throw Et("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");e.buffer,function(e,t){const r=e._pendingPullIntos.peek();if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.byteLength!==t.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");r.buffer=t.buffer,bt(e,t.byteLength)}(this._associatedReadableByteStreamController,e)}}class ot{constructor(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}get byobRequest(){if(!1===ct(this))throw Pt("byobRequest");if(void 0===this._byobRequest&&this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek(),t=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),r=Object.create(st.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(r,this,t),this._byobRequest=r}return this._byobRequest}get desiredSize(){if(!1===ct(this))throw Pt("desiredSize");return At(this)}close(){if(!1===ct(this))throw Pt("close");if(!0===this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);!function(e){const t=e._controlledReadableByteStream;if(e._queueTotalSize>0)return void(e._closeRequested=!0);if(e._pendingPullIntos.length>0){if(e._pendingPullIntos.peek().bytesFilled>0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw kt(e,t),t}}vt(e),Nt(t)}(this)}enqueue(e){if(!1===ct(this))throw Pt("enqueue");if(!0===this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);if(!ArrayBuffer.isView(e))throw new TypeError("You can only enqueue array buffer views when using a ReadableByteStreamController");e.buffer,function(e,t){const r=e._controlledReadableByteStream,n=t.buffer,i=t.byteOffset,a=t.byteLength,s=n;if(!0===F(r))if(0===j(r))ft(e,s,i,a);else{const e=new Uint8Array(s,i,a);L(r,e,!1)}else!0===Ct(r)?(ft(e,s,i,a),wt(e)):ft(e,s,i,a);lt(e)}(this,e)}error(e){if(!1===ct(this))throw Pt("error");kt(this,e)}[O](e){if(this._pendingPullIntos.length>0){this._pendingPullIntos.peek().bytesFilled=0}ee(this);const t=this._cancelAlgorithm(e);return vt(this),t}[q](){const e=this._controlledReadableByteStream;if(this._queueTotalSize>0){const t=this._queue.shift();let r;this._queueTotalSize-=t.byteLength,gt(this);try{r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}catch(e){return _(e)}return b(K(r,!1,e._reader._forAuthorCode))}const t=this._autoAllocateChunkSize;if(void 0!==t){let e;try{e=new ArrayBuffer(t)}catch(e){return _(e)}const r={buffer:e,byteOffset:0,byteLength:t,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(r)}const r=M(e);return lt(this),r}}function ct(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function ut(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function lt(e){!1!==function(e){const t=e._controlledReadableByteStream;if("readable"!==t._state)return!1;if(!0===e._closeRequested)return!1;if(!1===e._started)return!1;if(!0===F(t)&&j(t)>0)return!0;if(!0===Ct(t)&&Kt(t)>0)return!0;if(At(e)>0)return!0;return!1}(e)&&(!0!==e._pulling?(e._pulling=!0,k(e._pullAlgorithm(),()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,lt(e))},t=>{kt(e,t)})):e._pullAgain=!0)}function ht(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=dt(t);"default"===t.readerType?L(e,n,r):function(e,t,r){const n=e._reader;n._readIntoRequests.shift()._resolve(K(t,r,n._forAuthorCode))}(e,n,r)}function dt(e){const t=e.bytesFilled,r=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,t/r)}function ft(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function yt(e,t){const r=t.elementSize,n=t.bytesFilled-t.bytesFilled%r,i=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),a=t.bytesFilled+i,s=a-a%r;let o=i,c=!1;s>n&&(o=s-t.bytesFilled,c=!0);const u=e._queue;for(;o>0;){const r=u.peek(),n=Math.min(o,r.byteLength),i=t.byteOffset+t.bytesFilled;l=t.buffer,h=i,d=r.buffer,f=r.byteOffset,y=n,new Uint8Array(l).set(new Uint8Array(d,f,y),h),r.byteLength===n?u.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,pt(e,n,t),o-=n}var l,h,d,f,y;return c}function pt(e,t,r){mt(e),r.bytesFilled+=t}function gt(e){0===e._queueTotalSize&&!0===e._closeRequested?(vt(e),Nt(e._controlledReadableByteStream)):lt(e)}function mt(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function wt(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();!0===yt(e,t)&&(_t(e),ht(e._controlledReadableByteStream,t))}}function bt(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");!function(e,t){t.buffer=t.buffer;const r=e._controlledReadableByteStream;if(!0===Ct(r))for(;Kt(r)>0;){ht(r,_t(e))}}(e,r)}else!function(e,t,r){if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range");if(pt(e,t,r),r.bytesFilled<r.elementSize)return;_t(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled,i=r.buffer.slice(t-n,t);ft(e,i,0,i.byteLength)}r.buffer=r.buffer,r.bytesFilled-=n,ht(e._controlledReadableByteStream,r),wt(e)}(e,t,r);lt(e)}function _t(e){const t=e._pendingPullIntos.shift();return mt(e),t}function vt(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function kt(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(!function(e){mt(e),e._pendingPullIntos=new x}(e),ee(e),vt(e),Mt(r,t))}function At(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function St(e,t,r){const n=Object.create(ot.prototype);const i=u(t,"pull",0,[n]),a=u(t,"cancel",1,[]);let s=t.autoAllocateChunkSize;if(void 0!==s&&(s=Number(s),!1===at(s)||s<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");!function(e,t,r,n,i,a,s){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=void 0,t._queue=t._queueTotalSize=void 0,ee(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=d(a),t._pullAlgorithm=n,t._cancelAlgorithm=i,t._autoAllocateChunkSize=s,t._pendingPullIntos=new x,e._readableStreamController=t,k(b(r()),()=>{t._started=!0,lt(t)},e=>{kt(t,e)})}(e,n,(function(){return l(t,"start",[n])}),i,a,r,s)}function Et(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Pt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function xt(e){return w((t,r)=>{const n={_resolve:t,_reject:r};e._reader._readIntoRequests.push(n)})}function Kt(e){return e._reader._readIntoRequests.length}function Ct(e){const t=e._reader;return void 0!==t&&!!Rt(t)}class Ut{constructor(e){if(!zt(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===ct(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(Ot(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");C(this,e),this._readIntoRequests=new x}get closed(){return Rt(this)?this._closedPromise:_(Tt("closed"))}cancel(e){return Rt(this)?void 0===this._ownerReadableStream?_(T("cancel")):U(this,e):_(Tt("cancel"))}read(e){return Rt(this)?void 0===this._ownerReadableStream?_(T("read from")):ArrayBuffer.isView(e)?(e.buffer,0===e.byteLength?_(new TypeError("view must have non-zero byteLength")):function(e,t){const r=e._ownerReadableStream;if(r._disturbed=!0,"errored"===r._state)return _(r._storedError);return function(e,t){const r=e._controlledReadableByteStream;let n=1;t.constructor!==DataView&&(n=t.constructor.BYTES_PER_ELEMENT);const i=t.constructor,a={buffer:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:n,ctor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(a),xt(r);if("closed"===r._state){return b(K(new i(a.buffer,a.byteOffset,0),!0,r._reader._forAuthorCode))}if(e._queueTotalSize>0){if(!0===yt(e,a)){const t=dt(a);return gt(e),b(K(t,!1,r._reader._forAuthorCode))}if(!0===e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return kt(e,t),_(t)}}e._pendingPullIntos.push(a);const s=xt(r);return lt(e),s}(r._readableStreamController,t)}(this,e)):_(new TypeError("view must be an array buffer view")):_(Tt("read"))}releaseLock(){if(!Rt(this))throw Tt("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");R(this)}}}function Rt(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Tt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}class Dt{constructor(e={},t={}){Bt(this);const r=t.size;let n=t.highWaterMark;const i=e.type;if("bytes"===i+""){if(void 0!==r)throw new RangeError("The strategy for a byte stream cannot have a size function");void 0===n&&(n=0),n=d(n),St(this,e,n)}else{if(void 0!==i)throw new RangeError("Invalid type is specified");{const t=f(r);void 0===n&&(n=1),n=d(n),function(e,t,r,n){const i=Object.create(Ve.prototype),a=u(t,"pull",0,[i]),s=u(t,"cancel",1,[]);nt(e,i,(function(){return l(t,"start",[i])}),a,s,r,n)}(this,e,n,t)}}}get locked(){if(!1===zt(this))throw Lt("locked");return Ot(this)}cancel(e){return!1===zt(this)?_(Lt("cancel")):!0===Ot(this)?_(new TypeError("Cannot cancel a stream that already has a reader")):qt(this,e)}getReader({mode:e}={}){if(!1===zt(this))throw Lt("getReader");if(void 0===e)return N(this,!0);if("byob"===(e+=""))return function(e,t=!1){const r=new Ut(e);return r._forAuthorCode=t,r}(this,!0);throw new RangeError("Invalid mode is specified")}pipeThrough({writable:e,readable:t},{preventClose:r,preventAbort:n,preventCancel:i,signal:a}={}){if(!1===zt(this))throw Lt("pipeThrough");if(!1===se(e))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===zt(t))throw new TypeError("readable argument to pipeThrough must be a ReadableStream");if(r=!!r,n=!!n,i=!!i,void 0!==a&&!Fe(a))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===Ot(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===oe(e))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return P(Ge(this,e,r,n,i,a)),t}pipeTo(e,{preventClose:t,preventAbort:r,preventCancel:n,signal:i}={}){return!1===zt(this)?_(Lt("pipeTo")):!1===se(e)?_(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream")):(t=!!t,r=!!r,n=!!n,void 0===i||Fe(i)?!0===Ot(this)?_(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===oe(e)?_(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Ge(this,e,t,r,n,i):_(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))}tee(){if(!1===zt(this))throw Lt("tee");const e=function(e,t){const r=N(e);let n,i,a,o,c,u=!1,l=!1,h=!1;const d=w(e=>{c=e});function f(){if(!0===u)return b(void 0);return u=!0,P(E(G(r),e=>{if(u=!1,!0===e.done)return!1===l&&Xe(a._readableStreamController),void(!1===h&&Xe(o._readableStreamController));const t=e.value,r=t,n=t;!1===l&&Je(a._readableStreamController,r),!1===h&&Je(o._readableStreamController,n)})),b(void 0)}function y(){}return a=It(y,f,(function(t){if(l=!0,n=t,!0===h){const t=s([n,i]),r=qt(e,t);c(r)}return d})),o=It(y,f,(function(t){if(h=!0,i=t,!0===l){const t=s([n,i]),r=qt(e,t);c(r)}return d})),S(r._closedPromise,e=>{et(a._readableStreamController,e),et(o._readableStreamController,e)}),[a,o]}(this);return s(e)}getIterator({preventCancel:e=!1}={}){if(!1===zt(this))throw Lt("getIterator");return function(e,t=!1){const r=N(e),n=Object.create(Y);return n._asyncIteratorReader=r,n._preventCancel=!!t,n}(this,e)}}function It(e,t,r,n=1,i=(()=>1)){const a=Object.create(Dt.prototype);return Bt(a),nt(a,Object.create(Ve.prototype),e,t,r,n,i),a}function Bt(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function zt(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function Ot(e){return void 0!==e._reader}function qt(e,t){if(e._disturbed=!0,"closed"===e._state)return b(void 0);if("errored"===e._state)return _(e._storedError);return Nt(e),E(e._readableStreamController[O](t),r)}function Nt(e){e._state="closed";const t=e._reader;void 0!==t&&(W(t)&&(t._readRequests.forEach(e=>{e._resolve(K(void 0,!0,t._forAuthorCode))}),t._readRequests=new x),z(t))}function Mt(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(W(r)?(r._readRequests.forEach(e=>{e._reject(t)}),r._readRequests=new x):(r._readIntoRequests.forEach(e=>{e._reject(t)}),r._readIntoRequests=new x),B(r,t))}function Lt(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}"symbol"==typeof t.asyncIterator&&Object.defineProperty(Dt.prototype,t.asyncIterator,{value:Dt.prototype.getIterator,enumerable:!1,writable:!0,configurable:!0});function jt(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function Ft(e,t){et(e._readable._readableStreamController,t),Ht(e,t)}function Ht(e,t){$t(e._transformStreamController),Ke(e._writable._writableStreamController,t),!0===e._backpressure&&Wt(e,!1)}function Wt(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=w(t=>{e._backpressureChangePromise_resolve=t}),e._backpressure=t}class Gt{constructor(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}get desiredSize(){if(!1===Vt(this))throw Qt("desiredSize");return tt(this._controlledTransformStream._readable._readableStreamController)}enqueue(e){if(!1===Vt(this))throw Qt("enqueue");Yt(this,e)}error(e){if(!1===Vt(this))throw Qt("error");var t;t=e,Ft(this._controlledTransformStream,t)}terminate(){if(!1===Vt(this))throw Qt("terminate");!function(e){const t=e._controlledTransformStream,r=t._readable._readableStreamController;!0===rt(r)&&Xe(r);Ht(t,new TypeError("TransformStream terminated"))}(this)}}function Vt(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function $t(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Yt(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!1===rt(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{Je(n,t)}catch(e){throw Ht(r,e),r._readable._storedError}(function(e){return!0!==Ze(e)})(n)!==r._backpressure&&Wt(r,!0)}function Zt(e,t){return E(e._transformAlgorithm(t),void 0,t=>{throw Ft(e._controlledTransformStream,t),t})}function Qt(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function Xt(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}
3/*! *****************************************************************************
4Copyright (c) Microsoft Corporation. All rights reserved.
5Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6this file except in compliance with the License. You may obtain a copy of the
7License at http://www.apache.org/licenses/LICENSE-2.0
8
9THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
11WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
12MERCHANTABLITY OR NON-INFRINGEMENT.
13
14See the Apache Version 2.0 License for specific language governing permissions
15and limitations under the License.
16***************************************************************************** */var Jt=function(e,t){return(Jt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function er(e,t){function r(){this.constructor=e}Jt(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function tr(e){if(!e)throw new TypeError("Assertion failed")}function rr(){}function nr(e){return("object"==typeof(t=e)&&null!==t||"function"==typeof t)&&"function"==typeof e.getReader;var t}function ir(e){try{return e.getReader({mode:"byob"}).releaseLock(),!0}catch(e){return!1}}function ar(e){tr(function(e){return!!function(e){if("function"!=typeof e)return!1;var t=!1;try{new e({start:function(){t=!0}})}catch(e){}return t}(e)&&!!nr(new e)}(e));var t=function(e){try{return new e({type:"bytes"}),!0}catch(e){return!1}}(e);return function(r,n){var i=(void 0===n?{}:n).type;if("bytes"!==(i=sr(i))||t||(i=void 0),r.constructor===e&&("bytes"!==i||ir(r)))return r;var a=function(e,t){var r,n=(void 0===t?{}:t).type;tr(nr(e)),tr(!1===e.locked),r="bytes"===(n=sr(n))?new lr(e):new cr(e);return r}(r,{type:i});return new e(a)}}function sr(e){var t=e+"";if("bytes"===t)return t;if(void 0===e)return e;throw new RangeError("Invalid type is specified")}var or=function(){function e(e){this._underlyingReader=void 0,this._readerMode=void 0,this._readableStreamController=void 0,this._pendingRead=void 0,this._underlyingStream=e,this._attachDefaultReader()}return e.prototype.start=function(e){this._readableStreamController=e},e.prototype.cancel=function(e){return tr(void 0!==this._underlyingReader),this._underlyingReader.cancel(e)},e.prototype._attachDefaultReader=function(){if("default"!==this._readerMode){this._detachReader();var e=this._underlyingStream.getReader();this._readerMode="default",this._attachReader(e)}},e.prototype._attachReader=function(e){var t=this;tr(void 0===this._underlyingReader),this._underlyingReader=e;var r=this._underlyingReader.closed;r&&r.then((function(){return t._finishPendingRead()})).then((function(){e===t._underlyingReader&&t._readableStreamController.close()}),(function(r){e===t._underlyingReader&&t._readableStreamController.error(r)})).catch(rr)},e.prototype._detachReader=function(){void 0!==this._underlyingReader&&(this._underlyingReader.releaseLock(),this._underlyingReader=void 0,this._readerMode=void 0)},e.prototype._pullWithDefaultReader=function(){var e=this;this._attachDefaultReader();var t=this._underlyingReader.read().then((function(t){var r=e._readableStreamController;t.done?e._tryClose():r.enqueue(t.value)}));return this._setPendingRead(t),t},e.prototype._tryClose=function(){try{this._readableStreamController.close()}catch(e){}},e.prototype._setPendingRead=function(e){var t,r=this,n=function(){r._pendingRead===t&&(r._pendingRead=void 0)};this._pendingRead=t=e.then(n,n)},e.prototype._finishPendingRead=function(){var e=this;if(this._pendingRead){var t=function(){return e._finishPendingRead()};return this._pendingRead.then(t,t)}},e}(),cr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return er(t,e),t.prototype.pull=function(){return this._pullWithDefaultReader()},t}(or);function ur(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var lr=function(e){function t(t){var r=this,n=ir(t);return(r=e.call(this,t)||this)._supportsByob=n,r}return er(t,e),Object.defineProperty(t.prototype,"type",{get:function(){return"bytes"},enumerable:!0,configurable:!0}),t.prototype._attachByobReader=function(){if("byob"!==this._readerMode){tr(this._supportsByob),this._detachReader();var e=this._underlyingStream.getReader({mode:"byob"});this._readerMode="byob",this._attachReader(e)}},t.prototype.pull=function(){if(this._supportsByob){var e=this._readableStreamController.byobRequest;if(void 0!==e)return this._pullWithByobRequest(e)}return this._pullWithDefaultReader()},t.prototype._pullWithByobRequest=function(e){var t=this;this._attachByobReader();var r=new Uint8Array(e.view.byteLength),n=this._underlyingReader.read(r).then((function(r){var n,i,a;t._readableStreamController,r.done?(t._tryClose(),e.respond(0)):(n=r.value,i=e.view,a=ur(n),ur(i).set(a,0),e.respond(r.value.byteLength))}));return this._setPendingRead(n),n},t}(or);const hr="object"==typeof e.process&&"object"==typeof e.process.versions,dr=hr&&void 0;function fr(t){return e.ReadableStream&&e.ReadableStream.prototype.isPrototypeOf(t)?"web":Fr.ReadableStream.prototype.isPrototypeOf(t)?"ponyfill":!(!dr||!dr.prototype.isPrototypeOf(t))&&"node"}function yr(e){return Uint8Array.prototype.isPrototypeOf(e)}function pr(e){if(1===e.length)return e[0];let t=0;for(let r=0;r<e.length;r++){if(!yr(e[r]))throw Error("concatUint8Array: Data must be in the form of a Uint8Array");t+=e[r].length}const r=new Uint8Array(t);let n=0;return e.forEach((function(e){r.set(e,n),n+=e.length})),r}const gr=hr&&void 0,mr=hr&&void 0;let wr,br;if(mr){wr=function(e){return new Fr.ReadableStream({start(t){e.pause(),e.on("data",r=>{gr.isBuffer(r)&&(r=new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),t.enqueue(r),e.pause()}),e.on("end",()=>t.close()),e.on("error",e=>t.error(e))},pull(){e.resume()},cancel(t){if(e.pause(),e.cancel)return e.cancel(t)}})};class e extends mr{constructor(e,t){super(t),this._webStream=e,this._reader=Fr.getReader(e),this._reading=!1,this._doneReadingPromise=Promise.resolve(),this._cancelling=!1}_read(e){if(this._reading||this._cancelling)return;this._reading=!0;this._doneReadingPromise=(async()=>{try{for(;;){const{done:e,value:t}=await this._reader.read();if(e){this.push(null);break}if(!this.push(t)||this._cancelling){this._reading=!1;break}}}catch(e){this.emit("error",e)}})()}async cancel(e){return this._cancelling=!0,await this._doneReadingPromise,this._reader.releaseLock(),this._webStream.cancel(e)}}br=function(t){return new e(t)}}const _r=new WeakSet,vr=Symbol("externalBuffer");function kr(e){this.stream=e,e[vr]&&(this[vr]=e[vr].slice());let t=Fr.isStream(e);if("node"===t&&(e=Fr.nodeToWeb(e)),t){const t=e.getReader();return this._read=t.read.bind(t),void(this._releaseLock=()=>{t.closed.catch((function(){})),t.releaseLock()})}let r=!1;this._read=async()=>r||_r.has(e)?{value:void 0,done:!0}:(r=!0,{value:e,done:!1}),this._releaseLock=()=>{if(r)try{_r.add(e)}catch(e){}}}kr.prototype.read=async function(){if(this[vr]&&this[vr].length){return{done:!1,value:this[vr].shift()}}return this._read()},kr.prototype.releaseLock=function(){this[vr]&&(this.stream[vr]=this[vr]),this._releaseLock()},kr.prototype.readLine=async function(){let e,t=[];for(;!e;){let{done:r,value:n}=await this.read();if(n+="",r)return t.length?Fr.concat(t):void 0;const i=n.indexOf("\n")+1;i&&(e=Fr.concat(t.concat(n.substr(0,i))),t=[]),i!==n.length&&t.push(n.substr(i))}return this.unshift(...t),e},kr.prototype.readByte=async function(){const{done:e,value:t}=await this.read();if(e)return;const r=t[0];return this.unshift(Fr.slice(t,1)),r},kr.prototype.readBytes=async function(e){const t=[];let r=0;for(;;){const{done:n,value:i}=await this.read();if(n)return t.