!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).WebStreamsPolyfill={})}(this,(function(e){"use strict";const t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:e=>`Symbol(${e})`;function r(){}const o="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0,n=r;function a(e){return"object"==typeof e&&null!==e||"function"==typeof e}const i=r,l=Promise,s=Promise.prototype.then,u=Promise.resolve.bind(l),d=Promise.reject.bind(l);function c(e){return new l(e)}function f(e){return u(e)}function b(e){return d(e)}function _(e,t,r){return s.call(e,t,r)}function h(e,t,r){_(_(e,t,r),void 0,i)}function m(e,t){h(e,t)}function p(e,t){h(e,void 0,t)}function y(e,t,r){return _(e,t,r)}function g(e){_(e,void 0,i)}const S=(()=>{const e=o&&o.queueMicrotask;if("function"==typeof e)return e;const t=f(void 0);return e=>_(t,e)})();function v(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function w(e,t,r){try{return f(v(e,t,r))}catch(e){return b(e)}}const R=16384;class T{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;n(void 0===t._next),16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){n(this._size>0);const e=this._front;let t=e;const r=this._cursor;let o=r+1;const a=e._elements,i=a[r];return o===R&&(n(a.length===R),n(void 0!==e._next),t=e._next,o=0),--this._size,this._cursor=o,e!==t&&(this._front=t),a[r]=void 0,i}forEach(e){let t=this._cursor,r=this._front,o=r._elements;for(;!(t===o.length&&void 0===r._next||t===o.length&&(n(void 0!==r._next),r=r._next,o=r._elements,t=0,0===o.length));)e(o[t]),++t}peek(){n(this._size>0);const e=this._front,t=this._cursor;return e._elements[t]}}function C(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?W(e):"closed"===t._state?function(e){W(e),k(e)}(e):(n("errored"===t._state),O(e,t._storedError))}function q(e,t){return pr(e._ownerReadableStream,t)}function P(e){n(void 0!==e._ownerReadableStream),n(e._ownerReadableStream._reader===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){n(void 0===e._closedPromise_resolve),n(void 0===e._closedPromise_reject),O(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 E(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function W(e){e._closedPromise=c(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function O(e,t){W(e),B(e,t)}function B(e,t){void 0!==e._closedPromise_reject&&(g(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function k(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const j=t("[[AbortSteps]]"),A=t("[[ErrorSteps]]"),z=t("[[CancelSteps]]"),F=t("[[PullSteps]]"),I=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},D=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function L(e,t){if(void 0!==e&&("object"!=typeof(r=e)&&"function"!=typeof r))throw new TypeError(`${t} is not an object.`);var r}function $(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function M(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function Q(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function Y(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function x(e){return Number(e)}function N(e){return 0===e?0:e}function H(e,t){const r=Number.MAX_SAFE_INTEGER;let o=Number(e);if(o=N(o),!I(o))throw new TypeError(`${t} is not a finite number`);if(o=function(e){return N(D(e))}(o),o<0||o>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return I(o)&&0!==o?o:0}function V(e,t){if(!hr(e))throw new TypeError(`${t} is not a ReadableStream.`)}function U(e){return new ReadableStreamDefaultReader(e)}function G(e,t){n(Z(e._reader)),n("readable"===e._state),e._reader._readRequests.push(t)}function X(e,t,r){const o=e._reader;n(o._readRequests.length>0);const a=o._readRequests.shift();r?a._closeSteps():a._chunkSteps(t)}function J(e){return e._reader._readRequests.length}function K(e){const t=e._reader;return void 0!==t&&!!Z(t)}class ReadableStreamDefaultReader{constructor(e){if(Q(e,1,"ReadableStreamDefaultReader"),V(e,"First parameter"),mr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");C(this,e),this._readRequests=new T}get closed(){return Z(this)?this._closedPromise:b(te("closed"))}cancel(e){return Z(this)?void 0===this._ownerReadableStream?b(E("cancel")):q(this,e):b(te("cancel"))}read(){if(!Z(this))return b(te("read"));if(void 0===this._ownerReadableStream)return b(E("read from"));let e,t;const r=c(((r,o)=>{e=r,t=o}));return ee(this,{_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)}),r}releaseLock(){if(!Z(this))throw te("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");P(this)}}}function Z(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof ReadableStreamDefaultReader)}function ee(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):(n("readable"===r._state),r._readableStreamController[F](t))}function te(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}let re;Object.defineProperties(ReadableStreamDefaultReader.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(ReadableStreamDefaultReader.prototype,t.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0}),"symbol"==typeof t.asyncIterator&&(re={[t.asyncIterator](){return this}},Object.defineProperty(re,t.asyncIterator,{enumerable:!1}));class oe{constructor(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}next(){const e=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?y(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?y(this._ongoingPromise,t,t):t()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader;if(void 0===e._ownerReadableStream)return b(E("iterate"));let t,r;const o=c(((e,o)=>{t=e,r=o}));return ee(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,S((()=>t({value:e,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,P(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,P(e),r(t)}}),o}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(void 0===t._ownerReadableStream)return b(E("finish iterating"));if(n(0===t._readRequests.length),!this._preventCancel){const r=q(t,e);return P(t),y(r,(()=>({value:e,done:!0})))}return P(t),f({value:e,done:!0})}}const ne={next(){return ae(this)?this._asyncIteratorImpl.next():b(ie("next"))},return(e){return ae(this)?this._asyncIteratorImpl.return(e):b(ie("return"))}};function ae(e){if(!a(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof oe}catch(e){return!1}}function ie(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}void 0!==re&&Object.setPrototypeOf(ne,re);const le=Number.isNaN||function(e){return e!=e};function se(e){return e.slice()}function ue(e,t,r,o,n){new Uint8Array(e).set(new Uint8Array(r,o,n),t)}function de(e,t,r){if(e.slice)return e.slice(t,r);const o=r-t,n=new ArrayBuffer(o);return ue(n,0,e,t,o),n}function ce(e){const t=de(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function fe(e){n(e._queue.length>0);const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function be(e,t,r){if("number"!=typeof(o=r)||le(o)||o<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var o;e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function _e(e){e._queue=new T,e._queueTotalSize=0}class ReadableStreamBYOBRequest{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!me(this))throw De("view");return this._view}respond(e){if(!me(this))throw De("respond");if(Q(e,1,"respond"),e=H(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,n(this._view.byteLength>0),n(this._view.buffer.byteLength>0),ze(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!me(this))throw De("respondWithNewView");if(Q(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");e.buffer,Fe(this._associatedReadableByteStreamController,e)}}Object.defineProperties(ReadableStreamBYOBRequest.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(ReadableStreamBYOBRequest.prototype,t.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class ReadableByteStreamController{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!he(this))throw Le("byobRequest");return je(this)}get desiredSize(){if(!he(this))throw Le("desiredSize");return Ae(this)}close(){if(!he(this))throw Le("close");if(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`);Oe(this)}enqueue(e){if(!he(this))throw Le("enqueue");if(Q(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(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`);Be(this,e)}error(e){if(!he(this))throw Le("error");ke(this,e)}[z](e){ye(this),_e(this);const t=this._cancelAlgorithm(e);return We(this),t}[F](e){const t=this._controlledReadableByteStream;if(n(K(t)),this._queueTotalSize>0){n(0===J(t));const r=this._queue.shift();this._queueTotalSize-=r.byteLength,Te(this);const o=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return void e._chunkSteps(o)}const r=this._autoAllocateChunkSize;if(void 0!==r){let t;try{t=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}const o={buffer:t,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}G(t,e),pe(this)}}function he(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof ReadableByteStreamController)}function me(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof ReadableStreamBYOBRequest)}function pe(e){const t=function(e){const t=e._controlledReadableByteStream;if("readable"!==t._state)return!1;if(e._closeRequested)return!1;if(!e._started)return!1;if(K(t)&&J(t)>0)return!0;if(Ye(t)&&Qe(t)>0)return!0;const r=Ae(e);if(r>0)return!0;return!1}(e);if(!t)return;if(e._pulling)return void(e._pullAgain=!0);n(!e._pullAgain),e._pulling=!0;h(e._pullAlgorithm(),(()=>{e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,pe(e))}),(t=>{ke(e,t)}))}function ye(e){Ce(e),e._pendingPullIntos=new T}function ge(e,t){n("errored"!==e._state);let r=!1;"closed"===e._state&&(n(0===t.bytesFilled),r=!0);const o=Se(t);"default"===t.readerType?X(e,o,r):(n("byob"===t.readerType),function(e,t,r){const o=e._reader;n(o._readIntoRequests.length>0);const a=o._readIntoRequests.shift();r?a._closeSteps(t):a._chunkSteps(t)}(e,o,r))}function Se(e){const t=e.bytesFilled,r=e.elementSize;return n(t<=e.byteLength),new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function ve(e,t,r,o){e._queue.push({buffer:t,byteOffset:r,byteLength:o}),e._queueTotalSize+=o}function we(e,t){const r=t.elementSize,o=t.bytesFilled-t.bytesFilled%r,a=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),i=t.bytesFilled+a,l=i-i%r;let s=a,u=!1;l>o&&(s=l-t.bytesFilled,u=!0);const d=e._queue;for(;s>0;){const r=d.peek(),o=Math.min(s,r.byteLength),n=t.byteOffset+t.bytesFilled;ue(t.buffer,n,r.buffer,r.byteOffset,o),r.byteLength===o?d.shift():(r.byteOffset+=o,r.byteLength-=o),e._queueTotalSize-=o,Re(e,o,t),s-=o}return u||(n(0===e._queueTotalSize),n(t.bytesFilled>0),n(t.bytesFilled<t.elementSize)),u}function Re(e,t,r){n(0===e._pendingPullIntos.length||e._pendingPullIntos.peek()===r),n(null===e._byobRequest),r.bytesFilled+=t}function Te(e){n("readable"===e._controlledReadableByteStream._state),0===e._queueTotalSize&&e._closeRequested?(We(e),yr(e._controlledReadableByteStream)):pe(e)}function Ce(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function qe(e){for(n(!e._closeRequested);e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();we(e,t)&&(Ee(e),ge(e._controlledReadableByteStream,t))}}function Pe(e,t){const r=e._pendingPullIntos.peek();n((r.buffer,!0)),Ce(e);"closed"===e._controlledReadableByteStream._state?function(e,t){n(0===t.bytesFilled);const r=e._controlledReadableByteStream;if(Ye(r))for(;Qe(r)>0;)ge(r,Ee(e))}(e,r):function(e,t,r){if(n(r.bytesFilled+t<=r.byteLength),Re(e,t,r),r.bytesFilled<r.elementSize)return;Ee(e);const o=r.bytesFilled%r.elementSize;if(o>0){const t=r.byteOffset+r.bytesFilled,n=de(r.buffer,t-o,t);ve(e,n,0,n.byteLength)}r.bytesFilled-=o,ge(e._controlledReadableByteStream,r),qe(e)}(e,t,r),pe(e)}function Ee(e){n(null===e._byobRequest);return e._pendingPullIntos.shift()}function We(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function Oe(e){const t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{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 ke(e,t),t}}We(e),yr(t)}}function Be(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const o=t.buffer,a=t.byteOffset,i=t.byteLength,l=o;if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();t.buffer,0,t.buffer=t.buffer}if(Ce(e),K(r))if(0===J(r))n(0===e._pendingPullIntos.length),ve(e,l,a,i);else{n(0===e._queue.length),e._pendingPullIntos.length>0&&(n("default"===e._pendingPullIntos.peek().readerType),Ee(e));X(r,new Uint8Array(l,a,i),!1)}else Ye(r)?(ve(e,l,a,i),qe(e)):(n(!mr(r)),ve(e,l,a,i));pe(e)}function ke(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(ye(e),_e(e),We(e),gr(r,t))}function je(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),o=Object.create(ReadableStreamBYOBRequest.prototype);!function(e,t,r){n(he(t)),n((r.buffer,!0)),e._associatedReadableByteStreamController=t,e._view=r}(o,e,r),e._byobRequest=o}return e._byobRequest}function Ae(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function ze(e,t){n(e._pendingPullIntos.length>0);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")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=r.buffer,Pe(e,t)}function Fe(e,t){n(e._pendingPullIntos.length>0),n((t.buffer,!0));const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const o=t.byteLength;r.buffer=t.buffer,Pe(e,o)}function Ie(e,t,r,o,a,i,l){n(void 0===e._readableStreamController),t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,_e(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=o,t._cancelAlgorithm=a,t._autoAllocateChunkSize=l,t._pendingPullIntos=new T,e._readableStreamController=t;h(f(r()),(()=>{t._started=!0,n(!t._pulling),n(!t._pullAgain),pe(t)}),(e=>{ke(t,e)}))}function De(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Le(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function $e(e){return new ReadableStreamBYOBReader(e)}function Me(e,t){n(xe(e._reader)),n("readable"===e._state||"closed"===e._state),e._reader._readIntoRequests.push(t)}function Qe(e){return e._reader._readIntoRequests.length}function Ye(e){const t=e._reader;return void 0!==t&&!!xe(t)}Object.defineProperties(ReadableByteStreamController.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(ReadableByteStreamController.prototype,t.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class ReadableStreamBYOBReader{constructor(e){if(Q(e,1,"ReadableStreamBYOBReader"),V(e,"First parameter"),mr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!he(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");C(this,e),this._readIntoRequests=new T}get closed(){return xe(this)?this._closedPromise:b(He("closed"))}cancel(e){return xe(this)?void 0===this._ownerReadableStream?b(E("cancel")):q(this,e):b(He("cancel"))}read(e){if(!xe(this))return b(He("read"));if(!ArrayBuffer.isView(e))return b(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return b(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return b(new TypeError("view's buffer must have non-zero byteLength"));if(e.buffer,void 0===this._ownerReadableStream)return b(E("read from"));let t,r;const o=c(((e,o)=>{t=e,r=o}));return Ne(this,e,{_chunkSteps:e=>t({value:e,done:!1}),_closeSteps:e=>t({value:e,done:!0}),_errorSteps:e=>r(e)}),o}releaseLock(){if(!xe(this))throw He("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");P(this)}}}function xe(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof ReadableStreamBYOBReader)}function Ne(e,t,r){const o=e._ownerReadableStream;o._disturbed=!0,"errored"===o._state?r._errorSteps(o._storedError):function(e,t,r){const o=e._controlledReadableByteStream;let n=1;t.constructor!==DataView&&(n=t.constructor.BYTES_PER_ELEMENT);const a=t.constructor,i=t.buffer,l={buffer:i,bufferByteLength:i.byteLength,byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:n,viewConstructor:a,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(l),void Me(o,r);if("closed"!==o._state){if(e._queueTotalSize>0){if(we(e,l)){const t=Se(l);return Te(e),void r._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return ke(e,t),void r._errorSteps(t)}}e._pendingPullIntos.push(l),Me(o,r),pe(e)}else{const e=new a(l.buffer,l.byteOffset,0);r._closeSteps(e)}}(o._readableStreamController,t,r)}function He(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function Ve(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(le(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function Ue(e){const{size:t}=e;return t||(()=>1)}function Ge(e,t){L(e,t);const r=null==e?void 0:e.highWaterMark,o=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:x(r),size:void 0===o?void 0:Xe(o,`${t} has member 'size' that`)}}function Xe(e,t){return $(e,t),t=>x(e(t))}function Je(e,t,r){return $(e,r),r=>w(e,t,[r])}function Ke(e,t,r){return $(e,r),()=>w(e,t,[])}function Ze(e,t,r){return $(e,r),r=>v(e,t,[r])}function et(e,t,r){return $(e,r),(r,o)=>w(e,t,[r,o])}function tt(e,t){if(!it(e))throw new TypeError(`${t} is not a WritableStream.`)}function rt(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}Object.defineProperties(ReadableStreamBYOBReader.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(ReadableStreamBYOBReader.prototype,t.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const ot="function"==typeof AbortController;class WritableStream{constructor(e={},t={}){void 0===e?e=null:M(e,"First parameter");const r=Ge(t,"Second parameter"),o=function(e,t){L(e,t);const r=null==e?void 0:e.abort,o=null==e?void 0:e.close,n=null==e?void 0:e.start,a=null==e?void 0:e.type,i=null==e?void 0:e.write;return{abort:void 0===r?void 0:Je(r,e,`${t} has member 'abort' that`),close:void 0===o?void 0:Ke(o,e,`${t} has member 'close' that`),start:void 0===n?void 0:Ze(n,e,`${t} has member 'start' that`),write:void 0===i?void 0:et(i,e,`${t} has member 'write' that`),type:a}}(e,"First parameter");at(this);if(void 0!==o.type)throw new RangeError("Invalid type is specified");const n=Ue(r);!function(e,t,r,o){const n=Object.create(WritableStreamDefaultController.prototype);let a=()=>{},i=()=>f(void 0),l=()=>f(void 0),s=()=>f(void 0);void 0!==t.start&&(a=()=>t.start(n));void 0!==t.write&&(i=e=>t.write(e,n));void 0!==t.close&&(l=()=>t.close());void 0!==t.abort&&(s=e=>t.abort(e));Ct(e,n,a,i,l,s,r,o)}(this,o,Ve(r,1),n)}get locked(){if(!it(this))throw kt("locked");return lt(this)}abort(e){return it(this)?lt(this)?b(new TypeError("Cannot abort a stream that already has a writer")):st(this,e):b(kt("abort"))}close(){return it(this)?lt(this)?b(new TypeError("Cannot close a stream that already has a writer")):bt(this)?b(new TypeError("Cannot close an already-closing stream")):ut(this):b(kt("close"))}getWriter(){if(!it(this))throw kt("getWriter");return nt(this)}}function nt(e){return new WritableStreamDefaultWriter(e)}function at(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new T,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function it(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof WritableStream)}function lt(e){return n(it(e)),void 0!==e._writer}function st(e,t){var r;if("closed"===e._state||"errored"===e._state)return f(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort();const o=e._state;if("closed"===o||"errored"===o)return f(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let n=!1;"erroring"===o&&(n=!0,t=void 0);const a=c(((r,o)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:o,_reason:t,_wasAlreadyErroring:n}}));return e._pendingAbortRequest._promise=a,n||ct(e,t),a}function ut(e){const t=e._state;if("closed"===t||"errored"===t)return b(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));n(!bt(e));const r=c(((t,r)=>{const o={_resolve:t,_reject:r};e._closeRequest=o})),o=e._writer;var a;return void 0!==o&&e._backpressure&&"writable"===t&&xt(o),be(a=e._writableStreamController,Rt,0),Et(a),r}function dt(e,t){"writable"!==e._state?ft(e):ct(e,t)}function ct(e,t){n(void 0===e._storedError),n("writable"===e._state);const r=e._writableStreamController;e._state="erroring",e._storedError=t;const o=e._writer;void 0!==o&&St(o,t),!_t(e)&&r._started&&ft(e)}function ft(e){n("erroring"===e._state),n(!_t(e)),e._state="errored",e._writableStreamController[A]();const t=e._storedError;if(e._writeRequests.forEach((e=>{e._reject(t)})),e._writeRequests=new T,void 0===e._pendingAbortRequest)return void ht(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void ht(e);h(e._writableStreamController[j](r._reason),(()=>{r._resolve(),ht(e)}),(t=>{r._reject(t),ht(e)}))}function bt(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function _t(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}function ht(e){n("errored"===e._state),void 0!==e._closeRequest&&(n(void 0===e._inFlightCloseRequest),e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&Dt(t,e._storedError)}function mt(e,t){n("writable"===e._state),n(!bt(e));const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){n(void 0===e._readyPromise_resolve),n(void 0===e._readyPromise_reject),$t(e)}(r):xt(r)),e._backpressure=t}Object.defineProperties(WritableStream.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(WritableStream.prototype,t.toStringTag,{value:"WritableStream",configurable:!0});class WritableStreamDefaultWriter{constructor(e){if(Q(e,1,"WritableStreamDefaultWriter"),tt(e,"First parameter"),lt(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)!bt(e)&&e._backpressure?$t(this):Qt(this),Ft(this);else if("erroring"===t)Mt(this,e._storedError),Ft(this);else if("closed"===t)Qt(this),Ft(r=this),Lt(r);else{const t=e._storedError;Mt(this,t),It(this,t)}var r}get closed(){return pt(this)?this._closedPromise:b(At("closed"))}get desiredSize(){if(!pt(this))throw At("desiredSize");if(void 0===this._ownerWritableStream)throw zt("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;if("errored"===r||"erroring"===r)return null;if("closed"===r)return 0;return Pt(t._writableStreamController)}(this)}get ready(){return pt(this)?this._readyPromise:b(At("ready"))}abort(e){return pt(this)?void 0===this._ownerWritableStream?b(zt("abort")):function(e,t){return st(e._ownerWritableStream,t)}(this,e):b(At("abort"))}close(){if(!pt(this))return b(At("close"));const e=this._ownerWritableStream;return void 0===e?b(zt("close")):bt(e)?b(new TypeError("Cannot close an already-closing stream")):yt(this)}releaseLock(){if(!pt(this))throw At("releaseLock");const e=this._ownerWritableStream;void 0!==e&&(n(void 0!==e._writer),vt(this))}write(e){return pt(this)?void 0===this._ownerWritableStream?b(zt("write to")):wt(this,e):b(At("write"))}}function pt(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof WritableStreamDefaultWriter)}function yt(e){return ut(e._ownerWritableStream)}function gt(e,t){"pending"===e._closedPromiseState?Dt(e,t):function(e,t){n(void 0===e._closedPromise_resolve),n(void 0===e._closedPromise_reject),n("pending"!==e._closedPromiseState),It(e,t)}(e,t)}function St(e,t){"pending"===e._readyPromiseState?Yt(e,t):function(e,t){n(void 0===e._readyPromise_resolve),n(void 0===e._readyPromise_reject),Mt(e,t)}(e,t)}function vt(e){const t=e._ownerWritableStream;n(t._writer===e);const r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");St(e,r),gt(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function wt(e,t){const r=e._ownerWritableStream,o=r._writableStreamController,a=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Wt(e,t),1}}(o,t);if(r!==e._ownerWritableStream)return b(zt("write to"));const i=r._state;if("errored"===i)return b(r._storedError);if(bt(r)||"closed"===i)return b(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return b(r._storedError);const l=function(e){return n(lt(e)),n("writable"===e._state),c(((t,r)=>{const o={_resolve:t,_reject:r};e._writeRequests.push(o)}))}(r);return function(e,t,r){try{be(e,t,r)}catch(t){return void Wt(e,t)}const o=e._controlledWritableStream;if(!bt(o)&&"writable"===o._state){mt(o,Ot(e))}Et(e)}(o,t,a),l}Object.defineProperties(WritableStreamDefaultWriter.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(WritableStreamDefaultWriter.prototype,t.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Rt={};class WritableStreamDefaultController{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Tt(this))throw jt("abortReason");return this._abortReason}get signal(){if(!Tt(this))throw jt("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e){if(!Tt(this))throw jt("error");"writable"===this._controlledWritableStream._state&&Bt(this,e)}[j](e){const t=this._abortAlgorithm(e);return qt(this),t}[A](){_e(this)}}function Tt(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof WritableStreamDefaultController)}function Ct(e,t,r,o,a,i,l,s){n(it(e)),n(void 0===e._writableStreamController),t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,_e(t),t._abortReason=void 0,t._abortController=function(){if(ot)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=s,t._strategyHWM=l,t._writeAlgorithm=o,t._closeAlgorithm=a,t._abortAlgorithm=i;const u=Ot(t);mt(e,u);h(f(r()),(()=>{n("writable"===e._state||"erroring"===e._state),t._started=!0,Et(t)}),(r=>{n("writable"===e._state||"erroring"===e._state),t._started=!0,dt(e,r)}))}function qt(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Pt(e){return e._strategyHWM-e._queueTotalSize}function Et(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void ft(t);if(0===e._queue.length)return;const r=(n((o=e)._queue.length>0),o._queue.peek().value);var o;r===Rt?function(e){const t=e._controlledWritableStream;(function(e){n(void 0===e._inFlightCloseRequest),n(void 0!==e._closeRequest),e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),fe(e),n(0===e._queue.length);const r=e._closeAlgorithm();qt(e),h(r,(()=>{!function(e){n(void 0!==e._inFlightCloseRequest),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&&Lt(t),n(void 0===e._pendingAbortRequest),n(void 0===e._storedError)}(t)}),(e=>{!function(e,t){n(void 0!==e._inFlightCloseRequest),e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,n("writable"===e._state||"erroring"===e._state),void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),dt(e,t)}(t,e)}))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){n(void 0===e._inFlightWriteRequest),n(0!==e._writeRequests.length),e._inFlightWriteRequest=e._writeRequests.shift()}(r);const o=e._writeAlgorithm(t);h(o,(()=>{!function(e){n(void 0!==e._inFlightWriteRequest),e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(fe(e),!bt(r)&&"writable"===t){const t=Ot(e);mt(r,t)}Et(e)}),(t=>{"writable"===r._state&&qt(e),function(e,t){n(void 0!==e._inFlightWriteRequest),e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,n("writable"===e._state||"erroring"===e._state),dt(e,t)}(r,t)}))}(e,r)}function Wt(e,t){"writable"===e._controlledWritableStream._state&&Bt(e,t)}function Ot(e){return Pt(e)<=0}function Bt(e,t){const r=e._controlledWritableStream;n("writable"===r._state),qt(e),ct(r,t)}function kt(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function jt(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function At(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function zt(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Ft(e){e._closedPromise=c(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"}))}function It(e,t){Ft(e),Dt(e,t)}function Dt(e,t){void 0!==e._closedPromise_reject&&(n("pending"===e._closedPromiseState),g(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function Lt(e){void 0!==e._closedPromise_resolve&&(n("pending"===e._closedPromiseState),e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function $t(e){e._readyPromise=c(((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r})),e._readyPromiseState="pending"}function Mt(e,t){$t(e),Yt(e,t)}function Qt(e){$t(e),xt(e)}function Yt(e,t){void 0!==e._readyPromise_reject&&(g(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function xt(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(WritableStreamDefaultController.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(WritableStreamDefaultController.prototype,t.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const Nt="undefined"!=typeof DOMException?DOMException:void 0;const Ht=function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;try{return new e,!0}catch(e){return!1}}(Nt)?Nt:function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}();function Vt(e,t,o,a,i,l){n(hr(e)),n(it(t)),n(void 0===l||rt(l)),n(!mr(e)),n(!lt(t));const s=U(e),u=nt(t);e._disturbed=!0;let d=!1,y=f(void 0);return c(((n,S)=>{let v;if(void 0!==l){if(v=()=>{const r=new Ht("Aborted","AbortError"),o=[];a||o.push((()=>"writable"===t._state?st(t,r):f(void 0))),i||o.push((()=>"readable"===e._state?pr(e,r):f(void 0))),E((()=>Promise.all(o.map((e=>e())))),!0,r)},l.aborted)return void v();l.addEventListener("abort",v)}var w,R,T;if(q(e,s._closedPromise,(e=>{a?W(!0,e):E((()=>st(t,e)),!0,e)})),q(t,u._closedPromise,(t=>{i?W(!0,t):E((()=>pr(e,t)),!0,t)})),w=e,R=s._closedPromise,T=()=>{o?W():E((()=>function(e){const t=e._ownerWritableStream,r=t._state;return bt(t)||"closed"===r?f(void 0):"errored"===r?b(t._storedError):yt(e)}(u)))},"closed"===w._state?T():m(R,T),bt(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");i?W(!0,t):E((()=>pr(e,t)),!0,t)}function C(){const e=y;return _(y,(()=>e!==y?C():void 0))}function q(e,t,r){"errored"===e._state?r(e._storedError):p(t,r)}function E(e,r,o){function n(){h(e(),(()=>O(r,o)),(e=>O(!0,e)))}d||(d=!0,"writable"!==t._state||bt(t)?n():m(C(),n))}function W(e,r){d||(d=!0,"writable"!==t._state||bt(t)?O(e,r):m(C(),(()=>O(e,r))))}function O(e,t){vt(u),P(s),void 0!==l&&l.removeEventListener("abort",v),e?S(t):n(void 0)}g(c(((e,t)=>{!function o(n){n?e():_(d?f(!0):_(u._readyPromise,(()=>c(((e,t)=>{ee(s,{_chunkSteps:t=>{y=_(wt(u,t),void 0,r),e(!1)},_closeSteps:()=>e(!0),_errorSteps:t})})))),o,t)}(!1)})))}))}class ReadableStreamDefaultController{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Ut(this))throw nr("desiredSize");return tr(this)}close(){if(!Ut(this))throw nr("close");if(!rr(this))throw new TypeError("The stream is not in a state that permits close");Kt(this)}enqueue(e){if(!Ut(this))throw nr("enqueue");if(!rr(this))throw new TypeError("The stream is not in a state that permits enqueue");return Zt(this,e)}error(e){if(!Ut(this))throw nr("error");er(this,e)}[z](e){_e(this);const t=this._cancelAlgorithm(e);return Jt(this),t}[F](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=fe(this);this._closeRequested&&0===this._queue.length?(Jt(this),yr(t)):Gt(this),e._chunkSteps(r)}else G(t,e),Gt(this)}}function Ut(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof ReadableStreamDefaultController)}function Gt(e){if(!Xt(e))return;if(e._pulling)return void(e._pullAgain=!0);n(!e._pullAgain),e._pulling=!0;h(e._pullAlgorithm(),(()=>{e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,Gt(e))}),(t=>{er(e,t)}))}function Xt(e){const t=e._controlledReadableStream;if(!rr(e))return!1;if(!e._started)return!1;if(mr(t)&&J(t)>0)return!0;return tr(e)>0}function Jt(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Kt(e){if(!rr(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Jt(e),yr(t))}function Zt(e,t){if(!rr(e))return;const r=e._controlledReadableStream;if(mr(r)&&J(r)>0)X(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw er(e,t),t}try{be(e,t,r)}catch(t){throw er(e,t),t}}Gt(e)}function er(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(_e(e),Jt(e),gr(r,t))}function tr(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function rr(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function or(e,t,r,o,a,i,l){n(void 0===e._readableStreamController),t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,_e(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=l,t._strategyHWM=i,t._pullAlgorithm=o,t._cancelAlgorithm=a,e._readableStreamController=t;h(f(r()),(()=>{t._started=!0,n(!t._pulling),n(!t._pullAgain),Gt(t)}),(e=>{er(t,e)}))}function nr(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function ar(e,t){return n(hr(e)),he(e._readableStreamController)?function(e){n(hr(e)),n(he(e._readableStreamController));let t,r,o,a,i,l=U(e),s=!1,u=!1,d=!1,b=!1,_=!1;const h=c((e=>{i=e}));function m(e){p(e._closedPromise,(t=>{e===l&&(ke(o._readableStreamController,t),ke(a._readableStreamController,t),b&&_||i(void 0))}))}function y(){xe(l)&&(n(0===l._readIntoRequests.length),P(l),l=U(e),m(l));ee(l,{_chunkSteps:t=>{S((()=>{u=!1,d=!1;const r=t;let n=t;if(!b&&!_)try{n=ce(t)}catch(t){return ke(o._readableStreamController,t),ke(a._readableStreamController,t),void i(pr(e,t))}b||Be(o._readableStreamController,r),_||Be(a._readableStreamController,n),s=!1,u?v():d&&w()}))},_closeSteps:()=>{s=!1,b||Oe(o._readableStreamController),_||Oe(a._readableStreamController),o._readableStreamController._pendingPullIntos.length>0&&ze(o._readableStreamController,0),a._readableStreamController._pendingPullIntos.length>0&&ze(a._readableStreamController,0),b&&_||i(void 0)},_errorSteps:()=>{s=!1}})}function g(t,r){Z(l)&&(n(0===l._readRequests.length),P(l),l=$e(e),m(l));const c=r?a:o,f=r?o:a;Ne(l,t,{_chunkSteps:t=>{S((()=>{u=!1,d=!1;const o=r?_:b;if(r?b:_)o||Fe(c._readableStreamController,t);else{let r;try{r=ce(t)}catch(t){return ke(c._readableStreamController,t),ke(f._readableStreamController,t),void i(pr(e,t))}o||Fe(c._readableStreamController,t),Be(f._readableStreamController,r)}s=!1,u?v():d&&w()}))},_closeSteps:e=>{s=!1;const t=r?_:b,o=r?b:_;t||Oe(c._readableStreamController),o||Oe(f._readableStreamController),void 0!==e&&(n(0===e.byteLength),t||Fe(c._readableStreamController,e),!o&&f._readableStreamController._pendingPullIntos.length>0&&ze(f._readableStreamController,0)),t&&o||i(void 0)},_errorSteps:()=>{s=!1}})}function v(){if(s)return u=!0,f(void 0);s=!0;const e=je(o._readableStreamController);return null===e?y():g(e._view,!1),f(void 0)}function w(){if(s)return d=!0,f(void 0);s=!0;const e=je(a._readableStreamController);return null===e?y():g(e._view,!0),f(void 0)}function R(o){if(b=!0,t=o,_){const o=se([t,r]),n=pr(e,o);i(n)}return h}function T(o){if(_=!0,r=o,b){const o=se([t,r]),n=pr(e,o);i(n)}return h}function C(){}return o=br(C,v,R),a=br(C,w,T),m(l),[o,a]}(e):function(e,t){n(hr(e));const r=U(e);let o,a,i,l,s,u=!1,d=!1,b=!1,_=!1;const h=c((e=>{s=e}));function m(){if(u)return d=!0,f(void 0);u=!0;return ee(r,{_chunkSteps:e=>{S((()=>{d=!1;const t=e,r=e;b||Zt(i._readableStreamController,t),_||Zt(l._readableStreamController,r),u=!1,d&&m()}))},_closeSteps:()=>{u=!1,b||Kt(i._readableStreamController),_||Kt(l._readableStreamController),b&&_||s(void 0)},_errorSteps:()=>{u=!1}}),f(void 0)}function y(t){if(b=!0,o=t,_){const t=se([o,a]),r=pr(e,t);s(r)}return h}function g(t){if(_=!0,a=t,b){const t=se([o,a]),r=pr(e,t);s(r)}return h}function v(){}return i=fr(v,m,y),l=fr(v,m,g),p(r._closedPromise,(e=>{er(i._readableStreamController,e),er(l._readableStreamController,e),b&&_||s(void 0)})),[i,l]}(e)}function ir(e,t,r){return $(e,r),r=>w(e,t,[r])}function lr(e,t,r){return $(e,r),r=>w(e,t,[r])}function sr(e,t,r){return $(e,r),r=>v(e,t,[r])}function ur(e,t){if("bytes"!==(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function dr(e,t){if("byob"!==(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function cr(e,t){L(e,t);const r=null==e?void 0:e.preventAbort,o=null==e?void 0:e.preventCancel,n=null==e?void 0:e.preventClose,a=null==e?void 0:e.signal;return void 0!==a&&function(e,t){if(!rt(e))throw new TypeError(`${t} is not an AbortSignal.`)}(a,`${t} has member 'signal' that`),{preventAbort:Boolean(r),preventCancel:Boolean(o),preventClose:Boolean(n),signal:a}}Object.defineProperties(ReadableStreamDefaultController.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(ReadableStreamDefaultController.prototype,t.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class ReadableStream{constructor(e={},t={}){void 0===e?e=null:M(e,"First parameter");const r=Ge(t,"Second parameter"),o=function(e,t){L(e,t);const r=e,o=null==r?void 0:r.autoAllocateChunkSize,n=null==r?void 0:r.cancel,a=null==r?void 0:r.pull,i=null==r?void 0:r.start,l=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===o?void 0:H(o,`${t} has member 'autoAllocateChunkSize' that`),cancel:void 0===n?void 0:ir(n,r,`${t} has member 'cancel' that`),pull:void 0===a?void 0:lr(a,r,`${t} has member 'pull' that`),start:void 0===i?void 0:sr(i,r,`${t} has member 'start' that`),type:void 0===l?void 0:ur(l,`${t} has member 'type' that`)}}(e,"First parameter");if(_r(this),"bytes"===o.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(e,t,r){const o=Object.create(ReadableByteStreamController.prototype);let n=()=>{},a=()=>f(void 0),i=()=>f(void 0);void 0!==t.start&&(n=()=>t.start(o)),void 0!==t.pull&&(a=()=>t.pull(o)),void 0!==t.cancel&&(i=e=>t.cancel(e));const l=t.autoAllocateChunkSize;if(0===l)throw new TypeError("autoAllocateChunkSize must be greater than 0");Ie(e,o,n,a,i,r,l)}(this,o,Ve(r,0))}else{n(void 0===o.type);const e=Ue(r);!function(e,t,r,o){const n=Object.create(ReadableStreamDefaultController.prototype);let a=()=>{},i=()=>f(void 0),l=()=>f(void 0);void 0!==t.start&&(a=()=>t.start(n)),void 0!==t.pull&&(i=()=>t.pull(n)),void 0!==t.cancel&&(l=e=>t.cancel(e)),or(e,n,a,i,l,r,o)}(this,o,Ve(r,1),e)}}get locked(){if(!hr(this))throw Sr("locked");return mr(this)}cancel(e){return hr(this)?mr(this)?b(new TypeError("Cannot cancel a stream that already has a reader")):pr(this,e):b(Sr("cancel"))}getReader(e){if(!hr(this))throw Sr("getReader");return void 0===function(e,t){L(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:dr(r,`${t} has member 'mode' that`)}}(e,"First parameter").mode?U(this):$e(this)}pipeThrough(e,t={}){if(!hr(this))throw Sr("pipeThrough");Q(e,1,"pipeThrough");const r=function(e,t){L(e,t);const r=null==e?void 0:e.readable;Y(r,"readable","ReadableWritablePair"),V(r,`${t} has member 'readable' that`);const o=null==e?void 0:e.writable;return Y(o,"writable","ReadableWritablePair"),tt(o,`${t} has member 'writable' that`),{readable:r,writable:o}}(e,"First parameter"),o=cr(t,"Second parameter");if(mr(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(lt(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return g(Vt(this,r.writable,o.preventClose,o.preventAbort,o.preventCancel,o.signal)),r.readable}pipeTo(e,t={}){if(!hr(this))return b(Sr("pipeTo"));if(void 0===e)return b("Parameter 1 is required in 'pipeTo'.");if(!it(e))return b(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=cr(t,"Second parameter")}catch(e){return b(e)}return mr(this)?b(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):lt(e)?b(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Vt(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!hr(this))throw Sr("tee");return se(ar(this))}values(e){if(!hr(this))throw Sr("values");return function(e,t){const r=U(e),o=new oe(r,t),n=Object.create(ne);return n._asyncIteratorImpl=o,n}(this,function(e,t){L(e,t);const r=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(r)}}(e,"First parameter").preventCancel)}}function fr(e,t,r,o=1,n=(()=>1)){const a=Object.create(ReadableStream.prototype);_r(a);return or(a,Object.create(ReadableStreamDefaultController.prototype),e,t,r,o,n),a}function br(e,t,r){const o=Object.create(ReadableStream.prototype);_r(o);return Ie(o,Object.create(ReadableByteStreamController.prototype),e,t,r,0,void 0),o}function _r(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function hr(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof ReadableStream)}function mr(e){return n(hr(e)),void 0!==e._reader}function pr(e,t){if(e._disturbed=!0,"closed"===e._state)return f(void 0);if("errored"===e._state)return b(e._storedError);yr(e);const o=e._reader;void 0!==o&&xe(o)&&(o._readIntoRequests.forEach((e=>{e._closeSteps(void 0)})),o._readIntoRequests=new T);return y(e._readableStreamController[z](t),r)}function yr(e){n("readable"===e._state),e._state="closed";const t=e._reader;void 0!==t&&(k(t),Z(t)&&(t._readRequests.forEach((e=>{e._closeSteps()})),t._readRequests=new T))}function gr(e,t){n(hr(e)),n("readable"===e._state),e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(B(r,t),Z(r)?(r._readRequests.forEach((e=>{e._errorSteps(t)})),r._readRequests=new T):(n(xe(r)),r._readIntoRequests.forEach((e=>{e._errorSteps(t)})),r._readIntoRequests=new T))}function Sr(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function vr(e,t){L(e,t);const r=null==e?void 0:e.highWaterMark;return Y(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:x(r)}}t.asyncIterator,Object.defineProperties(ReadableStream.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(ReadableStream.prototype,t.toStringTag,{value:"ReadableStream",configurable:!0}),"symbol"==typeof t.asyncIterator&&Object.defineProperty(ReadableStream.prototype,t.asyncIterator,{value:ReadableStream.prototype.values,writable:!0,configurable:!0});const wr=e=>e.byteLength;try{Object.defineProperty(wr,"name",{value:"size",configurable:!0})}catch(e){}class ByteLengthQueuingStrategy{constructor(e){Q(e,1,"ByteLengthQueuingStrategy"),e=vr(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!Tr(this))throw Rr("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!Tr(this))throw Rr("size");return wr}}function Rr(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function Tr(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof ByteLengthQueuingStrategy)}Object.defineProperties(ByteLengthQueuingStrategy.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(ByteLengthQueuingStrategy.prototype,t.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const Cr=()=>1;try{Object.defineProperty(Cr,"name",{value:"size",configurable:!0})}catch(e){}class CountQueuingStrategy{constructor(e){Q(e,1,"CountQueuingStrategy"),e=vr(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!Pr(this))throw qr("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!Pr(this))throw qr("size");return Cr}}function qr(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function Pr(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof CountQueuingStrategy)}function Er(e,t,r){return $(e,r),r=>w(e,t,[r])}function Wr(e,t,r){return $(e,r),r=>v(e,t,[r])}function Or(e,t,r){return $(e,r),(r,o)=>w(e,t,[r,o])}Object.defineProperties(CountQueuingStrategy.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(CountQueuingStrategy.prototype,t.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class TransformStream{constructor(e={},t={},r={}){void 0===e&&(e=null);const o=Ge(t,"Second parameter"),a=Ge(r,"Third parameter"),i=function(e,t){L(e,t);const r=null==e?void 0:e.flush,o=null==e?void 0:e.readableType,n=null==e?void 0:e.start,a=null==e?void 0:e.transform,i=null==e?void 0:e.writableType;return{flush:void 0===r?void 0:Er(r,e,`${t} has member 'flush' that`),readableType:o,start:void 0===n?void 0:Wr(n,e,`${t} has member 'start' that`),transform:void 0===a?void 0:Or(a,e,`${t} has member 'transform' that`),writableType:i}}(e,"First parameter");if(void 0!==i.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==i.writableType)throw new RangeError("Invalid writableType specified");const l=Ve(a,0),s=Ue(a),u=Ve(o,1),d=Ue(o);let _;!function(e,t,r,o,a,i){function l(){return t}function s(t){return function(e,t){n("writable"===e._writable._state);const r=e._transformStreamController;if(e._backpressure){return y(e._backpressureChangePromise,(()=>{const o=e._writable;if("erroring"===o._state)throw o._storedError;return Dr(r,t)}))}return Dr(r,t)}(e,t)}function u(t){return function(e,t){return kr(e,t),f(void 0)}(e,t)}function d(){return function(e){const t=e._readable,r=e._transformStreamController,o=r._flushAlgorithm();return Fr(r),y(o,(()=>{if("errored"===t._state)throw t._storedError;Kt(t._readableStreamController)}),(r=>{throw kr(e,r),t._storedError}))}(e)}function c(){return function(e){return n(e._backpressure),n(void 0!==e._backpressureChangePromise),Ar(e,!1),e._backpressureChangePromise}(e)}function b(t){return jr(e,t),f(void 0)}e._writable=function(e,t,r,o,n=1,a=(()=>1)){const i=Object.create(WritableStream.prototype);return at(i),Ct(i,Object.create(WritableStreamDefaultController.prototype),e,t,r,o,n,a),i}(l,s,d,u,r,o),e._readable=fr(l,c,b,a,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Ar(e,!0),e._transformStreamController=void 0}(this,c((e=>{_=e})),u,d,l,s),function(e,t){const r=Object.create(TransformStreamDefaultController.prototype);let o=e=>{try{return Ir(r,e),f(void 0)}catch(e){return b(e)}},a=()=>f(void 0);void 0!==t.transform&&(o=e=>t.transform(e,r));void 0!==t.flush&&(a=()=>t.flush(r));!function(e,t,r,o){n(Br(e)),n(void 0===e._transformStreamController),t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=o}(e,r,o,a)}(this,i),void 0!==i.start?_(i.start(this._transformStreamController)):_(void 0)}get readable(){if(!Br(this))throw $r("readable");return this._readable}get writable(){if(!Br(this))throw $r("writable");return this._writable}}function Br(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof TransformStream)}function kr(e,t){er(e._readable._readableStreamController,t),jr(e,t)}function jr(e,t){Fr(e._transformStreamController),Wt(e._writable._writableStreamController,t),e._backpressure&&Ar(e,!1)}function Ar(e,t){n(e._backpressure!==t),void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=c((t=>{e._backpressureChangePromise_resolve=t})),e._backpressure=t}Object.defineProperties(TransformStream.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(TransformStream.prototype,t.toStringTag,{value:"TransformStream",configurable:!0});class TransformStreamDefaultController{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!zr(this))throw Lr("desiredSize");return tr(this._controlledTransformStream._readable._readableStreamController)}enqueue(e){if(!zr(this))throw Lr("enqueue");Ir(this,e)}error(e){if(!zr(this))throw Lr("error");var t;t=e,kr(this._controlledTransformStream,t)}terminate(){if(!zr(this))throw Lr("terminate");!function(e){const t=e._controlledTransformStream;Kt(t._readable._readableStreamController);const r=new TypeError("TransformStream terminated");jr(t,r)}(this)}}function zr(e){return!!a(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof TransformStreamDefaultController)}function Fr(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Ir(e,t){const r=e._controlledTransformStream,o=r._readable._readableStreamController;if(!rr(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{Zt(o,t)}catch(e){throw jr(r,e),r._readable._storedError}const n=function(e){return!Xt(e)}(o);n!==r._backpressure&&Ar(r,!0)}function Dr(e,t){return y(e._transformAlgorithm(t),void 0,(t=>{throw kr(e._controlledTransformStream,t),t}))}function Lr(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function $r(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}Object.defineProperties(TransformStreamDefaultController.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof t.toStringTag&&Object.defineProperty(TransformStreamDefaultController.prototype,t.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});const Mr={ReadableStream:ReadableStream,ReadableStreamDefaultController:ReadableStreamDefaultController,ReadableByteStreamController:ReadableByteStreamController,ReadableStreamBYOBRequest:ReadableStreamBYOBRequest,ReadableStreamDefaultReader:ReadableStreamDefaultReader,ReadableStreamBYOBReader:ReadableStreamBYOBReader,WritableStream:WritableStream,WritableStreamDefaultController:WritableStreamDefaultController,WritableStreamDefaultWriter:WritableStreamDefaultWriter,ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,CountQueuingStrategy:CountQueuingStrategy,TransformStream:TransformStream,TransformStreamDefaultController:TransformStreamDefaultController};if(void 0!==o)for(const e in Mr)Object.prototype.hasOwnProperty.call(Mr,e)&&Object.defineProperty(o,e,{value:Mr[e],writable:!0,configurable:!0});e.ByteLengthQueuingStrategy=ByteLengthQueuingStrategy,e.CountQueuingStrategy=CountQueuingStrategy,e.ReadableByteStreamController=ReadableByteStreamController,e.ReadableStream=ReadableStream,e.ReadableStreamBYOBReader=ReadableStreamBYOBReader,e.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest,e.ReadableStreamDefaultController=ReadableStreamDefaultController,e.ReadableStreamDefaultReader=ReadableStreamDefaultReader,e.TransformStream=TransformStream,e.TransformStreamDefaultController=TransformStreamDefaultController,e.WritableStream=WritableStream,e.WritableStreamDefaultController=WritableStreamDefaultController,e.WritableStreamDefaultWriter=WritableStreamDefaultWriter}));
//# sourceMappingURL=polyfill.es6.min.js.map
|