UNPKG

@cloudbase/js-sdk

Version:
2 lines 121 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(353)),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},353:function(e,t,r){"use strict";r.r(t),r.d(t,{LANGS:function(){return Bn},cloudbase:function(){return fi},default:function(){return pi},getBaseEndPoint:function(){return In}});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 u=function(){};function l(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 d(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 f(e,t){console.warn("[".concat(n(),"][").concat(e,"]:").concat(t))}var p,h,b=(p=function(e,t){return p=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])},p(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}p(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{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))},v=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(u){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,u])}}},_=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",u=new FormData;return"post"===s?(Object.keys(t).forEach((function(e){u.append(e,t[e])})),u.append("key",o),u.append("file",r),this.request(y(y({},e),{data:u,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 v(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,u,l,c,d,f,p,h,b=this;return v(this,(function(_){switch(_.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,u=e.signal,l=e.timeout,c=e.shouldThrowOnError,d=void 0===c||c,f=null!=l?l:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",(function(){return r.abort()}))),p=null,i&&f&&(p=setTimeout((function(){console.warn(b.timeoutMsg),r.abort(new Error(b.timeoutMsg))}),f)),[4,fetch(o,y(y({},e),{signal:r.signal})).then((function(e){return m(b,void 0,void 0,(function(){var t,r,o;return v(this,(function(n){switch(n.label){case 0:return clearTimeout(p),d?e.ok?(t=e,[3,3]):[3,1]:[3,4];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];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(p),d)return Promise.reject(e)}))];case 1:return h=_.sent(),[2,{data:s?h.body:(null===(t=h.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?h.json():h.text(),statusCode:h.status,header:h.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,u=e.url,l=e.headers,f=void 0===l?{}:l,p=e.data,h=e.responseType,b=e.withCredentials,y=e.body,m=e.onUploadProgress,v=d(a,u,"get"===o?p:{}),_=new XMLHttpRequest;_.open(o,v),h&&(_.responseType=h),Object.keys(f).forEach((function(e){_.setRequestHeader(e,f[e])})),m&&_.upload.addEventListener("progress",m),_.onreadystatechange=function(){var e={};if(4===_.readyState){var t=_.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=_.status;try{e.data="blob"===h?_.response:JSON.parse(_.responseText)}catch(t){e.data="blob"===h?_.response:_.responseText}clearTimeout(i),n(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),_.abort()}),r.timeout)),s=c(p)?p:"application/x-www-form-urlencoded"===f["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("&")}(p):y||(p?JSON.stringify(p):void 0),b&&(_.withCredentials=!0),_.send(s)}))},t}(u),g=function(){return g=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},g.apply(this,arguments)};!function(e){e.WEB="web",e.WX_MP="wx_mp"}(h||(h={}));var w=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)}}(),S=function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))},O=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(u){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,u])}}},P=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return w(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(){})),T=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:(f(s.INVALID_PARAMS,"localStorage is not supported on current platform"),new P(t.root));case"none":return new P(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 f(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return S(this,void 0,void 0,(function(){var o;return O(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={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0}.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:""}f(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return S(this,void 0,void 0,(function(){var o;return O(this,(function(n){switch(n.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0}.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):f(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return S(this,void 0,void 0,(function(){return O(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)}}(),R=function(e,t){this.data=t||null,this.name=e},A=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}(R),C=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 A)return console.error(e.error),this;var r="string"==typeof e?new R(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}();new C;var I=new C,j="lang_change";function k(e){this.message=e}function q(e){this.message=e}"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox"),k.prototype=new Error,k.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),q.prototype=new Error,q.prototype.name="InvalidTokenError";var x=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))},L=s,N={};function W(e,t){var r=t.name,o=t.namespace,n=t.entity,i=t.injectEvents,a=t.IIFE,s=void 0!==a&&a;if(N[r]||o&&e[o])throw new Error(JSON.stringify({code:L.INVALID_OPERATION,msg:"Duplicate component ".concat(r)}));if(s){if(!n||"function"!=typeof n)throw new Error(JSON.stringify({code:L.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));n.call(e)}if(N[r]=t,o?e.prototype[o]=n:M(e.prototype,n),i){var u=i.bus,l=i.events;if(!u||!l||0===l.length)return;var c=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[r]?e.prototype.events[r].events=x(x([],e.prototype.events[r].events,!0),l,!0):e.prototype.events[r]={bus:u,events:l},e.prototype.fire=function(e,t){c(e,t);for(var r=0,o=Object.keys(this.events);r<o.length;r++){var n=o[r],i=this.events[n],a=i.bus;if(i.events.includes(e)){a.fire(e,t);break}}}}}function M(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var r=0,o=Object.keys(t);r<o.length;r++){var n=o[r];Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=M(e[n],t[n]))}return e}function D(){}function F(e){return"object"==typeof e&&null!==e||"function"==typeof e}const B=D;function U(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const z=Promise,$=Promise.resolve.bind(z),V=Promise.prototype.then,H=Promise.reject.bind(z),G=$;function Y(e){return new z(e)}function K(e){return Y((t=>t(e)))}function Q(e){return H(e)}function J(e,t,r){return V.call(e,t,r)}function X(e,t,r){J(J(e,t,r),void 0,B)}function Z(e,t){X(e,t)}function ee(e,t){X(e,void 0,t)}function te(e,t,r){return J(e,t,r)}function re(e){J(e,void 0,B)}let oe=e=>{if("function"==typeof queueMicrotask)oe=queueMicrotask;else{const e=K(void 0);oe=t=>J(e,t)}return oe(e)};function ne(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function ie(e,t,r){try{return K(ne(e,t,r))}catch(e){return Q(e)}}class ae{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 se=Symbol("[[AbortSteps]]"),ue=Symbol("[[ErrorSteps]]"),le=Symbol("[[CancelSteps]]"),ce=Symbol("[[PullSteps]]"),de=Symbol("[[ReleaseSteps]]");function fe(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?ye(e):"closed"===t._state?function(e){ye(e),_e(e)}(e):me(e,t._storedError)}function pe(e,t){return So(e._ownerReadableStream,t)}function he(e){const t=e._ownerReadableStream;"readable"===t._state?ve(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){me(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[de](),t._reader=void 0,e._ownerReadableStream=void 0}function be(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function ye(e){e._closedPromise=Y(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function me(e,t){ye(e),ve(e,t)}function ve(e,t){void 0!==e._closedPromise_reject&&(re(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function _e(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const ge=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},we=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function Se(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError(`${t} is not an object.`);var r}function Oe(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function Pe(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function Te(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function Ee(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function Re(e){return Number(e)}function Ae(e){return 0===e?0:e}function Ce(e,t){const r=Number.MAX_SAFE_INTEGER;let o=Number(e);if(o=Ae(o),!ge(o))throw new TypeError(`${t} is not a finite number`);if(o=function(e){return Ae(we(e))}(o),o<0||o>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return ge(o)&&0!==o?o:0}function Ie(e,t){if(!go(e))throw new TypeError(`${t} is not a ReadableStream.`)}function je(e){return new Ne(e)}function ke(e,t){e._reader._readRequests.push(t)}function qe(e,t,r){const o=e._reader._readRequests.shift();r?o._closeSteps():o._chunkSteps(t)}function xe(e){return e._reader._readRequests.length}function Le(e){const t=e._reader;return void 0!==t&&!!We(t)}class Ne{constructor(e){if(Te(e,1,"ReadableStreamDefaultReader"),Ie(e,"First parameter"),wo(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");fe(this,e),this._readRequests=new ae}get closed(){return We(this)?this._closedPromise:Q(Fe("closed"))}cancel(e=void 0){return We(this)?void 0===this._ownerReadableStream?Q(be("cancel")):pe(this,e):Q(Fe("cancel"))}read(){if(!We(this))return Q(Fe("read"));if(void 0===this._ownerReadableStream)return Q(be("read from"));let e,t;const r=Y(((r,o)=>{e=r,t=o}));return Me(this,{_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)}),r}releaseLock(){if(!We(this))throw Fe("releaseLock");void 0!==this._ownerReadableStream&&function(e){he(e),De(e,new TypeError("Reader was released"))}(this)}}function We(e){return!!F(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof Ne}function Me(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[ce](t)}function De(e,t){const r=e._readRequests;e._readRequests=new ae,r.forEach((e=>{e._errorSteps(t)}))}function Fe(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}var Be,Ue,ze;function $e(e){return e.slice()}function Ve(e,t,r,o,n){new Uint8Array(e).set(new Uint8Array(r,o,n),t)}Object.defineProperties(Ne.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),U(Ne.prototype.cancel,"cancel"),U(Ne.prototype.read,"read"),U(Ne.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Ne.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});let He=e=>(He="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,He(e)),Ge=e=>(Ge="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,Ge(e));function Ye(e,t,r){if(e.slice)return e.slice(t,r);const o=r-t,n=new ArrayBuffer(o);return Ve(n,0,e,t,o),n}function Ke(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 Qe(e){try{const t=e.done,r=e.value;return J(G(r),(e=>({done:t,value:e})))}catch(e){return Q(e)}}const Je=null!==(ze=null!==(Be=Symbol.asyncIterator)&&void 0!==Be?Be:null===(Ue=Symbol.for)||void 0===Ue?void 0:Ue.call(Symbol,"Symbol.asyncIterator"))&&void 0!==ze?ze:"@@asyncIterator";function Xe(e,t="sync",r){if(void 0===r)if("async"===t){if(void 0===(r=Ke(e,Je)))return function(e){const t={next(){let t;try{t=Ze(e)}catch(e){return Q(e)}return Qe(t)},return(t){let r;try{const o=Ke(e.iterator,"return");if(void 0===o)return K({done:!0,value:t});r=ne(o,e.iterator,[t])}catch(e){return Q(e)}return F(r)?Qe(r):Q(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(Xe(e,"sync",Ke(e,Symbol.iterator)))}else r=Ke(e,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const o=ne(r,e,[]);if(!F(o))throw new TypeError("The iterator method must return an object");return{iterator:o,nextMethod:o.next,done:!1}}function Ze(e){const t=ne(e.nextMethod,e.iterator,[]);if(!F(t))throw new TypeError("The iterator.next() method must return an object");return t}class et{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?te(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?te(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=Y(((e,o)=>{t=e,r=o}));return Me(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,oe((()=>t({value:e,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,he(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,he(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=pe(t,e);return he(t),te(r,(()=>({value:e,done:!0})))}return he(t),K({value:e,done:!0})}}const tt={next(){return rt(this)?this._asyncIteratorImpl.next():Q(ot("next"))},return(e){return rt(this)?this._asyncIteratorImpl.return(e):Q(ot("return"))},[Je](){return this}};function rt(e){if(!F(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof et}catch(e){return!1}}function ot(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(tt,Je,{enumerable:!1});const nt=Number.isNaN||function(e){return e!=e};function it(e){const t=Ye(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function at(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function st(e,t,r){if("number"!=typeof(o=r)||nt(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 ut(e){e._queue=new ae,e._queueTotalSize=0}function lt(e){return e===DataView}class ct{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!pt(this))throw Mt("view");return this._view}respond(e){if(!pt(this))throw Mt("respond");if(Te(e,1,"respond"),e=Ce(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(Ge(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");Lt(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!pt(this))throw Mt("respondWithNewView");if(Te(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(Ge(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");Nt(this._associatedReadableByteStreamController,e)}}Object.defineProperties(ct.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),U(ct.prototype.respond,"respond"),U(ct.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ct.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class dt{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!ft(this))throw Dt("byobRequest");return qt(this)}get desiredSize(){if(!ft(this))throw Dt("desiredSize");return xt(this)}close(){if(!ft(this))throw Dt("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`);Ct(this)}enqueue(e){if(!ft(this))throw Dt("enqueue");if(Te(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`);It(this,e)}error(e=void 0){if(!ft(this))throw Dt("error");jt(this,e)}[le](e){bt(this),ut(this);const t=this._cancelAlgorithm(e);return At(this),t}[ce](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void kt(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)}ke(t,e),ht(this)}[de](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new ae,this._pendingPullIntos.push(e)}}}function ft(e){return!!F(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof dt}function pt(e){return!!F(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof ct}function ht(e){const t=function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&(!e._closeRequested&&(!!e._started&&(!!(Le(t)&&xe(t)>0)||(!!($t(t)&&zt(t)>0)||xt(e)>0))))}(e);t&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,X(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,ht(e)),null)),(t=>(jt(e,t),null)))))}function bt(e){Pt(e),e._pendingPullIntos=new ae}function yt(e,t){let r=!1;"closed"===e._state&&(r=!0);const o=mt(t);"default"===t.readerType?qe(e,o,r):function(e,t,r){const o=e._reader._readIntoRequests.shift();r?o._closeSteps(t):o._chunkSteps(t)}(e,o,r)}function mt(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function vt(e,t,r,o){e._queue.push({buffer:t,byteOffset:r,byteLength:o}),e._queueTotalSize+=o}function _t(e,t,r,o){let n;try{n=Ye(t,r,r+o)}catch(t){throw jt(e,t),t}vt(e,n,0,o)}function gt(e,t){t.bytesFilled>0&&_t(e,t.buffer,t.byteOffset,t.bytesFilled),Rt(e)}function wt(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;Ve(t.buffer,i,r.buffer,r.byteOffset,o),r.byteLength===o?s.shift():(r.byteOffset+=o,r.byteLength-=o),e._queueTotalSize-=o,St(0,o,t),n-=o}return i}function St(e,t,r){r.bytesFilled+=t}function Ot(e){0===e._queueTotalSize&&e._closeRequested?(At(e),Oo(e._controlledReadableByteStream)):ht(e)}function Pt(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Tt(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();wt(e,t)&&(Rt(e),yt(e._controlledReadableByteStream,t))}}function Et(e,t){const r=e._pendingPullIntos.peek();Pt(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&Rt(e);const r=e._controlledReadableByteStream;if($t(r))for(;zt(r)>0;)yt(r,Rt(e))}(e,r):function(e,t,r){if(St(0,t,r),"none"===r.readerType)return gt(e,r),void Tt(e);if(r.bytesFilled<r.minimumFill)return;Rt(e);const o=r.bytesFilled%r.elementSize;if(o>0){const t=r.byteOffset+r.bytesFilled;_t(e,r.buffer,t-o,o)}r.bytesFilled-=o,yt(e._controlledReadableByteStream,r),Tt(e)}(e,t,r),ht(e)}function Rt(e){return e._pendingPullIntos.shift()}function At(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function Ct(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 jt(e,t),t}}At(e),Oo(t)}}function It(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:o,byteOffset:n,byteLength:i}=t;if(Ge(o))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const a=He(o);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(Ge(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Pt(e),t.buffer=He(t.buffer),"none"===t.readerType&&gt(e,t)}Le(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;kt(e,t._readRequests.shift())}}(e),0===xe(r)?vt(e,a,n,i):(e._pendingPullIntos.length>0&&Rt(e),qe(r,new Uint8Array(a,n,i),!1))):$t(r)?(vt(e,a,n,i),Tt(e)):vt(e,a,n,i),ht(e)}function jt(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(bt(e),ut(e),At(e),Po(r,t))}function kt(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,Ot(e);const o=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(o)}function qt(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(ct.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(o,e,r),e._byobRequest=o}return e._byobRequest}function xt(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Lt(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=He(r.buffer),Et(e,t)}function Nt(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=He(t.buffer),Et(e,o)}function Wt(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,ut(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=o,t._cancelAlgorithm=n,t._autoAllocateChunkSize=a,t._pendingPullIntos=new ae,e._readableStreamController=t,X(K(r()),(()=>(t._started=!0,ht(t),null)),(e=>(jt(t,e),null)))}function Mt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Dt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function Ft(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function Bt(e){return new Vt(e)}function Ut(e,t){e._reader._readIntoRequests.push(t)}function zt(e){return e._reader._readIntoRequests.length}function $t(e){const t=e._reader;return void 0!==t&&!!Ht(t)}Object.defineProperties(dt.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),U(dt.prototype.close,"close"),U(dt.prototype.enqueue,"enqueue"),U(dt.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(dt.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class Vt{constructor(e){if(Te(e,1,"ReadableStreamBYOBReader"),Ie(e,"First parameter"),wo(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!ft(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");fe(this,e),this._readIntoRequests=new ae}get closed(){return Ht(this)?this._closedPromise:Q(Kt("closed"))}cancel(e=void 0){return Ht(this)?void 0===this._ownerReadableStream?Q(be("cancel")):pe(this,e):Q(Kt("cancel"))}read(e,t={}){if(!Ht(this))return Q(Kt("read"));if(!ArrayBuffer.isView(e))return Q(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return Q(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return Q(new TypeError("view's buffer must have non-zero byteLength"));if(Ge(e.buffer))return Q(new TypeError("view's buffer has been detached"));let r;try{r=function(e,t){var r;return Se(e,t),{min:Ce(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}(t,"options")}catch(e){return Q(e)}const o=r.min;if(0===o)return Q(new TypeError("options.min must be greater than 0"));if(function(e){return lt(e.constructor)}(e)){if(o>e.byteLength)return Q(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(o>e.length)return Q(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return Q(be("read from"));let n,i;const a=Y(((e,t)=>{n=e,i=t}));return Gt(this,e,o,{_chunkSteps:e=>n({value:e,done:!1}),_closeSteps:e=>n({value:e,done:!0}),_errorSteps:e=>i(e)}),a}releaseLock(){if(!Ht(this))throw Kt("releaseLock");void 0!==this._ownerReadableStream&&function(e){he(e),Yt(e,new TypeError("Reader was released"))}(this)}}function Ht(e){return!!F(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof Vt}function Gt(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 lt(e)?1:e.BYTES_PER_ELEMENT}(i),{byteOffset:s,byteLength:u}=t,l=r*a;let c;try{c=He(t.buffer)}catch(e){return void o._errorSteps(e)}const d={buffer:c,bufferByteLength:c.byteLength,byteOffset:s,byteLength:u,bytesFilled:0,minimumFill:l,elementSize:a,viewConstructor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(d),void Ut(n,o);if("closed"!==n._state){if(e._queueTotalSize>0){if(wt(e,d)){const t=mt(d);return Ot(e),void o._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return jt(e,t),void o._errorSteps(t)}}e._pendingPullIntos.push(d),Ut(n,o),ht(e)}else{const e=new i(d.buffer,d.byteOffset,0);o._closeSteps(e)}}(n._readableStreamController,t,r,o)}function Yt(e,t){const r=e._readIntoRequests;e._readIntoRequests=new ae,r.forEach((e=>{e._errorSteps(t)}))}function Kt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function Qt(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(nt(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function Jt(e){const{size:t}=e;return t||(()=>1)}function Xt(e,t){Se(e,t);const r=null==e?void 0:e.highWaterMark,o=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:Re(r),size:void 0===o?void 0:Zt(o,`${t} has member 'size' that`)}}function Zt(e,t){return Oe(e,t),t=>Re(e(t))}function er(e,t,r){return Oe(e,r),r=>ie(e,t,[r])}function tr(e,t,r){return Oe(e,r),()=>ie(e,t,[])}function rr(e,t,r){return Oe(e,r),r=>ne(e,t,[r])}function or(e,t,r){return Oe(e,r),(r,o)=>ie(e,t,[r,o])}function nr(e,t){if(!lr(e))throw new TypeError(`${t} is not a WritableStream.`)}Object.defineProperties(Vt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),U(Vt.prototype.cancel,"cancel"),U(Vt.prototype.read,"read"),U(Vt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Vt.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const ir="function"==typeof AbortController;class ar{constructor(e={},t={}){void 0===e?e=null:Pe(e,"First parameter");const r=Xt(t,"Second parameter"),o=function(e,t){Se(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:er(r,e,`${t} has member 'abort' that`),close:void 0===o?void 0:tr(o,e,`${t} has member 'close' that`),start:void 0===n?void 0:rr(n,e,`${t} has member 'start' that`),write:void 0===a?void 0:or(a,e,`${t} has member 'write' that`),type:i}}(e,"First parameter");if(ur(this),void 0!==o.type)throw new RangeError("Invalid type is specified");const n=Jt(r);!function(e,t,r,o){const n=Object.create(Er.prototype);let i,a,s,u;i=void 0!==t.start?()=>t.start(n):()=>{},a=void 0!==t.write?e=>t.write(e,n):()=>K(void 0),s=void 0!==t.close?()=>t.close():()=>K(void 0),u=void 0!==t.abort?e=>t.abort(e):()=>K(void 0),Ar(e,n,i,a,s,u,r,o)}(this,o,Qt(r,1),n)}get locked(){if(!lr(this))throw Lr("locked");return cr(this)}abort(e=void 0){return lr(this)?cr(this)?Q(new TypeError("Cannot abort a stream that already has a writer")):dr(this,e):Q(Lr("abort"))}close(){return lr(this)?cr(this)?Q(new TypeError("Cannot close a stream that already has a writer")):yr(this)?Q(new TypeError("Cannot close an already-closing stream")):fr(this):Q(Lr("close"))}getWriter(){if(!lr(this))throw Lr("getWriter");return sr(this)}}function sr(e){return new _r(e)}function ur(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new ae,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function lr(e){return!!F(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof ar}function cr(e){return void 0!==e._writer}function dr(e,t){var r;if("closed"===e._state||"errored"===e._state)return K(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 K(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let n=!1;"erroring"===o&&(n=!0,t=void 0);const i=Y(((r,o)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:o,_reason:t,_wasAlreadyErroring:n}}));return e._pendingAbortRequest._promise=i,n||hr(e,t),i}function fr(e){const t=e._state;if("closed"===t||"errored"===t)return Q(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=Y(((t,r)=>{const o={_resolve:t,_reject:r};e._closeRequest=o})),o=e._writer;var n;return void 0!==o&&e._backpressure&&"writable"===t&&Gr(o),st(n=e._writableStreamController,Tr,0),jr(n),r}function pr(e,t){"writable"!==e._state?br(e):hr(e,t)}function hr(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const o=e._writer;void 0!==o&&Sr(o,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&br(e)}function br(e){e._state="errored",e._writableStreamController[ue]();const t=e._storedError;if(e._writeRequests.forEach((e=>{e._reject(t)})),e._writeRequests=new ae,void 0===e._pendingAbortRequest)return void mr(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void mr(e);X(e._writableStreamController[se](r._reason),(()=>(r._resolve(),mr(e),null)),(t=>(r._reject(t),mr(e),null)))}function yr(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function mr(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&Br(t,e._storedError)}function vr(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){zr(e)}(r):Gr(r)),e._backpressure=t}Object.defineProperties(ar.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),U(ar.prototype.abort,"abort"),U(ar.prototype.close,"close"),U(ar.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ar.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class _r{constructor(e){if(Te(e,1,"WritableStreamDefaultWriter"),nr(e,"First parameter"),cr(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)!yr(e)&&e._backpressure?zr(this):Vr(this),Dr(this);else if("erroring"===t)$r(this,e._storedError),Dr(this);else if("closed"===t)Vr(this),Dr(this),Ur(this);else{const t=e._storedError;$r(this,t),Fr(this,t)}}get closed(){return gr(this)?this._closedPromise:Q(Wr("closed"))}get desiredSize(){if(!gr(this))throw Wr("desiredSize");if(void 0===this._ownerWritableStream)throw Mr("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:Ir(t._writableStreamController)}(this)}get ready(){return gr(this)?this._readyPromise:Q(Wr("ready"))}abort(e=void 0){return gr(this)?void 0===this._ownerWritableStream?Q(Mr("abort")):function(e,t){return dr(e._ownerWritableStream,t)}(this,e):Q(Wr("abort"))}close(){if(!gr(this))return Q(Wr("close"));const e=this._ownerWritableStream;return void 0===e?Q(Mr("close")):yr(e)?Q(new TypeError("Cannot close an already-closing stream")):wr(this)}releaseLock(){if(!gr(this))throw Wr("releaseLock");void 0!==this._ownerWritableStream&&Or(this)}write(e=void 0){return gr(this)?void 0===this._ownerWritableStream?Q(Mr("write to")):Pr(this,e):Q(Wr("write"))}}function gr(e){return!!F(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof _r}function wr(e){return fr(e._ownerWritableStream)}function Sr(e,t){"pending"===e._readyPromiseState?Hr(e,t):function(e,t){$r(e,t)}(e,t)}function Or(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Sr(e,r),function(e,t){"pending"===e._closedPromiseState?Br(e,t):function(e,t){Fr(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Pr(e,t){const r=e._ownerWritableStream,o=r._writableStreamController,n=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return kr(e,t),1}}(o,t);if(r!==e._ownerWritableStream)return Q(Mr("write to"));const i=r._state;if("errored"===i)return Q(r._storedError);if(yr(r)||"closed"===i)return Q(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return Q(r._storedError);const a=function(e){return Y(((t,r)=>{const o={_resolve:t,_reject:r};e._writeRequests.push(o)}))}(r);return function(e,t,r){try{st(e,t,r)}catch(t){return void kr(e,t)}const o=e._controlledWritableStream;yr(o)||"writable"!==o._state||vr(o,qr(e)),jr(e)}(o,t,n),a}Object.defineProperties(_r.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),U(_r.prototype.abort,"abort"),U(_r.prototype.close,"close"),U(_r.prototype.releaseLock,"releaseLock"),U(_r.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(_r.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Tr={};class Er{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Rr(this))throw Nr("abortReason");return this._abortReason}get signal(){if(!Rr(this))throw Nr("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!Rr(this))throw Nr("error");"writable"===this._controlledWritableStream._state&&xr(this,e)}[se](e){const t=this._abortAlgorithm(e);return Cr(this),t}[ue](){ut(this)}}function Rr(e){return!!F(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof Er}function Ar(e,t,r,o,n,i,a,s){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,ut(t),t._abortReason=void 0,t._abortController=function(){if(ir)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=s,t._strategyHWM=a,t._writeAlgorithm=o,t._closeAlgorithm=n,t._abortAlgorithm=i;const u=qr(t);vr(e,u),X(K(r()),(()=>(t._started=!0,jr(t),null)),(r=>(t._started=!0,pr(e,r),null)))}function Cr(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Ir(e){return e._strategyHWM-e._queueTotalSize}function jr(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void br(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Tr?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._clos