| 1 |
- var freeaps_determineBasal;(()=>{var e={5546:(e,r,t)=>{var o=t(6880);function i(e,a){a||(a=0);var r=Math.pow(10,a);return Math.round(e*r)/r}function n(e,a){return"mmol/L"===a.out_units?i(.0555*e,1):Math.round(e)}var s="",l="",m="",u="",d="",c="",g="",h="",p="";function f(e,a){var r=[2,7,12,16,20,50,60,80,90,100,110,150,180,200],t=[0,0,.4,.7,.7,-.5,-.5,-.3,-.2,0,0,.5,.7,.7],o=r.length-1,i=r[0],n=t[0],s=r[o],l=t[o],m=1,u=1,d=1,c=i;if(i>e)m=(u=n)+((l=t[1])-u)/((s=r[1])-(d=i))*(e-d);else if(s<e)m=(u=n=t[o-1])+(l-u)/(s-(d=i=r[o-1]))*(e-d);else for(var g=0;g<=o;g++){if(n=t[g],(i=r[g])==e){m=n;break}if(i>e){m=u+(n-u)/(i-(d=c))*(e-d);break}u=n,c=i}return m*=e>100?a.higher_ISFrange_weight:e>40?a.lower_ISFrange_weight:a.delta_ISFrange_weight}function b(e,a,r){if(void 0===e.smb_delivery_ratio_bg_range||0===e.smb_delivery_ratio_bg_range)return console.error("SMB delivery ratio set to fixed value "+e.smb_delivery_ratio),e.smb_delivery_ratio;var t=Math.min(e.smb_delivery_ratio_min,e.smb_delivery_ratio_max);if(a<=r)return console.error("SMB delivery ratio limited by minimum value "+t),t;var o=Math.max(e.smb_delivery_ratio_min,e.smb_delivery_ratio_max);if(a>=r+e.smb_delivery_ratio_bg_range)return console.error("SMB delivery ratio limited by maximum value "+o),o;var n=t+(o-t)*(a-r)/e.smb_delivery_ratio_bg_range;return console.error("SMB delivery ratio set to interpolated value "+i(n,2)),n}e.exports=function(e,r,t,v,B,_,M,y,x,S,w,C,D,F,I){var G=0,T="",U="",O="",R="",A="",P=0,j=(F=0,0),W=0,k=0,q=0;const E=I.weightedAverage,L=v.weightPercentage,z=I.average_total_data;function N(e,a){var r=e.getTime();return new Date(r+36e5*a)}function Z(e){var a=v.bolus_increment;.05!=a&&(a=.1);var r=e/a;return r>=1?i(Math.floor(r)*a,5):0}function H(e){function a(e){return e<10&&(e="0"+e),e}return a(e.getHours())+":"+a(e.getMinutes())+":00"}function $(e,a){var r=new Date("1/1/1999 "+e),t=new Date("1/1/1999 "+a);return(r.getTime()-t.getTime())/36e5}function J(e,a){var r=0,t=a,o=(e-a)/36e5,i=0,n=o,s=0;do{if(o>0){var l=H(t),m=D[0].rate;for(let e=0;e<D.length;e++){var u=D[e].start;if(l==u){if(e+1<D.length){o>=(s=$(D[e+1].start,D[e].start))?i=s:o<s&&(i=o)}else if(e+1==D.length){let a=D[0].start;o>=(s=24-$(D[e].start,a))?i=s:o<s&&(i=o)}r+=Z((m=D[e].rate)*i),o-=i,console.log("Dynamic ratios log: scheduled insulin added: "+Z(m*i)+" U. Bas duration: "+i.toPrecision(3)+" h. Base Rate: "+m+" U/h. Time :"+l),t=N(t,i)}else if(l>u)if(e+1<D.length){var d=D[e+1].start;l<d&&(o>=(s=$(d,l))?i=s:o<s&&(i=o),r+=Z((m=D[e].rate)*i),o-=i,console.log("Dynamic ratios log: scheduled insulin added: "+Z(m*i)+" U. Bas duration: "+i.toPrecision(3)+" h. Base Rate: "+m+" U/h. Time :"+l),t=N(t,i))}else if(e==D.length-1){o>=(s=$("23:59:59",l))?i=s:o<s&&(i=o),r+=Z((m=D[e].rate)*i),o-=i,console.log("Dynamic ratios log: scheduled insulin added: "+Z(m*i)+" U. Bas duration: "+i.toPrecision(3)+" h. Base Rate: "+m+" U/h. Time :"+l),t=N(t,i)}}}}while(o>0&&o<n);return r}if(w.length){let e=w.length-1;var K=new Date(w[e].timestamp),Q=new Date(w[0].timestamp);if("TempBasalDuration"==w[0]._type&&(Q=new Date),(G=(Q-K)/36e5)<24&&G>21)k=J(K,(V=24-G,X=K.getTime(),new Date(X-36e5*V))),R="24 hours of data is required for an accurate tdd calculation. Currently only "+G.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 R=""}else console.log("Pumphistory is empty!"),se=!1,enableDynamicCR=!1;var V,X;for(let e=0;e<w.length;e++)"Bolus"==w[e]._type&&(W+=w[e].amount);for(let e=1;e<w.length;e++)if("TempBasal"==w[e]._type&&w[e].rate>0){P=e,q=w[e].rate;var Y=w[e-1]["duration (min)"]/60,ee=Y,ae=new Date(w[e-1].timestamp),re=ae;do{if(e--,0==e){re=new Date;break}if("TempBasal"==w[e]._type||"PumpSuspend"==w[e]._type){re=new Date(w[e].timestamp);break}}while(e>0);var te=(re-ae)/36e5;te<ee&&(Y=te),j+=Z(q*Y),e=P}for(let e=0;e<w.length;e++)if(0,0==w[e]["duration (min)"]||"PumpResume"==w[e]._type){let a=new Date(w[e].timestamp),r=a,t=e;do{if(t>0&&(--t,"TempBasal"==w[t]._type)){r=new Date(w[t].timestamp);break}}while(t>0);(r-a)/36e5>0&&(k+=J(r,a))}for(let e=w.length-1;e>0;e--)if("TempBasalDuration"==w[e]._type){let a=w[e]["duration (min)"]/60,r=new Date(w[e].timestamp);var oe=r;let t=e;do{if(--t,t>=0&&("TempBasal"==w[t]._type||"PumpSuspend"==w[t]._type)){oe=new Date(w[t].timestamp);break}}while(t>0);if(0==e&&"TempBasalDuration"==w[0]._type&&(oe=new Date,a=w[e]["duration (min)"]/60),(oe-r)/36e5-a>0){k+=J(oe,N(r,a))}}var ie=F=W+j+k;G>21?(U=". Bolus insulin: "+W.toPrecision(5)+" U",O=". Temporary basal insulin: "+j.toPrecision(5)+" U",T=". Insulin with scheduled basal rate: "+k.toPrecision(5)+" U",A=R+(" TDD past 24h is: "+F.toPrecision(5)+" U")+U+O+T,tddReason=E>0&&z>0?", TDD: "+i(F,1)+" U, Weighted avg: "+i(E,1)+" U, Total data avg: "+i(z,1)+" U":", TDD: "+i(F,2)):tddReason=", TDD: Not enough pumpData (< 21h)";const ne=e.glucose;var se=C.enableChris,le=C.enableDynamicCR;const me=Math.min(v.autosens_min,v.autosens_max),ue=Math.max(v.autosens_min,v.autosens_max),de=C.adjustmentFactor,ce=v.min_bg;var ge=!1,he="",pe=1,fe="";z>0&&(pe=E/z),fe=pe>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: "+(pe=i(pe=Math.min(pe,v.autosens_max),2))+". Upper limit = Autosens max ("+v.autosens_max+")":pe<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: "+(pe=i(pe=Math.max(pe,v.autosens_min),2))+". Lower limit = Autosens min ("+v.autosens_min+")":"Basal adjusted with a 24 hour to total average (up to 14 days of data) TDD ratio: "+pe,fe=", Basal ratio: "+pe,1!=v.high_temptarget_raises_sensitivity&&1!=v.exercise_mode||(ge=!0),se&&(v.use_autoisf=!1,console.log("autoISF is off. dynISF is on")),ce>=118&&1==ge&&(v.use_autoisf=!1,se=!1,he="Dynamic ISF temporarily off due to a high temp target/exercising. Current min target: "+ce);var be=", Dynamic ratios log: ",ve=", AF: "+de,Be="BG: "+ne+" mg/dl ("+(.0555*ne).toPrecision(2)+" mmol/l)",_e="",Me="";const ye=C.curve,xe=C.insulinPeakTime,Se=C.useCustomPeakTime;var we=55,Ce=65;switch(ye){case"rapid-acting":Ce=65;break;case"ultra-rapid":Ce=50}if(Se?(we=120-xe,console.log("Custom insulinpeakTime set to :"+xe+", insulinFactor: "+we)):(we=120-Ce,console.log("insulinFactor set to : "+we)),ie=F,L<1&&E>0&&(F=E,console.log("Using weighted TDD average: "+i(F,2)+" U, instead of past 24 h ("+i(ie,2)+" U), weight: "+L),Me=", Weighted TDD: "+i(F,2)+" U"),C.useNewFormula&&se){var De=v.sens*de*F*Math.log(ne/we+1)/1800;_e=", Logarithmic formula"}else if(se){De=v.sens*de*F*ne/277700;_e=", Original formula"}var Fe=v.carb_ratio,Ie="",Ge="";if(se&&F>0){if(Ie=", Dynamic ISF/CR: On/",De>ue?(he=", Dynamic ISF limited by autosens_max setting: "+ue+" ("+i(De,2)+"), ",Ge=", Autosens/Dynamic Limit: "+ue+" ("+i(De,2)+")",De=ue):De<me&&(he=", Dynamic ISF limjted by autosens_min setting: "+me+" ("+i(De,2)+"). ",Ge=", Autosens/Dynamic Limit: "+me+" ("+i(De,2)+")",De=me),le){Ie+="On";var Te=De;De>1&&(Te=(De-1)/2+1);var Ue=" CR: "+(Fe=i(Fe/Te,2))+" g/U";v.carb_ratio=Fe}else Ue=" CR: "+Fe+" g/U",Ie+="Off";var Oe=v.sens/De;he+=", Dynamic autosens.ratio set to "+i(De,2)+" with ISF: "+Oe.toPrecision(3)+" mg/dl/U ("+(.0555*Oe).toPrecision(3)+" mmol/l/U)"+Ie,B.ratio=De,A+=be+Be+ve+_e+he+Ue+Me}else A+=be+"Dynamic Settings disabled";console.log(A),se||le?se&&v.tddAdjBasal?tddReason+=Ie+_e+Ge+ve+fe:se&&!v.tddAdjBasal&&(tddReason+=Ie+_e+Ge+ve):tddReason+="";var Re={},Ae=new Date;if(S&&(Ae=S),void 0===v||void 0===v.current_basal)return Re.error="Error: could not get current basal rate",Re;var Pe=o(v.current_basal,v),je=Pe,We=new Date;S&&(We=S);var ke,qe=new Date(e.date),Ee=i((We-qe)/60/1e3,1),Le=e.glucose,ze=e.noise;ke=e.delta>-.5?"+"+i(e.delta,0):i(e.delta,0);var Ne=Math.min(e.delta,e.short_avgdelta),Ze=Math.min(e.short_avgdelta,e.long_avgdelta),He=Math.max(e.delta,e.short_avgdelta,e.long_avgdelta);(Le<=10||38===Le||ze>=3)&&(Re.reason="CGM is calibrating, in ??? state, or noise is high");if(Le>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(Le,v)+"+"+n(e.delta,v)+") for 5m w/ "+n(e.short_avgdelta,v)+" mg/dL ~15m change & "+n(e.long_avgdelta,2)+" mg/dL ~45m change"),console.error("Simulator mode detected ("+e.device+"): continuing anyway")):!0),Ee>12||Ee<-5?Re.reason="If current system time "+We+" is correct, then BG data is too old. The last BG data was read "+Ee+"m ago at "+qe:0===e.short_avgdelta&&0===e.long_avgdelta&&(e.last_cal&&e.last_cal<3?Re.reason="CGM was just calibrated":Re.reason="CGM data is unchanged ("+n(Le,v)+"+"+n(e.delta,v)+") for 5m w/ "+n(e.short_avgdelta,v)+" mg/dL ~15m change & "+n(e.long_avgdelta,v)+" mg/dL ~45m change"),Le<=10||38===Le||ze>=3||Ee>12||Ee<-5||0===e.short_avgdelta&&0===e.long_avgdelta)return r.rate>=je?(Re.reason+=". Canceling high temp basal of "+r.rate,Re.deliverAt=Ae,Re.temp="absolute",Re.duration=0,Re.rate=0,Re):0===r.rate&&r.duration>30?(Re.reason+=". Shortening "+r.duration+"m long zero temp to 30m. ",Re.deliverAt=Ae,Re.temp="absolute",Re.duration=30,Re.rate=0,Re):(Re.reason+=". Temp "+r.rate+" <= current basal "+je+"U/hr; doing nothing. ",Re);var $e,Je,Ke,Qe,Ve=v.max_iob;if(void 0!==v.min_bg&&(Je=v.min_bg),void 0!==v.max_bg&&(Ke=v.max_bg),void 0!==v.enableSMB_high_bg_target&&(Qe=v.enableSMB_high_bg_target),void 0===v.min_bg||void 0===v.max_bg)return Re.error="Error: could not determine target_bg. ",Re;$e=(v.min_bg+v.max_bg)/2;var Xe=v.exercise_mode||v.high_temptarget_raises_sensitivity,Ye=100,ea=160;if(v.half_basal_exercise_target&&(ea=v.half_basal_exercise_target),Xe&&v.temptargetSet&&$e>Ye||v.low_temptarget_lowers_sensitivity&&v.temptargetSet&&$e<Ye){var aa=ea-Ye;sensitivityRatio=aa*(aa+$e-Ye)<=0?v.autosens_max:aa/(aa+$e-Ye),sensitivityRatio=Math.min(sensitivityRatio,v.autosens_max),sensitivityRatio=i(sensitivityRatio,2),process.stderr.write("Sensitivity ratio set to "+sensitivityRatio+" based on temp target of "+$e+"; ")}else void 0!==B&&B&&(sensitivityRatio=B.ratio,process.stderr.write("Autosens ratio: "+sensitivityRatio+"; "));if(sensitivityRatio&&0==v.enableChris?(je=v.current_basal*sensitivityRatio,je=o(je,v)):v.enableChris&&v.tddAdjBasal&&(je=v.current_basal*pe,je=o(je,v),process.stderr.write("TDD-adjustment of basals activated, using tdd24h_14d_Ratio "+i(pe,2)+", TDD 24h = "+i(ie,2)+"U, Weighted average TDD = "+i(E,2)+"U, (Weight percentage = "+L+"), Total data of TDDs (up to 14 days) average = "+i(z,2)+"U. "),je!==Pe?process.stderr.write("Adjusting basal from "+Pe+" U/h to "+je+" U/h; "):process.stderr.write("Basal unchanged: "+je+" U/h; ")),v.temptargetSet);else if(void 0!==B&&B&&(v.sensitivity_raises_target&&B.ratio<1||v.resistance_lowers_target&&B.ratio>1)){Je=i((Je-60)/B.ratio)+60,Ke=i((Ke-60)/B.ratio)+60;var ra=i(($e-60)/B.ratio)+60;$e===(ra=Math.max(80,ra))?process.stderr.write("target_bg unchanged: "+ra+"; "):process.stderr.write("target_bg from "+$e+" to "+ra+"; "),$e=ra}var ta=200,oa=200,ia=200;if(e.noise>=2){var na=Math.max(1.1,v.noisyCGMTargetMultiplier);Math.min(250,v.maxRaw);ta=i(Math.min(200,Je*na)),oa=i(Math.min(200,$e*na)),ia=i(Math.min(200,Ke*na)),process.stderr.write("Raising target_bg for noisy / raw CGM data, from "+$e+" to "+oa+"; "),Je=ta,$e=oa,Ke=ia}var sa=Je-.5*(Je-40),la=v.threshold_setting;la>sa&&la<=120&&la>=65?(console.error("Threshold changed in settings from "+n(sa,v)+" to "+n(la,v)+". "),sa=la):console.error("Current threshold: "+n(sa,v));var ma=i(v.sens,1),ua=v.sens;if(void 0!==B&&B&&((ua=i(ua=v.sens/sensitivityRatio,1))!==ma?process.stderr.write("ISF from "+n(ma,v)+" to "+n(ua,v)):process.stderr.write("ISF unchanged: "+n(ua,v)),s+="Autosens ratio: "+i(sensitivityRatio,2)+", ISF: "+n(ma,v)+"→"+n(ua,v)),console.error("CR:"+v.carb_ratio),ua=function(e,a,r,t,o,v,B,_){if(!r.use_autoisf)return console.error("autoISF disabled in Preferences"),e;var M=t.dura_p,y=t.delta_pl,x=t.delta_pn,S=t.r_squ,w=t.bg_acceleration,C=t.parabola_fit_a0,D=t.parabola_fit_a1,F=t.parabola_fit_a2,I=t.autoISF_duration,G=t.autoISF_average,T=r.autoisf_max,U=!1,O=1,R=1,A=1,P=a+10-G;if(!(o.mealCOB>0)||r.enableautoisf_with_COB){var j=t.pp_debug;if(c+="BG-accel: "+i(w,3)+", PF-minutes: "+M+", PF-corr: "+i(S,4)+", PF-nextDelta: "+n(x,r)+", PF-lastDelta: "+n(y,r)+", regular Delta: "+n(t.delta,r),console.error(j+c+" , Weights Accel/Brake: "+r.bgAccel_ISF_weight+" / "+r.bgBrake_ISF_weight),r.enable_BG_acceleration){var W=w;if(0!=t.parabola_fit_a2){var k=-D/2/F*5,q=i(C-k*k/25*F,1);(k=i(k,1))<0&&W<0?(p="saw max of "+n(q,r)+", about "+-k+" min ago",console.error("Parabolic fit "+p)):k<0&&W>0?(p="saw min of "+n(q,r)+", about "+-k+" min ago",console.error("Parabolic fit "+p)):k>0&&W<0?(p="predicts max of "+n(q,r)+", in about "+k+"min",console.error("Parabolic fit "+p)):k>0&&W>0&&(p="predicts min of "+n(q,r)+", in about "+k+" min",console.error("Parabolic fit "+p))}var E=S;if(E<=.9)p="acce_ISF by-passed, as correlation, "+i(E,3)+", is too low",console.error("Parabolic fit "+p),g+=", Parabolic Fit, "+p;else{g+=", Parabolic Fit, "+p+", lastΔ: "+n(y,r)+", nextΔ: "+n(x,r)+", Corr "+i(S,3)+", BG-Accel: "+i(W,2);var L=10*(E-.9),z=1;t.glucose<r.target_bg&&W>1&&(z=.5),A=1+W*z*(W<0?r.bgBrake_ISF_weight:r.bgAccel_ISF_weight)*L,console.error("Original result for acce_ISF: "+i(A,2)),1!=A&&(U=!0,g+=", acce-ISF Ratio: "+i(A,2))}}else console.error("autoISF BG accelertion adaption disabled in Preferences");var N=b(r,t.glucose,a);s+=", SMB Delivery Ratio:, "+i(N,2)+g+", autoISF";var Z=1+f(100-P,r);console.error("bg_ISF adaptation is "+i(Z,2)),Z<1&&A>1&&(h="bg-ISF adaptation lifted to "+i(Z*=A,2)+", as BG accelerates already",l="(lifted by "+i(A,2)+")",console.error(h));var H=1;if(Z<1)return(H=Math.min(Z,A))<r.autoisf_min&&(h="final ISF factor "+i(H,2)+" limited by autoisf_min "+r.autoisf_min,console.error(h),H=r.autoisf_min),l=" (lmtd.)",earlysens=Math.min(720,i(r.sens/Math.min(_,H),1)),console.error("early Return autoISF: "+n(earlysens,r)),s+=", bg-ISF Ratio: "+i(Z,2)+l+", ISF: "+n(earlysens,r),earlysens;Z>1&&(U=!0,s+=", bg-ISF Ratio: "+i(Z,2));var $=t.delta;P>0?console.error("delta_ISF adaptation by-passed as average glucose < "+n(a+10,r)):t.short_avgdelta<0?console.error("delta_ISF adaptation by-passed as no rise or too short lived"):r.enableppisf_always||r.postmeal_ISF_duration>=(v-o.lastCarbTime)/1e3/3600?(O=1+Math.max(0,$*r.postmeal_ISF_weight),console.error("pp_ISF adaptation is "+i(O,2)),u=", pp-ISF Ratio: "+i(O,2),1!=O&&(U=!0)):(R=f($,r),P>-20&&(R*=.5),R=1+R,console.error("delta_ISF adaptation is "+i(R,2)),d=", Δ-ISF Ratio: "+i(R,2),1!=R&&(U=!0));var J=1,K=r.autoisf_hourlychange;return o.mealCOB>0&&!r.enableautoisf_with_COB?console.error("dura_ISF by-passed; preferences disabled mealCOB of "+i(o.mealCOB,1)):I<10?console.error("dura_ISF by-passed; BG is only "+I+"m at level "+G):G<=a?console.error("dura_ISF by-passed; avg. glucose "+G+" below target "+n(a,r)):(J+=I/60*(K/a)*(G-a),U=!0,m=", Duration: "+I+", Avg: "+n(G,r)+", dura-ISF Ratio: "+i(J,2),console.error("dura_ISF adaptation is "+i(J,2)+" because ISF "+e+" did not do it for "+i(I,1)+"m")),H=1,U?(H=Math.max(J,Z,R,A,O),console.error("autoISF adaption ratios:"),console.error(" dura "+i(J,2)),console.error(" bg "+i(Z,2)),console.error(" delta "+i(R,2)),console.error(" pp "+i(O,2)),console.error(" accel "+i(A,2)),A<1&&(console.error("strongest ISF factor "+i(H,2)+" weakened to "+i(H*A,2)+" as bg decelerates already"),H*=A),H<r.autoisf_min?(console.error("final ISF factor "+i(H,2)+" limited by autoisf_min "+r.autoisf_min),H=r.autoisf_min):H>T&&(console.error("final ISF factor "+i(H,2)+" limited by autoisf_max "+T),H=T),H>=1&&(e=i(r.sens/Math.max(H,_),1)),H<1&&(e=i(r.sens/Math.min(H,_),1))):H=_,s+=u+d+m+", Ratio: "+i(H,2)+", ISF: "+n(e,r),console.error("Inside autoISF: Ratio "+i(H,2)+" resulting in "+n(e,r)),e}console.error("BG dependant autoISF by-passed; preferences disabled mealCOB of "+i(o.mealCOB,1))}(ua,$e,v,e,_,S,0,sensitivityRatio),void 0===t)return Re.error="Error: iob_data undefined. ",Re;var da,ca=t;if(t.length,t.length>1&&(t=ca[0]),void 0===t.activity||void 0===t.iob)return Re.error="Error: iob_data missing some property. ",Re;var ga=((da=void 0!==t.lastTemp?i((new Date(We).getTime()-t.lastTemp.date)/6e4):0)+r.duration)%30;if(console.error("currenttemp:"+r.rate+" lastTempAge:"+da+"m, tempModulus:"+ga+"m"),Re.temp="absolute",Re.deliverAt=Ae,y&&r&&t.lastTemp&&r.rate!==t.lastTemp.rate&&da>10&&r.duration)return Re.reason="Warning: currenttemp rate "+r.rate+" != lastTemp rate "+t.lastTemp.rate+" from pumphistory; canceling temp",M.setTempBasal(0,0,v,Re,r);if(r&&t.lastTemp&&r.duration>0){var ha=da-t.lastTemp.duration;if(ha>5&&da>10)return Re.reason="Warning: currenttemp running but lastTemp from pumphistory ended "+ha+"m ago; canceling temp",M.setTempBasal(0,0,v,Re,r)}var pa=i(-t.activity*ua*5,2),fa=i(6*(Ne-pa));fa<0&&(fa=i(6*(Ze-pa)))<0&&(fa=i(6*(e.long_avgdelta-pa)));var ba=Le,va=(ba=t.iob>0?i(Le-t.iob*ua):i(Le-t.iob*Math.min(ua,v.sens)))+fa;if(void 0===va||isNaN(va))return Re.error="Error: could not calculate eventualBG. Sensitivity: "+ua+" Deviation: "+fa,Re;var Ba=function(e,a,r){return i(r+(e-a)/24,1)}($e,va,pa);Re={temp:"absolute",bg:Le,tick:ke,eventualBG:va,insulinReq:0,reservoir:x,deliverAt:Ae,sensitivityRatio,TDD:ie};var _a=[],Ma=[],ya=[],xa=[];_a.push(Le),Ma.push(Le),xa.push(Le),ya.push(Le);var Sa=function(e,a,r,t,o,i){return a?!e.allowSMB_with_high_temptarget&&e.temptargetSet&&o>100?(console.error("SMB disabled due to high temptarget of "+o),!1):!0===r.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?(r.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&&r.mealCOB?(r.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 "+r.mealCOB),!0):!0===e.enableSMB_after_carbs&&r.carbs?(r.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?(r.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&&t>=i?(console.error("Checking BG to see if High for SMB enablement."),console.error("Current BG",t," | High BG ",i),r.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)}(v,y,_,Le,$e,Qe),wa=v.enableUAM,Ca=0,Da=0;Ca=i(Ne-pa,1);var Fa=i(Ne-pa,1);csf=ua/v.carb_ratio,console.error("profile.sens:"+n(v.sens,v)+", sens:"+n(ua,v)+", CSF:"+i(csf,1));var Ia=i(30*csf*5/60,1);Ca>Ia&&(console.error("Limiting carb impact from "+Ca+" to "+Ia+"mg/dL/5m (30g/h)"),Ca=Ia);var Ga=3;sensitivityRatio&&(Ga/=sensitivityRatio);var Ta=Ga;if(_.carbs){Ga=Math.max(Ga,_.mealCOB/20);var Ua=i((new Date(We).getTime()-_.lastCarbTime)/6e4),Oa=(_.carbs-_.mealCOB)/_.carbs;Ta=i(Ta=Ga+1.5*Ua/60,1),console.error("Last carbs "+Ua+" minutes ago; remainingCATime:"+Ta+"hours; "+i(100*Oa,1)+"% carbs absorbed")}var Ra=Math.max(0,Ca/5*60*Ta/2)/csf,Aa=90,Pa=1;v.remainingCarbsCap&&(Aa=Math.min(90,v.remainingCarbsCap)),v.remainingCarbsFraction&&(Pa=Math.min(1,v.remainingCarbsFraction));var ja=1-Pa,Wa=Math.max(0,_.mealCOB-Ra-_.carbs*ja),ka=(Wa=Math.min(Aa,Wa))*csf*5/60/(Ta/2),qa=i(_.slopeFromMaxDeviation,2),Ea=i(_.slopeFromMinDeviation,2),La=Math.min(qa,-Ea/3),za=0;0===Ca?Da=0:!0===v.floating_carbs?(Da=Math.min(60*Ta/5/2,Math.max(0,_.carbs*csf/Ca)),za=Math.min(60*Ta/5/2,Math.max(0,_.mealCOB*csf/Ca)),_.carbs>0&&(s+=", Floating Carbs:, CID: "+i(Da,1)+", MealCarbs: "+i(_.carbs,1)+", Not Floating:, CID: "+i(za,1)+", MealCOB: "+i(_.mealCOB,1),console.error("Floating Carbs CID: "+i(Da,1)+" / MealCarbs: "+i(_.carbs,1)+" vs. Not Floating:"+i(za,1)+" / MealCOB:"+i(_.mealCOB,1)))):Da=Math.min(60*Ta/5/2,Math.max(0,_.mealCOB*csf/Ca)),console.error("Carb Impact:"+Ca+"mg/dL per 5m; CI Duration:"+i(5*Da/60*2,1)+"hours; remaining CI ("+Ta/2+"h peak):"+i(ka,1)+"mg/dL per 5m");var Na,Za,Ha,$a,Ja,Ka=999,Qa=999,Va=999,Xa=Le,Ya=999,er=999,ar=999,rr=999,tr=va,or=Le,ir=Le,nr=0,sr=[],lr=[];try{ca.forEach((function(e){var a=i(-e.activity*ua*5,2),r=i(-e.iobWithZeroTemp.activity*ua*5,2),t=Ca*(1-Math.min(1,Ma.length/12));if(!0==(1==se&&1==C.useNewFormula)){tr=Ma[Ma.length-1]+i(-e.activity*(1800/(F*de*Math.log(Math.max(Ma[Ma.length-1],39)/we+1)))*5,2)+t;var o=xa[xa.length-1]+i(-e.iobWithZeroTemp.activity*(1800/(F*de*Math.log(Math.max(xa[xa.length-1],39)/we+1)))*5,2);console.log("Dynamic ISF (Logarithmic Formula) )adjusted predictions for IOB and ZT: IOBpredBG: "+i(tr,2)+" , ZTpredBG: "+i(o,2))}else{tr=Ma[Ma.length-1]+a+t;o=xa[xa.length-1]+r}var n=Math.max(0,Math.max(0,Ca)*(1-_a.length/Math.max(2*Da,1))),s=Math.min(_a.length,12*Ta-_a.length),l=Math.max(0,s/(Ta/2*12)*ka);n+l,sr.push(i(l,0)),lr.push(i(n,0)),COBpredBG=_a[_a.length-1]+a+Math.min(0,t)+n+l;var m=Math.max(0,Fa+ya.length*La),u=Math.max(0,Fa*(1-ya.length/Math.max(36,1))),d=Math.min(m,u);if(d>0&&(nr=i(5*(ya.length+1)/60,1)),!0==(1==se&&1==C.useNewFormula))UAMpredBG=ya[ya.length-1]+i(-e.activity*(1800/(F*de*Math.log(Math.max(ya[ya.length-1],39)/we+1)))*5,2)+Math.min(0,t)+d,console.log("Dynamic ISF (Logarithmic Formula) adjusted prediction for UAM: UAMpredBG: "+i(UAMpredBG,2));else UAMpredBG=ya[ya.length-1]+a+Math.min(0,t)+d;Ma.length<48&&Ma.push(tr),_a.length<48&&_a.push(COBpredBG),ya.length<48&&ya.push(UAMpredBG),xa.length<48&&xa.push(o),COBpredBG<Ya&&(Ya=i(COBpredBG)),UAMpredBG<er&&(er=i(UAMpredBG)),tr<ar&&(ar=i(tr)),o<rr&&(rr=i(o));Ma.length>18&&tr<Ka&&(Ka=i(tr)),tr>or&&(or=tr),(Da||ka>0)&&_a.length>18&&COBpredBG<Qa&&(Qa=i(COBpredBG)),(Da||ka>0)&&COBpredBG>or&&(ir=COBpredBG),wa&&ya.length>12&&UAMpredBG<Va&&(Va=i(UAMpredBG)),wa&&UAMpredBG>or&&UAMpredBG}))}catch(e){console.error("Problem with iobArray. Optional feature Advanced Meal Assist disabled")}_.mealCOB&&(console.error("predCIs (mg/dL/5m):"+lr.join(" ")),console.error("remainingCIs: "+sr.join(" "))),Re.predBGs={},Ma.forEach((function(e,a,r){r[a]=i(Math.min(401,Math.max(39,e)))}));for(var mr=Ma.length-1;mr>12&&Ma[mr-1]===Ma[mr];mr--)Ma.pop();for(Re.predBGs.IOB=Ma,Ha=i(Ma[Ma.length-1]),xa.forEach((function(e,a,r){r[a]=i(Math.min(401,Math.max(39,e)))})),mr=xa.length-1;mr>6&&!(xa[mr-1]>=xa[mr]||xa[mr]<=$e);mr--)xa.pop();if(Re.predBGs.ZT=xa,i(xa[xa.length-1]),_.mealCOB>0&&(Ca>0||ka>0)){for(_a.forEach((function(e,a,r){r[a]=i(Math.min(401,Math.max(39,e)))})),mr=_a.length-1;mr>12&&_a[mr-1]===_a[mr];mr--)_a.pop();Re.predBGs.COB=_a,$a=i(_a[_a.length-1]),va=Math.max(va,i(_a[_a.length-1]))}if(Ca>0||ka>0){if(wa){for(ya.forEach((function(e,a,r){r[a]=i(Math.min(401,Math.max(39,e)))})),mr=ya.length-1;mr>12&&ya[mr-1]===ya[mr];mr--)ya.pop();Re.predBGs.UAM=ya,Ja=i(ya[ya.length-1]),ya[ya.length-1]&&(va=Math.max(va,i(ya[ya.length-1])))}Re.eventualBG=va}console.error("UAM Impact:"+Fa+"mg/dL per 5m; UAM Duration:"+nr+"hours"),Ka=Math.max(39,Ka),Qa=Math.max(39,Qa),Va=Math.max(39,Va),Na=i(Ka);var ur=_.mealCOB/_.carbs;Za=i(Va<999&&Qa<999?(1-ur)*UAMpredBG+ur*COBpredBG:Qa<999?(tr+COBpredBG)/2:Va<999?(tr+UAMpredBG)/2:tr),rr>Za&&(Za=rr),Xa=i(Xa=Da||ka>0?wa?ur*Ya+(1-ur)*er:Ya:wa?er:ar);var dr=Va;if(rr<sa)dr=(Va+rr)/2;else if(rr<$e){var cr=(rr-sa)/($e-sa);dr=(Va+(Va*cr+rr*(1-cr)))/2}else rr>Va&&(dr=(Va+rr)/2);if(dr=i(dr),_.carbs)if(!wa&&Qa<999)Na=i(Math.max(Ka,Qa));else if(Qa<999){var gr=ur*Qa+(1-ur)*dr;Na=i(Math.max(Ka,Qa,gr))}else Na=wa?dr:Xa;else wa&&(Na=i(Math.max(Ka,dr)));Na=Math.min(Na,Za),process.stderr.write("minPredBG: "+Na+" minIOBPredBG: "+Ka+" minZTGuardBG: "+rr),Qa<999&&process.stderr.write(" minCOBPredBG: "+Qa),Va<999&&process.stderr.write(" minUAMPredBG: "+Va),console.error(" avgPredBG:"+Za+" COB/Carbs:"+_.mealCOB+"/"+_.carbs),ir>Le&&(Na=Math.min(Na,ir)),Re.COB=_.mealCOB,Re.IOB=t.iob,Re.BGI=n(pa,v),Re.deviation=n(fa,v),Re.ISF=n(ua,v),Re.CR=i(v.carb_ratio,2),Re.target_bg=n($e,v),Re.TDD=i(ie,2),Re.reason=s+", COB: "+Re.COB+", Dev: "+Re.deviation+", BGI: "+Re.BGI+", CR: "+Re.CR+", Target: "+Re.target_bg+", minPredBG "+n(Na,v)+", minGuardBG "+n(Xa,v)+", IOBpredBG "+n(Ha,v),$a>0&&(Re.reason+=", COBpredBG "+n($a,v)),Ja>0&&(Re.reason+=", UAMpredBG "+n(Ja,v)),Re.reason+=tddReason;var hr=", mw: "+v.MW;"empty"==!v.MW&&(Re.reason+=hr),Re.reason+="; ";var pr=ba;pr<40&&(pr=Math.min(Xa,pr));var fr,br=sa-pr,vr=240,Br=240;if(_.mealCOB>0&&(Ca>0||ka>0)){for(mr=0;mr<_a.length;mr++)if(_a[mr]<Je){vr=5*mr;break}for(mr=0;mr<_a.length;mr++)if(_a[mr]<sa){Br=5*mr;break}}else{for(mr=0;mr<Ma.length;mr++)if(Ma[mr]<Je){vr=5*mr;break}for(mr=0;mr<Ma.length;mr++)if(Ma[mr]<sa){Br=5*mr;break}}Sa&&Xa<sa&&(console.error("minGuardBG "+n(Xa,v)+" projected below "+n(sa,v)+" - disabling SMB"),Sa=!1),void 0===v.maxDelta_bg_threshold&&(fr=.2),void 0!==v.maxDelta_bg_threshold&&(fr=Math.min(v.maxDelta_bg_threshold,.4)),He>fr*Le&&(console.error("maxDelta "+n(He,v)+" > "+100*fr+"% of BG "+n(Le,v)+" - disabling SMB"),Re.reason+="maxDelta "+n(He,v)+" > "+100*fr+"% of BG "+n(Le,v)+" - SMB disabled!, ",Sa=!1),console.error("BG projected to remain above "+n(Je,v)+" for "+vr+"minutes"),(Br<240||vr<60)&&console.error("BG projected to remain above "+n(sa,v)+" for "+Br+"minutes");var _r=Br,Mr=v.current_basal*ua*_r/60,yr=Math.max(0,_.mealCOB-.25*_.carbs),xr=(br-Mr)/csf-yr;Mr=i(Mr),xr=i(xr),console.error("naive_eventualBG:",ba,"bgUndershoot:",br,"zeroTempDuration:",_r,"zeroTempEffect:",Mr,"carbsReq:",xr),"Could not parse clock data"==_.reason?console.error("carbsReq unknown: Could not parse clock data"):xr>=v.carbsReqThreshold&&Br<=45&&(Re.carbsReq=xr,Re.reason+=xr+" add'l carbs req w/in "+Br+"m; ");var Sr=0;if(Le<sa&&t.iob<20*-v.current_basal/60&&Ne>0&&Ne>Ba)Re.reason+="IOB "+t.iob+" < "+i(20*-v.current_basal/60,2),Re.reason+=" and minDelta "+n(Ne,v)+" > expectedDelta "+n(Ba,v)+"; ";else if(Le<sa||Xa<sa)return Re.reason+="minGuardBG "+n(Xa,v)+"<"+n(sa,v),Sr=i(60*((br=$e-Xa)/ua)/v.current_basal),Sr=30*i(Sr/30),Sr=Math.min(120,Math.max(30,Sr)),M.setTempBasal(0,Sr,v,Re,r);if(v.skip_neutral_temps&&Re.deliverAt.getMinutes()>=55)return Re.reason+="; Canceling temp at "+Re.deliverAt.getMinutes()+"m past the hour. ",M.setTempBasal(0,0,v,Re,r);var wr=0,Cr=je;if(va<Je){if(Re.reason+="Eventual BG "+n(va,v)+" < "+n(Je,v),Ne>Ba&&Ne>0&&!xr)return ba<40?(Re.reason+=", naive_eventualBG < 40. ",M.setTempBasal(0,30,v,Re,r)):(e.delta>Ne?Re.reason+=", but Delta "+n(ke,v)+" > expectedDelta "+n(Ba,v):Re.reason+=", but Min. Delta "+Ne.toFixed(2)+" > Exp. Delta "+n(Ba,v),r.duration>15&&o(je,v)===o(r.rate,v)?(Re.reason+=", temp "+r.rate+" ~ req "+je+"U/hr. ",Re):(Re.reason+="; setting current basal of "+je+" as temp. ",M.setTempBasal(je,30,v,Re,r)));wr=i(wr=2*Math.min(0,(va-$e)/ua),2);var Dr=Math.min(0,(ba-$e)/ua);if(Dr=i(Dr,2),Ne<0&&Ne>Ba)wr=i(wr*(Ne/Ba),2);if(Cr=o(Cr=je+2*wr,v),r.duration*(r.rate-je)/60<Math.min(wr,Dr)-.3*je)return Re.reason+=", "+r.duration+"m@"+r.rate.toFixed(2)+" is a lot less than needed. ",M.setTempBasal(Cr,30,v,Re,r);if(void 0!==r.rate&&r.duration>5&&Cr>=.8*r.rate)return Re.reason+=", temp "+r.rate+" ~< req "+Cr+"U/hr. ",Re;if(Cr<=0){if((Sr=i(60*((br=$e-ba)/ua)/v.current_basal))<0?Sr=0:(Sr=30*i(Sr/30),Sr=Math.min(120,Math.max(0,Sr))),Sr>0)return Re.reason+=", setting "+Sr+"m zero temp. ",M.setTempBasal(Cr,Sr,v,Re,r)}else Re.reason+=", setting "+Cr+"U/hr. ";return M.setTempBasal(Cr,30,v,Re,r)}if(Ne<Ba&&(!y||!Sa))return e.delta<Ne?Re.reason+="Eventual BG "+n(va,v)+" > "+n(Je,v)+" but Delta "+n(ke,v)+" < Exp. Delta "+n(Ba,v):Re.reason+="Eventual BG "+n(va,v)+" > "+n(Je,v)+" but Min. Delta "+Ne.toFixed(2)+" < Exp. Delta "+n(Ba,v),r.duration>15&&o(je,v)===o(r.rate,v)?(Re.reason+=", temp "+r.rate+" ~ req "+je+"U/hr. ",Re):(Re.reason+="; setting current basal of "+je+" as temp. ",M.setTempBasal(je,30,v,Re,r));if(Math.min(va,Na)<Ke&&(!y||!Sa))return Re.reason+=n(va,v)+"-"+n(Na,v)+" in range: no temp required",r.duration>15&&o(je,v)===o(r.rate,v)?(Re.reason+=", temp "+r.rate+" ~ req "+je+"U/hr. ",Re):(Re.reason+="; setting current basal of "+je+" as temp. ",M.setTempBasal(je,30,v,Re,r));if(va>=Ke&&(Re.reason+="Eventual BG "+n(va,v)+" >= "+n(Ke,v)+", "),t.iob>Ve)return Re.reason+="IOB "+i(t.iob,2)+" > max_iob "+Ve,r.duration>15&&o(je,v)===o(r.rate,v)?(Re.reason+=", temp "+r.rate+" ~ req "+je+"U/hr. ",Re):(Re.reason+="; setting current basal of "+je+" as temp. ",M.setTempBasal(je,30,v,Re,r));(wr=i((Math.min(Na,va)-$e)/ua,2))>Ve-t.iob?(console.error("SMB limited by maxIOB: "+Ve-t.iob+" (. insulinReq: "+wr+" U)"),Re.reason+="max_iob "+Ve+", ",wr=Ve-t.iob):console.error("SMB not limited by maxIOB ( insulinReq: "+wr+" U)."),Cr=o(Cr=je+2*wr,v),wr=i(wr,3),Re.insulinReq=wr;var Fr=i((new Date(We).getTime()-t.lastBolusTime)/6e4,1);if(y&&Sa&&Le>sa){var Ir=i(_.mealCOB/v.carb_ratio,3);if(v.use_autoisf)Gr=v.smb_max_range_extension;else{console.error("autoISF disabled, SMB range extension disabled");var Gr=1}Gr>1&&console.error("SMB max range extended from default by factor "+Gr);var Tr=0;void 0===v.maxSMBBasalMinutes?(Tr=i(Gr*v.current_basal*30/60,1),console.error("profile.maxSMBBasalMinutes undefined: defaulting to 30m"),wr>Tr&&(console.error("SMB limited by maxBolus: "+Tr+" ( "+wr+" U)"),a)):t.iob>Ir&&t.iob>0?(console.error("IOB"+t.iob+"> COB"+_.mealCOB+"; mealInsulinReq ="+Ir),v.maxUAMSMBBasalMinutes?(console.error("profile.maxUAMSMBBasalMinutes: "+v.maxUAMSMBBasalMinutes+", profile.current_basal: "+v.current_basal),Tr=i(Gr*v.current_basal*v.maxUAMSMBBasalMinutes/60,1)):(console.error("profile.maxUAMSMBBasalMinutes undefined: defaulting to 30m"),Tr=i(30*v.current_basal/60,1)),wr>Tr?console.error("SMB limited by maxUAMSMBBasalMinutes [ "+v.maxUAMSMBBasalMinutes+"m ]: "+Tr+"U ( "+wr+"U )"):console.error("SMB is not limited by maxUAMSMBBasalMinutes. ( insulinReq: "+wr+"U )")):(console.error("profile.maxSMBBasalMinutes: "+v.maxSMBBasalMinutes+", profile.current_basal: "+v.current_basal),wr>(Tr=i(Gr*v.current_basal*v.maxSMBBasalMinutes/60,1))?console.error("SMB limited by maxSMBBasalMinutes: "+v.maxSMBBasalMinutes+"m ]: "+Tr+"U ( insulinReq: "+wr+"U )"):console.error("SMB is not limited by maxSMBBasalMinutes. ( insulinReq: "+wr+"U )"));var Ur=v.bolus_increment,Or=1/Ur,Rr=b(v,Le,$e);Rr>.5&&console.error("SMB Delivery Ratio increased from default 0.5 to "+i(Rr,2));var Ar=Math.min(wr*Rr,Tr);Ar=Math.floor(Ar*Or)/Or,Sr=i(60*(($e-(ba+Ka)/2)/ua)/v.current_basal),wr>0&&Ar<Ur&&(Sr=0);var Pr=0;Sr<=0?Sr=0:Sr>=30?(Sr=30*i(Sr/30),Sr=Math.min(60,Math.max(0,Sr))):(Pr=i(je*Sr/30,2),Sr=30),Re.reason+=" insulinReq "+wr,Ar>=Tr&&(Re.reason+="; maxBolus "+Tr),Sr>0&&(Re.reason+="; setting "+Sr+"m low temp of "+Pr+"U/h"),Re.reason+=". ";var jr=3;v.SMBInterval&&(jr=Math.min(10,Math.max(1,v.SMBInterval)));var Wr=i(jr-Fr,0),kr=i(60*(jr-Fr),0)%60;if(console.error("naive_eventualBG "+ba+","+Sr+"m "+Pr+"U/h temp needed; last bolus "+Fr+"m ago; maxBolus: "+Tr),Fr>jr?Ar>0&&(Re.units=Ar,Re.reason+="Microbolusing "+Ar+"U. "):Re.reason+="Waiting "+Wr+"m "+kr+"s to microbolus again. ",Sr>0)return Re.rate=Pr,Re.duration=Sr,Re}var qr=M.getMaxSafeBasal(v);return Cr>qr&&(Re.reason+="adj. req. rate: "+Cr+" to maxSafeBasal: "+i(qr,2)+", ",Cr=o(qr,v)),r.duration*(r.rate-je)/60>=2*wr?(Re.reason+=r.duration+"m@"+r.rate.toFixed(2)+" > 2 * insulinReq. Setting temp basal of "+Cr+"U/hr. ",M.setTempBasal(Cr,30,v,Re,r)):void 0===r.duration||0===r.duration?(Re.reason+="no temp, setting "+Cr+"U/hr. ",M.setTempBasal(Cr,30,v,Re,r)):r.duration>5&&o(Cr,v)<=o(r.rate,v)?(Re.reason+="temp "+r.rate+" >~ req "+Cr+"U/hr. ",Re):(Re.reason+="temp "+r.rate+"<"+Cr+"U/hr. ",M.setTempBasal(Cr,30,v,Re,r))}},6880:(e,a,r)=>{var t=r(6654);e.exports=function(e,a){var r=20;void 0!==a&&"string"==typeof a.model&&(t(a.model,"54")||t(a.model,"23"))&&(r=40);return e<1?Math.round(e*r)/r:e<10?Math.round(20*e)/20:Math.round(10*e)/10}},2705:(e,a,r)=>{var t=r(5639).Symbol;e.exports=t},9932:e=>{e.exports=function(e,a){for(var r=-1,t=null==e?0:e.length,o=Array(t);++r<t;)o[r]=a(e[r],r,e);return o}},9750:e=>{e.exports=function(e,a,r){return e==e&&(void 0!==r&&(e=e<=r?e:r),void 0!==a&&(e=e>=a?e:a)),e}},4239:(e,a,r)=>{var t=r(2705),o=r(9607),i=r(2333),n=t?t.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?o(e):i(e)}},531:(e,a,r)=>{var t=r(2705),o=r(9932),i=r(1469),n=r(3448),s=t?t.prototype:void 0,l=s?s.toString:void 0;e.exports=function e(a){if("string"==typeof a)return a;if(i(a))return o(a,e)+"";if(n(a))return l?l.call(a):"";var r=a+"";return"0"==r&&1/a==-Infinity?"-0":r}},7561:(e,a,r)=>{var t=r(7990),o=/^\s+/;e.exports=function(e){return e?e.slice(0,t(e)+1).replace(o,""):e}},1957:(e,a,r)=>{var t="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=t},9607:(e,a,r)=>{var t=r(2705),o=Object.prototype,i=o.hasOwnProperty,n=o.toString,s=t?t.toStringTag:void 0;e.exports=function(e){var a=i.call(e,s),r=e[s];try{e[s]=void 0;var t=!0}catch(e){}var o=n.call(e);return t&&(a?e[s]=r:delete e[s]),o}},2333:e=>{var a=Object.prototype.toString;e.exports=function(e){return a.call(e)}},5639:(e,a,r)=>{var t=r(1957),o="object"==typeof self&&self&&self.Object===Object&&self,i=t||o||Function("return this")();e.exports=i},7990:e=>{var a=/\s/;e.exports=function(e){for(var r=e.length;r--&&a.test(e.charAt(r)););return r}},6654:(e,a,r)=>{var t=r(9750),o=r(531),i=r(554),n=r(9833);e.exports=function(e,a,r){e=n(e),a=o(a);var s=e.length,l=r=void 0===r?s:t(i(r),0,s);return(r-=a.length)>=0&&e.slice(r,l)==a}},1469:e=>{var a=Array.isArray;e.exports=a},3218:e=>{e.exports=function(e){var a=typeof e;return null!=e&&("object"==a||"function"==a)}},7005:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},3448:(e,a,r)=>{var t=r(4239),o=r(7005);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==t(e)}},8601:(e,a,r)=>{var t=r(4841),o=1/0;e.exports=function(e){return e?(e=t(e))===o||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}},554:(e,a,r)=>{var t=r(8601);e.exports=function(e){var a=t(e),r=a%1;return a==a?r?a-r:a:0}},4841:(e,a,r)=>{var t=r(7561),o=r(3218),i=r(3448),n=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,l=/^0o[0-7]+$/i,m=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var a="function"==typeof e.valueOf?e.valueOf():e;e=o(a)?a+"":a}if("string"!=typeof e)return 0===e?e:+e;e=t(e);var r=s.test(e);return r||l.test(e)?m(e.slice(2),r?2:8):n.test(e)?NaN:+e}},9833:(e,a,r)=>{var t=r(531);e.exports=function(e){return null==e?"":t(e)}}},r={};function t(a){var o=r[a];if(void 0!==o)return o.exports;var i=r[a]={exports:{}};return e[a](i,i.exports,t),i.exports}t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var o=t(5546);freeaps_determineBasal=o})();
|