blob: b6029821f3905dae9639a7178b1a8fc1db45d302 [file] [log] [blame]
'use strict';(function(d){function B(a){"string"!==typeof a&&(a=String(a));if(/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(a))throw new e("Invalid character in header field name");return a.toLowerCase()}function P(a){"string"!==typeof a&&(a=String(a));var b;var c=0;for(b=a.length;c<b;c++){var g=a.charCodeAt(c);if(9!==g&&10!==g&&13!==g&&32!==g)break}for(b=a.length-1;b>c&&(g=a.charCodeAt(b),9===g||10===g||13===g||32===g);b--);a=a.substring(c,b+1);c=0;for(b=a.length;c<b;c++)if(g=a.charCodeAt(c),256<=g||0===g||
10===g||13===g)throw new e("Invalid character in header field value");return a}function V(a,b){throw new e("Immutable header cannot be modified");}function W(a,b){return!1}function X(a,b){a=a.toLowerCase();return-1<Y.indexOf(a)||a.startsWith("proxy-")||a.startsWith("sec-")?!0:!1}function Z(a,b){a=a.toLowerCase();return-1<aa.indexOf(a)||"content-type"===a&&(b=b.split(";")[0].toLowerCase(),-1<ba.indexOf(b))?!1:!0}function I(a,b){return-1<ca.indexOf(a.toLowerCase())?!0:!1}function h(a){this[l]=new F;
void 0===this[t]&&(this[t]=W);if(void 0!==a){if(null===a||"object"!==typeof a)throw new e("Constructing Headers with invalid parameters");a instanceof h?a.forEach(function(a,c){this.append(c,a)},this):C.isArray(a)?a.forEach(function(a){if(2!==a.length)throw new e("Constructing Headers with invalid parameters");this.append(a[0],a[1])},this):Object.getOwnPropertyNames(a).forEach(function(b){this.append(b,a[b])},this)}}function D(a,b){var c=da(h.prototype);c[t]=b;h.call(c,a);return c}function J(a){if(a.bodyUsed)return K(new e("Body was already read"));
if(null===a.body)return ea(new u(0));if(fa(a.body))return K(new e("ReadableStream was already locked"));var b=a.body.getReader(),c=[],g=0;return b.read().then(function ga(a){if(a.done){if(0===c.length)a=new u(0);else if(1===c.length)a=new u(c[0]);else{a=new u(g);for(var d=0,k=c.length,f=0;d<k;d++)a.set(c[d],f),f+=c[d].length}return a}return a.value instanceof u?(g+=a.value.length,c.push(a.value),b.read().then(ga)):K(new e("Invalid stream data type"))})}function Q(){this._initBody=function(a){this[L]=
!1;this[m]=null===a||void 0===a?null:a instanceof M?a:new M({start:function(b){if(a)if("string"===typeof a)b.enqueue(FetchInternal.encodeToUTF8(a));else if(R.prototype.isPrototypeOf(a))b.enqueue(new u(a));else if(ha(a))b.enqueue(new u(a.buffer));else throw new e("Unsupported BodyInit type");b.close()}});this[r].get("content-type")||"string"===typeof a&&this[r].set("content-type","text/plain;charset=UTF-8")};N(this,{body:{get:function(){return this[m]}},bodyUsed:{get:function(){return this[L]?!0:this[m]?
!!ia(this[m]):!1}}});this.arrayBuffer=function(){return J(this).then(function(a){return a.buffer})};this.text=function(){return J(this).then(function(a){return FetchInternal.decodeFromUTF8(a)})};this.json=function(){return this.text().then(JSON.parse)};return this}function v(a,b){var c=void 0!==b&&null!==b&&void 0===b.cloneBody;b=b||{};var g=b.body||b.cloneBody,d=b.headers;if(a instanceof v){if(a.bodyUsed)throw new e("Request body was already read");this[w]=a.url;this[y]=a.cache;this[z]=a.credentials;
void 0===d&&(d=a.headers);this[A]=a.integrity;this[x]=a.method;this[n]=a.mode;c&&"navigate"===this[n]&&(this[n]="same-origin");this[E]=a.redirect;g||null===a.body||(g=a.body,a[L]=!0)}else{this[w]=String(a);if(!FetchInternal.isUrlValid(this[w],!1))throw new e("Invalid request URL");this[n]="cors";this[z]="omit"}if(void 0!==b.window&&null!==b.window)throw new e("Invalid request window");this[y]=b.cache||this[y]||"default";if(-1===ja.indexOf(this[y]))throw new e("Invalid request cache mode");this[z]=
b.credentials||this[z]||"omit";if(-1===ka.indexOf(this[z]))throw new e("Invalid request credentials");void 0!==b.integrity?this[A]=b.integrity:void 0===this[A]&&(this[A]="");a=(b.method||this[x]||"GET").toUpperCase();if(-1===la.indexOf(a))throw new e("Invalid request method");this[x]=a;if(b.mode&&-1===ma.indexOf(b.mode))throw new e("Invalid request mode");this[n]=b.mode||this[n]||"no-cors";if("no-cors"===this[n]){if(-1===na.indexOf(this[x]))throw new e("Invalid request method for no-cors");if(""!==
this[A])throw new e("Request integrity data is not allowed with no-cors");}if("same-origin"!==this[n]&&"only-if-cached"===this[y])throw new e("Request mode must be same-origin for only-if-cached");this[E]=b.redirect||this[E]||"follow";if(-1===oa.indexOf(this[E]))throw new e("Invalid request redirect mode");this[r]="no-cors"===this[n]?D(d,Z):D(d,X);if(("GET"===this[x]||"HEAD"===this[x])&&g)throw new e("Request body is not allowed for GET or HEAD");this._initBody(g)}function pa(a,b){var c=D(void 0,
b);a.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(a){var b=a.split(":");if(a=b.shift().trim())b=b.join(":").trim(),c.append(a,b)});return c}function p(a,b){b||(b={});this[G]="default";this[q]="status"in b?b.status:200;if(200>this[q]||599<this[q])throw new S("Invalid response status");this[T]=200<=this[q]&&300>this[q];if("statusText"in b){var c=b.statusText;for(var g=0,d=c.length,f;g<d;g++)if(f=c.charCodeAt(g),9!==f&&(32>f||255<f||127===f))throw e("Invalid response status text");}else c=
"OK";this[H]=c;this[r]=D(b.headers,I);this[w]=b.url||"";if(a&&-1<qa.indexOf(this[q]))throw new e("Response body is not allowed with a null body status");this._initBody(a)}if(!d.fetch){var C=d.Array,R=d.ArrayBuffer,da=d.Object.create,N=d.Object.defineProperties,f=d.Symbol,ra=f.iterator,F=d.Map,S=d.RangeError,e=d.TypeError,u=d.Uint8Array,O=d.Promise,K=O.reject,ea=O.resolve,M=d.ReadableStream,U=d.ReadableStreamTee,ia=d.IsReadableStreamDisturbed,fa=d.IsReadableStreamLocked,m=f("body"),L=f("bodyUsed"),
y=f("cache"),z=f("credentials"),t=f("guardCallback"),r=f("headers"),A=f("integrity"),l=f("map"),x=f("method"),n=f("mode"),T=f("ok"),E=f("redirect"),q=f("status"),H=f("statusText"),G=f("type"),w=f("url"),Y="accept-charset accept-encoding access-control-request-headers access-control-request-method connection content-length cookie cookie2 date dnt expect host keep-alive origin referer te trailer transfer-encoding upgrade via".split(" "),ca=["set-cookie","set-cookie2"],aa=["accept","accept-language",
"content-language"],ba=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],ja="default no-store reload no-cache force-cache only-if-cached".split(" "),ka=["omit","same-origin","include"],la="DELETE GET HEAD OPTIONS POST PUT".split(" "),na=["GET","HEAD","POST"],ma=["same-origin","no-cors","cors"],oa=["follow","error","manual"],qa=[101,204,205,304],sa=[301,302,303,307,308],ta="[object Int8Array];[object Uint8Array];[object Uint8ClampedArray];[object Int16Array];[object Uint16Array];[object Int32Array];[object Uint32Array];[object Float32Array];[object Float64Array]".split(";"),
ha=R.isView||function(a){return a&&-1<ta.indexOf(Object.prototype.toString.call(a))};h.prototype.append=function(a,b){if(2!==arguments.length)throw e("Invalid parameters to append");a=B(a);b=P(b);this[t](a,b)||(this[l].has(a)?this[l].set(a,this[l].get(a)+", "+b):this[l].set(a,b))};h.prototype["delete"]=function(a){if(1!==arguments.length)throw e("Invalid parameters to delete");this[t](a,"invalid")||this[l].delete(B(a))};h.prototype.get=function(a){if(1!==arguments.length)throw e("Invalid parameters to get");
a=B(a);var b=this[l].get(a);return void 0!==b?b:null};h.prototype.has=function(a){if(1!==arguments.length)throw e("Invalid parameters to has");return this[l].has(B(a))};h.prototype.set=function(a,b){if(2!==arguments.length)throw e("Invalid parameters to set");a=B(a);b=P(b);this[t](a,b)||this[l].set(a,b)};h.prototype.forEach=function(a,b){var c=this;C.from(this[l].entries()).sort().forEach(function(e){a.call(b,e[1],e[0],c)})};h.prototype.keys=function(){return(new F(C.from(this[l].entries()).sort())).keys()};
h.prototype.values=function(){return(new F(C.from(this[l].entries()).sort())).values()};h.prototype.entries=function(){return(new F(C.from(this[l].entries()).sort())).entries()};h.prototype[ra]=h.prototype.entries;v.prototype.clone=function(){var a=null;null!==this[m]&&(a=U(this[m],!0),this[m]=a[0],a=a[1]);return new v(this,{cloneBody:a})};N(v.prototype,{cache:{get:function(){return this[y]}},credentials:{get:function(){return this[z]}},headers:{get:function(){return this[r]}},integrity:{get:function(){return this[A]}},
method:{get:function(){return this[x]}},mode:{get:function(){return this[n]}},redirect:{get:function(){return this[E]}},url:{get:function(){return this[w]}}});Q.call(v.prototype);Q.call(p.prototype);p.prototype.clone=function(){var a=null;null!==this[m]&&(a=U(this[m],!0),this[m]=a[0],a=a[1]);return new p(a,{status:this[q],statusText:this[H],headers:D(this[r],I),url:this[w]})};N(p.prototype,{headers:{get:function(){return this[r]}},ok:{get:function(){return this[T]}},status:{get:function(){return this[q]}},
statusText:{get:function(){return this[H]}},type:{get:function(){return this[G]}},url:{get:function(){return this[w]}}});p.error=function(){var a=new p(null);a[r][t]=V;a[G]="error";a[q]=0;a[H]="";return a};p.redirect=function(a,b){if(!FetchInternal.isUrlValid(a,!0))throw new e("Invalid URL for response redirect");void 0===b&&(b=302);if(-1===sa.indexOf(b))throw new S("Invalid status code for response redirect");return new p(null,{status:b,headers:{location:a}})};d.Headers=h;d.Request=v;d.Response=
p;d.fetch=function(a,b){return new O(function(c,d){var g=!1,f=new v(a,b),k=new XMLHttpRequest,h=null,l=new M({start:function(a){h=a},cancel:function(a){g=!0;k.abort()}});k.onload=function(){h.close()};k.onreadystatechange=function(){if(k.readyState===k.HEADERS_RECEIVED){var a={status:k.status,statusText:k.statusText,headers:pa(k.getAllResponseHeaders()||"",I)};a.url="responseURL"in k?k.responseURL:a.headers.get("X-Request-URL");try{var b=new p(l,a);b[G]="basic";c(b)}catch(ua){d(ua)}}};k.onerror=function(){h.error(new e("Network request failed"));
d(new e("Network request failed"))};k.ontimeout=function(){h.error(new e("Network request failed"));d(new e("Network request failed"))};k.open(f.method,f.url,!0);"include"===f.credentials&&(k.withCredentials=!0);f.headers.forEach(function(a,b){k.setRequestHeader(b,a)});var m=function(a){g||h.enqueue(a)};null===f.body?k.fetch(m,null):J(f).then(function(a){k.fetch(m,a)})})};d.fetch.polyfill=!0}})(this);