@zac-apps/helium 2.0.0-beta.13 → 2.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -143
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,143 +1 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
-
import { useState, useEffect } from 'react';
|
|
4
|
-
import { useImmer } from 'use-immer';
|
|
5
|
-
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
6
|
-
import Grid from '@mui/material/Grid';
|
|
7
|
-
import GraphsPanel from '@/helium/panels/GraphsPanel.js';
|
|
8
|
-
import CalculatorPanel from '@/helium/panels/CalculatorPanel.js';
|
|
9
|
-
import SpectrometerSetPanel from '@/helium/panels/SpectrometerSetPanel.js';
|
|
10
|
-
import EstimatedConsumptionPanel from '@/helium/panels/EstimatedConsumptionPanel.js';
|
|
11
|
-
import EstimationPanel from '@/helium/panels/EstimationPanel.js';
|
|
12
|
-
import FillTargetPanel from '@/helium/panels/FillTargetPanel.js';
|
|
13
|
-
import { AppTheme, PublicFetch, Progress, AppGrid } from '@zac-apps/commons';
|
|
14
|
-
import { HeliumContext } from '@/helium/HeliumContext.js';
|
|
15
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
16
|
-
|
|
17
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
-
var heliumLookupData = process.env.HELIUM_LOOKUP || {
|
|
20
|
-
lookup: {}
|
|
21
|
-
};
|
|
22
|
-
console.log("Helium Lookup Data:", heliumLookupData);
|
|
23
|
-
|
|
24
|
-
// Site config
|
|
25
|
-
var site = process.env.SITE_CONFIG || {};
|
|
26
|
-
console.log("Site Config:", site);
|
|
27
|
-
|
|
28
|
-
// Principal function
|
|
29
|
-
|
|
30
|
-
function Helium(props) {
|
|
31
|
-
var basePath = site.basePath || props.basePath || "";
|
|
32
|
-
|
|
33
|
-
// State
|
|
34
|
-
|
|
35
|
-
var _useImmer = useImmer(null),
|
|
36
|
-
_useImmer2 = _slicedToArray(_useImmer, 2),
|
|
37
|
-
heliumData = _useImmer2[0],
|
|
38
|
-
SetHeliumData = _useImmer2[1];
|
|
39
|
-
var _useState = useState(false),
|
|
40
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
-
levelsEdited = _useState2[0],
|
|
42
|
-
SetLevelsEdited = _useState2[1];
|
|
43
|
-
var _useState3 = useState(false),
|
|
44
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
|
-
preprocessed = _useState4[0],
|
|
46
|
-
SetPreprocessed = _useState4[1];
|
|
47
|
-
var _useState5 = useState(null),
|
|
48
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
49
|
-
heliumError = _useState6[0],
|
|
50
|
-
SetHeliumError = _useState6[1];
|
|
51
|
-
|
|
52
|
-
// Query Media size for responsive column wrapping
|
|
53
|
-
|
|
54
|
-
var matches = useMediaQuery(AppTheme.breakpoints.up("lg"));
|
|
55
|
-
var maxHeight = matches ? props.maxHeight || 1280 : 1000000;
|
|
56
|
-
var cardSize = matches ? 6 : 12;
|
|
57
|
-
var collapsed = !matches;
|
|
58
|
-
var bottomMargin = 1;
|
|
59
|
-
|
|
60
|
-
// fetch data
|
|
61
|
-
|
|
62
|
-
var fetchGraph = site.showGraphs ? PublicFetch({
|
|
63
|
-
url: basePath + "/graphdata.json"
|
|
64
|
-
}) : {};
|
|
65
|
-
PublicFetch({
|
|
66
|
-
url: basePath + "/helium.json",
|
|
67
|
-
SetState: SetHeliumData,
|
|
68
|
-
SetError: SetHeliumError
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Catch empty data
|
|
72
|
-
|
|
73
|
-
useEffect(function () {
|
|
74
|
-
if (heliumError) {
|
|
75
|
-
SetHeliumData(function (heliumData) {
|
|
76
|
-
heliumData.helium = {};
|
|
77
|
-
});
|
|
78
|
-
Object.keys(heliumLookupData.lookup).map(function (spec) {
|
|
79
|
-
SetHeliumData(function (heliumData) {
|
|
80
|
-
heliumData.helium[spec] = 0;
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
SetHeliumData(function (heliumData) {
|
|
84
|
-
heliumData.meta = {};
|
|
85
|
-
heliumData.meta.date = 0;
|
|
86
|
-
});
|
|
87
|
-
SetPreprocessed(true);
|
|
88
|
-
}
|
|
89
|
-
}, [heliumError]);
|
|
90
|
-
useEffect(function () {
|
|
91
|
-
if (heliumData !== null && heliumError === null) {
|
|
92
|
-
Object.keys(heliumLookupData.lookup).map(function (spec) {
|
|
93
|
-
SetHeliumData(function (heliumData) {
|
|
94
|
-
heliumData.helium[spec] = Number(heliumData.helium[spec]);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
SetPreprocessed(true);
|
|
98
|
-
}
|
|
99
|
-
}, [heliumData]);
|
|
100
|
-
if (!heliumData || !fetchGraph || !preprocessed) {
|
|
101
|
-
return /*#__PURE__*/jsx(Progress, {});
|
|
102
|
-
}
|
|
103
|
-
var graphDataMeta = fetchGraph.meta;
|
|
104
|
-
var graphData = _objectSpread({}, fetchGraph);
|
|
105
|
-
delete graphData.meta;
|
|
106
|
-
if (!graphDataMeta) {
|
|
107
|
-
graphDataMeta = {};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Define values to pass in Context
|
|
111
|
-
|
|
112
|
-
var contextCollection = {
|
|
113
|
-
heliumData: heliumData,
|
|
114
|
-
SetHeliumData: SetHeliumData,
|
|
115
|
-
levelsEdited: levelsEdited,
|
|
116
|
-
SetLevelsEdited: SetLevelsEdited,
|
|
117
|
-
heliumLookupData: heliumLookupData,
|
|
118
|
-
cardSize: cardSize,
|
|
119
|
-
collapsed: collapsed,
|
|
120
|
-
matches: matches,
|
|
121
|
-
bottomMargin: bottomMargin
|
|
122
|
-
};
|
|
123
|
-
return /*#__PURE__*/jsx(AppGrid, {
|
|
124
|
-
children: /*#__PURE__*/jsxs(HeliumContext.Provider, {
|
|
125
|
-
value: contextCollection,
|
|
126
|
-
children: [site.showGraphs ? /*#__PURE__*/jsx(GraphsPanel, {
|
|
127
|
-
graphData: graphData,
|
|
128
|
-
graphDataMeta: graphDataMeta
|
|
129
|
-
}) : null, /*#__PURE__*/jsxs(Grid, {
|
|
130
|
-
sx: {
|
|
131
|
-
display: "flex",
|
|
132
|
-
flexFlow: "column wrap",
|
|
133
|
-
maxHeight: maxHeight
|
|
134
|
-
},
|
|
135
|
-
children: [/*#__PURE__*/jsx(CalculatorPanel, {}), /*#__PURE__*/jsx(SpectrometerSetPanel, {}), /*#__PURE__*/jsx(EstimatedConsumptionPanel, {}), /*#__PURE__*/jsx(EstimationPanel, {}), /*#__PURE__*/jsx(FillTargetPanel, {})]
|
|
136
|
-
})]
|
|
137
|
-
})
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Import and export all components
|
|
142
|
-
|
|
143
|
-
export { Helium as default };
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import t,{createContext as n,useContext as i,useState as l,useEffect as a}from"react";import{useImmer as o}from"use-immer";import c from"@mui/material/useMediaQuery";import u from"@mui/material/Grid";import{AppTheme as s,AppTable as m,TableHeadCell as d,DivTitle as h,AppCard as p,ErrorAlert as f,Percentage as b,SpecSwitch as v,PublicFetch as y,Progress as g,AppGrid as O}from"@zac-apps/commons";import x from"moment";import j from"@mui/material/Paper";import{LineChart as S,Line as k,CartesianGrid as D,XAxis as w,Label as P,YAxis as M,ReferenceLine as z,ReferenceArea as C,Tooltip as E}from"recharts";import L from"@mui/material/ButtonGroup";import N from"@mui/material/Button";import F from"@mui/material/FormGroup";import H from"@mui/material/FormControlLabel";import A from"@mui/material/Switch";import I from"@mui/material/TableHead";import Y from"@mui/material/TableCell";import T from"@mui/material/TableRow";import G from"@mui/material/TableBody";import{jsx as B,jsxs as _}from"react/jsx-runtime";import K from"regression";import{mean as J,sqrt as V,sum as q}from"mathjs";import W from"@mui/material/IconButton";import R from"@mui/icons-material/Save";import U from"@mui/icons-material/Edit";import Q from"@mui/material/TextField";import X from"@mui/material/InputAdornment";import Z from"moment/moment.js";import $ from"@mui/material/Divider";import ee from"@mui/material/Typography";import re from"@mui/material/FormControl";import te from"@mui/material/Checkbox";import ne from"@babel/runtime/helpers/toConsumableArray";import ie from"@mui/material/Chip";import le from"@mui/icons-material/AddBox";import ae from"@mui/icons-material/Delete";var oe=n(null);function ce(e){var r=e.spec,t=e.estimatedBoiloff,n=e.estimatedError,l=i(oe).heliumLookupData.boilOff[r].toFixed(3)||"N/A";t=t.toFixed(3)||"N/A",n=n.toFixed(3)||"N/A";var a=Math.abs(t-l)<.01?t:B("strong",{style:{color:s.palette.primary.main},children:t});return _("div",{children:[B("h4",{children:"Boiloff coefficients (%/day)"}),B(u,{container:!0,children:_(m,{children:[B(I,{children:_(T,{children:[B(d,{children:"Estimated"}),B(d,{children:"Stored"})]})}),B(G,{children:_(T,{children:[_(Y,{children:[a," ",_("em",{style:{color:s.palette.secondary.main},children:["(±",n,")"]})]}),B(Y,{children:l})]})})]})})]})}function ue(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function se(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ue(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):ue(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function me(e){var n=e.data,a=e.height,o=e.width,c=e.spec,u=i(oe).heliumLookupData,m=function(e){var r=e.data;e.spec;for(var t,n,i=Number(r[r.length-1].level),l=r.length-1,a=r.length-1,o=Number(r[a].level),c=r.length-2;c>=0;c--){var u=Number(r[c].level);if(u>i&&(o=u,a=c),u<o)break}a>=r.length-45&&(l=a-1,i=Number(r[l].level));for(var s=l-1,m=Number(r[s].level),d=s,h=s-1;h>=0;h--){var p=Number(r[h].level);if(p>m&&(m=p,d=h),p<m-1||p>=90)break}for(var f=[],b=d;b<=s;b++)f.push([b,Number(r[b].level)]);var v=K.linear(f,{precision:6});t=v.equation[0],n=v.equation[1];for(var y=[],g=d;g<=s;g++)y.push([g,g*t+n]);var O=J(f.map(function(e){return e[0]})),x=V(1/(y.length-2)*q(f.map(function(e,r){return Math.pow(e[1]-y[r][1],2)}))/q(f.map(function(e,r){return Math.pow(e[0]-O,2)})));return{slope:t,intercept:n,slopeError:x}}(se({},{data:n,spec:c})),d=m.slope,h=m.intercept,p=m.slopeError,f=function(e){var r=e.active,t=e.payload,n=e.label;if(r&&t&&t.length){var i=x(t[0].payload.date,"ddd MMM D HH:mm:ss YYYY").format("LL");return _("div",{style:{border:"solid 1px "+s.palette.secondary.main,padding:"0.75em",backgroundColor:"#ffffffaa"},children:[B("strong",{children:i}),B("br",{}),_("em",{children:["(",n," days ago)"]}),B("br",{}),_("strong",{style:{color:s.palette.primary.main},children:[t[0].value," %"]})]})}};function b(e){var r=e.value;return B(N,{onClick:function(){return O(r)},color:r===g?"primary":"secondary",variant:r===g?"contained":"outlined",size:"small",children:r})}var v=l(90),y=r(v,2),g=y[0],O=y[1],j=l(!0),I=r(j,2),Y=I[0],T=I[1],G=l(!1),W=r(G,2),R=W[0],U=W[1],Q=(n||[]).map(function(e){return se(se({},e),{},{days:-x(e.date,"ddd MMM D HH:mm:ss YYYY").diff(x(),"days")})}),X=0;Q.length>0&&(X=x().diff(x(Q[Q.length-1].date,"ddd MMM D HH:mm:ss YYYY"),"days"));var Z=R?Q.map(function(e){var r=e.days,t=e.level,n=d*(Q.length-r+X)+h;return{date:e.date,days:r,level:t,estimate:n}}):Q,$=Z.slice(Math.max(Z.length-g,0)),ee=R?s.palette.grey[300]:s.palette.primary.main;return _(t.Fragment,{children:[_(S,{height:a,width:o,data:$,margin:{top:5,right:20,bottom:25,left:0},children:[B(k,{dataKey:"level",stroke:ee,fill:ee,type:"linear",dot:{r:1.5}}),R?B(k,{dataKey:"estimate",stroke:s.palette.action.main,type:"monotone",strokeDasharray:"5 5",strokeWidth:2,dot:!1}):null,B(D,{stroke:s.palette.divider,strokeDasharray:"5 5"}),B(w,{dataKey:"days",interval:g<15?1:Math.round(g/3),children:B(P,{value:"Days ago",offset:1,position:"bottom"})}),B(M,{dataKey:"level",unit:"%",type:"number",domain:[0,100]}),Y?_(t.Fragment,{children:[B(z,{y:u.minima[c],stroke:s.palette.secondary.main,strokeDasharray:3}),B(C,{y1:u.minima[c],y2:0,stroke:"none",stro:!0,fill:s.palette.secondary.main,fillOpacity:.1})]}):null,B(E,{content:B(f,{})})]}),_(L,{disableElevation:!0,variant:"outlined",fullWidth:!0,color:"secondary","aria-label":"contained primary button group",sx:{justifySelf:"center",px:5},size:"small",children:[B(b,{value:7}),B(b,{value:30}),B(b,{value:90}),B(b,{value:180}),B(b,{value:365})]}),_(F,{children:[B(H,{control:B(A,{label:"Show Minimum",checked:Y,onChange:function(){return T(!Y)}}),label:"Show Minimum",sx:{justifyContent:"center"}}),B(H,{control:B(A,{label:"Show Estimate",checked:R,onChange:function(){return U(!R)}}),label:"Show Estimate",sx:{justifyContent:"center"}})]}),B(ce,{spec:c,estimatedBoiloff:d,estimatedError:p})]})}function de(e){var r=e.graphData,n=e.graphDataMeta,l=e.matches,a=l?250:200,o=l?300:280,c=i(oe).heliumLookupData;return Object.keys(r).forEach(function(e){c.boilOff[e]||delete r[e]}),r.error?_(t.Fragment,{children:[B(h,{children:B("strong",{children:"Helium level monitoring"})}),B(u,{sx:{display:"flex",justifyContent:"center"},children:B("em",{children:"No graph data available"})})]}):_(t.Fragment,{children:[_(h,{children:[B("strong",{children:"Helium level monitoring"})," ",_("em",{children:["(updated ",x(n.date).fromNow(),")"]})]}),B(u,{container:!0,sx:{display:"flex",justifyContent:"center"},children:Object.keys(r).map(function(e){return _(j,{sx:{display:"flex",flexDirection:"column",justifyItems:"center",stroke:s.palette.divider,px:2,paddingBottom:2,margin:2},children:[B("h4",{children:e}),B(me,{data:r[e],height:a,width:o,spec:e})]},"graph_"+e)})})]})}function he(e){var r=e.graphData,t=e.graphDataMeta,n=i(oe),l=n.collapsed,a=n.matches;return B(p,{title:"Helium Graphs",size:12,collapsed:l,children:B(de,{graphData:r,graphDataMeta:t,matches:a})})}function pe(e){var n=e.input,i=e.SetInput,a=e.error,o=e.SetError,c=e.minValue,u=e.maxValue,s=e.adornment,m=e.size,d=l(""),h=r(d,2),p=h[0],b=h[1],v=l(!1),y=r(v,2),g=y[0],O=y[1],x={};return"small"===m&&(x={maxWidth:75}),_(t.Fragment,{children:[B(Q,{size:"small",sx:x,onChange:function(e){return function(e){var r=!1,t=e.target.value;t.match(/[0-9-]*/)[0]&&t.match(/[0-9-]*/)[0]===t||(r=!0,b("Input is not numerical.")),(t>u||t<c)&&(r=!0,b("Input is outside allowed boundaries.")),i(t),o(r),O(r)}(e)},value:n,error:a,inputProps:{inputMode:"numeric"},InputProps:{endAdornment:B(X,{position:"end",children:s})}}),B(f,{alert:g,SetAlert:O,message:p})]})}function fe(e){var r=e.spec,t=e.value,n=i(oe).heliumLookupData.lookup;return t=t<0||!t?0:Number(t),n[r].find(function(e){return e.level===t}).liters}function be(e){var r=e.spec,t=e.value,n=i(oe).heliumLookupData.lookup;((t=Number(t)||0)<0||!t)&&(t=0);var l=Math.max.apply(null,n[r].map(function(e){return e.liters}))-n[r].find(function(e){return e.level===t}).liters;return l=Math.round(10*l)/10}function ve(e){var t=e.spec,n=i(oe),a=n.heliumLookupData.lookup,o=n.heliumData,c=n.SetHeliumData,u=n.SetLevelsEdited,s=Number(o.helium[t])||0,m=Math.max.apply(null,a[t].map(function(e){return e.level})),d=l(!1),h=r(d,2),p=h[0],f=h[1],v=l(s),y=r(v,2),g=y[0],O=y[1],x=l(!1),j=r(x,2),S=j[0],k=j[1];return _(Y,p?{children:[B(pe,{input:g,SetInput:O,error:S,SetError:k,minValue:0,maxValue:m,adornment:"%",size:"small"}),B(W,{disabled:S,onClick:function(){c(function(e){e.helium[t]=Number(g)}),f(!p),u(!0)},children:B(R,{})})]}:{children:[b(s,!0),B(W,{size:"small",onClick:function(){return f(!p)},children:B(U,{})})]})}function ye(){var e=i(oe),r=e.heliumData;if(e.SetHeliumData,e.SetLevelsEdited,0===r.helium.length)return B(u,{children:B("em",{children:"No Helium data found."})});var t=Object.keys(r.helium).reduce(function(e,t){return e+be({spec:t,value:r.helium[t]})},0);return t=Math.round(10*t)/10,_(m,{children:[B(I,{children:_(T,{children:[B(d,{children:"Spectrometer"}),_(d,{children:["Helium level",B("br",{}),"[%]"]}),_(d,{children:["Helium level",B("br",{}),"[liters]"]}),_(d,{children:["Diff. to maximum",B("br",{}),"[liters]"]})]})}),B(G,{children:Object.keys(r.helium).map(function(e){return _(T,{children:[B(Y,{children:e}),B(ve,{spec:e}),B(Y,{children:B(fe,{spec:e,value:r.helium[e]})}),B(Y,{children:B("strong",{children:B(be,{spec:e,value:r.helium[e]})})})]},e+"_entry")})}),B("tfoot",{children:_(T,{children:[B(Y,{children:B("strong",{children:"Sum"})}),B(Y,{}),B(Y,{}),B(Y,{children:B("strong",{children:t})})]})})]})}function ge(){return i(oe).levelsEdited?_(t.Fragment,{children:[", ",B("strong",{children:"edited"})]}):null}function Oe(){var e=i(oe),r=e.heliumData;return e.levelsEdited,_(p,{title:"Helium Calculator",size:e.cardSize,collapsed:e.collapsed,sx:{mb:e.bottomMargin},children:[B(u,{children:_(h,{children:[B("strong",{children:"Current levels"})," ",_("em",{children:[r.meta.date||0!==r.meta.date?"(updated "+x(r.meta.date).fromNow()+")":"(manual)",B(ge,{})]})]})}),B(u,{children:B(ye,{})})]})}function xe(e){var n=e.limit,i=e.SetLimit,a=e.error,o=e.SetError,c=l(n),u=r(c,2),s=u[0],m=u[1],d=l(!1),h=r(d,2),p=h[0],f=h[1];return _(t.Fragment,p?{children:[B(pe,{input:s,SetInput:m,error:a,SetError:o,size:"medium",adornment:"L"})," ",B(W,{disabled:a,size:"small",onClick:function(){f(!p),i(Number(s))},children:B(R,{})})]}:{children:[n," L"," ",B(W,{size:"small",onClick:function(){return f(!p)},children:B(U,{})})]})}function je(e){var r=e.specs,t=e.SetSpecs;function n(e){t(function(r){Object.keys(r).map(function(t){return r[t]=e})})}return _(re,{children:[B($,{textAlign:"left",children:B("strong",{children:"Select spectrometers"})}),_(F,{row:!0,sx:{px:2},children:[Object.keys(r).map(function(e){return B(H,{control:B(te,{size:"small"}),checked:r[e],onChange:function(){return t(function(r){r[e]=!r[e]})},label:e},e+"_check")})," ",B(N,{size:"small",onClick:function(){return n(!0)},children:"all"})," "," "," ",B(N,{size:"small",onClick:function(){return n(!1)},children:"none"})]})]})}function Se(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function ke(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Se(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Se(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function De(e){var r=e.children,t=e.title;return B(u,{children:_(m,{children:[B(I,{children:B(T,{children:B(d,{children:t})})}),B(G,{children:B(T,{children:B(Y,{children:r})})})]})})}function we(e){var r=e.minPair;if(0!==r.length){var t=new Date;t.setDate(t.getDate()+r[2]);var n=Z(t).format("ll");return _(De,{title:"Pair",children:[B("strong",{children:r[0]})," and ",B("strong",{children:r[1]})," ","in ",_("strong",{children:[r[2]," days"]})," (",n,")"]})}return B(De,{title:"Pair",children:B("em",{children:"No spectrometer pair reaches the target value."})})}function Pe(e){var r=e.minTriple;if(0!==r.length){var t=new Date;t.setDate(t.getDate()+r[3]);var n=Z(t).format("ll");return _(De,{title:"Triple",children:[B("strong",{children:r[0]}),", ",B("strong",{children:r[1]}),", and ",B("strong",{children:r[2]})," in"," ",_("strong",{children:[r[3]," days"]})," (",n,")"]})}return B(De,{title:"Triple",children:B("p",{children:B("em",{children:"No spectrometer triple reaches the target value."})})})}function Me(){var n=i(oe),a=n.heliumLookupData,c=n.heliumData,s=a.boilOff,m={};Object.keys(s).map(function(r){return m=ke(ke({},m),{},e({},r,!0))});var d=o(m),h=r(d,2),p=h[0],f=h[1],b=Object.keys(p).filter(function(e){return p[e]}),v=l(!1),y=r(v,2),g=y[0],O=y[1],x=l(100),j=r(x,2),S=j[0],k=j[1],D=function(e){var r=e.currSpecs,t=e.heliumData,n=e.boilOff,i=e.limit,l=[];r.map(function(e){r.map(function(r){e!==r&&l.push([e,r].sort())})}),l=Array.from(new Set(l.map(JSON.stringify)),JSON.parse);var a=[],o=function(){var e=1,r=0;a.push(l[c]);do{r=l[c].reduce(function(r,i){var l=Math.round(t.helium[i]+e*n[i]);return l<0&&(l=0),r+be({value:l,spec:i})},0),e++}while(r<i&&e<300);a[c].push(e),a[c].push(r),a[c].push(r>i)};for(var c in l)o();var u=[];switch((a=a.filter(function(e){return e[4]})).length){case 0:u=[];break;case 1:u=ne(a);break;default:u=a.reduce(function(e,r){return r[2]<e[2]?r:e})}return u.flat()}(ke({},{currSpecs:b,heliumData:c,boilOff:s,limit:S})),w=function(e){var r=e.currSpecs,t=e.heliumData,n=e.boilOff,i=e.limit,l=[];r.map(function(e){r.map(function(t){r.map(function(r){e!==t&&t!==r&&r!==e&&l.push([e,t,r].sort())})})}),l=Array.from(new Set(l.map(JSON.stringify)),JSON.parse);var a=[],o=function(){var e=1,r=0;a.push(l[c]);do{r=l[c].reduce(function(r,i){var l=Math.round(t.helium[i]+e*n[i]);return l<0&&(l=0),r+be({value:l,spec:i})},0),e++}while(r<i&&e<300);a[c].push(e),a[c].push(r),a[c].push(r>i)};for(var c in l)o();var u=[];switch((a=a.filter(function(e){return e[5]})).length){case 0:u=[];break;case 1:u=ne(a);break;default:u=a.reduce(function(e,r){return r[3]<e[3]?r:e})}return u.flat()}(ke({},{currSpecs:b,heliumData:c,boilOff:s,limit:S}));return B(t.Fragment,{children:_(u,{container:!0,columns:{xs:6,md:12},children:[_(u,{sx:{px:2},size:6,children:[B($,{textAlign:"left",children:B("strong",{children:"Find earliest set of spectrometers requiring"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:B(ee,{variant:"h4",children:B(xe,{limit:S,SetLimit:k,error:g,SetError:O})})}),B(u,{children:B(je,{specs:p,SetSpecs:f})})]}),_(u,{sx:{px:2},size:6,children:[B($,{textAlign:"left",children:B("strong",{children:"Result"})}),_(u,{sx:{px:3},children:[B(we,{minPair:D}),B(Pe,{minTriple:w})]})]})]})})}function ze(){var e=i(oe);return B(p,{title:"Spectrometer Set",size:e.cardSize,collapsed:e.collapsed,sx:{mb:e.bottomMargin},children:B(u,{children:B(Me,{})})})}function Ce(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function Ee(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ce(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Ce(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function Le(){var e=i(oe).heliumLookupData,r=e.boilOff,n=e.lookup,l=[];return Object.keys(n).map(function(e){return l.push({name:e,liters:(n[e].filter(function(e){return 100===e.level})[0].liters-n[e].filter(function(e){return 50===e.level})[0].liters).toFixed(1),days:(-50/r[e]).toFixed(1)})}),l=l.map(function(e){return Ee(Ee({},e),{},{perDay:e.liters/e.days,perMonth:(e.liters/e.days*30).toFixed(1),perYear:(e.liters/e.days*365).toFixed(1)})}),_(t.Fragment,{children:[B("p",{children:"Helium consumption estimated based on lookup values."}),_(m,{children:[B(I,{children:_(T,{children:[B(d,{}),l.map(function(e){return B(d,{children:e.name},"Head"+e.name)}),B(d,{children:"Sum"})]})}),_(G,{children:[_(T,{children:[B(Y,{children:"per month"}),l.map(function(e){return _(Y,{children:[e.perMonth," L ",B("br",{}),"(",(.79*e.perMonth).toFixed(2)," m",B("sup",{children:"3"})," Gas)"]},"perMonth"+e.name)}),B(Y,{children:_("strong",{children:[l.reduce(function(e,r){return e+Number(r.perMonth)},0).toFixed(1)," ","L",B("br",{}),"(",(.79*l.reduce(function(e,r){return e+Number(r.perMonth)},0)).toFixed(2)," ","m",B("sup",{children:"3"})," Gas)"]})})]}),_(T,{children:[B(Y,{rowSpan:2,children:"per year"}),l.map(function(e){return _(Y,{children:[e.perYear," L ",B("br",{}),"(",(.79*e.perYear).toFixed(2)," m",B("sup",{children:"3"})," ","Gas)"]},"perYear"+e.name)}),B(Y,{children:_("strong",{children:[l.reduce(function(e,r){return e+Number(r.perYear)},0).toFixed(1)," ","L",B("br",{}),"(",(.79*l.reduce(function(e,r){return e+Number(r.perYear)},0)).toFixed(2)," ","m",B("sup",{children:"3"})," Gas)"]})})]})]})]})]})}function Ne(){var e=i(oe),r=e.cardSize,t=e.collapsed;return B(p,{title:"Estimated Consumption",size:r,collapsed:t,sx:{mb:e.bottomMargin},children:B(u,{children:B(Le,{})})})}function Fe(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function He(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fe(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Fe(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}var Ae=s.palette.primary.main,Ie=s.palette.primary.contrastText,Ye=s.palette.warning.main;function Te(e){var r=e.value,t=e.days,n=e.spec,l=i(oe).heliumLookupData,a=l.boilOff,o=l.minima,c=Math.round(r+t*a[n]);c<0&&(c=0);var u=fe({value:c,spec:n}),s=be({value:c,spec:n}),m={};return c<o[n]-30*a[n]?m={backgroundColor:Ae,color:Ie}:c<o[n]-60*a[n]&&(m={color:Ye}),_(Y,{sx:m,children:[b(c,!0)," ",B("br",{}),u," L",B("br",{}),_("strong",{children:[s," L"]})]})}function Ge(r){var t=r.currHeliumData,n=r.days,l=i(oe).heliumLookupData.boilOff,a={};Object.keys(t).map(function(r){return a=He(He({},a),{},e({},r,Math.round(t[r]+n*l[r]))),null});var o=Object.keys(a).reduce(function(e,r){return e+be({spec:r,value:a[r]})},0);return o=Math.round(10*o)/10,B(Y,{children:_("strong",{children:[o," L"]})})}function Be(e){var t=e.days,n=e.increments,i=e.SetIncrements,a=e.dates,o=l(!1),c=r(o,2),u=c[0],s=c[1],m=l(t),d=r(m,2),h=d[0],p=d[1],f=l(!1),b=r(f,2),v=b[0],y=b[1];return _(Y,u?{children:[a[t]," ",B("br",{}),B(pe,{input:h,SetInput:p,error:v,SetError:y,size:"small"}),B("br",{}),B(W,{disabled:v,size:"small",onClick:function(){s(!u),i(n.map(function(e){return e===t?Number(h):e}))},children:B(R,{})}),B(W,{size:"small",onClick:function(){return i(n.filter(function(e){return e!==t}))},children:B(ae,{})})]}:{children:[a[t]," ",B("br",{})," in ",t," days ",B("br",{}),B(W,{size:"small",onClick:function(){return s(!u)},children:B(U,{})}),B(W,{size:"small",onClick:function(){return i(n.filter(function(e){return e!==t}))},children:B(ae,{})})]})}function _e(e){var r=e.increments,n=e.SetIncrements,i=e.currHeliumData,l=e.dates;return B(t.Fragment,{children:r.map(function(e){return _(T,{children:[B(Be,{days:e,increments:r,SetIncrements:n,dates:l}),Object.keys(i).map(function(r){return B(Te,{value:i[r],days:e,spec:r},r+"_progentry")}),B(Ge,{currHeliumData:i,days:e})]},e+"_incr")})})}function Ke(e){var n=e.increments,i=e.SetIncrements,a=l(""),o=r(a,2),c=o[0],s=o[1],m=l(!1),d=r(m,2),h=d[0],p=d[1];return _(t.Fragment,{children:[B($,{textAlign:"left",children:B("strong",{children:"Add prediction row"})}),_(u,{children:[B(pe,{input:c,SetInput:s,error:h,SetError:p,adornment:"days",size:"medium"}),B(W,{disabled:h,onClick:function(){i([Number(c)].concat(ne(n)))},children:B(le,{})})]})]})}function Je(){var t=i(oe),n=t.heliumLookupData,a=t.heliumData,c=n.minima,s={};Object.keys(a.helium).map(function(r){return s=He(He({},s),{},e({},r,!0))});var h=o(s),p=r(h,2),f=p[0],b=p[1],v=l([14,30,60,90]),y=r(v,2),g=y[0],O=y[1],j={};Object.keys(f).filter(function(e){return f[e]}).map(function(r){return j=He(He({},j),{},e({},r,a.helium[r]))});var S={};for(var k in g){var D=new Date;D.setDate(D.getDate()+g[k]),S=He(He({},S),{},e({},g[k],x(D).format("ll")))}return _(u,{container:!0,columns:{xs:6,sm:12},children:[B(u,{size:6,children:B(je,{specs:f,SetSpecs:b})}),B(u,{size:6,children:B(Ke,{increments:g,SetIncrements:O})}),B(u,{size:12,children:_(m,{children:[_(I,{children:[_(T,{children:[B(d,{}),Object.keys(j).map(function(e){return _(d,{children:[e,B("br",{}),"(",c[e]," %)"]},e+"_th")}),B(d,{children:"Sum"})]}),_(T,{children:[B(d,{}),B(d,{align:"center",colSpan:Object.keys(f).length+1,children:B("em",{children:"[%], Liters, L. to max"})})]})]}),B(G,{children:B(_e,{increments:g,SetIncrements:O,dates:S,currHeliumData:j})})]})}),_(u,{sx:{display:"flex",justifyContent:"center",alignItems:"center",pt:2},size:12,children:[B(ie,{sx:{backgroundColor:Ae,color:Ie,mx:1},label:"Minimum in less than 30 days"}),B(ie,{sx:{color:Ye,mx:1},variant:"outlined",label:"Minimum in less than 60 days"})]})]})}function Ve(){var e=i(oe);return B(p,{title:"Helium Estimation",size:e.cardSize,sx:{mb:e.bottomMargin},children:B(Je,{})})}function qe(){var e=i(oe),n=e.heliumLookupData,a=e.heliumData,o=n.boilOff,c=n.lookup,m=l(!1),d=r(m,2),h=d[0],p=d[1],f=l(25),b=r(f,2),y=b[0],g=b[1],O=l(Object.keys(c)[0]),x=r(O,2),j=x[0],S=x[1],k=a.helium[j],D=fe({value:k,spec:j}),w=function(e){var r=e.spec,t=e.value,n=i(oe).heliumLookupData.lookup,l=0;if((t=t<0||!t?0:Number(t))>n[r].find(function(e){return 100===e.level}).liters)l=100;else{var a=n[r].reduce(function(e,r){return Math.abs(r.liters-t)<Math.abs(e.liters-t)?r:e}).liters;l=n[r].find(function(e){return e.liters===a}).level}return l}({value:D+y,spec:j});return B(t.Fragment,{children:_(u,{container:!0,columns:{xs:6,md:12},children:[_(u,{sx:{px:2},size:6,children:[B($,{textAlign:"left",children:B("strong",{children:"Select Spectrometer"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:B(v,{setup:o,spec:j,SetSpec:S})})]}),_(u,{sx:{px:2},size:6,children:[B($,{textAlign:"left",children:B("strong",{children:"Current status"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:_(ee,{variant:"h4",children:[k," % (",D," L)"]})})]}),_(u,{sx:{px:2},size:6,children:[B($,{textAlign:"left",children:B("strong",{children:"Helium fill amount"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:B(ee,{variant:"h4",children:B(xe,{error:h,SetError:p,limit:y,SetLimit:g})})})]}),_(u,{sx:{px:2},size:6,children:[B($,{textAlign:"left",children:B("strong",{children:"After filling"})}),B(u,{sx:{padding:2,display:"flex",justifyContent:"center"},children:B(ee,{variant:"h4",children:_("em",{style:{color:s.palette.warning.main},children:["~ ",w," % (",fe({value:w,spec:j})," L)"]})})})]})]})})}function We(){var e=i(oe);return B(p,{title:"Fill Target",size:e.cardSize,sx:{mb:e.bottomMargin},children:B(qe,{})})}function Re(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}var Ue=process.env.HELIUM_LOOKUP||{lookup:{}};console.log("Helium Lookup Data:",Ue);var Qe=process.env.SITE_CONFIG||{};function Xe(t){var n=Qe.basePath||t.basePath||"",i=o(null),m=r(i,2),d=m[0],h=m[1],p=l(!1),f=r(p,2),b=f[0],v=f[1],x=l(!1),j=r(x,2),S=j[0],k=j[1],D=l(null),w=r(D,2),P=w[0],M=w[1],z=c(s.breakpoints.up("lg")),C=z?t.maxHeight||1280:1e6,E=z?6:12,L=!z,N=Qe.showGraphs?y({url:n+"/graphdata.json"}):{};if(y({url:n+"/helium.json",SetState:h,SetError:M}),a(function(){P&&(h(function(e){e.helium={}}),Object.keys(Ue.lookup).map(function(e){h(function(r){r.helium[e]=0})}),h(function(e){e.meta={},e.meta.date=0}),k(!0))},[P]),a(function(){null!==d&&null===P&&(Object.keys(Ue.lookup).map(function(e){h(function(r){r.helium[e]=Number(r.helium[e])})}),k(!0))},[d]),!d||!N||!S)return B(g,{});var F=N.meta,H=function(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Re(Object(n),!0).forEach(function(t){e(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Re(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}({},N);delete H.meta,F||(F={});var A={heliumData:d,SetHeliumData:h,levelsEdited:b,SetLevelsEdited:v,heliumLookupData:Ue,cardSize:E,collapsed:L,matches:z,bottomMargin:1};return B(O,{children:_(oe.Provider,{value:A,children:[Qe.showGraphs?B(he,{graphData:H,graphDataMeta:F}):null,_(u,{sx:{display:"flex",flexFlow:"column wrap",maxHeight:C},children:[B(Oe,{}),B(ze,{}),B(Ne,{}),B(Ve,{}),B(We,{})]})]})})}console.log("Site Config:",Qe);export{Xe as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zac-apps/helium",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.15",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"rollup": "node_modules/rollup/dist/rollup.js",
|
|
6
6
|
"dev": "next dev",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
43
43
|
"@rollup/plugin-json": "^6.1.0",
|
|
44
44
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
45
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
45
46
|
"@semantic-release/git": "^10.0.1",
|
|
46
47
|
"@semantic-release/gitlab": "^13.2.9",
|
|
47
48
|
"@semantic-release/npm": "^13.1.2",
|