UNPKG

@cloudbase/js-sdk

Version:
2 lines 107 kB
/*! For license information please see app.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase",[],t):"object"==typeof exports?exports.cloudbase=t():e.cloudbase=t()}("undefined"!=typeof window?window:this,(function(){return function(){var e={23:function(e,t,r){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},n=o(r(635)),i=o(r(878));n.default.registerVersion(i.default.version);try{window.cloudbase=n.default}catch(e){}t.default=n.default,e.exports=n.default},635:function(e,t,r){"use strict";r.r(t),r.d(t,{cloudbase:function(){return Hn},default:function(){return Yn},getBaseEndPoint:function(){return Tn}});var o="@cloudbase/js-sdk";function n(){return o}var i,a="https:",s={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"};!function(e){e.local="local",e.none="none",e.session="session"}(i||(i={}));var l=function(){};function u(e,t,r){void 0===r&&(r={});var o=/\?/.test(t),n="";for(var i in r)""===n?!o&&(t+="?"):n+="&",n+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=n)?t:""+e+t}function c(e){return"[object FormData]"===Object.prototype.toString.call(e)}function f(e,t,r){void 0===r&&(r={});var o=/\?/.test(t),n="";return Object.keys(r).forEach((function(e){""===n?!o&&(t+="?"):n+="&",n+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=n)?t:"".concat(e).concat(t)}function d(e,t){console.warn("[".concat(n(),"][").concat(e,"]:").concat(t))}var h,p,b=(h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},h(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),y=function(){return y=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},y.apply(this,arguments)},m=function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))},_=function(e,t){var r,o,n,i,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,o&&(n=2&s[0]?o.return:s[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,s[1])).done)return n;switch(o=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){a.label=s[1];break}if(6===s[0]&&a.label<n[1]){a.label=n[1],n=s;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(s);break}n[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{r=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},v=function(e){function t(t){var r=e.call(this)||this,o=t.timeout,n=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=o||0,r.timeoutMsg=n||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return b(t,e),t.prototype.get=function(e){return this.request(y(y({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(y(y({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(y(y({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,o=e.name,n=e.method,i=e.headers,a=void 0===i?{}:i,s={post:"post",put:"put"}[null==n?void 0:n.toLowerCase()]||"put",l=new FormData;return"post"===s?(Object.keys(t).forEach((function(e){l.append(e,t[e])})),l.append("key",o),l.append("file",r),this.request(y(y({},e),{data:l,method:s}),this.restrictedMethods.includes("upload"))):this.request(y(y({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return m(this,void 0,void 0,(function(){var t,r,o,n;return _(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(y(y({},e),{headers:{},responseType:"blob"}))];case 1:return t=i.sent().data,r=window.URL.createObjectURL(new Blob([t])),o=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(n=document.createElement("a")).href=r,n.setAttribute("download",o),n.style.display="none",document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(r),document.body.removeChild(n),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return m(this,void 0,void 0,(function(){var r,o,n,i,a,s,l,u,c,f,d,h=this;return _(this,(function(p){switch(p.label){case 0:return r=new AbortController,o=e.url,n=e.enableAbort,i=void 0!==n&&n,a=e.stream,s=void 0!==a&&a,l=e.signal,u=e.timeout,c=null!=u?u:this.timeout,l&&(l.aborted&&r.abort(),l.addEventListener("abort",(function(){return r.abort()}))),f=null,i&&c&&(f=setTimeout((function(){console.warn(h.timeoutMsg),r.abort(new Error(h.timeoutMsg))}),c)),[4,fetch(o,y(y({},e),{signal:r.signal})).then((function(e){return m(h,void 0,void 0,(function(){var t,r,o;return _(this,(function(n){switch(n.label){case 0:return clearTimeout(f),e.ok?(t=e,[3,3]):[3,1];case 1:return o=(r=Promise).reject,[4,e.json()];case 2:t=o.apply(r,[n.sent()]),n.label=3;case 3:return[2,t]}}))}))})).catch((function(e){return clearTimeout(f),Promise.reject(e)}))];case 1:return d=p.sent(),[2,{data:s?d.body:(null===(t=d.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?d.json():d.text(),statusCode:d.status,header:d.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var o=String(e.method).toLowerCase()||"get";return new Promise((function(n){var i,s,l=e.url,u=e.headers,d=void 0===u?{}:u,h=e.data,p=e.responseType,b=e.withCredentials,y=e.body,m=e.onUploadProgress,_=f(a,l,"get"===o?h:{}),v=new XMLHttpRequest;v.open(o,_),p&&(v.responseType=p),Object.keys(d).forEach((function(e){v.setRequestHeader(e,d[e])})),m&&v.upload.addEventListener("progress",m),v.onreadystatechange=function(){var e={};if(4===v.readyState){var t=v.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),o=t.shift().toLowerCase(),n=t.join(": ");r[o]=n})),e.header=r,e.statusCode=v.status;try{e.data="blob"===p?v.response:JSON.parse(v.responseText)}catch(t){e.data="blob"===p?v.response:v.responseText}clearTimeout(i),n(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),v.abort()}),r.timeout)),s=c(h)?h:"application/x-www-form-urlencoded"===d["content-type"]?function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")}(h):y||(h?JSON.stringify(h):void 0),b&&(v.withCredentials=!0),v.send(s)}))},t}(l);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(p||(p={}));var g=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),w=function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))},S=function(e,t){var r,o,n,i,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,o&&(n=2&s[0]?o.return:s[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,s[1])).done)return n;switch(o=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){a.label=s[1];break}if(6===s[0]&&a.label<n[1]){a.label=n[1],n=s;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(s);break}n[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{r=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},T=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return g(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}((function(){})),P=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,o=void 0===r?{}:r,n=e.keys,i=void 0===n?{}:n;this.platformInfo=o,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(d(s.INVALID_PARAMS,"localStorage is not supported on current platform"),new T(t.root));case"none":return new T(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var o={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(o))}catch(e){throw new Error(JSON.stringify({code:s.OPERATION_FAIL,msg:"[".concat(n(),"][").concat(s.OPERATION_FAIL,"]setStore failed"),info:e}))}}else d(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return w(this,void 0,void 0,(function(){var o;return S(this,(function(n){switch(n.label){case 0:if(!this.storage)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),o={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(o))];case 2:return n.sent(),[3,4];case 3:return n.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var o=this.storage.getItem(e);return o&&o.indexOf(t)>=0?JSON.parse(o).content:""}d(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return w(this,void 0,void 0,(function(){var o;return S(this,(function(n){switch(n.label){case 0:try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(o=n.sent())&&o.indexOf(t)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):d(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return w(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}(),E=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),O=function(e,t){this.data=t||null,this.name=e},R=function(e){function t(t,r){var o=e.call(this,"error",{error:t,data:r})||this;return o.error=t,o}return E(t,e),t}(O);function C(e){this.message=e}function A(e){this.message=e}function j(){}function q(e){return"object"==typeof e&&null!==e||"function"==typeof e}new(function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var o=r[e].indexOf(t);-1!==o&&r[e].splice(o,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if(e instanceof R)return console.error(e.error),this;var r="string"==typeof e?new O(e,t||{}):e,o=r.name;if(this.listens(o)){r.target=this;for(var n=0,i=this.listeners[o]?function(e,t,r){if(r||2===arguments.length)for(var o,n=0,i=t.length;n<i;n++)!o&&n in t||(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}([],this.listeners[o],!0):[];n<i.length;n++)i[n].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}()),"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox"),C.prototype=new Error,C.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),A.prototype=new Error,A.prototype.name="InvalidTokenError";const k=j;function I(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const x=Promise,L=Promise.resolve.bind(x),W=Promise.prototype.then,M=Promise.reject.bind(x),N=L;function F(e){return new x(e)}function B(e){return F((t=>t(e)))}function z(e){return M(e)}function D(e,t,r){return W.call(e,t,r)}function U(e,t,r){D(D(e,t,r),void 0,k)}function $(e,t){U(e,t)}function V(e,t){U(e,void 0,t)}function H(e,t,r){return D(e,t,r)}function Y(e){D(e,void 0,k)}let Q=e=>{if("function"==typeof queueMicrotask)Q=queueMicrotask;else{const e=B(void 0);Q=t=>D(e,t)}return Q(e)};function G(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function K(e,t,r){try{return B(G(e,t,r))}catch(e){return z(e)}}class J{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 o=r+1;const n=e._elements,i=n[r];return 16384===o&&(t=e._next,o=0),--this._size,this._cursor=o,e!==t&&(this._front=t),n[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&&(r=r._next,o=r._elements,t=0,0===o.length));)e(o[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}const X=Symbol("[[AbortSteps]]"),Z=Symbol("[[ErrorSteps]]"),ee=Symbol("[[CancelSteps]]"),te=Symbol("[[PullSteps]]"),re=Symbol("[[ReleaseSteps]]");function oe(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?se(e):"closed"===t._state?function(e){se(e),ce(e)}(e):le(e,t._storedError)}function ne(e,t){return ho(e._ownerReadableStream,t)}function ie(e){const t=e._ownerReadableStream;"readable"===t._state?ue(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){le(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[re](),t._reader=void 0,e._ownerReadableStream=void 0}function ae(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function se(e){e._closedPromise=F(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function le(e,t){se(e),ue(e,t)}function ue(e,t){void 0!==e._closedPromise_reject&&(Y(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function ce(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const fe=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},de=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function he(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError(`${t} is not an object.`);var r}function pe(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function be(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function ye(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function me(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function _e(e){return Number(e)}function ve(e){return 0===e?0:e}function ge(e,t){const r=Number.MAX_SAFE_INTEGER;let o=Number(e);if(o=ve(o),!fe(o))throw new TypeError(`${t} is not a finite number`);if(o=function(e){return ve(de(e))}(o),o<0||o>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return fe(o)&&0!==o?o:0}function we(e,t){if(!co(e))throw new TypeError(`${t} is not a ReadableStream.`)}function Se(e){return new Re(e)}function Te(e,t){e._reader._readRequests.push(t)}function Pe(e,t,r){const o=e._reader._readRequests.shift();r?o._closeSteps():o._chunkSteps(t)}function Ee(e){return e._reader._readRequests.length}function Oe(e){const t=e._reader;return void 0!==t&&!!Ce(t)}class Re{constructor(e){if(ye(e,1,"ReadableStreamDefaultReader"),we(e,"First parameter"),fo(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");oe(this,e),this._readRequests=new J}get closed(){return Ce(this)?this._closedPromise:z(qe("closed"))}cancel(e=void 0){return Ce(this)?void 0===this._ownerReadableStream?z(ae("cancel")):ne(this,e):z(qe("cancel"))}read(){if(!Ce(this))return z(qe("read"));if(void 0===this._ownerReadableStream)return z(ae("read from"));let e,t;const r=F(((r,o)=>{e=r,t=o}));return Ae(this,{_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)}),r}releaseLock(){if(!Ce(this))throw qe("releaseLock");void 0!==this._ownerReadableStream&&function(e){ie(e),je(e,new TypeError("Reader was released"))}(this)}}function Ce(e){return!!q(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof Re}function Ae(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[te](t)}function je(e,t){const r=e._readRequests;e._readRequests=new J,r.forEach((e=>{e._errorSteps(t)}))}function qe(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}var ke,Ie,xe;function Le(e){return e.slice()}function We(e,t,r,o,n){new Uint8Array(e).set(new Uint8Array(r,o,n),t)}Object.defineProperties(Re.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),I(Re.prototype.cancel,"cancel"),I(Re.prototype.read,"read"),I(Re.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Re.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});let Me=e=>(Me="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,Me(e)),Ne=e=>(Ne="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,Ne(e));function Fe(e,t,r){if(e.slice)return e.slice(t,r);const o=r-t,n=new ArrayBuffer(o);return We(n,0,e,t,o),n}function Be(e,t){const r=e[t];if(null!=r){if("function"!=typeof r)throw new TypeError(`${String(t)} is not a function`);return r}}function ze(e){try{const t=e.done,r=e.value;return D(N(r),(e=>({done:t,value:e})))}catch(e){return z(e)}}const De=null!==(xe=null!==(ke=Symbol.asyncIterator)&&void 0!==ke?ke:null===(Ie=Symbol.for)||void 0===Ie?void 0:Ie.call(Symbol,"Symbol.asyncIterator"))&&void 0!==xe?xe:"@@asyncIterator";function Ue(e,t="sync",r){if(void 0===r)if("async"===t){if(void 0===(r=Be(e,De)))return function(e){const t={next(){let t;try{t=$e(e)}catch(e){return z(e)}return ze(t)},return(t){let r;try{const o=Be(e.iterator,"return");if(void 0===o)return B({done:!0,value:t});r=G(o,e.iterator,[t])}catch(e){return z(e)}return q(r)?ze(r):z(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(Ue(e,"sync",Be(e,Symbol.iterator)))}else r=Be(e,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const o=G(r,e,[]);if(!q(o))throw new TypeError("The iterator method must return an object");return{iterator:o,nextMethod:o.next,done:!1}}function $e(e){const t=G(e.nextMethod,e.iterator,[]);if(!q(t))throw new TypeError("The iterator.next() method must return an object");return t}class Ve{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?H(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?H(this._ongoingPromise,t,t):t()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader;let t,r;const o=F(((e,o)=>{t=e,r=o}));return Ae(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,Q((()=>t({value:e,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,ie(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,ie(e),r(t)}}),o}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(!this._preventCancel){const r=ne(t,e);return ie(t),H(r,(()=>({value:e,done:!0})))}return ie(t),B({value:e,done:!0})}}const He={next(){return Ye(this)?this._asyncIteratorImpl.next():z(Qe("next"))},return(e){return Ye(this)?this._asyncIteratorImpl.return(e):z(Qe("return"))},[De](){return this}};function Ye(e){if(!q(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof Ve}catch(e){return!1}}function Qe(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(He,De,{enumerable:!1});const Ge=Number.isNaN||function(e){return e!=e};function Ke(e){const t=Fe(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function Je(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Xe(e,t,r){if("number"!=typeof(o=r)||Ge(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 Ze(e){e._queue=new J,e._queueTotalSize=0}function et(e){return e===DataView}class tt{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!nt(this))throw At("view");return this._view}respond(e){if(!nt(this))throw At("respond");if(ye(e,1,"respond"),e=ge(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(Ne(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");Ot(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!nt(this))throw At("respondWithNewView");if(ye(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");if(Ne(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");Rt(this._associatedReadableByteStreamController,e)}}Object.defineProperties(tt.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),I(tt.prototype.respond,"respond"),I(tt.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(tt.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class rt{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!ot(this))throw jt("byobRequest");return Pt(this)}get desiredSize(){if(!ot(this))throw jt("desiredSize");return Et(this)}close(){if(!ot(this))throw jt("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`);gt(this)}enqueue(e){if(!ot(this))throw jt("enqueue");if(ye(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`);wt(this,e)}error(e=void 0){if(!ot(this))throw jt("error");St(this,e)}[ee](e){at(this),Ze(this);const t=this._cancelAlgorithm(e);return vt(this),t}[te](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void Tt(this,e);const r=this._autoAllocateChunkSize;if(void 0!==r){let o;try{o=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}const n={buffer:o,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(n)}Te(t,e),it(this)}[re](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new J,this._pendingPullIntos.push(e)}}}function ot(e){return!!q(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof rt}function nt(e){return!!q(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof tt}function it(e){const t=function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&(!e._closeRequested&&(!!e._started&&(!!(Oe(t)&&Ee(t)>0)||(!!(Lt(t)&&xt(t)>0)||Et(e)>0))))}(e);t&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,U(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,it(e)),null)),(t=>(St(e,t),null)))))}function at(e){bt(e),e._pendingPullIntos=new J}function st(e,t){let r=!1;"closed"===e._state&&(r=!0);const o=lt(t);"default"===t.readerType?Pe(e,o,r):function(e,t,r){const o=e._reader._readIntoRequests.shift();r?o._closeSteps(t):o._chunkSteps(t)}(e,o,r)}function lt(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function ut(e,t,r,o){e._queue.push({buffer:t,byteOffset:r,byteLength:o}),e._queueTotalSize+=o}function ct(e,t,r,o){let n;try{n=Fe(t,r,r+o)}catch(t){throw St(e,t),t}ut(e,n,0,o)}function ft(e,t){t.bytesFilled>0&&ct(e,t.buffer,t.byteOffset,t.bytesFilled),_t(e)}function dt(e,t){const r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),o=t.bytesFilled+r;let n=r,i=!1;const a=o-o%t.elementSize;a>=t.minimumFill&&(n=a-t.bytesFilled,i=!0);const s=e._queue;for(;n>0;){const r=s.peek(),o=Math.min(n,r.byteLength),i=t.byteOffset+t.bytesFilled;We(t.buffer,i,r.buffer,r.byteOffset,o),r.byteLength===o?s.shift():(r.byteOffset+=o,r.byteLength-=o),e._queueTotalSize-=o,ht(0,o,t),n-=o}return i}function ht(e,t,r){r.bytesFilled+=t}function pt(e){0===e._queueTotalSize&&e._closeRequested?(vt(e),po(e._controlledReadableByteStream)):it(e)}function bt(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function yt(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();dt(e,t)&&(_t(e),st(e._controlledReadableByteStream,t))}}function mt(e,t){const r=e._pendingPullIntos.peek();bt(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&_t(e);const r=e._controlledReadableByteStream;if(Lt(r))for(;xt(r)>0;)st(r,_t(e))}(e,r):function(e,t,r){if(ht(0,t,r),"none"===r.readerType)return ft(e,r),void yt(e);if(r.bytesFilled<r.minimumFill)return;_t(e);const o=r.bytesFilled%r.elementSize;if(o>0){const t=r.byteOffset+r.bytesFilled;ct(e,r.buffer,t-o,o)}r.bytesFilled-=o,st(e._controlledReadableByteStream,r),yt(e)}(e,t,r),it(e)}function _t(e){return e._pendingPullIntos.shift()}function vt(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function gt(e){const t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(t.bytesFilled%t.elementSize!=0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw St(e,t),t}}vt(e),po(t)}}function wt(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:o,byteOffset:n,byteLength:i}=t;if(Ne(o))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const a=Me(o);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(Ne(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");bt(e),t.buffer=Me(t.buffer),"none"===t.readerType&&ft(e,t)}Oe(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;Tt(e,t._readRequests.shift())}}(e),0===Ee(r)?ut(e,a,n,i):(e._pendingPullIntos.length>0&&_t(e),Pe(r,new Uint8Array(a,n,i),!1))):Lt(r)?(ut(e,a,n,i),yt(e)):ut(e,a,n,i),it(e)}function St(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(at(e),Ze(e),vt(e),bo(r,t))}function Tt(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,pt(e);const o=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(o)}function Pt(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(tt.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(o,e,r),e._byobRequest=o}return e._byobRequest}function Et(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Ot(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")}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=Me(r.buffer),mt(e,t)}function Rt(e,t){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=Me(t.buffer),mt(e,o)}function Ct(e,t,r,o,n,i,a){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Ze(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=o,t._cancelAlgorithm=n,t._autoAllocateChunkSize=a,t._pendingPullIntos=new J,e._readableStreamController=t,U(B(r()),(()=>(t._started=!0,it(t),null)),(e=>(St(t,e),null)))}function At(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function jt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function qt(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function kt(e){return new Wt(e)}function It(e,t){e._reader._readIntoRequests.push(t)}function xt(e){return e._reader._readIntoRequests.length}function Lt(e){const t=e._reader;return void 0!==t&&!!Mt(t)}Object.defineProperties(rt.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),I(rt.prototype.close,"close"),I(rt.prototype.enqueue,"enqueue"),I(rt.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(rt.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class Wt{constructor(e){if(ye(e,1,"ReadableStreamBYOBReader"),we(e,"First parameter"),fo(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!ot(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");oe(this,e),this._readIntoRequests=new J}get closed(){return Mt(this)?this._closedPromise:z(Bt("closed"))}cancel(e=void 0){return Mt(this)?void 0===this._ownerReadableStream?z(ae("cancel")):ne(this,e):z(Bt("cancel"))}read(e,t={}){if(!Mt(this))return z(Bt("read"));if(!ArrayBuffer.isView(e))return z(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return z(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return z(new TypeError("view's buffer must have non-zero byteLength"));if(Ne(e.buffer))return z(new TypeError("view's buffer has been detached"));let r;try{r=function(e,t){var r;return he(e,t),{min:ge(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}(t,"options")}catch(e){return z(e)}const o=r.min;if(0===o)return z(new TypeError("options.min must be greater than 0"));if(function(e){return et(e.constructor)}(e)){if(o>e.byteLength)return z(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(o>e.length)return z(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return z(ae("read from"));let n,i;const a=F(((e,t)=>{n=e,i=t}));return Nt(this,e,o,{_chunkSteps:e=>n({value:e,done:!1}),_closeSteps:e=>n({value:e,done:!0}),_errorSteps:e=>i(e)}),a}releaseLock(){if(!Mt(this))throw Bt("releaseLock");void 0!==this._ownerReadableStream&&function(e){ie(e),Ft(e,new TypeError("Reader was released"))}(this)}}function Mt(e){return!!q(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof Wt}function Nt(e,t,r,o){const n=e._ownerReadableStream;n._disturbed=!0,"errored"===n._state?o._errorSteps(n._storedError):function(e,t,r,o){const n=e._controlledReadableByteStream,i=t.constructor,a=function(e){return et(e)?1:e.BYTES_PER_ELEMENT}(i),{byteOffset:s,byteLength:l}=t,u=r*a;let c;try{c=Me(t.buffer)}catch(e){return void o._errorSteps(e)}const f={buffer:c,bufferByteLength:c.byteLength,byteOffset:s,byteLength:l,bytesFilled:0,minimumFill:u,elementSize:a,viewConstructor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(f),void It(n,o);if("closed"!==n._state){if(e._queueTotalSize>0){if(dt(e,f)){const t=lt(f);return pt(e),void o._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return St(e,t),void o._errorSteps(t)}}e._pendingPullIntos.push(f),It(n,o),it(e)}else{const e=new i(f.buffer,f.byteOffset,0);o._closeSteps(e)}}(n._readableStreamController,t,r,o)}function Ft(e,t){const r=e._readIntoRequests;e._readIntoRequests=new J,r.forEach((e=>{e._errorSteps(t)}))}function Bt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function zt(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(Ge(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function Dt(e){const{size:t}=e;return t||(()=>1)}function Ut(e,t){he(e,t);const r=null==e?void 0:e.highWaterMark,o=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:_e(r),size:void 0===o?void 0:$t(o,`${t} has member 'size' that`)}}function $t(e,t){return pe(e,t),t=>_e(e(t))}function Vt(e,t,r){return pe(e,r),r=>K(e,t,[r])}function Ht(e,t,r){return pe(e,r),()=>K(e,t,[])}function Yt(e,t,r){return pe(e,r),r=>G(e,t,[r])}function Qt(e,t,r){return pe(e,r),(r,o)=>K(e,t,[r,o])}function Gt(e,t){if(!er(e))throw new TypeError(`${t} is not a WritableStream.`)}Object.defineProperties(Wt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),I(Wt.prototype.cancel,"cancel"),I(Wt.prototype.read,"read"),I(Wt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Wt.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const Kt="function"==typeof AbortController;class Jt{constructor(e={},t={}){void 0===e?e=null:be(e,"First parameter");const r=Ut(t,"Second parameter"),o=function(e,t){he(e,t);const r=null==e?void 0:e.abort,o=null==e?void 0:e.close,n=null==e?void 0:e.start,i=null==e?void 0:e.type,a=null==e?void 0:e.write;return{abort:void 0===r?void 0:Vt(r,e,`${t} has member 'abort' that`),close:void 0===o?void 0:Ht(o,e,`${t} has member 'close' that`),start:void 0===n?void 0:Yt(n,e,`${t} has member 'start' that`),write:void 0===a?void 0:Qt(a,e,`${t} has member 'write' that`),type:i}}(e,"First parameter");if(Zt(this),void 0!==o.type)throw new RangeError("Invalid type is specified");const n=Dt(r);!function(e,t,r,o){const n=Object.create(mr.prototype);let i,a,s,l;i=void 0!==t.start?()=>t.start(n):()=>{},a=void 0!==t.write?e=>t.write(e,n):()=>B(void 0),s=void 0!==t.close?()=>t.close():()=>B(void 0),l=void 0!==t.abort?e=>t.abort(e):()=>B(void 0),vr(e,n,i,a,s,l,r,o)}(this,o,zt(r,1),n)}get locked(){if(!er(this))throw Or("locked");return tr(this)}abort(e=void 0){return er(this)?tr(this)?z(new TypeError("Cannot abort a stream that already has a writer")):rr(this,e):z(Or("abort"))}close(){return er(this)?tr(this)?z(new TypeError("Cannot close a stream that already has a writer")):sr(this)?z(new TypeError("Cannot close an already-closing stream")):or(this):z(Or("close"))}getWriter(){if(!er(this))throw Or("getWriter");return Xt(this)}}function Xt(e){return new cr(e)}function Zt(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new J,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function er(e){return!!q(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof Jt}function tr(e){return void 0!==e._writer}function rr(e,t){var r;if("closed"===e._state||"errored"===e._state)return B(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort(t);const o=e._state;if("closed"===o||"errored"===o)return B(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let n=!1;"erroring"===o&&(n=!0,t=void 0);const i=F(((r,o)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:o,_reason:t,_wasAlreadyErroring:n}}));return e._pendingAbortRequest._promise=i,n||ir(e,t),i}function or(e){const t=e._state;if("closed"===t||"errored"===t)return z(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=F(((t,r)=>{const o={_resolve:t,_reject:r};e._closeRequest=o})),o=e._writer;var n;return void 0!==o&&e._backpressure&&"writable"===t&&Nr(o),Xe(n=e._writableStreamController,yr,0),Sr(n),r}function nr(e,t){"writable"!==e._state?ar(e):ir(e,t)}function ir(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const o=e._writer;void 0!==o&&hr(o,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&ar(e)}function ar(e){e._state="errored",e._writableStreamController[Z]();const t=e._storedError;if(e._writeRequests.forEach((e=>{e._reject(t)})),e._writeRequests=new J,void 0===e._pendingAbortRequest)return void lr(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void lr(e);U(e._writableStreamController[X](r._reason),(()=>(r._resolve(),lr(e),null)),(t=>(r._reject(t),lr(e),null)))}function sr(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function lr(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&kr(t,e._storedError)}function ur(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){xr(e)}(r):Nr(r)),e._backpressure=t}Object.defineProperties(Jt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),I(Jt.prototype.abort,"abort"),I(Jt.prototype.close,"close"),I(Jt.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Jt.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class cr{constructor(e){if(ye(e,1,"WritableStreamDefaultWriter"),Gt(e,"First parameter"),tr(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)!sr(e)&&e._backpressure?xr(this):Wr(this),jr(this);else if("erroring"===t)Lr(this,e._storedError),jr(this);else if("closed"===t)Wr(this),jr(this),Ir(this);else{const t=e._storedError;Lr(this,t),qr(this,t)}}get closed(){return fr(this)?this._closedPromise:z(Cr("closed"))}get desiredSize(){if(!fr(this))throw Cr("desiredSize");if(void 0===this._ownerWritableStream)throw Ar("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:wr(t._writableStreamController)}(this)}get ready(){return fr(this)?this._readyPromise:z(Cr("ready"))}abort(e=void 0){return fr(this)?void 0===this._ownerWritableStream?z(Ar("abort")):function(e,t){return rr(e._ownerWritableStream,t)}(this,e):z(Cr("abort"))}close(){if(!fr(this))return z(Cr("close"));const e=this._ownerWritableStream;return void 0===e?z(Ar("close")):sr(e)?z(new TypeError("Cannot close an already-closing stream")):dr(this)}releaseLock(){if(!fr(this))throw Cr("releaseLock");void 0!==this._ownerWritableStream&&pr(this)}write(e=void 0){return fr(this)?void 0===this._ownerWritableStream?z(Ar("write to")):br(this,e):z(Cr("write"))}}function fr(e){return!!q(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof cr}function dr(e){return or(e._ownerWritableStream)}function hr(e,t){"pending"===e._readyPromiseState?Mr(e,t):function(e,t){Lr(e,t)}(e,t)}function pr(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");hr(e,r),function(e,t){"pending"===e._closedPromiseState?kr(e,t):function(e,t){qr(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function br(e,t){const r=e._ownerWritableStream,o=r._writableStreamController,n=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Tr(e,t),1}}(o,t);if(r!==e._ownerWritableStream)return z(Ar("write to"));const i=r._state;if("errored"===i)return z(r._storedError);if(sr(r)||"closed"===i)return z(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return z(r._storedError);const a=function(e){return F(((t,r)=>{const o={_resolve:t,_reject:r};e._writeRequests.push(o)}))}(r);return function(e,t,r){try{Xe(e,t,r)}catch(t){return void Tr(e,t)}const o=e._controlledWritableStream;sr(o)||"writable"!==o._state||ur(o,Pr(e)),Sr(e)}(o,t,n),a}Object.defineProperties(cr.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),I(cr.prototype.abort,"abort"),I(cr.prototype.close,"close"),I(cr.prototype.releaseLock,"releaseLock"),I(cr.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(cr.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const yr={};class mr{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!_r(this))throw Rr("abortReason");return this._abortReason}get signal(){if(!_r(this))throw Rr("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!_r(this))throw Rr("error");"writable"===this._controlledWritableStream._state&&Er(this,e)}[X](e){const t=this._abortAlgorithm(e);return gr(this),t}[Z](){Ze(this)}}function _r(e){return!!q(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof mr}function vr(e,t,r,o,n,i,a,s){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Ze(t),t._abortReason=void 0,t._abortController=function(){if(Kt)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=s,t._strategyHWM=a,t._writeAlgorithm=o,t._closeAlgorithm=n,t._abortAlgorithm=i;const l=Pr(t);ur(e,l),U(B(r()),(()=>(t._started=!0,Sr(t),null)),(r=>(t._started=!0,nr(e,r),null)))}function gr(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function wr(e){return e._strategyHWM-e._queueTotalSize}function Sr(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void ar(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===yr?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),Je(e);const r=e._closeAlgorithm();gr(e),U(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&&Ir(t)}(t),null)),(e=>(function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),nr(e,t)}(t,e),null)))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r),U(e._writeAlgorithm(t),(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(Je(e),!sr(r)&&"writable"===t){const t=Pr(e);ur(r,t)}return Sr(e),null}),(t=>("writable"===r._state&&gr(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,nr(e,t)}(r,t),null)))}(e,r)}function Tr(e,t){"writable"===e._controlledWritableStream._state&&Er(e,t)}function Pr(e){return wr(e)<=0}function Er(e,t){const r=e._controlledWritableStream;gr(e),ir(r,t)}function Or(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function Rr(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function Cr(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function Ar(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function jr(e){e._closedPromise=F(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedP