summaryrefslogtreecommitdiff
path: root/client/index.e52d0c93.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/index.e52d0c93.js')
-rw-r--r--client/index.e52d0c93.js1
1 files changed, 1 insertions, 0 deletions
diff --git a/client/index.e52d0c93.js b/client/index.e52d0c93.js
new file mode 100644
index 0000000..6297cdc
--- /dev/null
+++ b/client/index.e52d0c93.js
@@ -0,0 +1 @@
+import{S as e,i as t,s as a,e as s,c as l,a as n,d as r,b as c,f as i,g as o,n as d,w as u,h,t as p,j as f,k as m,l as g,m as v,o as _,p as b,q as w,r as E,u as $,v as D,x as k,y,z as I,A as O,B as V,C as j,D as x,E as T,F as M,G as P,H as S,I as C}from"./client.c78b597d.js";function N(e){let t,a,u,h,p,f,m,g,v;return{c(){t=s("div"),a=s("div"),u=s("div"),h=s("div"),p=s("div"),f=s("div"),m=s("div"),g=s("div"),v=s("div"),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"DIV",{class:!0}),n(a).forEach(r),u=l(s,"DIV",{class:!0}),n(u).forEach(r),h=l(s,"DIV",{class:!0}),n(h).forEach(r),p=l(s,"DIV",{class:!0}),n(p).forEach(r),f=l(s,"DIV",{class:!0}),n(f).forEach(r),m=l(s,"DIV",{class:!0}),n(m).forEach(r),g=l(s,"DIV",{class:!0}),n(g).forEach(r),v=l(s,"DIV",{class:!0}),n(v).forEach(r),s.forEach(r),this.h()},h(){c(a,"class","svelte-7k6qu0"),c(u,"class","svelte-7k6qu0"),c(h,"class","svelte-7k6qu0"),c(p,"class","svelte-7k6qu0"),c(f,"class","svelte-7k6qu0"),c(m,"class","svelte-7k6qu0"),c(g,"class","svelte-7k6qu0"),c(v,"class","svelte-7k6qu0"),c(t,"class","lds-roller svelte-7k6qu0")},m(e,s){i(e,t,s),o(t,a),o(t,u),o(t,h),o(t,p),o(t,f),o(t,m),o(t,g),o(t,v)},p:d,i:d,o:d,d(e){e&&r(t)}}}class q extends e{constructor(e){super(),t(this,e,null,N,a,{})}}const H={updated:!1,updating:!0},A=u(Object.assign(Object.assign({},H),{available:!1,longitude:null,latitude:null,city:null})),B=u(Object.assign(Object.assign({},H),{available:!1})),J=u(Object.assign({},H));function z(e,t=!1){let a=t?{}:{updated:new Date};e.update((e=>Object.assign(Object.assign(Object.assign({},e),a),{updating:t})))}function F(e){let t,a,d,u,v=e[0].city+"";return{c(){t=s("i"),a=h(),d=s("h1"),u=p(v),this.h()},l(e){t=l(e,"I",{class:!0}),n(t).forEach(r),a=f(e),d=l(e,"H1",{class:!0});var s=n(d);u=m(s,v),s.forEach(r),this.h()},h(){c(t,"class","symbol fas fa-map-marker-alt svelte-9kdo4s"),c(d,"class","svelte-9kdo4s")},m(e,s){i(e,t,s),i(e,a,s),i(e,d,s),o(d,u)},p(e,t){1&t&&v!==(v=e[0].city+"")&&g(u,v)},d(e){e&&r(t),e&&r(a),e&&r(d)}}}function K(e){let t,a;function s(e,a){return 6&a&&(t=null),null==t&&(t=!!(Math.abs(e[1].updated-e[2].updated)>6e5)),t?U:L}let l=s(e,-1),n=l(e);return{c(){n.c(),a=v()},l(e){n.l(e),a=v()},m(e,t){n.m(e,t),i(e,a,t)},p(e,t){l===(l=s(e,t))&&n?n.p(e,t):(n.d(1),n=l(e),n&&(n.c(),n.m(a.parentNode,a)))},d(e){n.d(e),e&&r(a)}}}function L(e){let t,a,c=e[1].updated.toLocaleString("no-NO",{dateStyle:"medium",timeStyle:"short"})+"";return{c(){t=s("p"),a=p(c)},l(e){t=l(e,"P",{});var s=n(t);a=m(s,c),s.forEach(r)},m(e,s){i(e,t,s),o(t,a)},p(e,t){2&t&&c!==(c=e[1].updated.toLocaleString("no-NO",{dateStyle:"medium",timeStyle:"short"})+"")&&g(a,c)},d(e){e&&r(t)}}}function U(e){let t,a;return{c(){t=s("p"),a=p("There is more than 10 minutes difference between data updates")},l(e){t=l(e,"P",{});var s=n(t);a=m(s,"There is more than 10 minutes difference between data updates"),s.forEach(r)},m(e,s){i(e,t,s),o(t,a)},p:d,d(e){e&&r(t)}}}function Z(e){let t,a,u,v,_,b,w,E,$,D,k,y,I=e[2].now.kp+"",O=e[2].now.kp_max+"",V=e[2].now.kp_min+"";return{c(){t=s("h2"),a=p("KP "),u=p(I),v=h(),_=s("p"),b=s("span"),w=p("↑ KP "),E=p(O),$=h(),D=s("span"),k=p("↓ KP "),y=p(V),this.h()},l(e){t=l(e,"H2",{class:!0});var s=n(t);a=m(s,"KP "),u=m(s,I),s.forEach(r),v=f(e),_=l(e,"P",{});var c=n(_);b=l(c,"SPAN",{classname:!0});var i=n(b);w=m(i,"↑ KP "),E=m(i,O),i.forEach(r),$=f(c),D=l(c,"SPAN",{classname:!0});var o=n(D);k=m(o,"↓ KP "),y=m(o,V),o.forEach(r),c.forEach(r),this.h()},h(){c(t,"class","svelte-9kdo4s"),c(b,"classname","pr-2"),c(D,"classname","pl-2")},m(e,s){i(e,t,s),o(t,a),o(t,u),i(e,v,s),i(e,_,s),o(_,b),o(b,w),o(b,E),o(_,$),o(_,D),o(D,k),o(D,y)},p(e,t){4&t&&I!==(I=e[2].now.kp+"")&&g(u,I),4&t&&O!==(O=e[2].now.kp_max+"")&&g(E,O),4&t&&V!==(V=e[2].now.kp_min+"")&&g(y,V)},i:d,o:d,d(e){e&&r(t),e&&r(v),e&&r(_)}}}function G(e){let t,a;return t=new q({}),{c(){D(t.$$.fragment)},l(e){k(t.$$.fragment,e)},m(e,s){y(t,e,s),a=!0},p:d,i(e){a||(E(t.$$.fragment,e),a=!0)},o(e){b(t.$$.fragment,e),a=!1},d(e){I(t,e)}}}function Q(e){let t,a,d,u,_,b,w,E,$,D,k,y,I,O,V,j=e[2].now.bz+"",x=e[2].now.bt+"",T=e[1].available&&R(e);return{c(){t=s("div"),a=s("p"),d=p("BZ"),u=h(),_=s("p"),b=p(j),w=h(),E=s("div"),$=s("p"),D=p("BT"),k=h(),y=s("p"),I=p(x),O=h(),T&&T.c(),V=v(),this.h()},l(e){t=l(e,"DIV",{});var s=n(t);a=l(s,"P",{class:!0});var c=n(a);d=m(c,"BZ"),c.forEach(r),u=f(s),_=l(s,"P",{class:!0});var i=n(_);b=m(i,j),i.forEach(r),s.forEach(r),w=f(e),E=l(e,"DIV",{});var o=n(E);$=l(o,"P",{class:!0});var h=n($);D=m(h,"BT"),h.forEach(r),k=f(o),y=l(o,"P",{class:!0});var p=n(y);I=m(p,x),p.forEach(r),o.forEach(r),O=f(e),T&&T.l(e),V=v(),this.h()},h(){c(a,"class","svelte-9kdo4s"),c(_,"class","svelte-9kdo4s"),c($,"class","svelte-9kdo4s"),c(y,"class","svelte-9kdo4s")},m(e,s){i(e,t,s),o(t,a),o(a,d),o(t,u),o(t,_),o(_,b),i(e,w,s),i(e,E,s),o(E,$),o($,D),o(E,k),o(E,y),o(y,I),i(e,O,s),T&&T.m(e,s),i(e,V,s)},p(e,t){4&t&&j!==(j=e[2].now.bz+"")&&g(b,j),4&t&&x!==(x=e[2].now.bt+"")&&g(I,x),e[1].available?T?T.p(e,t):(T=R(e),T.c(),T.m(V.parentNode,V)):T&&(T.d(1),T=null)},d(e){e&&r(t),e&&r(w),e&&r(E),e&&r(O),T&&T.d(e),e&&r(V)}}}function R(e){let t,a,d,u,v,_,b,w,E,$,D,k,y,I,O,V=e[1].now.temp+"",j=e[1].now.clouds+"";return{c(){t=s("div"),a=s("p"),d=p("Temp"),u=h(),v=s("p"),_=p(V),b=p("°C"),w=h(),E=s("div"),$=s("p"),D=p("Clouds"),k=h(),y=s("p"),I=p(j),O=p("%"),this.h()},l(e){t=l(e,"DIV",{});var s=n(t);a=l(s,"P",{class:!0});var c=n(a);d=m(c,"Temp"),c.forEach(r),u=f(s),v=l(s,"P",{class:!0});var i=n(v);_=m(i,V),b=m(i,"°C"),i.forEach(r),s.forEach(r),w=f(e),E=l(e,"DIV",{});var o=n(E);$=l(o,"P",{class:!0});var h=n($);D=m(h,"Clouds"),h.forEach(r),k=f(o),y=l(o,"P",{class:!0});var p=n(y);I=m(p,j),O=m(p,"%"),p.forEach(r),o.forEach(r),this.h()},h(){c(a,"class","svelte-9kdo4s"),c(v,"class","svelte-9kdo4s"),c($,"class","svelte-9kdo4s"),c(y,"class","svelte-9kdo4s")},m(e,s){i(e,t,s),o(t,a),o(a,d),o(t,u),o(t,v),o(v,_),o(v,b),i(e,w,s),i(e,E,s),o(E,$),o($,D),o(E,k),o(E,y),o(y,I),o(y,O)},p(e,t){2&t&&V!==(V=e[1].now.temp+"")&&g(_,V),2&t&&j!==(j=e[1].now.clouds+"")&&g(I,j)},d(e){e&&r(t),e&&r(w),e&&r(E)}}}function W(e){let t,a,d,u,p,m,g,v,$,D,k,y,I=!e[0].updating&&e[0].available&&!e[1].updating&&!e[2].updating&&F(e),O=!e[1].updating&&!e[2].updating&&K(e);const V=[G,Z],j=[];function x(e,t){return e[2].updating||e[1].updating?0:1}v=x(e),$=j[v]=V[v](e);let T=!e[2].updating&&!e[1].updating&&Q(e);return{c(){t=s("div"),a=s("div"),d=s("div"),I&&I.c(),u=h(),p=s("div"),O&&O.c(),m=h(),g=s("div"),$.c(),D=h(),k=s("div"),T&&T.c(),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"DIV",{class:!0});var c=n(a);d=l(c,"DIV",{class:!0});var i=n(d);I&&I.l(i),i.forEach(r),u=f(c),p=l(c,"DIV",{class:!0});var o=n(p);O&&O.l(o),o.forEach(r),m=f(c),g=l(c,"DIV",{class:!0});var h=n(g);$.l(h),h.forEach(r),D=f(c),k=l(c,"DIV",{class:!0});var v=n(k);T&&T.l(v),v.forEach(r),c.forEach(r),s.forEach(r),this.h()},h(){c(d,"class","weatherCurrent-data-location svelte-9kdo4s"),c(p,"class","weatherCurrent-data-date"),c(g,"class","weatherCurrent-data-kp svelte-9kdo4s"),c(k,"class","current-details svelte-9kdo4s"),c(a,"class","weatherCurrent-data svelte-9kdo4s"),c(t,"class","weatherCurrent-wrapper svelte-9kdo4s")},m(e,s){i(e,t,s),o(t,a),o(a,d),I&&I.m(d,null),o(a,u),o(a,p),O&&O.m(p,null),o(a,m),o(a,g),j[v].m(g,null),o(a,D),o(a,k),T&&T.m(k,null),y=!0},p(e,[t]){e[0].updating||!e[0].available||e[1].updating||e[2].updating?I&&(I.d(1),I=null):I?I.p(e,t):(I=F(e),I.c(),I.m(d,null)),e[1].updating||e[2].updating?O&&(O.d(1),O=null):O?O.p(e,t):(O=K(e),O.c(),O.m(p,null));let a=v;v=x(e),v===a?j[v].p(e,t):(_(),b(j[a],1,1,(()=>{j[a]=null})),w(),$=j[v],$?$.p(e,t):($=j[v]=V[v](e),$.c()),E($,1),$.m(g,null)),e[2].updating||e[1].updating?T&&(T.d(1),T=null):T?T.p(e,t):(T=Q(e),T.c(),T.m(k,null))},i(e){y||(E($),y=!0)},o(e){b($),y=!1},d(e){e&&r(t),I&&I.d(),O&&O.d(),j[v].d(),T&&T.d()}}}function X(e,t,a){let s,l,n;return $(e,A,(e=>a(0,s=e))),$(e,B,(e=>a(1,l=e))),$(e,J,(e=>a(2,n=e))),[s,l,n]}!async function(){if("undefined"==typeof window)return;let e;z(A,!0);try{e=await async function(){return new Promise(((e,t)=>{"undefined"!=typeof navigator?navigator.geolocation.getCurrentPosition((t=>{e({longitude:t.coords.longitude,latitude:t.coords.latitude})}),(e=>{t(e)})):t(Error())}))}()}catch(e){return console.log(e),A.update((e=>Object.assign(Object.assign({},e),{available:!1,city:null,longitude:null,latitude:null}))),void z(A,!1)}let t=await fetch(`https://geocode.xyz/${e.latitude},${e.longitude}?geoit=json`),a=await t.json();A.update((t=>Object.assign(Object.assign(Object.assign({},t),{available:!0,city:a.city}),e))),z(A,!1)}(),A.subscribe((async function(e=null){if("undefined"==typeof window)return;if(null===e)return;if(e.updating)return;if(!e.available)return B.update((e=>Object.assign(Object.assign({},e),{available:!1}))),void z(B,!1);z(B,!0);let t=await fetch(`https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${e.latitude}&lon=${e.longitude}`),a=await t.json(),s={clouds:null,temp:null};try{s.clouds=a.properties.timeseries[0].data.instant.details.cloud_area_fraction,s.temp=a.properties.timeseries[0].data.instant.details.air_temperature,a.properties.timeseries=a.properties.timeseries.map((e=>Object.assign(Object.assign({},e),{time:new Date(e.time)})))}catch(e){}B.update((e=>Object.assign(Object.assign({},e),{yr_data_raw:a,now:s,available:!0}))),z(B,!1)})),async function(){if("undefined"==typeof window)return;z(J,!0);let e=await async function(){let e,t={now:{bz:"-",bt:"-",kp:"-",kp_min:"-",kp_max:"-"},usnoaa_data_raw:{solar_wind_mag_field:!1,noaa_planetary_k_index_forecast:!1,geospace_pred_est_kp_1_hour:!1,outlook_27_day:!1}},a=await fetch("https://services.swpc.noaa.gov/products/summary/solar-wind-mag-field.json");t.usnoaa_data_raw.solar_wind_mag_field=await a.json(),t.usnoaa_data_raw.solar_wind_mag_field.TimeStamp=new Date(t.usnoaa_data_raw.solar_wind_mag_field.TimeStamp+" UTC"),t.now.bz=t.usnoaa_data_raw.solar_wind_mag_field.Bz,t.now.bt=t.usnoaa_data_raw.solar_wind_mag_field.Bt,a=await fetch("https://services.swpc.noaa.gov/json/geospace/geospace_pred_est_kp_1_hour.json"),e=await a.json(),e=e.map((e=>Object.assign(Object.assign({},e),{model_prediction_time:new Date(e.model_prediction_time)}))),t.usnoaa_data_raw.geospace_pred_est_kp_1_hour=e,a=await fetch("https://services.swpc.noaa.gov/text/27-day-outlook.txt"),e=await a.text(),e=[...e.matchAll(/^(?<time>\d{4}\s.{3}\s\d{2})\s+(?<flux107>\d+)\s+(?<aindex>\d+)\s+(?<kindex>\d+)$/gm)],e=e.map((e=>Object.assign(Object.assign({},e.groups),{time:new Date(e.groups.time+" UTC")}))),t.usnoaa_data_raw.outlook_27_day=e,a=await fetch("https://services.swpc.noaa.gov/products/noaa-planetary-k-index-forecast.json"),t.usnoaa_data_raw.noaa_planetary_k_index_forecast=await a.json(),t.usnoaa_data_raw.noaa_planetary_k_index_forecast.shift();let s=new Date,l=new Date(0,0,0),n=1e3,r=0;return t.usnoaa_data_raw.noaa_planetary_k_index_forecast.forEach(((e,a)=>{e[1]>r&&(r=e[1]),e[1]<n&&(n=e[1]);let c=new Date(e[0]+" UTC");Math.abs(c.getTime()-s.getTime())<Math.abs(l.getTime()-s.getTime())&&(l=c,t.now.kp=e[1]),t.usnoaa_data_raw.noaa_planetary_k_index_forecast[a]={time:c,kp:e[1],observed:e[2]}})),t.now.kp_min=n.toString(),t.now.kp_max=r.toString(),console.log(t),t}();J.update((t=>Object.assign(Object.assign({},t),e))),z(J,!1)}();class Y extends e{constructor(e){super(),t(this,e,X,W,a,{})}}function ee(e){let t,a;const o=e[1].default,d=O(o,e,e[0],null);return{c(){t=s("div"),d&&d.c(),this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);d&&d.l(a),a.forEach(r),this.h()},h(){c(t,"class","chip svelte-6dfxfp")},m(e,s){i(e,t,s),d&&d.m(t,null),a=!0},p(e,[t]){d&&d.p&&(!a||1&t)&&V(d,o,e,e[0],a?x(o,e[0],t,null):j(e[0]),null)},i(e){a||(E(d,e),a=!0)},o(e){b(d,e),a=!1},d(e){e&&r(t),d&&d.d(e)}}}function te(e,t,a){let{$$slots:s={},$$scope:l}=t;return e.$$set=e=>{"$$scope"in e&&a(0,l=e.$$scope)},[l,s]}class ae extends e{constructor(e){super(),t(this,e,te,ee,a,{})}}function se(e){let t,a,u,g,v,_,b,w,E,$,D,k,y=e[5]&&function(e){let t,a,u,g,v,_,b,w,E,$,D,k,y=Math.round(e[3])+"",I=Math.round(e[4])+"";return{c(){t=s("div"),a=s("p"),u=s("i"),g=h(),v=p(y),_=p("°C"),b=h(),w=s("p"),E=s("i"),$=h(),D=p(I),k=p("%"),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"P",{class:!0});var c=n(a);u=l(c,"I",{class:!0}),n(u).forEach(r),g=f(c),v=m(c,y),_=m(c,"°C"),c.forEach(r),b=f(s),w=l(s,"P",{class:!0});var i=n(w);E=l(i,"I",{class:!0}),n(E).forEach(r),$=f(i),D=m(i,I),k=m(i,"%"),i.forEach(r),s.forEach(r),this.h()},h(){c(u,"class","fas fa-thermometer-half svelte-ghmp86"),c(a,"class","svelte-ghmp86"),c(E,"class","fas fa-cloud svelte-ghmp86"),c(w,"class","svelte-ghmp86"),c(t,"class","svelte-ghmp86")},m(e,s){i(e,t,s),o(t,a),o(a,u),o(a,g),o(a,v),o(a,_),o(t,b),o(t,w),o(w,E),o(w,$),o(w,D),o(w,k)},p:d,d(e){e&&r(t)}}}(e);return{c(){t=s("div"),a=s("div"),u=s("h3"),g=p(e[2]),v=h(),_=s("p"),b=p(e[1]),w=h(),E=s("div"),$=s("h2"),D=p(e[0]),k=h(),y&&y.c(),this.h()},l(s){t=l(s,"DIV",{class:!0});var c=n(t);a=l(c,"DIV",{class:!0});var i=n(a);u=l(i,"H3",{class:!0});var o=n(u);g=m(o,e[2]),o.forEach(r),v=f(i),_=l(i,"P",{class:!0});var d=n(_);b=m(d,e[1]),d.forEach(r),i.forEach(r),w=f(c),E=l(c,"DIV",{class:!0});var h=n(E);$=l(h,"H2",{class:!0});var p=n($);D=m(p,e[0]),p.forEach(r),k=f(h),y&&y.l(h),h.forEach(r),c.forEach(r),this.h()},h(){c(u,"class","svelte-ghmp86"),c(_,"class","svelte-ghmp86"),c(a,"class","svelte-ghmp86"),c($,"class","svelte-ghmp86"),c(E,"class","data svelte-ghmp86"),c(t,"class","prediction-details svelte-ghmp86")},m(e,s){i(e,t,s),o(t,a),o(a,u),o(u,g),o(a,v),o(a,_),o(_,b),o(t,w),o(t,E),o(E,$),o($,D),o(E,k),y&&y.m(E,null)},p(e,[t]){e[5]&&y.p(e,t)},i:d,o:d,d(e){e&&r(t),y&&y.d()}}}function le(e,t=2){let a=e;for(let s=0;s<t-e.length;s++)a="0"+a;return a}function ne(e,t,a){let{prediction:s}=t;let l=s.kp,n=s.time.getDate()+". "+["January","February","March","April","May","June","July","August","September","October","November","December"][s.time.getMonth()],r=le(s.time.getHours().toString())+":"+le(s.time.getMinutes().toString()),c=s.temp,i=s.clouds,o=s.hasNOMETData;return e.$$set=e=>{"prediction"in e&&a(6,s=e.prediction)},[l,n,r,c,i,o,s]}class re extends e{constructor(e){super(),t(this,e,ne,se,a,{prediction:6})}}function ce(e,t,a){const s=e.slice();return s[5]=t[a],s[7]=a,s}function ie(e){let t,a;return t=new re({props:{prediction:e[5]}}),{c(){D(t.$$.fragment)},l(e){k(t.$$.fragment,e)},m(e,s){y(t,e,s),a=!0},p(e,a){const s={};1&a&&(s.prediction=e[5]),t.$set(s)},i(e){a||(E(t.$$.fragment,e),a=!0)},o(e){b(t.$$.fragment,e),a=!1},d(e){I(t,e)}}}function oe(e){let t,a,o=e[0],d=[];for(let t=0;t<o.length;t+=1)d[t]=ie(ce(e,o,t));const u=e=>b(d[e],1,1,(()=>{d[e]=null}));return{c(){t=s("div");for(let e=0;e<d.length;e+=1)d[e].c();this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);for(let e=0;e<d.length;e+=1)d[e].l(a);a.forEach(r),this.h()},h(){c(t,"class","prediction-table svelte-dqc8qx")},m(e,s){i(e,t,s);for(let e=0;e<d.length;e+=1)d[e].m(t,null);a=!0},p(e,[a]){if(1&a){let s;for(o=e[0],s=0;s<o.length;s+=1){const l=ce(e,o,s);d[s]?(d[s].p(l,a),E(d[s],1)):(d[s]=ie(l),d[s].c(),E(d[s],1),d[s].m(t,null))}for(_(),s=o.length;s<d.length;s+=1)u(s);w()}},i(e){if(!a){for(let e=0;e<o.length;e+=1)E(d[e]);a=!0}},o(e){d=d.filter(Boolean);for(let e=0;e<d.length;e+=1)b(d[e]);a=!1},d(e){e&&r(t),T(d,e)}}}function de(e,t,a){let s,l,n;async function r(){if(l.updating||s.updating)return void a(0,n=null);let e=l.usnoaa_data_raw.geospace_pred_est_kp_1_hour.filter((e=>e.model_prediction_time>=new Date));a(0,n=e.map((e=>({time:e.model_prediction_time,kp:Math.round(e.k),temp:null,clouds:null,hasNOMETData:s.available})))),s.available&&n.forEach(((e,t)=>{let l,r,c=new Date(0,0,0),i=!0;s.yr_data_raw.properties.timeseries.forEach(((t,a)=>{let s=new Date(t.time);if(Math.abs(s.getTime()-e.time.getTime())<Math.abs(c.getTime()-e.time.getTime())){if(Math.abs(s.getTime()-e.time.getTime())>18e6)return void(i=!1);c=s,l=t.data.instant.details.air_temperature,r=t.data.instant.details.cloud_area_fraction}})),a(0,n[t]=Object.assign(Object.assign({},n[t]),{temp:l,clouds:r,hasNOMETData:i}),n)}))}return $(e,B,(e=>a(1,s=e))),$(e,J,(e=>a(2,l=e))),J.subscribe(r),B.subscribe(r),[n]}class ue extends e{constructor(e){super(),t(this,e,de,oe,a,{})}}function he(e){let t,a,o;return a=new ae({props:{$$slots:{default:[pe]},$$scope:{ctx:e}}}),{c(){t=s("div"),D(a.$$.fragment),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);k(a.$$.fragment,s),s.forEach(r),this.h()},h(){c(t,"class","svelte-ghmp86")},m(e,s){i(e,t,s),y(a,t,null),o=!0},p(e,t){const s={};257&t&&(s.$$scope={dirty:t,ctx:e}),a.$set(s)},i(e){o||(E(a.$$.fragment,e),o=!0)},o(e){b(a.$$.fragment,e),o=!1},d(e){e&&r(t),I(a)}}}function pe(e){let t,a=e[0].observed+"";return{c(){t=p(a)},l(e){t=m(e,a)},m(e,a){i(e,t,a)},p(e,s){1&s&&a!==(a=e[0].observed+"")&&g(t,a)},d(e){e&&r(t)}}}function fe(e){let t,a,u,g,v,$,D,k,y,I,O,V,j,x,T="predicted"!=e[0].observed&&he(e),M=e[6]&&function(e){let t,a,u,g,v,_,b,w,E,$,D,k,y=Math.round(e[4])+"",I=Math.round(e[5])+"";return{c(){t=s("div"),a=s("p"),u=s("i"),g=h(),v=p(y),_=p("°C"),b=h(),w=s("p"),E=s("i"),$=h(),D=p(I),k=p("%"),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"P",{class:!0});var c=n(a);u=l(c,"I",{class:!0}),n(u).forEach(r),g=f(c),v=m(c,y),_=m(c,"°C"),c.forEach(r),b=f(s),w=l(s,"P",{class:!0});var i=n(w);E=l(i,"I",{class:!0}),n(E).forEach(r),$=f(i),D=m(i,I),k=m(i,"%"),i.forEach(r),s.forEach(r),this.h()},h(){c(u,"class","fas fa-thermometer-half svelte-ghmp86"),c(a,"class","svelte-ghmp86"),c(E,"class","fas fa-cloud svelte-ghmp86"),c(w,"class","svelte-ghmp86"),c(t,"class","svelte-ghmp86")},m(e,s){i(e,t,s),o(t,a),o(a,u),o(a,g),o(a,v),o(a,_),o(t,b),o(t,w),o(w,E),o(w,$),o(w,D),o(w,k)},p:d,d(e){e&&r(t)}}}(e);return{c(){t=s("div"),a=s("div"),u=s("h3"),g=p(e[3]),v=h(),$=s("p"),D=p(e[2]),k=h(),T&&T.c(),y=h(),I=s("div"),O=s("h2"),V=p(e[1]),j=h(),M&&M.c(),this.h()},l(s){t=l(s,"DIV",{class:!0});var c=n(t);a=l(c,"DIV",{class:!0});var i=n(a);u=l(i,"H3",{class:!0});var o=n(u);g=m(o,e[3]),o.forEach(r),v=f(i),$=l(i,"P",{class:!0});var d=n($);D=m(d,e[2]),d.forEach(r),i.forEach(r),k=f(c),T&&T.l(c),y=f(c),I=l(c,"DIV",{class:!0});var h=n(I);O=l(h,"H2",{class:!0});var p=n(O);V=m(p,e[1]),p.forEach(r),j=f(h),M&&M.l(h),h.forEach(r),c.forEach(r),this.h()},h(){c(u,"class","svelte-ghmp86"),c($,"class","svelte-ghmp86"),c(a,"class","svelte-ghmp86"),c(O,"class","svelte-ghmp86"),c(I,"class","data svelte-ghmp86"),c(t,"class","prediction-details svelte-ghmp86")},m(e,s){i(e,t,s),o(t,a),o(a,u),o(u,g),o(a,v),o(a,$),o($,D),o(t,k),T&&T.m(t,null),o(t,y),o(t,I),o(I,O),o(O,V),o(I,j),M&&M.m(I,null),x=!0},p(e,[a]){"predicted"!=e[0].observed?T?(T.p(e,a),1&a&&E(T,1)):(T=he(e),T.c(),E(T,1),T.m(t,y)):T&&(_(),b(T,1,1,(()=>{T=null})),w()),e[6]&&M.p(e,a)},i(e){x||(E(T),x=!0)},o(e){b(T),x=!1},d(e){e&&r(t),T&&T.d(),M&&M.d()}}}function me(e,t=2){let a=e;for(let s=0;s<t-e.length;s++)a="0"+a;return a}function ge(e,t,a){let{prediction:s}=t;let l=s.kp,n=s.time.getDate()+". "+["January","February","March","April","May","June","July","August","September","October","November","December"][s.time.getMonth()],r=me(s.time.getHours().toString())+":"+me(s.time.getMinutes().toString()),c=s.temp,i=s.clouds,o=s.hasNOMETData;return e.$$set=e=>{"prediction"in e&&a(0,s=e.prediction)},[s,l,n,r,c,i,o]}class ve extends e{constructor(e){super(),t(this,e,ge,fe,a,{prediction:0})}}function _e(e,t,a){const s=e.slice();return s[5]=t[a],s[7]=a,s}function be(e){let t,a;return t=new ve({props:{prediction:e[5]}}),{c(){D(t.$$.fragment)},l(e){k(t.$$.fragment,e)},m(e,s){y(t,e,s),a=!0},p(e,a){const s={};1&a&&(s.prediction=e[5]),t.$set(s)},i(e){a||(E(t.$$.fragment,e),a=!0)},o(e){b(t.$$.fragment,e),a=!1},d(e){I(t,e)}}}function we(e){let t,a,o=e[0],d=[];for(let t=0;t<o.length;t+=1)d[t]=be(_e(e,o,t));const u=e=>b(d[e],1,1,(()=>{d[e]=null}));return{c(){t=s("div");for(let e=0;e<d.length;e+=1)d[e].c();this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);for(let e=0;e<d.length;e+=1)d[e].l(a);a.forEach(r),this.h()},h(){c(t,"class","prediction-table svelte-dqc8qx")},m(e,s){i(e,t,s);for(let e=0;e<d.length;e+=1)d[e].m(t,null);a=!0},p(e,[a]){if(1&a){let s;for(o=e[0],s=0;s<o.length;s+=1){const l=_e(e,o,s);d[s]?(d[s].p(l,a),E(d[s],1)):(d[s]=be(l),d[s].c(),E(d[s],1),d[s].m(t,null))}for(_(),s=o.length;s<d.length;s+=1)u(s);w()}},i(e){if(!a){for(let e=0;e<o.length;e+=1)E(d[e]);a=!0}},o(e){d=d.filter(Boolean);for(let e=0;e<d.length;e+=1)b(d[e]);a=!1},d(e){e&&r(t),T(d,e)}}}function Ee(e,t,a){let s,l,n;async function r(){if(l.updating||s.updating)return void a(0,n=null);let e=l.usnoaa_data_raw.noaa_planetary_k_index_forecast.filter((e=>"observed"!==e.observed));a(0,n=e.map((e=>({time:e.time,kp:e.kp,observed:e.observed,temp:null,clouds:null,hasNOMETData:s.available})))),s.available&&n.forEach(((e,t)=>{let l,r,c=new Date(0,0,0);s.yr_data_raw.properties.timeseries.forEach(((t,a)=>{let s=new Date(t.time);Math.abs(s.getTime()-e.time.getTime())<Math.abs(c.getTime()-e.time.getTime())&&(c=s,l=t.data.instant.details.air_temperature,r=t.data.instant.details.cloud_area_fraction)})),a(0,n[t]=Object.assign(Object.assign({},n[t]),{temp:l,clouds:r}),n)}))}return $(e,B,(e=>a(1,s=e))),$(e,J,(e=>a(2,l=e))),J.subscribe(r),B.subscribe(r),[n]}class $e extends e{constructor(e){super(),t(this,e,Ee,we,a,{})}}function De(e){let t,a,u,g,v,_,b,w,E,$,D,k,y=e[5]&&function(e){let t,a,u,g,v,_,b,w,E,$,D,k,y=Math.round(e[3])+"",I=Math.round(e[4])+"";return{c(){t=s("div"),a=s("p"),u=s("i"),g=h(),v=p(y),_=p("°C"),b=h(),w=s("p"),E=s("i"),$=h(),D=p(I),k=p("%"),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"P",{class:!0});var c=n(a);u=l(c,"I",{class:!0}),n(u).forEach(r),g=f(c),v=m(c,y),_=m(c,"°C"),c.forEach(r),b=f(s),w=l(s,"P",{class:!0});var i=n(w);E=l(i,"I",{class:!0}),n(E).forEach(r),$=f(i),D=m(i,I),k=m(i,"%"),i.forEach(r),s.forEach(r),this.h()},h(){c(u,"class","fas fa-thermometer-half svelte-ghmp86"),c(a,"class","svelte-ghmp86"),c(E,"class","fas fa-cloud svelte-ghmp86"),c(w,"class","svelte-ghmp86"),c(t,"class","svelte-ghmp86")},m(e,s){i(e,t,s),o(t,a),o(a,u),o(a,g),o(a,v),o(a,_),o(t,b),o(t,w),o(w,E),o(w,$),o(w,D),o(w,k)},p:d,d(e){e&&r(t)}}}(e);return{c(){t=s("div"),a=s("div"),u=s("h3"),g=p(e[2]),v=h(),_=s("p"),b=p(e[1]),w=h(),E=s("div"),$=s("h2"),D=p(e[0]),k=h(),y&&y.c(),this.h()},l(s){t=l(s,"DIV",{class:!0});var c=n(t);a=l(c,"DIV",{class:!0});var i=n(a);u=l(i,"H3",{class:!0});var o=n(u);g=m(o,e[2]),o.forEach(r),v=f(i),_=l(i,"P",{class:!0});var d=n(_);b=m(d,e[1]),d.forEach(r),i.forEach(r),w=f(c),E=l(c,"DIV",{class:!0});var h=n(E);$=l(h,"H2",{class:!0});var p=n($);D=m(p,e[0]),p.forEach(r),k=f(h),y&&y.l(h),h.forEach(r),c.forEach(r),this.h()},h(){c(u,"class","svelte-ghmp86"),c(_,"class","svelte-ghmp86"),c(a,"class","svelte-ghmp86"),c($,"class","svelte-ghmp86"),c(E,"class","data svelte-ghmp86"),c(t,"class","prediction-details svelte-ghmp86")},m(e,s){i(e,t,s),o(t,a),o(a,u),o(u,g),o(a,v),o(a,_),o(_,b),o(t,w),o(t,E),o(E,$),o($,D),o(E,k),y&&y.m(E,null)},p(e,[t]){e[5]&&y.p(e,t)},i:d,o:d,d(e){e&&r(t),y&&y.d()}}}function ke(e,t=2){let a=e;for(let s=0;s<t-e.length;s++)a="0"+a;return a}function ye(e,t,a){let{prediction:s}=t;let l=s.kp,n=s.time.getDate()+". "+["January","February","March","April","May","June","July","August","September","October","November","December"][s.time.getMonth()],r=ke(s.time.getHours().toString())+":"+ke(s.time.getMinutes().toString()),c=s.temp,i=s.clouds,o=s.hasNOMETData;return e.$$set=e=>{"prediction"in e&&a(6,s=e.prediction)},[l,n,r,c,i,o,s]}class Ie extends e{constructor(e){super(),t(this,e,ye,De,a,{prediction:6})}}function Oe(e,t,a){const s=e.slice();return s[5]=t[a],s[7]=a,s}function Ve(e){let t,a;return t=new Ie({props:{prediction:e[5]}}),{c(){D(t.$$.fragment)},l(e){k(t.$$.fragment,e)},m(e,s){y(t,e,s),a=!0},p(e,a){const s={};1&a&&(s.prediction=e[5]),t.$set(s)},i(e){a||(E(t.$$.fragment,e),a=!0)},o(e){b(t.$$.fragment,e),a=!1},d(e){I(t,e)}}}function je(e){let t,a,o=e[0],d=[];for(let t=0;t<o.length;t+=1)d[t]=Ve(Oe(e,o,t));const u=e=>b(d[e],1,1,(()=>{d[e]=null}));return{c(){t=s("div");for(let e=0;e<d.length;e+=1)d[e].c();this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);for(let e=0;e<d.length;e+=1)d[e].l(a);a.forEach(r),this.h()},h(){c(t,"class","prediction-table svelte-dqc8qx")},m(e,s){i(e,t,s);for(let e=0;e<d.length;e+=1)d[e].m(t,null);a=!0},p(e,[a]){if(1&a){let s;for(o=e[0],s=0;s<o.length;s+=1){const l=Oe(e,o,s);d[s]?(d[s].p(l,a),E(d[s],1)):(d[s]=Ve(l),d[s].c(),E(d[s],1),d[s].m(t,null))}for(_(),s=o.length;s<d.length;s+=1)u(s);w()}},i(e){if(!a){for(let e=0;e<o.length;e+=1)E(d[e]);a=!0}},o(e){d=d.filter(Boolean);for(let e=0;e<d.length;e+=1)b(d[e]);a=!1},d(e){e&&r(t),T(d,e)}}}function xe(e,t,a){let s,l,n;async function r(){if(l.updating||s.updating)return void a(0,n=null);let e=l.usnoaa_data_raw.outlook_27_day.filter((e=>e.time>=new Date));a(0,n=e.map((e=>({time:e.time,kp:e.kindex,temp:null,clouds:null,hasNOMETData:s.available})))),s.available&&n.forEach(((e,t)=>{let l,r,c=new Date(0,0,0),i=!0;s.yr_data_raw.properties.timeseries.forEach(((t,a)=>{let s=new Date(t.time);if(Math.abs(s.getTime()-e.time.getTime())<Math.abs(c.getTime()-e.time.getTime())){if(Math.abs(s.getTime()-e.time.getTime())>864e5)return void(i=!1);c=s,l=t.data.instant.details.air_temperature,r=t.data.instant.details.cloud_area_fraction}})),a(0,n[t]=Object.assign(Object.assign({},n[t]),{temp:l,clouds:r,hasNOMETData:i}),n)}))}return $(e,B,(e=>a(1,s=e))),$(e,J,(e=>a(2,l=e))),J.subscribe(r),B.subscribe(r),[n]}class Te extends e{constructor(e){super(),t(this,e,xe,je,a,{})}}function Me(e){let t,a,u,g,v;return{c(){t=s("div"),a=s("i"),u=h(),g=s("p"),v=p("No prediction data"),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"I",{class:!0}),n(a).forEach(r),u=f(s),g=l(s,"P",{});var c=n(g);v=m(c,"No prediction data"),c.forEach(r),s.forEach(r),this.h()},h(){c(a,"class","fas fa-7x fa-exclamation-triangle"),c(t,"class","no-data svelte-6c4yca")},m(e,s){i(e,t,s),o(t,a),o(t,u),o(t,g),o(g,v)},p:d,i:d,o:d,d(e){e&&r(t)}}}function Pe(e){let t,a,d,u,g,$,O,V,j,x,T,C,N,q,H,A,B,J,z;var F=e[0];return F&&(H=new F({})),{c(){t=s("div"),a=s("h2"),d=p("Forecast"),u=h(),g=s("div"),$=s("div"),O=p("hour"),V=h(),j=s("div"),x=p("3 day"),T=h(),C=s("div"),N=p("Long time"),q=h(),H&&D(H.$$.fragment),A=v(),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"H2",{class:!0});var c=n(a);d=m(c,"Forecast"),c.forEach(r),u=f(s),g=l(s,"DIV",{class:!0});var i=n(g);$=l(i,"DIV",{class:!0});var o=n($);O=m(o,"hour"),o.forEach(r),V=f(i),j=l(i,"DIV",{class:!0});var h=n(j);x=m(h,"3 day"),h.forEach(r),T=f(i),C=l(i,"DIV",{class:!0});var p=n(C);N=m(p,"Long time"),p.forEach(r),i.forEach(r),s.forEach(r),q=f(e),H&&k(H.$$.fragment,e),A=v(),this.h()},h(){c(a,"class","svelte-6c4yca"),c($,"class","svelte-6c4yca"),M($,"selected",e[0]==ue),c(j,"class","svelte-6c4yca"),M(j,"selected",e[0]==$e),c(C,"class","svelte-6c4yca"),M(C,"selected",e[0]==Te),c(g,"class","version-picker svelte-6c4yca"),c(t,"class","header svelte-6c4yca")},m(s,l){i(s,t,l),o(t,a),o(a,d),o(t,u),o(t,g),o(g,$),o($,O),o(g,V),o(g,j),o(j,x),o(g,T),o(g,C),o(C,N),i(s,q,l),H&&y(H,s,l),i(s,A,l),B=!0,J||(z=[P($,"click",e[3]),P(j,"click",e[4]),P(C,"click",e[5])],J=!0)},p(e,t){if(1&t&&M($,"selected",e[0]==ue),1&t&&M(j,"selected",e[0]==$e),1&t&&M(C,"selected",e[0]==Te),F!==(F=e[0])){if(H){_();const e=H;b(e.$$.fragment,1,0,(()=>{I(e,1)})),w()}F?(H=new F({}),D(H.$$.fragment),E(H.$$.fragment,1),y(H,A.parentNode,A)):H=null}},i(e){B||(H&&E(H.$$.fragment,e),B=!0)},o(e){H&&b(H.$$.fragment,e),B=!1},d(e){e&&r(t),e&&r(q),e&&r(A),H&&I(H,e),J=!1,S(z)}}}function Se(e){let t,a,o,d;const u=[Pe,Me],h=[];function p(e,t){return e[1].updating||e[2].updating?1:0}return a=p(e),o=h[a]=u[a](e),{c(){t=s("div"),o.c(),this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);o.l(a),a.forEach(r),this.h()},h(){c(t,"class","drawer svelte-6c4yca")},m(e,s){i(e,t,s),h[a].m(t,null),d=!0},p(e,[s]){let l=a;a=p(e),a===l?h[a].p(e,s):(_(),b(h[l],1,1,(()=>{h[l]=null})),w(),o=h[a],o?o.p(e,s):(o=h[a]=u[a](e),o.c()),E(o,1),o.m(t,null))},i(e){d||(E(o),d=!0)},o(e){b(o),d=!1},d(e){e&&r(t),h[a].d()}}}function Ce(e,t,a){let s,l;$(e,B,(e=>a(1,s=e))),$(e,J,(e=>a(2,l=e)));let n=$e;return[n,s,l,()=>a(0,n=ue),()=>a(0,n=$e),()=>a(0,n=Te)]}class Ne extends e{constructor(e){super(),t(this,e,Ce,Se,a,{})}}function qe(e){let t,a,u,p,m,g;return u=new Y({}),m=new Ne({}),{c(){t=h(),a=s("div"),D(u.$$.fragment),p=h(),D(m.$$.fragment),this.h()},l(e){C('[data-svelte="svelte-1q3846k"]',document.head).forEach(r),t=f(e),a=l(e,"DIV",{class:!0});var s=n(a);k(u.$$.fragment,s),p=f(s),k(m.$$.fragment,s),s.forEach(r),this.h()},h(){document.title="Aurora data",c(a,"class","homescreen svelte-pf4p6y")},m(e,s){i(e,t,s),i(e,a,s),y(u,a,null),o(a,p),y(m,a,null),g=!0},p:d,i(e){g||(E(u.$$.fragment,e),E(m.$$.fragment,e),g=!0)},o(e){b(u.$$.fragment,e),b(m.$$.fragment,e),g=!1},d(e){e&&r(t),e&&r(a),I(u),I(m)}}}class He extends e{constructor(e){super(),t(this,e,null,qe,a,{})}}export{He as default};