diff --git a/.npmignore b/.npmignore index dc3a8724..3fd9e83f 100644 --- a/.npmignore +++ b/.npmignore @@ -4,7 +4,7 @@ docs-config.json test.js test/ reports/ -csio-templates/ +contentstack-templates/ js-sdk-reference/ examples/ - +mocktest.json diff --git a/dist/nativescript/contentstack.js b/dist/nativescript/contentstack.js index 04987cfe..5c1df4c8 100755 --- a/dist/nativescript/contentstack.js +++ b/dist/nativescript/contentstack.js @@ -600,6 +600,8 @@ var Stack = function () { this.config = _config2.default; this.cachePolicy = _index2.default.policies.IGNORE_CACHE; this.provider = _index2.default.providers('localstorage'); + console.error(stack_arguments.length); + switch (stack_arguments.length) { case 1: if (_typeof(stack_arguments[0]) === "object" && typeof stack_arguments[0].api_key === "string" && typeof stack_arguments[0].delivery_token === "string" && typeof stack_arguments[0].environment === "string") { @@ -612,7 +614,36 @@ var Stack = function () { } else { console.error("Kindly provide valid object parameters. The specified API Key, Delivery Token, or Environment Name is invalid."); } - case (3, 4, 5): + case 3: + if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") { + this.headers = { + api_key: stack_arguments[0], + access_token: stack_arguments[1] + }; + this.environment = stack_arguments[2]; + return this; + } else { + console.error("Kindly provide valid string parameters."); + } + case 4: + if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") { + this.headers = { + api_key: stack_arguments[0], + access_token: stack_arguments[1] + }; + this.environment = stack_arguments[2]; + return this; + } else { + console.error("Kindly provide valid string parameters."); + } + if (stack_arguments[3]) { + if (typeof stack_arguments[3] === "string" && stack_arguments[3].region !== "us" && stack_arguments[3].region === "eu") { + _config2.default['host'] = stack_arguments[0].region + "-" + "cdn.contentstack.com"; + } else if (_typeof(stack_arguments[3]) === 'object') { + this.fetchOptions = stack_arguments[3]; + } + } + case 5: if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") { this.headers = { api_key: stack_arguments[0], @@ -630,7 +661,6 @@ var Stack = function () { this.fetchOptions = stack_arguments[3]; } } - if (stack_arguments[4] && _typeof(stack_arguments[4]) === 'object') { this.fetchOptions = stack_arguments[3]; } diff --git a/dist/node/contentstack.js b/dist/node/contentstack.js index ef783a50..a563d8c7 100644 --- a/dist/node/contentstack.js +++ b/dist/node/contentstack.js @@ -696,6 +696,8 @@ var Stack = function () { this.config = _config2.default; this.cachePolicy = _index2.default.policies.IGNORE_CACHE; this.provider = _index2.default.providers('localstorage'); + console.error(stack_arguments.length); + switch (stack_arguments.length) { case 1: if (_typeof(stack_arguments[0]) === "object" && typeof stack_arguments[0].api_key === "string" && typeof stack_arguments[0].delivery_token === "string" && typeof stack_arguments[0].environment === "string") { @@ -708,7 +710,36 @@ var Stack = function () { } else { console.error("Kindly provide valid object parameters. The specified API Key, Delivery Token, or Environment Name is invalid."); } - case (3, 4, 5): + case 3: + if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") { + this.headers = { + api_key: stack_arguments[0], + access_token: stack_arguments[1] + }; + this.environment = stack_arguments[2]; + return this; + } else { + console.error("Kindly provide valid string parameters."); + } + case 4: + if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") { + this.headers = { + api_key: stack_arguments[0], + access_token: stack_arguments[1] + }; + this.environment = stack_arguments[2]; + return this; + } else { + console.error("Kindly provide valid string parameters."); + } + if (stack_arguments[3]) { + if (typeof stack_arguments[3] === "string" && stack_arguments[3].region !== "us" && stack_arguments[3].region === "eu") { + _config2.default['host'] = stack_arguments[0].region + "-" + "cdn.contentstack.com"; + } else if (_typeof(stack_arguments[3]) === 'object') { + this.fetchOptions = stack_arguments[3]; + } + } + case 5: if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") { this.headers = { api_key: stack_arguments[0], @@ -726,7 +757,6 @@ var Stack = function () { this.fetchOptions = stack_arguments[3]; } } - if (stack_arguments[4] && _typeof(stack_arguments[4]) === 'object') { this.fetchOptions = stack_arguments[3]; } diff --git a/dist/react-native/contentstack.js b/dist/react-native/contentstack.js index 04987cfe..5c1df4c8 100755 --- a/dist/react-native/contentstack.js +++ b/dist/react-native/contentstack.js @@ -600,6 +600,8 @@ var Stack = function () { this.config = _config2.default; this.cachePolicy = _index2.default.policies.IGNORE_CACHE; this.provider = _index2.default.providers('localstorage'); + console.error(stack_arguments.length); + switch (stack_arguments.length) { case 1: if (_typeof(stack_arguments[0]) === "object" && typeof stack_arguments[0].api_key === "string" && typeof stack_arguments[0].delivery_token === "string" && typeof stack_arguments[0].environment === "string") { @@ -612,7 +614,36 @@ var Stack = function () { } else { console.error("Kindly provide valid object parameters. The specified API Key, Delivery Token, or Environment Name is invalid."); } - case (3, 4, 5): + case 3: + if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") { + this.headers = { + api_key: stack_arguments[0], + access_token: stack_arguments[1] + }; + this.environment = stack_arguments[2]; + return this; + } else { + console.error("Kindly provide valid string parameters."); + } + case 4: + if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") { + this.headers = { + api_key: stack_arguments[0], + access_token: stack_arguments[1] + }; + this.environment = stack_arguments[2]; + return this; + } else { + console.error("Kindly provide valid string parameters."); + } + if (stack_arguments[3]) { + if (typeof stack_arguments[3] === "string" && stack_arguments[3].region !== "us" && stack_arguments[3].region === "eu") { + _config2.default['host'] = stack_arguments[0].region + "-" + "cdn.contentstack.com"; + } else if (_typeof(stack_arguments[3]) === 'object') { + this.fetchOptions = stack_arguments[3]; + } + } + case 5: if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") { this.headers = { api_key: stack_arguments[0], @@ -630,7 +661,6 @@ var Stack = function () { this.fetchOptions = stack_arguments[3]; } } - if (stack_arguments[4] && _typeof(stack_arguments[4]) === 'object') { this.fetchOptions = stack_arguments[3]; } diff --git a/dist/web/contentstack.js b/dist/web/contentstack.js index 34370cb6..99eb0575 100755 --- a/dist/web/contentstack.js +++ b/dist/web/contentstack.js @@ -1,8 +1,8 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Contentstack=t():e.Contentstack=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=15)}([function(e,t,r){"use strict";(function(e){function n(e){return e&&e.__esModule?e:{default:e}}function o(e){return function(){switch(this._query[e]=this._query[e]||{},arguments.length){case 1:if(Array.isArray(arguments[0])||"string"==typeof arguments[0]){var t=this._query[e].BASE||[];return t=t.concat(arguments[0]),this._query[e].BASE=t,this}console.error("Kindly provide valid parameters");break;case 2:if("string"==typeof arguments[0]&&(Array.isArray(arguments[1])||"string"==typeof arguments[1])){var r=this._query[e][arguments[0]]||[];return r=r.concat(arguments[1]),this._query[e][arguments[0]]=r,this}console.error("Kindly provide valid parameters");break;default:console.error("Kindly provide valid parameters")}}}function i(e){var t=void 0===e?"undefined":p(e);switch(t){case"object":t,Array.isArray(e)&&(t="array");break;default:t}return t}function s(e,t){var r=this;return function e(t,n){for(var o in n)"object"==r._type(n[o])&&r._type(t[o])==r._type(n[o])?e(t[o],n[o]):"array"==r._type(n[o])&&r._type(t[o])==r._type(n[o])?t[o]=t[o].concat(n[o]):t[o]=n[o]}(e,t),e}function u(e,t){if(e&&t)for(var r in t)e[r]=t[r];return e}function a(){return"undefined"!=typeof window&&"object"===(void 0===e?"undefined":p(e))&&"browser"===e.title}function c(e,t,r){if(e&&e.requestParams){var n=u({},e.requestParams.body?e.requestParams.body.query||{}:{});return n.environment_uid&&(delete n.environment_uid,n.environment=e.environment),n.environment=e.environment,{content_type_uid:e.content_type_uid,locale:n.locale||"en-us",query:n,entry_uid:e.entry_uid,asset_uid:e.asset_uid,single:t||"false",toJSON:r||"false",api_key:e.requestParams.headers?e.requestParams.headers.api_key:""}}}function f(e){try{var t=l(JSON.stringify(e)),r=[];return r.push(e.content_type_uid),r.push(e.locale),e.entry_uid&&r.push(e.entry_uid),e.asset_uid&&r.push(e.asset_uid),r.push(t),r.join(".")}catch(e){}}function l(e){var t=0,r=void 0,n=void 0,o=void 0;if(0===e.length)return t;for(r=0,o=e.length;r=-1&&e<4?this._query?this.queryCachePolicy=e:this.cachePolicy=e:console.error("Kindly provide the valid policy"),this}},{key:"setCacheProvider",value:function(e){return e&&"object"===(void 0===e?"undefined":s(e))&&(this.provider=e),this}},{key:"clearByQuery",value:function(){if(this.provider&&"function"==typeof this.provider.clearByQuery)return this.provider.clearByQuery.apply(this.provider,arguments)}},{key:"clearByContentType",value:function(){if(this.provider&&"function"==typeof this.provider.clearByContentType)return this.provider.clearByContentType.apply(this.provider,arguments)}},{key:"clearAll",value:function(){if(this.provider&&"function"==typeof this.provider.clearAll)return this.provider.clearAll.apply(this.provider,arguments)}},{key:"getCacheProvider",value:function(){return this.provider}},{key:"ContentType",value:function(e){return e&&"string"==typeof e&&(this.content_type_uid=e,this.type="contentType"),this}},{key:"Entry",value:function(e){var t=new h.default;return e&&"string"==typeof e&&(t.entry_uid=e),l.merge(t,this)}},{key:"fetch",value:function(e){var t={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types+this.content_type_uid,body:{_method:"GET",environment:this.environment}},r=Object.assign({},this.fetchOptions,e);return(0,b.default)(t,r)}},{key:"Assets",value:function(e){if(this.type="asset",e&&"string"==typeof e){var t=new p.default;return t.asset_uid=e,l.merge(t,this)}return this}},{key:"Query",value:function(){var e=new _.default;return l.merge(e,this)}},{key:"getLastActivities",value:function(){var e={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types,body:{_method:"GET",only_last_activity:!0,environment:this.environment}};return(0,b.default)(e,this.fetchOptions)}},{key:"getContentTypes",value:function(e){var t={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types,body:{_method:"GET",environment:this.environment}};if(e&&void 0!==e)for(var r in e)t.body[r]=e[r];return(0,b.default)(t,this.fetchOptions)}},{key:"sync",value:function(e,t){this._query={},this._query=Object.assign(this._query,e),this.requestParams={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.sync,body:{_method:"GET",query:this._query}};var r=Object.assign({},this.fetchOptions,t);return l.sendRequest(this,r)}},{key:"imageTransform",value:function(e,t){if(e&&"string"==typeof e&&"object"===(void 0===t?"undefined":s(t))&&void 0===t.length){var r=[];for(var n in t)r.push(n+"="+t[n]);e+=e.indexOf("?")<=-1?"?"+r.join("&"):"&"+r.join("&")}return e}}]),e}();t.default=O},function(e,t,r){"use strict";function n(e,t){return new Promise(function(r,n){var i=void 0,s=e.url,c=e.headers;c["Content-Type"]="application/json; charset=UTF-8",c["X-User-Agent"]="contentstack-web/"+a,e.body&&"object"===o(e.body)&&(delete e.body._method,"object"===o(e.body.query)&&0===Object.keys(e.body.query).length&&delete e.body.query,i=function e(t,r){var n=[],i=void 0;if("object"===(void 0===t?"undefined":o(t))&&void 0!==t.length)for(var s=0,u=t.length;s1)for(var r=1;r=-1&&e<4?this._query?this.queryCachePolicy=e:this.cachePolicy=e:console.error("Kindly provide the valid policy"),this}},{key:"includeReference",value:function(){for(var e=arguments.length,t=Array(e),r=0;r=-1&&e<4?this._query?this.queryCachePolicy=e:this.cachePolicy=e:console.error("Kindly provide the valid policy"),this}},{key:"setCacheProvider",value:function(e){return e&&"object"===(void 0===e?"undefined":s(e))&&(this.provider=e),this}},{key:"clearByQuery",value:function(){if(this.provider&&"function"==typeof this.provider.clearByQuery)return this.provider.clearByQuery.apply(this.provider,arguments)}},{key:"clearByContentType",value:function(){if(this.provider&&"function"==typeof this.provider.clearByContentType)return this.provider.clearByContentType.apply(this.provider,arguments)}},{key:"clearAll",value:function(){if(this.provider&&"function"==typeof this.provider.clearAll)return this.provider.clearAll.apply(this.provider,arguments)}},{key:"getCacheProvider",value:function(){return this.provider}},{key:"ContentType",value:function(e){return e&&"string"==typeof e&&(this.content_type_uid=e,this.type="contentType"),this}},{key:"Entry",value:function(e){var t=new h.default;return e&&"string"==typeof e&&(t.entry_uid=e),l.merge(t,this)}},{key:"fetch",value:function(e){var t={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types+this.content_type_uid,body:{_method:"GET",environment:this.environment}},r=Object.assign({},this.fetchOptions,e);return(0,b.default)(t,r)}},{key:"Assets",value:function(e){if(this.type="asset",e&&"string"==typeof e){var t=new p.default;return t.asset_uid=e,l.merge(t,this)}return this}},{key:"Query",value:function(){var e=new _.default;return l.merge(e,this)}},{key:"getLastActivities",value:function(){var e={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types,body:{_method:"GET",only_last_activity:!0,environment:this.environment}};return(0,b.default)(e,this.fetchOptions)}},{key:"getContentTypes",value:function(e){var t={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types,body:{_method:"GET",environment:this.environment}};if(e&&void 0!==e)for(var r in e)t.body[r]=e[r];return(0,b.default)(t,this.fetchOptions)}},{key:"sync",value:function(e,t){this._query={},this._query=Object.assign(this._query,e),this.requestParams={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.sync,body:{_method:"GET",query:this._query}};var r=Object.assign({},this.fetchOptions,t);return l.sendRequest(this,r)}},{key:"imageTransform",value:function(e,t){if(e&&"string"==typeof e&&"object"===(void 0===t?"undefined":s(t))&&void 0===t.length){var r=[];for(var n in t)r.push(n+"="+t[n]);e+=e.indexOf("?")<=-1?"?"+r.join("&"):"&"+r.join("&")}return e}}]),e}();t.default=O},function(e,t,r){"use strict";function n(e,t){return new Promise(function(r,n){var i=void 0,s=e.url,c=e.headers;c["Content-Type"]="application/json; charset=UTF-8",c["X-User-Agent"]="contentstack-web/"+a,e.body&&"object"===o(e.body)&&(delete e.body._method,"object"===o(e.body.query)&&0===Object.keys(e.body.query).length&&delete e.body.query,i=function e(t,r){var n=[],i=void 0;if("object"===(void 0===t?"undefined":o(t))&&void 0!==t.length)for(var s=0,u=t.length;s1)for(var r=1;r=-1&&e<4?this._query?this.queryCachePolicy=e:this.cachePolicy=e:console.error("Kindly provide the valid policy"),this}},{key:"includeReference",value:function(){for(var e=arguments.length,t=Array(e),r=0;r-1?t:e}function v(e,t){t=t||{};var r=t.body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new u(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,r||null==e._bodyInit||(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new u(t.headers)),this.method=p(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function _(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(o))}}),t}function m(e){var t=new u;return e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();t.append(n,o)}}),t}function b(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}function g(e,t){return new Promise(function(r,n){function o(){s.abort()}var i=new v(e,t);if(i.signal&&i.signal.aborted)return n(new T("Aborted","AbortError"));var s=new XMLHttpRequest;s.onload=function(){var e={status:s.status,statusText:s.statusText,headers:m(s.getAllResponseHeaders()||"")};e.url="responseURL"in s?s.responseURL:e.headers.get("X-Request-URL");var t="response"in s?s.response:s.responseText;r(new b(t,e))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.onabort=function(){n(new T("Aborted","AbortError"))},s.open(i.method,i.url,!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&q.blob&&(s.responseType="blob"),i.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),i.signal&&(i.signal.addEventListener("abort",o),s.onreadystatechange=function(){4===s.readyState&&i.signal.removeEventListener("abort",o)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})}Object.defineProperty(t,"__esModule",{value:!0}),t.Headers=u,t.Request=v,t.Response=b,t.fetch=g;var q={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(q.arrayBuffer)var w=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],O=ArrayBuffer.isView||function(e){return e&&w.indexOf(Object.prototype.toString.call(e))>-1};u.prototype.append=function(e,t){e=o(e),t=i(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},u.prototype.delete=function(e){delete this.map[o(e)]},u.prototype.get=function(e){return e=o(e),this.has(e)?this.map[e]:null},u.prototype.has=function(e){return this.map.hasOwnProperty(o(e))},u.prototype.set=function(e,t){this.map[o(e)]=i(t)},u.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},u.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),s(e)},u.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),s(e)},u.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),s(e)},q.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var P=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},d.call(v.prototype),d.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},b.error=function(){var e=new b(null,{status:0,statusText:""});return e.type="error",e};var j=[301,302,303,307,308];b.redirect=function(e,t){if(-1===j.indexOf(t))throw new RangeError("Invalid status code");return new b(null,{status:t,headers:{location:e}})};var T=t.DOMException=self.DOMException;try{new T}catch(e){t.DOMException=T=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},T.prototype=Object.create(Error.prototype),T.prototype.constructor=T}g.polyfill=!0,self.fetch||(self.fetch=g,self.Headers=u,self.Request=v,self.Response=b)},function(e,t,r){"use strict";function n(e,t){!t&&e&&e.length&&e.push("");var r=void 0,n=i.getKeys(),o=i.getStorage();if(e&&e.length){r=e.join(".");for(var s=0,u=n.length;s-1?t:e}function v(e,t){t=t||{};var r=t.body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new u(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,r||null==e._bodyInit||(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new u(t.headers)),this.method=p(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function _(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(o))}}),t}function m(e){var t=new u;return e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();t.append(n,o)}}),t}function b(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}function g(e,t){return new Promise(function(r,n){function o(){s.abort()}var i=new v(e,t);if(i.signal&&i.signal.aborted)return n(new T("Aborted","AbortError"));var s=new XMLHttpRequest;s.onload=function(){var e={status:s.status,statusText:s.statusText,headers:m(s.getAllResponseHeaders()||"")};e.url="responseURL"in s?s.responseURL:e.headers.get("X-Request-URL");var t="response"in s?s.response:s.responseText;r(new b(t,e))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.onabort=function(){n(new T("Aborted","AbortError"))},s.open(i.method,i.url,!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&q.blob&&(s.responseType="blob"),i.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),i.signal&&(i.signal.addEventListener("abort",o),s.onreadystatechange=function(){4===s.readyState&&i.signal.removeEventListener("abort",o)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})}Object.defineProperty(t,"__esModule",{value:!0}),t.Headers=u,t.Request=v,t.Response=b,t.fetch=g;var q={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(q.arrayBuffer)var w=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],O=ArrayBuffer.isView||function(e){return e&&w.indexOf(Object.prototype.toString.call(e))>-1};u.prototype.append=function(e,t){e=o(e),t=i(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},u.prototype.delete=function(e){delete this.map[o(e)]},u.prototype.get=function(e){return e=o(e),this.has(e)?this.map[e]:null},u.prototype.has=function(e){return this.map.hasOwnProperty(o(e))},u.prototype.set=function(e,t){this.map[o(e)]=i(t)},u.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},u.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),s(e)},u.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),s(e)},u.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),s(e)},q.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var P=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},d.call(v.prototype),d.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},b.error=function(){var e=new b(null,{status:0,statusText:""});return e.type="error",e};var j=[301,302,303,307,308];b.redirect=function(e,t){if(-1===j.indexOf(t))throw new RangeError("Invalid status code");return new b(null,{status:t,headers:{location:e}})};var T=t.DOMException=self.DOMException;try{new T}catch(e){t.DOMException=T=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},T.prototype=Object.create(Error.prototype),T.prototype.constructor=T}g.polyfill=!0,self.fetch||(self.fetch=g,self.Headers=u,self.Request=v,self.Response=b)},function(e,t,r){"use strict";function n(e,t){!t&&e&&e.length&&e.push("");var r=void 0,n=i.getKeys(),o=i.getStorage();if(e&&e.length){r=e.join(".");for(var s=0,u=n.length;s