UNPKG

owm-onecall-api

Version:
3 lines (2 loc) 22.4 kB
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t,r=e(require("date-fns/isDate")),n=e(require("axios"));(t=exports.Exclude||(exports.Exclude={})).Currently="currently",t.Minutely="minutely",t.Hourly="hourly",t.Daily="daily";var i,o,a,u,s=[exports.Exclude.Currently,exports.Exclude.Minutely,exports.Exclude.Hourly,exports.Exclude.Daily];function c(e){return e?e.map((function(e){return function(e){return{title:e.event,description:e.description,time:e.start,expires:e.end,regions:void 0,severity:void 0,url:void 0}}(e)})):[]}function l(e,t,r,n,i,o,a){try{var u=e[o](a),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,i)}function h(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){l(o,n,i,a,u,"next",e)}function u(e){l(o,n,i,a,u,"throw",e)}a(void 0)}))}}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function v(e,t,r){return(v=m()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&y(i,r.prototype),i}).apply(null,arguments)}function g(e){var t="function"==typeof Map?new Map:void 0;return(g=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return v(e,arguments,f(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,e)})(e)}function x(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(i[r]=e[r]);return i}(i=exports.Language||(exports.Language={})).Afrikaans="af",i.Albanian="al",i.Arabic="ar",i.Azerbaijani="az",i.Bulgarian="bg",i.Catalan="ca",i.Czech="cz",i.Danish="da",i.German="de",i.Greek="el",i.English="en",i.Basque="eu",i.Persian="fa",i.Finnish="fi",i.French="fr",i.Galician="gl",i.Hebrew="he",i.Hindi="hi",i.Croatian="hr",i.Hungarian="hu",i.Indonesian="id",i.Italian="it",i.Japanese="ja",i.Korean="kr",i.Latvian="la",i.Lithuanian="lt",i.Macedonian="mk",i.Norwegian="no",i.Dutch="nl",i.Polish="pl",i.Portuguese="pt",i.Portuguese_Brazil="pt_br",i.Romanian="ro",i.Russian="ru",i.Swedish="sv",i.Slovak="sk",i.Slovenian="sl",i.Spanish="sp",i.Serbian="sr",i.Thai="th",i.Turkish="tr",i.Ukrainian="ua",i.Vietnamese="vi",i.Chinese_Simplified="zh_cn",i.Chinese_Traditional="zh_tw",i.Zulu="zu",(o=exports.Units||(exports.Units={})).Default="",o.Metric="metric",o.Imperial="imperial",(a=exports.WeatherIcon||(exports.WeatherIcon={})).ClearSky="01d",a.ClearSkyNight="01n",a.FewClouds="02d",a.FewCloudsNight="02n",a.ScatteredClouds="03d",a.ScatteredCloudsNight="03n",a.BrokenClouds="04d",a.BrokenCloudsNight="04n",a.ShowerRain="09d",a.ShowerRainNight="09n",a.Rain="10d",a.RainNight="10n",a.Thunderstorm="11d",a.ThunderstormNight="11n",a.Snow="13d",a.SnowNight="13n",a.Mist="50d",a.MistNight="50n",(u=exports.Condition||(exports.Condition={}))[u.ThunderstormRainLight=200]="ThunderstormRainLight",u[u.ThunderstormRain=201]="ThunderstormRain",u[u.ThunderstormRainHeavy=202]="ThunderstormRainHeavy",u[u.ThunderstormLight=210]="ThunderstormLight",u[u.ThunderstormNormal=211]="ThunderstormNormal",u[u.ThunderstormHeavy=212]="ThunderstormHeavy",u[u.ThunderstormRagged=221]="ThunderstormRagged",u[u.ThunderstormDrizzleLight=230]="ThunderstormDrizzleLight",u[u.ThunderstormDrizzle=231]="ThunderstormDrizzle",u[u.ThunderstormDrizzleHeavy=232]="ThunderstormDrizzleHeavy",u[u.DrizzleLight=300]="DrizzleLight",u[u.DrizzleNormal=301]="DrizzleNormal",u[u.DrizzleHeavy=302]="DrizzleHeavy",u[u.DrizzleRainLight=310]="DrizzleRainLight",u[u.DrizzleRain=311]="DrizzleRain",u[u.DrizzleRainHeavy=312]="DrizzleRainHeavy",u[u.DrizzleRainShower=313]="DrizzleRainShower",u[u.DrizzleRainShowerHeavy=314]="DrizzleRainShowerHeavy",u[u.DrizzleShower=321]="DrizzleShower",u[u.RainLight=500]="RainLight",u[u.RainModerate=501]="RainModerate",u[u.RainHeavy=502]="RainHeavy",u[u.RainVeryHeavy=503]="RainVeryHeavy",u[u.RainExtreme=504]="RainExtreme",u[u.RainFreezing=511]="RainFreezing",u[u.RainShowerLight=520]="RainShowerLight",u[u.RainShower=521]="RainShower",u[u.RainShowerHeavy=522]="RainShowerHeavy",u[u.RainRaggedShower=531]="RainRaggedShower",u[u.SnowLight=600]="SnowLight",u[u.SnowNormal=601]="SnowNormal",u[u.SnowHeavy=602]="SnowHeavy",u[u.SnowSleet=611]="SnowSleet",u[u.SnowSleetShowerLight=612]="SnowSleetShowerLight",u[u.SnowSleetShower=613]="SnowSleetShower",u[u.SnowMixedLight=615]="SnowMixedLight",u[u.SnowMixed=616]="SnowMixed",u[u.SnowShowerLight=620]="SnowShowerLight",u[u.SnowShower=621]="SnowShower",u[u.SnowShowerHeavy=622]="SnowShowerHeavy",u[u.Mist=701]="Mist",u[u.Smoke=711]="Smoke",u[u.Haze=721]="Haze",u[u.DustWhirls=731]="DustWhirls",u[u.Fog=741]="Fog",u[u.Sand=751]="Sand",u[u.Dust=761]="Dust",u[u.Ash=762]="Ash",u[u.Squall=771]="Squall",u[u.Tornado=781]="Tornado",u[u.Clear=800]="Clear",u[u.CloudsFew=801]="CloudsFew",u[u.CloudsScattered=802]="CloudsScattered",u[u.CloudsBroken=803]="CloudsBroken",u[u.CloudsOvercast=804]="CloudsOvercast";var w,S,k=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new b(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var u=w(a,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=c(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===l)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l={};function h(){}function p(){}function d(){}var f={};f[i]=function(){return this};var y=Object.getPrototypeOf,m=y&&y(y(R([])));m&&m!==t&&r.call(m,i)&&(f=m);var v=d.prototype=h.prototype=Object.create(f);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,u){var s=c(e[i],e,o);if("throw"!==s.type){var l=s.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):t.resolve(h).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,u)}))}u(s.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function R(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:z}}function z(){return{value:void 0,done:!0}}return p.prototype=v.constructor=d,d.constructor=p,p.displayName=u(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,u(e,a,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},g(x.prototype),x.prototype[o]=function(){return this},e.AsyncIterator=x,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new x(s(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(v),u(v,a,"Generator"),v[i]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=R,b.prototype={constructor:b,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),s=r.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:R(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(S={exports:{}}),S.exports);function b(e){var t=parseFloat(e);return!isNaN(t)&&isFinite(t)}function R(e){switch(e){case exports.WeatherIcon.ClearSky:return exports.DarkSkyWeatherIcon.ClearDay;case exports.WeatherIcon.ClearSkyNight:return exports.DarkSkyWeatherIcon.ClearNight;case exports.WeatherIcon.FewClouds:case exports.WeatherIcon.FewCloudsNight:return exports.DarkSkyWeatherIcon.Cloudy;case exports.WeatherIcon.ScatteredClouds:case exports.WeatherIcon.BrokenClouds:return exports.DarkSkyWeatherIcon.PartlyCloudyDay;case exports.WeatherIcon.ScatteredCloudsNight:case exports.WeatherIcon.BrokenCloudsNight:return exports.DarkSkyWeatherIcon.PartlyCloudyNight;case exports.WeatherIcon.ShowerRain:case exports.WeatherIcon.ShowerRainNight:case exports.WeatherIcon.Rain:case exports.WeatherIcon.RainNight:return exports.DarkSkyWeatherIcon.Rain;case exports.WeatherIcon.Snow:case exports.WeatherIcon.SnowNight:return exports.DarkSkyWeatherIcon.Snow;case exports.WeatherIcon.Thunderstorm:case exports.WeatherIcon.ThunderstormNight:return exports.DarkSkyWeatherIcon.Thunderstorm;case exports.WeatherIcon.Mist:case exports.WeatherIcon.MistNight:return exports.DarkSkyWeatherIcon.Fog;default:return}}function z(e){return e.rain?"rain":e.snow?"snow":void 0}function D(e){var t,r,n=null!=(t=e.rain)?t:e.snow;return b(n)?n:null!=(r=n)&&Object.getPrototypeOf(r).isPrototypeOf(Object)?n["1h"]:void 0}function C(e){var t=function(e){return{precipType:z(e),precipIntensity:D(e)}}(e),r=e.weather[0];return p({time:e.dt,summary:r.description,icon:R(r.icon),originalIcon:r.icon,pressure:e.pressure,humidity:e.humidity,dewPoint:e.dew_point,cloudCover:e.clouds,visibility:e.visibility,windSpeed:e.wind_speed,windBearing:e.wind_deg,windGust:e.wind_gust,precipProbability:e.pop,uvIndex:e.uvi},t)}function L(e){if(e)return p({},C(e),{sunriseTime:e.sunrise,sunsetTime:e.sunset,temperature:e.temp,apparentTemperature:e.feels_like,uvIndex:e.uvi,visibility:e.visibility})}function P(e){if(e)return{summary:void 0,icon:void 0,data:e.map((function(e){return{time:(t=e).dt,precipIntensity:t.precipitation};var t}))}}function T(e){var t;void 0===e&&(e=[]);var r=null==(t=e[0])?void 0:t.weather[0];if(r)return{summary:r.description,icon:R(r.icon),originalIcon:r.icon,data:e.map((function(e){return p({},C(t=e),{temperature:t.temp,apparentTemperature:t.feels_like,precipProbability:t.pop,visibility:t.visibility});var t}))}}function E(e){var t;void 0===e&&(e=[]);var r=null==(t=e[0])?void 0:t.weather[0];if(r)return{summary:r.description,icon:R(r.icon),originalIcon:r.icon,data:e.map((function(e){return r=C(t=e),n=Object.values(t.feels_like),i=Math.max.apply(Math,n),o=Math.min.apply(Math,n),p({},r,{sunriseTime:t.sunrise,sunsetTime:t.sunset,temperatureHigh:t.temp.day,temperatureLow:t.temp.night,temperatureMax:t.temp.max,temperatureMin:t.temp.min,apparentTemperatureHigh:t.feels_like.day,apparentTemperatureLow:t.feels_like.night,apparentTemperatureMax:i,apparentTemperatureMin:o,uvIndex:t.uvi,precipProbability:t.pop});var t,r,n,i,o}))}}function I(e){return{latitude:e.lat,longitude:e.lon,timezone:e.timezone,currently:L(e.current),minutely:P(e.minutely),hourly:T(e.hourly),daily:E(e.daily),alerts:c(e.alerts)}}function _(e){return M.apply(this,arguments)}function M(){return(M=h(k.mark((function e(t){return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t;case 2:return e.abrupt("return",I(e.sent));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(w=exports.DarkSkyWeatherIcon||(exports.DarkSkyWeatherIcon={})).ClearDay="clear-day",w.ClearNight="clear-night",w.Rain="rain",w.Snow="snow",w.Sleet="sleet",w.Wind="wind",w.Fog="fog",w.Cloudy="cloudy",w.PartlyCloudyDay="partly-cloudy-day",w.PartlyCloudyNight="partly-cloudy-night",w.Thunderstorm="thunderstorm";var N=function(e){function t(t,r,n){var i;return(i=e.call(this,r+(n?"\n"+n:""))||this).code=t,i.data=n,i}return d(t,e),t}(g(Error));function O(e){return new N(400,"Bad Request",e)}function W(e){return new N(404,"Not Found",e)}function H(e,t){return void 0===t&&(t={}),{forecast:function(r,n){return void 0===n&&(n={}),q(e,r,n,t)},timeMachine:function(r,n){return void 0===n&&(n={}),q(e,r,n,t)}}}function q(e,t,r,n){return j.apply(this,arguments)}function j(){return(j=h(k.mark((function e(t,r,i,o){var a;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=F(t,r,i),e.next=3,n.get(a,o);case 3:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function F(e,t,n){var i=t.lat,o=t.lon,a=t.time;if(!e)throw O("API Token is required!");if(!b(i)||!b(o))throw O("Latitude and Longitude need to be a valid number!");var u=function(e){if(e){if(b(e))return e;if(r(e))return e.getTime()/1e3;throw new Error("Could not parse Unix timestamp from 'time' property!")}}(a);return(u?"https://api.openweathermap.org/data/3.0/onecall/timemachine":"https://api.openweathermap.org/data/3.0/onecall")+function(e,t,r){var n=p({appid:e,dt:t.time},x(t,["time"]),r);return"?"+Object.keys(n).filter((function(e){return null!=n[e]})).filter((function(e){return!Array.isArray(n[e])||n[e].length})).map((function(e){var t=Array.isArray(n[e])?n[e].join(","):n[e];return e+"="+encodeURIComponent(t)})).join("&")}(e,{lat:i,lon:o,time:u},n)}var A=function(e,t){var r=void 0===t?{}:t,n=r.requestConfig,i=x(r,["requestConfig"]);this.token=e,this.client=H(e,n),this.requestParams=i},B=function(e){function t(t,r,n,i){var o;return(o=e.call(this,t,i)||this).request={lat:r,lon:n},o}d(t,e);var r=t.prototype;return r.params=function(e){return e&&(this.requestParams=p({},this.requestParams,e)),this},r.time=function(e){return this.request.time=e,this},r.units=function(e){return this.requestParams.units=e,this},r.language=function(e){return this.requestParams.lang=e,this},r.exclude=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=[].concat(this.requestParams.exclude||[],t);return this.requestParams.exclude=[].concat(new Set(n)),this},r.onlyCurrently=function(){return this.requestParams.exclude=this.excludeAllBut(exports.Exclude.Currently),this},r.excludeCurrently=function(){return this.addExlude(exports.Exclude.Currently),this},r.onlyMinutely=function(){return this.requestParams.exclude=this.excludeAllBut(exports.Exclude.Minutely),this},r.excludeMinutely=function(){return this.addExlude(exports.Exclude.Minutely),this},r.onlyHourly=function(){return this.requestParams.exclude=this.excludeAllBut(exports.Exclude.Hourly),this},r.excludeHourly=function(){return this.addExlude(exports.Exclude.Hourly),this},r.onlyDaily=function(){return this.requestParams.exclude=this.excludeAllBut(exports.Exclude.Daily),this},r.excludeDaily=function(){return this.addExlude(exports.Exclude.Daily),this},r.execute=function(){var e=this.request,t=e.lat,r=e.lon,n=e.time;return n?this.client.timeMachine({lat:t,lon:r,time:n},this.requestParams):this.client.forecast({lat:t,lon:r},this.requestParams)},r.excludeAllBut=function(e){return[].concat(this.requestParams.exclude||[],s.filter((function(t){return t!==e})))},r.addExlude=function(e){this.requestParams.exclude||(this.requestParams.exclude=[]),this.requestParams.exclude.includes(e)||this.requestParams.exclude.push(e)},t}(A);function G(e,t,r,n){return new B(e,t,r,n)}exports.OpenWeatherMap=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var r=t.prototype;return r.builder=function(e,t,r){return G(this.token,e,t).params(this.mergeParams(r))},r.forecast=function(e,t,r){return this.client.forecast({lat:e,lon:t},this.mergeParams(r))},r.timeMachine=function(e,t,r,n){return this.client.timeMachine({lat:e,lon:t,time:r},this.mergeParams(n))},r.current=function(){var e=h(k.mark((function e(t,r,n){var i;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.builder(t,r,n).onlyCurrently().execute();case 2:if((i=e.sent).current){e.next=5;break}throw W();case 5:return e.abrupt("return",i);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.week=function(){var e=h(k.mark((function e(t,r,n){var i;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.builder(t,r,n).onlyDaily().execute();case 2:if((i=e.sent).daily){e.next=5;break}throw W();case 5:return e.abrupt("return",i);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.day=function(){var e=h(k.mark((function e(t,r,n){var i;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.builder(t,r,n).onlyHourly().execute();case 2:if((i=e.sent).hourly){e.next=5;break}throw W();case 5:return e.abrupt("return",i);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.hour=function(){var e=h(k.mark((function e(t,r,n){var i;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.builder(t,r,n).onlyMinutely().execute();case 2:if((i=e.sent).minutely){e.next=5;break}throw W();case 5:return e.abrupt("return",i);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.mergeParams=function(e){return p({},this.requestParams,null!=e?e:{})},t}(A),exports.buildOpenWeatherMapRequest=G,exports.darkSkyCompatClient=function(e,t){void 0===t&&(t={});var r=H(e,t),n=function(e){return e.latitude||e.longitude?function(e){if(!e.latitude||!e.longitude)throw Error("Missing `Request.latitude` or `Request.longitude`");return{lat:e.latitude,lon:e.longitude,time:e.time}}(e):e};return{forecast:function(e,t){return void 0===t&&(t={}),_(r.forecast(n(e),t))},timeMachine:function(e,t){return void 0===t&&(t={}),_(r.timeMachine(n(e),t))}}},exports.mapAlertsToDarkSky=c,exports.mapResultToDarkSkyForecast=_,exports.mapToDarkSkyForecast=I,exports.openWeatherMapClient=H; //# sourceMappingURL=owm-onecall-api.cjs.production.min.js.map