var freeaps_glucoseGetLast;(()=>{var e={6237:e=>{function t(e){return e.date||Date.parse(e.display_time)||Date.parse(e.dateString)}e.exports=function(e){for(var r=(e=e.filter((function(e){return e.glucose||e.sgv})).map((function(e){if(e.glucose=e.glucose||e.sgv,null!==e.glucose)return e})))[0],o=t(r),n=[],u=[],a=[],l=0,s=1;s<e.length;s++){if(void 0!==e[s]&&"cal"===e[s].type){l=s;break}if(void 0!==e[s]&&e[s].glucose>38&&e[s].device===r.device){var c,d=e[s],g=t(d),i=0;void 0!==g&&void 0!==o?(c=Math.round((o-g)/6e4),i=(r.glucose-d.glucose)/c*5):console.error("Error: date field not found: cannot calculate avgdelta"),-2<c&&c<2.5?(r.glucose=(r.glucose+d.glucose)/2,o=(o+g)/2):2.5<c&&c<17.5?(u.push(i),2.5<c&&c<7.5&&n.push(i)):17.5<c&&c<42.5&&a.push(i)}}var v=0,f=0,h=0;return n.length>0&&(v=n.reduce((function(e,t){return e+t}))/n.length),u.length>0&&(f=u.reduce((function(e,t){return e+t}))/u.length),a.length>0&&(h=a.reduce((function(e,t){return e+t}))/a.length),{delta:Math.round(100*v)/100,glucose:Math.round(100*r.glucose)/100,noise:Math.round(r.noise),short_avgdelta:Math.round(100*f)/100,long_avgdelta:Math.round(100*h)/100,date:o,last_cal:l,device:r.device}}}},t={};var r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var u=t[o]={exports:{}};return e[o](u,u.exports,r),u.exports}(6237);freeaps_glucoseGetLast=r})();