whale-request
Version:
A Component Library for http request
4 lines (3 loc) • 32.6 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).WhaleRequest={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var n=r((function(t){function e(t,e,r,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=t.apply(r,n);function u(t){e(i,o,a,u,c,"next",t)}function c(t){e(i,o,a,u,c,"throw",t)}u(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports})),o=e(n),a=e(r((function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports}))),i=r((function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})),u=e(i),c=r((function(t){var e=i.default;t.exports=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports})),s=r((function(t){var e=i.default;t.exports=function(t){var r=c(t,"string");return"symbol"==e(r)?r:r+""},t.exports.__esModule=!0,t.exports.default=t.exports})),f=e(r((function(t){function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}t.exports=function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports}))),p=r((function(t){var e=i.default;function r(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
t.exports=r=function(){return o},t.exports.__esModule=!0,t.exports.default=t.exports;var n,o={},a=Object.prototype,i=a.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},s=c.iterator||"@@iterator",f=c.asyncIterator||"@@asyncIterator",p=c.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(n){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,a=Object.create(o.prototype),i=new T(n||[]);return u(a,"_invoke",{value:P(t,r,i)}),a}function v(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}o.wrap=h;var y="suspendedStart",d="suspendedYield",b="executing",g="completed",m={};function w(){}function _(){}function x(){}var j={};l(j,s,(function(){return this}));var k=Object.getPrototypeOf,O=k&&k(k(M([])));O&&O!==a&&i.call(O,s)&&(j=O);var E=x.prototype=w.prototype=Object.create(j);function S(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function I(t,r){function n(o,a,u,c){var s=v(t[o],t,a);if("throw"!==s.type){var f=s.arg,p=f.value;return p&&"object"==e(p)&&i.call(p,"__await")?r.resolve(p.__await).then((function(t){n("next",t,u,c)}),(function(t){n("throw",t,u,c)})):r.resolve(p).then((function(t){f.value=t,u(f)}),(function(t){return n("throw",t,u,c)}))}c(s.arg)}var o;u(this,"_invoke",{value:function(t,e){function a(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(a,a):a()}})}function P(t,e,r){var o=y;return function(a,i){if(o===b)throw Error("Generator is already running");if(o===g){if("throw"===a)throw i;return{value:n,done:!0}}for(r.method=a,r.arg=i;;){var u=r.delegate;if(u){var c=A(u,r);if(c){if(c===m)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===y)throw o=g,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=b;var s=v(t,e,r);if("normal"===s.type){if(o=r.done?g:d,s.arg===m)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=g,r.method="throw",r.arg=s.arg)}}}function A(t,e){var r=e.method,o=t.iterator[r];if(o===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,A(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var a=v(o,t.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,m;var i=a.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,m):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(t){if(t||""===t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function e(){for(;++o<t.length;)if(i.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=n,e.done=!0,e};return a.next=a}}throw new TypeError(e(t)+" is not iterable")}return _.prototype=x,u(E,"constructor",{value:x,configurable:!0}),u(x,"constructor",{value:_,configurable:!0}),_.displayName=l(x,p,"GeneratorFunction"),o.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,l(t,p,"GeneratorFunction")),t.prototype=Object.create(E),t},o.awrap=function(t){return{__await:t}},S(I.prototype),l(I.prototype,f,(function(){return this})),o.AsyncIterator=I,o.async=function(t,e,r,n,a){void 0===a&&(a=Promise);var i=new I(h(t,e,r,n),a);return o.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(E),l(E,p,"Generator"),l(E,s,(function(){return this})),l(E,"toString",(function(){return"[object Generator]"})),o.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},o.values=M,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(C),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,o){return u.type="throw",u.arg=t,e.next=r,o&&(e.method="next",e.arg=n),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:M(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),m}},o}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})),l=p(),h=l;try{regeneratorRuntime=l}catch(t){"object"===("undefined"==typeof globalThis?"undefined":u(globalThis))?globalThis.regeneratorRuntime=l:Function("r","regeneratorRuntime = r")(l)}var v=function(){return f((function t(){a(this,t),this.storage=localStorage}),[{key:"get",value:(n=o(h.mark((function t(e){var r;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this.storage.getItem(e))){t.next=3;break}return t.abrupt("return",JSON.parse(r));case 3:return t.abrupt("return",void 0);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"set",value:(r=o(h.mark((function t(e,r){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.storage.setItem(e,JSON.stringify(r));case 1:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"delete",value:(e=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.storage.removeItem(e);case 1:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"has",value:(t=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null!==this.storage.getItem(e));case 1:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})}]);var t,e,r,n}();function y(){return new v}var d=function(){return f((function t(){a(this,t),this.storage=sessionStorage}),[{key:"get",value:(n=o(h.mark((function t(e){var r;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this.storage.getItem(e))){t.next=3;break}return t.abrupt("return",JSON.parse(r));case 3:return t.abrupt("return",void 0);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"set",value:(r=o(h.mark((function t(e,r){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.storage.setItem(e,JSON.stringify(r));case 1:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"delete",value:(e=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.storage.removeItem(e);case 1:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"has",value:(t=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null!==this.storage.getItem(e));case 1:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})}]);var t,e,r,n}();function b(){return new d}var g=function(){function t(e){a(this,t),this.store=e}return f(t,[{key:"get",value:(u=o(h.mark((function t(e){var r;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(null==(r=t.sent)||!r.noExpire){t.next=7;break}return t.abrupt("return",r.value);case 7:if(!(r&&r.expiration>Date.now())){t.next=11;break}return t.abrupt("return",r.value);case 11:if(!r){t.next=14;break}return t.next=14,this.store.delete(e);case 14:return t.abrupt("return",void 0);case 15:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"getNormal",value:(i=o(h.mark((function t(e){var r;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:return r=t.sent,t.abrupt("return",null==r?void 0:r.value);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"set",value:(n=o(h.mark((function t(e,r,n){var o,a;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=0,a=!1,n?o=Date.now()+n:a=!0,t.next=5,this.store.set(e,{value:r,expiration:o,noExpire:a});case 5:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return n.apply(this,arguments)})},{key:"delete",value:(r=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.delete(e);case 2:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"has",value:(e=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.store.has(e));case 1:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}],[{key:"create",value:function(e){return new t(e)}}]);var e,r,n,i,u}(),m={memoryCache:{},persistCache:{}};function w(t){return m.memoryCache||(m.memoryCache=b()),m.persistCache||(m.persistCache=y()),g.create(t?m.persistCache:m.memoryCache)}var _=e(r((function(t){t.exports=function(t,e,r){return(e=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.__esModule=!0,t.exports.default=t.exports}))),x=function(){return f((function t(){a(this,t),_(this,"store",new Map)}),[{key:"get",value:(n=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.store.get(e));case 1:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"set",value:(r=o(h.mark((function t(e,r){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.store.set(e,r);case 1:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"delete",value:(e=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.store.delete(e);case 1:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"has",value:(t=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.store.has(e));case 1:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})}]);var t,e,r,n}();var j={cache:k()};function k(){return{duration:6e4,key:function(t){return"".concat((e=t).url,"_").concat(JSON.stringify(e.params||{}),"_").concat(JSON.stringify(e.data||{}));var e},isPersist:!1}}function O(t){if(t<1)return 0;return 1e3*Math.floor(Math.random()*Math.pow(2,Math.min(t,9))+1)}var E="object"==("undefined"==typeof global?"undefined":u(global))&&global&&global.Object===Object&&global,S="object"==("undefined"==typeof self?"undefined":u(self))&&self&&self.Object===Object&&self,I=E||S||Function("return this")(),P=I.Symbol,A=Object.prototype,L=A.hasOwnProperty,C=A.toString,T=P?P.toStringTag:void 0;var M=Object.prototype.toString;var z="[object Null]",N="[object Undefined]",R=P?P.toStringTag:void 0;function q(t){return null==t?void 0===t?N:z:R&&R in Object(t)?function(t){var e=L.call(t,T),r=t[T];try{t[T]=void 0;var n=!0}catch(t){}var o=C.call(t);return n&&(e?t[T]=r:delete t[T]),o}(t):function(t){return M.call(t)}(t)}function F(t){return null!=t&&"object"==u(t)}var G=Array.isArray;function U(t){var e=u(t);return null!=t&&("object"==e||"function"==e)}function $(t){return t}var D="[object AsyncFunction]",J="[object Function]",B="[object GeneratorFunction]",V="[object Proxy]";function W(t){if(!U(t))return!1;var e=q(t);return e==J||e==B||e==D||e==V}var Y,H=I["__core-js_shared__"],K=(Y=/[^.]+$/.exec(H&&H.keys&&H.keys.IE_PROTO||""))?"Symbol(src)_1."+Y:"";var Q=Function.prototype.toString;var X=/^\[object .+?Constructor\]$/,Z=Function.prototype,tt=Object.prototype,et=Z.toString,rt=tt.hasOwnProperty,nt=RegExp("^"+et.call(rt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ot(t){return!(!U(t)||(e=t,K&&K in e))&&(W(t)?nt:X).test(function(t){if(null!=t){try{return Q.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function at(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ot(r)?r:void 0}var it=Object.create,ut=function(){function t(){}return function(e){if(!U(e))return{};if(it)return it(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function ct(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var st=Date.now;var ft,pt,lt,ht=function(){try{var t=at(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),vt=ht,yt=vt?function(t,e){return vt(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:$,dt=(ft=yt,pt=0,lt=0,function(){var t=st(),e=16-(t-lt);if(lt=t,e>0){if(++pt>=800)return arguments[0]}else pt=0;return ft.apply(void 0,arguments)}),bt=dt,gt=9007199254740991,mt=/^(?:0|[1-9]\d*)$/;function wt(t,e){var r=u(t);return!!(e=null==e?gt:e)&&("number"==r||"symbol"!=r&&mt.test(t))&&t>-1&&t%1==0&&t<e}function _t(t,e,r){"__proto__"==e&&vt?vt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function xt(t,e){return t===e||t!=t&&e!=e}var jt=Object.prototype.hasOwnProperty;function kt(t,e,r){var n=t[e];jt.call(t,e)&&xt(n,r)&&(void 0!==r||e in t)||_t(t,e,r)}var Ot=Math.max;function Et(t,e){return bt(function(t,e,r){return e=Ot(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,a=Ot(n.length-e,0),i=Array(a);++o<a;)i[o]=n[e+o];o=-1;for(var u=Array(e+1);++o<e;)u[o]=n[o];return u[e]=r(i),ct(t,this,u)}}(t,e,$),t+"")}var St=9007199254740991;function It(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=St}function Pt(t){return null!=t&&It(t.length)&&!W(t)}var At=Object.prototype;function Lt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||At)}function Ct(t){return F(t)&&"[object Arguments]"==q(t)}var Tt=Object.prototype,Mt=Tt.hasOwnProperty,zt=Tt.propertyIsEnumerable,Nt=Ct(function(){return arguments}())?Ct:function(t){return F(t)&&Mt.call(t,"callee")&&!zt.call(t,"callee")},Rt=Nt;var qt="object"==(void 0===t?"undefined":u(t))&&t&&!t.nodeType&&t,Ft=qt&&"object"==("undefined"==typeof module?"undefined":u(module))&&module&&!module.nodeType&&module,Gt=Ft&&Ft.exports===qt?I.Buffer:void 0,Ut=(Gt?Gt.isBuffer:void 0)||function(){return!1},$t={};$t["[object Float32Array]"]=$t["[object Float64Array]"]=$t["[object Int8Array]"]=$t["[object Int16Array]"]=$t["[object Int32Array]"]=$t["[object Uint8Array]"]=$t["[object Uint8ClampedArray]"]=$t["[object Uint16Array]"]=$t["[object Uint32Array]"]=!0,$t["[object Arguments]"]=$t["[object Array]"]=$t["[object ArrayBuffer]"]=$t["[object Boolean]"]=$t["[object DataView]"]=$t["[object Date]"]=$t["[object Error]"]=$t["[object Function]"]=$t["[object Map]"]=$t["[object Number]"]=$t["[object Object]"]=$t["[object RegExp]"]=$t["[object Set]"]=$t["[object String]"]=$t["[object WeakMap]"]=!1;var Dt="object"==(void 0===t?"undefined":u(t))&&t&&!t.nodeType&&t,Jt=Dt&&"object"==("undefined"==typeof module?"undefined":u(module))&&module&&!module.nodeType&&module,Bt=Jt&&Jt.exports===Dt&&E.process,Vt=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Bt&&Bt.binding&&Bt.binding("util")}catch(t){}}(),Wt=Vt&&Vt.isTypedArray,Yt=Wt?function(t){return function(e){return t(e)}}(Wt):function(t){return F(t)&&It(t.length)&&!!$t[q(t)]},Ht=Yt,Kt=Object.prototype.hasOwnProperty;function Qt(t,e){var r=G(t),n=!r&&Rt(t),o=!r&&!n&&Ut(t),a=!r&&!n&&!o&&Ht(t),i=r||n||o||a,u=i?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=u.length;for(var s in t)!e&&!Kt.call(t,s)||i&&("length"==s||o&&("offset"==s||"parent"==s)||a&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||wt(s,c))||u.push(s);return u}var Xt=Object.prototype.hasOwnProperty;function Zt(t){if(!U(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Lt(t),r=[];for(var n in t)("constructor"!=n||!e&&Xt.call(t,n))&&r.push(n);return r}function te(t){return Pt(t)?Qt(t,!0):Zt(t)}var ee=at(Object,"create");var re=Object.prototype.hasOwnProperty;var ne=Object.prototype.hasOwnProperty;function oe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function ae(t,e){for(var r=t.length;r--;)if(xt(t[r][0],e))return r;return-1}oe.prototype.clear=function(){this.__data__=ee?ee(null):{},this.size=0},oe.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},oe.prototype.get=function(t){var e=this.__data__;if(ee){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return re.call(e,t)?e[t]:void 0},oe.prototype.has=function(t){var e=this.__data__;return ee?void 0!==e[t]:ne.call(e,t)},oe.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ee&&void 0===e?"__lodash_hash_undefined__":e,this};var ie=Array.prototype.splice;function ue(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ue.prototype.clear=function(){this.__data__=[],this.size=0},ue.prototype.delete=function(t){var e=this.__data__,r=ae(e,t);return!(r<0)&&(r==e.length-1?e.pop():ie.call(e,r,1),--this.size,!0)},ue.prototype.get=function(t){var e=this.__data__,r=ae(e,t);return r<0?void 0:e[r][1]},ue.prototype.has=function(t){return ae(this.__data__,t)>-1},ue.prototype.set=function(t,e){var r=this.__data__,n=ae(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ce=at(I,"Map");function se(t,e){var r,n,o=t.__data__;return("string"==(n=u(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function fe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}fe.prototype.clear=function(){this.size=0,this.__data__={hash:new oe,map:new(ce||ue),string:new oe}},fe.prototype.delete=function(t){var e=se(this,t).delete(t);return this.size-=e?1:0,e},fe.prototype.get=function(t){return se(this,t).get(t)},fe.prototype.has=function(t){return se(this,t).has(t)},fe.prototype.set=function(t,e){var r=se(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};var pe=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object),le=pe,he="[object Object]",ve=Function.prototype,ye=Object.prototype,de=ve.toString,be=ye.hasOwnProperty,ge=de.call(Object);function me(t){var e=this.__data__=new ue(t);this.size=e.size}me.prototype.clear=function(){this.__data__=new ue,this.size=0},me.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},me.prototype.get=function(t){return this.__data__.get(t)},me.prototype.has=function(t){return this.__data__.has(t)},me.prototype.set=function(t,e){var r=this.__data__;if(r instanceof ue){var n=r.__data__;if(!ce||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new fe(n)}return r.set(t,e),this.size=r.size,this};var we="object"==(void 0===t?"undefined":u(t))&&t&&!t.nodeType&&t,_e=we&&"object"==("undefined"==typeof module?"undefined":u(module))&&module&&!module.nodeType&&module,xe=_e&&_e.exports===we?I.Buffer:void 0,je=xe?xe.allocUnsafe:void 0;var ke=I.Uint8Array;function Oe(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new ke(n).set(new ke(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Ee,Se=function(t,e,r){for(var n=-1,o=Object(t),a=r(t),i=a.length;i--;){var u=a[Ee?i:++n];if(!1===e(o[u],u,o))break}return t};function Ie(t,e,r){(void 0!==r&&!xt(t[e],r)||void 0===r&&!(e in t))&&_t(t,e,r)}function Pe(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Ae(t){return function(t,e,r,n){var o=!r;r||(r={});for(var a=-1,i=e.length;++a<i;){var u=e[a],c=n?n(r[u],t[u],u,r,t):void 0;void 0===c&&(c=t[u]),o?_t(r,u,c):kt(r,u,c)}return r}(t,te(t))}function Le(t,e,r,n,o,a,i){var u=Pe(t,r),c=Pe(e,r),s=i.get(c);if(s)Ie(t,r,s);else{var f,p=a?a(u,c,r+"",t,e,i):void 0,l=void 0===p;if(l){var h=G(c),v=!h&&Ut(c),y=!h&&!v&&Ht(c);p=c,h||v||y?G(u)?p=u:F(f=u)&&Pt(f)?p=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(u):v?(l=!1,p=function(t,e){if(e)return t.slice();var r=t.length,n=je?je(r):new t.constructor(r);return t.copy(n),n}(c,!0)):y?(l=!1,p=Oe(c,!0)):p=[]:function(t){if(!F(t)||q(t)!=he)return!1;var e=le(t);if(null===e)return!0;var r=be.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&de.call(r)==ge}(c)||Rt(c)?(p=u,Rt(u)?p=Ae(u):U(u)&&!W(u)||(p=function(t){return"function"!=typeof t.constructor||Lt(t)?{}:ut(le(t))}(c))):l=!1}l&&(i.set(c,p),o(p,c,n,a,i),i.delete(c)),Ie(t,r,p)}}function Ce(t,e,r,n,o){t!==e&&Se(e,(function(a,i){if(o||(o=new me),U(a))Le(t,e,i,r,Ce,n,o);else{var u=n?n(Pe(t,i),a,i+"",t,e,o):void 0;void 0===u&&(u=a),Ie(t,i,u)}}),te)}function Te(t,e,r,n,o,a){return U(t)&&U(e)&&(a.set(e,t),Ce(t,e,void 0,Te,a),a.delete(e)),t}var Me,ze=(Me=function(t,e,r,n){Ce(t,e,r,n)},Et((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,a=n>2?e[2]:void 0;for(o=Me.length>3&&"function"==typeof o?(n--,o):void 0,a&&function(t,e,r){if(!U(r))return!1;var n=u(e);return!!("number"==n?Pt(r)&&wt(e,r.length):"string"==n&&e in r)&&xt(r[e],t)}(e[0],e[1],a)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var i=e[r];i&&Me(t,i,r,o)}return t}))),Ne=Et((function(t){return t.push(void 0,Te),ct(ze,void 0,t)}));function Re(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return qe(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return qe(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){u=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw a}}}}function qe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Fe=function(){function t(e){a(this,t),this.client=e}return f(t,[{key:"applyRequestInterceptors",value:(l=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.applyInterceptors(e,this.client.requestInterceptors));case 1:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})},{key:"applyResponseInterceptors",value:(p=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.applyInterceptors(e,this.client.responseInterceptors));case 1:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"applyInterceptors",value:(s=o(h.mark((function t(e,r){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r&&(null==r||r.forEach((function(t){e=e.then(t)}))),t.abrupt("return",e);case 2:case"end":return t.stop()}}),t)}))),function(t,e){return s.apply(this,arguments)})},{key:"applyErrorInterceptors",value:(c=o(h.mark((function t(e){var r,n,o;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.client.errorInterceptors){t.next=19;break}r=Re(this.client.errorInterceptors),t.prev=2,r.s();case 4:if((n=r.n()).done){t.next=11;break}return o=n.value,t.next=8,o(e);case 8:e=t.sent;case 9:t.next=4;break;case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(2),r.e(t.t0);case 16:return t.prev=16,r.f(),t.finish(16);case 19:return t.abrupt("return",Promise.reject(e));case 20:case"end":return t.stop()}}),t,this,[[2,13,16,19]])}))),function(t){return c.apply(this,arguments)})},{key:"getCachedResponse",value:(u=o(h.mark((function t(e,r,n){var o;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e&&n){t.next=2;break}return t.abrupt("return",void 0);case 2:if(e.has(n.key(r))){t.next=4;break}return t.abrupt("return",void 0);case 4:if(o=n.key(r),!n.isValid){t.next=10;break}if(!n.isValid(o,r)){t.next=8;break}return t.abrupt("return",e.getNormal(o));case 8:t.next=11;break;case 10:return t.abrupt("return",e.get(o));case 11:return t.abrupt("return",void 0);case 12:case"end":return t.stop()}}),t)}))),function(t,e,r){return u.apply(this,arguments)})},{key:"applyCache",value:(i=o(h.mark((function t(e,r,n){var a,i,u,c,s=this;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=(null==r?void 0:r.cache)||k(),i=w(a.isPersist),u=function(){var t=o(h.mark((function t(){var e;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,n(r);case 3:return e=t.sent,a&&i&&r.useCache&&i.set(a.key(r),e,a.duration),t.abrupt("return",e);case 8:if(t.prev=8,t.t0=t.catch(0),!(r.retry&&r.retry>0)){t.next=14;break}throw t.t0;case 14:return t.next=16,s.applyErrorInterceptors(t.t0);case 16:case"end":return t.stop()}}),t,null,[[0,8]])})));return function(){return t.apply(this,arguments)}}(),null==r||!r.useCache){t.next=10;break}return t.next=6,this.getCachedResponse(i,r,a);case 6:if(!(c=t.sent)){t.next=10;break}return e=e.then(o(h.mark((function t(){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Promise.resolve(c));case 1:case"end":return t.stop()}}),t)})))),t.abrupt("return",e);case 10:return e=null!=r&&r.retry&&r.retry>0?this.retry(u,r.retry,r.retryInterval?r.retryInterval:O(r.retry)):e.then(u),t.abrupt("return",e);case 12:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return i.apply(this,arguments)})},{key:"retry",value:(n=o(h.mark((function t(e,r,n){var o;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=0;case 1:if(!(o<r)){t.next=19;break}return t.prev=2,t.next=5,e();case 5:return t.abrupt("return",t.sent);case 8:if(t.prev=8,t.t0=t.catch(2),!(++o>=r)){t.next=15;break}return t.next=14,this.applyErrorInterceptors(t.t0);case 14:throw t.t0;case 15:return t.next=17,new Promise((function(t){return setTimeout(t,n)}));case 17:t.next=1;break;case 19:throw new Error("Exceeded maximum retries");case 20:case"end":return t.stop()}}),t,this,[[2,8]])}))),function(t,e,r){return n.apply(this,arguments)})},{key:"request",value:(r=o(h.mark((function t(e,r){var n;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.normalizeOptions(r),n=Promise.resolve(r),n=this.applyRequestInterceptors(n),n=this.applyCache(n,r,e),n=this.applyResponseInterceptors(n),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"normalizeOptions",value:function(t){return Ne(t,j)}},{key:"get",value:function(t){return this.request(this.client.get,t)}},{key:"post",value:(e=o(h.mark((function t(e){return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.request(this.client.post,e));case 1:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}],[{key:"create",value:function(e){return new t(e)}}]);var e,r,n,i,u,c,s,p,l}();t.whaleRequest=void 0,t.CacheManager=g,t.actualErrorRetryInterval=O,t.defaultRequestOptions=j,t.getDefaultCacheOptions=k,t.inject=function(e){t.whaleRequest=Fe.create(e)},t.injectCache=function(t,e){m.memoryCache=t,m.persistCache=e},t.requestCache=m,t.setGlobalOptions=function(t){Object.keys(t).forEach((function(e){j[e]=t[e]}))},t.useCache=w,t.useLocationStorageCache=y,t.useMemoryCache=function(){return new x},t.useRequestor=function(){return t.whaleRequest},t.useSessionStorageCache=b,Object.defineProperty(t,"__esModule",{value:!0})}));