diff --git a/FreeAPS/Resources/javascript/bundle/determine-basal.js b/FreeAPS/Resources/javascript/bundle/determine-basal.js index ad36ca9e3d..9d9cad486c 100644 --- a/FreeAPS/Resources/javascript/bundle/determine-basal.js +++ b/FreeAPS/Resources/javascript/bundle/determine-basal.js @@ -1 +1 @@ -var freeaps_determineBasal;(()=>{var e={5546:(e,t,a)=>{var r=a(6880);function o(e,t){t||(t=0);var a=Math.pow(10,t);return Math.round(e*a)/a}function n(e,t){return"mmol/L"===t.out_units?o(.0555*e,1):Math.round(e)}e.exports=function(e,t,a,i,s,l,u,m,d,c,g,h,p,v){var B=i.min_bg,f=v.overrideTarget;const b=v.smbIsOff,M=v.advancedSettings,_=v.isfAndCr,y=v.isf,x=v.cr,S=v.smbIsAlwaysOff,D=v.start,w=v.end,G=v.smbMinutes,T=v.uamMinutes;var C=0,U=B,O=0,R="",A="",I="",F="",j="",P=0,E=0,q=0,W=0,k=0,L=0;const z=v.weightedAverage;var N=1,H=i.sens,Z=i.carb_ratio;v.useOverride&&(N=v.overridePercentage/100,_?(H/=N,Z/=N):(x&&(Z/=N),y&&(H/=N)));const $=i.weightPercentage,J=v.average_total_data;function K(e,t){var a=e.getTime();return new Date(a+36e5*t)}function Q(e){var t=i.bolus_increment;.1!=t&&(t=.05);var a=e/t;return a>=1?o(Math.floor(a)*t,5):0}function V(e){function t(e){return e<10&&(e="0"+e),e}return t(e.getHours())+":"+t(e.getMinutes())+":00"}function X(e,t){var a=new Date("1/1/1999 "+e),r=new Date("1/1/1999 "+t);return(a.getTime()-r.getTime())/36e5}function Y(e,t){var a=0,r=t,o=(e-t)/36e5,n=0,i=o,s=0;do{if(o>0){var l=V(r),u=p[0].rate;for(let e=0;e=(s=X(p[e+1].start,p[e].start))?n=s:o=s?n=s:om)if(e+1=(s=X(d,l))?n=s:o=(s=X("23:59:59",l))?n=s:o0&&o21)k=Y(ee,(ae=24-O,re=ee.getTime(),new Date(re-36e5*ae))),F="24 hours of data is required for an accurate tdd calculation. Currently only "+O.toPrecision(3)+" hours of pump history data are available. Using your pump scheduled basals to fill in the missing hours. Scheduled basals added: "+k.toPrecision(5)+" U. ";else O<21?(pe=!1,enableDynamicCR=!1):F=""}else console.log("Pumphistory is empty!"),pe=!1,enableDynamicCR=!1;var ae,re;for(let e=0;e0){P=e,L=g[e].rate;var oe=g[e-1]["duration (min)"]/60,ne=oe,ie=new Date(g[e-1].timestamp),se=ie,le=0;do{if(e--,0==e){se=new Date;break}if("TempBasal"==g[e]._type||"PumpSuspend"==g[e]._type){se=new Date(g[e].timestamp);break}var ue=e-2;if(ue>=0&&"Rewind"==g[ue]._type){let e=g[ue].timestamp;for(;ue-1>=0&&"Prime"==g[ue-=1]._type;)le=(g[ue].timestamp-e)/36e5;le>=oe&&(se=e,le=0)}}while(e>0);var me=(se-ie)/36e5;me0&&(--r,"TempBasal"==g[r]._type)){a=new Date(g[r].timestamp);break}}while(r>0);(a-t)/36e5>0&&(k+=Y(a,t))}for(let e=g.length-1;e>0;e--)if("TempBasalDuration"==g[e]._type){let t=g[e]["duration (min)"]/60,a=new Date(g[e].timestamp);var de=a;let r=e;do{if(--r,r>=0&&("TempBasal"==g[r]._type||"PumpSuspend"==g[r]._type)){de=new Date(g[r].timestamp);break}}while(r>0);if(0==e&&"TempBasalDuration"==g[0]._type&&(de=new Date,t=g[e]["duration (min)"]/60),(de-a)/36e5-t>0){k+=Y(de,K(a,t))}}var ce,ge={TDD:o(E=W+q+k,5),bolus:o(W,5),temp_basal:o(q,5),scheduled_basal:o(k,5)};O>21?(A=". Bolus insulin: "+W.toPrecision(5)+" U",I=". Temporary basal insulin: "+q.toPrecision(5)+" U",R=". Insulin with scheduled basal rate: "+k.toPrecision(5)+" U",j=F+(" TDD past 24h is: "+E.toPrecision(5)+" U")+A+I+R,tddReason=", Total insulin: "+o(E,2)+" U, "+o(W/E*100,0)+"% Bolus "+o((q+k)/E*100,0)+"% Basal"):tddReason=", TDD: Not enough pumpData (< 21h)";const he=e.glucose;var pe=h.useNewFormula;const ve=h.enableDynamicCR,Be=Math.min(i.autosens_min,i.autosens_max),fe=Math.max(i.autosens_min,i.autosens_max);(fe==Be||fe<1||Be>1)&&(pe=!1,console.log("Dynamic ISF disabled due to current autosens settings"));const be=h.adjustmentFactor,Me=i.min_bg;var _e=!1,ye="",xe=1,Se="";J>0&&(xe=z/J),Se=xe>1?"Basal adjustment with a 24 hour to total average (up to 14 days of data) TDD ratio (limited by Autosens max setting). Basal Ratio: "+(xe=o(xe=Math.min(xe,i.autosens_max),2))+". Upper limit = Autosens max ("+i.autosens_max+")":xe<1?"Basal adjustment with a 24 hour to to total average (up to 14 days of data) TDD ratio (limited by Autosens min setting). Basal Ratio: "+(xe=o(xe=Math.max(xe,i.autosens_min),2))+". Lower limit = Autosens min ("+i.autosens_min+")":"Basal adjusted with a 24 hour to total average (up to 14 days of data) TDD ratio: "+xe,Se=", Basal ratio: "+xe,(i.high_temptarget_raises_sensitivity||i.exercise_mode||v.isEnabled)&&(_e=!0),Me>=118&&_e&&(pe=!1,ye="Dynamic ISF temporarily off due to a high temp target/exercising. Current min target: "+Me);var De=", Dynamic ratios log: ",we=", AF: "+be,Ge="BG: "+he+" mg/dl ("+(.0555*he).toPrecision(2)+" mmol/l)",Te="",Ce="";const Ue=h.curve,Oe=h.insulinPeakTime,Re=h.useCustomPeakTime;var Ae=55,Ie=65;switch(Ue){case"rapid-acting":Ie=65;break;case"ultra-rapid":Ie=50}Re?(Ae=120-Oe,console.log("Custom insulinpeakTime set to :"+Oe+", insulinFactor: "+Ae)):(Ae=120-Ie,console.log("insulinFactor set to : "+Ae)),ce=E,$<1&&z>0&&(E=z,console.log("Using weighted TDD average: "+o(E,2)+" U, instead of past 24 h ("+o(ce,2)+" U), weight: "+$),Ce=", Weighted TDD: "+o(E,2)+" U");const Fe=h.sigmoid;var je="";if(pe){var Pe=H*be*E*Math.log(he/Ae+1)/1800;Te=", Logarithmic formula"}if(pe&&Fe){const e=Be,t=fe-e,a=.0555*(he-i.min_bg);var Ee=xe,qe=fe-1;1==fe&&(qe=fe+.01-1);const r=Math.log10(1/qe-e/qe)/Math.log10(Math.E),o=a*be*Ee+r;Pe=t/(1+Math.exp(-o))+e,Te=", Sigmoid function"}var We=Z;const ke=o(Z,1);var Le="",ze="";if(pe&&E>0){if(Le=", Dynamic ISF/CR: On/",Pe>fe?(ye=", Dynamic ISF limited by autosens_max setting: "+fe+" ("+o(Pe,2)+"), ",ze=", Autosens/Dynamic Limit: "+fe+" ("+o(Pe,2)+")",Pe=fe):Pe-.5?"+"+o(e.delta,0):o(e.delta,0);var tt=Math.min(e.delta,e.short_avgdelta),at=Math.min(e.short_avgdelta,e.long_avgdelta),rt=Math.max(e.delta,e.short_avgdelta,e.long_avgdelta);(Ye<=10||38===Ye||et>=3)&&(He.reason="CGM is calibrating, in ??? state, or noise is high");if(Ye>60&&0==e.delta&&e.short_avgdelta>-1&&e.short_avgdelta<1&&e.long_avgdelta>-1&&e.long_avgdelta<1&&("fakecgm"==e.device?(console.error("CGM data is unchanged ("+n(Ye,i)+"+"+n(e.delta,i)+") for 5m w/ "+n(e.short_avgdelta,i)+" mg/dL ~15m change & "+n(e.long_avgdelta,2)+" mg/dL ~45m change"),console.error("Simulator mode detected ("+e.device+"): continuing anyway")):!0),Xe>12||Xe<-5?He.reason="If current system time "+Ke+" is correct, then BG data is too old. The last BG data was read "+Xe+"m ago at "+Ve:0===e.short_avgdelta&&0===e.long_avgdelta&&(e.last_cal&&e.last_cal<3?He.reason="CGM was just calibrated":He.reason="CGM data is unchanged ("+n(Ye,i)+"+"+n(e.delta,i)+") for 5m w/ "+n(e.short_avgdelta,i)+" mg/dL ~15m change & "+n(e.long_avgdelta,i)+" mg/dL ~45m change"),Ye<=10||38===Ye||et>=3||Xe>12||Xe<-5||0===e.short_avgdelta&&0===e.long_avgdelta)return t.rate>=Je?(He.reason+=". Canceling high temp basal of "+t.rate,He.deliverAt=Ze,He.temp="absolute",He.duration=0,He.rate=0,He):0===t.rate&&t.duration>30?(He.reason+=". Shortening "+t.duration+"m long zero temp to 30m. ",He.deliverAt=Ze,He.temp="absolute",He.duration=30,He.rate=0,He):(He.reason+=". Temp "+t.rate+" <= current basal "+Je+"U/hr; doing nothing. ",He);var ot,nt,it,st,lt=i.max_iob;if(void 0!==i.min_bg&&(nt=i.min_bg),void 0!==i.max_bg&&(it=i.max_bg),void 0!==i.enableSMB_high_bg_target&&(st=i.enableSMB_high_bg_target),void 0===i.min_bg||void 0===i.max_bg)return He.error="Error: could not determine target_bg. ",He;ot=(i.min_bg+i.max_bg)/2;var ut=i.exercise_mode||i.high_temptarget_raises_sensitivity||v.isEnabled,mt=100,dt=160;if(dt=i.half_basal_exercise_target,v.isEnabled){const e=v.hbt;console.log("Half Basal Target used: "+n(e,i)+" "+i.out_units),dt=e}else console.log("Default Half Basal Target used: "+n(dt,i)+" "+i.out_units);if(ut&&i.temptargetSet&&ot>mt||i.low_temptarget_lowers_sensitivity&&i.temptargetSet&&ot=ot&&sensitivityRatio0&&(process.stderr.write("TDD-adjustment of basals activated, using tdd24h_14d_Ratio "+o(xe,2)+", TDD 24h = "+o(ce,2)+"U, Weighted average TDD = "+o(z,2)+"U, (Weight percentage = "+$+"), Total data of TDDs (up to 14 days) average = "+o(J,2)+"U. "),Je!==$e*N?process.stderr.write("Adjusting basal from "+$e*N+" U/h to "+Je+" U/h; "):process.stderr.write("Basal unchanged: "+Je+" U/h; "))),i.temptargetSet);else if(void 0!==s&&s&&(i.sensitivity_raises_target&&s.ratio<1||i.resistance_lowers_target&&s.ratio>1)){nt=o((nt-60)/s.ratio)+60,it=o((it-60)/s.ratio)+60;var gt=o((ot-60)/s.ratio)+60;ot===(gt=Math.max(80,gt))?process.stderr.write("target_bg unchanged: "+n(gt,i)+"; "):process.stderr.write("target_bg from "+n(gt,i)+" to "+n(gt,i)+"; "),ot=gt}var ht=n(ot,i);ot!=B&&(ht=0!==f&&f!==ot?n(B,i)+"→"+n(f,i)+"→"+n(ot,i):n(B,i)+"→"+n(ot,i));var pt=200,vt=200,Bt=200;if(e.noise>=2){var ft=Math.max(1.1,i.noisyCGMTargetMultiplier);Math.min(250,i.maxRaw);pt=o(Math.min(200,nt*ft)),vt=o(Math.min(200,ot*ft)),Bt=o(Math.min(200,it*ft)),process.stderr.write("Raising target_bg for noisy / raw CGM data, from "+n(gt,i)+" to "+n(vt,i)+"; "),nt=pt,ot=vt,it=Bt}U=nt-.5*(nt-40);var bt=i.threshold_setting;bt>U&&bt<=120&&bt>=65?(console.error("Threshold changed in settings from "+n(U,i)+" to "+n(bt,i)+". "),U=bt):console.error("Current threshold: "+n(U,i));var Mt="",_t=(o(H,1),H);if(void 0!==s&&s&&((_t=o(_t=H/sensitivityRatio,1))!==H?process.stderr.write("ISF from "+n(H,i)+" to "+n(_t,i)):process.stderr.write("ISF unchanged: "+n(_t,i)),Mt+="Autosens ratio: "+o(sensitivityRatio,2)+", ISF: "+n(H,i)+"→"+n(_t,i)),console.error("CR:"+Z),void 0===a)return He.error="Error: iob_data undefined. ",He;var yt,xt=a;if(a.length,a.length>1&&(a=xt[0]),void 0===a.activity||void 0===a.iob)return He.error="Error: iob_data missing some property. ",He;var St=((yt=void 0!==a.lastTemp?o((new Date(Ke).getTime()-a.lastTemp.date)/6e4):0)+t.duration)%30;if(console.error("currenttemp:"+t.rate+" lastTempAge:"+yt+"m, tempModulus:"+St+"m"),He.temp="absolute",He.deliverAt=Ze,m&&t&&a.lastTemp&&t.rate!==a.lastTemp.rate&&yt>10&&t.duration)return He.reason="Warning: currenttemp rate "+t.rate+" != lastTemp rate "+a.lastTemp.rate+" from pumphistory; canceling temp",u.setTempBasal(0,0,i,He,t);if(t&&a.lastTemp&&t.duration>0){var Dt=yt-a.lastTemp.duration;if(Dt>5&&yt>10)return He.reason="Warning: currenttemp running but lastTemp from pumphistory ended "+Dt+"m ago; canceling temp",u.setTempBasal(0,0,i,He,t)}var wt=o(-a.activity*_t*5,2),Gt=o(6*(tt-wt));Gt<0&&(Gt=o(6*(at-wt)))<0&&(Gt=o(6*(e.long_avgdelta-wt)));var Tt=Ye,Ct=(Tt=a.iob>0?o(Ye-a.iob*_t):o(Ye-a.iob*Math.min(_t,H)))+Gt;if(void 0===Ct||isNaN(Ct))return He.error="Error: could not calculate eventualBG. Sensitivity: "+_t+" Deviation: "+Gt,He;var Ut,Ot,Rt=function(e,t,a){return o(a+(e-t)/24,1)}(ot,Ct,wt);He={temp:"absolute",bg:Ye,tick:Qe,eventualBG:Ct,insulinReq:0,reservoir:d,deliverAt:Ze,sensitivityRatio,TDD:ce,insulin:ge,current_target:ot,insulinForManualBolus:C,manualBolusErrorString:0,minDelta:tt,expectedDelta:Rt,minGuardBG:Ot,minPredBG:Ut,threshold:n(U,i)};var At=[],It=[],Ft=[],jt=[];At.push(Ye),It.push(Ye),jt.push(Ye),Ft.push(Ye);var Pt=function(e,t,a,r,o,i){return t?!e.allowSMB_with_high_temptarget&&e.temptargetSet&&o>100?(console.error("SMB disabled due to high temptarget of "+o),!1):!0===a.bwFound&&!1===e.A52_risk_enable?(console.error("SMB disabled due to Bolus Wizard activity in the last 6 hours."),!1):!0===e.enableSMB_always?(a.bwFound?console.error("Warning: SMB enabled within 6h of using Bolus Wizard: be sure to easy bolus 30s before using Bolus Wizard"):console.error("SMB enabled due to enableSMB_always"),!0):!0===e.enableSMB_with_COB&&a.mealCOB?(a.bwCarbs?console.error("Warning: SMB enabled with Bolus Wizard carbs: be sure to easy bolus 30s before using Bolus Wizard"):console.error("SMB enabled for COB of "+a.mealCOB),!0):!0===e.enableSMB_after_carbs&&a.carbs?(a.bwCarbs?console.error("Warning: SMB enabled with Bolus Wizard carbs: be sure to easy bolus 30s before using Bolus Wizard"):console.error("SMB enabled for 6h after carb entry"),!0):!0===e.enableSMB_with_temptarget&&e.temptargetSet&&o<100?(a.bwFound?console.error("Warning: SMB enabled within 6h of using Bolus Wizard: be sure to easy bolus 30s before using Bolus Wizard"):console.error("SMB enabled for temptarget of "+n(o,e)),!0):!0===e.enableSMB_high_bg&&null!==i&&r>=i?(console.error("Checking BG to see if High for SMB enablement."),console.error("Current BG",r," | High BG ",i),a.bwFound?console.error("Warning: High BG SMB enabled within 6h of using Bolus Wizard: be sure to easy bolus 30s before using Bolus Wizard"):console.error("High BG detected. Enabling SMB."),!0):(console.error("SMB disabled (no enableSMB preferences active or no condition satisfied)"),!1):(console.error("SMB disabled (!microBolusAllowed)"),!1)}(i,m,l,Ye,ot,st);if(b)if(S){let e=c.getHours();e>=D&&e<=w&&(console.error("SMB disabled by schedule (a Profile is active with SMBs disabled)"),Pt=!1)}else console.error("SMBs are disabled (a Profile is active with SMBs disabled)"),Pt=!1;var Et=i.enableUAM,qt=0,Wt=0;qt=o(tt-wt,1);var kt=o(tt-wt,1);csf=_t/Z,console.error("profile.sens:"+n(H,i)+", sens:"+n(_t,i)+", CSF:"+o(csf,1));var Lt=o(30*csf*5/60,1);qt>Lt&&(console.error("Limiting carb impact from "+qt+" to "+Lt+"mg/dL/5m (30g/h)"),qt=Lt);var zt=3;sensitivityRatio&&(zt/=sensitivityRatio);var Nt=zt;if(l.carbs){zt=Math.max(zt,l.mealCOB/20);var Ht=o((new Date(Ke).getTime()-l.lastCarbTime)/6e4),Zt=(l.carbs-l.mealCOB)/l.carbs;Nt=o(Nt=zt+1.5*Ht/60,1),console.error("Last carbs "+Ht+" minutes ago; remainingCATime:"+Nt+"hours; "+o(100*Zt,1)+"% carbs absorbed")}var $t=Math.max(0,qt/5*60*Nt/2)/csf,Jt=90,Kt=1;i.remainingCarbsCap&&(Jt=Math.min(90,i.remainingCarbsCap)),i.remainingCarbsFraction&&(Kt=Math.min(1,i.remainingCarbsFraction));var Qt=1-Kt,Vt=Math.max(0,l.mealCOB-$t-l.carbs*Qt),Xt=(Vt=Math.min(Jt,Vt))*csf*5/60/(Nt/2),Yt=o(l.slopeFromMaxDeviation,2),ea=o(l.slopeFromMinDeviation,2),ta=Math.min(Yt,-ea/3);Wt=0===qt?0:Math.min(60*Nt/5/2,Math.max(0,l.mealCOB*csf/qt)),console.error("Carb Impact:"+qt+"mg/dL per 5m; CI Duration:"+o(5*Wt/60*2,1)+"hours; remaining CI ("+Nt/2+"h peak):"+o(Xt,1)+"mg/dL per 5m");var aa,ra,oa,na,ia=999,sa=999,la=999,ua=999,ma=999,da=999,ca=999,ga=Ct,ha=Ye,pa=Ye,va=0,Ba=[],fa=[];try{xt.forEach((function(e){var t=o(-e.activity*_t*5,2),a=o(-e.iobWithZeroTemp.activity*_t*5,2),r=Tt,n=qt*(1-Math.min(1,It.length/12));if(!0===(pe&&!Fe))ga=It[It.length-1]+o(-e.activity*(1800/(E*be*Math.log(Math.max(It[It.length-1],39)/Ae+1)))*5,2)+n,r=jt[jt.length-1]+o(-e.iobWithZeroTemp.activity*(1800/(E*be*Math.log(Math.max(jt[jt.length-1],39)/Ae+1)))*5,2),console.log("Dynamic ISF (Logarithmic Formula) )adjusted predictions for IOB and ZT: IOBpredBG: "+o(ga,2)+" , ZTpredBG: "+o(r,2));else ga=It[It.length-1]+t+n,r=jt[jt.length-1]+a;var i=Math.max(0,Math.max(0,qt)*(1-At.length/Math.max(2*Wt,1))),s=Math.min(At.length,12*Nt-At.length),l=Math.max(0,s/(Nt/2*12)*Xt);i+l,Ba.push(o(l,0)),fa.push(o(i,0)),COBpredBG=At[At.length-1]+t+Math.min(0,n)+i+l;var u=Math.max(0,kt+Ft.length*ta),m=Math.max(0,kt*(1-Ft.length/Math.max(36,1))),d=Math.min(u,m);if(d>0&&(va=o(5*(Ft.length+1)/60,1)),!0===(pe&&!Fe))UAMpredBG=Ft[Ft.length-1]+o(-e.activity*(1800/(E*be*Math.log(Math.max(Ft[Ft.length-1],39)/Ae+1)))*5,2)+Math.min(0,n)+d,console.log("Dynamic ISF (Logarithmic Formula) adjusted prediction for UAM: UAMpredBG: "+o(UAMpredBG,2));else UAMpredBG=Ft[Ft.length-1]+t+Math.min(0,n)+d;It.length<48&&It.push(ga),At.length<48&&At.push(COBpredBG),Ft.length<48&&Ft.push(UAMpredBG),jt.length<48&&jt.push(r),COBpredBG18&&gaha&&(ha=ga),(Wt||Xt>0)&&At.length>18&&COBpredBG0)&&COBpredBG>ha&&(pa=COBpredBG),Et&&Ft.length>12&&UAMpredBGha&&UAMpredBG}))}catch(e){console.error("Problem with iobArray. Optional feature Advanced Meal Assist disabled")}l.mealCOB&&(console.error("predCIs (mg/dL/5m):"+fa.join(" ")),console.error("remainingCIs: "+Ba.join(" "))),He.predBGs={},It.forEach((function(e,t,a){a[t]=o(Math.min(401,Math.max(39,e)))}));for(var ba=It.length-1;ba>12&&It[ba-1]===It[ba];ba--)It.pop();for(He.predBGs.IOB=It,ra=o(It[It.length-1]),jt.forEach((function(e,t,a){a[t]=o(Math.min(401,Math.max(39,e)))})),ba=jt.length-1;ba>6&&!(jt[ba-1]>=jt[ba]||jt[ba]<=ot);ba--)jt.pop();if(He.predBGs.ZT=jt,o(jt[jt.length-1]),l.mealCOB>0&&(qt>0||Xt>0)){for(At.forEach((function(e,t,a){a[t]=o(Math.min(1500,Math.max(39,e)))})),ba=At.length-1;ba>12&&At[ba-1]===At[ba];ba--)At.pop();He.predBGs.COB=At,oa=o(At[At.length-1]),Ct=Math.max(Ct,o(At[At.length-1])),console.error("COBpredBG: "+o(At[At.length-1]))}if(qt>0||Xt>0){if(Et){for(Ft.forEach((function(e,t,a){a[t]=o(Math.min(401,Math.max(39,e)))})),ba=Ft.length-1;ba>12&&Ft[ba-1]===Ft[ba];ba--)Ft.pop();He.predBGs.UAM=Ft,na=o(Ft[Ft.length-1]),Ft[Ft.length-1]&&(Ct=Math.max(Ct,o(Ft[Ft.length-1])))}He.eventualBG=Ct}console.error("UAM Impact:"+kt+"mg/dL per 5m; UAM Duration:"+va+"hours"),ia=Math.max(39,ia),sa=Math.max(39,sa),la=Math.max(39,la),Ut=o(ia);var Ma=l.mealCOB/l.carbs;aa=o(la<999&&sa<999?(1-Ma)*UAMpredBG+Ma*COBpredBG:sa<999?(ga+COBpredBG)/2:la<999?(ga+UAMpredBG)/2:ga),ca>aa&&(aa=ca),Ot=o(Ot=Wt||Xt>0?Et?Ma*ua+(1-Ma)*ma:ua:Et?ma:da);var _a=la;if(cala&&(_a=(la+ca)/2);if(_a=o(_a),l.carbs)if(!Et&&sa<999)Ut=o(Math.max(ia,sa));else if(sa<999){var xa=Ma*sa+(1-Ma)*_a;Ut=o(Math.max(ia,sa,xa))}else Ut=Et?_a:Ot;else Et&&(Ut=o(Math.max(ia,_a)));Ut=Math.min(Ut,aa),process.stderr.write("minPredBG: "+Ut+" minIOBPredBG: "+ia+" minZTGuardBG: "+ca),sa<999&&process.stderr.write(" minCOBPredBG: "+sa),la<999&&process.stderr.write(" minUAMPredBG: "+la),console.error(" avgPredBG:"+aa+" COB/Carbs:"+l.mealCOB+"/"+l.carbs),pa>Ye&&(Ut=Math.min(Ut,pa)),He.COB=l.mealCOB,He.IOB=a.iob,He.BGI=n(wt,i),He.deviation=n(Gt,i),He.ISF=n(_t,i),He.CR=o(Z,1),He.target_bg=n(ot,i),He.TDD=o(ce,2),He.current_target=o(ot,0);var Sa=He.CR;ke!=He.CR&&(Sa=ke+"→"+He.CR),He.reason=Mt+", COB: "+He.COB+", Dev: "+He.deviation+", BGI: "+He.BGI+", CR: "+Sa+", Target: "+ht+", minPredBG "+n(Ut,i)+", minGuardBG "+n(Ot,i)+", IOBpredBG "+n(ra,i),oa>0&&(He.reason+=", COBpredBG "+n(oa,i)),na>0&&(He.reason+=", UAMpredBG "+n(na,i)),He.reason+=tddReason,He.reason+="; ";var Da=Tt;Da<40&&(Da=Math.min(Ot,Da));var wa,Ga=U-Da,Ta=240,Ca=240;if(l.mealCOB>0&&(qt>0||Xt>0)){for(ba=0;bawa*Ye&&(console.error("maxDelta "+n(rt,i)+" > "+100*wa+"% of BG "+n(Ye,i)+" - disabling SMB"),He.reason+="maxDelta "+n(rt,i)+" > "+100*wa+"% of BG "+n(Ye,i)+" - SMB disabled!, ",Pt=!1),console.error("BG projected to remain above "+n(nt,i)+" for "+Ta+"minutes"),(Ca<240||Ta<60)&&console.error("BG projected to remain above "+n(U,i)+" for "+Ca+"minutes");var Ua=Ca,Oa=i.current_basal*N*_t*Ua/60,Ra=Math.max(0,l.mealCOB-.25*l.carbs),Aa=(Ga-Oa)/csf-Ra;Oa=o(Oa),Aa=o(Aa),console.error("naive_eventualBG:",Tt,"bgUndershoot:",Ga,"zeroTempDuration:",Ua,"zeroTempEffect:",Oa,"carbsReq:",Aa),"Could not parse clock data"==l.reason?console.error("carbsReq unknown: Could not parse clock data"):Aa>=i.carbsReqThreshold&&Ca<=45&&(He.carbsReq=Aa,He.reason+=Aa+" add'l carbs req w/in "+Ca+"m; ");var Ia=0;if(Ye0&&tt>Rt)He.reason+="IOB "+a.iob+" < "+o(-i.current_basal*N*20/60,2),He.reason+=" and minDelta "+n(tt,i)+" > expectedDelta "+n(Rt,i)+"; ";else if(Ye=55)return He.reason+="; Canceling temp at "+He.deliverAt.getMinutes()+"m past the hour. ",u.setTempBasal(0,0,i,He,t);var Fa=0,ja=Je,Pa=0;if(CtRt&&tt>0&&!Aa)return Tt<40?(He.reason+=", naive_eventualBG < 40. ",u.setTempBasal(0,30,i,He,t)):(e.delta>tt?He.reason+=", but Delta "+n(Qe,i)+" > expectedDelta "+n(Rt,i):He.reason+=", but Min. Delta "+tt.toFixed(2)+" > Exp. Delta "+n(Rt,i),t.duration>15&&r(Je,i)===r(t.rate,i)?(He.reason+=", temp "+t.rate+" ~ req "+Je+"U/hr. ",He):(He.reason+="; setting current basal of "+Je+" as temp. ",u.setTempBasal(Je,30,i,He,t)));Fa=o(Fa=2*Math.min(0,(Ct-ot)/_t),2);var Ea=Math.min(0,(Tt-ot)/_t);if(Ea=o(Ea,2),tt<0&&tt>Rt)Fa=o(Fa*(tt/Rt),2);ja=r(ja=Je+2*Fa,i),Pa=t.duration*(t.rate-Je)/60;var qa=Math.min(Fa,Ea);if(console.log("naiveInsulinReq:"+Ea),Pa5&&ja>=.8*t.rate)return He.reason+=", temp "+t.rate+" ~< req "+ja+"U/hr. ",He;if(ja<=0){if((Ia=o(60*((Ga=ot-Tt)/_t)/i.current_basal*N))<0?Ia=0:(Ia=30*o(Ia/30),Ia=Math.min(120,Math.max(0,Ia))),Ia>0)return He.reason+=", setting "+Ia+"m zero temp. ",u.setTempBasal(ja,Ia,i,He,t)}else He.reason+=", setting "+ja+"U/hr. ";return u.setTempBasal(ja,30,i,He,t)}if(tt=2||Rt+-1*tt>=2)&&(He.manualBolusErrorString=tt>=0&&Rt>0?3:tt<0&&Rt<=0||tt<0&&Rt>=0?4:5),He.insulinForManualBolus=o((He.eventualBG-He.target_bg)/_t,2),!m||!Pt))return e.delta "+n(nt,i)+" but Delta "+n(Qe,i)+" < Exp. Delta "+n(Rt,i):He.reason+="Eventual BG "+n(Ct,i)+" > "+n(nt,i)+" but Min. Delta "+tt.toFixed(2)+" < Exp. Delta "+n(Rt,i),t.duration>15&&r(Je,i)===r(t.rate,i)?(He.reason+=", temp "+t.rate+" ~ req "+Je+"U/hr. ",He):(He.reason+="; setting current basal of "+Je+" as temp. ",u.setTempBasal(Je,30,i,He,t));if(Math.min(Ct,Ut)nt&&(He.manualBolusErrorString=6,He.insulinForManualBolus=o((He.eventualBG-He.target_bg)/_t,2),He.minPredBG=Ut),!m||!Pt))return He.reason+=n(Ct,i)+"-"+n(Ut,i)+" in range: no temp required",t.duration>15&&r(Je,i)===r(t.rate,i)?(He.reason+=", temp "+t.rate+" ~ req "+Je+"U/hr. ",He):(He.reason+="; setting current basal of "+Je+" as temp. ",u.setTempBasal(Je,30,i,He,t));if(Ct>=it&&(He.reason+="Eventual BG "+n(Ct,i)+" >= "+n(it,i)+", ",Ct>it&&(He.insulinForManualBolus=o((Ct-ot)/_t,2))),a.iob>lt)return He.reason+="IOB "+o(a.iob,2)+" > max_iob "+lt,t.duration>15&&r(Je,i)===r(t.rate,i)?(He.reason+=", temp "+t.rate+" ~ req "+Je+"U/hr. ",He):(He.reason+="; setting current basal of "+Je+" as temp. ",u.setTempBasal(Je,30,i,He,t));Fa=o((Math.min(Ut,Ct)-ot)/_t,2),C=o((Ct-ot)/_t,2),Fa>lt-a.iob?(console.error("SMB limited by maxIOB: "+lt-a.iob+" (. insulinReq: "+Fa+" U)"),He.reason+="max_iob "+lt+", ",Fa=lt-a.iob):console.error("SMB not limited by maxIOB ( insulinReq: "+Fa+" U)."),C>lt-a.iob?(console.error("Ev. Bolus limited by maxIOB: "+lt-a.iob+" (. insulinForManualBolus: "+C+" U)"),He.reason+="max_iob "+lt+", "):console.error("Ev. Bolus would not be limited by maxIOB ( insulinForManualBolus: "+C+" U)."),ja=r(ja=Je+2*Fa,i),Fa=o(Fa,3),He.insulinReq=Fa;var Wa=o((new Date(Ke).getTime()-a.lastBolusTime)/6e4,1);if(m&&Pt&&Ye>U){var ka=30;void 0!==i.maxSMBBasalMinutes&&(ka=i.maxSMBBasalMinutes);var La=30;void 0!==i.maxUAMSMBBasalMinutes&&(La=i.maxUAMSMBBasalMinutes),v.useOverride&&M&&G!==ka&&(console.error("SMB Max Minutes - setting overriden from "+ka+" to "+G),ka=G),v.useOverride&&M&&T!==La&&(console.error("UAM Max Minutes - setting overriden from "+La+" to "+T),La=T);var za=o(l.mealCOB/Z,3),Na=0;void 0===ka?(Na=o(i.current_basal*N*30/60,1),console.error("smbMinutesSetting undefined: defaulting to 30m"),Fa>Na&&console.error("SMB limited by maxBolus: "+Na+" ( "+Fa+" U)")):a.iob>za&&a.iob>0?(console.error("IOB"+a.iob+"> COB"+l.mealCOB+"; mealInsulinReq ="+za),La?(console.error("maxUAMSMBBasalMinutes: "+La+", profile.current_basal: "+i.current_basal*N),Na=o(i.current_basal*N*La/60,1)):(console.error("maxUAMSMBBasalMinutes undefined: defaulting to 30m"),Na=o(i.current_basal*N*30/60,1)),Fa>Na?console.error("SMB limited by maxUAMSMBBasalMinutes [ "+La+"m ]: "+Na+"U ( "+Fa+"U )"):console.error("SMB is not limited by maxUAMSMBBasalMinutes. ( insulinReq: "+Fa+"U )")):(console.error(".maxSMBBasalMinutes: "+ka+", profile.current_basal: "+i.current_basal*N),Fa>(Na=o(i.current_basal*ka/60,1))?console.error("SMB limited by maxSMBBasalMinutes: "+ka+"m ]: "+Na+"U ( insulinReq: "+Fa+"U )"):console.error("SMB is not limited by maxSMBBasalMinutes. ( insulinReq: "+Fa+"U )"));var Ha=i.bolus_increment,Za=1/Ha,$a=i.smb_delivery_ratio;$a>.5&&console.error("SMB Delivery Ratio increased from default 0.5 to "+o($a,2));var Ja=Math.min(Fa*$a,Na);Ja=Math.floor(Ja*Za)/Za,Ia=o(60*((ot-(Tt+ia)/2)/_t)/i.current_basal*N),Fa>0&&Ja=30?(Ia=30*o(Ia/30),Ia=Math.min(60,Math.max(0,Ia))):(Ka=o(Je*Ia/30,2),Ia=30),He.reason+=" insulinReq "+Fa,Ja>=Na&&(He.reason+="; maxBolus "+Na),Ia>0&&(He.reason+="; setting "+Ia+"m low temp of "+Ka+"U/h"),He.reason+=". ";var Qa=3;i.SMBInterval&&(Qa=Math.min(10,Math.max(1,i.SMBInterval)));var Va=o(Qa-Wa,0),Xa=o(60*(Qa-Wa),0)%60;if(console.error("naive_eventualBG "+Tt+","+Ia+"m "+Ka+"U/h temp needed; last bolus "+Wa+"m ago; maxBolus: "+Na),Wa>Qa?Ja>0&&(He.units=Ja,He.reason+="Microbolusing "+Ja+"U. "):He.reason+="Waiting "+Va+"m "+Xa+"s to microbolus again. ",Ia>0)return He.rate=Ka,He.duration=Ia,He}var Ya=u.getMaxSafeBasal(i);return ja>Ya&&(He.reason+="adj. req. rate: "+ja+" to maxSafeBasal: "+o(Ya,2)+", ",ja=r(Ya,i)),(Pa=t.duration*(t.rate-Je)/60)>=2*Fa?(He.reason+=t.duration+"m@"+t.rate.toFixed(2)+" > 2 * insulinReq. Setting temp basal of "+ja+"U/hr. ",u.setTempBasal(ja,30,i,He,t)):void 0===t.duration||0===t.duration?(He.reason+="no temp, setting "+ja+"U/hr. ",u.setTempBasal(ja,30,i,He,t)):t.duration>5&&r(ja,i)<=r(t.rate,i)?(He.reason+="temp "+t.rate+" >~ req "+ja+"U/hr. ",He):(He.reason+="temp "+t.rate+"<"+ja+"U/hr. ",u.setTempBasal(ja,30,i,He,t))}},6880:(e,t,a)=>{var r=a(6654);e.exports=function(e,t){var a=20;void 0!==t&&"string"==typeof t.model&&(r(t.model,"54")||r(t.model,"23"))&&(a=40);return e<1?Math.round(e*a)/a:e<10?Math.round(20*e)/20:Math.round(10*e)/10}},2705:(e,t,a)=>{var r=a(5639).Symbol;e.exports=r},9932:e=>{e.exports=function(e,t){for(var a=-1,r=null==e?0:e.length,o=Array(r);++a{e.exports=function(e,t,a){return e==e&&(void 0!==a&&(e=e<=a?e:a),void 0!==t&&(e=e>=t?e:t)),e}},4239:(e,t,a)=>{var r=a(2705),o=a(9607),n=a(2333),i=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":i&&i in Object(e)?o(e):n(e)}},531:(e,t,a)=>{var r=a(2705),o=a(9932),n=a(1469),i=a(3448),s=r?r.prototype:void 0,l=s?s.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(n(t))return o(t,e)+"";if(i(t))return l?l.call(t):"";var a=t+"";return"0"==a&&1/t==-Infinity?"-0":a}},7561:(e,t,a)=>{var r=a(7990),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},1957:(e,t,a)=>{var r="object"==typeof a.g&&a.g&&a.g.Object===Object&&a.g;e.exports=r},9607:(e,t,a)=>{var r=a(2705),o=Object.prototype,n=o.hasOwnProperty,i=o.toString,s=r?r.toStringTag:void 0;e.exports=function(e){var t=n.call(e,s),a=e[s];try{e[s]=void 0;var r=!0}catch(e){}var o=i.call(e);return r&&(t?e[s]=a:delete e[s]),o}},2333:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},5639:(e,t,a)=>{var r=a(1957),o="object"==typeof self&&self&&self.Object===Object&&self,n=r||o||Function("return this")();e.exports=n},7990:e=>{var t=/\s/;e.exports=function(e){for(var a=e.length;a--&&t.test(e.charAt(a)););return a}},6654:(e,t,a)=>{var r=a(9750),o=a(531),n=a(554),i=a(9833);e.exports=function(e,t,a){e=i(e),t=o(t);var s=e.length,l=a=void 0===a?s:r(n(a),0,s);return(a-=t.length)>=0&&e.slice(a,l)==t}},1469:e=>{var t=Array.isArray;e.exports=t},3218:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},7005:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},3448:(e,t,a)=>{var r=a(4239),o=a(7005);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},8601:(e,t,a)=>{var r=a(4841),o=1/0;e.exports=function(e){return e?(e=r(e))===o||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}},554:(e,t,a)=>{var r=a(8601);e.exports=function(e){var t=r(e),a=t%1;return t==t?a?t-a:t:0}},4841:(e,t,a)=>{var r=a(7561),o=a(3218),n=a(3448),i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(n(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var a=s.test(e);return a||l.test(e)?u(e.slice(2),a?2:8):i.test(e)?NaN:+e}},9833:(e,t,a)=>{var r=a(531);e.exports=function(e){return null==e?"":r(e)}}},t={};function a(r){var o=t[r];if(void 0!==o)return o.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,a),n.exports}a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var r=a(5546);freeaps_determineBasal=r})(); \ No newline at end of file +var freeaps_determineBasal;(()=>{var e={5546:(e,t,a)=>{var r=a(6880);function o(e,t){t||(t=0);var a=Math.pow(10,t);return Math.round(e*a)/a}function n(e,t){return"mmol/L"===t.out_units?o(.0555*e,1):Math.round(e)}e.exports=function(e,t,a,i,s,l,u,d,m,c,g,h,p,v){var B=i.min_bg,f=v.overrideTarget;0!=f&&v.useOverride&&!i.temptargetSet&&(B=f);const b=v.smbIsOff,M=v.advancedSettings,_=v.isfAndCr,y=v.isf,x=v.cr,S=v.smbIsAlwaysOff,D=v.start,w=v.end,G=v.smbMinutes,T=v.uamMinutes;var C=0,U=B,O=0,R="",A="",I="",F="",j="",P=0,E=0,q=0,W=0,k=0,L=0;const z=v.weightedAverage;var N=1,H=i.sens,Z=i.carb_ratio;v.useOverride&&(N=v.overridePercentage/100,_?(H/=N,Z/=N):(x&&(Z/=N),y&&(H/=N)));const $=i.weightPercentage,J=v.average_total_data;function K(e,t){var a=e.getTime();return new Date(a+36e5*t)}function Q(e){var t=i.bolus_increment;.1!=t&&(t=.05);var a=e/t;return a>=1?o(Math.floor(a)*t,5):0}function V(e){function t(e){return e<10&&(e="0"+e),e}return t(e.getHours())+":"+t(e.getMinutes())+":00"}function X(e,t){var a=new Date("1/1/1999 "+e),r=new Date("1/1/1999 "+t);return(a.getTime()-r.getTime())/36e5}function Y(e,t){var a=0,r=t,o=(e-t)/36e5,n=0,i=o,s=0;do{if(o>0){var l=V(r),u=p[0].rate;for(let e=0;e=(s=X(p[e+1].start,p[e].start))?n=s:o=s?n=s:od)if(e+1=(s=X(m,l))?n=s:o=(s=X("23:59:59",l))?n=s:o0&&o21)k=Y(ee,(ae=24-O,re=ee.getTime(),new Date(re-36e5*ae))),F="24 hours of data is required for an accurate tdd calculation. Currently only "+O.toPrecision(3)+" hours of pump history data are available. Using your pump scheduled basals to fill in the missing hours. Scheduled basals added: "+k.toPrecision(5)+" U. ";else O<21?(pe=!1,enableDynamicCR=!1):F=""}else console.log("Pumphistory is empty!"),pe=!1,enableDynamicCR=!1;var ae,re;for(let e=0;e0){P=e,L=g[e].rate;var oe=g[e-1]["duration (min)"]/60,ne=oe,ie=new Date(g[e-1].timestamp),se=ie,le=0;do{if(e--,0==e){se=new Date;break}if("TempBasal"==g[e]._type||"PumpSuspend"==g[e]._type){se=new Date(g[e].timestamp);break}var ue=e-2;if(ue>=0&&"Rewind"==g[ue]._type){let e=g[ue].timestamp;for(;ue-1>=0&&"Prime"==g[ue-=1]._type;)le=(g[ue].timestamp-e)/36e5;le>=oe&&(se=e,le=0)}}while(e>0);var de=(se-ie)/36e5;de0&&(--r,"TempBasal"==g[r]._type)){a=new Date(g[r].timestamp);break}}while(r>0);(a-t)/36e5>0&&(k+=Y(a,t))}for(let e=g.length-1;e>0;e--)if("TempBasalDuration"==g[e]._type){let t=g[e]["duration (min)"]/60,a=new Date(g[e].timestamp);var me=a;let r=e;do{if(--r,r>=0&&("TempBasal"==g[r]._type||"PumpSuspend"==g[r]._type)){me=new Date(g[r].timestamp);break}}while(r>0);if(0==e&&"TempBasalDuration"==g[0]._type&&(me=new Date,t=g[e]["duration (min)"]/60),(me-a)/36e5-t>0){k+=Y(me,K(a,t))}}var ce,ge={TDD:o(E=W+q+k,5),bolus:o(W,5),temp_basal:o(q,5),scheduled_basal:o(k,5)};O>21?(A=". Bolus insulin: "+W.toPrecision(5)+" U",I=". Temporary basal insulin: "+q.toPrecision(5)+" U",R=". Insulin with scheduled basal rate: "+k.toPrecision(5)+" U",j=F+(" TDD past 24h is: "+E.toPrecision(5)+" U")+A+I+R,tddReason=", Total insulin: "+o(E,2)+" U, "+o(W/E*100,0)+"% Bolus "+o((q+k)/E*100,0)+"% Basal"):tddReason=", TDD: Not enough pumpData (< 21h)";const he=e.glucose;var pe=h.useNewFormula;const ve=h.enableDynamicCR,Be=Math.min(i.autosens_min,i.autosens_max),fe=Math.max(i.autosens_min,i.autosens_max);(fe==Be||fe<1||Be>1)&&(pe=!1,console.log("Dynamic ISF disabled due to current autosens settings"));const be=h.adjustmentFactor,Me=B;var _e=!1,ye="",xe=1,Se="";J>0&&(xe=z/J),Se=xe>1?"Basal adjustment with a 24 hour to total average (up to 14 days of data) TDD ratio (limited by Autosens max setting). Basal Ratio: "+(xe=o(xe=Math.min(xe,i.autosens_max),2))+". Upper limit = Autosens max ("+i.autosens_max+")":xe<1?"Basal adjustment with a 24 hour to to total average (up to 14 days of data) TDD ratio (limited by Autosens min setting). Basal Ratio: "+(xe=o(xe=Math.max(xe,i.autosens_min),2))+". Lower limit = Autosens min ("+i.autosens_min+")":"Basal adjusted with a 24 hour to total average (up to 14 days of data) TDD ratio: "+xe,Se=", Basal ratio: "+xe,(i.high_temptarget_raises_sensitivity||i.exercise_mode||v.isEnabled)&&(_e=!0),Me>=118&&_e&&(pe=!1,ye="Dynamic ISF temporarily off due to a high temp target/exercising. Current min target: "+Me);var De=", Dynamic ratios log: ",we=", AF: "+be,Ge="BG: "+he+" mg/dl ("+(.0555*he).toPrecision(2)+" mmol/l)",Te="",Ce="";const Ue=h.curve,Oe=h.insulinPeakTime,Re=h.useCustomPeakTime;var Ae=55,Ie=65;switch(Ue){case"rapid-acting":Ie=65;break;case"ultra-rapid":Ie=50}Re?(Ae=120-Oe,console.log("Custom insulinpeakTime set to :"+Oe+", insulinFactor: "+Ae)):(Ae=120-Ie,console.log("insulinFactor set to : "+Ae)),ce=E,$<1&&z>0&&(E=z,console.log("Using weighted TDD average: "+o(E,2)+" U, instead of past 24 h ("+o(ce,2)+" U), weight: "+$),Ce=", Weighted TDD: "+o(E,2)+" U");const Fe=h.sigmoid;var je="";if(pe){var Pe=H*be*E*Math.log(he/Ae+1)/1800;Te=", Logarithmic formula"}if(pe&&Fe){const e=Be,t=fe-e,a=.0555*(he-B);var Ee=xe,qe=fe-1;1==fe&&(qe=fe+.01-1);const r=Math.log10(1/qe-e/qe)/Math.log10(Math.E),o=a*be*Ee+r;Pe=t/(1+Math.exp(-o))+e,Te=", Sigmoid function"}var We=Z;const ke=o(Z,1);var Le="",ze="";if(pe&&E>0){if(Le=", Dynamic ISF/CR: On/",Pe>fe?(ye=", Dynamic ISF limited by autosens_max setting: "+fe+" ("+o(Pe,2)+"), ",ze=", Autosens/Dynamic Limit: "+fe+" ("+o(Pe,2)+")",Pe=fe):Pe-.5?"+"+o(e.delta,0):o(e.delta,0);var tt=Math.min(e.delta,e.short_avgdelta),at=Math.min(e.short_avgdelta,e.long_avgdelta),rt=Math.max(e.delta,e.short_avgdelta,e.long_avgdelta);(Ye<=10||38===Ye||et>=3)&&(He.reason="CGM is calibrating, in ??? state, or noise is high");if(Ye>60&&0==e.delta&&e.short_avgdelta>-1&&e.short_avgdelta<1&&e.long_avgdelta>-1&&e.long_avgdelta<1&&("fakecgm"==e.device?(console.error("CGM data is unchanged ("+n(Ye,i)+"+"+n(e.delta,i)+") for 5m w/ "+n(e.short_avgdelta,i)+" mg/dL ~15m change & "+n(e.long_avgdelta,2)+" mg/dL ~45m change"),console.error("Simulator mode detected ("+e.device+"): continuing anyway")):!0),Xe>12||Xe<-5?He.reason="If current system time "+Ke+" is correct, then BG data is too old. The last BG data was read "+Xe+"m ago at "+Ve:0===e.short_avgdelta&&0===e.long_avgdelta&&(e.last_cal&&e.last_cal<3?He.reason="CGM was just calibrated":He.reason="CGM data is unchanged ("+n(Ye,i)+"+"+n(e.delta,i)+") for 5m w/ "+n(e.short_avgdelta,i)+" mg/dL ~15m change & "+n(e.long_avgdelta,i)+" mg/dL ~45m change"),Ye<=10||38===Ye||et>=3||Xe>12||Xe<-5||0===e.short_avgdelta&&0===e.long_avgdelta)return t.rate>=Je?(He.reason+=". Canceling high temp basal of "+t.rate,He.deliverAt=Ze,He.temp="absolute",He.duration=0,He.rate=0,He):0===t.rate&&t.duration>30?(He.reason+=". Shortening "+t.duration+"m long zero temp to 30m. ",He.deliverAt=Ze,He.temp="absolute",He.duration=30,He.rate=0,He):(He.reason+=". Temp "+t.rate+" <= current basal "+Je+"U/hr; doing nothing. ",He);var ot,nt,it,st,lt=i.max_iob;if(void 0!==B&&(nt=B),void 0!==i.max_bg&&(it=B),void 0!==i.enableSMB_high_bg_target&&(st=i.enableSMB_high_bg_target),void 0===B)return He.error="Error: could not determine target_bg. ",He;ot=B;var ut=i.exercise_mode||i.high_temptarget_raises_sensitivity||v.isEnabled,dt=100,mt=160;if(mt=i.half_basal_exercise_target,v.isEnabled){const e=v.hbt;console.log("Half Basal Target used: "+n(e,i)+" "+i.out_units),mt=e}else console.log("Default Half Basal Target used: "+n(mt,i)+" "+i.out_units);if(ut&&i.temptargetSet&&ot>dt||i.low_temptarget_lowers_sensitivity&&i.temptargetSet&&ot=ot&&sensitivityRatio0&&(process.stderr.write("TDD-adjustment of basals activated, using tdd24h_14d_Ratio "+o(xe,2)+", TDD 24h = "+o(ce,2)+"U, Weighted average TDD = "+o(z,2)+"U, (Weight percentage = "+$+"), Total data of TDDs (up to 14 days) average = "+o(J,2)+"U. "),Je!==$e*N?process.stderr.write("Adjusting basal from "+$e*N+" U/h to "+Je+" U/h; "):process.stderr.write("Basal unchanged: "+Je+" U/h; "))),i.temptargetSet);else if(void 0!==s&&s&&(i.sensitivity_raises_target&&s.ratio<1||i.resistance_lowers_target&&s.ratio>1)){nt=o((nt-60)/s.ratio)+60,it=o((it-60)/s.ratio)+60;var gt=o((ot-60)/s.ratio)+60;ot===(gt=Math.max(80,gt))?process.stderr.write("target_bg unchanged: "+n(gt,i)+"; "):process.stderr.write("target_bg from "+n(gt,i)+" to "+n(gt,i)+"; "),ot=gt}var ht=n(ot,i);ot!=B&&(ht=0!==f&&f!==ot?n(B,i)+"→"+n(f,i)+"→"+n(ot,i):n(B,i)+"→"+n(ot,i));var pt=200,vt=200,Bt=200;if(e.noise>=2){var ft=Math.max(1.1,i.noisyCGMTargetMultiplier);Math.min(250,i.maxRaw);pt=o(Math.min(200,nt*ft)),vt=o(Math.min(200,ot*ft)),Bt=o(Math.min(200,it*ft)),process.stderr.write("Raising target_bg for noisy / raw CGM data, from "+n(gt,i)+" to "+n(vt,i)+"; "),nt=pt,ot=vt,it=Bt}U=nt-.5*(nt-40);var bt=i.threshold_setting;bt>U&&bt<=120&&bt>=65?(console.error("Threshold changed in settings from "+n(U,i)+" to "+n(bt,i)+". "),U=bt):console.error("Current threshold: "+n(U,i));var Mt="",_t=(o(H,1),H);if(void 0!==s&&s&&((_t=o(_t=H/sensitivityRatio,1))!==H?process.stderr.write("ISF from "+n(H,i)+" to "+n(_t,i)):process.stderr.write("ISF unchanged: "+n(_t,i)),Mt+="Autosens ratio: "+o(sensitivityRatio,2)+", ISF: "+n(H,i)+"→"+n(_t,i)),console.error("CR:"+Z),void 0===a)return He.error="Error: iob_data undefined. ",He;var yt,xt=a;if(a.length,a.length>1&&(a=xt[0]),void 0===a.activity||void 0===a.iob)return He.error="Error: iob_data missing some property. ",He;var St=((yt=void 0!==a.lastTemp?o((new Date(Ke).getTime()-a.lastTemp.date)/6e4):0)+t.duration)%30;if(console.error("currenttemp:"+t.rate+" lastTempAge:"+yt+"m, tempModulus:"+St+"m"),He.temp="absolute",He.deliverAt=Ze,d&&t&&a.lastTemp&&t.rate!==a.lastTemp.rate&&yt>10&&t.duration)return He.reason="Warning: currenttemp rate "+t.rate+" != lastTemp rate "+a.lastTemp.rate+" from pumphistory; canceling temp",u.setTempBasal(0,0,i,He,t);if(t&&a.lastTemp&&t.duration>0){var Dt=yt-a.lastTemp.duration;if(Dt>5&&yt>10)return He.reason="Warning: currenttemp running but lastTemp from pumphistory ended "+Dt+"m ago; canceling temp",u.setTempBasal(0,0,i,He,t)}var wt=o(-a.activity*_t*5,2),Gt=o(6*(tt-wt));Gt<0&&(Gt=o(6*(at-wt)))<0&&(Gt=o(6*(e.long_avgdelta-wt)));var Tt=Ye,Ct=(Tt=a.iob>0?o(Ye-a.iob*_t):o(Ye-a.iob*Math.min(_t,H)))+Gt;if(void 0===Ct||isNaN(Ct))return He.error="Error: could not calculate eventualBG. Sensitivity: "+_t+" Deviation: "+Gt,He;var Ut,Ot,Rt=function(e,t,a){return o(a+(e-t)/24,1)}(ot,Ct,wt);He={temp:"absolute",bg:Ye,tick:Qe,eventualBG:Ct,insulinReq:0,reservoir:m,deliverAt:Ze,sensitivityRatio,CR:o(Z,1),TDD:ce,insulin:ge,current_target:ot,insulinForManualBolus:C,manualBolusErrorString:0,minDelta:tt,expectedDelta:Rt,minGuardBG:Ot,minPredBG:Ut,threshold:n(U,i)};var At=[],It=[],Ft=[],jt=[];At.push(Ye),It.push(Ye),jt.push(Ye),Ft.push(Ye);var Pt=function(e,t,a,r,o,i){return t?!e.allowSMB_with_high_temptarget&&e.temptargetSet&&o>100?(console.error("SMB disabled due to high temptarget of "+o),!1):!0===a.bwFound&&!1===e.A52_risk_enable?(console.error("SMB disabled due to Bolus Wizard activity in the last 6 hours."),!1):!0===e.enableSMB_always?(a.bwFound?console.error("Warning: SMB enabled within 6h of using Bolus Wizard: be sure to easy bolus 30s before using Bolus Wizard"):console.error("SMB enabled due to enableSMB_always"),!0):!0===e.enableSMB_with_COB&&a.mealCOB?(a.bwCarbs?console.error("Warning: SMB enabled with Bolus Wizard carbs: be sure to easy bolus 30s before using Bolus Wizard"):console.error("SMB enabled for COB of "+a.mealCOB),!0):!0===e.enableSMB_after_carbs&&a.carbs?(a.bwCarbs?console.error("Warning: SMB enabled with Bolus Wizard carbs: be sure to easy bolus 30s before using Bolus Wizard"):console.error("SMB enabled for 6h after carb entry"),!0):!0===e.enableSMB_with_temptarget&&e.temptargetSet&&o<100?(a.bwFound?console.error("Warning: SMB enabled within 6h of using Bolus Wizard: be sure to easy bolus 30s before using Bolus Wizard"):console.error("SMB enabled for temptarget of "+n(o,e)),!0):!0===e.enableSMB_high_bg&&null!==i&&r>=i?(console.error("Checking BG to see if High for SMB enablement."),console.error("Current BG",r," | High BG ",i),a.bwFound?console.error("Warning: High BG SMB enabled within 6h of using Bolus Wizard: be sure to easy bolus 30s before using Bolus Wizard"):console.error("High BG detected. Enabling SMB."),!0):(console.error("SMB disabled (no enableSMB preferences active or no condition satisfied)"),!1):(console.error("SMB disabled (!microBolusAllowed)"),!1)}(i,d,l,Ye,ot,st);if(b)if(S){let e=c.getHours();e>=D&&e<=w&&(console.error("SMB disabled by schedule (a Profile is active with SMBs disabled)"),Pt=!1)}else console.error("SMBs are disabled (a Profile is active with SMBs disabled)"),Pt=!1;var Et=i.enableUAM,qt=0,Wt=0;qt=o(tt-wt,1);var kt=o(tt-wt,1);csf=_t/Z,console.error("profile.sens:"+n(H,i)+", sens:"+n(_t,i)+", CSF:"+o(csf,1));var Lt=o(30*csf*5/60,1);qt>Lt&&(console.error("Limiting carb impact from "+qt+" to "+Lt+"mg/dL/5m (30g/h)"),qt=Lt);var zt=3;sensitivityRatio&&(zt/=sensitivityRatio);var Nt=zt;if(l.carbs){zt=Math.max(zt,l.mealCOB/20);var Ht=o((new Date(Ke).getTime()-l.lastCarbTime)/6e4),Zt=(l.carbs-l.mealCOB)/l.carbs;Nt=o(Nt=zt+1.5*Ht/60,1),console.error("Last carbs "+Ht+" minutes ago; remainingCATime:"+Nt+"hours; "+o(100*Zt,1)+"% carbs absorbed")}var $t=Math.max(0,qt/5*60*Nt/2)/csf,Jt=90,Kt=1;i.remainingCarbsCap&&(Jt=Math.min(90,i.remainingCarbsCap)),i.remainingCarbsFraction&&(Kt=Math.min(1,i.remainingCarbsFraction));var Qt=1-Kt,Vt=Math.max(0,l.mealCOB-$t-l.carbs*Qt),Xt=(Vt=Math.min(Jt,Vt))*csf*5/60/(Nt/2),Yt=o(l.slopeFromMaxDeviation,2),ea=o(l.slopeFromMinDeviation,2),ta=Math.min(Yt,-ea/3);Wt=0===qt?0:Math.min(60*Nt/5/2,Math.max(0,l.mealCOB*csf/qt)),console.error("Carb Impact:"+qt+"mg/dL per 5m; CI Duration:"+o(5*Wt/60*2,1)+"hours; remaining CI ("+Nt/2+"h peak):"+o(Xt,1)+"mg/dL per 5m");var aa,ra,oa,na,ia=999,sa=999,la=999,ua=999,da=999,ma=999,ca=999,ga=Ct,ha=Ye,pa=Ye,va=0,Ba=[],fa=[];try{xt.forEach((function(e){var t=o(-e.activity*_t*5,2),a=o(-e.iobWithZeroTemp.activity*_t*5,2),r=Tt,n=qt*(1-Math.min(1,It.length/12));if(!0===(pe&&!Fe))ga=It[It.length-1]+o(-e.activity*(1800/(E*be*Math.log(Math.max(It[It.length-1],39)/Ae+1)))*5,2)+n,r=jt[jt.length-1]+o(-e.iobWithZeroTemp.activity*(1800/(E*be*Math.log(Math.max(jt[jt.length-1],39)/Ae+1)))*5,2),console.log("Dynamic ISF (Logarithmic Formula) )adjusted predictions for IOB and ZT: IOBpredBG: "+o(ga,2)+" , ZTpredBG: "+o(r,2));else ga=It[It.length-1]+t+n,r=jt[jt.length-1]+a;var i=Math.max(0,Math.max(0,qt)*(1-At.length/Math.max(2*Wt,1))),s=Math.min(At.length,12*Nt-At.length),l=Math.max(0,s/(Nt/2*12)*Xt);i+l,Ba.push(o(l,0)),fa.push(o(i,0)),COBpredBG=At[At.length-1]+t+Math.min(0,n)+i+l;var u=Math.max(0,kt+Ft.length*ta),d=Math.max(0,kt*(1-Ft.length/Math.max(36,1))),m=Math.min(u,d);if(m>0&&(va=o(5*(Ft.length+1)/60,1)),!0===(pe&&!Fe))UAMpredBG=Ft[Ft.length-1]+o(-e.activity*(1800/(E*be*Math.log(Math.max(Ft[Ft.length-1],39)/Ae+1)))*5,2)+Math.min(0,n)+m,console.log("Dynamic ISF (Logarithmic Formula) adjusted prediction for UAM: UAMpredBG: "+o(UAMpredBG,2));else UAMpredBG=Ft[Ft.length-1]+t+Math.min(0,n)+m;It.length<48&&It.push(ga),At.length<48&&At.push(COBpredBG),Ft.length<48&&Ft.push(UAMpredBG),jt.length<48&&jt.push(r),COBpredBG18&&gaha&&(ha=ga),(Wt||Xt>0)&&At.length>18&&COBpredBG0)&&COBpredBG>ha&&(pa=COBpredBG),Et&&Ft.length>12&&UAMpredBGha&&UAMpredBG}))}catch(e){console.error("Problem with iobArray. Optional feature Advanced Meal Assist disabled")}l.mealCOB&&(console.error("predCIs (mg/dL/5m):"+fa.join(" ")),console.error("remainingCIs: "+Ba.join(" "))),He.predBGs={},It.forEach((function(e,t,a){a[t]=o(Math.min(401,Math.max(39,e)))}));for(var ba=It.length-1;ba>12&&It[ba-1]===It[ba];ba--)It.pop();for(He.predBGs.IOB=It,ra=o(It[It.length-1]),jt.forEach((function(e,t,a){a[t]=o(Math.min(401,Math.max(39,e)))})),ba=jt.length-1;ba>6&&!(jt[ba-1]>=jt[ba]||jt[ba]<=ot);ba--)jt.pop();if(He.predBGs.ZT=jt,o(jt[jt.length-1]),l.mealCOB>0&&(qt>0||Xt>0)){for(At.forEach((function(e,t,a){a[t]=o(Math.min(1500,Math.max(39,e)))})),ba=At.length-1;ba>12&&At[ba-1]===At[ba];ba--)At.pop();He.predBGs.COB=At,oa=o(At[At.length-1]),Ct=Math.max(Ct,o(At[At.length-1])),console.error("COBpredBG: "+o(At[At.length-1]))}if(qt>0||Xt>0){if(Et){for(Ft.forEach((function(e,t,a){a[t]=o(Math.min(401,Math.max(39,e)))})),ba=Ft.length-1;ba>12&&Ft[ba-1]===Ft[ba];ba--)Ft.pop();He.predBGs.UAM=Ft,na=o(Ft[Ft.length-1]),Ft[Ft.length-1]&&(Ct=Math.max(Ct,o(Ft[Ft.length-1])))}He.eventualBG=Ct}console.error("UAM Impact:"+kt+"mg/dL per 5m; UAM Duration:"+va+"hours"),ia=Math.max(39,ia),sa=Math.max(39,sa),la=Math.max(39,la),Ut=o(ia);var Ma=l.mealCOB/l.carbs;aa=o(la<999&&sa<999?(1-Ma)*UAMpredBG+Ma*COBpredBG:sa<999?(ga+COBpredBG)/2:la<999?(ga+UAMpredBG)/2:ga),ca>aa&&(aa=ca),Ot=o(Ot=Wt||Xt>0?Et?Ma*ua+(1-Ma)*da:ua:Et?da:ma);var _a=la;if(cala&&(_a=(la+ca)/2);if(_a=o(_a),l.carbs)if(!Et&&sa<999)Ut=o(Math.max(ia,sa));else if(sa<999){var xa=Ma*sa+(1-Ma)*_a;Ut=o(Math.max(ia,sa,xa))}else Ut=Et?_a:Ot;else Et&&(Ut=o(Math.max(ia,_a)));Ut=Math.min(Ut,aa),process.stderr.write("minPredBG: "+Ut+" minIOBPredBG: "+ia+" minZTGuardBG: "+ca),sa<999&&process.stderr.write(" minCOBPredBG: "+sa),la<999&&process.stderr.write(" minUAMPredBG: "+la),console.error(" avgPredBG:"+aa+" COB/Carbs:"+l.mealCOB+"/"+l.carbs),pa>Ye&&(Ut=Math.min(Ut,pa)),He.COB=l.mealCOB,He.IOB=a.iob,He.BGI=n(wt,i),He.deviation=n(Gt,i),He.ISF=n(_t,i),He.CR=o(Z,1),He.target_bg=n(ot,i),He.TDD=o(ce,2),He.current_target=o(ot,0);var Sa=He.CR;ke!=He.CR&&(Sa=ke+"→"+He.CR),He.reason=Mt+", COB: "+He.COB+", Dev: "+He.deviation+", BGI: "+He.BGI+", CR: "+Sa+", Target: "+ht+", minPredBG "+n(Ut,i)+", minGuardBG "+n(Ot,i)+", IOBpredBG "+n(ra,i),oa>0&&(He.reason+=", COBpredBG "+n(oa,i)),na>0&&(He.reason+=", UAMpredBG "+n(na,i)),He.reason+=tddReason,He.reason+="; ";var Da=Tt;Da<40&&(Da=Math.min(Ot,Da));var wa,Ga=U-Da,Ta=240,Ca=240;if(l.mealCOB>0&&(qt>0||Xt>0)){for(ba=0;bawa*Ye&&(console.error("maxDelta "+n(rt,i)+" > "+100*wa+"% of BG "+n(Ye,i)+" - disabling SMB"),He.reason+="maxDelta "+n(rt,i)+" > "+100*wa+"% of BG "+n(Ye,i)+" - SMB disabled!, ",Pt=!1),console.error("BG projected to remain above "+n(nt,i)+" for "+Ta+"minutes"),(Ca<240||Ta<60)&&console.error("BG projected to remain above "+n(U,i)+" for "+Ca+"minutes");var Ua=Ca,Oa=i.current_basal*N*_t*Ua/60,Ra=Math.max(0,l.mealCOB-.25*l.carbs),Aa=(Ga-Oa)/csf-Ra;Oa=o(Oa),Aa=o(Aa),console.error("naive_eventualBG:",Tt,"bgUndershoot:",Ga,"zeroTempDuration:",Ua,"zeroTempEffect:",Oa,"carbsReq:",Aa),"Could not parse clock data"==l.reason?console.error("carbsReq unknown: Could not parse clock data"):Aa>=i.carbsReqThreshold&&Ca<=45&&(He.carbsReq=Aa,He.reason+=Aa+" add'l carbs req w/in "+Ca+"m; ");var Ia=0;if(Ye0&&tt>Rt)He.reason+="IOB "+a.iob+" < "+o(-i.current_basal*N*20/60,2),He.reason+=" and minDelta "+n(tt,i)+" > expectedDelta "+n(Rt,i)+"; ";else if(Ye=55)return He.reason+="; Canceling temp at "+He.deliverAt.getMinutes()+"m past the hour. ",u.setTempBasal(0,0,i,He,t);var Fa=0,ja=Je,Pa=0;if(CtRt&&tt>0&&!Aa)return Tt<40?(He.reason+=", naive_eventualBG < 40. ",u.setTempBasal(0,30,i,He,t)):(e.delta>tt?He.reason+=", but Delta "+n(Qe,i)+" > expectedDelta "+n(Rt,i):He.reason+=", but Min. Delta "+tt.toFixed(2)+" > Exp. Delta "+n(Rt,i),t.duration>15&&r(Je,i)===r(t.rate,i)?(He.reason+=", temp "+t.rate+" ~ req "+Je+"U/hr. ",He):(He.reason+="; setting current basal of "+Je+" as temp. ",u.setTempBasal(Je,30,i,He,t)));Fa=o(Fa=2*Math.min(0,(Ct-ot)/_t),2);var Ea=Math.min(0,(Tt-ot)/_t);if(Ea=o(Ea,2),tt<0&&tt>Rt)Fa=o(Fa*(tt/Rt),2);ja=r(ja=Je+2*Fa,i),Pa=t.duration*(t.rate-Je)/60;var qa=Math.min(Fa,Ea);if(console.log("naiveInsulinReq:"+Ea),Pa5&&ja>=.8*t.rate)return He.reason+=", temp "+t.rate+" ~< req "+ja+"U/hr. ",He;if(ja<=0){if((Ia=o(60*((Ga=ot-Tt)/_t)/i.current_basal*N))<0?Ia=0:(Ia=30*o(Ia/30),Ia=Math.min(120,Math.max(0,Ia))),Ia>0)return He.reason+=", setting "+Ia+"m zero temp. ",u.setTempBasal(ja,Ia,i,He,t)}else He.reason+=", setting "+ja+"U/hr. ";return u.setTempBasal(ja,30,i,He,t)}if(tt=2||Rt+-1*tt>=2)&&(He.manualBolusErrorString=tt>=0&&Rt>0?3:tt<0&&Rt<=0||tt<0&&Rt>=0?4:5),He.insulinForManualBolus=o((He.eventualBG-He.target_bg)/_t,2),!d||!Pt))return e.delta "+n(nt,i)+" but Delta "+n(Qe,i)+" < Exp. Delta "+n(Rt,i):He.reason+="Eventual BG "+n(Ct,i)+" > "+n(nt,i)+" but Min. Delta "+tt.toFixed(2)+" < Exp. Delta "+n(Rt,i),t.duration>15&&r(Je,i)===r(t.rate,i)?(He.reason+=", temp "+t.rate+" ~ req "+Je+"U/hr. ",He):(He.reason+="; setting current basal of "+Je+" as temp. ",u.setTempBasal(Je,30,i,He,t));if(Math.min(Ct,Ut)nt&&(He.manualBolusErrorString=6,He.insulinForManualBolus=o((He.eventualBG-He.target_bg)/_t,2),He.minPredBG=Ut),!d||!Pt))return He.reason+=n(Ct,i)+"-"+n(Ut,i)+" in range: no temp required",t.duration>15&&r(Je,i)===r(t.rate,i)?(He.reason+=", temp "+t.rate+" ~ req "+Je+"U/hr. ",He):(He.reason+="; setting current basal of "+Je+" as temp. ",u.setTempBasal(Je,30,i,He,t));if(Ct>=it&&(He.reason+="Eventual BG "+n(Ct,i)+" >= "+n(it,i)+", ",Ct>it&&(He.insulinForManualBolus=o((Ct-ot)/_t,2))),a.iob>lt)return He.reason+="IOB "+o(a.iob,2)+" > max_iob "+lt,t.duration>15&&r(Je,i)===r(t.rate,i)?(He.reason+=", temp "+t.rate+" ~ req "+Je+"U/hr. ",He):(He.reason+="; setting current basal of "+Je+" as temp. ",u.setTempBasal(Je,30,i,He,t));Fa=o((Math.min(Ut,Ct)-ot)/_t,2),C=o((Ct-ot)/_t,2),Fa>lt-a.iob?(console.error("SMB limited by maxIOB: "+lt-a.iob+" (. insulinReq: "+Fa+" U)"),He.reason+="max_iob "+lt+", ",Fa=lt-a.iob):console.error("SMB not limited by maxIOB ( insulinReq: "+Fa+" U)."),C>lt-a.iob?(console.error("Ev. Bolus limited by maxIOB: "+lt-a.iob+" (. insulinForManualBolus: "+C+" U)"),He.reason+="max_iob "+lt+", "):console.error("Ev. Bolus would not be limited by maxIOB ( insulinForManualBolus: "+C+" U)."),ja=r(ja=Je+2*Fa,i),Fa=o(Fa,3),He.insulinReq=Fa;var Wa=o((new Date(Ke).getTime()-a.lastBolusTime)/6e4,1);if(d&&Pt&&Ye>U){var ka=30;void 0!==i.maxSMBBasalMinutes&&(ka=i.maxSMBBasalMinutes);var La=30;void 0!==i.maxUAMSMBBasalMinutes&&(La=i.maxUAMSMBBasalMinutes),v.useOverride&&M&&G!==ka&&(console.error("SMB Max Minutes - setting overriden from "+ka+" to "+G),ka=G),v.useOverride&&M&&T!==La&&(console.error("UAM Max Minutes - setting overriden from "+La+" to "+T),La=T);var za=o(l.mealCOB/Z,3),Na=0;void 0===ka?(Na=o(i.current_basal*N*30/60,1),console.error("smbMinutesSetting undefined: defaulting to 30m"),Fa>Na&&console.error("SMB limited by maxBolus: "+Na+" ( "+Fa+" U)")):a.iob>za&&a.iob>0?(console.error("IOB"+a.iob+"> COB"+l.mealCOB+"; mealInsulinReq ="+za),La?(console.error("maxUAMSMBBasalMinutes: "+La+", profile.current_basal: "+i.current_basal*N),Na=o(i.current_basal*N*La/60,1)):(console.error("maxUAMSMBBasalMinutes undefined: defaulting to 30m"),Na=o(i.current_basal*N*30/60,1)),Fa>Na?console.error("SMB limited by maxUAMSMBBasalMinutes [ "+La+"m ]: "+Na+"U ( "+Fa+"U )"):console.error("SMB is not limited by maxUAMSMBBasalMinutes. ( insulinReq: "+Fa+"U )")):(console.error(".maxSMBBasalMinutes: "+ka+", profile.current_basal: "+i.current_basal*N),Fa>(Na=o(i.current_basal*ka/60,1))?console.error("SMB limited by maxSMBBasalMinutes: "+ka+"m ]: "+Na+"U ( insulinReq: "+Fa+"U )"):console.error("SMB is not limited by maxSMBBasalMinutes. ( insulinReq: "+Fa+"U )"));var Ha=i.bolus_increment,Za=1/Ha,$a=i.smb_delivery_ratio;$a>.5&&console.error("SMB Delivery Ratio increased from default 0.5 to "+o($a,2));var Ja=Math.min(Fa*$a,Na);Ja=Math.floor(Ja*Za)/Za,Ia=o(60*((ot-(Tt+ia)/2)/_t)/i.current_basal*N),Fa>0&&Ja=30?(Ia=30*o(Ia/30),Ia=Math.min(60,Math.max(0,Ia))):(Ka=o(Je*Ia/30,2),Ia=30),He.reason+=" insulinReq "+Fa,Ja>=Na&&(He.reason+="; maxBolus "+Na),Ia>0&&(He.reason+="; setting "+Ia+"m low temp of "+Ka+"U/h"),He.reason+=". ";var Qa=3;i.SMBInterval&&(Qa=Math.min(10,Math.max(1,i.SMBInterval)));var Va=o(Qa-Wa,0),Xa=o(60*(Qa-Wa),0)%60;if(console.error("naive_eventualBG "+Tt+","+Ia+"m "+Ka+"U/h temp needed; last bolus "+Wa+"m ago; maxBolus: "+Na),Wa>Qa?Ja>0&&(He.units=Ja,He.reason+="Microbolusing "+Ja+"U. "):He.reason+="Waiting "+Va+"m "+Xa+"s to microbolus again. ",Ia>0)return He.rate=Ka,He.duration=Ia,He}var Ya=u.getMaxSafeBasal(i);return ja>Ya&&(He.reason+="adj. req. rate: "+ja+" to maxSafeBasal: "+o(Ya,2)+", ",ja=r(Ya,i)),(Pa=t.duration*(t.rate-Je)/60)>=2*Fa?(He.reason+=t.duration+"m@"+t.rate.toFixed(2)+" > 2 * insulinReq. Setting temp basal of "+ja+"U/hr. ",u.setTempBasal(ja,30,i,He,t)):void 0===t.duration||0===t.duration?(He.reason+="no temp, setting "+ja+"U/hr. ",u.setTempBasal(ja,30,i,He,t)):t.duration>5&&r(ja,i)<=r(t.rate,i)?(He.reason+="temp "+t.rate+" >~ req "+ja+"U/hr. ",He):(He.reason+="temp "+t.rate+"<"+ja+"U/hr. ",u.setTempBasal(ja,30,i,He,t))}},6880:(e,t,a)=>{var r=a(6654);e.exports=function(e,t){var a=20;void 0!==t&&"string"==typeof t.model&&(r(t.model,"54")||r(t.model,"23"))&&(a=40);return e<1?Math.round(e*a)/a:e<10?Math.round(20*e)/20:Math.round(10*e)/10}},2705:(e,t,a)=>{var r=a(5639).Symbol;e.exports=r},9932:e=>{e.exports=function(e,t){for(var a=-1,r=null==e?0:e.length,o=Array(r);++a{e.exports=function(e,t,a){return e==e&&(void 0!==a&&(e=e<=a?e:a),void 0!==t&&(e=e>=t?e:t)),e}},4239:(e,t,a)=>{var r=a(2705),o=a(9607),n=a(2333),i=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":i&&i in Object(e)?o(e):n(e)}},531:(e,t,a)=>{var r=a(2705),o=a(9932),n=a(1469),i=a(3448),s=r?r.prototype:void 0,l=s?s.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(n(t))return o(t,e)+"";if(i(t))return l?l.call(t):"";var a=t+"";return"0"==a&&1/t==-Infinity?"-0":a}},7561:(e,t,a)=>{var r=a(7990),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},1957:(e,t,a)=>{var r="object"==typeof a.g&&a.g&&a.g.Object===Object&&a.g;e.exports=r},9607:(e,t,a)=>{var r=a(2705),o=Object.prototype,n=o.hasOwnProperty,i=o.toString,s=r?r.toStringTag:void 0;e.exports=function(e){var t=n.call(e,s),a=e[s];try{e[s]=void 0;var r=!0}catch(e){}var o=i.call(e);return r&&(t?e[s]=a:delete e[s]),o}},2333:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},5639:(e,t,a)=>{var r=a(1957),o="object"==typeof self&&self&&self.Object===Object&&self,n=r||o||Function("return this")();e.exports=n},7990:e=>{var t=/\s/;e.exports=function(e){for(var a=e.length;a--&&t.test(e.charAt(a)););return a}},6654:(e,t,a)=>{var r=a(9750),o=a(531),n=a(554),i=a(9833);e.exports=function(e,t,a){e=i(e),t=o(t);var s=e.length,l=a=void 0===a?s:r(n(a),0,s);return(a-=t.length)>=0&&e.slice(a,l)==t}},1469:e=>{var t=Array.isArray;e.exports=t},3218:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},7005:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},3448:(e,t,a)=>{var r=a(4239),o=a(7005);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},8601:(e,t,a)=>{var r=a(4841),o=1/0;e.exports=function(e){return e?(e=r(e))===o||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}},554:(e,t,a)=>{var r=a(8601);e.exports=function(e){var t=r(e),a=t%1;return t==t?a?t-a:t:0}},4841:(e,t,a)=>{var r=a(7561),o=a(3218),n=a(3448),i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(n(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var a=s.test(e);return a||l.test(e)?u(e.slice(2),a?2:8):i.test(e)?NaN:+e}},9833:(e,t,a)=>{var r=a(531);e.exports=function(e){return null==e?"":r(e)}}},t={};function a(r){var o=t[r];if(void 0!==o)return o.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,a),n.exports}a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var r=a(5546);freeaps_determineBasal=r})(); \ No newline at end of file diff --git a/FreeAPS/Resources/javascript/bundle/profile.js b/FreeAPS/Resources/javascript/bundle/profile.js index 94dd050942..03366d75e8 100644 --- a/FreeAPS/Resources/javascript/bundle/profile.js +++ b/FreeAPS/Resources/javascript/bundle/profile.js @@ -1,2 +1,2 @@ /*! For license information please see profile.js.LICENSE.txt */ -var freeaps_profile;(()=>{var t={6261:(t,n)=>{t.exports=function(t){var n=new Date;return n.setHours("00"),n.setMinutes("00"),n.setSeconds("00"),n.getTime()+60*t*1e3}},1836:(t,n,r)=>{var e=r(6486);n.maxDailyBasal=function(t){var n=e.maxBy(t.basals,(function(t){return Number(t.rate)}));return 1e3*Number(n.rate)/1e3},n.maxBasalLookup=function(t){return t.settings.maxBasal},n.basalLookup=function(t,n){var r=n;void 0===n&&(r=new Date);var u=e.sortBy(t,(function(t){return t.i})),i=u[u.length-1].rate;if(0!==i){for(var a=60*r.getHours()+r.getMinutes(),o=0;o=u[o].minutes&&a{var e=r(6261);function u(t,n){var r=new Date,u=t.carbratio;if(void 0===u||void 0===u.schedule);else{var i;if("grams"===u.units||"exchanges"===u.units){i=u.schedule[u.schedule.length-1];for(var a=0;a=e(u.schedule[a].offset)&&r150)return void console.error("Error: carbRatio of "+i+" out of bounds.");break}return"exchanges"===u.units&&(i.ratio=12/i.ratio),i.ratio}console.error("Error: Unsupported carb_ratio units "+u.units)}}u.carbRatioLookup=u,t.exports=u},6014:(t,n,r)=>{var e=r(1836),u=r(4034),i=r(3725),a=r(5364),o=r(6486);function f(){return{max_iob:9,max_daily_safety_multiplier:5,current_basal_safety_multiplier:6,autosens_max:2.5,autosens_min:.5,rewind_resets_autosens:!0,high_temptarget_raises_sensitivity:!1,low_temptarget_lowers_sensitivity:!1,sensitivity_raises_target:!1,resistance_lowers_target:!1,exercise_mode:!1,half_basal_exercise_target:150,maxCOB:120,skip_neutral_temps:!1,unsuspend_if_no_temp:!1,min_5m_carbimpact:8,autotune_isf_adjustmentFraction:1,remainingCarbsFraction:1,remainingCarbsCap:90,enableUAM:!0,A52_risk_enable:!1,enableSMB_with_COB:!0,enableSMB_with_temptarget:!0,enableSMB_always:!0,enableSMB_after_carbs:!0,allowSMB_with_high_temptarget:!0,maxSMBBasalMinutes:90,maxUAMSMBBasalMinutes:90,SMBInterval:3,bolus_increment:.05,maxDelta_bg_threshold:.2,curve:"rapid-acting",useCustomPeakTime:!1,insulinPeakTime:45,carbsReqThreshold:1,offline_hotspot:!1,noisyCGMTargetMultiplier:1.3,suspend_zeros_iob:!0,enableEnliteBgproxy:!1,calc_glucose_noise:!1,target_bg:!1,smb_delivery_ratio:.5,adjustmentFactor:1,useNewFormula:!1,enableDynamicCR:!1,sigmoid:!1,weightPercentage:.65,tddAdjBasal:!1,enableSMB_high_bg:!1,enableSMB_high_bg_target:110}}function c(t,n){var r=n&&n.type?n:{max_iob:9,max_daily_safety_multiplier:5,current_basal_safety_multiplier:6,autosens_max:2.5,autosens_min:.5,rewind_resets_autosens:!0,high_temptarget_raises_sensitivity:!1,low_temptarget_lowers_sensitivity:!1,sensitivity_raises_target:!1,resistance_lowers_target:!1,exercise_mode:!1,half_basal_exercise_target:150,maxCOB:120,skip_neutral_temps:!1,unsuspend_if_no_temp:!1,min_5m_carbimpact:8,autotune_isf_adjustmentFraction:1,remainingCarbsFraction:1,remainingCarbsCap:90,enableUAM:!0,A52_risk_enable:!1,enableSMB_with_COB:!0,enableSMB_with_temptarget:!0,enableSMB_always:!0,enableSMB_after_carbs:!0,allowSMB_with_high_temptarget:!0,maxSMBBasalMinutes:90,maxUAMSMBBasalMinutes:90,SMBInterval:3,bolus_increment:.05,maxDelta_bg_threshold:.2,curve:"rapid-acting",useCustomPeakTime:!1,insulinPeakTime:45,carbsReqThreshold:1,offline_hotspot:!1,noisyCGMTargetMultiplier:1.3,suspend_zeros_iob:!0,enableEnliteBgproxy:!1,calc_glucose_noise:!1,target_bg:!1,smb_delivery_ratio:.5,adjustmentFactor:1,useNewFormula:!1,enableDynamicCR:!1,sigmoid:!1,weightPercentage:.65,tddAdjBasal:!1,enableSMB_high_bg:!1,enableSMB_high_bg_target:110,threshold_setting:65};for(var f in r)t.hasOwnProperty(f)&&(r[f]=t[f]);var c=t.settings;if(!(t.settings.insulin_action_curve>1))return console.error("DIA of",r.dia,"is not supported"),-1;if(r.dia=c.insulin_action_curve,t.model&&(r.model=t.model),r.skip_neutral_temps=t.skip_neutral_temps,r.current_basal=e.basalLookup(t.basals),r.basalprofile=t.basals,o.forEach(r.basalprofile,(function(t){t.rate=+(Math.round(t.rate+"e+3")+"e-3")})),r.max_daily_basal=e.maxDailyBasal(t),r.max_basal=e.maxBasalLookup(t),0===r.current_basal)return console.error("current_basal of",r.current_basal,"is not supported"),-1;if(0===r.max_daily_basal)return console.error("max_daily_basal of",r.max_daily_basal,"is not supported"),-1;if(r.max_basal<.1)return console.error("max_basal of",r.max_basal,"is not supported"),-1;var l=u.bgTargetsLookup(t,r);return r.out_units=t.targets.user_preferred_units,r.min_bg=Math.round(l.min_bg),r.max_bg=Math.round(l.max_bg),r.bg_targets=t.targets,o.forEach(r.bg_targets.targets,(function(t){t.high=Math.round(t.high),t.low=Math.round(t.low),t.min_bg=Math.round(t.min_bg),t.max_bg=Math.round(t.max_bg)})),delete r.bg_targets.raw,r.temptargetSet=l.temptargetSet,r.sens=i.isfLookup(t.isf),r.isfProfile=t.isf,r.sens<5?(console.error("ISF of",r.sens,"is not supported"),-1):(void 0!==t.carbratio?(r.carb_ratio=a.carbRatioLookup(t,r),r.carb_ratios=t.carbratio):console.error("Profile wasn't given carb ratio data, cannot calculate carb_ratio"),r)}c.defaults=f,c.displayedDefaults=function(){var t={max_iob:9,max_daily_safety_multiplier:5,current_basal_safety_multiplier:6,autosens_max:2.5,autosens_min:.5,rewind_resets_autosens:!0,high_temptarget_raises_sensitivity:!1,low_temptarget_lowers_sensitivity:!1,sensitivity_raises_target:!1,resistance_lowers_target:!1,exercise_mode:!1,half_basal_exercise_target:150,maxCOB:120,skip_neutral_temps:!1,unsuspend_if_no_temp:!1,min_5m_carbimpact:8,autotune_isf_adjustmentFraction:1,remainingCarbsFraction:1,remainingCarbsCap:90,enableUAM:!0,A52_risk_enable:!1,enableSMB_with_COB:!0,enableSMB_with_temptarget:!0,enableSMB_always:!0,enableSMB_after_carbs:!0,allowSMB_with_high_temptarget:!0,maxSMBBasalMinutes:90,maxUAMSMBBasalMinutes:90,SMBInterval:3,bolus_increment:.05,maxDelta_bg_threshold:.2,curve:"rapid-acting",useCustomPeakTime:!1,insulinPeakTime:45,carbsReqThreshold:1,offline_hotspot:!1,noisyCGMTargetMultiplier:1.3,suspend_zeros_iob:!0,enableEnliteBgproxy:!1,calc_glucose_noise:!1,target_bg:!1,smb_delivery_ratio:.5,adjustmentFactor:1,useNewFormula:!1,enableDynamicCR:!1,sigmoid:!1,weightPercentage:.65,tddAdjBasal:!1,enableSMB_high_bg:!1,enableSMB_high_bg_target:110,threshold_setting:65},n={};return n.max_iob=t.max_iob,n.max_daily_safety_multiplier=t.max_daily_safety_multiplier,n.current_basal_safety_multiplier=t.current_basal_safety_multiplier,n.autosens_max=t.autosens_max,n.autosens_min=t.autosens_min,n.rewind_resets_autosens=t.rewind_resets_autosens,n.exercise_mode=t.exercise_mode,n.sensitivity_raises_target=t.sensitivity_raises_target,n.unsuspend_if_no_temp=t.unsuspend_if_no_temp,n.enableSMB_with_COB=t.enableSMB_with_COB,n.enableSMB_with_temptarget=t.enableSMB_with_temptarget,n.enableUAM=t.enableUAM,n.curve=t.curve,n.offline_hotspot=t.offline_hotspot,n.bolus_increment=t.bolus_increment,n.smb_delivery_ratio=t.smb_delivery_ratio,n.maxDelta_bg_threshold=t.maxDelta_bg_threshold,n.adjustmentFactor=t.adjustmentFactor,n.useNewFormula=t.useNewFormula,n.enableDynamicCR=t.enableDynamicCR,n.sigmoid=t.sigmoid,n.weightPercentage=t.weightPercentage,n.tddAdjBasal=t.tddAdjBasal,console.error(n),n},t.exports=c},3725:(t,n,r)=>{var e=r(6486),u=null;function i(t,n){var r=n;void 0===n&&(r=new Date);var i=60*r.getHours()+r.getMinutes();if(u&&i>=u.offset&&i=c.offset&&i{var e=r(6261);function u(t,n){return a(i(t,n))}function i(t,n){for(var r=t.targets,u=t.temptargets,i=new Date,a=r.targets[r.targets.length-1],o=0;o=e(r.targets[o].offset)&&i=c&&0===u[o].duration){f=a;break}if(!u[o].targetBottom||!u[o].targetTop){console.error("eventualBG target range invalid: "+u[o].targetBottom+"-"+u[o].targetTop);break}if(i>=c&&i"']/g,J=RegExp(H.source),Y=RegExp(V.source),Q=/<%-([\s\S]+?)%>/g,X=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,nt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,rt=/^\w*$/,et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ut=/[\\^$.*+?()[\]{}|]/g,it=RegExp(ut.source),at=/^\s+/,ot=/\s/,ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ct=/\{\n\/\* \[wrapped with (.+)\] \*/,lt=/,? & /,st=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,_t=/[()=,{}\[\]\/\s]/,ht=/\\(\\)?/g,pt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,gt=/\w*$/,vt=/^[-+]0x[0-9a-f]+$/i,dt=/^0b[01]+$/i,yt=/^\[object .+?Constructor\]$/,bt=/^0o[0-7]+$/i,mt=/^(?:0|[1-9]\d*)$/,wt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,xt=/($^)/,St=/['\n\r\u2028\u2029\\]/g,Bt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",jt="\\u2700-\\u27bf",At="a-z\\xdf-\\xf6\\xf8-\\xff",kt="A-Z\\xc0-\\xd6\\xd8-\\xde",It="\\ufe0e\\ufe0f",Mt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ct="['’]",Ft="[\\ud800-\\udfff]",Ot="["+Mt+"]",Rt="["+Bt+"]",Et="\\d+",zt="[\\u2700-\\u27bf]",Tt="["+At+"]",Dt="[^\\ud800-\\udfff"+Mt+Et+jt+At+kt+"]",Lt="\\ud83c[\\udffb-\\udfff]",Ut="[^\\ud800-\\udfff]",Wt="(?:\\ud83c[\\udde6-\\uddff]){2}",Pt="[\\ud800-\\udbff][\\udc00-\\udfff]",Nt="["+kt+"]",$t="(?:"+Tt+"|"+Dt+")",qt="(?:"+Nt+"|"+Dt+")",Gt="(?:['’](?:d|ll|m|re|s|t|ve))?",Zt="(?:['’](?:D|LL|M|RE|S|T|VE))?",Kt="(?:"+Rt+"|"+Lt+")"+"?",Ht="[\\ufe0e\\ufe0f]?",Vt=Ht+Kt+("(?:\\u200d(?:"+[Ut,Wt,Pt].join("|")+")"+Ht+Kt+")*"),Jt="(?:"+[zt,Wt,Pt].join("|")+")"+Vt,Yt="(?:"+[Ut+Rt+"?",Rt,Wt,Pt,Ft].join("|")+")",Qt=RegExp(Ct,"g"),Xt=RegExp(Rt,"g"),tn=RegExp(Lt+"(?="+Lt+")|"+Yt+Vt,"g"),nn=RegExp([Nt+"?"+Tt+"+"+Gt+"(?="+[Ot,Nt,"$"].join("|")+")",qt+"+"+Zt+"(?="+[Ot,Nt+$t,"$"].join("|")+")",Nt+"?"+$t+"+"+Gt,Nt+"+"+Zt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Et,Jt].join("|"),"g"),rn=RegExp("[\\u200d\\ud800-\\udfff"+Bt+It+"]"),en=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,un=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],an=-1,on={};on[T]=on[D]=on[L]=on[U]=on[W]=on[P]=on[N]=on[$]=on[q]=!0,on[y]=on[b]=on[E]=on[m]=on[z]=on[w]=on[x]=on[S]=on[j]=on[A]=on[k]=on[M]=on[C]=on[F]=on[R]=!1;var fn={};fn[y]=fn[b]=fn[E]=fn[z]=fn[m]=fn[w]=fn[T]=fn[D]=fn[L]=fn[U]=fn[W]=fn[j]=fn[A]=fn[k]=fn[M]=fn[C]=fn[F]=fn[O]=fn[P]=fn[N]=fn[$]=fn[q]=!0,fn[x]=fn[S]=fn[R]=!1;var cn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ln=parseFloat,sn=parseInt,_n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,hn="object"==typeof self&&self&&self.Object===Object&&self,pn=_n||hn||Function("return this")(),gn=n&&!n.nodeType&&n,vn=gn&&t&&!t.nodeType&&t,dn=vn&&vn.exports===gn,yn=dn&&_n.process,bn=function(){try{var t=vn&&vn.require&&vn.require("util").types;return t||yn&&yn.binding&&yn.binding("util")}catch(t){}}(),mn=bn&&bn.isArrayBuffer,wn=bn&&bn.isDate,xn=bn&&bn.isMap,Sn=bn&&bn.isRegExp,Bn=bn&&bn.isSet,jn=bn&&bn.isTypedArray;function An(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}function kn(t,n,r,e){for(var u=-1,i=null==t?0:t.length;++u-1}function Rn(t,n,r){for(var e=-1,u=null==t?0:t.length;++e-1;);return r}function rr(t,n){for(var r=t.length;r--&&Nn(n,t[r],0)>-1;);return r}function er(t,n){for(var r=t.length,e=0;r--;)t[r]===n&&++e;return e}var ur=Kn({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),ir=Kn({"&":"&","<":"<",">":">",'"':""","'":"'"});function ar(t){return"\\"+cn[t]}function or(t){return rn.test(t)}function fr(t){var n=-1,r=Array(t.size);return t.forEach((function(t,e){r[++n]=[e,t]})),r}function cr(t,n){return function(r){return t(n(r))}}function lr(t,n){for(var r=-1,e=t.length,u=0,i=[];++r",""":'"',"'":"'"});var dr=function t(n){var r,e=(n=null==n?pn:dr.defaults(pn.Object(),n,dr.pick(pn,un))).Array,ot=n.Date,Bt=n.Error,jt=n.Function,At=n.Math,kt=n.Object,It=n.RegExp,Mt=n.String,Ct=n.TypeError,Ft=e.prototype,Ot=jt.prototype,Rt=kt.prototype,Et=n["__core-js_shared__"],zt=Ot.toString,Tt=Rt.hasOwnProperty,Dt=0,Lt=(r=/[^.]+$/.exec(Et&&Et.keys&&Et.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",Ut=Rt.toString,Wt=zt.call(kt),Pt=pn._,Nt=It("^"+zt.call(Tt).replace(ut,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$t=dn?n.Buffer:u,qt=n.Symbol,Gt=n.Uint8Array,Zt=$t?$t.allocUnsafe:u,Kt=cr(kt.getPrototypeOf,kt),Ht=kt.create,Vt=Rt.propertyIsEnumerable,Jt=Ft.splice,Yt=qt?qt.isConcatSpreadable:u,tn=qt?qt.iterator:u,rn=qt?qt.toStringTag:u,cn=function(){try{var t=hi(kt,"defineProperty");return t({},"",{}),t}catch(t){}}(),_n=n.clearTimeout!==pn.clearTimeout&&n.clearTimeout,hn=ot&&ot.now!==pn.Date.now&&ot.now,gn=n.setTimeout!==pn.setTimeout&&n.setTimeout,vn=At.ceil,yn=At.floor,bn=kt.getOwnPropertySymbols,Un=$t?$t.isBuffer:u,Kn=n.isFinite,yr=Ft.join,br=cr(kt.keys,kt),mr=At.max,wr=At.min,xr=ot.now,Sr=n.parseInt,Br=At.random,jr=Ft.reverse,Ar=hi(n,"DataView"),kr=hi(n,"Map"),Ir=hi(n,"Promise"),Mr=hi(n,"Set"),Cr=hi(n,"WeakMap"),Fr=hi(kt,"create"),Or=Cr&&new Cr,Rr={},Er=Wi(Ar),zr=Wi(kr),Tr=Wi(Ir),Dr=Wi(Mr),Lr=Wi(Cr),Ur=qt?qt.prototype:u,Wr=Ur?Ur.valueOf:u,Pr=Ur?Ur.toString:u;function Nr(t){if(eo(t)&&!Za(t)&&!(t instanceof Zr)){if(t instanceof Gr)return t;if(Tt.call(t,"__wrapped__"))return Pi(t)}return new Gr(t)}var $r=function(){function t(){}return function(n){if(!ro(n))return{};if(Ht)return Ht(n);t.prototype=n;var r=new t;return t.prototype=u,r}}();function qr(){}function Gr(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=u}function Zr(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=v,this.__views__=[]}function Kr(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n=n?t:n)),t}function le(t,n,r,e,i,a){var o,f=1&n,c=2&n,l=4&n;if(r&&(o=i?r(t,e,i,a):r(t)),o!==u)return o;if(!ro(t))return t;var s=Za(t);if(s){if(o=function(t){var n=t.length,r=new t.constructor(n);n&&"string"==typeof t[0]&&Tt.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!f)return Fu(t,o)}else{var _=vi(t),h=_==S||_==B;if(Ja(t))return ju(t,f);if(_==k||_==y||h&&!i){if(o=c||h?{}:yi(t),!f)return c?function(t,n){return Ou(t,gi(t),n)}(t,function(t,n){return t&&Ou(n,zo(n),t)}(o,t)):function(t,n){return Ou(t,pi(t),n)}(t,ae(o,t))}else{if(!fn[_])return i?t:{};o=function(t,n,r){var e=t.constructor;switch(n){case E:return Au(t);case m:case w:return new e(+t);case z:return function(t,n){var r=n?Au(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case T:case D:case L:case U:case W:case P:case N:case $:case q:return ku(t,r);case j:return new e;case A:case F:return new e(t);case M:return function(t){var n=new t.constructor(t.source,gt.exec(t));return n.lastIndex=t.lastIndex,n}(t);case C:return new e;case O:return u=t,Wr?kt(Wr.call(u)):{}}var u}(t,_,f)}}a||(a=new Yr);var p=a.get(t);if(p)return p;a.set(t,o),fo(t)?t.forEach((function(e){o.add(le(e,n,r,e,t,a))})):uo(t)&&t.forEach((function(e,u){o.set(u,le(e,n,r,u,t,a))}));var g=s?u:(l?c?ai:ii:c?zo:Eo)(t);return In(g||t,(function(e,u){g&&(e=t[u=e]),ee(o,u,le(e,n,r,u,t,a))})),o}function se(t,n,r){var e=r.length;if(null==t)return!e;for(t=kt(t);e--;){var i=r[e],a=n[i],o=t[i];if(o===u&&!(i in t)||!a(o))return!1}return!0}function _e(t,n,r){if("function"!=typeof t)throw new Ct(i);return Ri((function(){t.apply(u,r)}),n)}function he(t,n,r,e){var u=-1,i=On,a=!0,o=t.length,f=[],c=n.length;if(!o)return f;r&&(n=En(n,Qn(r))),e?(i=Rn,a=!1):n.length>=200&&(i=tr,a=!1,n=new Jr(n));t:for(;++u-1},Hr.prototype.set=function(t,n){var r=this.__data__,e=ue(r,t);return e<0?(++this.size,r.push([t,n])):r[e][1]=n,this},Vr.prototype.clear=function(){this.size=0,this.__data__={hash:new Kr,map:new(kr||Hr),string:new Kr}},Vr.prototype.delete=function(t){var n=si(this,t).delete(t);return this.size-=n?1:0,n},Vr.prototype.get=function(t){return si(this,t).get(t)},Vr.prototype.has=function(t){return si(this,t).has(t)},Vr.prototype.set=function(t,n){var r=si(this,t),e=r.size;return r.set(t,n),this.size+=r.size==e?0:1,this},Jr.prototype.add=Jr.prototype.push=function(t){return this.__data__.set(t,a),this},Jr.prototype.has=function(t){return this.__data__.has(t)},Yr.prototype.clear=function(){this.__data__=new Hr,this.size=0},Yr.prototype.delete=function(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r},Yr.prototype.get=function(t){return this.__data__.get(t)},Yr.prototype.has=function(t){return this.__data__.has(t)},Yr.prototype.set=function(t,n){var r=this.__data__;if(r instanceof Hr){var e=r.__data__;if(!kr||e.length<199)return e.push([t,n]),this.size=++r.size,this;r=this.__data__=new Vr(e)}return r.set(t,n),this.size=r.size,this};var pe=zu(xe),ge=zu(Se,!0);function ve(t,n){var r=!0;return pe(t,(function(t,e,u){return r=!!n(t,e,u)})),r}function de(t,n,r){for(var e=-1,i=t.length;++e0&&r(o)?n>1?be(o,n-1,r,e,u):zn(u,o):e||(u[u.length]=o)}return u}var me=Tu(),we=Tu(!0);function xe(t,n){return t&&me(t,n,Eo)}function Se(t,n){return t&&we(t,n,Eo)}function Be(t,n){return Fn(n,(function(n){return Xa(t[n])}))}function je(t,n){for(var r=0,e=(n=wu(n,t)).length;null!=t&&rn}function Me(t,n){return null!=t&&Tt.call(t,n)}function Ce(t,n){return null!=t&&n in kt(t)}function Fe(t,n,r){for(var i=r?Rn:On,a=t[0].length,o=t.length,f=o,c=e(o),l=1/0,s=[];f--;){var _=t[f];f&&n&&(_=En(_,Qn(n))),l=wr(_.length,l),c[f]=!r&&(n||a>=120&&_.length>=120)?new Jr(f&&_):u}_=t[0];var h=-1,p=c[0];t:for(;++h=o?f:f*("desc"==r[e]?-1:1)}return t.index-n.index}(t,n,r)}))}function Ke(t,n,r){for(var e=-1,u=n.length,i={};++e-1;)o!==t&&Jt.call(o,f,1),Jt.call(t,f,1);return t}function Ve(t,n){for(var r=t?n.length:0,e=r-1;r--;){var u=n[r];if(r==e||u!==i){var i=u;mi(u)?Jt.call(t,u,1):hu(t,u)}}return t}function Je(t,n){return t+yn(Br()*(n-t+1))}function Ye(t,n){var r="";if(!t||n<1||n>p)return r;do{n%2&&(r+=t),(n=yn(n/2))&&(t+=t)}while(n);return r}function Qe(t,n){return Ei(Ii(t,n,of),t+"")}function Xe(t){return Xr($o(t))}function tu(t,n){var r=$o(t);return Di(r,ce(n,0,r.length))}function nu(t,n,r,e){if(!ro(t))return t;for(var i=-1,a=(n=wu(n,t)).length,o=a-1,f=t;null!=f&&++ii?0:i+n),(r=r>i?i:r)<0&&(r+=i),i=n>r?0:r-n>>>0,n>>>=0;for(var a=e(i);++u>>1,a=t[i];null!==a&&!lo(a)&&(r?a<=n:a=200){var c=n?null:Yu(t);if(c)return sr(c);a=!1,u=tr,f=new Jr}else f=n?[]:o;t:for(;++e=e?t:iu(t,n,r)}var Bu=_n||function(t){return pn.clearTimeout(t)};function ju(t,n){if(n)return t.slice();var r=t.length,e=Zt?Zt(r):new t.constructor(r);return t.copy(e),e}function Au(t){var n=new t.constructor(t.byteLength);return new Gt(n).set(new Gt(t)),n}function ku(t,n){var r=n?Au(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Iu(t,n){if(t!==n){var r=t!==u,e=null===t,i=t==t,a=lo(t),o=n!==u,f=null===n,c=n==n,l=lo(n);if(!f&&!l&&!a&&t>n||a&&o&&c&&!f&&!l||e&&o&&c||!r&&c||!i)return 1;if(!e&&!a&&!l&&t1?r[i-1]:u,o=i>2?r[2]:u;for(a=t.length>3&&"function"==typeof a?(i--,a):u,o&&wi(r[0],r[1],o)&&(a=i<3?u:a,i=1),n=kt(n);++e-1?i[a?n[o]:o]:u}}function Pu(t){return ui((function(n){var r=n.length,e=r,a=Gr.prototype.thru;for(t&&n.reverse();e--;){var o=n[e];if("function"!=typeof o)throw new Ct(i);if(a&&!f&&"wrapper"==fi(o))var f=new Gr([],!0)}for(e=f?e:r;++e1&&b.reverse(),h&&lf))return!1;var l=a.get(t),s=a.get(n);if(l&&s)return l==n&&s==t;var _=-1,h=!0,p=2&r?new Jr:u;for(a.set(t,n),a.set(n,t);++_-1&&t%1==0&&t1?"& ":"")+n[e],n=n.join(r>2?", ":" "),t.replace(ft,"{\n/* [wrapped with "+n+"] */\n")}(e,function(t,n){return In(d,(function(r){var e="_."+r[0];n&r[1]&&!On(t,e)&&t.push(e)})),t.sort()}(function(t){var n=t.match(ct);return n?n[1].split(lt):[]}(e),r)))}function Ti(t){var n=0,r=0;return function(){var e=xr(),i=16-(e-r);if(r=e,i>0){if(++n>=800)return arguments[0]}else n=0;return t.apply(u,arguments)}}function Di(t,n){var r=-1,e=t.length,i=e-1;for(n=n===u?e:n;++r1?t[n-1]:u;return r="function"==typeof r?(t.pop(),r):u,oa(t,r)}));function pa(t){var n=Nr(t);return n.__chain__=!0,n}function ga(t,n){return n(t)}var va=ui((function(t){var n=t.length,r=n?t[0]:0,e=this.__wrapped__,i=function(n){return fe(n,t)};return!(n>1||this.__actions__.length)&&e instanceof Zr&&mi(r)?((e=e.slice(r,+r+(n?1:0))).__actions__.push({func:ga,args:[i],thisArg:u}),new Gr(e,this.__chain__).thru((function(t){return n&&!t.length&&t.push(u),t}))):this.thru(i)}));var da=Ru((function(t,n,r){Tt.call(t,r)?++t[r]:oe(t,r,1)}));var ya=Wu(Gi),ba=Wu(Zi);function ma(t,n){return(Za(t)?In:pe)(t,li(n,3))}function wa(t,n){return(Za(t)?Mn:ge)(t,li(n,3))}var xa=Ru((function(t,n,r){Tt.call(t,r)?t[r].push(n):oe(t,r,[n])}));var Sa=Qe((function(t,n,r){var u=-1,i="function"==typeof n,a=Ha(t)?e(t.length):[];return pe(t,(function(t){a[++u]=i?An(n,t,r):Oe(t,n,r)})),a})),Ba=Ru((function(t,n,r){oe(t,r,n)}));function ja(t,n){return(Za(t)?En:Pe)(t,li(n,3))}var Aa=Ru((function(t,n,r){t[r?0:1].push(n)}),(function(){return[[],[]]}));var ka=Qe((function(t,n){if(null==t)return[];var r=n.length;return r>1&&wi(t,n[0],n[1])?n=[]:r>2&&wi(n[0],n[1],n[2])&&(n=[n[0]]),Ze(t,be(n,1),[])})),Ia=hn||function(){return pn.Date.now()};function Ma(t,n,r){return n=r?u:n,n=t&&null==n?t.length:n,Xu(t,s,u,u,u,u,n)}function Ca(t,n){var r;if("function"!=typeof n)throw new Ct(i);return t=vo(t),function(){return--t>0&&(r=n.apply(this,arguments)),t<=1&&(n=u),r}}var Fa=Qe((function(t,n,r){var e=1;if(r.length){var u=lr(r,ci(Fa));e|=c}return Xu(t,e,n,r,u)})),Oa=Qe((function(t,n,r){var e=3;if(r.length){var u=lr(r,ci(Oa));e|=c}return Xu(n,e,t,r,u)}));function Ra(t,n,r){var e,a,o,f,c,l,s=0,_=!1,h=!1,p=!0;if("function"!=typeof t)throw new Ct(i);function g(n){var r=e,i=a;return e=a=u,s=n,f=t.apply(i,r)}function v(t){return s=t,c=Ri(y,n),_?g(t):f}function d(t){var r=t-l;return l===u||r>=n||r<0||h&&t-s>=o}function y(){var t=Ia();if(d(t))return b(t);c=Ri(y,function(t){var r=n-(t-l);return h?wr(r,o-(t-s)):r}(t))}function b(t){return c=u,p&&e?g(t):(e=a=u,f)}function m(){var t=Ia(),r=d(t);if(e=arguments,a=this,l=t,r){if(c===u)return v(l);if(h)return Bu(c),c=Ri(y,n),g(l)}return c===u&&(c=Ri(y,n)),f}return n=bo(n)||0,ro(r)&&(_=!!r.leading,o=(h="maxWait"in r)?mr(bo(r.maxWait)||0,n):o,p="trailing"in r?!!r.trailing:p),m.cancel=function(){c!==u&&Bu(c),s=0,e=l=a=c=u},m.flush=function(){return c===u?f:b(Ia())},m}var Ea=Qe((function(t,n){return _e(t,1,n)})),za=Qe((function(t,n,r){return _e(t,bo(n)||0,r)}));function Ta(t,n){if("function"!=typeof t||null!=n&&"function"!=typeof n)throw new Ct(i);var r=function(){var e=arguments,u=n?n.apply(this,e):e[0],i=r.cache;if(i.has(u))return i.get(u);var a=t.apply(this,e);return r.cache=i.set(u,a)||i,a};return r.cache=new(Ta.Cache||Vr),r}function Da(t){if("function"!=typeof t)throw new Ct(i);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}Ta.Cache=Vr;var La=xu((function(t,n){var r=(n=1==n.length&&Za(n[0])?En(n[0],Qn(li())):En(be(n,1),Qn(li()))).length;return Qe((function(e){for(var u=-1,i=wr(e.length,r);++u=n})),Ga=Re(function(){return arguments}())?Re:function(t){return eo(t)&&Tt.call(t,"callee")&&!Vt.call(t,"callee")},Za=e.isArray,Ka=mn?Qn(mn):function(t){return eo(t)&&ke(t)==E};function Ha(t){return null!=t&&no(t.length)&&!Xa(t)}function Va(t){return eo(t)&&Ha(t)}var Ja=Un||mf,Ya=wn?Qn(wn):function(t){return eo(t)&&ke(t)==w};function Qa(t){if(!eo(t))return!1;var n=ke(t);return n==x||"[object DOMException]"==n||"string"==typeof t.message&&"string"==typeof t.name&&!ao(t)}function Xa(t){if(!ro(t))return!1;var n=ke(t);return n==S||n==B||"[object AsyncFunction]"==n||"[object Proxy]"==n}function to(t){return"number"==typeof t&&t==vo(t)}function no(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=p}function ro(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function eo(t){return null!=t&&"object"==typeof t}var uo=xn?Qn(xn):function(t){return eo(t)&&vi(t)==j};function io(t){return"number"==typeof t||eo(t)&&ke(t)==A}function ao(t){if(!eo(t)||ke(t)!=k)return!1;var n=Kt(t);if(null===n)return!0;var r=Tt.call(n,"constructor")&&n.constructor;return"function"==typeof r&&r instanceof r&&zt.call(r)==Wt}var oo=Sn?Qn(Sn):function(t){return eo(t)&&ke(t)==M};var fo=Bn?Qn(Bn):function(t){return eo(t)&&vi(t)==C};function co(t){return"string"==typeof t||!Za(t)&&eo(t)&&ke(t)==F}function lo(t){return"symbol"==typeof t||eo(t)&&ke(t)==O}var so=jn?Qn(jn):function(t){return eo(t)&&no(t.length)&&!!on[ke(t)]};var _o=Hu(We),ho=Hu((function(t,n){return t<=n}));function po(t){if(!t)return[];if(Ha(t))return co(t)?pr(t):Fu(t);if(tn&&t[tn])return function(t){for(var n,r=[];!(n=t.next()).done;)r.push(n.value);return r}(t[tn]());var n=vi(t);return(n==j?fr:n==C?sr:$o)(t)}function go(t){return t?(t=bo(t))===h||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function vo(t){var n=go(t),r=n%1;return n==n?r?n-r:n:0}function yo(t){return t?ce(vo(t),0,v):0}function bo(t){if("number"==typeof t)return t;if(lo(t))return g;if(ro(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=ro(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=Yn(t);var r=dt.test(t);return r||bt.test(t)?sn(t.slice(2),r?2:8):vt.test(t)?g:+t}function mo(t){return Ou(t,zo(t))}function wo(t){return null==t?"":su(t)}var xo=Eu((function(t,n){if(ji(n)||Ha(n))Ou(n,Eo(n),t);else for(var r in n)Tt.call(n,r)&&ee(t,r,n[r])})),So=Eu((function(t,n){Ou(n,zo(n),t)})),Bo=Eu((function(t,n,r,e){Ou(n,zo(n),t,e)})),jo=Eu((function(t,n,r,e){Ou(n,Eo(n),t,e)})),Ao=ui(fe);var ko=Qe((function(t,n){t=kt(t);var r=-1,e=n.length,i=e>2?n[2]:u;for(i&&wi(n[0],n[1],i)&&(e=1);++r1),n})),Ou(t,ai(t),r),e&&(r=le(r,7,ri));for(var u=n.length;u--;)hu(r,n[u]);return r}));var Uo=ui((function(t,n){return null==t?{}:function(t,n){return Ke(t,n,(function(n,r){return Co(t,r)}))}(t,n)}));function Wo(t,n){if(null==t)return{};var r=En(ai(t),(function(t){return[t]}));return n=li(n),Ke(t,r,(function(t,r){return n(t,r[0])}))}var Po=Qu(Eo),No=Qu(zo);function $o(t){return null==t?[]:Xn(t,Eo(t))}var qo=Lu((function(t,n,r){return n=n.toLowerCase(),t+(r?Go(n):n)}));function Go(t){return Xo(wo(t).toLowerCase())}function Zo(t){return(t=wo(t))&&t.replace(wt,ur).replace(Xt,"")}var Ko=Lu((function(t,n,r){return t+(r?"-":"")+n.toLowerCase()})),Ho=Lu((function(t,n,r){return t+(r?" ":"")+n.toLowerCase()})),Vo=Du("toLowerCase");var Jo=Lu((function(t,n,r){return t+(r?"_":"")+n.toLowerCase()}));var Yo=Lu((function(t,n,r){return t+(r?" ":"")+Xo(n)}));var Qo=Lu((function(t,n,r){return t+(r?" ":"")+n.toUpperCase()})),Xo=Du("toUpperCase");function tf(t,n,r){return t=wo(t),(n=r?u:n)===u?function(t){return en.test(t)}(t)?function(t){return t.match(nn)||[]}(t):function(t){return t.match(st)||[]}(t):t.match(n)||[]}var nf=Qe((function(t,n){try{return An(t,u,n)}catch(t){return Qa(t)?t:new Bt(t)}})),rf=ui((function(t,n){return In(n,(function(n){n=Ui(n),oe(t,n,Fa(t[n],t))})),t}));function ef(t){return function(){return t}}var uf=Pu(),af=Pu(!0);function of(t){return t}function ff(t){return De("function"==typeof t?t:le(t,1))}var cf=Qe((function(t,n){return function(r){return Oe(r,t,n)}})),lf=Qe((function(t,n){return function(r){return Oe(t,r,n)}}));function sf(t,n,r){var e=Eo(n),u=Be(n,e);null!=r||ro(n)&&(u.length||!e.length)||(r=n,n=t,t=this,u=Be(n,Eo(n)));var i=!(ro(r)&&"chain"in r&&!r.chain),a=Xa(t);return In(u,(function(r){var e=n[r];t[r]=e,a&&(t.prototype[r]=function(){var n=this.__chain__;if(i||n){var r=t(this.__wrapped__),u=r.__actions__=Fu(this.__actions__);return u.push({func:e,args:arguments,thisArg:t}),r.__chain__=n,r}return e.apply(t,zn([this.value()],arguments))})})),t}function _f(){}var hf=Gu(En),pf=Gu(Cn),gf=Gu(Ln);function vf(t){return xi(t)?Zn(Ui(t)):function(t){return function(n){return je(n,t)}}(t)}var df=Ku(),yf=Ku(!0);function bf(){return[]}function mf(){return!1}var wf=qu((function(t,n){return t+n}),0),xf=Ju("ceil"),Sf=qu((function(t,n){return t/n}),1),Bf=Ju("floor");var jf,Af=qu((function(t,n){return t*n}),1),kf=Ju("round"),If=qu((function(t,n){return t-n}),0);return Nr.after=function(t,n){if("function"!=typeof n)throw new Ct(i);return t=vo(t),function(){if(--t<1)return n.apply(this,arguments)}},Nr.ary=Ma,Nr.assign=xo,Nr.assignIn=So,Nr.assignInWith=Bo,Nr.assignWith=jo,Nr.at=Ao,Nr.before=Ca,Nr.bind=Fa,Nr.bindAll=rf,Nr.bindKey=Oa,Nr.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Za(t)?t:[t]},Nr.chain=pa,Nr.chunk=function(t,n,r){n=(r?wi(t,n,r):n===u)?1:mr(vo(n),0);var i=null==t?0:t.length;if(!i||n<1)return[];for(var a=0,o=0,f=e(vn(i/n));ai?0:i+r),(e=e===u||e>i?i:vo(e))<0&&(e+=i),e=r>e?0:yo(e);r>>0)?(t=wo(t))&&("string"==typeof n||null!=n&&!oo(n))&&!(n=su(n))&&or(t)?Su(pr(t),0,r):t.split(n,r):[]},Nr.spread=function(t,n){if("function"!=typeof t)throw new Ct(i);return n=null==n?0:mr(vo(n),0),Qe((function(r){var e=r[n],u=Su(r,0,n);return e&&zn(u,e),An(t,this,u)}))},Nr.tail=function(t){var n=null==t?0:t.length;return n?iu(t,1,n):[]},Nr.take=function(t,n,r){return t&&t.length?iu(t,0,(n=r||n===u?1:vo(n))<0?0:n):[]},Nr.takeRight=function(t,n,r){var e=null==t?0:t.length;return e?iu(t,(n=e-(n=r||n===u?1:vo(n)))<0?0:n,e):[]},Nr.takeRightWhile=function(t,n){return t&&t.length?gu(t,li(n,3),!1,!0):[]},Nr.takeWhile=function(t,n){return t&&t.length?gu(t,li(n,3)):[]},Nr.tap=function(t,n){return n(t),t},Nr.throttle=function(t,n,r){var e=!0,u=!0;if("function"!=typeof t)throw new Ct(i);return ro(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),Ra(t,n,{leading:e,maxWait:n,trailing:u})},Nr.thru=ga,Nr.toArray=po,Nr.toPairs=Po,Nr.toPairsIn=No,Nr.toPath=function(t){return Za(t)?En(t,Ui):lo(t)?[t]:Fu(Li(wo(t)))},Nr.toPlainObject=mo,Nr.transform=function(t,n,r){var e=Za(t),u=e||Ja(t)||so(t);if(n=li(n,4),null==r){var i=t&&t.constructor;r=u?e?new i:[]:ro(t)&&Xa(i)?$r(Kt(t)):{}}return(u?In:xe)(t,(function(t,e,u){return n(r,t,e,u)})),r},Nr.unary=function(t){return Ma(t,1)},Nr.union=ea,Nr.unionBy=ua,Nr.unionWith=ia,Nr.uniq=function(t){return t&&t.length?_u(t):[]},Nr.uniqBy=function(t,n){return t&&t.length?_u(t,li(n,2)):[]},Nr.uniqWith=function(t,n){return n="function"==typeof n?n:u,t&&t.length?_u(t,u,n):[]},Nr.unset=function(t,n){return null==t||hu(t,n)},Nr.unzip=aa,Nr.unzipWith=oa,Nr.update=function(t,n,r){return null==t?t:pu(t,n,mu(r))},Nr.updateWith=function(t,n,r,e){return e="function"==typeof e?e:u,null==t?t:pu(t,n,mu(r),e)},Nr.values=$o,Nr.valuesIn=function(t){return null==t?[]:Xn(t,zo(t))},Nr.without=fa,Nr.words=tf,Nr.wrap=function(t,n){return Ua(mu(n),t)},Nr.xor=ca,Nr.xorBy=la,Nr.xorWith=sa,Nr.zip=_a,Nr.zipObject=function(t,n){return yu(t||[],n||[],ee)},Nr.zipObjectDeep=function(t,n){return yu(t||[],n||[],nu)},Nr.zipWith=ha,Nr.entries=Po,Nr.entriesIn=No,Nr.extend=So,Nr.extendWith=Bo,sf(Nr,Nr),Nr.add=wf,Nr.attempt=nf,Nr.camelCase=qo,Nr.capitalize=Go,Nr.ceil=xf,Nr.clamp=function(t,n,r){return r===u&&(r=n,n=u),r!==u&&(r=(r=bo(r))==r?r:0),n!==u&&(n=(n=bo(n))==n?n:0),ce(bo(t),n,r)},Nr.clone=function(t){return le(t,4)},Nr.cloneDeep=function(t){return le(t,5)},Nr.cloneDeepWith=function(t,n){return le(t,5,n="function"==typeof n?n:u)},Nr.cloneWith=function(t,n){return le(t,4,n="function"==typeof n?n:u)},Nr.conformsTo=function(t,n){return null==n||se(t,n,Eo(n))},Nr.deburr=Zo,Nr.defaultTo=function(t,n){return null==t||t!=t?n:t},Nr.divide=Sf,Nr.endsWith=function(t,n,r){t=wo(t),n=su(n);var e=t.length,i=r=r===u?e:ce(vo(r),0,e);return(r-=n.length)>=0&&t.slice(r,i)==n},Nr.eq=Na,Nr.escape=function(t){return(t=wo(t))&&Y.test(t)?t.replace(V,ir):t},Nr.escapeRegExp=function(t){return(t=wo(t))&&it.test(t)?t.replace(ut,"\\$&"):t},Nr.every=function(t,n,r){var e=Za(t)?Cn:ve;return r&&wi(t,n,r)&&(n=u),e(t,li(n,3))},Nr.find=ya,Nr.findIndex=Gi,Nr.findKey=function(t,n){return Wn(t,li(n,3),xe)},Nr.findLast=ba,Nr.findLastIndex=Zi,Nr.findLastKey=function(t,n){return Wn(t,li(n,3),Se)},Nr.floor=Bf,Nr.forEach=ma,Nr.forEachRight=wa,Nr.forIn=function(t,n){return null==t?t:me(t,li(n,3),zo)},Nr.forInRight=function(t,n){return null==t?t:we(t,li(n,3),zo)},Nr.forOwn=function(t,n){return t&&xe(t,li(n,3))},Nr.forOwnRight=function(t,n){return t&&Se(t,li(n,3))},Nr.get=Mo,Nr.gt=$a,Nr.gte=qa,Nr.has=function(t,n){return null!=t&&di(t,n,Me)},Nr.hasIn=Co,Nr.head=Hi,Nr.identity=of,Nr.includes=function(t,n,r,e){t=Ha(t)?t:$o(t),r=r&&!e?vo(r):0;var u=t.length;return r<0&&(r=mr(u+r,0)),co(t)?r<=u&&t.indexOf(n,r)>-1:!!u&&Nn(t,n,r)>-1},Nr.indexOf=function(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var u=null==r?0:vo(r);return u<0&&(u=mr(e+u,0)),Nn(t,n,u)},Nr.inRange=function(t,n,r){return n=go(n),r===u?(r=n,n=0):r=go(r),function(t,n,r){return t>=wr(n,r)&&t=-9007199254740991&&t<=p},Nr.isSet=fo,Nr.isString=co,Nr.isSymbol=lo,Nr.isTypedArray=so,Nr.isUndefined=function(t){return t===u},Nr.isWeakMap=function(t){return eo(t)&&vi(t)==R},Nr.isWeakSet=function(t){return eo(t)&&"[object WeakSet]"==ke(t)},Nr.join=function(t,n){return null==t?"":yr.call(t,n)},Nr.kebabCase=Ko,Nr.last=Qi,Nr.lastIndexOf=function(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var i=e;return r!==u&&(i=(i=vo(r))<0?mr(e+i,0):wr(i,e-1)),n==n?function(t,n,r){for(var e=r+1;e--;)if(t[e]===n)return e;return e}(t,n,i):Pn(t,qn,i,!0)},Nr.lowerCase=Ho,Nr.lowerFirst=Vo,Nr.lt=_o,Nr.lte=ho,Nr.max=function(t){return t&&t.length?de(t,of,Ie):u},Nr.maxBy=function(t,n){return t&&t.length?de(t,li(n,2),Ie):u},Nr.mean=function(t){return Gn(t,of)},Nr.meanBy=function(t,n){return Gn(t,li(n,2))},Nr.min=function(t){return t&&t.length?de(t,of,We):u},Nr.minBy=function(t,n){return t&&t.length?de(t,li(n,2),We):u},Nr.stubArray=bf,Nr.stubFalse=mf,Nr.stubObject=function(){return{}},Nr.stubString=function(){return""},Nr.stubTrue=function(){return!0},Nr.multiply=Af,Nr.nth=function(t,n){return t&&t.length?Ge(t,vo(n)):u},Nr.noConflict=function(){return pn._===this&&(pn._=Pt),this},Nr.noop=_f,Nr.now=Ia,Nr.pad=function(t,n,r){t=wo(t);var e=(n=vo(n))?hr(t):0;if(!n||e>=n)return t;var u=(n-e)/2;return Zu(yn(u),r)+t+Zu(vn(u),r)},Nr.padEnd=function(t,n,r){t=wo(t);var e=(n=vo(n))?hr(t):0;return n&&en){var e=t;t=n,n=e}if(r||t%1||n%1){var i=Br();return wr(t+i*(n-t+ln("1e-"+((i+"").length-1))),n)}return Je(t,n)},Nr.reduce=function(t,n,r){var e=Za(t)?Tn:Hn,u=arguments.length<3;return e(t,li(n,4),r,u,pe)},Nr.reduceRight=function(t,n,r){var e=Za(t)?Dn:Hn,u=arguments.length<3;return e(t,li(n,4),r,u,ge)},Nr.repeat=function(t,n,r){return n=(r?wi(t,n,r):n===u)?1:vo(n),Ye(wo(t),n)},Nr.replace=function(){var t=arguments,n=wo(t[0]);return t.length<3?n:n.replace(t[1],t[2])},Nr.result=function(t,n,r){var e=-1,i=(n=wu(n,t)).length;for(i||(i=1,t=u);++ep)return[];var r=v,e=wr(t,v);n=li(n),t-=v;for(var u=Jn(e,n);++r=a)return t;var f=r-hr(e);if(f<1)return e;var c=o?Su(o,0,f).join(""):t.slice(0,f);if(i===u)return c+e;if(o&&(f+=c.length-f),oo(i)){if(t.slice(f).search(i)){var l,s=c;for(i.global||(i=It(i.source,wo(gt.exec(i))+"g")),i.lastIndex=0;l=i.exec(s);)var _=l.index;c=c.slice(0,_===u?f:_)}}else if(t.indexOf(su(i),f)!=f){var h=c.lastIndexOf(i);h>-1&&(c=c.slice(0,h))}return c+e},Nr.unescape=function(t){return(t=wo(t))&&J.test(t)?t.replace(H,vr):t},Nr.uniqueId=function(t){var n=++Dt;return wo(t)+n},Nr.upperCase=Qo,Nr.upperFirst=Xo,Nr.each=ma,Nr.eachRight=wa,Nr.first=Hi,sf(Nr,(jf={},xe(Nr,(function(t,n){Tt.call(Nr.prototype,n)||(jf[n]=t)})),jf),{chain:!1}),Nr.VERSION="4.17.21",In(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){Nr[t].placeholder=Nr})),In(["drop","take"],(function(t,n){Zr.prototype[t]=function(r){r=r===u?1:mr(vo(r),0);var e=this.__filtered__&&!n?new Zr(this):this.clone();return e.__filtered__?e.__takeCount__=wr(r,e.__takeCount__):e.__views__.push({size:wr(r,v),type:t+(e.__dir__<0?"Right":"")}),e},Zr.prototype[t+"Right"]=function(n){return this.reverse()[t](n).reverse()}})),In(["filter","map","takeWhile"],(function(t,n){var r=n+1,e=1==r||3==r;Zr.prototype[t]=function(t){var n=this.clone();return n.__iteratees__.push({iteratee:li(t,3),type:r}),n.__filtered__=n.__filtered__||e,n}})),In(["head","last"],(function(t,n){var r="take"+(n?"Right":"");Zr.prototype[t]=function(){return this[r](1).value()[0]}})),In(["initial","tail"],(function(t,n){var r="drop"+(n?"":"Right");Zr.prototype[t]=function(){return this.__filtered__?new Zr(this):this[r](1)}})),Zr.prototype.compact=function(){return this.filter(of)},Zr.prototype.find=function(t){return this.filter(t).head()},Zr.prototype.findLast=function(t){return this.reverse().find(t)},Zr.prototype.invokeMap=Qe((function(t,n){return"function"==typeof t?new Zr(this):this.map((function(r){return Oe(r,t,n)}))})),Zr.prototype.reject=function(t){return this.filter(Da(li(t)))},Zr.prototype.slice=function(t,n){t=vo(t);var r=this;return r.__filtered__&&(t>0||n<0)?new Zr(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),n!==u&&(r=(n=vo(n))<0?r.dropRight(-n):r.take(n-t)),r)},Zr.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Zr.prototype.toArray=function(){return this.take(v)},xe(Zr.prototype,(function(t,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),e=/^(?:head|last)$/.test(n),i=Nr[e?"take"+("last"==n?"Right":""):n],a=e||/^find/.test(n);i&&(Nr.prototype[n]=function(){var n=this.__wrapped__,o=e?[1]:arguments,f=n instanceof Zr,c=o[0],l=f||Za(n),s=function(t){var n=i.apply(Nr,zn([t],o));return e&&_?n[0]:n};l&&r&&"function"==typeof c&&1!=c.length&&(f=l=!1);var _=this.__chain__,h=!!this.__actions__.length,p=a&&!_,g=f&&!h;if(!a&&l){n=g?n:new Zr(this);var v=t.apply(n,o);return v.__actions__.push({func:ga,args:[s],thisArg:u}),new Gr(v,_)}return p&&g?t.apply(this,o):(v=this.thru(s),p?e?v.value()[0]:v.value():v)})})),In(["pop","push","shift","sort","splice","unshift"],(function(t){var n=Ft[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",e=/^(?:pop|shift)$/.test(t);Nr.prototype[t]=function(){var t=arguments;if(e&&!this.__chain__){var u=this.value();return n.apply(Za(u)?u:[],t)}return this[r]((function(r){return n.apply(Za(r)?r:[],t)}))}})),xe(Zr.prototype,(function(t,n){var r=Nr[n];if(r){var e=r.name+"";Tt.call(Rr,e)||(Rr[e]=[]),Rr[e].push({name:n,func:r})}})),Rr[Nu(u,2).name]=[{name:"wrapper",func:u}],Zr.prototype.clone=function(){var t=new Zr(this.__wrapped__);return t.__actions__=Fu(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Fu(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Fu(this.__views__),t},Zr.prototype.reverse=function(){if(this.__filtered__){var t=new Zr(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Zr.prototype.value=function(){var t=this.__wrapped__.value(),n=this.__dir__,r=Za(t),e=n<0,u=r?t.length:0,i=function(t,n,r){var e=-1,u=r.length;for(;++e=this.__values__.length;return{done:t,value:t?u:this.__values__[this.__index__++]}},Nr.prototype.plant=function(t){for(var n,r=this;r instanceof qr;){var e=Pi(r);e.__index__=0,e.__values__=u,n?i.__wrapped__=e:n=e;var i=e;r=r.__wrapped__}return i.__wrapped__=t,n},Nr.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Zr){var n=t;return this.__actions__.length&&(n=new Zr(this)),(n=n.reverse()).__actions__.push({func:ga,args:[ra],thisArg:u}),new Gr(n,this.__chain__)}return this.thru(ra)},Nr.prototype.toJSON=Nr.prototype.valueOf=Nr.prototype.value=function(){return vu(this.__wrapped__,this.__actions__)},Nr.prototype.first=Nr.prototype.head,tn&&(Nr.prototype[tn]=function(){return this}),Nr}();pn._=dr,(e=function(){return dr}.call(n,r,n,t))===u||(t.exports=e)}.call(this)}},n={};function r(e){var u=n[e];if(void 0!==u)return u.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var e=r(6014);freeaps_profile=e})(); +var freeaps_profile;(()=>{var t={6261:(t,n)=>{t.exports=function(t){var n=new Date;return n.setHours("00"),n.setMinutes("00"),n.setSeconds("00"),n.getTime()+60*t*1e3}},1836:(t,n,r)=>{var e=r(6486);n.maxDailyBasal=function(t){var n=e.maxBy(t.basals,(function(t){return Number(t.rate)}));return 1e3*Number(n.rate)/1e3},n.maxBasalLookup=function(t){return t.settings.maxBasal},n.basalLookup=function(t,n){var r=n;void 0===n&&(r=new Date);var u=e.sortBy(t,(function(t){return t.i})),i=u[u.length-1].rate;if(0!==i){for(var a=60*r.getHours()+r.getMinutes(),o=0;o=u[o].minutes&&a{var e=r(6261);function u(t,n){var r=new Date,u=t.carbratio;if(void 0===u||void 0===u.schedule);else{var i;if("grams"===u.units||"exchanges"===u.units){i=u.schedule[u.schedule.length-1];for(var a=0;a=e(u.schedule[a].offset)&&r150)return void console.error("Error: carbRatio of "+i+" out of bounds.");break}return"exchanges"===u.units&&(i.ratio=12/i.ratio),i.ratio}console.error("Error: Unsupported carb_ratio units "+u.units)}}u.carbRatioLookup=u,t.exports=u},6014:(t,n,r)=>{var e=r(1836),u=r(4034),i=r(3725),a=r(5364),o=r(6486);function f(){return{max_iob:9,max_daily_safety_multiplier:5,current_basal_safety_multiplier:6,autosens_max:2.5,autosens_min:.5,rewind_resets_autosens:!0,high_temptarget_raises_sensitivity:!1,low_temptarget_lowers_sensitivity:!1,sensitivity_raises_target:!1,resistance_lowers_target:!1,exercise_mode:!1,half_basal_exercise_target:150,maxCOB:120,skip_neutral_temps:!1,unsuspend_if_no_temp:!1,min_5m_carbimpact:8,autotune_isf_adjustmentFraction:1,remainingCarbsFraction:1,remainingCarbsCap:90,enableUAM:!0,A52_risk_enable:!1,enableSMB_with_COB:!0,enableSMB_with_temptarget:!0,enableSMB_always:!0,enableSMB_after_carbs:!0,allowSMB_with_high_temptarget:!0,maxSMBBasalMinutes:90,maxUAMSMBBasalMinutes:90,SMBInterval:3,bolus_increment:.05,maxDelta_bg_threshold:.2,curve:"rapid-acting",useCustomPeakTime:!1,insulinPeakTime:45,carbsReqThreshold:1,offline_hotspot:!1,noisyCGMTargetMultiplier:1.3,suspend_zeros_iob:!0,enableEnliteBgproxy:!1,calc_glucose_noise:!1,target_bg:!1,smb_delivery_ratio:.5,adjustmentFactor:1,useNewFormula:!1,enableDynamicCR:!1,sigmoid:!1,weightPercentage:.65,tddAdjBasal:!1,enableSMB_high_bg:!1,enableSMB_high_bg_target:110}}function c(t,n){var r=n&&n.type?n:{max_iob:9,max_daily_safety_multiplier:5,current_basal_safety_multiplier:6,autosens_max:2.5,autosens_min:.5,rewind_resets_autosens:!0,high_temptarget_raises_sensitivity:!1,low_temptarget_lowers_sensitivity:!1,sensitivity_raises_target:!1,resistance_lowers_target:!1,exercise_mode:!1,half_basal_exercise_target:150,maxCOB:120,skip_neutral_temps:!1,unsuspend_if_no_temp:!1,min_5m_carbimpact:8,autotune_isf_adjustmentFraction:1,remainingCarbsFraction:1,remainingCarbsCap:90,enableUAM:!0,A52_risk_enable:!1,enableSMB_with_COB:!0,enableSMB_with_temptarget:!0,enableSMB_always:!0,enableSMB_after_carbs:!0,allowSMB_with_high_temptarget:!0,maxSMBBasalMinutes:90,maxUAMSMBBasalMinutes:90,SMBInterval:3,bolus_increment:.05,maxDelta_bg_threshold:.2,curve:"rapid-acting",useCustomPeakTime:!1,insulinPeakTime:45,carbsReqThreshold:1,offline_hotspot:!1,noisyCGMTargetMultiplier:1.3,suspend_zeros_iob:!0,enableEnliteBgproxy:!1,calc_glucose_noise:!1,target_bg:!1,smb_delivery_ratio:.5,adjustmentFactor:1,useNewFormula:!1,enableDynamicCR:!1,sigmoid:!1,weightPercentage:.65,tddAdjBasal:!1,enableSMB_high_bg:!1,enableSMB_high_bg_target:110,threshold_setting:65};for(var f in r)t.hasOwnProperty(f)&&(r[f]=t[f]);var c=t.settings;if(!(t.settings.insulin_action_curve>1))return console.error("DIA of",r.dia,"is not supported"),-1;if(r.dia=c.insulin_action_curve,t.model&&(r.model=t.model),r.skip_neutral_temps=t.skip_neutral_temps,r.current_basal=e.basalLookup(t.basals),r.basalprofile=t.basals,o.forEach(r.basalprofile,(function(t){t.rate=+(Math.round(t.rate+"e+3")+"e-3")})),r.max_daily_basal=e.maxDailyBasal(t),r.max_basal=e.maxBasalLookup(t),0===r.current_basal)return console.error("current_basal of",r.current_basal,"is not supported"),-1;if(0===r.max_daily_basal)return console.error("max_daily_basal of",r.max_daily_basal,"is not supported"),-1;if(r.max_basal<.1)return console.error("max_basal of",r.max_basal,"is not supported"),-1;var l=u.bgTargetsLookup(t,r);return r.out_units=t.targets.user_preferred_units,r.min_bg=Math.round(l.min_bg),r.max_bg=Math.round(l.max_bg),r.bg_targets=t.targets,o.forEach(r.bg_targets.targets,(function(t){t.high=Math.round(t.high),t.low=Math.round(t.low),t.min_bg=Math.round(t.min_bg),t.max_bg=Math.round(t.max_bg)})),delete r.bg_targets.raw,r.temptargetSet=l.temptargetSet,r.sens=i.isfLookup(t.isf),r.isfProfile=t.isf,r.sens<5?(console.error("ISF of",r.sens,"is not supported"),-1):(void 0!==t.carbratio?(r.carb_ratio=a.carbRatioLookup(t,r),r.carb_ratios=t.carbratio):console.error("Profile wasn't given carb ratio data, cannot calculate carb_ratio"),r)}c.defaults=f,c.displayedDefaults=function(){var t={max_iob:9,max_daily_safety_multiplier:5,current_basal_safety_multiplier:6,autosens_max:2.5,autosens_min:.5,rewind_resets_autosens:!0,high_temptarget_raises_sensitivity:!1,low_temptarget_lowers_sensitivity:!1,sensitivity_raises_target:!1,resistance_lowers_target:!1,exercise_mode:!1,half_basal_exercise_target:150,maxCOB:120,skip_neutral_temps:!1,unsuspend_if_no_temp:!1,min_5m_carbimpact:8,autotune_isf_adjustmentFraction:1,remainingCarbsFraction:1,remainingCarbsCap:90,enableUAM:!0,A52_risk_enable:!1,enableSMB_with_COB:!0,enableSMB_with_temptarget:!0,enableSMB_always:!0,enableSMB_after_carbs:!0,allowSMB_with_high_temptarget:!0,maxSMBBasalMinutes:90,maxUAMSMBBasalMinutes:90,SMBInterval:3,bolus_increment:.05,maxDelta_bg_threshold:.2,curve:"rapid-acting",useCustomPeakTime:!1,insulinPeakTime:45,carbsReqThreshold:1,offline_hotspot:!1,noisyCGMTargetMultiplier:1.3,suspend_zeros_iob:!0,enableEnliteBgproxy:!1,calc_glucose_noise:!1,target_bg:!1,smb_delivery_ratio:.5,adjustmentFactor:1,useNewFormula:!1,enableDynamicCR:!1,sigmoid:!1,weightPercentage:.65,tddAdjBasal:!1,enableSMB_high_bg:!1,enableSMB_high_bg_target:110,threshold_setting:65},n={};return n.max_iob=t.max_iob,n.max_daily_safety_multiplier=t.max_daily_safety_multiplier,n.current_basal_safety_multiplier=t.current_basal_safety_multiplier,n.autosens_max=t.autosens_max,n.autosens_min=t.autosens_min,n.rewind_resets_autosens=t.rewind_resets_autosens,n.exercise_mode=t.exercise_mode,n.sensitivity_raises_target=t.sensitivity_raises_target,n.unsuspend_if_no_temp=t.unsuspend_if_no_temp,n.enableSMB_with_COB=t.enableSMB_with_COB,n.enableSMB_with_temptarget=t.enableSMB_with_temptarget,n.enableUAM=t.enableUAM,n.curve=t.curve,n.offline_hotspot=t.offline_hotspot,n.bolus_increment=t.bolus_increment,n.smb_delivery_ratio=t.smb_delivery_ratio,n.maxDelta_bg_threshold=t.maxDelta_bg_threshold,n.adjustmentFactor=t.adjustmentFactor,n.useNewFormula=t.useNewFormula,n.enableDynamicCR=t.enableDynamicCR,n.sigmoid=t.sigmoid,n.weightPercentage=t.weightPercentage,n.tddAdjBasal=t.tddAdjBasal,console.error(n),n},t.exports=c},3725:(t,n,r)=>{var e=r(6486),u=null;function i(t,n){var r=n;void 0===n&&(r=new Date);var i=60*r.getHours()+r.getMinutes();if(u&&i>=u.offset&&i=c.offset&&i{var e=r(6261);function u(t,n){return a(i(t,n))}function i(t,n){for(var r=t.targets,u=t.temptargets,i=new Date,a=r.targets[r.targets.length-1],o=0;o=e(r.targets[o].offset)&&i=c&&0===u[o].duration){f=a;break}if(!u[o].targetBottom||!u[o].targetTop){console.error("eventualBG target range invalid: "+u[o].targetBottom+"-"+u[o].targetTop);break}if(i>=c&&i"']/g,J=RegExp(H.source),Y=RegExp(V.source),Q=/<%-([\s\S]+?)%>/g,X=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,nt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,rt=/^\w*$/,et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ut=/[\\^$.*+?()[\]{}|]/g,it=RegExp(ut.source),at=/^\s+/,ot=/\s/,ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ct=/\{\n\/\* \[wrapped with (.+)\] \*/,lt=/,? & /,st=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,_t=/[()=,{}\[\]\/\s]/,ht=/\\(\\)?/g,pt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,gt=/\w*$/,vt=/^[-+]0x[0-9a-f]+$/i,dt=/^0b[01]+$/i,yt=/^\[object .+?Constructor\]$/,bt=/^0o[0-7]+$/i,mt=/^(?:0|[1-9]\d*)$/,wt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,xt=/($^)/,St=/['\n\r\u2028\u2029\\]/g,Bt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",jt="\\u2700-\\u27bf",At="a-z\\xdf-\\xf6\\xf8-\\xff",kt="A-Z\\xc0-\\xd6\\xd8-\\xde",It="\\ufe0e\\ufe0f",Mt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ct="['’]",Ft="[\\ud800-\\udfff]",Ot="["+Mt+"]",Rt="["+Bt+"]",Et="\\d+",zt="[\\u2700-\\u27bf]",Tt="["+At+"]",Dt="[^\\ud800-\\udfff"+Mt+Et+jt+At+kt+"]",Lt="\\ud83c[\\udffb-\\udfff]",Ut="[^\\ud800-\\udfff]",Wt="(?:\\ud83c[\\udde6-\\uddff]){2}",Pt="[\\ud800-\\udbff][\\udc00-\\udfff]",Nt="["+kt+"]",$t="(?:"+Tt+"|"+Dt+")",qt="(?:"+Nt+"|"+Dt+")",Gt="(?:['’](?:d|ll|m|re|s|t|ve))?",Zt="(?:['’](?:D|LL|M|RE|S|T|VE))?",Kt="(?:"+Rt+"|"+Lt+")"+"?",Ht="[\\ufe0e\\ufe0f]?",Vt=Ht+Kt+("(?:\\u200d(?:"+[Ut,Wt,Pt].join("|")+")"+Ht+Kt+")*"),Jt="(?:"+[zt,Wt,Pt].join("|")+")"+Vt,Yt="(?:"+[Ut+Rt+"?",Rt,Wt,Pt,Ft].join("|")+")",Qt=RegExp(Ct,"g"),Xt=RegExp(Rt,"g"),tn=RegExp(Lt+"(?="+Lt+")|"+Yt+Vt,"g"),nn=RegExp([Nt+"?"+Tt+"+"+Gt+"(?="+[Ot,Nt,"$"].join("|")+")",qt+"+"+Zt+"(?="+[Ot,Nt+$t,"$"].join("|")+")",Nt+"?"+$t+"+"+Gt,Nt+"+"+Zt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Et,Jt].join("|"),"g"),rn=RegExp("[\\u200d\\ud800-\\udfff"+Bt+It+"]"),en=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,un=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],an=-1,on={};on[T]=on[D]=on[L]=on[U]=on[W]=on[P]=on[N]=on[$]=on[q]=!0,on[y]=on[b]=on[E]=on[m]=on[z]=on[w]=on[x]=on[S]=on[j]=on[A]=on[k]=on[M]=on[C]=on[F]=on[R]=!1;var fn={};fn[y]=fn[b]=fn[E]=fn[z]=fn[m]=fn[w]=fn[T]=fn[D]=fn[L]=fn[U]=fn[W]=fn[j]=fn[A]=fn[k]=fn[M]=fn[C]=fn[F]=fn[O]=fn[P]=fn[N]=fn[$]=fn[q]=!0,fn[x]=fn[S]=fn[R]=!1;var cn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ln=parseFloat,sn=parseInt,_n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,hn="object"==typeof self&&self&&self.Object===Object&&self,pn=_n||hn||Function("return this")(),gn=n&&!n.nodeType&&n,vn=gn&&t&&!t.nodeType&&t,dn=vn&&vn.exports===gn,yn=dn&&_n.process,bn=function(){try{var t=vn&&vn.require&&vn.require("util").types;return t||yn&&yn.binding&&yn.binding("util")}catch(t){}}(),mn=bn&&bn.isArrayBuffer,wn=bn&&bn.isDate,xn=bn&&bn.isMap,Sn=bn&&bn.isRegExp,Bn=bn&&bn.isSet,jn=bn&&bn.isTypedArray;function An(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}function kn(t,n,r,e){for(var u=-1,i=null==t?0:t.length;++u-1}function Rn(t,n,r){for(var e=-1,u=null==t?0:t.length;++e-1;);return r}function rr(t,n){for(var r=t.length;r--&&Nn(n,t[r],0)>-1;);return r}function er(t,n){for(var r=t.length,e=0;r--;)t[r]===n&&++e;return e}var ur=Kn({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),ir=Kn({"&":"&","<":"<",">":">",'"':""","'":"'"});function ar(t){return"\\"+cn[t]}function or(t){return rn.test(t)}function fr(t){var n=-1,r=Array(t.size);return t.forEach((function(t,e){r[++n]=[e,t]})),r}function cr(t,n){return function(r){return t(n(r))}}function lr(t,n){for(var r=-1,e=t.length,u=0,i=[];++r",""":'"',"'":"'"});var dr=function t(n){var r,e=(n=null==n?pn:dr.defaults(pn.Object(),n,dr.pick(pn,un))).Array,ot=n.Date,Bt=n.Error,jt=n.Function,At=n.Math,kt=n.Object,It=n.RegExp,Mt=n.String,Ct=n.TypeError,Ft=e.prototype,Ot=jt.prototype,Rt=kt.prototype,Et=n["__core-js_shared__"],zt=Ot.toString,Tt=Rt.hasOwnProperty,Dt=0,Lt=(r=/[^.]+$/.exec(Et&&Et.keys&&Et.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",Ut=Rt.toString,Wt=zt.call(kt),Pt=pn._,Nt=It("^"+zt.call(Tt).replace(ut,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$t=dn?n.Buffer:u,qt=n.Symbol,Gt=n.Uint8Array,Zt=$t?$t.allocUnsafe:u,Kt=cr(kt.getPrototypeOf,kt),Ht=kt.create,Vt=Rt.propertyIsEnumerable,Jt=Ft.splice,Yt=qt?qt.isConcatSpreadable:u,tn=qt?qt.iterator:u,rn=qt?qt.toStringTag:u,cn=function(){try{var t=hi(kt,"defineProperty");return t({},"",{}),t}catch(t){}}(),_n=n.clearTimeout!==pn.clearTimeout&&n.clearTimeout,hn=ot&&ot.now!==pn.Date.now&&ot.now,gn=n.setTimeout!==pn.setTimeout&&n.setTimeout,vn=At.ceil,yn=At.floor,bn=kt.getOwnPropertySymbols,Un=$t?$t.isBuffer:u,Kn=n.isFinite,yr=Ft.join,br=cr(kt.keys,kt),mr=At.max,wr=At.min,xr=ot.now,Sr=n.parseInt,Br=At.random,jr=Ft.reverse,Ar=hi(n,"DataView"),kr=hi(n,"Map"),Ir=hi(n,"Promise"),Mr=hi(n,"Set"),Cr=hi(n,"WeakMap"),Fr=hi(kt,"create"),Or=Cr&&new Cr,Rr={},Er=Wi(Ar),zr=Wi(kr),Tr=Wi(Ir),Dr=Wi(Mr),Lr=Wi(Cr),Ur=qt?qt.prototype:u,Wr=Ur?Ur.valueOf:u,Pr=Ur?Ur.toString:u;function Nr(t){if(eo(t)&&!Za(t)&&!(t instanceof Zr)){if(t instanceof Gr)return t;if(Tt.call(t,"__wrapped__"))return Pi(t)}return new Gr(t)}var $r=function(){function t(){}return function(n){if(!ro(n))return{};if(Ht)return Ht(n);t.prototype=n;var r=new t;return t.prototype=u,r}}();function qr(){}function Gr(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=u}function Zr(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=v,this.__views__=[]}function Kr(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n=n?t:n)),t}function le(t,n,r,e,i,a){var o,f=1&n,c=2&n,l=4&n;if(r&&(o=i?r(t,e,i,a):r(t)),o!==u)return o;if(!ro(t))return t;var s=Za(t);if(s){if(o=function(t){var n=t.length,r=new t.constructor(n);n&&"string"==typeof t[0]&&Tt.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!f)return Fu(t,o)}else{var _=vi(t),h=_==S||_==B;if(Ja(t))return ju(t,f);if(_==k||_==y||h&&!i){if(o=c||h?{}:yi(t),!f)return c?function(t,n){return Ou(t,gi(t),n)}(t,function(t,n){return t&&Ou(n,zo(n),t)}(o,t)):function(t,n){return Ou(t,pi(t),n)}(t,ae(o,t))}else{if(!fn[_])return i?t:{};o=function(t,n,r){var e=t.constructor;switch(n){case E:return Au(t);case m:case w:return new e(+t);case z:return function(t,n){var r=n?Au(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case T:case D:case L:case U:case W:case P:case N:case $:case q:return ku(t,r);case j:return new e;case A:case F:return new e(t);case M:return function(t){var n=new t.constructor(t.source,gt.exec(t));return n.lastIndex=t.lastIndex,n}(t);case C:return new e;case O:return u=t,Wr?kt(Wr.call(u)):{}}var u}(t,_,f)}}a||(a=new Yr);var p=a.get(t);if(p)return p;a.set(t,o),fo(t)?t.forEach((function(e){o.add(le(e,n,r,e,t,a))})):uo(t)&&t.forEach((function(e,u){o.set(u,le(e,n,r,u,t,a))}));var g=s?u:(l?c?ai:ii:c?zo:Eo)(t);return In(g||t,(function(e,u){g&&(e=t[u=e]),ee(o,u,le(e,n,r,u,t,a))})),o}function se(t,n,r){var e=r.length;if(null==t)return!e;for(t=kt(t);e--;){var i=r[e],a=n[i],o=t[i];if(o===u&&!(i in t)||!a(o))return!1}return!0}function _e(t,n,r){if("function"!=typeof t)throw new Ct(i);return Ri((function(){t.apply(u,r)}),n)}function he(t,n,r,e){var u=-1,i=On,a=!0,o=t.length,f=[],c=n.length;if(!o)return f;r&&(n=En(n,Qn(r))),e?(i=Rn,a=!1):n.length>=200&&(i=tr,a=!1,n=new Jr(n));t:for(;++u-1},Hr.prototype.set=function(t,n){var r=this.__data__,e=ue(r,t);return e<0?(++this.size,r.push([t,n])):r[e][1]=n,this},Vr.prototype.clear=function(){this.size=0,this.__data__={hash:new Kr,map:new(kr||Hr),string:new Kr}},Vr.prototype.delete=function(t){var n=si(this,t).delete(t);return this.size-=n?1:0,n},Vr.prototype.get=function(t){return si(this,t).get(t)},Vr.prototype.has=function(t){return si(this,t).has(t)},Vr.prototype.set=function(t,n){var r=si(this,t),e=r.size;return r.set(t,n),this.size+=r.size==e?0:1,this},Jr.prototype.add=Jr.prototype.push=function(t){return this.__data__.set(t,a),this},Jr.prototype.has=function(t){return this.__data__.has(t)},Yr.prototype.clear=function(){this.__data__=new Hr,this.size=0},Yr.prototype.delete=function(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r},Yr.prototype.get=function(t){return this.__data__.get(t)},Yr.prototype.has=function(t){return this.__data__.has(t)},Yr.prototype.set=function(t,n){var r=this.__data__;if(r instanceof Hr){var e=r.__data__;if(!kr||e.length<199)return e.push([t,n]),this.size=++r.size,this;r=this.__data__=new Vr(e)}return r.set(t,n),this.size=r.size,this};var pe=zu(xe),ge=zu(Se,!0);function ve(t,n){var r=!0;return pe(t,(function(t,e,u){return r=!!n(t,e,u)})),r}function de(t,n,r){for(var e=-1,i=t.length;++e0&&r(o)?n>1?be(o,n-1,r,e,u):zn(u,o):e||(u[u.length]=o)}return u}var me=Tu(),we=Tu(!0);function xe(t,n){return t&&me(t,n,Eo)}function Se(t,n){return t&&we(t,n,Eo)}function Be(t,n){return Fn(n,(function(n){return Xa(t[n])}))}function je(t,n){for(var r=0,e=(n=wu(n,t)).length;null!=t&&rn}function Me(t,n){return null!=t&&Tt.call(t,n)}function Ce(t,n){return null!=t&&n in kt(t)}function Fe(t,n,r){for(var i=r?Rn:On,a=t[0].length,o=t.length,f=o,c=e(o),l=1/0,s=[];f--;){var _=t[f];f&&n&&(_=En(_,Qn(n))),l=wr(_.length,l),c[f]=!r&&(n||a>=120&&_.length>=120)?new Jr(f&&_):u}_=t[0];var h=-1,p=c[0];t:for(;++h=o?f:f*("desc"==r[e]?-1:1)}return t.index-n.index}(t,n,r)}))}function Ke(t,n,r){for(var e=-1,u=n.length,i={};++e-1;)o!==t&&Jt.call(o,f,1),Jt.call(t,f,1);return t}function Ve(t,n){for(var r=t?n.length:0,e=r-1;r--;){var u=n[r];if(r==e||u!==i){var i=u;mi(u)?Jt.call(t,u,1):hu(t,u)}}return t}function Je(t,n){return t+yn(Br()*(n-t+1))}function Ye(t,n){var r="";if(!t||n<1||n>p)return r;do{n%2&&(r+=t),(n=yn(n/2))&&(t+=t)}while(n);return r}function Qe(t,n){return Ei(Ii(t,n,of),t+"")}function Xe(t){return Xr($o(t))}function tu(t,n){var r=$o(t);return Di(r,ce(n,0,r.length))}function nu(t,n,r,e){if(!ro(t))return t;for(var i=-1,a=(n=wu(n,t)).length,o=a-1,f=t;null!=f&&++ii?0:i+n),(r=r>i?i:r)<0&&(r+=i),i=n>r?0:r-n>>>0,n>>>=0;for(var a=e(i);++u>>1,a=t[i];null!==a&&!lo(a)&&(r?a<=n:a=200){var c=n?null:Yu(t);if(c)return sr(c);a=!1,u=tr,f=new Jr}else f=n?[]:o;t:for(;++e=e?t:iu(t,n,r)}var Bu=_n||function(t){return pn.clearTimeout(t)};function ju(t,n){if(n)return t.slice();var r=t.length,e=Zt?Zt(r):new t.constructor(r);return t.copy(e),e}function Au(t){var n=new t.constructor(t.byteLength);return new Gt(n).set(new Gt(t)),n}function ku(t,n){var r=n?Au(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Iu(t,n){if(t!==n){var r=t!==u,e=null===t,i=t==t,a=lo(t),o=n!==u,f=null===n,c=n==n,l=lo(n);if(!f&&!l&&!a&&t>n||a&&o&&c&&!f&&!l||e&&o&&c||!r&&c||!i)return 1;if(!e&&!a&&!l&&t1?r[i-1]:u,o=i>2?r[2]:u;for(a=t.length>3&&"function"==typeof a?(i--,a):u,o&&wi(r[0],r[1],o)&&(a=i<3?u:a,i=1),n=kt(n);++e-1?i[a?n[o]:o]:u}}function Pu(t){return ui((function(n){var r=n.length,e=r,a=Gr.prototype.thru;for(t&&n.reverse();e--;){var o=n[e];if("function"!=typeof o)throw new Ct(i);if(a&&!f&&"wrapper"==fi(o))var f=new Gr([],!0)}for(e=f?e:r;++e1&&b.reverse(),h&&lf))return!1;var l=a.get(t),s=a.get(n);if(l&&s)return l==n&&s==t;var _=-1,h=!0,p=2&r?new Jr:u;for(a.set(t,n),a.set(n,t);++_-1&&t%1==0&&t1?"& ":"")+n[e],n=n.join(r>2?", ":" "),t.replace(ft,"{\n/* [wrapped with "+n+"] */\n")}(e,function(t,n){return In(d,(function(r){var e="_."+r[0];n&r[1]&&!On(t,e)&&t.push(e)})),t.sort()}(function(t){var n=t.match(ct);return n?n[1].split(lt):[]}(e),r)))}function Ti(t){var n=0,r=0;return function(){var e=xr(),i=16-(e-r);if(r=e,i>0){if(++n>=800)return arguments[0]}else n=0;return t.apply(u,arguments)}}function Di(t,n){var r=-1,e=t.length,i=e-1;for(n=n===u?e:n;++r1?t[n-1]:u;return r="function"==typeof r?(t.pop(),r):u,oa(t,r)}));function pa(t){var n=Nr(t);return n.__chain__=!0,n}function ga(t,n){return n(t)}var va=ui((function(t){var n=t.length,r=n?t[0]:0,e=this.__wrapped__,i=function(n){return fe(n,t)};return!(n>1||this.__actions__.length)&&e instanceof Zr&&mi(r)?((e=e.slice(r,+r+(n?1:0))).__actions__.push({func:ga,args:[i],thisArg:u}),new Gr(e,this.__chain__).thru((function(t){return n&&!t.length&&t.push(u),t}))):this.thru(i)}));var da=Ru((function(t,n,r){Tt.call(t,r)?++t[r]:oe(t,r,1)}));var ya=Wu(Gi),ba=Wu(Zi);function ma(t,n){return(Za(t)?In:pe)(t,li(n,3))}function wa(t,n){return(Za(t)?Mn:ge)(t,li(n,3))}var xa=Ru((function(t,n,r){Tt.call(t,r)?t[r].push(n):oe(t,r,[n])}));var Sa=Qe((function(t,n,r){var u=-1,i="function"==typeof n,a=Ha(t)?e(t.length):[];return pe(t,(function(t){a[++u]=i?An(n,t,r):Oe(t,n,r)})),a})),Ba=Ru((function(t,n,r){oe(t,r,n)}));function ja(t,n){return(Za(t)?En:Pe)(t,li(n,3))}var Aa=Ru((function(t,n,r){t[r?0:1].push(n)}),(function(){return[[],[]]}));var ka=Qe((function(t,n){if(null==t)return[];var r=n.length;return r>1&&wi(t,n[0],n[1])?n=[]:r>2&&wi(n[0],n[1],n[2])&&(n=[n[0]]),Ze(t,be(n,1),[])})),Ia=hn||function(){return pn.Date.now()};function Ma(t,n,r){return n=r?u:n,n=t&&null==n?t.length:n,Xu(t,s,u,u,u,u,n)}function Ca(t,n){var r;if("function"!=typeof n)throw new Ct(i);return t=vo(t),function(){return--t>0&&(r=n.apply(this,arguments)),t<=1&&(n=u),r}}var Fa=Qe((function(t,n,r){var e=1;if(r.length){var u=lr(r,ci(Fa));e|=c}return Xu(t,e,n,r,u)})),Oa=Qe((function(t,n,r){var e=3;if(r.length){var u=lr(r,ci(Oa));e|=c}return Xu(n,e,t,r,u)}));function Ra(t,n,r){var e,a,o,f,c,l,s=0,_=!1,h=!1,p=!0;if("function"!=typeof t)throw new Ct(i);function g(n){var r=e,i=a;return e=a=u,s=n,f=t.apply(i,r)}function v(t){return s=t,c=Ri(y,n),_?g(t):f}function d(t){var r=t-l;return l===u||r>=n||r<0||h&&t-s>=o}function y(){var t=Ia();if(d(t))return b(t);c=Ri(y,function(t){var r=n-(t-l);return h?wr(r,o-(t-s)):r}(t))}function b(t){return c=u,p&&e?g(t):(e=a=u,f)}function m(){var t=Ia(),r=d(t);if(e=arguments,a=this,l=t,r){if(c===u)return v(l);if(h)return Bu(c),c=Ri(y,n),g(l)}return c===u&&(c=Ri(y,n)),f}return n=bo(n)||0,ro(r)&&(_=!!r.leading,o=(h="maxWait"in r)?mr(bo(r.maxWait)||0,n):o,p="trailing"in r?!!r.trailing:p),m.cancel=function(){c!==u&&Bu(c),s=0,e=l=a=c=u},m.flush=function(){return c===u?f:b(Ia())},m}var Ea=Qe((function(t,n){return _e(t,1,n)})),za=Qe((function(t,n,r){return _e(t,bo(n)||0,r)}));function Ta(t,n){if("function"!=typeof t||null!=n&&"function"!=typeof n)throw new Ct(i);var r=function(){var e=arguments,u=n?n.apply(this,e):e[0],i=r.cache;if(i.has(u))return i.get(u);var a=t.apply(this,e);return r.cache=i.set(u,a)||i,a};return r.cache=new(Ta.Cache||Vr),r}function Da(t){if("function"!=typeof t)throw new Ct(i);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}Ta.Cache=Vr;var La=xu((function(t,n){var r=(n=1==n.length&&Za(n[0])?En(n[0],Qn(li())):En(be(n,1),Qn(li()))).length;return Qe((function(e){for(var u=-1,i=wr(e.length,r);++u=n})),Ga=Re(function(){return arguments}())?Re:function(t){return eo(t)&&Tt.call(t,"callee")&&!Vt.call(t,"callee")},Za=e.isArray,Ka=mn?Qn(mn):function(t){return eo(t)&&ke(t)==E};function Ha(t){return null!=t&&no(t.length)&&!Xa(t)}function Va(t){return eo(t)&&Ha(t)}var Ja=Un||mf,Ya=wn?Qn(wn):function(t){return eo(t)&&ke(t)==w};function Qa(t){if(!eo(t))return!1;var n=ke(t);return n==x||"[object DOMException]"==n||"string"==typeof t.message&&"string"==typeof t.name&&!ao(t)}function Xa(t){if(!ro(t))return!1;var n=ke(t);return n==S||n==B||"[object AsyncFunction]"==n||"[object Proxy]"==n}function to(t){return"number"==typeof t&&t==vo(t)}function no(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=p}function ro(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function eo(t){return null!=t&&"object"==typeof t}var uo=xn?Qn(xn):function(t){return eo(t)&&vi(t)==j};function io(t){return"number"==typeof t||eo(t)&&ke(t)==A}function ao(t){if(!eo(t)||ke(t)!=k)return!1;var n=Kt(t);if(null===n)return!0;var r=Tt.call(n,"constructor")&&n.constructor;return"function"==typeof r&&r instanceof r&&zt.call(r)==Wt}var oo=Sn?Qn(Sn):function(t){return eo(t)&&ke(t)==M};var fo=Bn?Qn(Bn):function(t){return eo(t)&&vi(t)==C};function co(t){return"string"==typeof t||!Za(t)&&eo(t)&&ke(t)==F}function lo(t){return"symbol"==typeof t||eo(t)&&ke(t)==O}var so=jn?Qn(jn):function(t){return eo(t)&&no(t.length)&&!!on[ke(t)]};var _o=Hu(We),ho=Hu((function(t,n){return t<=n}));function po(t){if(!t)return[];if(Ha(t))return co(t)?pr(t):Fu(t);if(tn&&t[tn])return function(t){for(var n,r=[];!(n=t.next()).done;)r.push(n.value);return r}(t[tn]());var n=vi(t);return(n==j?fr:n==C?sr:$o)(t)}function go(t){return t?(t=bo(t))===h||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function vo(t){var n=go(t),r=n%1;return n==n?r?n-r:n:0}function yo(t){return t?ce(vo(t),0,v):0}function bo(t){if("number"==typeof t)return t;if(lo(t))return g;if(ro(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=ro(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=Yn(t);var r=dt.test(t);return r||bt.test(t)?sn(t.slice(2),r?2:8):vt.test(t)?g:+t}function mo(t){return Ou(t,zo(t))}function wo(t){return null==t?"":su(t)}var xo=Eu((function(t,n){if(ji(n)||Ha(n))Ou(n,Eo(n),t);else for(var r in n)Tt.call(n,r)&&ee(t,r,n[r])})),So=Eu((function(t,n){Ou(n,zo(n),t)})),Bo=Eu((function(t,n,r,e){Ou(n,zo(n),t,e)})),jo=Eu((function(t,n,r,e){Ou(n,Eo(n),t,e)})),Ao=ui(fe);var ko=Qe((function(t,n){t=kt(t);var r=-1,e=n.length,i=e>2?n[2]:u;for(i&&wi(n[0],n[1],i)&&(e=1);++r1),n})),Ou(t,ai(t),r),e&&(r=le(r,7,ri));for(var u=n.length;u--;)hu(r,n[u]);return r}));var Uo=ui((function(t,n){return null==t?{}:function(t,n){return Ke(t,n,(function(n,r){return Co(t,r)}))}(t,n)}));function Wo(t,n){if(null==t)return{};var r=En(ai(t),(function(t){return[t]}));return n=li(n),Ke(t,r,(function(t,r){return n(t,r[0])}))}var Po=Qu(Eo),No=Qu(zo);function $o(t){return null==t?[]:Xn(t,Eo(t))}var qo=Lu((function(t,n,r){return n=n.toLowerCase(),t+(r?Go(n):n)}));function Go(t){return Xo(wo(t).toLowerCase())}function Zo(t){return(t=wo(t))&&t.replace(wt,ur).replace(Xt,"")}var Ko=Lu((function(t,n,r){return t+(r?"-":"")+n.toLowerCase()})),Ho=Lu((function(t,n,r){return t+(r?" ":"")+n.toLowerCase()})),Vo=Du("toLowerCase");var Jo=Lu((function(t,n,r){return t+(r?"_":"")+n.toLowerCase()}));var Yo=Lu((function(t,n,r){return t+(r?" ":"")+Xo(n)}));var Qo=Lu((function(t,n,r){return t+(r?" ":"")+n.toUpperCase()})),Xo=Du("toUpperCase");function tf(t,n,r){return t=wo(t),(n=r?u:n)===u?function(t){return en.test(t)}(t)?function(t){return t.match(nn)||[]}(t):function(t){return t.match(st)||[]}(t):t.match(n)||[]}var nf=Qe((function(t,n){try{return An(t,u,n)}catch(t){return Qa(t)?t:new Bt(t)}})),rf=ui((function(t,n){return In(n,(function(n){n=Ui(n),oe(t,n,Fa(t[n],t))})),t}));function ef(t){return function(){return t}}var uf=Pu(),af=Pu(!0);function of(t){return t}function ff(t){return De("function"==typeof t?t:le(t,1))}var cf=Qe((function(t,n){return function(r){return Oe(r,t,n)}})),lf=Qe((function(t,n){return function(r){return Oe(t,r,n)}}));function sf(t,n,r){var e=Eo(n),u=Be(n,e);null!=r||ro(n)&&(u.length||!e.length)||(r=n,n=t,t=this,u=Be(n,Eo(n)));var i=!(ro(r)&&"chain"in r&&!r.chain),a=Xa(t);return In(u,(function(r){var e=n[r];t[r]=e,a&&(t.prototype[r]=function(){var n=this.__chain__;if(i||n){var r=t(this.__wrapped__),u=r.__actions__=Fu(this.__actions__);return u.push({func:e,args:arguments,thisArg:t}),r.__chain__=n,r}return e.apply(t,zn([this.value()],arguments))})})),t}function _f(){}var hf=Gu(En),pf=Gu(Cn),gf=Gu(Ln);function vf(t){return xi(t)?Zn(Ui(t)):function(t){return function(n){return je(n,t)}}(t)}var df=Ku(),yf=Ku(!0);function bf(){return[]}function mf(){return!1}var wf=qu((function(t,n){return t+n}),0),xf=Ju("ceil"),Sf=qu((function(t,n){return t/n}),1),Bf=Ju("floor");var jf,Af=qu((function(t,n){return t*n}),1),kf=Ju("round"),If=qu((function(t,n){return t-n}),0);return Nr.after=function(t,n){if("function"!=typeof n)throw new Ct(i);return t=vo(t),function(){if(--t<1)return n.apply(this,arguments)}},Nr.ary=Ma,Nr.assign=xo,Nr.assignIn=So,Nr.assignInWith=Bo,Nr.assignWith=jo,Nr.at=Ao,Nr.before=Ca,Nr.bind=Fa,Nr.bindAll=rf,Nr.bindKey=Oa,Nr.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Za(t)?t:[t]},Nr.chain=pa,Nr.chunk=function(t,n,r){n=(r?wi(t,n,r):n===u)?1:mr(vo(n),0);var i=null==t?0:t.length;if(!i||n<1)return[];for(var a=0,o=0,f=e(vn(i/n));ai?0:i+r),(e=e===u||e>i?i:vo(e))<0&&(e+=i),e=r>e?0:yo(e);r>>0)?(t=wo(t))&&("string"==typeof n||null!=n&&!oo(n))&&!(n=su(n))&&or(t)?Su(pr(t),0,r):t.split(n,r):[]},Nr.spread=function(t,n){if("function"!=typeof t)throw new Ct(i);return n=null==n?0:mr(vo(n),0),Qe((function(r){var e=r[n],u=Su(r,0,n);return e&&zn(u,e),An(t,this,u)}))},Nr.tail=function(t){var n=null==t?0:t.length;return n?iu(t,1,n):[]},Nr.take=function(t,n,r){return t&&t.length?iu(t,0,(n=r||n===u?1:vo(n))<0?0:n):[]},Nr.takeRight=function(t,n,r){var e=null==t?0:t.length;return e?iu(t,(n=e-(n=r||n===u?1:vo(n)))<0?0:n,e):[]},Nr.takeRightWhile=function(t,n){return t&&t.length?gu(t,li(n,3),!1,!0):[]},Nr.takeWhile=function(t,n){return t&&t.length?gu(t,li(n,3)):[]},Nr.tap=function(t,n){return n(t),t},Nr.throttle=function(t,n,r){var e=!0,u=!0;if("function"!=typeof t)throw new Ct(i);return ro(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),Ra(t,n,{leading:e,maxWait:n,trailing:u})},Nr.thru=ga,Nr.toArray=po,Nr.toPairs=Po,Nr.toPairsIn=No,Nr.toPath=function(t){return Za(t)?En(t,Ui):lo(t)?[t]:Fu(Li(wo(t)))},Nr.toPlainObject=mo,Nr.transform=function(t,n,r){var e=Za(t),u=e||Ja(t)||so(t);if(n=li(n,4),null==r){var i=t&&t.constructor;r=u?e?new i:[]:ro(t)&&Xa(i)?$r(Kt(t)):{}}return(u?In:xe)(t,(function(t,e,u){return n(r,t,e,u)})),r},Nr.unary=function(t){return Ma(t,1)},Nr.union=ea,Nr.unionBy=ua,Nr.unionWith=ia,Nr.uniq=function(t){return t&&t.length?_u(t):[]},Nr.uniqBy=function(t,n){return t&&t.length?_u(t,li(n,2)):[]},Nr.uniqWith=function(t,n){return n="function"==typeof n?n:u,t&&t.length?_u(t,u,n):[]},Nr.unset=function(t,n){return null==t||hu(t,n)},Nr.unzip=aa,Nr.unzipWith=oa,Nr.update=function(t,n,r){return null==t?t:pu(t,n,mu(r))},Nr.updateWith=function(t,n,r,e){return e="function"==typeof e?e:u,null==t?t:pu(t,n,mu(r),e)},Nr.values=$o,Nr.valuesIn=function(t){return null==t?[]:Xn(t,zo(t))},Nr.without=fa,Nr.words=tf,Nr.wrap=function(t,n){return Ua(mu(n),t)},Nr.xor=ca,Nr.xorBy=la,Nr.xorWith=sa,Nr.zip=_a,Nr.zipObject=function(t,n){return yu(t||[],n||[],ee)},Nr.zipObjectDeep=function(t,n){return yu(t||[],n||[],nu)},Nr.zipWith=ha,Nr.entries=Po,Nr.entriesIn=No,Nr.extend=So,Nr.extendWith=Bo,sf(Nr,Nr),Nr.add=wf,Nr.attempt=nf,Nr.camelCase=qo,Nr.capitalize=Go,Nr.ceil=xf,Nr.clamp=function(t,n,r){return r===u&&(r=n,n=u),r!==u&&(r=(r=bo(r))==r?r:0),n!==u&&(n=(n=bo(n))==n?n:0),ce(bo(t),n,r)},Nr.clone=function(t){return le(t,4)},Nr.cloneDeep=function(t){return le(t,5)},Nr.cloneDeepWith=function(t,n){return le(t,5,n="function"==typeof n?n:u)},Nr.cloneWith=function(t,n){return le(t,4,n="function"==typeof n?n:u)},Nr.conformsTo=function(t,n){return null==n||se(t,n,Eo(n))},Nr.deburr=Zo,Nr.defaultTo=function(t,n){return null==t||t!=t?n:t},Nr.divide=Sf,Nr.endsWith=function(t,n,r){t=wo(t),n=su(n);var e=t.length,i=r=r===u?e:ce(vo(r),0,e);return(r-=n.length)>=0&&t.slice(r,i)==n},Nr.eq=Na,Nr.escape=function(t){return(t=wo(t))&&Y.test(t)?t.replace(V,ir):t},Nr.escapeRegExp=function(t){return(t=wo(t))&&it.test(t)?t.replace(ut,"\\$&"):t},Nr.every=function(t,n,r){var e=Za(t)?Cn:ve;return r&&wi(t,n,r)&&(n=u),e(t,li(n,3))},Nr.find=ya,Nr.findIndex=Gi,Nr.findKey=function(t,n){return Wn(t,li(n,3),xe)},Nr.findLast=ba,Nr.findLastIndex=Zi,Nr.findLastKey=function(t,n){return Wn(t,li(n,3),Se)},Nr.floor=Bf,Nr.forEach=ma,Nr.forEachRight=wa,Nr.forIn=function(t,n){return null==t?t:me(t,li(n,3),zo)},Nr.forInRight=function(t,n){return null==t?t:we(t,li(n,3),zo)},Nr.forOwn=function(t,n){return t&&xe(t,li(n,3))},Nr.forOwnRight=function(t,n){return t&&Se(t,li(n,3))},Nr.get=Mo,Nr.gt=$a,Nr.gte=qa,Nr.has=function(t,n){return null!=t&&di(t,n,Me)},Nr.hasIn=Co,Nr.head=Hi,Nr.identity=of,Nr.includes=function(t,n,r,e){t=Ha(t)?t:$o(t),r=r&&!e?vo(r):0;var u=t.length;return r<0&&(r=mr(u+r,0)),co(t)?r<=u&&t.indexOf(n,r)>-1:!!u&&Nn(t,n,r)>-1},Nr.indexOf=function(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var u=null==r?0:vo(r);return u<0&&(u=mr(e+u,0)),Nn(t,n,u)},Nr.inRange=function(t,n,r){return n=go(n),r===u?(r=n,n=0):r=go(r),function(t,n,r){return t>=wr(n,r)&&t=-9007199254740991&&t<=p},Nr.isSet=fo,Nr.isString=co,Nr.isSymbol=lo,Nr.isTypedArray=so,Nr.isUndefined=function(t){return t===u},Nr.isWeakMap=function(t){return eo(t)&&vi(t)==R},Nr.isWeakSet=function(t){return eo(t)&&"[object WeakSet]"==ke(t)},Nr.join=function(t,n){return null==t?"":yr.call(t,n)},Nr.kebabCase=Ko,Nr.last=Qi,Nr.lastIndexOf=function(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var i=e;return r!==u&&(i=(i=vo(r))<0?mr(e+i,0):wr(i,e-1)),n==n?function(t,n,r){for(var e=r+1;e--;)if(t[e]===n)return e;return e}(t,n,i):Pn(t,qn,i,!0)},Nr.lowerCase=Ho,Nr.lowerFirst=Vo,Nr.lt=_o,Nr.lte=ho,Nr.max=function(t){return t&&t.length?de(t,of,Ie):u},Nr.maxBy=function(t,n){return t&&t.length?de(t,li(n,2),Ie):u},Nr.mean=function(t){return Gn(t,of)},Nr.meanBy=function(t,n){return Gn(t,li(n,2))},Nr.min=function(t){return t&&t.length?de(t,of,We):u},Nr.minBy=function(t,n){return t&&t.length?de(t,li(n,2),We):u},Nr.stubArray=bf,Nr.stubFalse=mf,Nr.stubObject=function(){return{}},Nr.stubString=function(){return""},Nr.stubTrue=function(){return!0},Nr.multiply=Af,Nr.nth=function(t,n){return t&&t.length?Ge(t,vo(n)):u},Nr.noConflict=function(){return pn._===this&&(pn._=Pt),this},Nr.noop=_f,Nr.now=Ia,Nr.pad=function(t,n,r){t=wo(t);var e=(n=vo(n))?hr(t):0;if(!n||e>=n)return t;var u=(n-e)/2;return Zu(yn(u),r)+t+Zu(vn(u),r)},Nr.padEnd=function(t,n,r){t=wo(t);var e=(n=vo(n))?hr(t):0;return n&&en){var e=t;t=n,n=e}if(r||t%1||n%1){var i=Br();return wr(t+i*(n-t+ln("1e-"+((i+"").length-1))),n)}return Je(t,n)},Nr.reduce=function(t,n,r){var e=Za(t)?Tn:Hn,u=arguments.length<3;return e(t,li(n,4),r,u,pe)},Nr.reduceRight=function(t,n,r){var e=Za(t)?Dn:Hn,u=arguments.length<3;return e(t,li(n,4),r,u,ge)},Nr.repeat=function(t,n,r){return n=(r?wi(t,n,r):n===u)?1:vo(n),Ye(wo(t),n)},Nr.replace=function(){var t=arguments,n=wo(t[0]);return t.length<3?n:n.replace(t[1],t[2])},Nr.result=function(t,n,r){var e=-1,i=(n=wu(n,t)).length;for(i||(i=1,t=u);++ep)return[];var r=v,e=wr(t,v);n=li(n),t-=v;for(var u=Jn(e,n);++r=a)return t;var f=r-hr(e);if(f<1)return e;var c=o?Su(o,0,f).join(""):t.slice(0,f);if(i===u)return c+e;if(o&&(f+=c.length-f),oo(i)){if(t.slice(f).search(i)){var l,s=c;for(i.global||(i=It(i.source,wo(gt.exec(i))+"g")),i.lastIndex=0;l=i.exec(s);)var _=l.index;c=c.slice(0,_===u?f:_)}}else if(t.indexOf(su(i),f)!=f){var h=c.lastIndexOf(i);h>-1&&(c=c.slice(0,h))}return c+e},Nr.unescape=function(t){return(t=wo(t))&&J.test(t)?t.replace(H,vr):t},Nr.uniqueId=function(t){var n=++Dt;return wo(t)+n},Nr.upperCase=Qo,Nr.upperFirst=Xo,Nr.each=ma,Nr.eachRight=wa,Nr.first=Hi,sf(Nr,(jf={},xe(Nr,(function(t,n){Tt.call(Nr.prototype,n)||(jf[n]=t)})),jf),{chain:!1}),Nr.VERSION="4.17.21",In(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){Nr[t].placeholder=Nr})),In(["drop","take"],(function(t,n){Zr.prototype[t]=function(r){r=r===u?1:mr(vo(r),0);var e=this.__filtered__&&!n?new Zr(this):this.clone();return e.__filtered__?e.__takeCount__=wr(r,e.__takeCount__):e.__views__.push({size:wr(r,v),type:t+(e.__dir__<0?"Right":"")}),e},Zr.prototype[t+"Right"]=function(n){return this.reverse()[t](n).reverse()}})),In(["filter","map","takeWhile"],(function(t,n){var r=n+1,e=1==r||3==r;Zr.prototype[t]=function(t){var n=this.clone();return n.__iteratees__.push({iteratee:li(t,3),type:r}),n.__filtered__=n.__filtered__||e,n}})),In(["head","last"],(function(t,n){var r="take"+(n?"Right":"");Zr.prototype[t]=function(){return this[r](1).value()[0]}})),In(["initial","tail"],(function(t,n){var r="drop"+(n?"":"Right");Zr.prototype[t]=function(){return this.__filtered__?new Zr(this):this[r](1)}})),Zr.prototype.compact=function(){return this.filter(of)},Zr.prototype.find=function(t){return this.filter(t).head()},Zr.prototype.findLast=function(t){return this.reverse().find(t)},Zr.prototype.invokeMap=Qe((function(t,n){return"function"==typeof t?new Zr(this):this.map((function(r){return Oe(r,t,n)}))})),Zr.prototype.reject=function(t){return this.filter(Da(li(t)))},Zr.prototype.slice=function(t,n){t=vo(t);var r=this;return r.__filtered__&&(t>0||n<0)?new Zr(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),n!==u&&(r=(n=vo(n))<0?r.dropRight(-n):r.take(n-t)),r)},Zr.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Zr.prototype.toArray=function(){return this.take(v)},xe(Zr.prototype,(function(t,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),e=/^(?:head|last)$/.test(n),i=Nr[e?"take"+("last"==n?"Right":""):n],a=e||/^find/.test(n);i&&(Nr.prototype[n]=function(){var n=this.__wrapped__,o=e?[1]:arguments,f=n instanceof Zr,c=o[0],l=f||Za(n),s=function(t){var n=i.apply(Nr,zn([t],o));return e&&_?n[0]:n};l&&r&&"function"==typeof c&&1!=c.length&&(f=l=!1);var _=this.__chain__,h=!!this.__actions__.length,p=a&&!_,g=f&&!h;if(!a&&l){n=g?n:new Zr(this);var v=t.apply(n,o);return v.__actions__.push({func:ga,args:[s],thisArg:u}),new Gr(v,_)}return p&&g?t.apply(this,o):(v=this.thru(s),p?e?v.value()[0]:v.value():v)})})),In(["pop","push","shift","sort","splice","unshift"],(function(t){var n=Ft[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",e=/^(?:pop|shift)$/.test(t);Nr.prototype[t]=function(){var t=arguments;if(e&&!this.__chain__){var u=this.value();return n.apply(Za(u)?u:[],t)}return this[r]((function(r){return n.apply(Za(r)?r:[],t)}))}})),xe(Zr.prototype,(function(t,n){var r=Nr[n];if(r){var e=r.name+"";Tt.call(Rr,e)||(Rr[e]=[]),Rr[e].push({name:n,func:r})}})),Rr[Nu(u,2).name]=[{name:"wrapper",func:u}],Zr.prototype.clone=function(){var t=new Zr(this.__wrapped__);return t.__actions__=Fu(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Fu(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Fu(this.__views__),t},Zr.prototype.reverse=function(){if(this.__filtered__){var t=new Zr(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Zr.prototype.value=function(){var t=this.__wrapped__.value(),n=this.__dir__,r=Za(t),e=n<0,u=r?t.length:0,i=function(t,n,r){var e=-1,u=r.length;for(;++e=this.__values__.length;return{done:t,value:t?u:this.__values__[this.__index__++]}},Nr.prototype.plant=function(t){for(var n,r=this;r instanceof qr;){var e=Pi(r);e.__index__=0,e.__values__=u,n?i.__wrapped__=e:n=e;var i=e;r=r.__wrapped__}return i.__wrapped__=t,n},Nr.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Zr){var n=t;return this.__actions__.length&&(n=new Zr(this)),(n=n.reverse()).__actions__.push({func:ga,args:[ra],thisArg:u}),new Gr(n,this.__chain__)}return this.thru(ra)},Nr.prototype.toJSON=Nr.prototype.valueOf=Nr.prototype.value=function(){return vu(this.__wrapped__,this.__actions__)},Nr.prototype.first=Nr.prototype.head,tn&&(Nr.prototype[tn]=function(){return this}),Nr}();pn._=dr,(e=function(){return dr}.call(n,r,n,t))===u||(t.exports=e)}.call(this)}},n={};function r(e){var u=n[e];if(void 0!==u)return u.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var e=r(6014);freeaps_profile=e})(); diff --git a/FreeAPS/Resources/javascript/prepare/autotune-prep.js b/FreeAPS/Resources/javascript/prepare/autotune-prep.js index 9bda3dd8eb..50a7f6337a 100644 --- a/FreeAPS/Resources/javascript/prepare/autotune-prep.js +++ b/FreeAPS/Resources/javascript/prepare/autotune-prep.js @@ -1,6 +1,6 @@ function generate(pumphistory_data, profile_data, glucose_data, pumpprofile_data, carb_data = {} , categorize_uam_as_basal = false, tune_insulin_curve = false) { - if (typeof(profile_data.carb_ratio) === 'undefined' || profile_data.carb_ratio < 1) { - if (typeof(pumpprofile_data.carb_ratio) === 'undefined' || pumpprofile_data.carb_ratio < 1) { + if (typeof(profile_data.carb_ratio) === 'undefined' || profile_data.carb_ratio < 0.1) { + if (typeof(pumpprofile_data.carb_ratio) === 'undefined' || pumpprofile_data.carb_ratio < 0.1) { console.log('{ "carbs": 0, "mealCOB": 0, "reason": "carb_ratios ' + profile_data.carb_ratio + ' and ' + pumpprofile_data.carb_ratio + ' out of bounds" }'); return console.error("Error: carb_ratios " + profile_data.carb_ratio + ' and ' + pumpprofile_data.carb_ratio + " out of bounds"); } else { diff --git a/FreeAPS/Resources/javascript/prepare/meal.js b/FreeAPS/Resources/javascript/prepare/meal.js index 6411339aea..6523a4df70 100644 --- a/FreeAPS/Resources/javascript/prepare/meal.js +++ b/FreeAPS/Resources/javascript/prepare/meal.js @@ -1,7 +1,7 @@ //для monitor/meal.json параметры: monitor/pumphistory-24h-zoned.json settings/profile.json monitor/clock-zoned.json monitor/glucose.json settings/basal_profile.json monitor/carbhistory.json function generate(pumphistory_data, profile_data, clock_data, glucose_data, basalprofile_data, carbhistory = false) { - if (typeof(profile_data.carb_ratio) === 'undefined' || profile_data.carb_ratio < 1) { + if (typeof(profile_data.carb_ratio) === 'undefined' || profile_data.carb_ratio < 0.1) { return {"error":"Error: carb_ratio " + profile_data.carb_ratio + " out of bounds"}; } diff --git a/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json b/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json index 6c630c6272..bec8a8989b 100644 --- a/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json +++ b/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json @@ -1,42 +1,44 @@ { - "useAlarmSound" : false, - "uploadStats" : false, - "useCalendar" : false, - "rulerMarks" : false, - "individualAdjustmentFactor" : 0.5, - "low" : 70, - "displayHR" : true, - "localGlucosePort" : 8080, - "uploadGlucose" : true, - "allowAnnouncements" : false, - "debugOptions" : false, - "useAppleHealth" : false, - "high" : 170, - "yGridLines" : true, - "useLocalGlucoseSource" : false, - "closedLoop" : false, - "units" : "mmol/L", - "xGridLines" : true, - "lowGlucose" : 70, - "oneDimensionalGraph" : false, - "glucoseNotificationsAlways" : false, - "addSourceInfoToGlucoseNotifications" : false, - "cgm" : "nightscout", - "glucoseBadge" : true, - "overrideHbA1cUnit" : false, - "delay" : 80, - "smoothGlucose" : false, - "skipBolusScreenAfterCarbs" : false, - "highGlucose" : 220, - "timeCap" : 8, - "minuteInterval" : 20, - "isUploadEnabled" : true, - "useAutotune" : false, - "hours" : 6, - "carbsRequiredThreshold" : 50, - "insulinReqPercentage" : 80, - "useFPUconversion" : false, - "displayOnWatch" : "HR", - "animatedBackground" : false - "maxCarbs": 1000 + "units" : "mmol/L", + "closedLoop" : false, + "allowAnnouncements" : false, + "useAutotune" : false, + "onlyAutotuneBasals" : false, + "isUploadEnabled" : false, + "useLocalGlucoseSource" : false, + "localGlucosePort" : 8080, + "debugOptions" : false, + "insulinReqPercentage" : 70, + "skipBolusScreenAfterCarbs" : false, + "displayHR" : false, + "cgm" : "nightscout", + "uploadGlucose" : true, + "useCalendar" : false, + "glucoseBadge" : false, + "glucoseNotificationsAlways" : false, + "useAlarmSound" : false, + "addSourceInfoToGlucoseNotifications" : false, + "lowGlucose" : 72, + "highGlucose" : 270, + "carbsRequiredThreshold" : 10, + "animatedBackground" : false, + "useFPUconversion" : true, + "individualAdjustmentFactor" : 0.5, + "timeCap" : 8, + "minuteInterval" : 30, + "delay" : 60, + "useAppleHealth" : false, + "smoothGlucose" : false, + "displayOnWatch" : "BGTarget", + "overrideHbA1cUnit" : false, + "high" : 145, + "low" : 70, + "uploadStats" : true, + "hours" : 6, + "xGridLines" : true, + "yGridLines" : true, + "oneDimensionalGraph" : false, + "rulerMarks" : false, + "maxCarbs": 1000, + "displayFatAndProteinOnWatch": false } diff --git a/FreeAPS/Resources/json/defaults/preferences.json b/FreeAPS/Resources/json/defaults/preferences.json new file mode 100644 index 0000000000..6edb81100d --- /dev/null +++ b/FreeAPS/Resources/json/defaults/preferences.json @@ -0,0 +1,53 @@ +{ + "max_iob" : 0, + "max_daily_safety_multiplier" : 3, + "current_basal_safety_multiplier" : 4, + "autosens_max" : 1.2, + "autosens_min" : 0.7, + "smb_delivery_ratio" : 0.5, + "rewind_resets_autosens" : true, + "high_temptarget_raises_sensitivity" : false, + "low_temptarget_lowers_sensitivity" : false, + "sensitivity_raises_target" : true, + "resistanceLowersTarget" : false, + "adv_target_adjustments" : false, + "exercise_mode" : false, + "half_basal_exercise_target" : 160, + "maxCOB" : 120, + "wide_bg_target_range" : false, + "skip_neutral_temps" : false, + "unsuspend_if_no_temp" : false, + "min_5m_carbimpact" : 8, + "autotune_isf_adjustmentFraction" : 1, + "remainingCarbsFraction" : 1, + "remainingCarbsCap" : 90, + "enableUAM" : false, + "A52_risk_enable" : false, + "enableSMB_with_COB" : false, + "enableSMB_with_temptarget" : false, + "enableSMB_always" : false, + "enableSMB_after_carbs" : false, + "allowSMB_with_high_temptarget" : false, + "maxSMBBasalMinutes" : 30, + "maxUAMSMBBasalMinutes" : 30, + "SMBInterval" : 3, + "bolus_increment" : 0.1, + "curve" : "rapid-acting", + "useCustomPeakTime" : false, + "insulinPeakTime" : 75, + "carbsReqThreshold" : 1, + "noisyCGMTargetMultiplier" : 1.3, + "suspend_zeros_iob" : false, + "maxDelta_bg_threshold" : 0.2, + "adjustmentFactor" : 0.5, + "sigmoid" : false, + "enableDynamicCR" : false, + "useNewFormula" : false, + "useWeightedAverage" : false, + "weightPercentage" : 0.65, + "tddAdjBasal" : false, + "enableSMB_high_bg" : false, + "enableSMB_high_bg_target" : 110, + "threshold_setting" : 65, + "updateInterval" : 20 +} diff --git a/FreeAPS/Resources/json/defaults/settings/bg_targets.json b/FreeAPS/Resources/json/defaults/settings/bg_targets.json index beab52737e..50631acb45 100644 --- a/FreeAPS/Resources/json/defaults/settings/bg_targets.json +++ b/FreeAPS/Resources/json/defaults/settings/bg_targets.json @@ -4,7 +4,7 @@ "targets": [ { "low": 5.5, - "high": 6.0, + "high": 5.5, "start": "00:00:00", "offset": 0 } diff --git a/FreeAPS/Sources/Models/Preferences.swift b/FreeAPS/Sources/Models/Preferences.swift index 80f94c3e9f..ee4057a3da 100644 --- a/FreeAPS/Sources/Models/Preferences.swift +++ b/FreeAPS/Sources/Models/Preferences.swift @@ -8,8 +8,8 @@ struct Preferences: JSON { var autosensMin: Decimal = 0.7 var smbDeliveryRatio: Decimal = 0.5 var rewindResetsAutosens: Bool = true - var highTemptargetRaisesSensitivity: Bool = true - var lowTemptargetLowersSensitivity: Bool = true + var highTemptargetRaisesSensitivity: Bool = false + var lowTemptargetLowersSensitivity: Bool = false var sensitivityRaisesTarget: Bool = true var resistanceLowersTarget: Bool = false var advTargetAdjustments: Bool = false @@ -39,7 +39,7 @@ struct Preferences: JSON { var insulinPeakTime: Decimal = 75 var carbsReqThreshold: Decimal = 1.0 var noisyCGMTargetMultiplier: Decimal = 1.3 - var suspendZerosIOB: Bool = true + var suspendZerosIOB: Bool = false var timestamp: Date? var maxDeltaBGthreshold: Decimal = 0.2 var adjustmentFactor: Decimal = 0.5 diff --git a/FreeAPS/Sources/Modules/CREditor/CREditorStateModel.swift b/FreeAPS/Sources/Modules/CREditor/CREditorStateModel.swift index 25c7f48d2a..56076c0415 100644 --- a/FreeAPS/Sources/Modules/CREditor/CREditorStateModel.swift +++ b/FreeAPS/Sources/Modules/CREditor/CREditorStateModel.swift @@ -7,7 +7,7 @@ extension CREditor { let timeValues = stride(from: 0.0, to: 1.days.timeInterval, by: 30.minutes.timeInterval).map { $0 } - let rateValues = stride(from: 15.0, to: 501.0, by: 1.0).map { ($0.decimal ?? .zero) / 10 } + let rateValues = stride(from: 1.0, to: 501.0, by: 1.0).map { ($0.decimal ?? .zero) / 10 } var canAdd: Bool { guard let lastItem = items.last else { return true } diff --git a/FreeAPS/Sources/Modules/OverrideProfilesConfig/View/OverrideProfilesRootView.swift b/FreeAPS/Sources/Modules/OverrideProfilesConfig/View/OverrideProfilesRootView.swift index 248e979fd8..d00107fb47 100644 --- a/FreeAPS/Sources/Modules/OverrideProfilesConfig/View/OverrideProfilesRootView.swift +++ b/FreeAPS/Sources/Modules/OverrideProfilesConfig/View/OverrideProfilesRootView.swift @@ -292,10 +292,9 @@ extension OverrideProfilesConfig { let durationString = perpetual ? "" : "\(formatter.string(from: duration as NSNumber)!)" let scheduledSMBstring = (preset.smbIsOff && preset.smbIsAlwaysOff) ? "Scheduled SMBs" : "" let smbString = (preset.smbIsOff && scheduledSMBstring == "") ? "SMBs are off" : "" - let targetString = target != 0 ? "\(formatter.string(from: target as NSNumber)!)" : "" + let targetString = target != 0 ? "\(glucoseFormatter.string(from: target as NSNumber)!)" : "" let maxMinutesSMB = (preset.smbMinutes as Decimal?) != nil ? (preset.smbMinutes ?? 0) as Decimal : 0 let maxMinutesUAM = (preset.uamMinutes as Decimal?) != nil ? (preset.uamMinutes ?? 0) as Decimal : 0 - let isfString = preset.isf ? "ISF" : "" let crString = preset.cr ? "CR" : "" let dash = crString != "" ? "/" : ""