import{TableBody_default as e,TableRow_default as t,Table_default as n}from"./TableRow-zQ6IbNgB.js";import{TableContainer_default as r}from"./TableContainer-DLP0G0fV.js";import{TableHead_default as i}from"./TableHead-DLuSQxsL.js";import{Button_default as a,CircularProgress_default as o,Fragment as s,Paper_default as c,TableCell_default as l,__toESM as u,fetchLookupTables as d,find_default as f,getLadleOverviewTable as p,get_default as m,isNil_default as h,jsx as g,jsxs as _,require_react as v,setLadleForModify as y,useAppDispatch as b,useAppSelector as x}from"./index-BSpgqPAY.js";import"./root-type.enum-Bd2G-woW.js";import"./component-BwlgCS8y.js";import{metricColors as S}from"./metric-colors.data-DKno4zcw.js";import"./change-ladle.modal-5bBroKBd.js";import"./location-selector-qczRWIZb.js";import"./RootStateSelector-DHW4USM_.js";import{RootSetStateModalComponent as C}from"./root-set-state-modal.component-CU1-qY-J.js";const w=[{componentTypeId:211,name:`Barrel`,metrics:[{metricTypeId:203,name:`Heats`},{metricTypeId:204,name:`Min`}]},{componentTypeId:227,name:`SlagLine`,metrics:[{metricTypeId:210,name:`Heats`},{metricTypeId:204,name:`Min`}]},{componentTypeId:216,name:`Coll Nozzle`,metrics:[{metricTypeId:210,name:`Heats`}]},{componentTypeId:220,name:`Plate`,metrics:[{metricTypeId:210,name:`Heats`}]},{componentTypeId:229,name:`Upper Nozzle`,metrics:[{metricTypeId:210,name:`Heats`}]},{componentTypeId:202,name:`Plug1`,metrics:[{metricTypeId:203,name:`Heats`},{metricTypeId:205,name:`Min`}]},{componentTypeId:203,name:`Plug1 Block`,metrics:[{metricTypeId:205,name:`Min`}]},{componentTypeId:205,name:`Plug2`,metrics:[{metricTypeId:203,name:`Heats`},{metricTypeId:205,name:`Min`}]},{componentTypeId:206,name:`Plug2 Block`,metrics:[{metricTypeId:205,name:`Min`}]}];var T=u(v());const E=({metricType:e,componentType:t,root:n})=>{let r=(0,T.useMemo)(()=>{var r;let i=(r=f(n.components,e=>e.componentTypeId===t.componentTypeId))?.metrics;return f(i,t=>t.metricTypeId===e.metricTypeId)},[n]);if(h(r))return g(l,{},`root-${n.rootId}-${t.name}-${e.name}`);let i=h(r?.value)?``:Math.round(r.value),a=r?.metricState==1?``:m(S,r?.metricState,`rgba(0,0,0,0)`);return g(l,{style:{backgroundColor:a,border:`1px solid #C0C0C0`,color:Number.isNaN(i)||i==0?`darkgray`:`black`},className:`text-center`,children:i===``?``:new Intl.NumberFormat().format(i)},`root-${n.rootId}-${t.name}-${e.name}`)},D=({root:e})=>{let t=e.supervisorInstructions?`Supervisor comments: ${e.supervisorInstructions}`:``,n=e.workerComments?`Operator comments: ${e.workerComments}`:``;return _(`div`,{className:`truncate`,title:`${t}\n\n${n}`,children:[e.supervisorInstructions??``,e.supervisorInstructions&&g(`br`,{}),e.workerComments??``]})},O=({root:e})=>{let n=b(),r=x(e=>e.common.lookupTables),i=m(r,`roots[${e.rootId}].rootName`,``),o=m(r,`locations[${e.locationId}].locationName`,``),s=m(e,`currentHeat.heatName`,``),c=m(r,`rootStates[${e.rootStateId}].rootStateName`,``),u=()=>{n(y(e))};return _(t,{hover:!0,children:[g(l,{children:i}),g(l,{children:o}),g(l,{children:s}),g(l,{children:c}),g(l,{children:g(a,{size:`small`,variant:`outlined`,color:`primary`,onClick:u,style:{whiteSpace:`nowrap`},children:`Set State`})}),g(l,{children:g(D,{root:e},`root-${e.rootId}-comments`)}),w.reduce((t,n)=>[...t,n.metrics.map(t=>g(E,{root:e,metricType:t,componentType:n},`root-${e.rootId}_metricType-${t.metricTypeId}_componentType-${n.componentTypeId}`))],[])]})},k=({isLoading:a})=>{let u=x(e=>e.ladleOverview.roots),d=x(e=>{var t;return(t=e.ladleOverview.ladleForModify)?.renderModal});return _(c,{style:{paddingLeft:`1rem`,paddingTop:`0.3rem`},children:[g(`h1`,{className:`ladle-overview-table__title`,children:`All Ladles`}),g(s,{children:a?g(`div`,{style:{display:`flex`,justifyContent:`center`,alignContent:`center`,padding:`18rem`},children:g(o,{})}):g(r,{children:_(n,{size:`small`,children:[_(i,{children:[_(t,{children:[g(l,{colSpan:6}),w.map(e=>g(l,{className:`text-center`,colSpan:e.metrics.length,children:e.name},`header-${e.name}`))]}),_(t,{children:[g(l,{children:`Ladle`}),g(l,{children:`Location`}),g(l,{children:`Heat`}),g(l,{children:`State/Comment`}),g(l,{}),g(l,{children:`Supervisor/Operator Comments`}),w.reduce((e,t)=>[...e,...Object.entries(t.metrics).map(([e,n])=>g(l,{style:{width:`4rem`},className:`text-center`,children:n.name},`header-${t.name}-${n.name}`))],[])]})]}),g(e,{children:Object.values(u).map(e=>g(O,{root:e},`root-${e.rootId.toString()}`))})]})})}),d&&g(C,{loadWithComponents:!0})]})},A=()=>{let[e,t]=(0,T.useState)(!1),n=b();function r(){t(!0),n(d()),n(p(!0)).then(()=>t(!1))}return(0,T.useEffect)(()=>r(),[]),g(`div`,{className:`container-fluid`,children:g(k,{isLoading:e})})};export{A as LadleOverviewComponent};
//# sourceMappingURL=ladle-overview-CQJUkKi-.js.map