@seedtactics/insight-client 17.0.10 → 17.1.0
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/assets/index-DRTGFb2E.js +92 -0
- package/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/assets/vendor-DxpZ1E10.js +275 -0
- package/dist/fms-insight-api.json +1 -1
- package/dist/index.html +4 -2
- package/dist/network/api.js +1 -1
- package/package.json +6 -6
- package/dist/assets/index-BKr-hck2.js +0 -366
- /package/dist/assets/{index-DXfAwuj-.css → vendor-DXfAwuj-.css} +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,$n as n,$r as r,$t as i,A as a,An as o,Ar as s,At as c,B as l,Bn as u,Br as d,Bt as f,C as p,Cn as m,Cr as h,Ct as g,D as ee,Dn as _,Dr as te,Dt as ne,E as v,En as y,Er as b,Et as re,F as ie,Fn as ae,Fr as x,Ft as oe,G as se,Gn as ce,Gr as le,Gt as ue,H as de,Hn as S,Hr as fe,Ht as pe,I as me,In as he,Ir as ge,It as _e,J as ve,Jn as ye,Jr as be,Jt as xe,K as Se,Kn as Ce,Kr as we,Kt as Te,L as Ee,Ln as De,Lr as Oe,Lt as ke,M as Ae,Mn as je,Mr as Me,Mt as Ne,N as Pe,Nn as Fe,Nr as Ie,Nt as Le,O as Re,On as ze,Or as C,Ot as Be,P as Ve,Pn as w,Pr as He,Pt as Ue,Q as We,Qn as Ge,Qr as Ke,Qt as qe,R as Je,Rn as Ye,Rr as Xe,Rt as Ze,S as Qe,Sn as $e,Sr as et,St as tt,T as nt,Tn as rt,Tr as it,Tt as at,U as T,Un as ot,Ur as st,Ut as ct,V as lt,Vn as E,Vr as ut,Vt as dt,W as D,Wn as O,Wr as ft,Wt as pt,X as k,Xn as mt,Xr as A,Xt as ht,Y as gt,Yn as _t,Yr as vt,Yt as yt,Z as bt,Zn as xt,Zr as j,Zt as St,_ as Ct,_n as wt,_r as Tt,_t as Et,a as Dt,an as Ot,ar as kt,at as At,b as jt,bn as Mt,br as Nt,bt as Pt,c as Ft,cn as It,cr as Lt,ct as Rt,d as zt,dn as Bt,dr as M,dt as Vt,ei as Ht,en as Ut,er as Wt,et as Gt,f as Kt,fn as qt,fr as N,ft as P,g as Jt,gn as Yt,gr as Xt,gt as Zt,h as Qt,hn as $t,hr as en,ht as tn,i as nn,ii as F,in as rn,ir as an,it as on,j as sn,jn as cn,jr as ln,jt as un,k as dn,kn as fn,kr as pn,kt as mn,l as hn,ln as gn,lr as _n,lt as vn,m as yn,mn as bn,mr as xn,mt as Sn,n as Cn,ni as wn,nn as Tn,nr as En,nt as Dn,o as On,on as kn,or as An,ot as jn,p as Mn,pn as Nn,pr as I,pt as Pn,q as Fn,qn as L,qr as In,qt as Ln,r as Rn,ri as zn,rn as Bn,rr as Vn,rt as Hn,s as Un,sn as Wn,sr as R,st as Gn,t as Kn,ti as qn,tn as Jn,tr as Yn,tt as Xn,u as Zn,un as Qn,ur as $n,ut as er,v as tr,vn as nr,vr as z,vt as rr,w as ir,wn as ar,wr as or,wt as sr,x as cr,xn as lr,xr as ur,xt as dr,y as fr,yn as pr,yr as B,yt as mr,z as hr,zn as gr,zr as _r,zt as vr}from"./vendor-DxpZ1E10.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var yr=class{constructor(e,t){this.jsonParseReviver=void 0,this.http=t||window,this.baseUrl=e??``}fMSInformation(e){let t=this.baseUrl+`/api/v1/fms/fms-information`;t=t.replace(/[?&]$/,``);let n={method:`GET`,signal:e,headers:{Accept:`application/json`}};return this.http.fetch(t,n).then(e=>this.processFMSInformation(e))}processFMSInformation(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Cr.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}findInstructions(e,t,n,r,i,a,o){let s=this.baseUrl+`/api/v1/fms/find-instructions/{part}?`;if(e==null)throw new globalThis.Error(`The parameter 'part' must be defined.`);if(s=s.replace(`{part}`,encodeURIComponent(``+e)),t==null)throw new globalThis.Error(`The parameter 'type' must be defined and cannot be null.`);if(s+=`type=`+encodeURIComponent(``+t)+`&`,n!=null&&(s+=`process=`+encodeURIComponent(``+n)+`&`),r!=null&&(s+=`materialID=`+encodeURIComponent(``+r)+`&`),i!=null&&(s+=`operatorName=`+encodeURIComponent(``+i)+`&`),a===null)throw new globalThis.Error(`The parameter 'pallet' cannot be null.`);a!==void 0&&(s+=`pallet=`+encodeURIComponent(``+a)+`&`),s=s.replace(/[?&]$/,``);let c={method:`GET`,signal:o,headers:{}};return this.http.fetch(s,c).then(e=>this.processFindInstructions(e))}processFindInstructions(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===302?e.text().then(e=>W(`A server side error occurred.`,t,e,n)):t===404?e.text().then(e=>{let r=null,i=e===``?null:JSON.parse(e,this.jsonParseReviver);return r=_i.fromJS(i),W(`A server side error occurred.`,t,e,n,r)}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}printLabel(e,t,n){let r=this.baseUrl+`/api/v1/fms/print-label/{materialId}?`;if(e==null)throw new globalThis.Error(`The parameter 'materialId' must be defined.`);if(r=r.replace(`{materialId}`,encodeURIComponent(``+e)),t===null)throw new globalThis.Error(`The parameter 'process' cannot be null.`);t!==void 0&&(r+=`process=`+encodeURIComponent(``+t)+`&`),r=r.replace(/[?&]$/,``);let i={method:`POST`,signal:n,headers:{}};return this.http.fetch(r,i).then(e=>this.processPrintLabel(e))}processPrintLabel(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t===400?e.text().then(e=>{let r=null,i=e===``?null:JSON.parse(e,this.jsonParseReviver);return r=_i.fromJS(i),W(`A server side error occurred.`,t,e,n,r)}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}parseBarcode(e,t,n){let r=this.baseUrl+`/api/v1/fms/parse-barcode?`;if(e==null)throw new globalThis.Error(`The parameter 'barcode' must be defined and cannot be null.`);r+=`barcode=`+encodeURIComponent(``+e)+`&`,t!=null&&t&&t.forEach(e=>{r+=`queuesToAddTo=`+encodeURIComponent(``+e)+`&`}),r=r.replace(/[?&]$/,``);let i={method:`POST`,signal:n,headers:{Accept:`application/json`}};return this.http.fetch(r,i).then(e=>this.processParseBarcode(e))}processParseBarcode(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=n?vi.fromJS(n):null,t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}enableVerboseLoggingForFiveMinutes(e){let t=this.baseUrl+`/api/v1/fms/enable-verbose-logging-for-five-minutes`;t=t.replace(/[?&]$/,``);let n={method:`POST`,signal:e,headers:{}};return this.http.fetch(t,n).then(e=>this.processEnableVerboseLoggingForFiveMinutes(e))}processEnableVerboseLoggingForFiveMinutes(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}},br=class{constructor(e,t){this.jsonParseReviver=void 0,this.http=t||window,this.baseUrl=e??``}history(e,t,n){let r=this.baseUrl+`/api/v1/jobs/history?`;if(e==null)throw new globalThis.Error(`The parameter 'startUTC' must be defined and cannot be null.`);if(r+=`startUTC=`+encodeURIComponent(e?``+e.toISOString():``)+`&`,t==null)throw new globalThis.Error(`The parameter 'endUTC' must be defined and cannot be null.`);r+=`endUTC=`+encodeURIComponent(t?``+t.toISOString():``)+`&`,r=r.replace(/[?&]$/,``);let i={method:`GET`,signal:n,headers:{Accept:`application/json`}};return this.http.fetch(r,i).then(e=>this.processHistory(e))}processHistory(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Si.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}filteredHistory(e,t,n,r){let i=this.baseUrl+`/api/v1/jobs/history?`;if(e==null)throw new globalThis.Error(`The parameter 'startUTC' must be defined and cannot be null.`);if(i+=`startUTC=`+encodeURIComponent(e?``+e.toISOString():``)+`&`,t==null)throw new globalThis.Error(`The parameter 'endUTC' must be defined and cannot be null.`);i+=`endUTC=`+encodeURIComponent(t?``+t.toISOString():``)+`&`,i=i.replace(/[?&]$/,``);let a={body:JSON.stringify(n),method:`POST`,signal:r,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(i,a).then(e=>this.processFilteredHistory(e))}processFilteredHistory(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Si.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}recent(e,t,n){let r=this.baseUrl+`/api/v1/jobs/recent?`;if(e==null)throw new globalThis.Error(`The parameter 'startUTC' must be defined and cannot be null.`);r+=`startUTC=`+encodeURIComponent(e?``+e.toISOString():``)+`&`,r=r.replace(/[?&]$/,``);let i={body:JSON.stringify(t),method:`POST`,signal:n,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(r,i).then(e=>this.processRecent(e))}processRecent(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Ci.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}latestSchedule(e){let t=this.baseUrl+`/api/v1/jobs/latest-schedule`;t=t.replace(/[?&]$/,``);let n={method:`GET`,signal:e,headers:{Accept:`application/json`}};return this.http.fetch(t,n).then(e=>this.processLatestSchedule(e))}processLatestSchedule(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=wi.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}completeBasketLoadStation(e,t){let n=this.baseUrl+`/api/v1/jobs/basket-load-station/complete`;n=n.replace(/[?&]$/,``);let r={body:JSON.stringify(e),method:`POST`,signal:t,headers:{"Content-Type":`application/json`}};return this.http.fetch(n,r).then(e=>this.processCompleteBasketLoadStation(e))}processCompleteBasketLoadStation(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}currentStatus(e){let t=this.baseUrl+`/api/v1/jobs/status`;t=t.replace(/[?&]$/,``);let n={method:`GET`,signal:e,headers:{Accept:`application/json`}};return this.http.fetch(t,n).then(e=>this.processCurrentStatus(e))}processCurrentStatus(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Kr.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}unscheduledRebookings(e){let t=this.baseUrl+`/api/v1/jobs/unscheduled-rebookings`;t=t.replace(/[?&]$/,``);let n={method:`GET`,signal:e,headers:{Accept:`application/json`}};return this.http.fetch(t,n).then(e=>this.processUnscheduledRebookings(e))}processUnscheduledRebookings(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Ei.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}addFromSim(e,t,n){let r=this.baseUrl+`/api/v1/jobs/add-from-sim?`;if(e===void 0)throw new globalThis.Error(`The parameter 'expectedPreviousScheduleId' must be defined.`);e!==null&&(r+=`expectedPreviousScheduleId=`+encodeURIComponent(``+e)+`&`),r=r.replace(/[?&]$/,``);let i={body:JSON.stringify(t),method:`POST`,signal:n,headers:{"Content-Type":`application/json`}};return this.http.fetch(r,i).then(e=>this.processAddFromSim(e))}processAddFromSim(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}add(e,t,n){let r=this.baseUrl+`/api/v1/jobs/add?`;if(e===void 0)throw new globalThis.Error(`The parameter 'expectedPreviousScheduleId' must be defined.`);e!==null&&(r+=`expectedPreviousScheduleId=`+encodeURIComponent(``+e)+`&`),r=r.replace(/[?&]$/,``);let i={body:JSON.stringify(t),method:`POST`,signal:n,headers:{"Content-Type":`application/json`}};return this.http.fetch(r,i).then(e=>this.processAdd(e))}processAdd(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}addUnallocatedCastingToQueue(e,t,n,r,i,a,o){let s=this.baseUrl+`/api/v1/jobs/casting/{castingName}?`;if(e==null)throw new globalThis.Error(`The parameter 'castingName' must be defined.`);if(s=s.replace(`{castingName}`,encodeURIComponent(``+e)),t==null)throw new globalThis.Error(`The parameter 'queue' must be defined and cannot be null.`);if(s+=`queue=`+encodeURIComponent(``+t)+`&`,n===null)throw new globalThis.Error(`The parameter 'qty' cannot be null.`);n!==void 0&&(s+=`qty=`+encodeURIComponent(``+n)+`&`),r!=null&&(s+=`operName=`+encodeURIComponent(``+r)+`&`),i!=null&&(s+=`workorder=`+encodeURIComponent(``+i)+`&`),s=s.replace(/[?&]$/,``);let c={body:JSON.stringify(a),method:`POST`,signal:o,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(s,c).then(e=>this.processAddUnallocatedCastingToQueue(e))}processAddUnallocatedCastingToQueue(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push($r.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}getJobPlan(e,t){let n=this.baseUrl+`/api/v1/jobs/job/{jobUnique}/plan`;if(e==null)throw new globalThis.Error(`The parameter 'jobUnique' must be defined.`);n=n.replace(`{jobUnique}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processGetJobPlan(e))}processGetJobPlan(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=qr.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}addUnprocessedMaterialToQueue(e,t,n,r,i,a,o,s){let c=this.baseUrl+`/api/v1/jobs/job/{jobUnique}/unprocessed-material?`;if(e==null)throw new globalThis.Error(`The parameter 'jobUnique' must be defined.`);if(c=c.replace(`{jobUnique}`,encodeURIComponent(``+e)),t==null)throw new globalThis.Error(`The parameter 'lastCompletedProcess' must be defined and cannot be null.`);if(c+=`lastCompletedProcess=`+encodeURIComponent(``+t)+`&`,n==null)throw new globalThis.Error(`The parameter 'queue' must be defined and cannot be null.`);if(c+=`queue=`+encodeURIComponent(``+n)+`&`,r==null)throw new globalThis.Error(`The parameter 'pos' must be defined and cannot be null.`);c+=`pos=`+encodeURIComponent(``+r)+`&`,i!=null&&(c+=`operName=`+encodeURIComponent(``+i)+`&`),a!=null&&(c+=`workorder=`+encodeURIComponent(``+a)+`&`),c=c.replace(/[?&]$/,``);let l={body:JSON.stringify(o),method:`POST`,signal:s,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(c,l).then(e=>this.processAddUnprocessedMaterialToQueue(e))}processAddUnprocessedMaterialToQueue(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=$r.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}setJobComment(e,t,n){let r=this.baseUrl+`/api/v1/jobs/job/{jobUnique}/comment`;if(e==null)throw new globalThis.Error(`The parameter 'jobUnique' must be defined.`);r=r.replace(`{jobUnique}`,encodeURIComponent(``+e)),r=r.replace(/[?&]$/,``);let i={body:JSON.stringify(t),method:`PUT`,signal:n,headers:{"Content-Type":`application/json`}};return this.http.fetch(r,i).then(e=>this.processSetJobComment(e))}processSetJobComment(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}setMaterialInQueue(e,t,n,r){let i=this.baseUrl+`/api/v1/jobs/material/{materialId}/queue?`;if(e==null)throw new globalThis.Error(`The parameter 'materialId' must be defined.`);i=i.replace(`{materialId}`,encodeURIComponent(``+e)),t!=null&&(i+=`operName=`+encodeURIComponent(``+t)+`&`),i=i.replace(/[?&]$/,``);let a={body:JSON.stringify(n),method:`PUT`,signal:r,headers:{"Content-Type":`application/json`}};return this.http.fetch(i,a).then(e=>this.processSetMaterialInQueue(e))}processSetMaterialInQueue(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}removeMaterialFromAllQueues(e,t,n){let r=this.baseUrl+`/api/v1/jobs/material/{materialId}/queue?`;if(e==null)throw new globalThis.Error(`The parameter 'materialId' must be defined.`);r=r.replace(`{materialId}`,encodeURIComponent(``+e)),t!=null&&(r+=`operName=`+encodeURIComponent(``+t)+`&`),r=r.replace(/[?&]$/,``);let i={method:`DELETE`,signal:n,headers:{}};return this.http.fetch(r,i).then(e=>this.processRemoveMaterialFromAllQueues(e))}processRemoveMaterialFromAllQueues(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t===400||t===409?e.text().then(e=>W(`A server side error occurred.`,t,e,n)):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}signalMaterialForQuarantine(e,t,n,r){let i=this.baseUrl+`/api/v1/jobs/material/{materialId}/signal-quarantine?`;if(e==null)throw new globalThis.Error(`The parameter 'materialId' must be defined.`);i=i.replace(`{materialId}`,encodeURIComponent(``+e)),t!=null&&(i+=`operName=`+encodeURIComponent(``+t)+`&`),i=i.replace(/[?&]$/,``);let a={body:JSON.stringify(n),method:`PUT`,signal:r,headers:{"Content-Type":`application/json`}};return this.http.fetch(i,a).then(e=>this.processSignalMaterialForQuarantine(e))}processSignalMaterialForQuarantine(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t===400||t===409?e.text().then(e=>W(`A server side error occurred.`,t,e,n)):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}quarantineQueuedMaterial(e,t,n,r){let i=this.baseUrl+`/api/v1/jobs/material/{materialId}/quarantine-queued?`;if(e==null)throw new globalThis.Error(`The parameter 'materialId' must be defined.`);i=i.replace(`{materialId}`,encodeURIComponent(``+e)),t!=null&&(i+=`operName=`+encodeURIComponent(``+t)+`&`),i=i.replace(/[?&]$/,``);let a={body:JSON.stringify(n),method:`PUT`,signal:r,headers:{"Content-Type":`application/json`}};return this.http.fetch(i,a).then(e=>this.processQuarantineQueuedMaterial(e))}processQuarantineQueuedMaterial(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t===400||t===409?e.text().then(e=>W(`A server side error occurred.`,t,e,n)):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}cancelLoad(e,t,n,r){let i=this.baseUrl+`/api/v1/jobs/material/{materialId}/cancel-load?`;if(e==null)throw new globalThis.Error(`The parameter 'materialId' must be defined.`);i=i.replace(`{materialId}`,encodeURIComponent(``+e)),t!=null&&(i+=`operName=`+encodeURIComponent(``+t)+`&`),i=i.replace(/[?&]$/,``);let a={body:JSON.stringify(n),method:`PUT`,signal:r,headers:{"Content-Type":`application/json`}};return this.http.fetch(i,a).then(e=>this.processCancelLoad(e))}processCancelLoad(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t===400||t===409||t===500?e.text().then(e=>W(`A server side error occurred.`,t,e,n)):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}invalidatePalletCycle(e,t,n,r,i,a){let o=this.baseUrl+`/api/v1/jobs/material/{materialId}/invalidate-process?`;if(e==null)throw new globalThis.Error(`The parameter 'materialId' must be defined.`);o=o.replace(`{materialId}`,encodeURIComponent(``+e)),t!=null&&(o+=`operName=`+encodeURIComponent(``+t)+`&`),n!=null&&(o+=`changeCastingTo=`+encodeURIComponent(``+n)+`&`),r!=null&&(o+=`changeJobUniqueTo=`+encodeURIComponent(``+r)+`&`),o=o.replace(/[?&]$/,``);let s={body:JSON.stringify(i),method:`PUT`,signal:a,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(o,s).then(e=>this.processInvalidatePalletCycle(e))}processInvalidatePalletCycle(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=yi.fromJS(n),t}):t===400||t===409?e.text().then(e=>W(`A server side error occurred.`,t,e,n)):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}bulkRemoveMaterialFromQueues(e,t,n){let r=this.baseUrl+`/api/v1/jobs/material?`;e!=null&&(r+=`operName=`+encodeURIComponent(``+e)+`&`),r=r.replace(/[?&]$/,``);let i={body:JSON.stringify(t),method:`DELETE`,signal:n,headers:{"Content-Type":`application/json`}};return this.http.fetch(r,i).then(e=>this.processBulkRemoveMaterialFromQueues(e))}processBulkRemoveMaterialFromQueues(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}decrementQuantities(e,t,n){let r=this.baseUrl+`/api/v1/jobs/planned-cycles?`;e!=null&&(r+=`loadDecrementsStrictlyAfterDecrementId=`+encodeURIComponent(``+e)+`&`),t!=null&&(r+=`loadDecrementsAfterTimeUTC=`+encodeURIComponent(t?``+t.toISOString():``)+`&`),r=r.replace(/[?&]$/,``);let i={method:`DELETE`,signal:n,headers:{Accept:`application/json`}};return this.http.fetch(r,i).then(e=>this.processDecrementQuantities(e))}processDecrementQuantities(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Ai.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}},xr=class{constructor(e,t){this.jsonParseReviver=void 0,this.http=t||window,this.baseUrl=e??``}get(e,t,n){let r=this.baseUrl+`/api/v1/log/events/all?`;if(e==null)throw new globalThis.Error(`The parameter 'startUTC' must be defined and cannot be null.`);if(r+=`startUTC=`+encodeURIComponent(e?``+e.toISOString():``)+`&`,t==null)throw new globalThis.Error(`The parameter 'endUTC' must be defined and cannot be null.`);r+=`endUTC=`+encodeURIComponent(t?``+t.toISOString():``)+`&`,r=r.replace(/[?&]$/,``);let i={method:`GET`,signal:n,headers:{Accept:`application/json`}};return this.http.fetch(r,i).then(e=>this.processGet(e))}processGet(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Er.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}getEventCSV(e,t,n){let r=this.baseUrl+`/api/v1/log/events.csv?`;if(e==null)throw new globalThis.Error(`The parameter 'startUTC' must be defined and cannot be null.`);if(r+=`startUTC=`+encodeURIComponent(e?``+e.toISOString():``)+`&`,t==null)throw new globalThis.Error(`The parameter 'endUTC' must be defined and cannot be null.`);r+=`endUTC=`+encodeURIComponent(t?``+t.toISOString():``)+`&`,r=r.replace(/[?&]$/,``);let i={method:`GET`,signal:n,headers:{Accept:`application/octet-stream`}};return this.http.fetch(r,i).then(e=>this.processGetEventCSV(e))}processGetEventCSV(e){let t=e.status,n={};if(e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200||t===206){let r=e.headers?e.headers.get(`content-disposition`):void 0,i=r?/filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(r):void 0,a=i&&i.length>1?i[3]||i[2]:void 0;return a?a=decodeURIComponent(a):(i=r?/filename="?([^"]*?)"?(;|$)/g.exec(r):void 0,a=i&&i.length>1?i[1]:void 0),e.blob().then(e=>({fileName:a,data:e,status:t,headers:n}))}return t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}getCompletedParts(e,t,n){let r=this.baseUrl+`/api/v1/log/events/all-completed-parts?`;if(e==null)throw new globalThis.Error(`The parameter 'startUTC' must be defined and cannot be null.`);if(r+=`startUTC=`+encodeURIComponent(e?``+e.toISOString():``)+`&`,t==null)throw new globalThis.Error(`The parameter 'endUTC' must be defined and cannot be null.`);r+=`endUTC=`+encodeURIComponent(t?``+t.toISOString():``)+`&`,r=r.replace(/[?&]$/,``);let i={method:`GET`,signal:n,headers:{Accept:`application/json`}};return this.http.fetch(r,i).then(e=>this.processGetCompletedParts(e))}processGetCompletedParts(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Er.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}recent(e,t,n){let r=this.baseUrl+`/api/v1/log/events/recent?`;if(e==null)throw new globalThis.Error(`The parameter 'lastSeenCounter' must be defined and cannot be null.`);r+=`lastSeenCounter=`+encodeURIComponent(``+e)+`&`,t!=null&&(r+=`expectedEndUTCofLastSeen=`+encodeURIComponent(t?``+t.toISOString():``)+`&`),r=r.replace(/[?&]$/,``);let i={method:`GET`,signal:n,headers:{Accept:`application/json`}};return this.http.fetch(r,i).then(e=>this.processRecent(e))}processRecent(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Er.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}logForMaterial(e,t){let n=this.baseUrl+`/api/v1/log/events/for-material/{materialID}`;if(e==null)throw new globalThis.Error(`The parameter 'materialID' must be defined.`);n=n.replace(`{materialID}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processLogForMaterial(e))}processLogForMaterial(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Er.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}logForMaterials(e,t){let n=this.baseUrl+`/api/v1/log/events/for-material?`;e!=null&&e&&e.forEach(e=>{n+=`id=`+encodeURIComponent(``+e)+`&`}),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processLogForMaterials(e))}processLogForMaterials(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Er.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}logForSerial(e,t){let n=this.baseUrl+`/api/v1/log/events/for-serial/{serial}`;if(e==null)throw new globalThis.Error(`The parameter 'serial' must be defined.`);n=n.replace(`{serial}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processLogForSerial(e))}processLogForSerial(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Er.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}logForWorkorder(e,t){let n=this.baseUrl+`/api/v1/log/events/for-workorder/{workorder}`;if(e==null)throw new globalThis.Error(`The parameter 'workorder' must be defined.`);n=n.replace(`{workorder}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processLogForWorkorder(e))}processLogForWorkorder(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Er.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}materialDetails(e,t){let n=this.baseUrl+`/api/v1/log/material-details/{materialID}`;if(e==null)throw new globalThis.Error(`The parameter 'materialID' must be defined.`);n=n.replace(`{materialID}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processMaterialDetails(e))}processMaterialDetails(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=yi.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}materialDetailsForJob(e,t){let n=this.baseUrl+`/api/v1/log/material-for-job/{jobUnique}`;if(e==null)throw new globalThis.Error(`The parameter 'jobUnique' must be defined.`);n=n.replace(`{jobUnique}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processMaterialDetailsForJob(e))}processMaterialDetailsForJob(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(yi.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}materialForSerial(e,t){let n=this.baseUrl+`/api/v1/log/material-for-serial/{serial}`;if(e==null)throw new globalThis.Error(`The parameter 'serial' must be defined.`);n=n.replace(`{serial}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processMaterialForSerial(e))}processMaterialForSerial(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(yi.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}setSerial(e,t,n,r){let i=this.baseUrl+`/api/v1/log/material-details/{materialID}/serial?`;if(e==null)throw new globalThis.Error(`The parameter 'materialID' must be defined.`);if(i=i.replace(`{materialID}`,encodeURIComponent(``+e)),t===null)throw new globalThis.Error(`The parameter 'process' cannot be null.`);t!==void 0&&(i+=`process=`+encodeURIComponent(``+t)+`&`),i=i.replace(/[?&]$/,``);let a={body:JSON.stringify(n),method:`POST`,signal:r,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(i,a).then(e=>this.processSetSerial(e))}processSetSerial(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Er.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}setWorkorder(e,t,n,r){let i=this.baseUrl+`/api/v1/log/material-details/{materialID}/workorder?`;if(e==null)throw new globalThis.Error(`The parameter 'materialID' must be defined.`);if(i=i.replace(`{materialID}`,encodeURIComponent(``+e)),t===null)throw new globalThis.Error(`The parameter 'process' cannot be null.`);t!==void 0&&(i+=`process=`+encodeURIComponent(``+t)+`&`),i=i.replace(/[?&]$/,``);let a={body:JSON.stringify(n),method:`POST`,signal:r,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(i,a).then(e=>this.processSetWorkorder(e))}processSetWorkorder(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Er.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}setInspectionDecision(e,t,n,r,i){let a=this.baseUrl+`/api/v1/log/material-details/{materialID}/inspections/{inspType}?`;if(e==null)throw new globalThis.Error(`The parameter 'materialID' must be defined.`);if(a=a.replace(`{materialID}`,encodeURIComponent(``+e)),t==null)throw new globalThis.Error(`The parameter 'inspType' must be defined.`);if(a=a.replace(`{inspType}`,encodeURIComponent(``+t)),n===null)throw new globalThis.Error(`The parameter 'process' cannot be null.`);n!==void 0&&(a+=`process=`+encodeURIComponent(``+n)+`&`),a=a.replace(/[?&]$/,``);let o={body:JSON.stringify(r),method:`POST`,signal:i,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(a,o).then(e=>this.processSetInspectionDecision(e))}processSetInspectionDecision(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Er.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}recordOperatorNotes(e,t,n,r,i){let a=this.baseUrl+`/api/v1/log/material-details/{materialID}/notes?`;if(e==null)throw new globalThis.Error(`The parameter 'materialID' must be defined.`);if(a=a.replace(`{materialID}`,encodeURIComponent(``+e)),t===null)throw new globalThis.Error(`The parameter 'process' cannot be null.`);t!==void 0&&(a+=`process=`+encodeURIComponent(``+t)+`&`),n!=null&&(a+=`operatorName=`+encodeURIComponent(``+n)+`&`),a=a.replace(/[?&]$/,``);let o={body:JSON.stringify(r),method:`POST`,signal:i,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(a,o).then(e=>this.processRecordOperatorNotes(e))}processRecordOperatorNotes(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Er.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}requestRebooking(e,t,n,r,i,a){let o=this.baseUrl+`/api/v1/log/events/rebooking?`;if(e==null)throw new globalThis.Error(`The parameter 'partName' must be defined and cannot be null.`);if(o+=`partName=`+encodeURIComponent(``+e)+`&`,t===null)throw new globalThis.Error(`The parameter 'qty' cannot be null.`);t!==void 0&&(o+=`qty=`+encodeURIComponent(``+t)+`&`),n!=null&&(o+=`workorder=`+encodeURIComponent(``+n)+`&`),r!=null&&(o+=`priority=`+encodeURIComponent(``+r)+`&`),o=o.replace(/[?&]$/,``);let s={body:JSON.stringify(i),method:`POST`,signal:a,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(o,s).then(e=>this.processRequestRebooking(e))}processRequestRebooking(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Er.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}cancelRebooking(e,t){let n=this.baseUrl+`/api/v1/log/events/cancel-rebooking/{bookingId}`;if(e==null)throw new globalThis.Error(`The parameter 'bookingId' must be defined.`);n=n.replace(`{bookingId}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`POST`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processCancelRebooking(e))}processCancelRebooking(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Er.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}recordInspectionCompleted(e,t){let n=this.baseUrl+`/api/v1/log/events/inspection-result`;n=n.replace(/[?&]$/,``);let r={body:JSON.stringify(e),method:`POST`,signal:t,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processRecordInspectionCompleted(e))}processRecordInspectionCompleted(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Er.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}recordCloseoutCompleted(e,t){let n=this.baseUrl+`/api/v1/log/events/closeout`;n=n.replace(/[?&]$/,``);let r={body:JSON.stringify(e),method:`POST`,signal:t,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processRecordCloseoutCompleted(e))}processRecordCloseoutCompleted(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Er.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}recordWorkorderComment(e,t,n,r){let i=this.baseUrl+`/api/v1/log/workorder/{workorder}/comment?`;if(e==null)throw new globalThis.Error(`The parameter 'workorder' must be defined.`);i=i.replace(`{workorder}`,encodeURIComponent(``+e)),t!=null&&(i+=`operatorName=`+encodeURIComponent(``+t)+`&`),i=i.replace(/[?&]$/,``);let a={body:JSON.stringify(n),method:`POST`,signal:r,headers:{"Content-Type":`application/json`,Accept:`application/json`}};return this.http.fetch(i,a).then(e=>this.processRecordWorkorderComment(e))}processRecordWorkorderComment(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=Er.fromJS(n),t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}getActiveWorkorder(e,t){let n=this.baseUrl+`/api/v1/log/workorder/{workorder}`;if(e==null)throw new globalThis.Error(`The parameter 'workorder' must be defined.`);n=n.replace(`{workorder}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processGetActiveWorkorder(e))}processGetActiveWorkorder(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(ci.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}},Sr=class{constructor(e,t){this.jsonParseReviver=void 0,this.http=t||window,this.baseUrl=e??``}getToolsInMachines(e){let t=this.baseUrl+`/api/v1/machines/tools`;t=t.replace(/[?&]$/,``);let n={method:`GET`,signal:e,headers:{Accept:`application/json`}};return this.http.fetch(t,n).then(e=>this.processGetToolsInMachines(e))}processGetToolsInMachines(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Pi.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}getProgramsInCellController(e){let t=this.baseUrl+`/api/v1/machines/programs-in-cell-controller`;t=t.replace(/[?&]$/,``);let n={method:`GET`,signal:e,headers:{Accept:`application/json`}};return this.http.fetch(t,n).then(e=>this.processGetProgramsInCellController(e))}processGetProgramsInCellController(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Fi.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}getProgramRevisionsInDescendingOrderOfRevision(e,t,n,r){let i=this.baseUrl+`/api/v1/machines/program/{programName}/revisions?`;if(e==null)throw new globalThis.Error(`The parameter 'programName' must be defined.`);if(i=i.replace(`{programName}`,encodeURIComponent(``+e)),t==null)throw new globalThis.Error(`The parameter 'count' must be defined and cannot be null.`);i+=`count=`+encodeURIComponent(``+t)+`&`,n!=null&&(i+=`revisionToStart=`+encodeURIComponent(``+n)+`&`),i=i.replace(/[?&]$/,``);let a={method:`GET`,signal:r,headers:{Accept:`application/json`}};return this.http.fetch(i,a).then(e=>this.processGetProgramRevisionsInDescendingOrderOfRevision(e))}processGetProgramRevisionsInDescendingOrderOfRevision(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);if(Array.isArray(n)){t=[];for(let e of n)t.push(Ii.fromJS(e))}else t=null;return t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}getProgramRevisionContent(e,t,n){let r=this.baseUrl+`/api/v1/machines/program/{programName}/revision/{revision}/content`;if(e==null)throw new globalThis.Error(`The parameter 'programName' must be defined.`);if(r=r.replace(`{programName}`,encodeURIComponent(``+e)),t==null)throw new globalThis.Error(`The parameter 'revision' must be defined.`);r=r.replace(`{revision}`,encodeURIComponent(``+t)),r=r.replace(/[?&]$/,``);let i={method:`GET`,signal:n,headers:{Accept:`application/json`}};return this.http.fetch(r,i).then(e=>this.processGetProgramRevisionContent(e))}processGetProgramRevisionContent(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=n===void 0?null:n,t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}getLatestProgramRevisionContent(e,t){let n=this.baseUrl+`/api/v1/machines/program/{programName}/latest-revision/content`;if(e==null)throw new globalThis.Error(`The parameter 'programName' must be defined.`);n=n.replace(`{programName}`,encodeURIComponent(``+e)),n=n.replace(/[?&]$/,``);let r={method:`GET`,signal:t,headers:{Accept:`application/json`}};return this.http.fetch(n,r).then(e=>this.processGetLatestProgramRevisionContent(e))}processGetLatestProgramRevisionContent(e){let t=e.status,n={};return e.headers&&e.headers.forEach&&e.headers.forEach((e,t)=>n[t]=e),t===200?e.text().then(e=>{let t=null,n=e===``?null:JSON.parse(e,this.jsonParseReviver);return t=n===void 0?null:n,t}):t!==200&&t!==204?e.text().then(e=>W(`An unexpected server error occurred.`,t,e,n)):Promise.resolve(null)}},Cr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e){if(this.name=e.Name,this.version=e.Version,this.licenseExpires=e.LicenseExpires?new Date(e.LicenseExpires.toString()):void 0,Array.isArray(e.AdditionalLogServers)){this.additionalLogServers=[];for(let t of e.AdditionalLogServers)this.additionalLogServers.push(t)}if(this.openIDConnectAuthority=e.OpenIDConnectAuthority,this.localhostOpenIDConnectAuthority=e.LocalhostOpenIDConnectAuthority,this.openIDConnectClientId=e.OpenIDConnectClientId,this.usingLabelPrinterForSerials=e.UsingLabelPrinterForSerials,this.useClientPrinterForLabels=e.UseClientPrinterForLabels,this.quarantineQueue=e.QuarantineQueue,this.customStationMonitorDialogUrl=e.CustomStationMonitorDialogUrl,this.supportsRebookings=e.SupportsRebookings,this.allowChangeWorkorderAtLoadStation=e.AllowChangeWorkorderAtLoadStation,this.allowInvalidateMaterialAtLoadStation=e.AllowInvalidateMaterialAtLoadStation,e.LoadStationNames){this.loadStationNames={};for(let t in e.LoadStationNames)e.LoadStationNames.hasOwnProperty(t)&&(this.loadStationNames[t]=e.LoadStationNames[t])}this.requireScanAtCloseout=e.RequireScanAtCloseout,this.requireWorkorderBeforeAllowCloseoutComplete=e.RequireWorkorderBeforeAllowCloseoutComplete,this.addToQueueButton=e.AddToQueueButton,this.requireOperatorNamePromptWhenAddingMaterial=e.RequireOperatorNamePromptWhenAddingMaterial,this.allowEditJobPlanQuantityFromQueuesPage=e.AllowEditJobPlanQuantityFromQueuesPage,this.allowInvalidateMaterialOnQueuesPage=e.AllowInvalidateMaterialOnQueuesPage,this.basketName=e.BasketName}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.Name=this.name,e.Version=this.version,e.LicenseExpires=this.licenseExpires?this.licenseExpires.toISOString():void 0,Array.isArray(this.additionalLogServers)){e.AdditionalLogServers=[];for(let t of this.additionalLogServers)e.AdditionalLogServers.push(t)}if(e.OpenIDConnectAuthority=this.openIDConnectAuthority,e.LocalhostOpenIDConnectAuthority=this.localhostOpenIDConnectAuthority,e.OpenIDConnectClientId=this.openIDConnectClientId,e.UsingLabelPrinterForSerials=this.usingLabelPrinterForSerials,e.UseClientPrinterForLabels=this.useClientPrinterForLabels,e.QuarantineQueue=this.quarantineQueue,e.CustomStationMonitorDialogUrl=this.customStationMonitorDialogUrl,e.SupportsRebookings=this.supportsRebookings,e.AllowChangeWorkorderAtLoadStation=this.allowChangeWorkorderAtLoadStation,e.AllowInvalidateMaterialAtLoadStation=this.allowInvalidateMaterialAtLoadStation,this.loadStationNames){e.LoadStationNames={};for(let t in this.loadStationNames)this.loadStationNames.hasOwnProperty(t)&&(e.LoadStationNames[t]=this.loadStationNames[t])}return e.RequireScanAtCloseout=this.requireScanAtCloseout,e.RequireWorkorderBeforeAllowCloseoutComplete=this.requireWorkorderBeforeAllowCloseoutComplete,e.AddToQueueButton=this.addToQueueButton,e.RequireOperatorNamePromptWhenAddingMaterial=this.requireOperatorNamePromptWhenAddingMaterial,e.AllowEditJobPlanQuantityFromQueuesPage=this.allowEditJobPlanQuantityFromQueuesPage,e.AllowInvalidateMaterialOnQueuesPage=this.allowInvalidateMaterialOnQueuesPage,e.BasketName=this.basketName,e}},wr=function(e){return e.DoNotShow=`DoNotShow`,e.AddBulkUnassigned=`AddBulkUnassigned`,e.LookupExistingSerial=`LookupExistingSerial`,e.ManualBarcodeScan=`ManualBarcodeScan`,e}({}),Tr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.logEntry=e.LogEntry?Er.fromJS(e.LogEntry):void 0,this.newJobs=e.NewJobs?jr.fromJS(e.NewJobs):void 0,this.newCurrentStatus=e.NewCurrentStatus?Kr.fromJS(e.NewCurrentStatus):void 0)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.LogEntry=this.logEntry?this.logEntry.toJSON():void 0,e.NewJobs=this.newJobs?this.newJobs.toJSON():void 0,e.NewCurrentStatus=this.newCurrentStatus?this.newCurrentStatus.toJSON():void 0,e}},Er=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.material=[])}init(e){if(e){if(this.counter=e.counter,Array.isArray(e.material)){this.material=[];for(let t of e.material)this.material.push(Dr.fromJS(t))}if(this.type=e.type,this.startofcycle=e.startofcycle,this.endUTC=e.endUTC?new Date(e.endUTC.toString()):void 0,this.loc=e.loc,this.locnum=e.locnum,this.pal=e.pal,this.program=e.program,this.result=e.result,this.elapsed=e.elapsed,this.active=e.active,e.details){this.details={};for(let t in e.details)e.details.hasOwnProperty(t)&&(this.details[t]=e.details[t])}if(Array.isArray(e.tooluse)){this.tooluse=[];for(let t of e.tooluse)this.tooluse.push(Or.fromJS(t))}}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.counter=this.counter,Array.isArray(this.material)){e.material=[];for(let t of this.material)e.material.push(t?t.toJSON():void 0)}if(e.type=this.type,e.startofcycle=this.startofcycle,e.endUTC=this.endUTC?this.endUTC.toISOString():void 0,e.loc=this.loc,e.locnum=this.locnum,e.pal=this.pal,e.program=this.program,e.result=this.result,e.elapsed=this.elapsed,e.active=this.active,this.details){e.details={};for(let t in this.details)this.details.hasOwnProperty(t)&&(e.details[t]=this.details[t])}if(Array.isArray(this.tooluse)){e.tooluse=[];for(let t of this.tooluse)e.tooluse.push(t?t.toJSON():void 0)}return e}},Dr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.id=e.id,this.uniq=e.uniq,this.part=e.part,this.proc=e.proc,this.path=e.path,this.numproc=e.numproc,this.face=e.face,this.serial=e.serial,this.workorder=e.workorder)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.id=this.id,e.uniq=this.uniq,e.part=this.part,e.proc=this.proc,e.path=this.path,e.numproc=this.numproc,e.face=this.face,e.serial=this.serial,e.workorder=this.workorder,e}},V=function(e){return e.LoadUnloadCycle=`LoadUnloadCycle`,e.MachineCycle=`MachineCycle`,e.PartMark=`PartMark`,e.Inspection=`Inspection`,e.OrderAssignment=`OrderAssignment`,e.GeneralMessage=`GeneralMessage`,e.PalletCycle=`PalletCycle`,e.WorkorderComment=`WorkorderComment`,e.InspectionResult=`InspectionResult`,e.CloseOut=`CloseOut`,e.AddToQueue=`AddToQueue`,e.RemoveFromQueue=`RemoveFromQueue`,e.InspectionForce=`InspectionForce`,e.PalletOnRotaryInbound=`PalletOnRotaryInbound`,e.PalletInStocker=`PalletInStocker`,e.SignalQuarantine=`SignalQuarantine`,e.InvalidateCycle=`InvalidateCycle`,e.SwapMaterialOnPallet=`SwapMaterialOnPallet`,e.Rebooking=`Rebooking`,e.CancelRebooking=`CancelRebooking`,e.BasketLoadUnload=`BasketLoadUnload`,e.BasketCycle=`BasketCycle`,e.CastingAssigned=`CastingAssigned`,e.CastingUnassigned=`CastingUnassigned`,e.JobDecrement=`JobDecrement`,e}({}),Or=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.tool=e.Tool,this.pocket=e.Pocket,this.toolChangeOccurred=e.ToolChangeOccurred,this.toolSerialAtStartOfCycle=e.ToolSerialAtStartOfCycle,this.toolSerialAtEndOfCycle=e.ToolSerialAtEndOfCycle,this.toolUseDuringCycle=e.ToolUseDuringCycle,this.totalToolUseAtEndOfCycle=e.TotalToolUseAtEndOfCycle,this.configuredToolLife=e.ConfiguredToolLife,this.toolUseCountDuringCycle=e.ToolUseCountDuringCycle,this.totalToolUseCountAtEndOfCycle=e.TotalToolUseCountAtEndOfCycle,this.configuredToolLifeCount=e.ConfiguredToolLifeCount)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.Tool=this.tool,e.Pocket=this.pocket,e.ToolChangeOccurred=this.toolChangeOccurred,e.ToolSerialAtStartOfCycle=this.toolSerialAtStartOfCycle,e.ToolSerialAtEndOfCycle=this.toolSerialAtEndOfCycle,e.ToolUseDuringCycle=this.toolUseDuringCycle,e.TotalToolUseAtEndOfCycle=this.totalToolUseAtEndOfCycle,e.ConfiguredToolLife=this.configuredToolLife,e.ToolUseCountDuringCycle=this.toolUseCountDuringCycle,e.TotalToolUseCountAtEndOfCycle=this.totalToolUseCountAtEndOfCycle,e.ConfiguredToolLifeCount=this.configuredToolLifeCount,e}},kr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.stops=[])}init(e){if(e){if(this.materialID=e.MaterialID,this.process=e.Process,this.pallet=e.Pallet,this.loadStation=e.LoadStation,Array.isArray(e.Stops)){this.stops=[];for(let t of e.Stops)this.stops.push(Ar.fromJS(t))}this.unloadStation=e.UnloadStation}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.MaterialID=this.materialID,e.Process=this.process,e.Pallet=this.pallet,e.LoadStation=this.loadStation,Array.isArray(this.stops)){e.Stops=[];for(let t of this.stops)e.Stops.push(t?t.toJSON():void 0)}return e.UnloadStation=this.unloadStation,e}},Ar=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.stationName=e.StationName,this.stationNum=e.StationNum)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.StationName=this.stationName,e.StationNum=this.stationNum,e}},jr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.jobs=[])}init(e){if(e){if(this.scheduleId=e.ScheduleId,Array.isArray(e.Jobs)){this.jobs=[];for(let t of e.Jobs)this.jobs.push(Mr.fromJS(t))}if(e.ExtraParts){this.extraParts={};for(let t in e.ExtraParts)e.ExtraParts.hasOwnProperty(t)&&(this.extraParts[t]=e.ExtraParts[t])}if(Array.isArray(e.StationUse)){this.stationUse=[];for(let t of e.StationUse)this.stationUse.push(zr.fromJS(t))}if(Array.isArray(e.StationUseForCurrentStatus)){this.stationUseForCurrentStatus=[];for(let t of e.StationUseForCurrentStatus)this.stationUseForCurrentStatus.push(zr.fromJS(t))}if(Array.isArray(e.SimDayUsage)){this.simDayUsage=[];for(let t of e.SimDayUsage)this.simDayUsage.push(Vr.fromJS(t))}if(Array.isArray(e.SimWorkordersFilled)){this.simWorkordersFilled=[];for(let t of e.SimWorkordersFilled)this.simWorkordersFilled.push(Hr.fromJS(t))}if(Array.isArray(e.CurrentUnfilledWorkorders)){this.currentUnfilledWorkorders=[];for(let t of e.CurrentUnfilledWorkorders)this.currentUnfilledWorkorders.push(Ur.fromJS(t))}if(Array.isArray(e.Programs)){this.programs=[];for(let t of e.Programs)this.programs.push(Gr.fromJS(t))}if(Array.isArray(e.AllocationWarning)){this.allocationWarning=[];for(let t of e.AllocationWarning)this.allocationWarning.push(t)}this.debugMessage=e.DebugMessage}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.ScheduleId=this.scheduleId,Array.isArray(this.jobs)){e.Jobs=[];for(let t of this.jobs)e.Jobs.push(t?t.toJSON():void 0)}if(this.extraParts){e.ExtraParts={};for(let t in this.extraParts)this.extraParts.hasOwnProperty(t)&&(e.ExtraParts[t]=this.extraParts[t])}if(Array.isArray(this.stationUse)){e.StationUse=[];for(let t of this.stationUse)e.StationUse.push(t?t.toJSON():void 0)}if(Array.isArray(this.stationUseForCurrentStatus)){e.StationUseForCurrentStatus=[];for(let t of this.stationUseForCurrentStatus)e.StationUseForCurrentStatus.push(t?t.toJSON():void 0)}if(Array.isArray(this.simDayUsage)){e.SimDayUsage=[];for(let t of this.simDayUsage)e.SimDayUsage.push(t?t.toJSON():void 0)}if(Array.isArray(this.simWorkordersFilled)){e.SimWorkordersFilled=[];for(let t of this.simWorkordersFilled)e.SimWorkordersFilled.push(t?t.toJSON():void 0)}if(Array.isArray(this.currentUnfilledWorkorders)){e.CurrentUnfilledWorkorders=[];for(let t of this.currentUnfilledWorkorders)e.CurrentUnfilledWorkorders.push(t?t.toJSON():void 0)}if(Array.isArray(this.programs)){e.Programs=[];for(let t of this.programs)e.Programs.push(t?t.toJSON():void 0)}if(Array.isArray(this.allocationWarning)){e.AllocationWarning=[];for(let t of this.allocationWarning)e.AllocationWarning.push(t)}return e.DebugMessage=this.debugMessage,e}},Mr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.procsAndPaths=[])}init(e){if(e){if(this.unique=e.Unique,this.routeStartUTC=e.RouteStartUTC?new Date(e.RouteStartUTC.toString()):void 0,this.routeEndUTC=e.RouteEndUTC?new Date(e.RouteEndUTC.toString()):void 0,this.archived=e.Archived,this.partName=e.PartName,this.comment=e.Comment,this.allocationAlgorithm=e.AllocationAlgorithm,Array.isArray(e.Bookings)){this.bookings=[];for(let t of e.Bookings)this.bookings.push(t)}if(this.provisionalWorkorderId=e.ProvisionalWorkorderId,this.artifactRunDate=e.ArtifactRunDate?new Date(e.ArtifactRunDate.toString()):void 0,this.manuallyCreated=e.ManuallyCreated,this.holdEntireJob=e.HoldEntireJob?Nr.fromJS(e.HoldEntireJob):void 0,this.cycles=e.Cycles,Array.isArray(e.ProcsAndPaths)){this.procsAndPaths=[];for(let t of e.ProcsAndPaths)this.procsAndPaths.push(Pr.fromJS(t))}}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.Unique=this.unique,e.RouteStartUTC=this.routeStartUTC?this.routeStartUTC.toISOString():void 0,e.RouteEndUTC=this.routeEndUTC?this.routeEndUTC.toISOString():void 0,e.Archived=this.archived,e.PartName=this.partName,e.Comment=this.comment,e.AllocationAlgorithm=this.allocationAlgorithm,Array.isArray(this.bookings)){e.Bookings=[];for(let t of this.bookings)e.Bookings.push(t)}if(e.ProvisionalWorkorderId=this.provisionalWorkorderId,e.ArtifactRunDate=this.artifactRunDate?Li(this.artifactRunDate):void 0,e.ManuallyCreated=this.manuallyCreated,e.HoldEntireJob=this.holdEntireJob?this.holdEntireJob.toJSON():void 0,e.Cycles=this.cycles,Array.isArray(this.procsAndPaths)){e.ProcsAndPaths=[];for(let t of this.procsAndPaths)e.ProcsAndPaths.push(t?t.toJSON():void 0)}return e}},Nr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.holdUnholdPattern=[])}init(e){if(e){if(this.userHold=e.UserHold,this.reasonForUserHold=e.ReasonForUserHold,Array.isArray(e.HoldUnholdPattern)){this.holdUnholdPattern=[];for(let t of e.HoldUnholdPattern)this.holdUnholdPattern.push(t)}this.holdUnholdPatternStartUTC=e.HoldUnholdPatternStartUTC?new Date(e.HoldUnholdPatternStartUTC.toString()):void 0,this.holdUnholdPatternRepeats=e.HoldUnholdPatternRepeats}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.UserHold=this.userHold,e.ReasonForUserHold=this.reasonForUserHold,Array.isArray(this.holdUnholdPattern)){e.HoldUnholdPattern=[];for(let t of this.holdUnholdPattern)e.HoldUnholdPattern.push(t)}return e.HoldUnholdPatternStartUTC=this.holdUnholdPatternStartUTC?this.holdUnholdPatternStartUTC.toISOString():void 0,e.HoldUnholdPatternRepeats=this.holdUnholdPatternRepeats,e}},Pr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.paths=[])}init(e){if(e){if(e.ExtraFields){this.extraFields={};for(let t in e.ExtraFields)e.ExtraFields.hasOwnProperty(t)&&(this.extraFields[t]=e.ExtraFields[t])}if(Array.isArray(e.BasketLoadStations)){this.basketLoadStations=[];for(let t of e.BasketLoadStations)this.basketLoadStations.push(t)}if(this.expectedBasketLoadTime=e.ExpectedBasketLoadTime,Array.isArray(e.BasketUnloadStations)){this.basketUnloadStations=[];for(let t of e.BasketUnloadStations)this.basketUnloadStations.push(t)}if(this.expectedBasketUnloadTime=e.ExpectedBasketUnloadTime,Array.isArray(e.paths)){this.paths=[];for(let t of e.paths)this.paths.push(Fr.fromJS(t))}}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},this.extraFields){e.ExtraFields={};for(let t in this.extraFields)this.extraFields.hasOwnProperty(t)&&(e.ExtraFields[t]=this.extraFields[t])}if(Array.isArray(this.basketLoadStations)){e.BasketLoadStations=[];for(let t of this.basketLoadStations)e.BasketLoadStations.push(t)}if(e.ExpectedBasketLoadTime=this.expectedBasketLoadTime,Array.isArray(this.basketUnloadStations)){e.BasketUnloadStations=[];for(let t of this.basketUnloadStations)e.BasketUnloadStations.push(t)}if(e.ExpectedBasketUnloadTime=this.expectedBasketUnloadTime,Array.isArray(this.paths)){e.paths=[];for(let t of this.paths)e.paths.push(t?t.toJSON():void 0)}return e}},Fr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.palletNums=[],this.load=[],this.unload=[],this.stops=[])}init(e){if(e){if(Array.isArray(e.PalletNums)){this.palletNums=[];for(let t of e.PalletNums)this.palletNums.push(t)}if(this.fixture=e.Fixture,this.face=e.Face,Array.isArray(e.Load)){this.load=[];for(let t of e.Load)this.load.push(t)}if(this.expectedLoadTime=e.ExpectedLoadTime,Array.isArray(e.Unload)){this.unload=[];for(let t of e.Unload)this.unload.push(t)}if(this.expectedUnloadTime=e.ExpectedUnloadTime,Array.isArray(e.Stops)){this.stops=[];for(let t of e.Stops)this.stops.push(Ir.fromJS(t))}if(Array.isArray(e.SimulatedProduction)){this.simulatedProduction=[];for(let t of e.SimulatedProduction)this.simulatedProduction.push(Lr.fromJS(t))}if(e.SimulatedStartTimePerPallet){this.simulatedStartTimePerPallet={};for(let t in e.SimulatedStartTimePerPallet)e.SimulatedStartTimePerPallet.hasOwnProperty(t)&&(this.simulatedStartTimePerPallet[t]=e.SimulatedStartTimePerPallet[t]?new Date(e.SimulatedStartTimePerPallet[t].toString()):void 0)}if(this.simulatedStartingUTC=e.SimulatedStartingUTC?new Date(e.SimulatedStartingUTC.toString()):void 0,this.simulatedAverageFlowTime=e.SimulatedAverageFlowTime,this.holdMachining=e.HoldMachining?Nr.fromJS(e.HoldMachining):void 0,this.holdLoadUnload=e.HoldLoadUnload?Nr.fromJS(e.HoldLoadUnload):void 0,this.partsPerPallet=e.PartsPerPallet,this.inputQueue=e.InputQueue,this.outputQueue=e.OutputQueue,Array.isArray(e.Inspections)){this.inspections=[];for(let t of e.Inspections)this.inspections.push(Rr.fromJS(t))}this.casting=e.Casting}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},Array.isArray(this.palletNums)){e.PalletNums=[];for(let t of this.palletNums)e.PalletNums.push(t)}if(e.Fixture=this.fixture,e.Face=this.face,Array.isArray(this.load)){e.Load=[];for(let t of this.load)e.Load.push(t)}if(e.ExpectedLoadTime=this.expectedLoadTime,Array.isArray(this.unload)){e.Unload=[];for(let t of this.unload)e.Unload.push(t)}if(e.ExpectedUnloadTime=this.expectedUnloadTime,Array.isArray(this.stops)){e.Stops=[];for(let t of this.stops)e.Stops.push(t?t.toJSON():void 0)}if(Array.isArray(this.simulatedProduction)){e.SimulatedProduction=[];for(let t of this.simulatedProduction)e.SimulatedProduction.push(t?t.toJSON():void 0)}if(this.simulatedStartTimePerPallet){e.SimulatedStartTimePerPallet={};for(let t in this.simulatedStartTimePerPallet)this.simulatedStartTimePerPallet.hasOwnProperty(t)&&(e.SimulatedStartTimePerPallet[t]=this.simulatedStartTimePerPallet[t]?this.simulatedStartTimePerPallet[t].toISOString():void 0)}if(e.SimulatedStartingUTC=this.simulatedStartingUTC?this.simulatedStartingUTC.toISOString():void 0,e.SimulatedAverageFlowTime=this.simulatedAverageFlowTime,e.HoldMachining=this.holdMachining?this.holdMachining.toJSON():void 0,e.HoldLoadUnload=this.holdLoadUnload?this.holdLoadUnload.toJSON():void 0,e.PartsPerPallet=this.partsPerPallet,e.InputQueue=this.inputQueue,e.OutputQueue=this.outputQueue,Array.isArray(this.inspections)){e.Inspections=[];for(let t of this.inspections)e.Inspections.push(t?t.toJSON():void 0)}return e.Casting=this.casting,e}},Ir=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.stationNums=[])}init(e){if(e){if(this.stationGroup=e.StationGroup,Array.isArray(e.StationNums)){this.stationNums=[];for(let t of e.StationNums)this.stationNums.push(t)}this.expectedCycleTime=e.ExpectedCycleTime,this.program=e.Program,this.programRevision=e.ProgramRevision}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.StationGroup=this.stationGroup,Array.isArray(this.stationNums)){e.StationNums=[];for(let t of this.stationNums)e.StationNums.push(t)}return e.ExpectedCycleTime=this.expectedCycleTime,e.Program=this.program,e.ProgramRevision=this.programRevision,e}},Lr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.timeUTC=e.TimeUTC?new Date(e.TimeUTC.toString()):void 0,this.quantity=e.Quantity)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.TimeUTC=this.timeUTC?this.timeUTC.toISOString():void 0,e.Quantity=this.quantity,e}},Rr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.inspectionType=e.InspectionType,this.counter=e.Counter,this.maxVal=e.MaxVal,this.randomFreq=e.RandomFreq,this.timeInterval=e.TimeInterval,this.expectedInspectionTime=e.ExpectedInspectionTime)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.InspectionType=this.inspectionType,e.Counter=this.counter,e.MaxVal=this.maxVal,e.RandomFreq=this.randomFreq,e.TimeInterval=this.timeInterval,e.ExpectedInspectionTime=this.expectedInspectionTime,e}},zr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e&&(this.scheduleId=e.ScheduleId,this.stationGroup=e.StationGroup,this.stationNum=e.StationNum,this.startUTC=e.StartUTC?new Date(e.StartUTC.toString()):void 0,this.endUTC=e.EndUTC?new Date(e.EndUTC.toString()):void 0,this.planDown=e.PlanDown,this.pallet=e.Pallet,Array.isArray(e.Parts))){this.parts=[];for(let t of e.Parts)this.parts.push(Br.fromJS(t))}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.ScheduleId=this.scheduleId,e.StationGroup=this.stationGroup,e.StationNum=this.stationNum,e.StartUTC=this.startUTC?this.startUTC.toISOString():void 0,e.EndUTC=this.endUTC?this.endUTC.toISOString():void 0,e.PlanDown=this.planDown,e.Pallet=this.pallet,Array.isArray(this.parts)){e.Parts=[];for(let t of this.parts)e.Parts.push(t?t.toJSON():void 0)}return e}},Br=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.jobUnique=e.JobUnique,this.process=e.Process,this.path=e.Path)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.JobUnique=this.jobUnique,e.Process=this.process,e.Path=this.path,e}},Vr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.day=e.Day?new Date(e.Day.toString()):void 0,this.machineGroup=e.MachineGroup,this.usage=e.Usage)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.Day=this.day?Li(this.day):void 0,e.MachineGroup=this.machineGroup,e.Usage=this.usage,e}},Hr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.workorderId=e.WorkorderId,this.part=e.Part,this.started=e.Started?new Date(e.Started.toString()):void 0,this.filled=e.Filled?new Date(e.Filled.toString()):void 0)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.WorkorderId=this.workorderId,e.Part=this.part,e.Started=this.started?Li(this.started):void 0,e.Filled=this.filled?Li(this.filled):void 0,e}},Ur=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e&&(this.workorderId=e.WorkorderId,this.part=e.Part,this.quantity=e.Quantity,this.dueDate=e.DueDate?new Date(e.DueDate.toString()):void 0,this.priority=e.Priority,Array.isArray(e.Programs))){this.programs=[];for(let t of e.Programs)this.programs.push(Wr.fromJS(t))}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.WorkorderId=this.workorderId,e.Part=this.part,e.Quantity=this.quantity,e.DueDate=this.dueDate?this.dueDate.toISOString():void 0,e.Priority=this.priority,Array.isArray(this.programs)){e.Programs=[];for(let t of this.programs)e.Programs.push(t?t.toJSON():void 0)}return e}},Wr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.processNumber=e.ProcessNumber,this.stopIndex=e.StopIndex,this.programName=e.ProgramName,this.revision=e.Revision)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.ProcessNumber=this.processNumber,e.StopIndex=this.stopIndex,e.ProgramName=this.programName,e.Revision=this.revision,e}},Gr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.programName=e.ProgramName,this.comment=e.Comment,this.programContent=e.ProgramContent,this.revision=e.Revision)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.ProgramName=this.programName,e.Comment=this.comment,e.ProgramContent=this.programContent,e.Revision=this.revision,e}},Kr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.jobs={},this.pallets={},this.material=[],this.alarms=[],this.queues={})}init(e){if(e){if(this.revision=e.Revision,this.timeOfCurrentStatusUTC=e.TimeOfCurrentStatusUTC?new Date(e.TimeOfCurrentStatusUTC.toString()):void 0,e.Jobs){this.jobs={};for(let t in e.Jobs)e.Jobs.hasOwnProperty(t)&&(this.jobs[t]=e.Jobs[t]?Jr.fromJS(e.Jobs[t]):new Jr)}if(e.Pallets){this.pallets={};for(let t in e.Pallets)e.Pallets.hasOwnProperty(t)&&(this.pallets[t]=e.Pallets[t]?Xr.fromJS(e.Pallets[t]):new Xr)}if(Array.isArray(e.Material)){this.material=[];for(let t of e.Material)this.material.push($r.fromJS(t))}if(Array.isArray(e.Alarms)){this.alarms=[];for(let t of e.Alarms)this.alarms.push(t)}if(Array.isArray(e.AlarmDetails)){this.alarmDetails=[];for(let t of e.AlarmDetails)this.alarmDetails.push(ni.fromJS(t))}if(e.Queues){this.queues={};for(let t in e.Queues)e.Queues.hasOwnProperty(t)&&(this.queues[t]=e.Queues[t]?ai.fromJS(e.Queues[t]):new ai)}if(Array.isArray(e.MachineLocations)){this.machineLocations=[];for(let t of e.MachineLocations)this.machineLocations.push(si.fromJS(t))}if(Array.isArray(e.Workorders)){this.workorders=[];for(let t of e.Workorders)this.workorders.push(ci.fromJS(t))}if(e.Baskets){this.baskets={};for(let t in e.Baskets)e.Baskets.hasOwnProperty(t)&&(this.baskets[t]=e.Baskets[t]?fi.fromJS(e.Baskets[t]):new fi)}this.customState=e.CustomState}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.Revision=this.revision,e.TimeOfCurrentStatusUTC=this.timeOfCurrentStatusUTC?this.timeOfCurrentStatusUTC.toISOString():void 0,this.jobs){e.Jobs={};for(let t in this.jobs)this.jobs.hasOwnProperty(t)&&(e.Jobs[t]=this.jobs[t]?this.jobs[t].toJSON():void 0)}if(this.pallets){e.Pallets={};for(let t in this.pallets)this.pallets.hasOwnProperty(t)&&(e.Pallets[t]=this.pallets[t]?this.pallets[t].toJSON():void 0)}if(Array.isArray(this.material)){e.Material=[];for(let t of this.material)e.Material.push(t?t.toJSON():void 0)}if(Array.isArray(this.alarms)){e.Alarms=[];for(let t of this.alarms)e.Alarms.push(t)}if(Array.isArray(this.alarmDetails)){e.AlarmDetails=[];for(let t of this.alarmDetails)e.AlarmDetails.push(t?t.toJSON():void 0)}if(this.queues){e.Queues={};for(let t in this.queues)this.queues.hasOwnProperty(t)&&(e.Queues[t]=this.queues[t]?this.queues[t].toJSON():void 0)}if(Array.isArray(this.machineLocations)){e.MachineLocations=[];for(let t of this.machineLocations)e.MachineLocations.push(t?t.toJSON():void 0)}if(Array.isArray(this.workorders)){e.Workorders=[];for(let t of this.workorders)e.Workorders.push(t?t.toJSON():void 0)}if(this.baskets){e.Baskets={};for(let t in this.baskets)this.baskets.hasOwnProperty(t)&&(e.Baskets[t]=this.baskets[t]?this.baskets[t].toJSON():void 0)}return e.CustomState=this.customState,e}},qr=class e extends Mr{constructor(e){super(e)}init(e){if(super.init(e),e&&(this.scheduleId=e.ScheduleId,this.copiedToSystem=e.CopiedToSystem,Array.isArray(e.Decrements))){this.decrements=[];for(let t of e.Decrements)this.decrements.push(Yr.fromJS(t))}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.ScheduleId=this.scheduleId,e.CopiedToSystem=this.copiedToSystem,Array.isArray(this.decrements)){e.Decrements=[];for(let t of this.decrements)e.Decrements.push(t?t.toJSON():void 0)}return super.toJSON(e),e}},Jr=class e extends qr{constructor(e){super(e)}init(e){if(super.init(e),e){if(Array.isArray(e.Completed)){this.completed=[];for(let t of e.Completed)this.completed.push(t)}if(Array.isArray(e.Precedence)){this.precedence=[];for(let t of e.Precedence)this.precedence.push(t)}if(Array.isArray(e.AssignedWorkorders)){this.assignedWorkorders=[];for(let t of e.AssignedWorkorders)this.assignedWorkorders.push(t)}this.remainingToStart=e.RemainingToStart}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},Array.isArray(this.completed)){e.Completed=[];for(let t of this.completed)e.Completed.push(t)}if(Array.isArray(this.precedence)){e.Precedence=[];for(let t of this.precedence)e.Precedence.push(t)}if(Array.isArray(this.assignedWorkorders)){e.AssignedWorkorders=[];for(let t of this.assignedWorkorders)e.AssignedWorkorders.push(t)}return e.RemainingToStart=this.remainingToStart,super.toJSON(e),e}},Yr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.decrementId=e.DecrementId,this.timeUTC=e.TimeUTC?new Date(e.TimeUTC.toString()):void 0,this.quantity=e.Quantity)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.DecrementId=this.decrementId,e.TimeUTC=this.timeUTC?this.timeUTC.toISOString():void 0,e.Quantity=this.quantity,e}},Xr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.currentPalletLocation=new Zr)}init(e){if(e){if(this.palletNum=e.PalletNum,this.fixtureOnPallet=e.FixtureOnPallet,this.onHold=e.OnHold,this.currentPalletLocation=e.CurrentPalletLocation?Zr.fromJS(e.CurrentPalletLocation):new Zr,this.newFixture=e.NewFixture,this.numFaces=e.NumFaces,Array.isArray(e.FaceNames)){this.faceNames=[];for(let t of e.FaceNames)this.faceNames.push(t)}this.targetLocation=e.TargetLocation?Zr.fromJS(e.TargetLocation):void 0,this.percentMoveCompleted=e.PercentMoveCompleted}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.PalletNum=this.palletNum,e.FixtureOnPallet=this.fixtureOnPallet,e.OnHold=this.onHold,e.CurrentPalletLocation=this.currentPalletLocation?this.currentPalletLocation.toJSON():void 0,e.NewFixture=this.newFixture,e.NumFaces=this.numFaces,Array.isArray(this.faceNames)){e.FaceNames=[];for(let t of this.faceNames)e.FaceNames.push(t)}return e.TargetLocation=this.targetLocation?this.targetLocation.toJSON():void 0,e.PercentMoveCompleted=this.percentMoveCompleted,e}},Zr=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.loc=e.loc,this.group=e.group,this.num=e.num)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.loc=this.loc,e.group=this.group,e.num=this.num,e}},Qr=function(e){return e.LoadUnload=`LoadUnload`,e.Machine=`Machine`,e.MachineQueue=`MachineQueue`,e.Buffer=`Buffer`,e.Cart=`Cart`,e}({}),$r=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.signaledInspections=[],this.location=new ei,this.action=new ti)}init(e){if(e){if(this.materialID=e.MaterialID,this.jobUnique=e.JobUnique,this.partName=e.PartName,this.process=e.Process,this.path=e.Path,this.serial=e.Serial,this.workorderId=e.WorkorderId,Array.isArray(e.SignaledInspections)){this.signaledInspections=[];for(let t of e.SignaledInspections)this.signaledInspections.push(t)}this.quarantineAfterUnload=e.QuarantineAfterUnload,this.problem=e.Problem,this.lastCompletedMachiningRouteStopIndex=e.LastCompletedMachiningRouteStopIndex,this.location=e.Location?ei.fromJS(e.Location):new ei,this.action=e.Action?ti.fromJS(e.Action):new ti}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.MaterialID=this.materialID,e.JobUnique=this.jobUnique,e.PartName=this.partName,e.Process=this.process,e.Path=this.path,e.Serial=this.serial,e.WorkorderId=this.workorderId,Array.isArray(this.signaledInspections)){e.SignaledInspections=[];for(let t of this.signaledInspections)e.SignaledInspections.push(t)}return e.QuarantineAfterUnload=this.quarantineAfterUnload,e.Problem=this.problem,e.LastCompletedMachiningRouteStopIndex=this.lastCompletedMachiningRouteStopIndex,e.Location=this.location?this.location.toJSON():void 0,e.Action=this.action?this.action.toJSON():void 0,e}},ei=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.type=e.Type,this.palletNum=e.PalletNum,this.face=e.Face,this.currentQueue=e.CurrentQueue,this.queuePosition=e.QueuePosition,this.basketId=e.BasketId,this.basketSlot=e.BasketSlot)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.Type=this.type,e.PalletNum=this.palletNum,e.Face=this.face,e.CurrentQueue=this.currentQueue,e.QueuePosition=this.queuePosition,e.BasketId=this.basketId,e.BasketSlot=this.basketSlot,e}},H=function(e){return e.Free=`Free`,e.OnPallet=`OnPallet`,e.InQueue=`InQueue`,e.InBasket=`InBasket`,e}({}),ti=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.type=e.Type,this.automatedTransfer=e.AutomatedTransfer,this.workId=e.WorkId,this.loadCancellationId=e.LoadCancellationId,this.loadOntoPalletNum=e.LoadOntoPalletNum,this.loadOntoFace=e.LoadOntoFace,this.processAfterLoad=e.ProcessAfterLoad,this.pathAfterLoad=e.PathAfterLoad,this.loadFromBasketId=e.LoadFromBasketId,this.loadToBasketId=e.LoadToBasketId,this.loadToBasketSlot=e.LoadToBasketSlot,this.unloadIntoQueue=e.UnloadIntoQueue,this.unloadToBasketId=e.UnloadToBasketId,this.unloadToBasketSlot=e.UnloadToBasketSlot,this.elapsedLoadUnloadTime=e.ElapsedLoadUnloadTime,this.program=e.Program,this.elapsedMachiningTime=e.ElapsedMachiningTime,this.expectedRemainingMachiningTime=e.ExpectedRemainingMachiningTime)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.Type=this.type,e.AutomatedTransfer=this.automatedTransfer,e.WorkId=this.workId,e.LoadCancellationId=this.loadCancellationId,e.LoadOntoPalletNum=this.loadOntoPalletNum,e.LoadOntoFace=this.loadOntoFace,e.ProcessAfterLoad=this.processAfterLoad,e.PathAfterLoad=this.pathAfterLoad,e.LoadFromBasketId=this.loadFromBasketId,e.LoadToBasketId=this.loadToBasketId,e.LoadToBasketSlot=this.loadToBasketSlot,e.UnloadIntoQueue=this.unloadIntoQueue,e.UnloadToBasketId=this.unloadToBasketId,e.UnloadToBasketSlot=this.unloadToBasketSlot,e.ElapsedLoadUnloadTime=this.elapsedLoadUnloadTime,e.Program=this.program,e.ElapsedMachiningTime=this.elapsedMachiningTime,e.ExpectedRemainingMachiningTime=this.expectedRemainingMachiningTime,e}},U=function(e){return e.Waiting=`Waiting`,e.Loading=`Loading`,e.UnloadToInProcess=`UnloadToInProcess`,e.UnloadToCompletedMaterial=`UnloadToCompletedMaterial`,e.Machining=`Machining`,e.LoadingToBasket=`LoadingToBasket`,e}({}),ni=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.code=e.Code,this.message=e.Message,this.impact=e.Impact,this.activity=e.Activity,this.basketId=e.BasketId)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.Code=this.code,e.Message=this.message,e.Impact=this.impact,e.Activity=this.activity,e.BasketId=this.basketId,e}},ri=function(e){return e.Informational=`Informational`,e.SuspendChanges=`SuspendChanges`,e}({}),ii=function(e){return e.BasketMovement=`BasketMovement`,e.BasketLoadStation=`BasketLoadStation`,e}({}),ai=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.maxSizeBeforeStopUnloading=e.MaxSizeBeforeStopUnloading,this.role=e.Role)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.MaxSizeBeforeStopUnloading=this.maxSizeBeforeStopUnloading,e.Role=this.role,e}},oi=function(e){return e.RawMaterial=`RawMaterial`,e.InProcessTransfer=`InProcessTransfer`,e.Quarantine=`Quarantine`,e.Other=`Other`,e}({}),si=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.possibleLoadStations=[])}init(e){if(e){if(this.machineGroup=e.MachineGroup,this.machineNum=e.MachineNum,this.moving=e.Moving,Array.isArray(e.PossibleLoadStations)){this.possibleLoadStations=[];for(let t of e.PossibleLoadStations)this.possibleLoadStations.push(t)}this.currentLoadStation=e.CurrentLoadStation}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.MachineGroup=this.machineGroup,e.MachineNum=this.machineNum,e.Moving=this.moving,Array.isArray(this.possibleLoadStations)){e.PossibleLoadStations=[];for(let t of this.possibleLoadStations)e.PossibleLoadStations.push(t)}return e.CurrentLoadStation=this.currentLoadStation,e}},ci=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.elapsedStationTime={},this.activeStationTime={})}init(e){if(e){if(this.workorderId=e.WorkorderId,this.part=e.Part,this.plannedQuantity=e.PlannedQuantity,this.dueDate=e.DueDate?new Date(e.DueDate.toString()):void 0,this.priority=e.Priority,this.simulatedStart=e.SimulatedStart?new Date(e.SimulatedStart.toString()):void 0,this.simulatedFilled=e.SimulatedFilled?new Date(e.SimulatedFilled.toString()):void 0,this.completedQuantity=e.CompletedQuantity,Array.isArray(e.Comments)){this.comments=[];for(let t of e.Comments)this.comments.push(li.fromJS(t))}if(e.ElapsedStationTime){this.elapsedStationTime={};for(let t in e.ElapsedStationTime)e.ElapsedStationTime.hasOwnProperty(t)&&(this.elapsedStationTime[t]=e.ElapsedStationTime[t])}if(e.ActiveStationTime){this.activeStationTime={};for(let t in e.ActiveStationTime)e.ActiveStationTime.hasOwnProperty(t)&&(this.activeStationTime[t]=e.ActiveStationTime[t])}if(Array.isArray(e.Material)){this.material=[];for(let t of e.Material)this.material.push(ui.fromJS(t))}}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.WorkorderId=this.workorderId,e.Part=this.part,e.PlannedQuantity=this.plannedQuantity,e.DueDate=this.dueDate?this.dueDate.toISOString():void 0,e.Priority=this.priority,e.SimulatedStart=this.simulatedStart?Li(this.simulatedStart):void 0,e.SimulatedFilled=this.simulatedFilled?Li(this.simulatedFilled):void 0,e.CompletedQuantity=this.completedQuantity,Array.isArray(this.comments)){e.Comments=[];for(let t of this.comments)e.Comments.push(t?t.toJSON():void 0)}if(this.elapsedStationTime){e.ElapsedStationTime={};for(let t in this.elapsedStationTime)this.elapsedStationTime.hasOwnProperty(t)&&(e.ElapsedStationTime[t]=this.elapsedStationTime[t])}if(this.activeStationTime){e.ActiveStationTime={};for(let t in this.activeStationTime)this.activeStationTime.hasOwnProperty(t)&&(e.ActiveStationTime[t]=this.activeStationTime[t])}if(Array.isArray(this.material)){e.Material=[];for(let t of this.material)e.Material.push(t?t.toJSON():void 0)}return e}},li=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.comment=e.Comment,this.timeUTC=e.TimeUTC?new Date(e.TimeUTC.toString()):void 0)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.Comment=this.comment,e.TimeUTC=this.timeUTC?this.timeUTC.toISOString():void 0,e}},ui=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.materialID=e.MaterialID,this.serial=e.Serial,this.quarantined=e.Quarantined,this.inspectionFailed=e.InspectionFailed,this.closeout=e.Closeout)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.MaterialID=this.materialID,e.Serial=this.serial,e.Quarantined=this.quarantined,e.InspectionFailed=this.inspectionFailed,e.Closeout=this.closeout,e}},di=function(e){return e.None=`None`,e.ClosedOut=`ClosedOut`,e.CloseOutFailed=`CloseOutFailed`,e}({}),fi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e){if(this.basketId=e.BasketId,this.slotCount=e.SlotCount,this.loadStationWork=e.LoadStationWork?pi.fromJS(e.LoadStationWork):void 0,this.position=e.Position?hi.fromJS(e.Position):void 0,Array.isArray(e.EmptySlots)){this.emptySlots=[];for(let t of e.EmptySlots)this.emptySlots.push(t)}if(Array.isArray(e.UnknownSlots)){this.unknownSlots=[];for(let t of e.UnknownSlots)this.unknownSlots.push(t)}}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.BasketId=this.basketId,e.SlotCount=this.slotCount,e.LoadStationWork=this.loadStationWork?this.loadStationWork.toJSON():void 0,e.Position=this.position?this.position.toJSON():void 0,Array.isArray(this.emptySlots)){e.EmptySlots=[];for(let t of this.emptySlots)e.EmptySlots.push(t)}if(Array.isArray(this.unknownSlots)){e.UnknownSlots=[];for(let t of this.unknownSlots)e.UnknownSlots.push(t)}return e}},pi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e&&(this.workId=e.WorkId,this.type=e.Type,this.readyToConfirm=e.ReadyToConfirm,this.confirmationBlockedReason=e.ConfirmationBlockedReason,this.instructionWarning=e.InstructionWarning,Array.isArray(e.AwaitingMaterialSlots))){this.awaitingMaterialSlots=[];for(let t of e.AwaitingMaterialSlots)this.awaitingMaterialSlots.push(t)}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.WorkId=this.workId,e.Type=this.type,e.ReadyToConfirm=this.readyToConfirm,e.ConfirmationBlockedReason=this.confirmationBlockedReason,e.InstructionWarning=this.instructionWarning,Array.isArray(this.awaitingMaterialSlots)){e.AwaitingMaterialSlots=[];for(let t of this.awaitingMaterialSlots)e.AwaitingMaterialSlots.push(t)}return e}},mi=function(e){return e.Material=`Material`,e.ConfirmEmptyBasket=`ConfirmEmptyBasket`,e}({}),hi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.location=e.Location,this.locationNum=e.LocationNum,this.locationTitle=e.LocationTitle,this.zone=e.Zone)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.Location=this.location,e.LocationNum=this.locationNum,e.LocationTitle=this.locationTitle,e.Zone=this.zone,e}},gi=function(e){return e.LoadUnload=`LoadUnload`,e.LoadStationStaging=`LoadStationStaging`,e.Storage=`Storage`,e.InTransit=`InTransit`,e}({}),_i=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);this.type=e.type,this.title=e.title,this.status=e.status,this.detail=e.detail,this.instance=e.instance}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){for(var t in e=typeof e==`object`?e:{},this)this.hasOwnProperty(t)&&(e[t]=this[t]);return e.type=this.type,e.title=this.title,e.status=this.status,e.detail=this.detail,e.instance=this.instance,e}},vi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.existingMaterial=e.ExistingMaterial?yi.fromJS(e.ExistingMaterial):void 0,this.potentialNewMaterial=e.PotentialNewMaterial?bi.fromJS(e.PotentialNewMaterial):void 0)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.ExistingMaterial=this.existingMaterial?this.existingMaterial.toJSON():void 0,e.PotentialNewMaterial=this.potentialNewMaterial?this.potentialNewMaterial.toJSON():void 0,e}},yi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e&&(this.materialID=e.MaterialID,this.jobUnique=e.JobUnique,this.partName=e.PartName,this.numProcesses=e.NumProcesses,this.workorder=e.Workorder,this.serial=e.Serial,e.Paths)){this.paths={};for(let t in e.Paths)e.Paths.hasOwnProperty(t)&&(this.paths[t]=e.Paths[t])}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.MaterialID=this.materialID,e.JobUnique=this.jobUnique,e.PartName=this.partName,e.NumProcesses=this.numProcesses,e.Workorder=this.workorder,e.Serial=this.serial,this.paths){e.Paths={};for(let t in this.paths)this.paths.hasOwnProperty(t)&&(e.Paths[t]=this.paths[t])}return e}},bi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e){if(e.PossibleCastingsByQueue){this.possibleCastingsByQueue={};for(let t in e.PossibleCastingsByQueue)e.PossibleCastingsByQueue.hasOwnProperty(t)&&(this.possibleCastingsByQueue[t]=e.PossibleCastingsByQueue[t]===void 0?[]:e.PossibleCastingsByQueue[t])}if(e.PossibleJobsByQueue){this.possibleJobsByQueue={};for(let t in e.PossibleJobsByQueue)e.PossibleJobsByQueue.hasOwnProperty(t)&&(this.possibleJobsByQueue[t]=e.PossibleJobsByQueue[t]?e.PossibleJobsByQueue[t].map(e=>xi.fromJS(e)):[])}this.workorder=e.Workorder,this.serial=e.Serial}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},this.possibleCastingsByQueue){e.PossibleCastingsByQueue={};for(let t in this.possibleCastingsByQueue)this.possibleCastingsByQueue.hasOwnProperty(t)&&(e.PossibleCastingsByQueue[t]=this.possibleCastingsByQueue[t])}if(this.possibleJobsByQueue){e.PossibleJobsByQueue={};for(let t in this.possibleJobsByQueue)this.possibleJobsByQueue.hasOwnProperty(t)&&(e.PossibleJobsByQueue[t]=this.possibleJobsByQueue[t])}return e.Workorder=this.workorder,e.Serial=this.serial,e}},xi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.jobUnique=e.JobUnique,this.lastCompletedProcess=e.LastCompletedProcess,this.workorder=e.Workorder)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.JobUnique=this.jobUnique,e.LastCompletedProcess=this.lastCompletedProcess,e.Workorder=this.workorder,e}},Si=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.jobs={},this.stationUse=[])}init(e){if(e){if(e.Jobs){this.jobs={};for(let t in e.Jobs)e.Jobs.hasOwnProperty(t)&&(this.jobs[t]=e.Jobs[t]?qr.fromJS(e.Jobs[t]):new qr)}if(Array.isArray(e.StationUse)){this.stationUse=[];for(let t of e.StationUse)this.stationUse.push(zr.fromJS(t))}}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},this.jobs){e.Jobs={};for(let t in this.jobs)this.jobs.hasOwnProperty(t)&&(e.Jobs[t]=this.jobs[t]?this.jobs[t].toJSON():void 0)}if(Array.isArray(this.stationUse)){e.StationUse=[];for(let t of this.stationUse)e.StationUse.push(t?t.toJSON():void 0)}return e}},Ci=class e extends Si{constructor(e){super(e)}init(e){if(super.init(e),e&&(this.mostRecentSimulationId=e.MostRecentSimulationId,Array.isArray(e.MostRecentSimDayUsage))){this.mostRecentSimDayUsage=[];for(let t of e.MostRecentSimDayUsage)this.mostRecentSimDayUsage.push(Vr.fromJS(t))}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.MostRecentSimulationId=this.mostRecentSimulationId,Array.isArray(this.mostRecentSimDayUsage)){e.MostRecentSimDayUsage=[];for(let t of this.mostRecentSimDayUsage)e.MostRecentSimDayUsage.push(t?t.toJSON():void 0)}return super.toJSON(e),e}},wi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e||(this.jobs=[],this.extraParts={})}init(e){if(e){if(this.latestScheduleId=e.LatestScheduleId,Array.isArray(e.Jobs)){this.jobs=[];for(let t of e.Jobs)this.jobs.push(qr.fromJS(t))}if(e.ExtraParts){this.extraParts={};for(let t in e.ExtraParts)e.ExtraParts.hasOwnProperty(t)&&(this.extraParts[t]=e.ExtraParts[t])}if(Array.isArray(e.RecentArtifactRuns)){this.recentArtifactRuns=[];for(let t of e.RecentArtifactRuns)this.recentArtifactRuns.push(Ti.fromJS(t))}if(Array.isArray(e.UnscheduledRebookings)){this.unscheduledRebookings=[];for(let t of e.UnscheduledRebookings)this.unscheduledRebookings.push(Ei.fromJS(t))}}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.LatestScheduleId=this.latestScheduleId,Array.isArray(this.jobs)){e.Jobs=[];for(let t of this.jobs)e.Jobs.push(t?t.toJSON():void 0)}if(this.extraParts){e.ExtraParts={};for(let t in this.extraParts)this.extraParts.hasOwnProperty(t)&&(e.ExtraParts[t]=this.extraParts[t])}if(Array.isArray(this.recentArtifactRuns)){e.RecentArtifactRuns=[];for(let t of this.recentArtifactRuns)e.RecentArtifactRuns.push(t?t.toJSON():void 0)}if(Array.isArray(this.unscheduledRebookings)){e.UnscheduledRebookings=[];for(let t of this.unscheduledRebookings)e.UnscheduledRebookings.push(t?t.toJSON():void 0)}return e}},Ti=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.jobUnique=e.JobUnique,this.partName=e.PartName,this.artifactRunDate=e.ArtifactRunDate?new Date(e.ArtifactRunDate.toString()):void 0)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.JobUnique=this.jobUnique,e.PartName=this.partName,e.ArtifactRunDate=this.artifactRunDate?Li(this.artifactRunDate):void 0,e}},Ei=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.bookingId=e.BookingId,this.partName=e.PartName,this.quantity=e.Quantity,this.timeUTC=e.TimeUTC?new Date(e.TimeUTC.toString()):void 0,this.priority=e.Priority,this.notes=e.Notes,this.workorder=e.Workorder)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.BookingId=this.bookingId,e.PartName=this.partName,e.Quantity=this.quantity,e.TimeUTC=this.timeUTC?this.timeUTC.toISOString():void 0,e.Priority=this.priority,e.Notes=this.notes,e.Workorder=this.workorder,e}},Di=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.workId=e.WorkId)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.WorkId=this.workId,e}},Oi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.queue=e.Queue,this.position=e.Position)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.Queue=this.queue,e.Position=this.position,e}},ki=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.expectedLoadCancellationId=e.ExpectedLoadCancellationId,this.reason=e.Reason)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.ExpectedLoadCancellationId=this.expectedLoadCancellationId,e.Reason=this.reason,e}},Ai=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.decrementId=e.DecrementId,this.jobUnique=e.JobUnique,this.timeUTC=e.TimeUTC?new Date(e.TimeUTC.toString()):void 0,this.part=e.Part,this.quantity=e.Quantity)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.DecrementId=this.decrementId,e.JobUnique=this.jobUnique,e.TimeUTC=this.timeUTC?this.timeUTC.toISOString():void 0,e.Part=this.part,e.Quantity=this.quantity,e}},ji=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e){if(this.materialID=e.MaterialID,this.process=e.Process,this.inspectionLocationNum=e.InspectionLocationNum,this.inspectionType=e.InspectionType,this.success=e.Success,e.ExtraData){this.extraData={};for(let t in e.ExtraData)e.ExtraData.hasOwnProperty(t)&&(this.extraData[t]=e.ExtraData[t])}this.elapsed=e.Elapsed,this.active=e.Active}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.MaterialID=this.materialID,e.Process=this.process,e.InspectionLocationNum=this.inspectionLocationNum,e.InspectionType=this.inspectionType,e.Success=this.success,this.extraData){e.ExtraData={};for(let t in this.extraData)this.extraData.hasOwnProperty(t)&&(e.ExtraData[t]=this.extraData[t])}return e.Elapsed=this.elapsed,e.Active=this.active,e}},Mi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){if(e){if(this.materialID=e.MaterialID,this.process=e.Process,this.locationNum=e.LocationNum,this.closeoutType=e.CloseoutType,e.ExtraData){this.extraData={};for(let t in e.ExtraData)e.ExtraData.hasOwnProperty(t)&&(this.extraData[t]=e.ExtraData[t])}this.elapsed=e.Elapsed,this.active=e.Active,this.failed=e.Failed}}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){if(e=typeof e==`object`?e:{},e.MaterialID=this.materialID,e.Process=this.process,e.LocationNum=this.locationNum,e.CloseoutType=this.closeoutType,this.extraData){e.ExtraData={};for(let t in this.extraData)this.extraData.hasOwnProperty(t)&&(e.ExtraData[t]=this.extraData[t])}return e.Elapsed=this.elapsed,e.Active=this.active,e.Failed=this.failed,e}},Ni=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.pocket=e.Pocket,this.toolName=e.ToolName,this.serial=e.Serial,this.currentUse=e.CurrentUse,this.totalLifeTime=e.TotalLifeTime,this.currentUseCount=e.CurrentUseCount,this.totalLifeCount=e.TotalLifeCount)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.Pocket=this.pocket,e.ToolName=this.toolName,e.Serial=this.serial,e.CurrentUse=this.currentUse,e.TotalLifeTime=this.totalLifeTime,e.CurrentUseCount=this.currentUseCount,e.TotalLifeCount=this.totalLifeCount,e}},Pi=class e extends Ni{constructor(e){super(e)}init(e){super.init(e),e&&(this.machineGroupName=e.MachineGroupName,this.machineNum=e.MachineNum)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.MachineGroupName=this.machineGroupName,e.MachineNum=this.machineNum,super.toJSON(e),e}},Fi=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.cellControllerProgramName=e.CellControllerProgramName,this.programName=e.ProgramName,this.revision=e.Revision,this.comment=e.Comment)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.CellControllerProgramName=this.cellControllerProgramName,e.ProgramName=this.programName,e.Revision=this.revision,e.Comment=this.comment,e}},Ii=class e{constructor(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}init(e){e&&(this.programName=e.ProgramName,this.revision=e.Revision,this.comment=e.Comment,this.cellControllerProgramName=e.CellControllerProgramName)}static fromJS(t){t=typeof t==`object`?t:{};let n=new e;return n.init(t),n}toJSON(e){return e=typeof e==`object`?e:{},e.ProgramName=this.programName,e.Revision=this.revision,e.Comment=this.comment,e.CellControllerProgramName=this.cellControllerProgramName,e}};function Li(e){return e.getUTCFullYear()+`-`+(e.getUTCMonth()<9?`0`+(e.getUTCMonth()+1):e.getUTCMonth()+1)+`-`+(e.getUTCDate()<10?`0`+e.getUTCDate():e.getUTCDate())}var Ri=class extends Error{constructor(e,t,n,r,i){super(),this.isApiException=!0,this.message=e,this.status=t,this.response=n,this.headers=r,this.result=i}static isApiException(e){return e.isApiException===!0}};function W(e,t,n,r,i){throw i??new Ri(e,t,n,r,null)}var zi,Bi,Vi,Hi,Ui=[],Wi=[],Gi;function Ki(){Vi=new xr,Hi=new Sr,Bi=new br,zi=new yr}function qi(e){Ui=e,Wi=e.map(e=>new xr(e))}function Ji(e){Gi=e.access_token;let t={fetch:Yi};zi=new yr(void 0,t),Bi=new br(void 0,t),Vi=new xr(void 0,t),Wi=Ui.map(e=>new xr(e,t))}function Yi(e,t){let n=new Headers(e instanceof Request?e.headers:void 0);return new Headers(t?.headers).forEach((e,t)=>n.set(t,e)),Gi&&n.set(`Authorization`,`Bearer `+Gi),window.fetch(e,t?{...t,headers:n}:{headers:n})}function Xi(e,t,n,r,i,a){return`/api/v1/fms/find-instructions/`+encodeURIComponent(e)+`?type=`+encodeURIComponent(t)+(`&materialID=`+n.toString())+(i==null?``:`&process=`+i.toString())+(a===null?``:`&operatorName=`+encodeURIComponent(a))+(r?`&pallet=`+encodeURIComponent(r):``)}var Zi;function Qi(e){return e.openIDConnectClientId?location.hostname===`localhost`?!!e.localhostOpenIDConnectAuthority:!!e.openIDConnectAuthority:!1}async function $i(){let e=await zi.fMSInformation();e.additionalLogServers&&e.additionalLogServers.length>0&&qi(e.additionalLogServers);let t=null;if(Qi(e)){if(Zi=new vt({authority:(location.hostname===`localhost`?e.localhostOpenIDConnectAuthority:e.openIDConnectAuthority)??``,client_id:e.openIDConnectClientId??``,redirect_uri:window.location.protocol+`//`+window.location.host+`/`,post_logout_redirect_uri:window.location.protocol+`//`+window.location.host+`/`,automaticSilentRenew:!0,loadUserInfo:!0,scope:`openid profile`}),t=await Zi.getUser(),!t){try{t=await Zi.signinRedirectCallback()}catch{t=null}window.history.replaceState({},``,`/`)}t&&(Ji(t),localStorage.setItem(`current-operator`,t.profile.name||t.profile.sub))}return{...e,user:t===null?void 0:t}}var G=F({name:`FMS Insight`,version:``});function ea(e){Zi&&!e.user&&Zi.signinRedirect().catch(e=>console.log(e))}function ta(){Zi&&Zi.signoutRedirect().catch(e=>console.log(e))}var K=e(wn(),1),na=be(),ra=F(T.empty()),ia=ra,aa=F(Fn.empty()),oa=aa,sa=F(T.empty()),ca=sa;function la(e,t){if(e.size===0)return t;let n={...t,jobs:{...t.jobs},stationUse:t.stationUse.filter(t=>!e.has(t.scheduleId))};for(let[r,i]of Object.entries(t.jobs))i.scheduleId&&e.has(i.scheduleId)&&delete n.jobs[r];return n}var ua=F(null,(e,t,n)=>{t(ra,e=>e.union(D.ofObject(n.jobs).toHashMap(e=>e))),t(aa,e=>e.union(D.ofObject(n.jobs).collect(([,e])=>e.scheduleId).concat(n.stationUse.map(e=>e.scheduleId)).toHashSet(e=>e)))}),da=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.newJobs){let e=n.newJobs.scheduleId,a=D.of(n.newJobs.jobs);t(ra,e=>{if(i){let t=P(r,-30);e=e.filter(e=>e.routeStartUTC>=t)}return e.union(a.toHashMap(e=>{let t=new qr({...e,copiedToSystem:!0});return[e.unique,t]}))}),e&&t(aa,t=>t.add(e))}}),fa=F(null,(e,t,n)=>{t(sa,D.ofObject(n.jobs).toHashMap(e=>e))}),pa=de(e=>F(t=>t(ia).get(e)?.comment??null,(t,n,r)=>{let i=r===null?``:r;n(ra,t=>{let n=t.get(e);return n===void 0?t:t.set(e,{...n,comment:i??void 0})})})),ma=l(`current-operator`,null),ha=l(`operators`,[]),ga=F(e=>{let t=e(ma),n=e(G);return n.user?n.user.profile.name||n.user.profile.sub||null:t},(e,t,n)=>{t(ma,n)}),_a=F({revision:0,timeOfCurrentStatusUTC:new Date,jobs:{},pallets:{},material:[],alarms:[],queues:{}}),q=_a,va=F(Math.floor(Date.now()/1e3));va.onMount=e=>{let t=setInterval(()=>{e(Math.floor(Date.now()/1e3))},1e3);return()=>clearInterval(t)};var ya=F(e=>Math.floor(e(va)/60)),ba=F(null,(e,t,n,r)=>{let i=r===null?``:r;t(_a,e=>{let t=e.jobs[n];if(t){let r=new Jr(t);return r.comment=i,{...e,jobs:{...e.jobs,[n]:r}}}return e}),t(pa(n),i),Bi.setJobComment(n,i)}),xa=F(null,(e,t,{workorder:n,comment:r})=>{let i=e(ga);t(_a,e=>e.workorders?{...e,workorders:e.workorders.map(e=>e.workorderId===n?new ci({...e,comments:[...e.comments??[],new li({comment:r,timeUTC:new Date})]}):e)}:e),Vi.recordWorkorderComment(n,i,r)}),Sa=F(null,(e,t,n)=>t(_a,n)),Ca=F(null,(e,t,{evt:n})=>{n.logEntry?t(_a,wa(n.logEntry)):n.newCurrentStatus&&t(_a,n.newCurrentStatus)});function wa(e){return t=>{if(e.type!==V.PartMark&&e.type!==V.OrderAssignment&&e.type!==V.Inspection&&e.type!==V.InspectionForce)return t;let n=Fn.from(e.material.map(e=>e.id)),r=t.material.map(t=>{if(t.materialID<0||!n.has(t.materialID))return t;let r=t;switch(e.type){case V.PartMark:return t.serial===e.result?t:new $r({...r,serial:e.result});case V.OrderAssignment:return t.workorderId===e.result?t:new $r({...r,workorderId:e.result});case V.Inspection:case V.InspectionForce:if(e.result.toLowerCase()===`true`||e.result===`1`){let n;if(n=e.type===V.InspectionForce?e.program:(e.details||{}).InspectionType,n&&!t.signaledInspections.includes(n))return new $r({...r,signaledInspections:[...t.signaledInspections,n]})}}return t});return r.every((e,n)=>e===t.material[n])?t:{...t,material:r}}}var Ta=F(null,(e,t,{queue:n,matId:r,newIdx:i})=>{t(_a,e=>{let t=e.material.find(e=>e.materialID===r);if(!t||t.location.type!==H.InQueue||t.location.currentQueue===n&&t.location.queuePosition===i)return e;let a=t.location.currentQueue,o=t.location.queuePosition;if(o===void 0||a===void 0)return e;let s=e.material.map(e=>{if(e.location.type!==H.InQueue||e.location.queuePosition===void 0||e.location.currentQueue===void 0)return e;if(e.materialID===r)return new $r({...e,location:new ei({...e.location,type:H.InQueue,currentQueue:n,queuePosition:i})});let t=e.location.queuePosition;return e.location.currentQueue===a&&e.location.queuePosition>o&&--t,e.location.currentQueue===n&&t>=i&&(t+=1),t===e.location.queuePosition?e:new $r({...e,location:new ei({...e.location,queuePosition:t})})});return{...e,material:s}})}),Ea=RegExp(`^(-?)P(-?\\d+(?:[\\.,]\\d+)?Y)?(-?\\d+(?:[\\.,]\\d+)?M)?(-?\\d+(?:[\\.,]\\d+)?D)?(?:T(-?\\d+(?:[\\.,]\\d+)?H)?(-?\\d+(?:[\\.,]\\d+)?M)?(-?\\d+(?:[\\.,]\\d+)?S)?)?$`);function Da(e){let t=Ea.exec(e);if(!t||!t.slice(2).some(Boolean))return null;let n=t[1]===`-`?-1:1,r={};return t[2]&&(r.years=n*parseFloat(t[2])),t[3]&&(r.months=n*parseFloat(t[3])),t[4]&&(r.days=n*parseFloat(t[4])),t[5]&&(r.hours=n*parseFloat(t[5])),t[6]&&(r.minutes=n*parseFloat(t[6])),t[7]&&(r.seconds=n*parseFloat(t[7])),r}function Oa(e){let t=Da(e);return t?((((t.years??0)*365+(t.months??0)*30+(t.days??0))*24+(t.hours??0))*60+(t.minutes??0))*60+(t.seconds??0):0}function J(e){return Oa(e)/60}var ka=class e{constructor(e,t,n){this.part=e,this.statGroup=t,this.operation=n}static ofLogCycle(t){return new e(t.material[0].part,t.loc,(t.type===V.LoadUnloadCycle||t.type===V.BasketLoadUnload)&&t.material.length>0?t.result+`-`+t.material[0].proc.toString():t.program)}static ofPartCycle(t){return new e(t.part,t.stationGroup,t.carrier.kind!==`machining`&&t.material.length>0?t.operation+`-`+t.material[0].proc.toString():t.operation)}compare(e){let t=this.part.localeCompare(e.part);return t!==0||(t=this.statGroup.localeCompare(e.statGroup),t!==0)?t:this.operation.localeCompare(e.operation)}hash(){return ve(this.part,this.statGroup,this.operation)}toString(){return`{part: ${this.part}}, statGroup: ${this.statGroup}, operation: ${this.operation}}`}},Aa=F(T.empty()),ja=Aa,Ma=F(T.empty()),Na=Ma;function Pa(e,t){return e.medianMinutesForSingleMat===0?!1:t<e.medianMinutesForSingleMat?(e.medianMinutesForSingleMat-t)/e.MAD_belowMinutes>2:(t-e.medianMinutesForSingleMat)/e.MAD_aboveMinutes>2}function Fa(e,t){return e.medianMinutesForSingleMat===0||t<e.medianMinutesForSingleMat?!1:(t-e.medianMinutesForSingleMat)/e.MAD_aboveMinutes>2}function Ia(e){let t=e.toSortedArray(e=>e);if(t.length===0)return 0;let n=Math.floor(t.length/2);return t.length%2==0?(t[n-1]+t[n])/2:t[n]}function La(e){let t=Ia(D.of(e)),n=1.4826*Ia(D.of(e).filter(e=>e<=t).map(e=>t-e));n<.25&&(n=.25);let r=1.4826*Ia(D.of(e).filter(e=>e>=t).map(e=>e-t));r<.25&&(r=.25);let i={medianMinutesForSingleMat:t,MAD_belowMinutes:n,MAD_aboveMinutes:r,expectedCycleMinutesForSingleMat:0},a=D.of(e).filter(e=>!Pa(i,e)).toRArray(),o=a.reduce((e,t)=>e+t,0)/a.length;return{...i,expectedCycleMinutesForSingleMat:o}}function Ra(e,n,r){return e.toLookupOrderedMap(n,r,e=>[e],(e,t)=>e.concat(t)).toAscLazySeq().map(([e,n])=>{let i=[],a=[];for(let e of n.valuesToAscLazySeq().flatMap(e=>e))a.length===0?a=[e]:t(r(e),r(a[a.length-1]))<10?a.push(e):(i.push(a),a=[e]);return a.length>0&&i.push(a),[e,i]})}function za(e,t,n){let r=0,i=0,a=!0;for(let t of e)n(t)<0&&(a=!1),i+=t.material.length,r+=n(t);return a&&r>0?e.map(e=>({cycle:e,elapsedForSingleMaterialMinutes:t(e)*n(e)/r/e.material.length})):i>0?e.map(e=>({cycle:e,elapsedForSingleMaterialMinutes:t(e)/i})):e.map(e=>({cycle:e,elapsedForSingleMaterialMinutes:t(e)}))}function Ba(e){let t=new Set;for(let n of e)if(n.type===V.PalletCycle&&n.material.length>0)for(let e of n.material)t.add(e.id);return Ra(D.of(e).filter(e=>(e.type===V.LoadUnloadCycle||e.type===V.BasketLoadUnload||e.type===V.MachineCycle)&&!e.startofcycle&&e.loc!==``&&e.material.length>0),e=>e.loc+` #`+e.locnum.toString(),e=>e.endUTC).flatMap(([e,t])=>t).flatMap(e=>{let n=J(e[0].elapsed);return e.length>=2&&e.every(e=>J(e.elapsed)===n&&e.material.every(e=>!t.has(e.id)))?za(e,e=>J(e.elapsed),e=>e.active===``?-1:J(e.active)):e.map(e=>({cycle:e,elapsedForSingleMaterialMinutes:e.material.length>0?J(e.elapsed)/e.material.length:0}))})}function Va(e){return Ba(e).toLookup(e=>ka.ofLogCycle(e.cycle),e=>e.elapsedForSingleMaterialMinutes).mapValues(La)}var Ha=F(null,(e,t,n)=>{t(Aa,e=>e.size===0?Va(n):e)}),Ua=F(null,(e,t,n)=>{t(Ma,Va(n))});function Wa(e){return e.carrier.kind!==`machining`}function Ga(e){return e.carrier.kind===`machining`}function Ka(e){return e.carrier.kind===`pallet-lul`}function qa(e){return e.carrier.kind===`basket-lul`}function Ja(e){return e.carrier.kind===`basket-lul`?void 0:e.carrier.pallet}function Ya(e){return e.carrier.kind===`basket-lul`?e.carrier.basket:void 0}function Xa(e,t){return e.startsWith(`Inspect`)?e:e+` #`+t.toString()}function Za(e,t){let n=t?.[e.toString()];return n&&n.trim().length>0?n:`L/U #${e}`}function Qa(e,t,n){return e===`L/U`?Za(t,n):Xa(e,t)}function $a(e){if(!Number.isSafeInteger(e)||e<=0)return String(e);let t=``;for(let n=e;n>0;n=Math.floor((n-1)/26))t=String.fromCharCode(65+(n-1)%26)+t;return t}function eo(e){return e&&e.trim().length>0?e:`Basket`}function to(e,t=`Basket`){switch(e.carrier.kind){case`machining`:case`pallet-lul`:return`Pallet ${e.carrier.pallet}`;case`basket-lul`:return`${t} ${e.carrier.basket}`}}function no(e){switch(e.carrier.kind){case`machining`:case`pallet-lul`:return e.carrier.pallet;case`basket-lul`:return e.carrier.basket+1e6}}function ro(e){return e.valuesToLazySeq().some(e=>e.carrier.kind===`basket-lul`)}var io=F(T.empty()),ao=io,oo=F(e=>ro(e(io))),so=F(T.empty()),co=so,lo=F(e=>ro(e(so)));function uo(e,t,n,r){if(t.startofcycle||t.type!==V.LoadUnloadCycle&&t.type!==V.BasketLoadUnload&&t.type!==V.MachineCycle||t.loc===``)return null;let i=t.type===V.MachineCycle?{kind:`machining`,pallet:t.pal}:t.type===V.LoadUnloadCycle?{kind:`pallet-lul`,pallet:t.pal}:{kind:`basket-lul`,basket:t.pal},a=J(t.active);if(i.kind===`basket-lul`&&n<=0&&a<=0)return null;let o=t.material.length>0?t.material[0].part:``,s=t.material.length>0?e.get(ka.ofLogCycle(t)):void 0,c=a;return(t.active===``||c<=0||t.material.length==0)&&(c=(s?.expectedCycleMinutesForSingleMat??0)*t.material.length),{endTime:t.endUTC,elapsedMinsPerMaterial:n,cntr:t.counter,activeMinutes:c,medianCycleMinutes:(s?.medianMinutesForSingleMat??0)*t.material.length,MAD_aboveMinutes:s?.MAD_aboveMinutes??0,part:o,carrier:i,material:t.material,isOutlier:s?Pa(s,n):!1,stationGroup:t.loc,stationNumber:t.locnum,stationLabel:Qa(t.loc,t.locnum,r),operation:i.kind===`machining`?t.program:t.result,operator:t.details&&t.details.operator||``}}function fo(e,t,n){return Ba(t).collect(t=>uo(e,t.cycle,t.elapsedForSingleMaterialMinutes,n)).buildHashMap(e=>e.cntr)}var po=F(null,(e,t,n)=>{let r=e(ja),i=e(G)?.loadStationNames;t(io,e=>e.union(fo(r,n,i)))}),mo=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.logEntry&&n.logEntry.type===V.InvalidateCycle){let e=n.logEntry.details?.EditedCounters,r=e?new Set(e.split(`,`).map(e=>parseInt(e))):new Set;r.size>0&&t(io,e=>{for(let t of r){let n=e.get(t);n!==void 0&&(e=e.set(t,{...n,activeMinutes:0}))}return e})}else if(n.logEntry){let a=e(ja),o=n.logEntry.material.length>0?J(n.logEntry.elapsed)/n.logEntry.material.length:0,s=e(G)?.loadStationNames,c=uo(a,n.logEntry,o,s);if(!c)return;t(io,e=>{if(i){let t=P(r,-30);e=e.filter(e=>e.endTime>=t)}return e=e.set(c.cntr,c),e})}}),ho=F(null,(e,t,n)=>{let r=e(Na),i=e(G)?.loadStationNames;t(so,fo(r,n,i))});function go(e,t){return!t&&e===`Basket`?`Any`:e}function _o(e,t){let n=Se.empty(),r=Se.empty(),i=Se.empty(),a=se.empty(),o=Se.empty(),s=!1;for(let c of e){let e=Ja(c);e!==void 0&&(n=n.add(e)),s||=qa(c),Wa(c)?r=r.add(c.stationLabel):(i=i.add(c.stationLabel),t&&c.part==t.part&&c.material.some(e=>e.proc===t.proc)&&(o=o.add(ka.ofPartCycle(c))));for(let e of c.material)a=a.alter(e.part,t=>(t??Se.empty()).add(e.proc))}return{allPalletNames:n.toAscLazySeq().toRArray(),allLoadStationNames:r.toAscLazySeq().toRArray(),allMachineNames:i.toAscLazySeq().toRArray(),allPartAndProcNames:a.toAscLazySeq().flatMap(([e,t])=>t.toAscLazySeq().map(t=>({part:e,proc:t}))).toRArray(),allMachineOperations:o.toAscLazySeq().toRArray(),hasBasketCycles:s}}var vo=`@@@_FMSInsight_FilterAnyMachineKey_@@@`,yo=`@@@_FMSInsigt_FilterAnyLoadKey_@@@`;function bo(e){return{..._o(e),seriesLabel:`Station`,data:new Map}}function xo(e,{zoom:t,partAndProc:n,pallet:r,station:i,operation:a,carrierKind:o}){let s=n&&i&&i!==`@@@_FMSInsight_FilterAnyMachineKey_@@@`&&i!==`@@@_FMSInsigt_FilterAnyLoadKey_@@@`,c=r&&!a&&i&&i!==`@@@_FMSInsight_FilterAnyMachineKey_@@@`&&i!==`@@@_FMSInsigt_FilterAnyLoadKey_@@@`;return{..._o(e,n),seriesLabel:s?`Carrier`:c?`Part`:`Station`,data:D.of(e).filter(e=>{if(t&&(e.endTime<t.start||e.endTime>t.end)||n&&(e.part!==n.part||!e.material.some(e=>e.proc===n.proc))||r&&Ja(e)!==r||o===`Pallet`&&Ya(e)!==void 0||o===`Basket`&&Ya(e)===void 0)return!1;if(i===`@@@_FMSInsight_FilterAnyMachineKey_@@@`){if(Wa(e))return!1}else if(i===`@@@_FMSInsigt_FilterAnyLoadKey_@@@`){if(!Wa(e))return!1}else if(i&&e.stationLabel!==i)return!1;return!(a&&a.compare(ka.ofPartCycle(e))!==0)}).toRLookup(e=>s?to(e):c?e.part+`-`+D.of(e.material).map(e=>e.proc).distinctAndSortBy(e=>e).toRArray().join(`:`):e.stationLabel,e=>({...e,x:e.endTime,y:e.elapsedMinsPerMaterial*e.material.length}))}}function So(e,{zoom:t,partAndProc:n,pallet:r,station:i,carrierKind:a}){let o=D.of(e).filter(e=>a===`Pallet`&&Ya(e)!==void 0||a===`Basket`&&Ya(e)===void 0?!1:!i||i===`@@@_FMSInsigt_FilterAnyLoadKey_@@@`?Wa(e):Wa(e)&&e.stationLabel===i);return{..._o(e,n),seriesLabel:`Station`,data:Ra(o,e=>e.stationLabel,e=>e.endTime).map(([e,i])=>[e,D.of(i).collect(e=>{let i=e.find(e=>!(t&&(e.endTime<t.start||e.endTime>t.end)||n&&(e.part!==n.part||!e.material.some(e=>e.proc===n.proc))||r&&Ja(e)!==r));return i?{...i,x:i.endTime,y:e.reduce((e,t)=>e+t.elapsedMinsPerMaterial*t.material.length,0),operations:D.of(e).flatMap(e=>e.material.map(t=>({mat:t,operation:e.operation}))).toRArray()}:null}).toRArray()]).filter(([,e])=>e.length>0).toRMap(e=>e)}}function Co(e,t){let n=null;for(let[,r]of e.data)for(let e of r)if(e.material.length>0&&(n===null||n.time<e.x)){let r=t?e.activeMinutes/e.material.length:e.activeMinutes;n={time:e.x,mins:r}}return n?.mins}function wo(e){return Ra(e,e=>e.stationLabel,e=>e.endTime).flatMap(function*([e,t]){for(let n of t){let t=D.of(n).sumBy(e=>e.elapsedMinsPerMaterial*e.material.length),r=jn(n[0].endTime,-t*60),i=D.of(n).sumBy(e=>e.activeMinutes);yield{station:e,startTime:r,endActive:i>0?Gn(r,i):void 0,endOccupied:n[0].endTime,outlier:n.some(e=>e.isOutlier),parts:D.of(n).flatMap(e=>D.of(e.material).distinctBy(e=>e.proc).map(t=>({part:e.part,proc:t.proc,oper:e.operation}))).distinctAndSortBy(e=>e.part,e=>e.proc,e=>e.oper).map(e=>({part:e.part+`-`+e.proc.toString(),oper:e.oper})).toRArray()}}}).toRArray()}function To(e,t){let n=[],r=new Set,i=new Set,a=new Set;for(let n of e.material){let e=t.get(n.id);if(e!==void 0){for(let t of e.signaledInspections)r.add(t);for(let[t,n]of D.ofObject(e.completedInspections??{}))r.add(t),i.add(t),n.success&&a.add(t)}}for(let e of D.of(r).toSortedArray(e=>e))i.has(e)?n.push(e+`[`+(a.has(e)?`success`:`failed`)+`]`):n.push(e);return n.join(`, `)}function Eo(e,t,n,r,i,a,o){let s=`<table>
|
|
2
|
+
<thead><tr>`;s+=`<th>Date</th><th>Part</th><th>Station</th><th>Carrier</th>`,s+=`<th>Serial</th><th>Workorder</th><th>Inspection</th>`,s+=`<th>Elapsed Min</th><th>Target Min</th>`,i||(s+=`<th>Median Elapsed Min</th><th>Median Deviation</th>`),s+=`</tr></thead>
|
|
3
|
+
<tbody>
|
|
4
|
+
`;let c=D.of(e.data).flatMap(([,e])=>e).filter(e=>(!n||e.endTime>=n)&&(!r||e.endTime<r)).toSortedArray(e=>e.endTime.getTime());for(let e of c)s+=`<tr>`,s+=`<td>`+e.endTime.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`})+`</td>`,s+=`<td>`+e.part+`-`+D.of(e.material).map(e=>e.proc).distinctAndSortBy(e=>e).toRArray().join(`:`)+`</td>`,s+=`<td>`+Qa(e.stationGroup,e.stationNumber,a)+`</td>`,s+=`<td>`+to(e,eo(o))+`</td>`,s+=`<td>`+e.material.filter(e=>e.serial).map(e=>e.serial).join(`,`)+`</td>`,s+=`<td>`+e.material.filter(e=>e.workorder).map(e=>e.workorder).join(`,`)+`</td>`,s+=`<td>`+To(e,t)+`</td>`,s+=`<td>`+(e.elapsedMinsPerMaterial*e.material.length).toFixed(1)+`</td>`,s+=`<td>`+e.activeMinutes.toFixed(1)+`</td>`,i||(s+=`<td>`+e.medianCycleMinutes.toFixed(1)+`</td>`,s+=`<td>`+e.MAD_aboveMinutes.toFixed(1)+`</td>`),s+=`</tr>
|
|
5
|
+
`;return s+=`</tbody>
|
|
6
|
+
</table>`,s}function Do(e,t,n,r,i,a){Je(Eo(e,t,n?n.start:void 0,n?n.end:void 0,r,i,a)).catch(console.error)}function Oo(e,t=`Pallet`){let n=`<table>
|
|
7
|
+
<thead><tr>`;n+=`<th>${t}</th><th>Date</th><th>Elapsed (min)</th>`,n+=`</tr></thead>
|
|
8
|
+
<tbody>
|
|
9
|
+
`;let r=e.keysToLazySeq().toSortedArray(e=>e);for(let t of r)for(let r of e.get(t)?.valuesToLazySeq()??[])n+=`<tr>`,n+=`<td>`+t.toString()+`</td>`,n+=`<td>`+r.x.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`})+`</td>`,n+=`<td>`+r.y.toFixed(1)+`</td>`,n+=`</tr>
|
|
10
|
+
`;return n+=`</tbody>
|
|
11
|
+
</table>`,n}function ko(e,t=`Pallet`){Je(Oo(e,t)).catch(console.error)}function Ao(e){switch(e.type){case V.LoadUnloadCycle:case V.MachineCycle:return e.loc+` #`+e.locnum.toString();case V.AddToQueue:case V.RemoveFromQueue:return e.loc;case V.PartMark:return`Mark`;case V.OrderAssignment:return`Workorder`;case V.CloseOut:return`CloseOut`;case V.Inspection:return`Signal `+((e.details||{}).InspectionType||``);case V.InspectionForce:return`Signal `+e.program;case V.InspectionResult:return`Inspect `+e.program;default:return e.loc}}function jo(e){switch(e.type){case V.Inspection:case V.InspectionForce:case V.LoadUnloadCycle:case V.PartMark:case V.OrderAssignment:return e.result;case V.AddToQueue:return`Add`;case V.RemoveFromQueue:return`Remove`;case V.MachineCycle:return e.program;case V.InspectionResult:return e.result.toLowerCase()===`false`?`Failed`:`Succeeded`;default:return``}}function Mo(e){let t=`<table>
|
|
12
|
+
<thead><tr>`;t+=`<th>Date</th><th>Part</th><th>Station</th><th>Pallet</th>`,t+=`<th>Serial</th><th>Workorder</th><th>Result</th><th>Elapsed Min</th><th>Active Min</th>`,t+=`</tr></thead>
|
|
13
|
+
<tbody>
|
|
14
|
+
`;for(let n of e)if(!n.startofcycle)for(let e of n.material)t+=`<tr>`,t+=`<td>`+n.endUTC.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`})+`</td>`,t+=`<td>`+e.part+`-`+e.proc.toString()+`</td>`,t+=`<td>`+Ao(n)+`</td>`,t+=`<td>`+n.pal.toString()+`</td>`,t+=`<td>`+(e.serial||``)+`</td>`,t+=`<td>`+(e.workorder||``)+`</td>`,t+=`<td>`+jo(n)+`</td>`,t+=`<td>`+J(n.elapsed).toFixed(1)+`</td>`,t+=`<td>`+J(n.active).toFixed(1)+`</td>`,t+=`</tr>
|
|
15
|
+
`;return t+=`</tbody>
|
|
16
|
+
</table>`,t}function No(e){Je(Mo(e)).catch(console.error)}var Po=F([]),Fo=Po,Io=F([]),Lo=Io;function Ro(e,t){return e.map(e=>({station:e.stationGroup+` #`+e.stationNum.toString(),stationLabel:Qa(e.stationGroup,e.stationNum,t),start:e.startUTC,end:e.endUTC,plannedDown:e.planDown??!1,parts:e.parts?.map(e=>({uniq:e.jobUnique,proc:e.process,path:e.path}))}))}var zo=F(null,(e,t,n)=>{let r=e(G)?.loadStationNames;t(Po,e=>e.concat(Ro(n.stationUse,r)))}),Bo=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.newJobs?.stationUse){let a=n.newJobs?.stationUse,o=e(G)?.loadStationNames;t(Po,e=>{if(i){let t=P(r,-30),n=D.of(e).minBy(e=>e.end.getTime());if((n===void 0||n.start>=t)&&a.length===0)return e;e=e.filter(e=>e.start>=t)}return e.concat(Ro(a,o))})}}),Vo=F(null,(e,t,n)=>{let r=e(G)?.loadStationNames;t(Io,Ro(n.stationUse,r))});function Ho(e){let{target:t}=e;if(!(t instanceof SVGElement))return null;let n=t instanceof SVGSVGElement?t:t.ownerSVGElement;if(!n)return null;let r=n.getScreenCTM();if(!r)return null;let i=n.createSVGPoint();return`changedTouches`in e?(i.x=e.changedTouches[0].clientX,i.y=e.changedTouches[0].clientY):(i.x=e.clientX,i.y=e.clientY),i.matrixTransform(r.inverse())}var Uo=`__bms_measure_text_element`;function Wo(e,t){try{let n=document.getElementById(Uo),r;if(n instanceof SVGTextElement)r=n;else{let e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);e.setAttribute(`aria-hidden`,`true`),e.style.position=`absolute`,e.style.top=`-100%`,e.style.left=`-100%`,e.style.width=`0`,e.style.height=`0`,e.style.opacity=`0`;let n=document.createElementNS(`http://www.w3.org/2000/svg`,`text`);if(!(n instanceof SVGTextElement))return null;r=n,r.setAttribute(`id`,Uo),t&&(r.style.fontSize=t.toString()),e.appendChild(r),document.body.appendChild(e)}return r.textContent=e,r.getComputedTextLength()}catch{return null}}var Y=fe(),Go=_r(`div`)({backgroundColor:ft[700],color:`white`,padding:`0.3rem 0.5rem`,borderRadius:`3px`,boxShadow:`0 1px 2px rgba(33, 33, 33, 0.2)`,pointerEvents:`none`});function Ko({chartHeight:e,chartWidth:t,atom:n,TooltipContent:i}){let a=r(n),{ref:o,width:s,height:c}=Ee({refreshMode:`debounce`,refreshRate:100});if(!a)return null;let l=a.left,u=a.top;return s!==void 0&&(l+10+s>t&&l+10>t/2?l=l-s-30:l+=10),c!==void 0&&(u+10+c>e&&u+10>e/2?u=u-c-10:u+=10),(0,Y.jsx)(`div`,{style:{visibility:c!==void 0&&s!==void 0?`visible`:`hidden`,position:`absolute`,left:l,top:u,zIndex:10},children:(0,Y.jsx)(Go,{ref:o,style:a?.zIndex?{zIndex:a.zIndex}:void 0,children:(0,Y.jsx)(i,{tooltip:a})})})}function qo({chart:e,tooltipAtom:t,TooltipContent:n,sx:r,autoHeight:i}){let{ref:a,width:o,height:s}=Ee({refreshMode:`debounce`,refreshRate:100});return(0,Y.jsx)(B,{ref:a,sx:r,children:(0,Y.jsxs)(B,{sx:{position:`relative`,overflow:`hidden`},children:[o&&(s||i)?e({width:o,height:s??0}):void 0,s&&o?(0,Y.jsx)(Ko,{chartHeight:s,chartWidth:o,atom:t,TooltipContent:n}):void 0]})})}function Jo(e){return D.ofObject(e.baskets??{}).collect(([,e])=>{let t=e.position;return t===void 0?null:t.location===gi.LoadUnload||t.location===gi.LoadStationStaging?[e.basketId,{group:`L/U`,num:t.locationNum}]:null}).toRMap(([e,t])=>[e,t])}function Yo(e,t,n){return e.action.type===U.LoadingToBasket?n.get(e.action.loadToBasketId??0)??null:e.action.type===U.Loading?e.action.loadOntoPalletNum?t.get(e.action.loadOntoPalletNum)??null:e.action.loadFromBasketId?n.get(e.action.loadFromBasketId)??null:null:e.location.palletNum?t.get(e.location.palletNum)??null:e.location.basketId?n.get(e.location.basketId)??null:null}function Xo(e,t,n,r){return D.of(e.material).collect(e=>{if(e.action.type!==U.Machining||!e.location.palletNum)return null;let t=n.get(e.location.palletNum);return t?{mat:e,loc:t}:null}).groupBy(({loc:e})=>e.group,({loc:e})=>e.num).map(([[n,i],a])=>{let o=t.get(new ka(a[0].mat.partName,n,a[0].mat.action.program??``)),s=Oa(a[0].mat.action.elapsedMachiningTime??`PT0S`),c=Oa(a[0].mat.action.expectedRemainingMachiningTime??`PT0S`);return{station:Qa(n,i,r),start:jn(e.timeOfCurrentStatusUTC,-s),expectedEnd:jn(e.timeOfCurrentStatusUTC,c),isOutlier:o?Fa(o,s/60/a.length):!1,parts:[{part:a[0].mat.partName,oper:a[0].mat.action.program??``}]}})}function Zo(e,t,n,r){let i=Jo(e);return D.of(e.material).collect(e=>{if(e.action.type===U.UnloadToCompletedMaterial||e.action.type===U.UnloadToInProcess){let t=Yo(e,n,i);return t?{mat:e,material:[e],proc:e.process,path:e.path,loc:t}:null}if(e.action.type===U.Loading||e.action.type===U.LoadingToBasket){let t=Yo(e,n,i);return t?{mat:e,material:[e],proc:e.action.processAfterLoad??e.process,path:e.action.pathAfterLoad??e.path,loc:t}:null}return null}).map(t=>{let n=e.jobs[t.mat.jobUnique],r=n?.procsAndPaths?.[t.proc-1],i=n?.procsAndPaths?.[t.proc-1]?.paths?.[t.path-1];if(t.mat.action.type===U.Loading||t.mat.action.type===U.LoadingToBasket){let e=t.mat.action.type===U.Loading?i?.expectedLoadTime:r?.expectedBasketLoadTime??i?.expectedLoadTime;return{...t,expectedLoadSecs:Oa(e??`PT0S`)}}{let e=t.mat.location.palletNum!==null&&t.mat.location.palletNum!==void 0?i?.expectedUnloadTime:r?.expectedBasketUnloadTime??i?.expectedUnloadTime;return{...t,expectedLoadSecs:Oa(e??`PT0S`)}}}).groupBy(({loc:e})=>e.group,({loc:e})=>e.num).map(([[n,i],a])=>{let o=za(a,e=>J(e.mat.action.elapsedLoadUnloadTime??`PT0S`),e=>e.expectedLoadSecs/60),s=!1,c=0;for(let{cycle:e,elapsedForSingleMaterialMinutes:r}of o){let i=t.get(new ka(e.mat.partName,n,e.mat.action.type===U.Loading||e.mat.action.type===U.LoadingToBasket?`LOAD-`+e.proc.toString():`UNLOAD-`+e.proc.toString()));i&&Fa(i,r)&&(s=!0),e.expectedLoadSecs>0?c+=e.expectedLoadSecs:i?.expectedCycleMinutesForSingleMat&&(c+=i.expectedCycleMinutesForSingleMat*60)}let l=Oa(a[0].mat.action.elapsedLoadUnloadTime??`PT0S`);return{station:Qa(n,i,r),start:jn(e.timeOfCurrentStatusUTC,-l),expectedEnd:jn(e.timeOfCurrentStatusUTC,-l+c),isOutlier:s,parts:D.of(a).distinctAndSortBy(e=>e.mat.partName,e=>e.proc,e=>e.mat.action.type===U.Loading||e.mat.action.type===U.LoadingToBasket?`LOAD`:`UNLOAD`).map(e=>({part:e.mat.partName+`-`+e.proc.toString(),oper:e.mat.action.type===U.Loading||e.mat.action.type===U.LoadingToBasket?`LOAD`:`UNLOAD`})).toRArray()}})}function Qo(e,t,n){let r=D.ofObject(e.pallets).buildHashMap(([,e])=>e.palletNum,(e,[,t])=>t.currentPalletLocation);return Xo(e,t,r,n).concat(Zo(e,t,r,n)).toRArray()}function $o({scale:e,width:t,tickOverride:n}){return(0,Y.jsx)(`g`,{children:(n??e.ticks()).map((n,r)=>(0,Y.jsx)(`line`,{x1:0,y1:e(n),x2:t,y2:e(n),stroke:`#eaf0f6`,strokeWidth:1},r))})}function es({scale:e,height:t,tickOverride:n}){return(0,Y.jsx)(`g`,{children:(n??e.ticks()).map((n,r)=>(0,Y.jsx)(`line`,{x1:e(n),y1:0,x2:e(n),y2:t,stroke:`#eaf0f6`,strokeWidth:1},r))})}function ts({xScale:e,yScale:t,width:n,height:r,rowTickOverride:i,colTickOverride:a}){return(0,Y.jsxs)(`g`,{children:[(0,Y.jsx)($o,{scale:t,width:n,tickOverride:i}),(0,Y.jsx)(es,{scale:e,height:r,tickOverride:a})]})}var ns=8;function rs(e,t){if(t)return t.map(t=>({tick:t,pos:e(t)??0}));if(`ticks`in e&&e.ticks)return e.ticks().map(t=>({tick:t,pos:e(t)??0}));if(`bandwidth`in e&&e.bandwidth){let t=e.bandwidth();return e.domain().map(n=>({tick:n,pos:(e(n)??0)+t/2}))}return e.domain().map(t=>({tick:t,pos:e(t)??0}))}function is({top:e,scale:t,label:n,fontSize:r,tickFormat:i,tickOverride:a}){r??=10,i??=`tickFormat`in t&&t.tickFormat?t.tickFormat():e=>String(e);let o=rs(t,a),s=t.range();return(0,Y.jsxs)(`g`,{transform:`translate(0, ${e})`,children:[(0,Y.jsx)(`line`,{x1:s[0],y1:0,x2:s[1],y2:0,stroke:`#222`,strokeWidth:1,shapeRendering:`crispEdges`}),o.map((e,t)=>(0,Y.jsxs)(`g`,{transform:`translate(${e.pos}, 0)`,children:[(0,Y.jsx)(`line`,{y1:ns,y2:0,stroke:`#222`,strokeWidth:1,shapeRendering:`crispEdges`}),(0,Y.jsx)(`text`,{dy:13,textAnchor:`middle`,fontSize:r,fill:`#222`,dominantBaseline:`hanging`,children:i(e.tick)})]},t)),n?(0,Y.jsx)(`text`,{x:(s[0]+s[1])/2,y:ns+r+20,textAnchor:`middle`,fontSize:r+2,fill:`#222`,children:n}):void 0]})}function as({left:e,scale:t,label:n,fontSize:r,tickFormat:i,tickOverride:a}){r??=10,i??=`tickFormat`in t&&t.tickFormat?t.tickFormat():e=>String(e);let o=rs(t,a),s=t.range();return(0,Y.jsxs)(`g`,{transform:`translate(${e}, 0)`,children:[(0,Y.jsx)(`line`,{x1:0,y1:s[0],x2:0,y2:s[1],stroke:`#222`,strokeWidth:1,shapeRendering:`crispEdges`}),o.map((e,t)=>(0,Y.jsxs)(`g`,{transform:`translate(0, ${e.pos})`,children:[(0,Y.jsx)(`line`,{x1:-8,x2:0,y1:0,y2:0,stroke:`#222`,strokeWidth:1,shapeRendering:`crispEdges`}),(0,Y.jsx)(`text`,{dx:-13,textAnchor:`end`,fontSize:r,fill:`#222`,dominantBaseline:`middle`,children:i(e.tick)})]},t)),n?(0,Y.jsx)(`text`,{x:-(s[0]+s[1])/2,y:-8-r-20,textAnchor:`middle`,fontSize:r+2,fill:`#222`,transform:`rotate(-90)`,children:n}):void 0]})}function os({top:e,scale:t,label:n,fontSize:r,tickFormat:i,tickOverride:a}){r??=10,i??=`tickFormat`in t&&t.tickFormat?t.tickFormat():e=>String(e);let o=rs(t,a),s=t.range();return(0,Y.jsxs)(`g`,{transform:`translate(0, ${e})`,children:[(0,Y.jsx)(`line`,{x1:s[0],y1:0,x2:s[1],y2:0,stroke:`#222`,strokeWidth:1,shapeRendering:`crispEdges`}),o.map((e,t)=>(0,Y.jsxs)(`g`,{transform:`translate(${e.pos}, 0)`,children:[(0,Y.jsx)(`line`,{y1:0,y2:-8,stroke:`#222`,strokeWidth:1,shapeRendering:`crispEdges`}),(0,Y.jsx)(`text`,{dy:-13,textAnchor:`middle`,fontSize:r,fill:`#222`,children:i(e.tick)})]},t)),n?(0,Y.jsx)(`text`,{x:(s[0]+s[1])/2,y:-8-r-20,textAnchor:`middle`,fontSize:r+2,fill:`#222`,children:n}):void 0]})}var ss=we[200],cs=we[600],ls=we[900],us=In[700],ds=ft[400],fs=ft[100],ps=F(e=>Math.floor(e(ya)/5)*5*6e4);function ms(e){let t=r(ia),n=r(Fo);return(0,K.useMemo)(()=>{let r=er(e,-12);return D.of(n).filter(e=>e.end>=r).sortBy(e=>+!!e.plannedDown).map(e=>({station:e.stationLabel,start:e.start,end:e.end,plannedDown:e.plannedDown,parts:D.of(e.parts??[]).collect(e=>{let n=t.get(e.uniq);return n?n.partName+`-`+e.proc.toString():null}).distinctAndSortBy(e=>e).toRArray()})).toRArray()},[t,n,e])}var hs=F(null),gs=14,_s=20,vs=10,ys=2;function bs(e,t,n,r,i){let a=Se.build(e,e=>e.station).union(Se.build(t,e=>e.station)),o=(a.toAscLazySeq().map(e=>Wo(e,gs)).maxBy(e=>e??0)??20)+30,s=Math.max(r-o-ys,5),c=Math.max(i-vs-_s,5),l=me().domain([er(n,-12),er(n,8)]).range([0,s]),u=Ve().domain(Array.from(a)).range([0,c]).padding(.3);return{xScale:l,yScale:u,actualPlannedScale:Ve().domain([`actual`,`planned`]).range([0,u.bandwidth()]).padding(.1),marginLeft:o}}function xs({xScale:e,yScale:t}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(is,{scale:e,top:t.range()[1]}),(0,Y.jsx)(as,{scale:t,left:e.range()[0],fontSize:gs}),(0,Y.jsx)(es,{scale:e,height:t.range()[1]-t.range()[0]})]})}function Ss({cycles:e,xScale:t,yScale:n,actualPlannedScale:r,hideTooltipRef:i}){let a=r(`actual`)??0,o=j(hs);function s(e){return t=>{let n=Ho(t);n&&(i.current!==null&&(clearTimeout(i.current),i.current=null),o({left:n.x,top:n.y,data:{kind:`actual`,cycle:e}}))}}let c=(0,K.useCallback)(()=>{i.current=setTimeout(()=>{o(null)},300)},[i,o]);return(0,Y.jsx)(`g`,{children:e.map((e,i)=>e.endActive&&e.endActive<e.endOccupied?(0,Y.jsxs)(`g`,{onMouseOver:s(e),onMouseLeave:c,children:[(0,Y.jsx)(`rect`,{x:t(e.startTime),y:(n(e.station)??0)+a,width:t(e.endOccupied)-t(e.startTime),height:r.bandwidth(),fill:cs}),(0,Y.jsx)(`rect`,{x:t(e.endActive),y:(n(e.station)??0)+a+r.bandwidth()/10,width:t(e.endOccupied)-t(e.endActive),height:r.bandwidth()*8/10,fill:e.outlier?us:ls})]},i):(0,Y.jsx)(`g`,{onMouseOver:s(e),onMouseLeave:c,children:(0,Y.jsx)(`rect`,{x:t(e.startTime),y:(n(e.station)??0)+a,width:t(e.endOccupied)-t(e.startTime),height:r.bandwidth(),fill:cs})},i))})}function Cs(e,t,n,r){return`M ${e} ${t} A ${n} ${r} 0 0 1 ${e} ${t+r}`}function ws({now:e,cycles:t,xScale:n,yScale:r,actualPlannedScale:i,hideTooltipRef:a}){let o=i(`actual`)??0,s=j(hs);function c(t){return n=>{let r=Ho(n);r&&(a.current!==null&&(clearTimeout(a.current),a.current=null),s({left:r.x,top:r.y,data:{kind:`current`,cycle:t,now:e}}))}}let l=(0,K.useCallback)(()=>{a.current=setTimeout(()=>{s(null)},300)},[a,s]);return(0,Y.jsx)(`g`,{children:t.map((t,a)=>(0,Y.jsxs)(`g`,{onMouseOver:c(t),onMouseLeave:l,children:[(0,Y.jsx)(`rect`,{x:n(t.start),y:(r(t.station)??0)+o,width:n(e)-n(t.start),height:i.bandwidth(),fill:cs}),t.expectedEnd<e?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`rect`,{x:n(t.expectedEnd),y:(r(t.station)??0)+o+i.bandwidth()/10,width:n(e)-n(t.expectedEnd),height:i.bandwidth()*8/10,fill:t.isOutlier?us:ls}),(0,Y.jsx)(`path`,{d:Cs(n(e),(r(t.station)??0)+o,80,i.bandwidth()),fill:ss})]}):(0,Y.jsx)(`rect`,{x:n(e),y:(r(t.station)??0)+o,width:n(t.expectedEnd)-n(e),height:i.bandwidth(),fill:ss})]},a))})}function Ts({sim:e,xScale:t,yScale:n,actualPlannedScale:r,hideTooltipRef:i}){let a=r(`planned`)??0,o=j(hs);function s(e){return t=>{let n=Ho(t);n&&(i.current!==null&&(clearTimeout(i.current),i.current=null),o({left:n.x,top:n.y,data:{kind:`sim`,cycle:e}}))}}let c=(0,K.useCallback)(()=>{i.current=setTimeout(()=>{o(null)},300)},[i,o]);return(0,Y.jsx)(`g`,{children:e.map((e,i)=>(0,Y.jsx)(`g`,{onMouseOver:s(e),onMouseLeave:c,children:(0,Y.jsx)(`rect`,{x:t(e.start),y:(n(e.station)??0)+a,width:t(e.end)-t(e.start),height:r.bandwidth(),fill:e.plannedDown?fs:ds})},i))})}function Es({tooltip:e}){return(0,Y.jsx)(E,{children:e.data.kind===`actual`?(0,Y.jsxs)(Y.Fragment,{children:[e.data.cycle.outlier?(0,Y.jsxs)(`div`,{children:[`Outlier Cycle for `,e.data.cycle.station]}):(0,Y.jsx)(`div`,{children:e.data.cycle.station}),(0,Y.jsxs)(`div`,{children:[`Start: `,e.data.cycle.startTime.toLocaleString()]}),(0,Y.jsxs)(`div`,{children:[`End: `,e.data.cycle.endOccupied.toLocaleString()]}),e.data.cycle.endActive===void 0?void 0:(0,Y.jsxs)(`div`,{children:[`Active Minutes:`,` `,Xn(e.data.cycle.endActive,e.data.cycle.startTime)]}),(0,Y.jsxs)(`div`,{children:[`Occupied Minutes:`,` `,Xn(e.data.cycle.endOccupied,e.data.cycle.startTime)]}),e.data.cycle.parts.map((e,t)=>(0,Y.jsxs)(`div`,{children:[`Part: `,e.part,` `,e.oper]},t))]}):e.data.kind===`sim`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{children:[`Simulation of `,e.data.cycle.station]}),e.data.cycle.parts.map((e,t)=>(0,Y.jsxs)(`div`,{children:[`Part: `,e]},t)),(0,Y.jsxs)(`div`,{children:[`Predicted Start: `,e.data.cycle.start.toLocaleString()]}),(0,Y.jsxs)(`div`,{children:[`Predicted End: `,e.data.cycle.end.toLocaleString()]}),e.data.cycle.plannedDown?(0,Y.jsx)(`div`,{children:`Planned Downtime`}):void 0]}):(0,Y.jsxs)(Y.Fragment,{children:[e.data.cycle.isOutlier?(0,Y.jsxs)(`div`,{children:[`Current Outlier Cycle for `,e.data.cycle.station]}):(0,Y.jsxs)(`div`,{children:[`Current `,e.data.cycle.station]}),(0,Y.jsxs)(`div`,{children:[`Start: `,e.data.cycle.start.toLocaleString()]}),(0,Y.jsxs)(`div`,{children:[`Expected End: `,e.data.cycle.expectedEnd.toLocaleString()]}),e.data.cycle.expectedEnd<e.data.now?(0,Y.jsxs)(`div`,{children:[`Cycle Exceeding Expected By`,` `,Xn(e.data.now,e.data.cycle.expectedEnd),` Minutes`]}):(0,Y.jsxs)(`div`,{children:[`Expected Remaining Minutes:`,` `,Xn(e.data.cycle.expectedEnd,e.data.now)]}),(0,Y.jsxs)(`div`,{children:[`Occupied Minutes: `,Xn(e.data.now,e.data.cycle.start)]}),e.data.cycle.parts.map((e,t)=>(0,Y.jsxs)(`div`,{children:[`Part: `,e.part,` `,e.oper]},t))]})})}function Ds({now:e,xScale:t,yScale:n}){let r=t(e);return(0,Y.jsxs)(`g`,{children:[(0,Y.jsx)(`line`,{x1:r,x2:r,y1:n.range()[0],y2:n.range()[1]+8,stroke:`black`}),(0,Y.jsx)(`text`,{x:r,y:n.range()[1]+8+11,textAnchor:`middle`,fontSize:11,children:`Now`})]})}function Os({height:e,width:t}){let n=r(ao),i=r(ja),a=r(q),o=r(ps),s=(0,K.useMemo)(()=>new Date(o),[o]),c=(0,K.useMemo)(()=>new Date(Math.max(o,a.timeOfCurrentStatusUTC.getTime())),[o,a.timeOfCurrentStatusUTC]),l=ms(s),u=r(G),d=(0,K.useMemo)(()=>{let e=er(s,-12);return wo(n.valuesToLazySeq().filter(t=>t.endTime>=e))},[n,s]),f=(0,K.useMemo)(()=>Qo(a,i,u.loadStationNames),[a,i,u.loadStationNames]),{xScale:p,yScale:m,actualPlannedScale:h,marginLeft:g}=bs(d,f,c,t,e),ee=(0,K.useRef)(null);return e<=0||t<=0?null:(0,Y.jsxs)(`div`,{style:{position:`relative`,overflow:`hidden`},children:[(0,Y.jsx)(`svg`,{height:e,width:t,children:(0,Y.jsxs)(`g`,{transform:`translate(${g}, ${vs})`,children:[(0,Y.jsx)(`clipPath`,{id:`recent-cycle-clip-body`,children:(0,Y.jsx)(`rect`,{x:0,y:0,width:t-ys-g,height:e-_s-vs})}),(0,Y.jsx)(xs,{xScale:p,yScale:m}),(0,Y.jsxs)(`g`,{clipPath:`url(#recent-cycle-clip-body)`,children:[(0,Y.jsx)(Ss,{cycles:d,xScale:p,yScale:m,hideTooltipRef:ee,actualPlannedScale:h}),(0,Y.jsx)(ws,{now:c,cycles:f,xScale:p,yScale:m,hideTooltipRef:ee,actualPlannedScale:h}),(0,Y.jsx)(Ts,{sim:l,xScale:p,yScale:m,actualPlannedScale:h,hideTooltipRef:ee})]}),(0,Y.jsx)(Ds,{now:c,xScale:p,yScale:m})]})}),(0,Y.jsx)(Ko,{chartHeight:e,chartWidth:t,atom:hs,TooltipContent:Es})]})}function ks(e,t){return e.impact===ri.SuspendChanges&&(e.activity==null||e.activity===t.activity)&&(e.basketId==null||e.basketId===t.basketId)}function As(e,t){return(e.alarmDetails??[]).filter(e=>ks(e,t))}function js(e,t){if(!e.alarmDetails?.length)return[];let n=[{},...t.flatMap(t=>{let n=t.materialID>=0?e.material?.find(e=>e.materialID===t.materialID):void 0;return n&&n!==t?[t,n]:[t]}).flatMap(e=>{let t=e.action.type===U.LoadingToBasket||e.action.type===U.UnloadToInProcess||e.action.type===U.UnloadToCompletedMaterial;return[...e.location.type===H.InBasket?[{basketId:e.location.basketId,activity:t?ii.BasketLoadStation:void 0}]:[],...e.action.type===U.LoadingToBasket?[{basketId:e.action.loadToBasketId,activity:ii.BasketLoadStation}]:[],...e.action.type===U.Loading&&e.action.loadFromBasketId!==void 0?[{basketId:e.action.loadFromBasketId,activity:e.action.loadOntoPalletNum==null?ii.BasketLoadStation:void 0}]:[],...t&&e.action.unloadToBasketId!==void 0?[{basketId:e.action.unloadToBasketId}]:[]]})];return(e.alarmDetails??[]).filter(e=>n.some(t=>ks(e,t)))}function Ms(e,t){return(t.action.type===U.Loading||t.action.type===U.LoadingToBasket||t.action.type===U.UnloadToInProcess||t.action.type===U.UnloadToCompletedMaterial)&&js(e,[t]).length>0}function*Ns(e){let t=null;for(let n of e)t!=null&&t.type===V.RemoveFromQueue&&n.type===V.AddToQueue&&t.loc===n.loc?t=null:(t!==null&&(yield t),t=n);t!==null&&(yield t)}function Ps(e,t){return e.pal>0?`${t} ${e.pal}`:t}function Fs(e,t){let n=Ps(e,t);return e.startofcycle?`${n} started cycle`:`${n} completed cycle`}var Is=_r(`span`,{shouldForwardProp:e=>e.toString()[0]!==`$`})(({$type:e})=>{switch(e){case`machine`:return{color:`#1565C0`};case`loadStation`:return{color:`#795548`};case`pallet`:return{color:`#00695C`};case`queue`:return{color:`#6A1B9A`};case`inspectionNotSignaled`:return{color:`#4527A0`};case`inspectionSignaled`:return{color:`red`};case`closeoutFailed`:return{color:`red`}}});function Ls(e,t){let n=eo(t.basketName);switch(e.type){case V.LoadUnloadCycle:return e.startofcycle?`Start `+e.result.charAt(0).toUpperCase()+e.result.substring(1).toLowerCase():`End `+e.result.charAt(0).toUpperCase()+e.result.substring(1).toLowerCase();case V.BasketLoadUnload:return e.program===`LOAD`?`${n} Load`:`${n} Unload`;case V.BasketCycle:return`${n} Cycle`;case V.MachineCycle:return e.startofcycle?`Start Cycle`:`End Cycle`;case V.PartMark:return`Serial`;case V.OrderAssignment:return`Workorder`;case V.Inspection:case V.InspectionForce:return`Signal`;case V.PalletCycle:return`Pallet Cycle`;case V.WorkorderComment:return`Workorder`;case V.CloseOut:return`CloseOut`;case V.InspectionResult:return`Inspection`;case V.AddToQueue:return`Queue`;case V.RemoveFromQueue:return`Queue`;case V.PalletInStocker:return`Stocker`;case V.PalletOnRotaryInbound:return`Rotary`;case V.SignalQuarantine:return`Quarantine`;case V.SwapMaterialOnPallet:return`Swap Serial`;case V.InvalidateCycle:return`Invalidate Cycle`;case V.Rebooking:return`Rebooking`;case V.CancelRebooking:return`Cancel Rebooking`;case V.CastingAssigned:return`Casting Assigned`;case V.CastingUnassigned:return`Casting Unassigned`;case V.JobDecrement:return`Job Decrement`;default:return`Message`}}function Rs(e){return e.details?.PalletCycleInvalidated===`1`}function zs(e){return e.length>1?e[0].numproc==1?`${e[0].part} x${e.length}`:`${e[0].part}-${D.of(e).map(e=>e.proc).distinctAndSortBy(e=>e).toRArray().join(`&`)} x${e.length}`:e.length==1?e[0].numproc==1?e[0].part:`${e[0].part}-${e[0].proc}`:``}function Bs(e){return e.length>1?`${e[0].part} x${e.length}`:e.length===1?e[0].part:``}function Vs(e,t){let n=e.entry;switch(n.type){case V.LoadUnloadCycle:return(0,Y.jsxs)(`span`,{children:[zs(n.material),` on`,` `,(0,Y.jsxs)(Is,{$type:`pallet`,children:[`pallet `,n.pal]}),` at`,` `,(0,Y.jsx)(Is,{$type:`loadStation`,children:Za(n.locnum,t.loadStationNames)})]});case V.BasketLoadUnload:{let e=eo(t.basketName);return(0,Y.jsxs)(`span`,{children:[zs(n.material),` `,n.program===`LOAD`?`loaded onto`:`unloaded from`,` `,(0,Y.jsx)(Is,{$type:`pallet`,children:Ps(n,e)}),` at`,` `,(0,Y.jsx)(Is,{$type:`loadStation`,children:Za(n.locnum,t.loadStationNames)})]})}case V.BasketCycle:{let e=eo(t.basketName);return(0,Y.jsx)(`span`,{children:Fs(n,e)})}case V.MachineCycle:return(0,Y.jsxs)(`span`,{children:[zs(n.material),` on`,` `,(0,Y.jsxs)(Is,{$type:`pallet`,children:[`pallet `,n.pal]}),` at`,` `,(0,Y.jsxs)(Is,{$type:`machine`,children:[n.loc,` `,n.locnum.toString()]}),n.program&&n.program!==``?(0,Y.jsxs)(`span`,{children:[` with program `,n.program]}):void 0]});case V.PartMark:return(0,Y.jsxs)(`span`,{children:[zs(n.material),` marked with `,n.result]});case V.OrderAssignment:return(0,Y.jsxs)(`span`,{children:[zs(n.material),` assigned to workorder `,n.result]});case V.PalletCycle:return n.startofcycle?(0,Y.jsxs)(`span`,{children:[`Pallet `,n.pal,` started route`]}):(0,Y.jsxs)(`span`,{children:[`Pallet `,n.pal,` completed route`]});case V.Inspection:{let e=(n.details||{}).InspectionType||``;return n.result.toLowerCase()===`true`||n.result===`1`?(0,Y.jsxs)(`span`,{children:[zs(n.material),` signaled for inspection`,` `,(0,Y.jsx)(Is,{$type:`inspectionSignaled`,children:e})]}):(0,Y.jsxs)(`span`,{children:[zs(n.material),` skipped inspection`,` `,(0,Y.jsx)(Is,{$type:`inspectionNotSignaled`,children:e})]})}case V.InspectionForce:{let e=n.program;return n.result.toLowerCase()===`true`||n.result===`1`?(0,Y.jsxs)(`span`,{children:[zs(n.material),` declared for inspection`,` `,(0,Y.jsx)(Is,{$type:`inspectionSignaled`,children:e})]}):(0,Y.jsxs)(`span`,{children:[zs(n.material),` passed over for inspection`,` `,(0,Y.jsx)(Is,{$type:`inspectionNotSignaled`,children:e})]})}case V.WorkorderComment:return(0,Y.jsxs)(`span`,{children:[`Workorder `,n.result,` Comment`]});case V.InspectionResult:return n.result.toLowerCase()===`false`?(0,Y.jsxs)(Is,{$type:`inspectionSignaled`,children:[n.program,` Failed`]}):(0,Y.jsxs)(Is,{$type:`inspectionSignaled`,children:[n.program,` Succeeded`]});case V.CloseOut:return n.result.toLowerCase()===`failed`?(0,Y.jsxs)(Is,{$type:`closeoutFailed`,children:[n.program&&n.program!==``?n.program:`CloseOut`,` Failed`]}):(0,Y.jsxs)(`span`,{children:[n.program&&n.program!==``?n.program:`CloseOut`,` Completed`]});case V.AddToQueue:switch(n.program){case`Unloaded`:return(0,Y.jsxs)(`span`,{children:[Bs(n.material),` unloaded into queue`,` `,(0,Y.jsx)(Is,{$type:`queue`,children:n.loc})]});case`SetByOperator`:return(0,Y.jsxs)(`span`,{children:[Bs(n.material),` set manually into queue`,` `,(0,Y.jsx)(Is,{$type:`queue`,children:n.loc})]});case`Quarantine`:return(0,Y.jsxs)(`span`,{children:[Bs(n.material),` quarantined into queue`,` `,(0,Y.jsx)(Is,{$type:`queue`,children:n.loc})]});case`SwapMaterial`:return(0,Y.jsxs)(`span`,{children:[Bs(n.material),` swapped off pallet into queue`,` `,(0,Y.jsx)(Is,{$type:`queue`,children:n.loc})]});case`MaterialMissingOnPallet`:return(0,Y.jsxs)(`span`,{children:[Bs(n.material),` removed from cell controller, added to queue`,` `,(0,Y.jsx)(Is,{$type:`queue`,children:n.loc})]});default:return(0,Y.jsxs)(`span`,{children:[Bs(n.material),` added to queue`,` `,(0,Y.jsx)(Is,{$type:`queue`,children:n.loc}),n.program&&n.program!==``?` (`+n.program+`)`:void 0]})}case V.RemoveFromQueue:return(0,Y.jsxs)(`span`,{children:[Bs(n.material),` removed from queue`,` `,(0,Y.jsx)(Is,{$type:`queue`,children:n.loc})]});case V.PalletInStocker:return n.startofcycle?(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(Is,{$type:`pallet`,children:[`Pallet `,n.pal]}),` arrived at stocker`,` `,n.locnum]}):(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(Is,{$type:`pallet`,children:[`Pallet `,n.pal]}),` departed stocker`,` `,n.locnum]});case V.PalletOnRotaryInbound:return n.startofcycle?(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(Is,{$type:`pallet`,children:[`Pallet `,n.pal]}),` arrived at`,` `,(0,Y.jsxs)(Is,{$type:`machine`,children:[n.loc,` `,n.locnum.toString()]})]}):n.result==`RotateIntoWorktable`?(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(Is,{$type:`pallet`,children:[`Pallet `,n.pal]}),` rotated into`,` `,(0,Y.jsxs)(Is,{$type:`machine`,children:[n.loc,` `,n.locnum.toString()]}),` `,`worktable`]}):(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(Is,{$type:`pallet`,children:[`Pallet `,n.pal]}),` left`,` `,(0,Y.jsxs)(Is,{$type:`machine`,children:[n.loc,` `,n.locnum.toString()]})]});case V.SignalQuarantine:return(0,Y.jsxs)(`span`,{children:[zs(n.material),` signaled for quarantine after unload`]});case V.SwapMaterialOnPallet:return(0,Y.jsx)(`span`,{children:n.result});case V.InvalidateCycle:return(0,Y.jsx)(`span`,{children:n.result});case V.Rebooking:return(0,Y.jsxs)(`span`,{children:[`Rebooking requested with ID `,n.result]});case V.CancelRebooking:return(0,Y.jsxs)(`span`,{children:[`Rebooking `,n.result,` canceled`]});case V.CastingAssigned:return(0,Y.jsxs)(`span`,{children:[`Casting assigned to job `,n.result]});case V.CastingUnassigned:return(0,Y.jsxs)(`span`,{children:[`Casting released from job `,n.result]});case V.JobDecrement:return(0,Y.jsxs)(`span`,{children:[`Job quantities decremented (decrement `,n.result,`)`]});default:return(0,Y.jsx)(`span`,{children:n.result})}}function Hs(e){let t=[];if(e.details&&e.details.operator&&t.push({name:`Operator`,value:e.details.operator}),e.details&&e.details.note&&t.push({name:`Note`,value:e.details.note}),e.tooluse)for(let n of e.tooluse){let e=null;if(n.toolUseDuringCycle&&n.toolUseDuringCycle!==``&&(e=J(n.toolUseDuringCycle).toFixed(1)+` minutes used during cycle.`,n.totalToolUseAtEndOfCycle&&n.configuredToolLife&&n.totalToolUseAtEndOfCycle!==``&&n.configuredToolLife!==``)){let t=Oa(n.totalToolUseAtEndOfCycle),r=Oa(n.configuredToolLife),i=t/r;e+=` Total use at end of cycle: ${(t/60).toFixed(1)}/${(r/60).toFixed(1)} minutes (${(i*100).toFixed(0)}%).`}if(n.toolUseCountDuringCycle&&n.toolUseCountDuringCycle>0&&(e=(e===null?``:` | `)+`${n.toolUseCountDuringCycle} use${n.toolUseCountDuringCycle>1?`s`:``} during cycle.`,n.totalToolUseCountAtEndOfCycle&&n.configuredToolLifeCount&&(e+=` Total use count at end of cycle: ${n.totalToolUseCountAtEndOfCycle}/${n.configuredToolLifeCount} (${(n.totalToolUseCountAtEndOfCycle/n.configuredToolLifeCount*100).toFixed(0)}%).`)),e!==null){let r=n.pocket>0?`${n.tool} [${n.pocket}]`:n.tool,i=n.toolSerialAtEndOfCycle??n.toolSerialAtStartOfCycle;i&&i!==``&&(r+=` (${i})`),t.push({name:r,value:e})}}return t}var Us=[V.AddToQueue,V.RemoveFromQueue,V.LoadUnloadCycle,V.BasketLoadUnload,V.MachineCycle],Ws=_r(o,{shouldForwardProp:e=>e.toString()[0]!==`$`})(({$highlightProc:e,$invalidCycle:t})=>({...e&&{backgroundColor:`#eeeeee`},...t&&{textDecoration:`line-through`}})),Gs=(0,K.memo)(function(e){let t=Hs(e.entry),n=e.highlightProcsGreaterOrEqualTo,i=r(G);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Ws,{$highlightProc:n!==void 0&&e.entry.material.findIndex(e=>e.proc>=n)>=0&&Us.indexOf(e.entry.type)>=0,$invalidCycle:Rs(e.entry),children:[(0,Y.jsx)(w,{size:`small`,children:e.entry.endUTC.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`2-digit`})}),(0,Y.jsx)(w,{size:`small`,children:e.entry.endUTC.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}),(0,Y.jsx)(w,{size:`small`,children:Ls(e.entry,i)}),(0,Y.jsx)(w,{size:`small`,children:Vs(e,i)}),(0,Y.jsx)(w,{padding:`checkbox`,children:t.length>0?(0,Y.jsx)(C,{style:{transition:`all ease 200ms`,transform:e.entry.counter===e.detailLogCounter?`rotate(90deg)`:`none`},onClick:t=>{e.setDetail(e.entry.counter===e.detailLogCounter?null:e.entry.counter),t.stopPropagation()},size:`small`,children:(0,Y.jsx)(Qn,{fontSize:`inherit`})}):void 0})]}),t.length>0&&e.entry.counter===e.detailLogCounter?(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{colSpan:5,children:(0,Y.jsx)(`ul`,{children:t.map((e,t)=>(0,Y.jsxs)(`li`,{children:[e.name,`: `,e.value]},t))})})}):void 0]})}),Ks=(0,K.memo)(function(e){let[t,n]=(0,K.useState)(null);return(0,Y.jsxs)(he,{children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Date`}),(0,Y.jsx)(w,{children:`Time`}),(0,Y.jsx)(w,{children:`Type`}),(0,Y.jsx)(w,{children:`Details`}),(0,Y.jsx)(w,{padding:`checkbox`,children:e.copyToClipboard?(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:()=>No(e.entries),style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,children:(0,Y.jsx)(ct,{})})}):void 0})]})}),(0,Y.jsx)(ae,{children:Array.from(Ns(e.entries)).map((r,i)=>(0,Y.jsx)(Gs,{entry:r,detailLogCounter:t,setDetail:n,highlightProcsGreaterOrEqualTo:e.highlightProcsGreaterOrEqualTo},i))})]})}),qs=F(null),X=F(e=>e(qs),(e,t,n)=>{n===null?(t(qs,null),t(ac,[])):t(qs,n)}),Js=F(async e=>{let t=e(qs);if(t&&t.type===`Barcode`){if(zi===void 0)return null;let n=e(Nc),r=t.toQueue?[t.toQueue]:n.route===Z.Station_LoadMonitor||n.route===Z.Station_Queues?n.queues:null;return await zi.parseBarcode(t.barcode,r)}return null}),Ys=F(async e=>(await e(Js))?.potentialNewMaterial??null),Xs=F(async e=>{let t=e(qs);if(t===null)return null;switch(t.type){case`InProcMat`:return t.inproc;case`MatSummary`:return t.summary;case`MatDetails`:return t.details;case`LogMat`:return{materialID:t.logMat.id,partName:t.logMat.part,serial:t.logMat.serial,workorderId:t.logMat.workorder};case`Barcode`:{let t=await e(Js);return t?.existingMaterial&&t.existingMaterial.materialID>=0?t.existingMaterial:null}case`ManuallyEnteredSerial`:case`AddMatWithEnteredSerial`:return Vi===void 0?null:(await Vi.materialForSerial(t.serial))?.[0]??null}}),Zs=hr(Xs,e=>e??null);function Qs(e){return hr(F(t=>t(e).then(e=>({state:`hasData`,data:e}),e=>({state:`hasError`,error:e}))),()=>({state:`loading`}))}var $s=Qs(Xs);function ec(e,t){let n=e($s);switch(n.state){case`hasData`:return t(n.data);case`hasError`:throw n.error;case`loading`:return e(Xs).then(t)}}var tc=F(e=>{let t=e(qs);if(t===null)return null;let n=e(q);return t.type===`InProcMat`?n.material.find(e=>e.materialID===t.inproc.materialID&&(e.materialID>=0||e.action.loadCancellationId===t.inproc.action.loadCancellationId&&e.action.workId===t.inproc.action.workId&&e.action.loadToBasketSlot===t.inproc.action.loadToBasketSlot&&e.action.loadToBasketId===t.inproc.action.loadToBasketId&&e.jobUnique===t.inproc.jobUnique))??null:ec(e,e=>e!==null&&e.materialID>=0?n.material.find(t=>t.materialID===e.materialID)??null:null)}),nc=F(async e=>{let t=e(qs);if(t===null)return null;switch(t.type){case`InProcMat`:return t.inproc.serial??null;case`MatSummary`:return t.summary.serial??null;case`MatDetails`:return t.details.serial??null;case`LogMat`:return t.logMat.serial??null;case`Barcode`:{let t=await e(Js);return t?.existingMaterial?.serial??t?.potentialNewMaterial?.serial??null}case`ManuallyEnteredSerial`:case`AddMatWithEnteredSerial`:return t.serial}});hr(nc,e=>e??null);var rc=Qs(nc),ic=F(async e=>{let t=e(qs);if(t===null)return null;switch(t.type){case`InProcMat`:return t.inproc.workorderId??null;case`MatSummary`:return t.summary.workorderId??null;case`MatDetails`:return t.details.workorder??null;case`LogMat`:return t.logMat.workorder??null;case`Barcode`:{let t=await e(Js);return t?.existingMaterial?.workorder??t?.potentialNewMaterial?.workorder??null}case`ManuallyEnteredSerial`:case`AddMatWithEnteredSerial`:return null}}),ac=F([]),oc=F(async(e,{signal:t})=>{let n=await e(Xs);return n===null||Vi===void 0?[]:n.materialID>=0?await Vi.logForMaterial(n.materialID,t):n.serial&&n.serial!==``?await Vi.logForSerial(n.serial):[]}),sc=hr(oc,e=>e??[]),cc=F(async(e,{signal:t})=>{let n=await e(nc);if(n===null||n===``)return[];let r=[];for(let e of Wi)r.push.apply(await e.logForSerial(n,t));return r}),lc=hr(cc,e=>e??[]),uc=F(e=>D.of(e(sc)).concat(e(ac)).toRArray()),dc=F(e=>{let t=e(ac);return D.of(e(sc)).concat(e(lc)).sortBy(e=>e.endUTC.getTime(),e=>e.counter).concat(t).toRArray()}),fc=F(async e=>{let t=await e(Xs);if(t===null)return null;let n=e(dc),r=D.of(n).filter(e=>!Rs(e)&&(e.type===V.LoadUnloadCycle||e.type===V.MachineCycle||e.type===V.AddToQueue)).flatMap(e=>e.material).filter(e=>e.id===t.materialID).maxBy(e=>e.proc);return r?{process:r.proc,totalNumProcesses:r.numproc}:null}),pc=F(e=>{let t=e(qs),n=e(dc);if(t===null)return{signaledInspections:[],completedInspections:[]};let r=new Set(t.type===`InProcMat`?t.inproc.signaledInspections:[]),i=new Set;return n.forEach(e=>{switch(e.type){case V.Inspection:if(e.result.toLowerCase()===`true`||e.result===`1`){let t=(e.details||{}).InspectionType;t&&r.add(t)}break;case V.InspectionForce:(e.result.toLowerCase()===`true`||e.result===`1`)&&r.add(e.program);break;case V.InspectionResult:i.add(e.program)}}),{signaledInspections:D.of(r).toSortedArray(e=>e),completedInspections:D.of(i).toSortedArray(e=>e)}}),mc=F(e=>{let t=e(q)?.workorders??[];return ec(e,e=>e===null||e.partName===``?[]:D.of(t).filter(t=>t.part===e.partName).toSortedArray(e=>e.dueDate.getTime(),e=>-e.priority))});function hc(){let e=r(tc);return js(r(q),e?[e]:[])}function gc(){let[e,t]=(0,K.useState)(!1),n=j(ac);return[(0,K.useCallback)(e=>{t(!0),Vi.setInspectionDecision(e.mat.materialID,e.inspType,1,e.inspect).then(e=>n(t=>[...t,e])).catch(console.log).finally(()=>t(!1))},[n]),e]}function _c(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(e=>{t(!0),Vi.recordInspectionCompleted(new ji({materialID:e.mat.materialID,process:1,inspectionLocationNum:1,inspectionType:e.inspType,success:e.success,active:`PT0S`,elapsed:`PT0S`,extraData:e.operator?{operator:e.operator}:void 0})).catch(console.log).finally(()=>t(!1))},[]),e]}function vc(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(e=>{t(!0),Vi.recordCloseoutCompleted(new Mi({materialID:e.mat.materialID,process:1,locationNum:1,closeoutType:``,active:`PT0S`,elapsed:`PT0S`,extraData:e.operator?{operator:e.operator}:void 0,failed:e.failed})).catch(console.log).finally(()=>t(!1))},[]),e]}function yc(){let[e,t]=(0,K.useState)(!1),n=j(ac);return[(0,K.useCallback)((e,r)=>{t(!0),Vi.setWorkorder(e.materialID,1,r).then(e=>n(t=>[...t,e])).catch(console.log).finally(()=>t(!1))},[n]),e]}function bc(){let[e,t]=(0,K.useState)(!1),n=j(ac);return[(0,K.useCallback)(e=>{t(!0),Vi.recordOperatorNotes(e.matId,e.process,e.operator,e.notes).then(e=>n(t=>[...t,e])).catch(console.log).finally(()=>t(!1))},[n]),e]}function xc(){let[e,t]=(0,K.useState)(!1),[n,r]=(0,K.useState)(!1);return[(0,K.useCallback)(e=>{t(!0),zi.printLabel(e.materialId,e.proc).catch(console.log).finally(()=>{t(!1),r(!0)})},[]),e,n]}function Sc(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(async(e,n)=>{t(!0);try{await Bi.removeMaterialFromAllQueues(e,n??void 0)}finally{t(!1)}},[]),e]}function Cc(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(async(e,n,r)=>{t(!0);try{await Bi.signalMaterialForQuarantine(e,n,r===``?void 0:r)}finally{t(!1)}},[]),e]}function wc(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(async(e,n,r)=>{t(!0);try{await Bi.quarantineQueuedMaterial(e,n,r===``?void 0:r)}finally{t(!1)}},[]),e]}function Tc(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(async e=>{t(!0);try{await Bi.setMaterialInQueue(e.materialId,e.operator,new Oi({queue:e.queue,position:e.queuePosition}))}finally{t(!1)}},[]),e]}function Ec(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(async e=>{t(!0);try{let t=await Bi.addUnprocessedMaterialToQueue(e.jobUnique,e.lastCompletedProcess,e.queue,e.queuePosition,e.operator,e.workorder,e.serial||``);if(t===void 0)throw Error(`No material returned`);return e.onNewMaterial?.(t),t}catch(t){throw e.onError?.(t),t}finally{t(!1)}},[]),e]}function Dc(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(async e=>{t(!0);try{let t=await Bi.addUnallocatedCastingToQueue(e.casting,e.queue,e.quantity,e.operator,e.workorder,[...e.serials||[]]);return e.onNewMaterial?.(t),t}catch(t){throw e.onError?.(t),t}finally{t(!1)}},[]),e]}var Z=function(e){return e.ChooseMode=`/`,e.Station_LoadMonitor=`/station/loadunload/:num`,e.Station_InspectionMonitor=`/station/inspection`,e.Station_InspectionMonitorWithType=`/station/inspection/:type`,e.Station_Closeout=`/station/closeout`,e.Station_Queues=`/station/queues`,e.Station_Overview=`/station/overview`,e.Operations_Dashboard=`/operations`,e.Operations_LoadOutliers=`/operations/load-outliers`,e.Operations_LoadHours=`/operations/load-hours`,e.Operations_LoadCycles=`/operations/load-cycles`,e.Operations_MachineOutliers=`/operations/machine-outliers`,e.Operations_MachineHours=`/operations/machine-hours`,e.Operations_MachineCycles=`/operations/machine-cycles`,e.Operations_SystemOverview=`/operations/system-overview`,e.Operations_AllMaterial=`/operations/material`,e.Operations_RecentSchedules=`/operations/recent-schedules`,e.Operations_CurrentWorkorders=`/operations/current-workorders`,e.Operations_Production=`/operations/recent-production`,e.Operations_Tools=`/operations/tools`,e.Operations_Programs=`/operations/programs`,e.Operations_Quality=`/operations/quality`,e.Operations_Inspections=`/operations/inspections`,e.Operations_CloseoutReport=`/operations/closeout`,e.Operations_Rebookings=`/analysis/rebookings`,e.Operations_Parts=`/operations/parts`,e.Engineering_Cycles=`/engineering`,e.Engineering_Hours=`/engineering/hours`,e.Engineering_Outliers=`/engineering/outliers`,e.Quality_Dashboard=`/quality`,e.Quality_Paths=`/quality/paths`,e.Quality_Quarantine=`/quality/quarantine`,e.Tools_Dashboard=`/tools`,e.Tools_Programs=`/tools/programs`,e.Analysis_Buffers=`/analysis/buffers`,e.Analysis_StationOEE=`/analysis/station-oee`,e.Analysis_PartsCompleted=`/analysis/parts-completed`,e.Analysis_MachineCycles=`/analysis/machine-cycles`,e.Analysis_LoadCycles=`/analysis/load-cycles`,e.Analysis_PalletCycles=`/analysis/pallet-cycles`,e.Analysis_BasketCycles=`/analysis/basket-cycles`,e.Analysis_Schedules=`/analysis/schedules`,e.Analysis_Quality=`/analysis/quality`,e.Analysis_ToolReplacements=`/analysis/tool-replacements`,e.Analysis_CostPercents=`/analysis/cost-percents`,e.Analysis_CostPerPiece=`/analysis/cost`,e.Sales_Dashboard=`/sales`,e.Sales_ProjectedUsage=`/sales/projected-usage`,e.VerboseLogging=`/logging`,e.Client_Custom=`/client/:custom+`,e}({}),Oc=D.ofObject(Z).map(([,e])=>[e,new URLPattern(e,location.origin)]).append([`/operations/recent-schedules`,new URLPattern(`/operations/completed`,location.origin)]).append([`/station/closeout`,new URLPattern(`/station/wash`,location.origin)]).toRArray();function kc(e){switch(e.route){case`/station/loadunload/:num`:if(e.queues.length>0||e.completed){let t=new URLSearchParams;for(let n of e.queues)t.append(`queue`,n);return e.completed&&t.append(`completed`,`t`),`/station/loadunload/${e.loadNum}?${t.toString()}`}return`/station/loadunload/${e.loadNum}`;case`/station/inspection/:type`:return`/station/inspection/${encodeURIComponent(e.inspType)}`;case`/station/queues`:if(e.queues.length>0){let t=new URLSearchParams;for(let n of e.queues)t.append(`queue`,n);return`/station/queues?${t.toString()}`}return`/station/queues`;case`/operations/current-workorders`:if(e.workorder){let t=new URLSearchParams;return t.append(`workorder`,e.workorder),`/operations/current-workorders?${t.toString()}`}return`/operations/current-workorders`;case`/client/:custom+`:return`/client/`+e.custom.map(e=>encodeURIComponent(e)).join(`/`);default:return e.route}}function Ac(e){for(let[t,n]of Oc){let r=n.exec(e.origin+e.pathname)?.pathname?.groups;if(r)switch(t){case`/station/loadunload/:num`:return{route:t,loadNum:parseInt(r.num??`1`),queues:e.searchParams.getAll(`queue`),completed:e.searchParams.has(`completed`)};case`/station/inspection/:type`:{let e=r.type;return e?{route:`/station/inspection/:type`,inspType:e}:{route:`/station/inspection`}}case`/station/queues`:return{route:`/station/queues`,queues:e.searchParams.getAll(`queue`)};case`/operations/current-workorders`:return{route:`/operations/current-workorders`,workorder:e.searchParams.get(`workorder`)??void 0};case`/client/:custom+`:return{route:`/client/:custom+`,custom:r?.custom?.split(`/`)?.map(e=>decodeURIComponent(e))??[]};default:return{route:t}}}return{route:`/`}}var jc=F(Ac(new URL(location.href))),Mc=F(!1),Nc=F(e=>e(jc),(e,t,n)=>{let r=e(Mc);t(jc,n),t(X,null),r||history.pushState(null,``,kc(n))});function Pc({to:e,children:t}){let n=j(Nc);return(0,K.createElement)(Yn,{href:kc(e),onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e)}},t)}function Fc(){let e=r(Mc),t=j(jc);(0,K.useEffect)(()=>{if(e)return;function n(){t(Ac(new URL(location.href)))}return addEventListener(`popstate`,n),()=>removeEventListener(`popstate`,n)},[e,t])}function Ic(){return r(Mc)}function Q(e){(0,K.useEffect)(()=>{document.title=e+` - FMS Insight`},[e])}function Lc(e){switch(e.route){case`/station/loadunload/:num`:case`/station/inspection`:case`/station/inspection/:type`:case`/station/closeout`:case`/station/queues`:case`/station/overview`:return`https://www.seedtactics.com/docs/fms-insight/client-station-monitor`;case`/operations`:case`/operations/load-outliers`:case`/operations/load-hours`:case`/operations/load-cycles`:case`/operations/system-overview`:case`/operations/material`:case`/operations/recent-schedules`:case`/operations/current-workorders`:case`/operations/closeout`:case`/operations/recent-production`:case`/analysis/rebookings`:case`/operations/parts`:return`https://www.seedtactics.com/docs/fms-insight/client-operations`;case`/operations/machine-outliers`:case`/operations/machine-hours`:case`/operations/machine-cycles`:return`https://www.seedtactics.com/docs/fms-insight/client-engineering`;case`/operations/quality`:case`/operations/inspections`:return`https://www.seedtactics.com/docs/fms-insight/client-quality`;case`/operations/tools`:case`/operations/programs`:return`https://www.seedtactics.com/docs/fms-insight/client-tools-programs`;case`/engineering`:case`/engineering/outliers`:case`/engineering/hours`:return`https://www.seedtactics.com/docs/fms-insight/client-engineering`;case`/quality`:case`/quality/paths`:case`/quality/quarantine`:return`https://www.seedtactics.com/docs/fms-insight/client-quality`;case`/tools`:case`/tools/programs`:return`https://www.seedtactics.com/docs/fms-insight/client-tools-programs`;case`/analysis/schedules`:case`/analysis/buffers`:case`/analysis/station-oee`:case`/analysis/parts-completed`:case`/analysis/machine-cycles`:case`/analysis/load-cycles`:case`/analysis/pallet-cycles`:case`/analysis/quality`:case`/analysis/cost-percents`:case`/analysis/tool-replacements`:case`/analysis/cost`:return`https://www.seedtactics.com/docs/fms-insight/client-efficiency`;case`/sales`:case`/sales/projected-usage`:return`https://www.seedtactics.com/docs/fms-insight/client-sales`;default:return`https://www.seedtactics.com/docs/fms-insight/client-launch`}}var Rc=new Intl.NumberFormat(void 0,{style:`percent`,minimumFractionDigits:1});function zc(){let e=new Date;return t=>{if(!t.simulatedProduction)return 0;let n=0;for(let r of t.simulatedProduction){if(r.timeUTC>e)break;n=r.quantity}return n}}var Bc=(0,K.memo)(function(){let e=r(q),t=D.ofObject(e.jobs).sumBy(([,e])=>D.of(e.completed??[]).sumBy(e=>D.of(e).sumBy(e=>e))),n=D.ofObject(e.jobs).flatMap(([,e])=>e.procsAndPaths).flatMap(e=>e.paths).sumBy(zc()),i=D.ofObject(e.jobs).sumBy(([,e])=>(e.cycles??0)*e.procsAndPaths.length);return(0,Y.jsx)(B,{sx:{maxWidth:`60em`,ml:`auto`,mr:`auto`,pt:`1em`},children:(0,Y.jsxs)(B,{sx:{display:`grid`,gridTemplateColumns:`auto 1fr auto`,gridColumnGap:`0.5em`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{gridRow:1,gridColumn:1},children:(0,Y.jsxs)(b,{variant:`body2`,children:[`Completed Parts: `,t,`/`,i]})}),(0,Y.jsx)(B,{sx:{gridRow:1,gridColumn:2},children:(0,Y.jsx)(En,{variant:`determinate`,value:t/i*100,color:`secondary`})}),(0,Y.jsx)(B,{sx:{gridRow:1,gridColumn:3},children:(0,Y.jsx)(b,{variant:`body2`,children:Rc.format(t/i)})}),(0,Y.jsx)(B,{sx:{gridRow:2,gridColumn:1},children:(0,Y.jsxs)(b,{variant:`body2`,children:[`Simulated Parts: `,n,`/`,i]})}),(0,Y.jsx)(B,{sx:{gridRow:2,gridColumn:2},children:(0,Y.jsx)(En,{variant:`determinate`,value:n/i*100,color:`secondary`})}),(0,Y.jsx)(B,{sx:{gridRow:2,gridColumn:3},children:(0,Y.jsx)(b,{variant:`body2`,children:Rc.format(n/i)})})]})})});function Vc(){let{ref:e,width:t,height:n}=Ee({refreshMode:`debounce`,refreshRate:100});return(0,Y.jsxs)(`main`,{style:{height:`calc(100vh - 64px)`,display:`flex`,flexDirection:`column`},children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Bc,{})}),(0,Y.jsx)(`div`,{ref:e,style:{flexGrow:1,overflow:`hidden`,margin:`8px`},children:t&&n&&(0,Y.jsx)(Os,{width:t,height:n})})]})}function Hc(){let{ref:e,width:t}=Ee({refreshMode:`debounce`,refreshRate:100,handleHeight:!1});return(0,Y.jsxs)(`main`,{style:{padding:`8px`},children:[(0,Y.jsx)(Bc,{}),(0,Y.jsx)(`div`,{ref:e,style:{overflow:`hidden`},children:t&&(0,Y.jsx)(Os,{width:t,height:500})})]})}function Uc(){return Q(`Dashboard`),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(B,{sx:{display:{xs:`none`,md:`block`}},children:(0,Y.jsx)(Vc,{})}),(0,Y.jsx)(B,{sx:{display:{xs:`block`,md:`none`}},children:(0,Y.jsx)(Hc,{})})]})}var Wc=F(null),Gc=F(null,(e,t,n)=>{t(Wc,n)}),Kc=F(new Set),qc=Kc,Jc=F(new Set),Yc=Jc,Xc=F(new Set),Zc=Xc,Qc=F(new Set),$c=Qc,el=F(null,(e,t,{evt:n})=>{n.newJobs?il(t,n.newJobs.jobs):n.logEntry?ol(t,[n.logEntry]):n.newCurrentStatus&&al(e,t,n.newCurrentStatus)}),tl=F(null,(e,t,n)=>{il(t,Object.values(n.jobs))}),nl=F(null,(e,t,n)=>ol(t,n)),rl=F(null,al);function il(e,t){e(Xc,e=>{let n=new Set;for(let r of t)for(let t of r.procsAndPaths[0].paths)t.casting&&t.casting!==``&&!e.has(t.casting)&&n.add(t.casting);return n.size===0?e:new Set([...e,...n])})}function al(e,t,n){il(t,Object.values(n.jobs));let r=e(Kc),i=e(Jc),a=new Set,o=new Set;for(let[e,t]of D.ofObject(n.queues))t.role===oi.RawMaterial?r.has(e)||a.add(e):t.role===oi.InProcessTransfer&&(i.has(e)||o.add(e));a.size>0&&t(Kc,new Set([...r,...a])),o.size>0&&t(Jc,new Set([...i,...o]))}function ol(e,t){e(Qc,e=>{let n=new Set;for(let r of t)switch(r.type){case V.Inspection:{let t=(r.details||{}).InspectionType;t&&!e.has(t)&&n.add(t)}break;case V.InspectionForce:case V.InspectionResult:{let t=r.program;e.has(t)||n.add(t)}}return n.size===0?e:new Set([...e,...n])})}var sl=F({id:0,open:!1,snapshot:null}),cl=F(!1),ll=F(null);F(e=>({session:e(sl).id})),F(null,(e,t,n,r)=>{let i=e(sl);return i.id===n.session?i.snapshot&&r.revision<=i.snapshot.status.revision?!0:t(fl,n.session,r,`http`):!1});function ul(e,t){return e(sl).id===t}var dl=F(null,(e,t,n)=>{t(Sa,n),t(Gc,n.customState??null),t(rl,n)}),fl=F(null,(e,t,n,r,i)=>{let a=e(sl),o=a.snapshot?.status;return a.id!==n||o&&r.revision<=o.revision?!1:(t(dl,r),t(sl,{...a,snapshot:{status:r,source:i}}),a.open&&t(cl,!0),t(ll,null),!0)}),pl=F([]),ml=pl,hl=F([]),gl=hl;function*_l(e){for(let t of e)for(let e=0;e<t.procsAndPaths.length;e++){let n=t.procsAndPaths[e];for(let r=0;r<n.paths.length;r++){let i=n.paths[r],a=0;for(let e of i.stops)a+=J(e.expectedCycleTime);let o=0;for(let n of i.simulatedProduction||[])yield{partName:t.partName,process:e+1,finalProcess:e===t.procsAndPaths.length-1,completeTime:n.timeUTC,quantity:n.quantity-o,expectedMachineMins:a},o=n.quantity}}}var vl=F(null,(e,t,n)=>{t(pl,e=>[...e,..._l(Object.values(n.jobs))])}),yl=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.newJobs){let e=n.newJobs.jobs;t(pl,t=>{if(i){let n=P(r,-30),i=D.of(t).minBy(e=>e.completeTime.getTime());if((i===void 0||i.completeTime>=n)&&e.length===0)return t;t=t.filter(e=>e.completeTime>=n)}return[...t,..._l(e)]})}}),bl=F(null,(e,t,n)=>{t(hl,Array.from(_l(Object.values(n.jobs))))}),xl=F(T.empty()),Sl=xl,Cl=F(T.empty()),wl=Cl;function Tl(e){if(e.elapsed===``)return null;let t=Oa(e.elapsed);if(t<=0)return null;switch(e.type){case V.RemoveFromQueue:return[e.counter,{buffer:{type:`Queue`,queue:e.loc},endTime:e.endUTC,elapsedSeconds:t,numMaterial:e.material.length}];case V.PalletInStocker:return!e.startofcycle&&e.result===`WaitForMachine`?[e.counter,{buffer:{type:`StockerWaitForMC`,stockerNum:e.locnum},endTime:e.endUTC,elapsedSeconds:t,numMaterial:e.material.length}]:e.startofcycle?null:[e.counter,{buffer:{type:`StockerWaitForUnload`,stockerNum:e.locnum},endTime:e.endUTC,elapsedSeconds:t,numMaterial:e.material.length}];case V.PalletOnRotaryInbound:return e.startofcycle?null:[e.counter,{buffer:{type:`Rotary`,machineGroup:e.loc,machineNum:e.locnum},endTime:e.endUTC,elapsedSeconds:t,numMaterial:e.material.length}];default:return null}}var El=F(null,(e,t,n)=>{t(xl,e=>e.union(D.of(n).collect(Tl).toHashMap(e=>e)))}),Dl=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(!n.logEntry)return;let a=Tl(n.logEntry);a&&t(xl,e=>{if(i){let t=P(r,-30);e=e.filter(e=>e.endTime>=t)}return e.set(a[0],a[1])})}),Ol=F(null,(e,t,n)=>{t(Cl,D.of(n).collect(Tl).toHashMap(e=>e))}),kl=function(e){return e[e.Triggered=0]=`Triggered`,e[e.Forced=1]=`Forced`,e[e.Completed=2]=`Completed`,e}({}),Al=class{constructor(e,t){this.part=e,this.inspType=t}compare(e){let t=this.part.localeCompare(e.part);return t===0?this.inspType.localeCompare(e.inspType):t}hash(){return ve(this.part,this.inspType)}toString(){return`{part: ${this.part}}, inspType: ${this.inspType}}`}},jl=F(T.empty()),Ml=jl,Nl=F(T.empty()),Pl=Nl;function Fl(e){return e.type!==V.Inspection&&e.type!==V.InspectionForce&&e.type!==V.InspectionResult?[]:e.material.map(t=>{if(e.type===V.Inspection){let n=JSON.parse((e.details||{}).ActualPath||`[]`),r=Array.isArray(n)?n:[],i=[];for(let e of r)i.push(kr.fromJS(e));let a=(e.details||{}).InspectionType||``,o;return o=e.result.toLowerCase()===`true`||e.result===`1`,{key:new Al(t.part,a),entry:{cntr:e.counter,time:e.endUTC,materialID:t.id,serial:t.serial,workorder:t.workorder,result:{type:0,actualPath:i,toInspect:o},part:t.part,inspType:a}}}if(e.type===V.InspectionForce){let n;return n=e.result.toLowerCase()===`true`||e.result===`1`,{key:new Al(t.part,e.program),entry:{cntr:e.counter,time:e.endUTC,materialID:t.id,serial:t.serial,workorder:t.workorder,result:{type:1,toInspect:n},part:t.part,inspType:e.program}}}{let n;return n=e.result.toLowerCase()===`true`||e.result===`1`,{key:new Al(t.part,e.program),entry:{cntr:e.counter,time:e.endUTC,materialID:t.id,serial:t.serial,workorder:t.workorder,result:{type:2,success:n},part:t.part,inspType:e.program}}}})}var Il=F(null,(e,t,n)=>{t(jl,e=>e.union(D.of(n).flatMap(Fl).toLookupMap(e=>e.key,e=>e.entry.cntr,e=>e.entry),(e,t)=>e.union(t)))}),Ll=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.logEntry){let e=Fl(n.logEntry);if(e.length===0)return;t(jl,t=>{if(i){let e=P(r,-30);t=t.collectValues(t=>{let n=t.filter(t=>t.time>=e);return n.size===0?null:n})}return t.union(D.of(e).toLookupMap(e=>e.key,e=>e.entry.cntr,e=>e.entry),(e,t)=>e.union(t))})}}),Rl=F(null,(e,t,n)=>{t(Nl,D.of(n).flatMap(Fl).toLookupMap(e=>e.key,e=>e.entry.cntr,e=>e.entry))}),zl=F({matsById:T.empty(),matIdsForJob:T.empty()}),Bl=zl,Vl=F({matsById:T.empty(),matIdsForJob:T.empty()}),Hl=Vl;function Ul(e){return{materialID:e.materialID,jobUnique:e.jobUnique,partName:e.partName,startedProcess1:e.process>0,serial:e.serial,workorderId:e.workorderId,signaledInspections:e.signaledInspections,quarantineAfterUnload:e.quarantineAfterUnload}}function Wl(e,t){let n=e.matsById,r=e.matIdsForJob;if(t.startofcycle||t.material.length===0)return e;for(let e of t.material){if(e.uniq&&e.uniq!==``){let t=r.get(e.uniq);t===void 0?r=r.set(e.uniq,Fn.empty().add(e.id)):t.has(e.id)||(r=r.set(e.uniq,t.add(e.id)))}let i=n.get(e.id),a;switch(a=i===void 0?{materialID:e.id,jobUnique:e.uniq,partName:e.part,last_event:t.endUTC,startedProcess1:!1,numProcesses:e.numproc,unloaded_processes:{},signaledInspections:[],quarantineAfterUnload:null,completedInspections:{}}:{...i,last_event:t.endUTC},t.type){case V.PartMark:a={...a,serial:t.result};break;case V.OrderAssignment:a={...a,workorderId:t.result};break;case V.Inspection:if(t.result.toLowerCase()===`true`||t.result===`1`){let e=(t.details||{}).InspectionType;e&&(a={...a,signaledInspections:[...a.signaledInspections,e]})}break;case V.InspectionForce:if(t.result.toLowerCase()===`true`||t.result===`1`){let e=t.program;a={...a,signaledInspections:[...a.signaledInspections,e]}}break;case V.InspectionResult:{let e=t.result.toLowerCase()==`true`||t.result===`1`;a={...a,completedInspections:{...a.completedInspections,[t.program]:{time:t.endUTC,success:e}},completed_inspect_time:t.endUTC};break}case V.LoadUnloadCycle:t.result===`UNLOAD`?(a={...a,unloaded_processes:{...a.unloaded_processes,[e.proc]:t.endUTC},quarantineAfterUnload:!1,currently_quarantined:!1},a=e.proc===e.numproc?{...a,last_unload_time:t.endUTC,completed_last_proc_machining:!0}:{...a,last_unload_time:t.endUTC}):t.result===`LOAD`&&(a={...a,startedProcess1:!0,quarantineAfterUnload:!1,currently_quarantined:!1});break;case V.MachineCycle:a.currently_quarantined&&(a={...a,currently_quarantined:!1});break;case V.AddToQueue:t.program===`Quarantine`&&(a={...a,currently_quarantined:!0});break;case V.CloseOut:a={...a,closeout_completed:t.endUTC,closeout_failed:t.result===`Failed`};break;case V.SignalQuarantine:{let n=a.quarantineSignals??T.empty(),r=n.get(e.proc);a={...a,quarantineAfterUnload:!0,quarantineSignals:r&&r.counter>=t.counter?n:n.set(e.proc,{counter:t.counter,note:t.details?.note?.trim()})};break}}n=n.set(e.id,a)}return{matsById:n,matIdsForJob:r}}function Gl(e,{matIdsForJob:t,matsById:n}){let r=n.valuesToLazySeq().filter(t=>t.last_event<e).toRSet(e=>e.materialID);return r.size>0&&(t=t.collectValues(e=>{let t=D.of(r).fold(e,(e,t)=>e.delete(t));return t.size>0?t:null})),n=n.filter(t=>t.last_event>=e),{matIdsForJob:t,matsById:n}}var Kl=F(null,(e,t,n)=>{t(zl,e=>n.reduce(Wl,e))}),ql=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.logEntry){let e=n.logEntry;t(zl,t=>{let n=Wl(t,e);return n===t||!i?n:Gl(P(r,-30),n)})}}),Jl=F(null,(e,t,n)=>{t(Vl,n.reduce(Wl,{matsById:T.empty(),matIdsForJob:T.empty()}))}),Yl=F(T.empty()),Xl=Yl;function Zl(e,t,n){if(e.tooluse===void 0||e.tooluse.length===0||e.type!==V.MachineCycle)return n;let r=e.material.length>0?t.get(ka.ofLogCycle(e)):void 0,i=J(e.elapsed);if(r===void 0||Pa(r,i))return n;let a=ka.ofLogCycle(e),o=D.of(e.tooluse).groupBy(e=>e.tool).map(([e,t])=>({toolName:e,cycleUsageMinutes:D.of(t).sumBy(e=>e.toolUseDuringCycle&&e.toolUseDuringCycle!==``?J(e.toolUseDuringCycle):0),cycleUsageCnt:D.of(t).sumBy(e=>e.toolUseCountDuringCycle??0),toolChangedDuringMiddleOfCycle:D.of(t).some(e=>e.toolChangeOccurred??!1)})).toRArray();return o.length===0&&n.has(a)?n:n.modify(a,t=>{if(t){let n=t.recentCycles.slice(-4);return n.push({tools:o}),{machines:t.machines.add(Xa(e.loc,e.locnum)),recentCycles:n}}return{machines:Se.empty().add(Xa(e.loc,e.locnum)),recentCycles:[{tools:o}]}})}var Ql=F(null,(e,t,n)=>{let r=e(ja);t(Yl,e=>n.reduce((e,t)=>Zl(t,r,e),e))}),$l=F(null,(e,t,{evt:n})=>{if(n.logEntry){let r=n.logEntry,i=e(ja);t(Yl,e=>Zl(r,i,e))}}),eu=F(T.empty()),tu=eu,nu=F(T.empty()),ru=nu;function iu(e){return{cntr:e.counter,x:e.endUTC,y:J(e.elapsed),active:J(e.active),mats:e.material}}var au=F(null,(e,t,n)=>{t(eu,e=>e.union(D.of(n).filter(e=>!e.startofcycle&&e.type===V.PalletCycle&&e.pal!==0).toLookupMap(e=>e.pal,e=>e.counter,iu),(e,t)=>e.union(t)))}),ou=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.logEntry&&!n.logEntry.startofcycle&&n.logEntry.type===V.PalletCycle&&n.logEntry.pal!==0){let e=n.logEntry;t(eu,t=>{if(i){let e=P(r,-30);t=t.collectValues(t=>{let n=t.filter(t=>t.x>=e);return n.size>0?n:null})}return t.modify(e.pal,t=>(t??T.empty()).set(e.counter,iu(e)))})}}),su=F(null,(e,t,n)=>{t(nu,D.of(n).filter(e=>!e.startofcycle&&e.type===V.PalletCycle&&e.pal!==0).toLookupMap(e=>e.pal,e=>e.counter,iu))}),cu=F(T.empty()),lu=cu,uu=F(e=>e(cu).size>0),du=F(T.empty()),fu=du,pu=F(e=>e(du).size>0);function mu(e){return{cntr:e.counter,x:e.endUTC,y:J(e.elapsed),active:J(e.active),mats:e.material}}var hu=F(null,(e,t,n)=>{t(cu,e=>e.union(D.of(n).filter(e=>!e.startofcycle&&e.type===V.BasketCycle&&e.pal!==0).toLookupMap(e=>e.pal,e=>e.counter,mu),(e,t)=>e.union(t)))}),gu=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.logEntry&&!n.logEntry.startofcycle&&n.logEntry.type===V.BasketCycle&&n.logEntry.pal!==0){let e=n.logEntry;t(cu,t=>{if(i){let e=P(r,-30);t=t.collectValues(t=>{let n=t.filter(t=>t.x>=e);return n.size>0?n:null})}return t.modify(e.pal,t=>(t??T.empty()).set(e.counter,mu(e)))})}}),_u=F(null,(e,t,n)=>{t(du,D.of(n).filter(e=>!e.startofcycle&&e.type===V.BasketCycle&&e.pal!==0).toLookupMap(e=>e.pal,e=>e.counter,mu))}),vu=class e{constructor(e,t){this.group=e,this.num=t}static ofLogCycle(t){return new e(t.loc,t.locnum)}hash(){return ve(this.group,this.num)}compare(e){return this.group===e.group?this.num-e.num:this.group.localeCompare(e.group)}toString(){return this.group+` #`+this.num.toString()}},yu={replacements:se.empty(),recentUse:T.empty()},bu=F(yu),xu=F(e=>e(bu).replacements),Su=F(yu),Cu=F(e=>e(Su).replacements);function wu(e,t){let n=vu.ofLogCycle(t);return{replacements:e.replacements.alter(n,r=>{let i=[];for(let r of t.tooluse??[]){let t=r.toolUseDuringCycle!==null&&r.toolUseDuringCycle!==void 0?J(r.toolUseDuringCycle):null,a=r.totalToolUseAtEndOfCycle!==null&&r.totalToolUseAtEndOfCycle!==void 0?J(r.totalToolUseAtEndOfCycle):null,o=r.toolUseCountDuringCycle??null,s=r.totalToolUseCountAtEndOfCycle??null;if((t||o)&&t===a&&o===s){let t=e.recentUse.get(n)?.find(e=>e.tool===r.tool&&e.pocket===r.pocket);if(t){let e=t.totalToolUseAtEndOfCycle?J(t.totalToolUseAtEndOfCycle):null;(e||t.totalToolUseCountAtEndOfCycle)&&i.push({tool:r.tool,pocket:r.pocket,type:`ReplaceBeforeCycleStart`,useAtReplacement:e,cntAtReplacement:t.totalToolUseCountAtEndOfCycle??null})}}else if(r.toolChangeOccurred&&(t&&r.configuredToolLife||o&&r.configuredToolLifeCount)){let e=r.configuredToolLife!==null&&r.configuredToolLife!==void 0?J(r.configuredToolLife):null,n=r.configuredToolLifeCount??null;i.push({tool:r.tool,pocket:r.pocket,type:`ReplaceInCycle`,totalUseAtBeginningOfCycle:e!==null&&t!==null?e-t+(a??0):null,totalUseAtEndOfCycle:a,totalCntAtBeginningOfCycle:n!==null&&o!==null?n-o+(s??0):null,totalCntAtEndOfCycle:s})}}return i.length>0?(r??se.empty()).set(t.counter,{time:t.endUTC,replacements:i}):r}),recentUse:t.tooluse?e.recentUse.set(n,t.tooluse):e.recentUse}}var Tu=F(null,(e,t,n)=>{t(bu,e=>D.of(n).filter(e=>e.type===V.MachineCycle&&!e.startofcycle&&!!e.tooluse&&e.tooluse.length>0).fold(e,wu))}),Eu=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.logEntry&&!n.logEntry.startofcycle&&n.logEntry.type===V.MachineCycle&&n.logEntry.tooluse&&n.logEntry.tooluse.length>0){let e=n.logEntry;t(bu,t=>{if(i){let e=P(r,-30);t={replacements:t.replacements.collectValues(t=>{let n=t.filter(t=>t.time>=e);return n.size>0?n:null}),recentUse:t.recentUse}}return wu(t,e)})}}),Du=F(null,(e,t,n)=>{t(Su,D.of(n).filter(e=>e.type===V.MachineCycle&&!e.startofcycle&&!!e.tooluse&&e.tooluse.length>0).fold(yu,wu))}),Ou=F(null),ku=Ou;function Au(e,t,n,r){let i=e(ku);(i===null||i.simId<n)&&t(Ou,{simId:n,usage:r})}var ju=F(null,(e,t,n)=>{n.mostRecentSimulationId&&n.mostRecentSimDayUsage&&n.mostRecentSimDayUsage.length!==0&&Au(e,t,n.mostRecentSimulationId,n.mostRecentSimDayUsage)}),Mu=F(null,(e,t,{evt:n})=>{n.newJobs&&n.newJobs.simDayUsage&&n.newJobs.simDayUsage.length>0&&Au(e,t,n.newJobs.scheduleId,n.newJobs.simDayUsage)}),Nu=F(se.empty()),Pu=hr(F(async(e,{signal:t})=>Bi===void 0?se.empty():Fu(await Bi.unscheduledRebookings(t))),e=>e??se.empty());function Fu(e){return se.build(e??[],e=>e.bookingId)}var Iu=F(e=>{let t=e(Nu),n=e(Pu);return t.union(n,(e,t)=>e??t)}),Lu=F(se.empty()),Ru=Lu,zu=F(se.empty()),Bu=zu;function Vu(e){let t=1;return e.details?.Quantity&&(t=parseInt(e.details.Quantity,10)),{bookingId:e.result,partName:e.program,quantity:t,timeUTC:e.endUTC,priority:e.locnum,notes:e.details?.Notes,workorder:e.details?.Workorder??e.material?.[0]?.workorder}}var Hu=F(null,(e,t,n)=>{t(Nu,e=>e.union(D.of(n).filter(e=>e.type===V.Rebooking).toOrderedMap(e=>[e.result,Vu(e)]))),t(Lu,e=>e.union(D.of(n).filter(e=>e.type===V.CancelRebooking).toOrderedMap(e=>[e.result,e.endUTC])))});function Uu(e,t,n){e(zu,e=>(n&&(e=e.filter(e=>e.scheduledTime>=n)),e.union(t.flatMap(e=>(e.bookings??[]).map(t=>[t,{scheduledTime:e.routeStartUTC,jobUnique:e.unique}])).toOrderedMap(e=>e))))}var Wu=F(null,(e,t,n)=>{Uu(t,D.ofObject(n.jobs).map(([,e])=>e))}),Gu=F(null,(e,t,{evt:n,now:r,expire:i})=>{if(n.newJobs)Uu(t,D.of(n.newJobs.jobs),i?P(r,-30):void 0);else if(n.logEntry){let e=n.logEntry;e.type===V.Rebooking?t(Nu,t=>t.set(e.result,Vu(e))):e.type===V.CancelRebooking&&t(Lu,t=>t.set(e.result,e.endUTC))}});function Ku(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(e=>(t(!0),Vi.cancelRebooking(e).then(()=>{}).catch(console.log).finally(()=>t(!1))),[]),e]}function qu(){let[e,t]=(0,K.useState)(!1);return[(0,K.useCallback)(e=>(t(!0),Vi.requestRebooking(e.part,e.qty&&!isNaN(e.qty)?e.qty:1,e.workorder,e.priority!==void 0&&e.priority!==null&&!isNaN(e.priority)?e.priority:void 0,e.notes).then(()=>{}).catch(console.log).finally(()=>t(!1))),[]),e]}var Ju=F(null),Yu=Ju,Xu=F(null,(e,t,n)=>{n.evt.newCurrentStatus&&t(Gc,n.evt.newCurrentStatus.customState??null),t(Ca,n)}),Zu=F(null,(e,t,n)=>{if(t(yl,n),t(Bo,n),t(da,n),t(Dl,n),t(ql,n),t(Ll,n),t(el,n),t($l,n),t(ou,n),t(gu,n),t(Eu,n),t(mo,n),t(Gu,n),t(Mu,n),n.evt.logEntry){let e=n.evt.logEntry.counter;t(Ju,t=>Math.max(t??e,e))}});F(null,(e,t,n)=>{t(Xu,n),t(Zu,n)});var Qu=F(null,(e,t,n)=>{let r=la(e(oa),n);t(zo,r),t(vl,r),t(ua,r),t(tl,r),t(ju,r),t(Wu,r)}),$u=F(null,(e,t,n)=>{t(Ha,n),t(El,n),t(Il,n),t(Kl,n),t(nl,n),t(Ql,n),t(au,n),t(hu,n),t(Tu,n),t(po,n),t(Hu,n);let r=D.of(n).maxBy(e=>e.counter)?.counter??null;t(Ju,e=>e===null?r:Math.max(e,r??-1))}),ed=F(null,async(e,t,{operator:n,...r})=>{let i=e(q),a=js(i,i.material.filter(e=>e.materialID===r.matId));if(a.length>0)throw Error(a.map(e=>e.message).join(` `));t(Ta,r);let o=e(q);try{await Bi.setMaterialInQueue(r.matId,n,new Oi({queue:r.queue,position:r.newIdx}))}catch(n){let r=e(sl).id,a=e(q);try{let n=await Bi.currentStatus();e(q)===a&&t(fl,r,n,`http`)}catch{e(sl).id===r&&e(q)===o&&t(dl,i)}throw n}}),td=F(null,(e,t,n)=>{t(Vo,n),t(bl,n),t(fa,n)}),nd=F(null,(e,t,n)=>{t(Ua,n),t(Ol,n),t(Rl,n),t(Jl,n),t(su,n),t(_u,n),t(Du,n),t(ho,n)}),rd=F(`Last30`),id=F(We(new Date)),ad=F(e=>e(id),(e,t,n)=>{t(rd,`SpecificMonth`),t(id,n),e(sd)!==n&&!e(cd)&&fd(n,t)}),od=F(e=>e(rd)===`Last30`?{type:`Last30`}:{type:`SpecificMonth`,month:e(id)}),sd=F(null),cd=F(!1),ld=cd,ud=F(null),dd=ud;function fd(e,t){t(cd,!0),t(ud,null);let n=Vt(e,1),r=Bi.history(e,n).then(e=>t(td,e)),i=Vi.get(e,n).then(e=>t(nd,e));Promise.all([r,i]).then(()=>t(sd,e)).catch(e=>t(ud,e.message??`Error`)).finally(()=>t(cd,!1))}function pd(){let e=j(rd);return()=>e(`Last30`)}function md(){return j(id)}function hd(e){return Ka(e)&&e.operation===`UNLOAD`}function gd(e){return Object.prototype.hasOwnProperty.call(e,`month`)}function _d(e,t,n,r){let i=gd(r)?r.month:r.thirtyDaysAgo,a=gd(r)?Vt(r.month,1):P(r.thirtyDaysAgo,31),o=0,s=new Map,c=0,l=new Map,u=e.filter(e=>e.endTime>=i&&e.endTime<=a&&!e.material.some(e=>t.has(e.part)));for(let e of u)if(hd(e)&&(o+=1),Wa(e))c+=e.activeMinutes;else if(Ga(e)){s.set(e.stationGroup,e.activeMinutes+(s.get(e.stationGroup)??0));let t=l.get(e.stationGroup);t?t.add(e.stationNumber):l.set(e.stationGroup,new Set([e.stationNumber]))}let d=D.of(n).filter(([,e])=>{if(t.has(e.partName)||e.numProcesses===void 0)return!1;let n=e.unloaded_processes?.[e.numProcesses];return!!n&&n>=i&&n<=a}).toRMap(([,e])=>[e.partName,1],(e,t)=>e+t);return{parts:u.groupBy(e=>e.part).map(([e,t])=>({part:e,parts_completed:d.get(e)??0,machine:D.of(t).filter(e=>Ga(e)).buildOrderedMap(e=>e.stationGroup,(e,t)=>(e??0)+t.activeMinutes).mapValues((e,t)=>e/(s.get(t)??1)),labor:D.of(t).filter(e=>Wa(e)).sumBy(e=>e.activeMinutes/c),automation:o>0?t.reduce((e,t)=>hd(t)?e+1:e,0)/o:0})).toRArray(),machineQuantities:D.of(l).toOrderedMap(([e,t])=>[e,t.size]),type:r}}function vd(e,t,n,r){let i=gd(e.type)?bt(e.type.month):30,a=n?n*i/365:0,o=e.machineQuantities.mapValues((e,n)=>(t[n]??0)*e*i/365);return{machineQuantities:e.machineQuantities,type:e.type,parts:e.parts.map(e=>({part:e.part,parts_completed:e.parts_completed,machine:e.machine.mapValues((t,n)=>e.parts_completed>0?t*(o.get(n)??0)/e.parts_completed:0),labor:e.parts_completed>0?e.labor*r/e.parts_completed:0,automation:e.parts_completed>0?e.automation*a/e.parts_completed:0}))}}function yd(e){let t=`<table>
|
|
17
|
+
<thead><tr>`;t+=`<th>Part</th>`,t+=`<th>Completed Quantity</th>`;for(let n of e.machineQuantities.keys())t+=`<th>`+n+` Cost %</th>`;t+=`<th>Labor Cost</th>`,t+=`<th>Automation Cost</th>`,t+=`</tr></thead>
|
|
18
|
+
<tbody>
|
|
19
|
+
`;let n=D.of(e.parts).sortBy(e=>e.part),r=Intl.NumberFormat(void 0,{maximumFractionDigits:1});for(let i of n){t+=`<tr><td>`+i.part+`</td>`,t+=`<td>`+i.parts_completed.toString()+`</td>`;for(let n of e.machineQuantities.keys())t+=`<td>`+r.format(i.machine.get(n)??0)+`</td>`;t+=`<td>`+(i.parts_completed>0?r.format(i.labor):`0`)+`</td>`,t+=`<td>`+(i.parts_completed>0?r.format(i.automation):`0`)+`</td>`,t+=`</tr>
|
|
20
|
+
`}return t+=`</tbody>
|
|
21
|
+
</table>`,t}function bd(e){Je(yd(e))}function xd(e){let t=`<table>
|
|
22
|
+
<thead><tr>`;t+=`<th>Part</th>`,t+=`<th>Completed Quantity</th>`;for(let n of e.machineQuantities.keys())t+=`<th>`+n+` Cost %</th>`;t+=`<th>Labor Cost %</th>`,t+=`<th>Automation Cost %</th>`,t+=`</tr></thead>
|
|
23
|
+
<tbody>
|
|
24
|
+
`;let n=D.of(e.parts).sortBy(e=>e.part),r=new Intl.NumberFormat(void 0,{style:`percent`,minimumFractionDigits:1,maximumFractionDigits:1});for(let i of n){t+=`<tr><td>`+i.part+`</td>`,t+=`<td>`+i.parts_completed.toString()+`</td>`;for(let n of e.machineQuantities.keys())t+=`<td>`+r.format(i.machine.get(n)??0)+`</td>`;t+=`<td>`+r.format(i.labor)+`</td>`,t+=`<td>`+r.format(i.automation)+`</td>`,t+=`</tr>
|
|
25
|
+
`}return t+=`</tbody>
|
|
26
|
+
</table>`,t}function Sd(e){Je(xd(e))}function Cd(e){let t=e[`content-type`];return typeof t==`string`?(t.split(`;`)[0]??``).trim().toLowerCase():``}function wd(e){return typeof e==`string`&&e.trim()!==``?e:null}function Td(e){try{let t=JSON.parse(e);return typeof t!=`object`||!t?null:(`detail`in t?wd(t.detail):null)??(`title`in t?wd(t.title):null)}catch{return null}}function Ed(e){if(typeof e!=`object`||!e||!Ri.isApiException(e))return null;let t=Cd(e.headers);return t===`application/problem+json`||t===`application/json`?Td(e.response):t===`text/plain`||t===``?wd(e.response):null}function Dd(e,t=`Error`){let n=Ed(e);return n===null?e instanceof Error?e.message:wd(e)??t:n}function Od(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?e.toString():JSON.stringify(e)??``}function kd(){return(0,Y.jsxs)(`div`,{style:{textAlign:`center`,marginTop:`4em`},children:[(0,Y.jsx)(pn,{}),(0,Y.jsx)(`p`,{children:`Loading`})]})}function Ad({error:e}){return e===void 0?(0,Y.jsx)(Y.Fragment,{}):Ri.isApiException(e)?(0,Y.jsx)(Tt,{children:(0,Y.jsxs)(Xt,{children:[(0,Y.jsx)(`h3`,{children:`FMS Insight Server Error`}),(0,Y.jsx)(`p`,{children:Dd(e)})]})}):e instanceof Error?(0,Y.jsx)(Tt,{children:(0,Y.jsx)(Xt,{children:e.message})}):(0,Y.jsx)(Tt,{children:(0,Y.jsxs)(Xt,{children:[(0,Y.jsx)(`h3`,{children:`Unknown Error`}),(0,Y.jsx)(`p`,{children:Od(e)})]})})}function jd(e){return(0,Y.jsx)(yn,{FallbackComponent:Ad,children:(0,Y.jsx)(K.Suspense,{fallback:e.fallback??(0,Y.jsx)(kd,{}),children:e.children})})}function Md(e){let t=e.action.loadCancellationId;return t!==void 0&&t.trim()!==``?t:null}function Nd(e){switch(e.action.type){case U.Loading:case U.UnloadToInProcess:case U.UnloadToCompletedMaterial:case U.LoadingToBasket:return!0;default:return!1}}function Pd(e){if(e.action.automatedTransfer===!0)return{kind:`AutomationControlled`};let t=Md(e);return e.action.loadCancellationId!==void 0||Nd(e)?{kind:`ActiveLoadStationOperation`,cancellationId:t}:e.location.type===H.InQueue&&e.action.type===U.Waiting?{kind:`HumanControlledQueue`}:e.location.type===H.OnPallet||e.location.type===H.InBasket||e.action.type===U.Machining?{kind:`AutomationControlled`}:{kind:`AddToQueueProposal`}}function Fd(e){if(e===null)return!1;let t=Pd(e);return t.kind===`ActiveLoadStationOperation`&&t.cancellationId!==null}function Id(e){return e!==null&&e.materialID>=0&&(Pd(e).kind===`AutomationControlled`||e.action.type===U.UnloadToInProcess||e.action.type===U.UnloadToCompletedMaterial)}function Ld(e){return e!==null&&Pd(e).kind===`HumanControlledQueue`}function Rd(e){return Ld(e)}function zd(e){return e===null||Pd(e).kind===`AddToQueueProposal`}function Bd(e){if(e===null)return!0;let t=Pd(e);return t.kind===`AddToQueueProposal`||t.kind===`HumanControlledQueue`}function Vd(e){return e!==null&&e.location.type===H.InQueue&&e.action.automatedTransfer!==!0}function Hd(e,t){return e?.location.type===H.InQueue&&e.location.currentQueue===t?Vd(e):Bd(e)}function Ud(e){return e.action.automatedTransfer===!0&&(e.action.type===U.Loading||e.action.type===U.LoadingToBasket)?{process:e.action.processAfterLoad??0,path:e.action.pathAfterLoad??0}:{process:e.process,path:e.path}}var $=class extends K.PureComponent{render(){let e=this.props.size||50,t=Pe(this.props.part,e);return(0,Y.jsx)(`div`,{style:{width:e,height:e},dangerouslySetInnerHTML:{__html:t}})}},Wd=2,Gd=st`
|
|
27
|
+
from, to { transform: translate(0, 0) }
|
|
28
|
+
10% { transform: translate(${Wd}px, 0) }
|
|
29
|
+
20% { transform: translate(0, 0) }
|
|
30
|
+
30% { transform: translate(${Wd}px, 0) }
|
|
31
|
+
40% { transform: translate(0, 0) }
|
|
32
|
+
50% { transform: translate(${Wd}px, 0) }
|
|
33
|
+
60% { transform: translate(0, 0) }
|
|
34
|
+
`,Kd=`${Gd} 1s ease-in-out infinite`;function qd(e){return`animationName`in e}function Jd(e){let t=e.currentTarget.getAnimations().find(e=>qd(e)&&e.animationName===Gd.name);if(t&&typeof t.startTime==`number`)t.startTime-=t.startTime%1e3;else if(t&&typeof t.startTime==`object`&&t.startTime instanceof CSSNumericValue){let e=t.startTime.to(`ms`).value;t.startTime=CSS.ms(e-e%1e3)}}var Yd=_r(`div`,{shouldForwardProp:e=>e!==`fsize`})(({fsize:e,theme:t})=>{if(!e)return{fontSize:`1.25rem`,fontWeight:`500`};switch(e){case`normal`:return{fontSize:`1rem`,fontWeight:`500`,[t.breakpoints.up(`md`)]:{fontSize:`1.25rem`},[t.breakpoints.up(`lg`)]:{fontSize:`1.5rem`}};case`large`:return{fontSize:`1.5rem`,fontWeight:`500`,[t.breakpoints.up(`lg`)]:{fontSize:`1.75rem`},[t.breakpoints.up(`xl`)]:{fontSize:`2rem`}};case`x-large`:return{fontSize:`1.5rem`,fontWeight:`500`,[t.breakpoints.up(`md`)]:{fontSize:`1.75rem`},[t.breakpoints.up(`lg`)]:{fontSize:`2.75rem`},[t.breakpoints.up(`xl`)]:{fontSize:`3.75rem`}}}}),Xd=_r(`div`,{shouldForwardProp:e=>e!==`fsize`})(({fsize:e,theme:t})=>{if(!e)return{fontSize:`0.75rem`,fontWeight:`500`};switch(e){case`normal`:return{fontSize:`0.75rem`,fontWeight:`500`,[t.breakpoints.up(`md`)]:{fontSize:`1rem`}};case`large`:return{fontSize:`1rem`,fontWeight:`500`,[t.breakpoints.up(`lg`)]:{fontSize:`1.5rem`},[t.breakpoints.up(`xl`)]:{fontSize:`1.75rem`}};case`x-large`:return{fontSize:`1rem`,fontWeight:`500`,[t.breakpoints.up(`md`)]:{fontSize:`1.5rem`},[t.breakpoints.up(`lg`)]:{fontSize:`2.5rem`},[t.breakpoints.up(`xl`)]:{fontSize:`3.5rem`}}}});function Zd({mat:e,displayActionForSinglePallet:t,displayActionForSingleBasket:n,fsize:i}){let a=r(q),o=Qd(e,a,eo(r(G).basketName),t,n);return o===null?null:(0,Y.jsx)(Xd,{fsize:i,children:Ms(a,e)?`System alarm`:o})}function Qd(e,t,n,r,i){switch(e.action.type){case U.Loading:if(e.action.loadFromBasketId){if(e.action.loadOntoPalletNum===null||e.action.loadOntoPalletNum===void 0)return(0,Y.jsxs)(Y.Fragment,{children:[`Load into `,n,` `,e.action.loadFromBasketId]});if(r===void 0)return(0,Y.jsxs)(Y.Fragment,{children:[`Load from `,n,` `,e.action.loadFromBasketId,` to pal`,` `,e.action.loadOntoPalletNum??``]});if(r===e.action.loadOntoPalletNum){let r=e.action.loadOntoFace??0,i=e.action.loadOntoPalletNum?t.pallets[e.action.loadOntoPalletNum]?.faceNames?.[r-1]:null;return(0,Y.jsxs)(Y.Fragment,{children:[`Load from `,n,` `,e.action.loadFromBasketId,` to`,` `,i??`face ${r}`]})}return null}switch(e.location.type){case H.OnPallet:if(r===void 0||r===e.location.palletNum){if(e.action.loadOntoFace===void 0||e.action.loadOntoFace===e.location.face)return e.action.processAfterLoad&&e.action.processAfterLoad!==e.process?(0,Y.jsxs)(Y.Fragment,{children:[`Reclamp material to process # `,e.action.processAfterLoad]}):null;{let n=e.action.loadOntoFace??0,r=e.location.palletNum?t.pallets[e.location.palletNum]?.faceNames?.[n-1]:null;return(0,Y.jsxs)(Y.Fragment,{children:[`Transfer to `,r??`face ${n}`]})}}return null;default:{let n=e.action.loadOntoFace??0,i=e.action.loadOntoPalletNum?t.pallets[e.action.loadOntoPalletNum]?.faceNames?.[n-1]:null;return r===void 0?(0,Y.jsxs)(Y.Fragment,{children:[`Load to `,i??`face ${n}`,` of pal `,e.action.loadOntoPalletNum??``]}):r===e.action.loadOntoPalletNum?(0,Y.jsxs)(Y.Fragment,{children:[`Load to `,i??`face ${n}`]}):null}}case U.LoadingToBasket:return i!==void 0&&i===e.action.loadToBasketId&&e.action.loadToBasketSlot!==void 0?(0,Y.jsxs)(Y.Fragment,{children:[`Load into slot `,$a(e.action.loadToBasketSlot),e.action.processAfterLoad===void 0?``:` for process ${e.action.processAfterLoad}`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Load into `,n,` `,e.action.loadToBasketId??``,e.action.loadToBasketSlot===void 0?``:` slot ${$a(e.action.loadToBasketSlot)}`,e.action.processAfterLoad===void 0?``:` for process ${e.action.processAfterLoad}`]});case U.UnloadToInProcess:case U.UnloadToCompletedMaterial:return e.action.unloadToBasketId?(0,Y.jsxs)(Y.Fragment,{children:[`Unload to `,n,` `,e.action.unloadToBasketId,e.action.unloadToBasketSlot===void 0?``:` slot ${$a(e.action.unloadToBasketSlot)}`]}):e.action.unloadIntoQueue?(0,Y.jsxs)(Y.Fragment,{children:[`Unload into queue `,e.action.unloadIntoQueue]}):e.action.type===U.UnloadToCompletedMaterial&&e.location.type===H.InBasket?(0,Y.jsxs)(Y.Fragment,{children:[`Unload completed from `,n,` `,e.location.basketId]}):e.location.type===H.InBasket?(0,Y.jsxs)(Y.Fragment,{children:[`Unload from `,n,` `,e.location.basketId]}):(0,Y.jsx)(Y.Fragment,{children:`Unload from pallet`});case U.Waiting:if(e.location.type===H.InQueue&&e.jobUnique&&e.jobUnique!==``)return(0,Y.jsxs)(Y.Fragment,{children:[`Waiting; next process is #`,e.process+1]});if(e.location.type===H.InBasket)return(0,Y.jsxs)(Y.Fragment,{children:[`In `,n,` `,e.location.basketId]});if(e.location.type===H.OnPallet){if((t.jobs[e.jobUnique]?.procsAndPaths?.[e.process-1]?.paths?.[e.path-1])?.stops?.length===0)return(0,Y.jsx)(Y.Fragment,{children:`Waiting`});if(e.lastCompletedMachiningRouteStopIndex===null||e.lastCompletedMachiningRouteStopIndex===void 0)return(0,Y.jsx)(Y.Fragment,{children:`Waiting for machining`})}break;case U.Machining:return(0,Y.jsxs)(Y.Fragment,{children:[`Machining program `,e.action.program??``]})}return null}function $d({mat:e,inProcMat:t}){let n=r(Bl).matsById.get(e.materialID),i=t?n?.quarantineSignals?.get(Ud(t).process)?.note:void 0,a=null;if(e.signaledInspections.length>0&&(a=`Inspect: `+e.signaledInspections.join(`, `)),e.quarantineAfterUnload){let e=`Material will quarantine after unload`+(i?`: ${i}`:``);a===null?a=e:a+=`; ${e}`}return a===null?null:(0,Y.jsx)(S,{title:a,describeChild:!0,children:(0,Y.jsx)(tn,{titleAccess:`Material warnings`})})}function ef({fsize:e,mat:t}){let n=r(q).jobs[t.jobUnique],i=t.path;if((t.action.type===U.Loading||t.action.type===U.LoadingToBasket)&&t.action.pathAfterLoad&&(i=t.action.pathAfterLoad),!n)return null;let a=n.procsAndPaths?.[0]?.paths?.[i-1];return a&&a.casting&&a.casting!==``?(0,Y.jsx)(Xd,{fsize:e,children:a.casting}):null}function tf({fsize:e,uniq:t}){let n=r(q).jobs[t],i=r(Iu);if(n&&n.bookings&&n.bookings.length>0){let t=i.get(n.bookings[0]);if(t&&t.notes&&t.notes!==``)return(0,Y.jsx)(Xd,{fsize:e,style:{textOverflow:`ellipsis`,overflow:`hidden`,whiteSpace:`nowrap`,maxWidth:`10em`},children:t.notes})}return null}function nf(){let e=r(q),t=r(ic);if(!t)return null;let n=e.workorders?.find(e=>e.workorderId===t)?.comments??[];return(0,Y.jsxs)(`div`,{style:{marginTop:`1em`,marginLeft:`1em`},children:[(0,Y.jsxs)(`p`,{children:[`Workorder: `,t]}),(0,Y.jsx)(`ul`,{children:n.map((e,t)=>(0,Y.jsx)(`li`,{children:e.comment},t))})]})}var rf=function({mat:e,materialCount:t=1,inProcMat:n,fsize:r,focusInspectionType:i,isDragOverlay:a,isActiveDrag:o,shake:s,dragRootProps:c,showDragHandle:l,setDragHandleRef:u,dragHandleProps:d,displayJob:f,hideEmptySerial:p,showRawMaterial:m,showJobComment:h,displayActionForSinglePallet:g,displayActionForSingleBasket:ee,hideAvatar:_,hideWarningIcon:te,ref:ne}){let v=j(X),y=e.completedInspections||{},re;return i&&y[i]?re=(0,Y.jsxs)(Xd,{fsize:r,children:[(0,Y.jsx)(`span`,{children:`Inspection completed `}),(0,Y.jsx)(Ae,{date:y[i].time})]}):i&&e.last_unload_time?re=(0,Y.jsxs)(Xd,{fsize:r,children:[(0,Y.jsx)(`span`,{children:`Unloaded `}),(0,Y.jsx)(Ae,{date:e.last_unload_time})]}):e.closeout_completed&&(re=(0,Y.jsxs)(Xd,{fsize:r,children:[(0,Y.jsxs)(`span`,{children:[e.closeout_failed?`Failed `:``,`Closed Out `]}),(0,Y.jsx)(Ae,{date:e.closeout_completed})]})),(0,Y.jsxs)(He,{ref:ne,elevation:4,sx:{position:`relative`,display:`flex`,minWidth:`10em`,padding:`8px`,margin:a?void 0:`8px`,opacity:o?.2:1,animation:s?Kd:void 0,"&:hover":{animationPlayState:`paused`}},onAnimationIteration:Jd,...c,children:[t>1&&(0,Y.jsx)(Nt,{badgeContent:t,color:`secondary`,sx:{position:`absolute`,top:0,right:0,zIndex:1}}),l?(0,Y.jsx)(`div`,{ref:u,role:`button`,tabIndex:0,style:{display:`flex`,flexDirection:`column`,justifyContent:`center`,cursor:a?`grabbing`:`grab`,touchAction:`none`},...d,children:(0,Y.jsx)(Tn,{fontSize:`large`,color:`action`})}):void 0,(0,Y.jsx)(ln,{focusRipple:!0,sx:{width:`100%`},onClick:()=>v(n?{type:`InProcMat`,inproc:n}:{type:`MatSummary`,summary:e}),children:(0,Y.jsxs)(B,{sx:{display:`flex`,textAlign:`left`,alignItems:`center`,width:`100%`},children:[(0,Y.jsx)($,{part:e.partName}),(0,Y.jsxs)(B,{sx:{marginLeft:`8px`,flexGrow:1,minWidth:0},children:[(0,Y.jsx)(Yd,{fsize:r,children:e.partName}),f?(0,Y.jsx)(Xd,{fsize:r,children:e.jobUnique&&e.jobUnique!==``?`Assigned to `+e.jobUnique:`Unassigned material`}):void 0,!p||e.serial?(0,Y.jsxs)(Xd,{fsize:r,children:[`Serial: `,e.serial?e.serial:`none`]}):void 0,e.workorderId===void 0||e.workorderId===``||e.workorderId===e.serial?void 0:(0,Y.jsxs)(Xd,{fsize:r,children:[`Workorder: `,e.workorderId]}),e.jobUnique!==void 0&&m&&n&&n.process===0?(0,Y.jsx)(ef,{fsize:r,mat:n}):void 0,h&&e.jobUnique&&e.jobUnique!==``?(0,Y.jsx)(tf,{fsize:r,uniq:e.jobUnique}):void 0,n?(0,Y.jsx)(Zd,{mat:n,displayActionForSinglePallet:g,displayActionForSingleBasket:ee,fsize:r}):void 0,n?.problem?(0,Y.jsx)(Xd,{fsize:r,children:(0,Y.jsxs)(b,{variant:`body2`,color:`error`,sx:{fontWeight:`bold`},children:[`⚠ `,n.problem]})}):void 0,re]}),(0,Y.jsxs)(B,{sx:{marginLeft:`4px`,display:`flex`,flexDirection:`column`,justifyContent:`space-between`,alignItems:`flex-end`,alignSelf:`start`,flexShrink:0},children:[e.serial&&e.serial.length>=1&&!_?(0,Y.jsx)(`div`,{children:(0,Y.jsx)(ur,{style:{width:`30px`,height:`30px`},children:e.serial.slice(-1)})}):void 0,te?void 0:(0,Y.jsx)(`div`,{children:(0,Y.jsx)($d,{mat:e,inProcMat:n})})]})]})})]})},af=(0,K.memo)(rf),of=(0,K.memo)(function(e){return(0,Y.jsx)(rf,{mat:Ul(e.mat),materialCount:e.materialCount,inProcMat:e.mat,displayActionForSinglePallet:e.displayActionForSinglePallet,displayActionForSingleBasket:e.displayActionForSingleBasket,fsize:e.fsize,hideAvatar:e.hideAvatar,displayJob:e.displayJob,showDragHandle:e.showHandle,hideEmptySerial:e.hideEmptySerial,showRawMaterial:e.showRawMaterial,showJobComment:e.showJobComment,shake:e.shake})}),sf=(0,K.memo)(function(e){let t=js(r(q),[e.mat]).length>0,n=!t&&(Vd(e.mat)||Bd(e.mat)),i={mat:e.mat},{active:a,isDragging:o,attributes:s,listeners:c,setNodeRef:l,setActivatorNodeRef:u,transform:d,transition:f}=fr({id:e.mat.materialID,data:i,disabled:{draggable:!n}}),p={...c};for(let[e,t]of Object.entries(s))e.startsWith(`aria`)&&(p[e]=t);let m={transform:d?`translate3d(${Math.round(d.x)}px, ${Math.round(d.y)}px, 0)`:void 0,transition:a===null?void 0:f};return(0,Y.jsx)(rf,{ref:l,dragRootProps:{style:m},showDragHandle:n,dragHandleProps:p,setDragHandleRef:u,isActiveDrag:o,mat:Ul(e.mat),materialCount:e.materialCount,inProcMat:e.mat,displayActionForSinglePallet:e.displayActionForSinglePallet,displayActionForSingleBasket:e.displayActionForSingleBasket,hideAvatar:e.hideAvatar,displayJob:e.displayJob,hideEmptySerial:e.hideEmptySerial,fsize:e.fsize,shake:a||t?void 0:e.shake,showRawMaterial:e.showRawMaterial,showJobComment:e.showJobComment})});function cf(e){return(0,Y.jsx)(rf,{mat:Ul(e.mat),materialCount:e.materialCount,inProcMat:e.mat,displayActionForSinglePallet:e.displayActionForSinglePallet,displayActionForSingleBasket:e.displayActionForSingleBasket,showDragHandle:!0,hideAvatar:e.hideAvatar,displayJob:e.displayJob,fsize:e.fsize,hideEmptySerial:e.hideEmptySerial,isDragOverlay:!0})}var lf=(0,K.memo)(function(e){return(0,Y.jsx)(He,{elevation:4,sx:{display:`flex`,minWidth:`10em`,padding:`8px`,margin:`8px`},children:(0,Y.jsx)(Nt,{badgeContent:e.material.length<2?0:e.material.length,color:`secondary`,children:(0,Y.jsx)(ln,{focusRipple:!0,onClick:()=>e.onOpen(),children:(0,Y.jsxs)(B,{sx:{display:`flex`,textAlign:`left`},children:[(0,Y.jsx)($,{part:e.partOrCasting}),(0,Y.jsxs)(B,{sx:{marginLeft:`8px`,flexGrow:1},children:[(0,Y.jsx)(b,{variant:`h6`,children:e.partOrCasting}),(0,Y.jsx)(Xd,{fsize:e.fsize,children:e.assignedJobUnique&&e.assignedJobUnique!==``?`Assigned to `+e.assignedJobUnique:`Unassigned material`})]}),e.material.length>0&&e.material[0].serial&&e.material[0].serial.length>=1?(0,Y.jsx)(`div`,{children:(0,Y.jsx)(ur,{style:{width:`30px`,height:`30px`},children:e.material[0].serial.slice(-1)})}):void 0]})})})})}),uf=(0,K.memo)(function({partName:e,serial:t,subtitle:n,notes:r}){let i;return i=e===``?t??`Material`:t==null||t===``?r?`Add note for `+e:e:r?`Add note for `+t:e+` - `+t,(0,Y.jsxs)(B,{sx:{display:`flex`,textAlign:`left`},children:[e===``?(0,Y.jsx)(at,{}):(0,Y.jsx)($,{part:e}),(0,Y.jsxs)(B,{sx:{marginLeft:`8px`,flexGrow:1},children:[(0,Y.jsx)(b,{variant:`h6`,children:i}),n?(0,Y.jsx)(b,{variant:`caption`,children:n}):void 0]})]})});function df({notes:e}){let t=r(X),n=r($s),i=r(rc),a=``,o=null;switch(t?.type){case`InProcMat`:a=t.inproc.partName,o=t.inproc.serial;break;case`MatSummary`:a=t.summary.partName,o=t.summary.serial;break;case`MatDetails`:a=t.details.partName,o=t.details.serial;break;case`LogMat`:a=t.logMat.part,o=t.logMat.serial;break;case`Barcode`:o=t.barcode;break;case`ManuallyEnteredSerial`:case`AddMatWithEnteredSerial`:o=t.serial}return n.state===`hasData`&&n.data!==null&&(a=n.data.partName,o=n.data.serial??o),i.state===`hasData`&&i.data&&(o=i.data),(0,Y.jsx)(uf,{notes:e,partName:a,serial:o})}function ff(){let e=r(pc);function t(t){return e.completedInspections.includes(t)?`black`:`red`}return e.signaledInspections.length===0?(0,Y.jsx)(`small`,{children:`Inspections: none`}):(0,Y.jsxs)(`small`,{children:[`Inspections:`,` `,e.signaledInspections.map((e,n)=>(0,Y.jsxs)(`span`,{children:[n===0?``:`, `,(0,Y.jsx)(`span`,{style:{color:t(e)},children:e})]},n))]})}function pf({highlightProcsGreaterOrEqualTo:e}){let t=r(dc);return(0,Y.jsx)(Ks,{entries:t,copyToClipboard:!0,highlightProcsGreaterOrEqualTo:e})}function mf(){let e=r(tc),t=r(q).jobs,n=r(Iu),i=e?t[e.jobUnique]:null;if(i&&i.bookings&&i.bookings.length>0){let e=n.get(i.bookings[0]);if(e&&e.notes&&e.notes!==``)return(0,Y.jsx)(b,{variant:`caption`,sx:{width:`100%`,textWrap:`wrap`},children:e.notes})}return null}function hf({material:e}){let t=r(uc),n=Ud(e).process,i=t.reduce((t,r)=>r.type===V.SignalQuarantine&&r.material.some(t=>t.id===e.materialID&&t.proc===n)&&(t===null||r.counter>t.counter)?r:t,null)?.details?.note?.trim();return i?`: ${i}`:null}function gf(){let e=r(tc),t=hc(),n=e?Pd(e):null;return(0,Y.jsx)(Y.Fragment,{children:e?.quarantineAfterUnload?(0,Y.jsxs)(b,{variant:`caption`,component:`p`,children:[`Quarantine requested`,(0,Y.jsx)(yn,{fallback:null,resetKeys:[e.materialID,Ud(e).process],children:(0,Y.jsx)(hf,{material:e})})]}):t.length===0&&n?.kind===`ActiveLoadStationOperation`&&n.cancellationId===null?(0,Y.jsx)(b,{variant:`caption`,component:`p`,children:`This material is part of the current load/unload operation. Complete the operation or cancel it at the machine control before making other changes.`}):null})}var _f=(0,K.memo)(function({highlightProcsGreaterOrEqualTo:e}){let t=r(X),n=r(Xs),i=r(Ys);return t===null?null:n===null?t.type===`AddMatWithEnteredSerial`||t.type===`ManuallyEnteredSerial`?(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`},children:[`Material with serial `,t.serial,` not found.`]}):t.type===`Barcode`?i?(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`},children:[`Material with barcode `,t.barcode,` does not yet exist in the cell.`]}):(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`},children:[`Material with barcode `,t.barcode,` not found.`]}):(0,Y.jsx)(`div`,{style:{marginLeft:`1em`},children:`Material not found.`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`},children:[(0,Y.jsx)(gf,{}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(`small`,{children:[`Workorder: `,n?.workorderId??`none`]})}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(jd,{fallback:(0,Y.jsxs)(`small`,{children:[`Inspections: `,(0,Y.jsx)(pn,{size:`10`})]}),children:(0,Y.jsx)(ff,{})})}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(jd,{fallback:(0,Y.jsx)(`div`,{}),children:(0,Y.jsx)(mf,{})})})]}),(0,Y.jsx)(jd,{fallback:(0,Y.jsx)(pn,{}),children:(0,Y.jsx)(pf,{highlightProcsGreaterOrEqualTo:e})})]})});function vf(e){let[t,n]=(0,K.useState)(``),i=r(ga),[a]=bc(),o=r(Xs);return o===null?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(M,{children:(0,Y.jsx)(_,{sx:{mt:`5px`},multiline:!0,label:`Note`,autoFocus:!0,variant:`outlined`,value:t,onChange:e=>n(e.target.value)})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(z,{onClick:()=>{a({matId:o.materialID,process:0,operator:i,notes:t}),e.setNotesOpen(!1),n(``)},disabled:t===``,color:`secondary`,children:`Save`}),(0,Y.jsx)(z,{onClick:()=>{e.setNotesOpen(!1),n(``)},color:`secondary`,children:`Cancel`})]})]})}function yf(){let e=r(X);if(e===null)return null;let t;switch(e.type){case`Barcode`:t=`Loading material with barcode `+e.barcode+`...`;break;case`AddMatWithEnteredSerial`:case`ManuallyEnteredSerial`:t=`Loading material with serial `+e.serial+`...`;break;default:t=`Loading material...`}return(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`},children:[(0,Y.jsx)(pn,{}),(0,Y.jsx)(`div`,{style:{marginTop:`1em`},children:t})]})}function bf({setNotesOpen:e}){let t=r(Xs);return t===null||t.materialID<0?null:(0,Y.jsx)(z,{onClick:()=>e(!0),color:`primary`,children:`Add Note`})}var xf=(0,K.memo)(function(e){let[t,n]=(0,K.useState)(!1),[r,i]=A(X);function a(){i(null),e.onClose&&e.onClose()}let o,s;return r&&(o=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($n,{children:(0,Y.jsx)(df,{})}),(0,Y.jsx)(M,{children:(0,Y.jsxs)(jd,{fallback:(0,Y.jsx)(yf,{}),children:[(0,Y.jsx)(_f,{highlightProcsGreaterOrEqualTo:e.highlightProcsGreaterOrEqualTo}),(0,Y.jsx)(jd,{fallback:(0,Y.jsx)(pn,{}),children:e.extraDialogElements})]})}),(0,Y.jsxs)(N,{children:[r&&(e.buttons||e.allowNote)?(0,Y.jsx)(yn,{fallback:(0,Y.jsx)(`div`,{}),children:(0,Y.jsxs)(K.Suspense,{fallback:(0,Y.jsx)(`div`,{}),children:[r&&e.allowNote?(0,Y.jsx)(bf,{setNotesOpen:n}):void 0,e.buttons]})}):null,(0,Y.jsx)(z,{onClick:a,color:`secondary`,children:`Close`})]})]}),e.allowNote&&(s=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($n,{children:(0,Y.jsx)(df,{notes:!0})}),(0,Y.jsxs)(jd,{fallback:(0,Y.jsx)(M,{children:(0,Y.jsx)(pn,{})}),children:[(0,Y.jsx)(vf,{setNotesOpen:n}),`;`]})]}))),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(I,{open:r!==null,onClose:a,maxWidth:`lg`,children:o}),e.allowNote?(0,Y.jsx)(I,{open:t,onClose:()=>n(!1),maxWidth:`md`,children:s}):void 0]})}),Sf=l(`MachineCostPerYear`,{}),Cf=l(`AutomationCostPerYear`,null),wf=l(`Last30LaborCost`,null),Tf=de(e=>l(`PerMonthLabor-`+e.getFullYear().toString()+`-`+e.getMonth().toString(),null)),Ef=F(e=>e(e(od).type===`Last30`?ia:ca).valuesToLazySeq().filter(e=>e.procsAndPaths.length===1&&e.procsAndPaths[0].paths.length===1&&e.procsAndPaths[0].paths[0].stops.length===1&&Oa(e.procsAndPaths[0].paths[0].stops[0].expectedCycleTime)===0).toHashSet(e=>e.partName)),Df=F(e=>{let t=e(od),n=e(t.type===`Last30`?ao:co),r=e(t.type===`Last30`?Bl:Hl),i=e(Ef),a=P(k(),-30),o=t.type===`Last30`?null:t.month;return _d(n.valuesToLazySeq(),i,r.matsById,o?{month:o}:{thirtyDaysAgo:a})}),Of=F(e=>{let t=e(od),n=e(Sf),r=e(Cf),i=e(t.type===`Last30`?wf:Tf(t.month));return vd(e(Df),n,r,i??0)});function kf(){let[e,t]=(0,K.useState)(null),[n,r]=A(Cf);return(0,Y.jsx)(_,{id:`auotmation-cost-year`,type:`number`,label:`Cost for automated handling system per year`,style:{marginTop:`1.5em`},variant:`outlined`,value:e===null?n??``:isNaN(e)?``:e,onChange:e=>t(parseFloat(e.target.value)),onBlur:()=>{e!=null&&r(isNaN(e)?null:e),t(null)},slotProps:{htmlInput:{min:0}}})}function Af(){let e=r(od),t=e.type===`Last30`?null:e.month,[n,i]=(0,K.useState)(null),[a,o]=A(t===null?wf:Tf(t));return(0,Y.jsx)(_,{type:`number`,label:`Total labor cost for `+(t===null?`last 30 days`:t.toLocaleDateString(void 0,{month:`long`,year:`numeric`})),variant:`outlined`,value:n===null?a??``:isNaN(n)?``:n,onChange:e=>i(parseFloat(e.target.value)),onBlur:()=>{n!=null&&o(isNaN(n)?null:n),i(null)},slotProps:{htmlInput:{min:0}}})}function jf(e){let[t,n]=(0,K.useState)(null),[r,i]=A(Sf);return(0,Y.jsx)(_,{type:`number`,variant:`outlined`,label:`Cost for `+e.machineGroup+` per station per year`,style:{marginTop:`1.5em`},value:t===null?r[e.machineGroup]??``:isNaN(t)?``:t,onChange:e=>n(parseFloat(e.target.value)),onBlur:()=>{if(t!=null){let n={...r};isNaN(t)?delete n[e.machineGroup]:n[e.machineGroup]=t,i(n)}n(null)},slotProps:{htmlInput:{min:0}}})}function Mf(){let e=r(Of);return(0,Y.jsx)(Y.Fragment,{children:e.machineQuantities.keysToAscLazySeq().map((t,n)=>(0,Y.jsx)(jf,{machineQuantities:e.machineQuantities,machineGroup:t},n))})}var Nf=Intl.NumberFormat(void 0,{minimumFractionDigits:1,maximumFractionDigits:1}),Pf=new Intl.NumberFormat(void 0,{style:`percent`,minimumFractionDigits:1,maximumFractionDigits:1});function Ff(){Q(`Cost Percentages`);let e=r(Df);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsx)(b,{variant:`subtitle1`,children:`Part Cost Percentage Breakdown`}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},onClick:()=>Sd(e),size:`large`,children:(0,Y.jsx)(ct,{})})})]}),(0,Y.jsx)(`main`,{children:(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Part`}),(0,Y.jsx)(w,{align:`right`,children:`Completed Quantity`}),e.machineQuantities.keysToAscLazySeq().map(e=>(0,Y.jsxs)(w,{align:`right`,children:[e,` Cost %`]},e)),(0,Y.jsx)(w,{align:`right`,children:`Labor Cost %`}),(0,Y.jsx)(w,{align:`right`,children:`Automation Cost %`})]})}),(0,Y.jsx)(ae,{children:D.of(e.parts).sortBy(e=>e.part).map((t,n)=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:t.part,size:25})}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(b,{variant:`body2`,component:`span`,sx:{display:`block`},children:t.part})})]})}),(0,Y.jsx)(w,{align:`right`,children:t.parts_completed}),e.machineQuantities.keysToAscLazySeq().map(e=>(0,Y.jsx)(w,{align:`right`,children:Pf.format(t.machine.get(e)??0)},e)),(0,Y.jsx)(w,{align:`right`,children:Pf.format(t.labor)}),(0,Y.jsx)(w,{align:`right`,children:Pf.format(t.automation)})]},n))})]})})]})}function If(){let e=r(Of);return(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Part`}),(0,Y.jsx)(w,{align:`right`,children:`Completed Quantity`}),e.machineQuantities.keysToAscLazySeq().map(e=>(0,Y.jsxs)(w,{align:`right`,children:[e,` Cost`]},e)),(0,Y.jsx)(w,{align:`right`,children:`Labor Cost`}),(0,Y.jsx)(w,{align:`right`,children:`Automation Cost`}),(0,Y.jsxs)(w,{align:`right`,children:[(0,Y.jsx)(`span`,{children:`Total`}),(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},onClick:()=>bd(e),size:`large`,children:(0,Y.jsx)(ct,{})})})]})]})}),(0,Y.jsx)(ae,{children:D.of(e.parts).sortBy(e=>e.part).map((t,n)=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:t.part,size:25})}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(b,{variant:`body2`,component:`span`,sx:{display:`block`},children:t.part})})]})}),(0,Y.jsx)(w,{align:`right`,children:t.parts_completed}),e.machineQuantities.keysToAscLazySeq().map(e=>(0,Y.jsx)(w,{align:`right`,children:Nf.format(t.machine.get(e)??0)},e)),(0,Y.jsx)(w,{align:`right`,children:Nf.format(t.labor)}),(0,Y.jsx)(w,{align:`right`,children:Nf.format(t.automation)}),(0,Y.jsx)(w,{align:`right`,children:Nf.format(t.machine.valuesToAscLazySeq().sumBy(e=>e)+t.labor+t.automation)})]},n))})]})}var Lf=(0,K.memo)(function(){return Q(`Cost Per Piece`),(0,Y.jsx)(B,{component:`main`,sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`20px`},children:(0,Y.jsxs)(E,{direction:`column`,spacing:4,children:[(0,Y.jsxs)(E,{direction:`column`,spacing:2,children:[(0,Y.jsx)(Af,{}),(0,Y.jsx)(kf,{}),(0,Y.jsx)(Mf,{})]}),(0,Y.jsx)(If,{})]})})}),Rf=F(!1),zf=Rf,Bf=F(null),Vf=F(Fn.empty()),Hf=F(null),Uf=F(null),Wf=F(e=>e(ll)??e(Hf)??e(Uf));async function Gf(e,t,n,r){for(;ul(e,n);){let i=e(q),a=e(sl).snapshot,o;try{r?.throwIfAborted(),o=await Bi.currentStatus(r),r?.throwIfAborted()}catch(t){let i=e(sl);if(i.id!==n)return!1;if(!r?.aborted&&i.snapshot!==a&&i.snapshot?.source===`socket`)return!0;throw t}let s=e(sl);if(s.id!==n)return!1;let c=s.snapshot?.status;if(c&&o.revision<=c.revision)return!0;if(e(q)===i||e(q)===c)return t(fl,n,o,`http`),!0}return!1}var Kf=F(null,(e,t,n)=>Gf(e,t,e(sl).id,n));async function qf(e,t,n,r=1e3){try{await Gf(e,t,n,AbortSignal.timeout(1e4))}catch(i){if(!ul(e,n)||e(cl))return;t(ll,Dd(i,`Error loading current status`)),setTimeout(()=>{ul(e,n)&&!e(cl)&&qf(e,t,n,Math.min(r*2,3e4))},r)}}function Jf(e,t,n,r,i=1e3){let a=new Date,o=AbortSignal.timeout(12e4);return(r===null?Vi.get(P(a,-30),a,o):Vi.recent(r,void 0,o)).then(r=>{if(!ul(e,n))return;let i=e(Bf)??se.empty(),a=r.reduce((e,t)=>e.set(t.counter,t),i);t($u,a.valuesToAscLazySeq().toRArray()),t(Vf,Fn.from(a.keys())),t(Bf,null),t(Uf,null)},a=>{ul(e,n)&&(t(Uf,o.aborted?`Loading log history timed out.`:Dd(a,`Error loading log history`)),setTimeout(()=>{ul(e,n)&&Jf(e,t,n,r,Math.min(i*2,3e4))},i))})}function Yf(e,t,n){let r=e(Yu),i=e(oa);Xf([qf(e,t,n),Bi.recent(P(new Date,-30),r!==null&&i?Array.from(i):[]).then(r=>{ul(e,n)&&t(Qu,r)}),Jf(e,t,n,r)],e,t,n)}function Xf(e,t,n,r){Promise.all(e).catch(e=>{ul(t,r)&&n(Hf,Dd(e,`Error`))}).finally(()=>{ul(t,r)&&n(Rf,!1)})}var Zf=class{constructor(e){this.session=null,this.userCalledClose=!1,this.reconnectAttempts=0,this.url=e,this.connect()}close(){this.userCalledClose=!0,this.ws?.close(),this.endSession(!1)}endSession(e){let t=this.session;this.session=null,this.handleClose?.(t,e)}connect(){if(this.userCalledClose)return;this.ws=new WebSocket(this.url);let e=this.ws,t=setTimeout(()=>{e.close()},2e3);e.addEventListener(`open`,()=>{clearTimeout(t),this.reconnectAttempts=0,this.session=this.handleOpen?.()??null}),e.addEventListener(`close`,()=>{if(clearTimeout(t),this.ws=void 0,this.userCalledClose)return;this.endSession(!0);let e=Math.min(1e3*1.5**this.reconnectAttempts,3e4);setTimeout(()=>{this.reconnectAttempts++,this.connect()},e)}),e.addEventListener(`message`,e=>{this.handleMessage?.(e,this.session)})}},Qf=F(null,(e,t)=>{let n=e(sl).id+1;return t(sl,{id:n,open:!0,snapshot:null}),t(Rf,!0),t(cl,!1),t(Hf,null),t(Uf,null),t(ll,null),t(Bf,se.empty()),Yf(e,t,n),n}),$f=F(null,(e,t,n,r)=>{r&&t(Rf,!0),n!==null&&ul(e,n)&&(t(sl,{id:n+1,open:!1,snapshot:null}),t(cl,!1),t(Bf,null))}),ep=F(null,(e,t,n,r)=>{if(r===null||!ul(e,r))return;let i=Tr.fromJS(JSON.parse(n.data)),a=i.newCurrentStatus,o=a&&t(fl,r,a,`socket`),s=a&&!o?new Tr({logEntry:i.logEntry,newJobs:i.newJobs}):i,c={evt:s,now:new Date,expire:!0};s.newCurrentStatus||t(Xu,c);let l=s.logEntry,u=e(Bf);l&&e(Vf).has(l.counter)||(l&&u!==null?t(Bf,u.set(l.counter,l)):t(Zu,c))});function tp(){let e=j(Qf),t=j($f),n=j(ep),i=r(G),a=(0,K.useRef)(null);return(0,K.useEffect)(()=>{if(a.current)return;let r=i.user??null,o=window.location,s;if(o.protocol===`backup:`)return;s=o.protocol===`https:`?`wss:`:`ws:`,s+=`//`+o.host+`/api/v1/events`,r&&(s+=`?token=`+encodeURIComponent(r.access_token));let c=new Zf(s);return c.handleOpen=e,c.handleClose=t,c.handleMessage=n,a.current=c,()=>{a.current&&=(a.current.close(),null)}},[i,n,e,t]),null}var np=[{type:`Subheader`,caption:`Shop Floor`},{type:`Link`,route:{route:Z.Station_LoadMonitor,loadNum:1,queues:[],completed:!1},icon:(0,Y.jsx)(Ot,{}),label:`Load Station`},{type:`Link`,route:{route:Z.Station_Queues,queues:[]},icon:(0,Y.jsx)(ht,{}),label:`Queue Management`},{type:`Link`,route:{route:Z.Station_InspectionMonitor},icon:(0,Y.jsx)(pe,{}),label:`Inspection Stand`},{type:`Link`,route:{route:Z.Station_Closeout},icon:(0,Y.jsx)(un,{}),label:`Close Out`},{type:`Link`,route:{route:Z.Tools_Dashboard},icon:(0,Y.jsx)(nr,{}),label:`Tool Management`},{type:`Link`,route:{route:Z.Station_Overview},icon:(0,Y.jsx)($t,{}),label:`System Overview`},{type:`Subheader`,caption:`Daily Monitoring`},{type:`Link`,route:{route:Z.Operations_Dashboard},icon:(0,Y.jsx)(g,{}),label:`Operation Management`},{type:`Link`,route:{route:Z.Engineering_Cycles},icon:(0,Y.jsx)(Ue,{}),label:`Engineering`},{type:`Link`,route:{route:Z.Quality_Dashboard},icon:(0,Y.jsx)(Pt,{}),label:`Quality Analysis`},{type:`Link`,route:{route:Z.Sales_Dashboard},icon:(0,Y.jsx)(c,{}),label:`Sales`},{type:`Subheader`,caption:`Monthly Review`},{type:`Link`,route:{route:Z.Analysis_Buffers},icon:(0,Y.jsx)(dt,{}),label:`Flexibility Analysis`}];function rp(e){let t=r(q),i=r(Wf),a=r(dd),o=D.of([...t.alarms,i,a]).filter(e=>e!==null&&e.length>0).distinct().toRArray(),s=(0,Y.jsx)(He,{children:(0,Y.jsx)(Wt,{component:`nav`,dense:!0,children:(e.modes??np).map((t,r)=>t.type===`Subheader`?(0,Y.jsx)(h,{children:t.caption},r):(0,Y.jsx)(xt,{children:(0,Y.jsxs)(n,{onClick:()=>e.setRoute(t.route),children:[(0,Y.jsx)(mt,{children:t.icon}),(0,Y.jsx)(_t,{children:t.label})]})},r))})});return(0,Y.jsx)(`main`,{style:{display:`flex`,justifyContent:`center`},children:(0,Y.jsxs)(`div`,{style:{maxWidth:`50em`,padding:`0 1em`},children:[(0,Y.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,Y.jsx)(b,{variant:`h4`,style:{marginTop:`2em`},children:`Select user and computer location`}),(0,Y.jsxs)(b,{variant:`caption`,style:{marginBottom:`2em`,maxWidth:`30em`,marginLeft:`auto`,marginRight:`auto`},children:[`We recommend that after selecting one of the following modes, you bookmark the page and visit it directly.`,(0,Y.jsx)(`a`,{href:`https://fms-insight.seedtactics.com/docs/client-dashboard.html`,children:`Learn More`})]})]}),o.length>0?(0,Y.jsxs)(te,{severity:`error`,sx:{margin:`1em 0`},children:[(0,Y.jsx)(it,{children:`FMS Insight errors`}),o.map(e=>(0,Y.jsx)(`p`,{children:e},e))]}):void 0,s]})})}var ip=(0,K.memo)(function(){let e=j(X);return(0,K.useEffect)(()=>{let t,n=!1,r=``,i=null;function a(){r=``,n=!1}function o(){r=``,n=!0,t=window.setTimeout(a,3e3)}function s(){t&&=(clearTimeout(t),void 0),n=!1,e({type:`Barcode`,barcode:r,toQueue:null})}function c(e){e.key===`!`?i=Date.now():e.code===`F1`&&!n||e.key===`*`&&!n&&i!==null&&Date.now()-i<1e3?(o(),e.stopPropagation(),e.preventDefault()):n&&e.code===`Enter`?(s(),e.stopPropagation(),e.preventDefault()):n&&e.key&&e.key.length===1&&/[a-zA-Z0-9-|_,;]/.test(e.key)&&(r+=e.key,e.stopPropagation(),e.preventDefault())}return document.addEventListener(`keydown`,c,{capture:!0}),()=>document.removeEventListener(`keydown`,c)},[e]),null}),ap=(0,K.memo)(function(){let[e,t]=(0,K.useState)(!1),n=j(X),[r,i]=(0,K.useState)(``);if(window.location.protocol!==`https:`)return null;function a(e){e.length>0&&e[0].rawValue!==null&&e[0].rawValue!==``&&(n({type:`Barcode`,barcode:e[0].rawValue,toQueue:null}),t(!1),i(``))}function o(){r!==``&&n({type:`Barcode`,barcode:r,toQueue:null}),t(!1),i(``)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(I,{open:e,onClose:()=>t(!1),children:[(0,Y.jsx)($n,{children:`Scan a QR Code`}),(0,Y.jsxs)(M,{children:[(0,Y.jsx)(B,{sx:{width:`15em`,height:`15em`},children:e?(0,Y.jsx)(Mn,{onScan:a}):void 0}),(0,Y.jsx)(B,{sx:{marginTop:`1em`},children:(0,Y.jsx)(_,{label:`Manual Entry`,value:r,variant:`outlined`,fullWidth:!0,onKeyDown:e=>{e.key===`Enter`&&o()},onChange:e=>i(e.target.value)})})]}),(0,Y.jsxs)(N,{children:[r===``?void 0:(0,Y.jsx)(z,{onClick:o,children:`Submit`}),(0,Y.jsx)(z,{onClick:()=>t(!1),children:`Cancel`})]})]}),(0,Y.jsx)(S,{title:`Scan QR Code`,children:(0,Y.jsx)(C,{onClick:()=>t(!0),size:`large`,children:(0,Y.jsx)(Nn,{})})})]})}),op=F(null),sp=(0,K.memo)(function(){let[e,t]=A(op),[n,r]=(0,K.useState)(``),i=j(X);function a(n){e!==null&&n.length>0&&n[0].rawValue!==null&&n[0].rawValue!==``&&(i({type:`Barcode`,barcode:n[0].rawValue,toQueue:e}),t(null),r(``))}function o(){n!==``&&e!==null&&i({type:`Barcode`,barcode:n,toQueue:e}),t(null),r(``)}return(0,Y.jsxs)(I,{open:e!==null,onClose:()=>t(null),maxWidth:`md`,children:[(0,Y.jsxs)($n,{children:[`Scan a Barcode To Add To `,e]}),(0,Y.jsxs)(M,{children:[window.location.protocol===`https:`?(0,Y.jsx)(B,{sx:{width:`15em`,height:`15em`},children:e===null?void 0:(0,Y.jsx)(Mn,{onScan:a})}):void 0,(0,Y.jsx)(B,{sx:{marginTop:`1em`},children:(0,Y.jsx)(_,{label:`Manual Entry`,value:n,variant:`outlined`,fullWidth:!0,onKeyDown:e=>{e.key===`Enter`&&o()},onChange:e=>r(e.target.value)})})]}),(0,Y.jsxs)(N,{children:[n===``?void 0:(0,Y.jsx)(z,{onClick:o,children:`Submit`}),(0,Y.jsx)(z,{onClick:()=>t(null),children:`Cancel`})]})]})});function cp(e,t,n,r){let i=D.of(t).flatMap(([e,t])=>D.ofObject(t.unloaded_processes??{}).map(([n])=>({matId:e,proc:parseInt(n),uniq:t.jobUnique}))).toLookupMap(e=>e.uniq,e=>e.proc,()=>1,(e,t)=>e+t),a=new Map;if(r)for(let[e,t]of D.ofObject(r.jobs)){let n=D.of(t.procsAndPaths[0]?.paths??[]).collect(e=>e.casting===``?null:e.casting).head();a.set(e,{partName:t.partName,comment:t.comment,routeStartTime:t.routeStartUTC,historicJob:null,inProcJob:t,casting:n??``,scheduledQty:t.cycles??0,decrementedQty:D.of(t.decrements||[]).sumBy(e=>e.quantity),completedQty:D.of(t.completed?.[t.completed?.length-1]??[]).sumBy(e=>e),inProcessQty:0,remainingQty:t.remainingToStart??0,darkRow:!1})}for(let[t,r]of n){let n=a.get(t);if(n)n.historicJob=r;else if(!e||r.routeStartUTC>=e.start&&r.routeStartUTC<=e.end){let e=D.of(r.procsAndPaths[0]?.paths??[]).collect(e=>e.casting===``?null:e.casting).head();a.set(t,{partName:r.partName,comment:r.comment,routeStartTime:r.routeStartUTC,historicJob:r,inProcJob:null,casting:e??``,scheduledQty:r.cycles??0,decrementedQty:D.of(r.decrements||[]).sumBy(e=>e.quantity),completedQty:i.get(t)?.get(r.procsAndPaths.length)??0,inProcessQty:0,darkRow:!1,remainingQty:0})}}if(r){for(let e of r.material)if(e.jobUnique){let t=a.get(e.jobUnique);t&&(t.inProcessQty+=1)}}let o=D.of(a.values()).toSortedArray({desc:e=>e.routeStartTime.getTime()},e=>e.partName),s=null,c=!0;for(let e of o)s!=(e.historicJob?.scheduleId??e.inProcJob?.scheduleId??null)&&(c=!c,s=e.historicJob?.scheduleId??e.inProcJob?.scheduleId??null),e.darkRow=c;return o}function lp(e,t){let n=`<table>
|
|
35
|
+
<thead><tr>`;n+=`<th>Date</th>`,n+=`<th>Part</th>`,t&&(n+=`<th>Material</th>`),n+=`<th>Note</th>`,n+=`<th>Scheduled</th>`,n+=`<th>Removed</th>`,n+=`<th>Completed</th>`,n+=`<th>In Process</th>`,n+=`</tr></thead>
|
|
36
|
+
<tbody>
|
|
37
|
+
`;for(let r of e)n+=`<tr><td>`+r.routeStartTime.toString()+`</td>`,n+=`<td>`+r.partName+`</td>`,t&&(n+=`<td>`+(r.casting??r.partName)+`</td>`),n+=`<td>`+(r.comment??``)+`</td>`,n+=`<td>`+r.scheduledQty.toFixed(0)+`</td>`,n+=`<td>`+r.decrementedQty.toFixed(0)+`</td>`,n+=`<td>`+r.completedQty.toFixed(0)+`</td>`,n+=`<td>`+r.inProcessQty.toFixed(0)+`</td>`,n+=`</tr>
|
|
38
|
+
`;return n+=`</tbody>
|
|
39
|
+
</table>`,n}function up(e,t){Je(lp(e,t))}var dp=l(`fmsinsight.hide-nonloading-loadstation`,!1);function fp(e){return`${e.palletNums&&e.palletNums.length>1?`Pallets `+e.palletNums.map(e=>e.toString()).join(`,`):e.palletNums&&e.palletNums.length==1?`Pallet `+e.palletNums[0].toString():`Pallet`}; ${e.stops.map(e=>e.stationGroup+`#`+(e.stationNums??[]).join(`,`)).join(`->`)}`}function pp(e,t,n){let r=D.ofObject(e.jobs).filter(([,e])=>e.procsAndPaths[0].paths.some(e=>e.casting===n)).toHashSet(([,e])=>e.partName),i=e.workorders?.find(e=>e.workorderId===t&&(e.part===n||r.has(e.part)));return i?`Started: ${i.material?.length??0}; Planned: ${i.plannedQuantity}`:null}function mp(e,t,n){let r=t?.workorder;return D.of(t?.possibleCastingsByQueue?.[n]??[]).map(t=>({casting:t,message:r?pp(e,r,t):null})).toSortedArray(e=>e.casting)}function hp(e,t,n,r){return D.of(n?.possibleJobsByQueue?.[r]??[]).groupBy(e=>e.jobUnique).collect(([n,r])=>{let i=e.jobs[n]??t.get(n);return{jobUnique:n,job:i??null,workorder:D.of(r).collect(e=>e.workorder).head()??null,machinedProcs:r.map(e=>({lastProc:e.lastCompletedProcess,details:i?.procsAndPaths[e.lastCompletedProcess].paths.map(fp).join(` | `)??``}))}}).toSortedArray(e=>e.job?.partName??e.jobUnique)}function gp(e){let t=r(ia),n=r(q),i=r(Ys),a=r(qc);return(0,K.useMemo)(()=>i===null||e===null?{castings:[],jobs:[]}:{castings:a.has(e)?mp(n,i,e):[],jobs:hp(n,t,i,e)},[n,t,e,i,a])}function _p(e,t){return t.jobUnique===e&&t.location.type===H.InQueue&&t.action.type!==U.Loading&&t.action.type!==U.LoadingToBasket&&t.process===0}function vp(e,t){return t.partName===e&&t.location.type===H.InQueue&&t.action.type!==U.Loading&&t.action.type!==U.LoadingToBasket&&t.process===0&&!t.jobUnique}function yp(e,t,n){return D.ofObject(e).filter(([,e])=>e.remainingToStart===void 0||e.remainingToStart>0).collect(([,e])=>{let r=(e.procsAndPaths?.[0]?.paths??[]).filter(e=>e.inputQueue===n);if(r.length===0)return null;let i=D.of(r).collect(e=>e.casting&&e.casting!==``?e.casting:void 0).head()??e.partName;return{job:e,startingTime:D.of(r).map(e=>e.simulatedStartingUTC).minBy(e=>e),rawMatName:i,remainingToStart:e.remainingToStart??0,assignedRaw:D.of(t).filter(t=>_p(e.unique,t)).length(),availableUnassigned:D.of(t).filter(e=>vp(i,e)).length()}}).toSortedArray(e=>{let t=D.of(e.job.precedence?.[0]??[]).minBy(e=>e);return!t||t<0?2**53-1:t})}function bp(e){return e.serial!==void 0&&e.serial!==null&&e.serial!==``}function xp(e){return[e.partName,e.jobUnique,e.process,e.action.type,e.action.loadOntoPalletNum,e.action.loadOntoFace,e.action.loadToBasketId,e.action.loadToBasketSlot,e.action.processAfterLoad,e.action.pathAfterLoad].join(`|`)}function Sp(e,t){let n=e=>t(e)&&!bp(e)?xp(e):null,r=D.of(e).collect(e=>{let t=n(e);return t===null?null:[t,e]}).groupBy(([e])=>e).toHashMap(([e,t])=>[e,t.map(([,e])=>e)]),i=new Set;return e.flatMap(e=>{let t=n(e);return t===null?[[e]]:i.has(t)?[]:(i.add(t),[r.get(t)??[e]])})}function Cp(e,t,n,r){let i=[],a=[...e];a.sort((e,t)=>e.localeCompare(t));for(let e of a)if(n.has(e)){let n=D.of(t.material).filter(t=>t.location.type===H.InQueue&&t.location.currentQueue===e&&t.location.queuePosition!==void 0).toSortedArray(e=>e.location.queuePosition??0),r=e=>!bp(e)&&e.action.type===U.Waiting,a=D.of(Sp(n.filter(r),()=>!0)).toSortedArray(e=>e[0].partName,e=>e[0].jobUnique??``);i.push({label:e,free:!1,rawMaterialQueue:!0,inProcQueue:!1,material:n.filter(e=>!r(e)),groupedRawMat:a.map(e=>({partOrCasting:e[0].partName,assignedJobUnique:e[0].jobUnique||null,material:e}))})}else i.push({label:e,free:!1,rawMaterialQueue:!1,inProcQueue:r.has(e),material:D.of(t.material).filter(t=>t.location.type===H.InQueue&&t.location.currentQueue===e&&t.location.queuePosition!==void 0).toSortedArray(e=>e.location.queuePosition??0)});return i}async function wp(e){let n=[];for(let t of D.of(e).chunk(15))n.push(...await Vi.logForMaterials(t.map(e=>e.materialID)));n.sort((e,t)=>e.endUTC.getTime()-t.endUTC.getTime());let r=[];for(let e=0;e<n.length;e++){let i=n[e];if(i.type===V.AddToQueue||i.type===V.RemoveFromQueue){let a=[...i.material];for(;e+1<n.length&&n[e+1].type===i.type&&t(n[e+1].endUTC,i.endUTC)<10;)a.push(...n[e+1].material),e+=1;a.length===i.material.length?r.push(i):r.push({...i,material:a})}else r.push(n[e])}return r}function Tp(e){return e.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`})}function Ep(e){let t=e.job.completed?.[e.procIdx]?.[e.pathIdx];return t===void 0?null:(0,Y.jsxs)(`div`,{children:[`Completed: `,t]})}function Dp(e){let t=r(G),n=e=>e.map(e=>Za(e,t.loadStationNames)).join(`, `);return(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(`dl`,{children:[(0,Y.jsx)(`dt`,{children:`Job ID`}),(0,Y.jsx)(`dd`,{children:e.job.unique}),(0,Y.jsx)(`dt`,{children:`Time`}),(0,Y.jsxs)(`dd`,{children:[Tp(e.job.routeStartUTC),` to `,Tp(e.job.routeEndUTC)]}),e.job.cycles?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{children:`Quantity`}),(0,Y.jsx)(`dd`,{children:e.job.cycles})]}):void 0,e.job.comment!==void 0&&e.job.comment!==``?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{children:`Comment`}),(0,Y.jsx)(`dd`,{children:e.job.comment})]}):void 0,e.job.assignedWorkorders&&e.job.assignedWorkorders.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{children:`Workorders`}),(0,Y.jsx)(`dd`,{children:e.job.assignedWorkorders.join(`, `)})]}):void 0,e.job.procsAndPaths.map((t,r)=>(0,Y.jsx)(K.Fragment,{children:t.paths.map((i,a)=>(0,Y.jsxs)(K.Fragment,{children:[(0,Y.jsxs)(`dt`,{children:[`Process `,r+1,t.paths.length>1?`, Path `+(a+1).toString():void 0]}),(0,Y.jsxs)(`dd`,{children:[(0,Y.jsx)(Ep,{job:e.job,procIdx:r,pathIdx:a}),(0,Y.jsxs)(`div`,{children:[`Estimated Start: `,Tp(i.simulatedStartingUTC)]}),(0,Y.jsxs)(`div`,{children:[`Pallets: `,(i.palletNums??[]).map(e=>e.toString()).join(`,`)]}),i.fixture?(0,Y.jsxs)(`div`,{children:[`Fixture: `,i.fixture,` `,i.face===void 0?void 0:`, Face: `+i.face.toString()]}):void 0,i.inputQueue?(0,Y.jsxs)(`div`,{children:[`Input Queue: `,i.inputQueue]}):void 0,i.casting?(0,Y.jsxs)(`div`,{children:[`Raw Material: `,i.casting]}):void 0,t.basketLoadStations&&t.basketLoadStations.length>0&&t.expectedBasketLoadTime?(0,Y.jsxs)(`div`,{children:[`Basket Load Stations: `,n(t.basketLoadStations),` |`,` `,J(t.expectedBasketLoadTime).toFixed(1),` mins`,i.partsPerPallet>1?` per piece`:``]}):void 0,(0,Y.jsxs)(`div`,{children:[`Load Stations: `,n(i.load),` |`,` `,J(i.expectedLoadTime).toFixed(1),` mins`,i.partsPerPallet>1?` per piece`:``]}),i.stops.map((e,t)=>(0,Y.jsx)(K.Fragment,{children:(0,Y.jsxs)(`div`,{children:[e.stationGroup,`: `,(e.stationNums??[]).join(`,`),` | Program:`,` `,e.program,e.programRevision?` rev`+e.programRevision.toString():void 0,` `,`|`,` `,(J(e.expectedCycleTime)/i.partsPerPallet).toFixed(1),` `,`mins`,i.partsPerPallet>1?` per piece`:``]})},t)),(0,Y.jsxs)(`div`,{children:[`Unload Stations: `,n(i.unload),` |`,` `,J(i.expectedUnloadTime).toFixed(1),` mins`,i.partsPerPallet>1?` per piece`:``]}),t.basketUnloadStations&&t.basketUnloadStations.length>0&&t.expectedBasketUnloadTime?(0,Y.jsxs)(`div`,{children:[`Basket Unload Stations: `,n(t.basketUnloadStations),` |`,` `,J(t.expectedBasketUnloadTime).toFixed(1),` mins`,i.partsPerPallet>1?` per piece`:``]}):void 0,i.outputQueue?(0,Y.jsxs)(`div`,{children:[`Output Queue: `,i.outputQueue]}):void 0,i.inspections&&i.inspections.length>0?(0,Y.jsxs)(`div`,{children:[`Inspections: `,i.inspections.map(e=>e.inspectionType).join(`,`)]}):void 0]})]},a))},r))]})})}function Op(e){let t=eo(r(G).basketName);return e.inProcMat!==null&&e.inProcMat.location.type===H.OnPallet?(0,Y.jsxs)(`span`,{children:[`On pallet `,e.inProcMat.location.palletNum??``]}):e.inProcMat!==null&&e.inProcMat.location.type===H.InQueue?(0,Y.jsxs)(`span`,{children:[`In queue `,e.inProcMat.location.currentQueue??``]}):e.inProcMat!==null&&e.inProcMat.location.type===H.InBasket?(0,Y.jsxs)(`span`,{children:[`In `,t,` `,e.inProcMat.location.basketId??``]}):e.matSummary?.completed_last_proc_machining?(0,Y.jsx)(`span`,{children:`Completed`}):e.matSummary!==null&&!e.matSummary.startedProcess1?(0,Y.jsx)(`span`,{children:`Not yet started`}):(0,Y.jsx)(`span`,{})}function kp(e){let t=r(q).material,n=j(X),i=D.of(e.matIdsForJob.get(e.unique)??Fn.empty()).collect(t=>e.matsFromEvents.get(t)).toRArray();if(i===null||i.length===0)return(0,Y.jsx)(`div`,{});let a=D.of(t).toHashMap(e=>[e.materialID,e],(e,t)=>e),s=D.of(i).some(e=>e.workorderId!==void 0&&e.workorderId!==``&&e.workorderId!==e.serial);return(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(he,{size:`small`,style:{width:e.fullWidth?`100%`:`auto`},children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[s?(0,Y.jsx)(w,{children:`Workorder`}):void 0,(0,Y.jsx)(w,{children:`Serial`}),(0,Y.jsx)(w,{children:`Status`}),(0,Y.jsx)(w,{padding:`checkbox`})]})}),(0,Y.jsx)(ae,{children:i.map(t=>(0,Y.jsxs)(o,{children:[s?(0,Y.jsx)(w,{children:t.workorderId??``}):void 0,(0,Y.jsx)(w,{children:t.serial??``}),(0,Y.jsx)(w,{children:(0,Y.jsx)(Op,{matSummary:e.matsFromEvents.get(t.materialID)??null,inProcMat:a.get(t.materialID)??null})}),(0,Y.jsx)(w,{padding:`checkbox`,children:(0,Y.jsx)(C,{onClick:()=>n({type:`MatSummary`,summary:t}),size:`large`,children:(0,Y.jsx)(Le,{fontSize:`inherit`})})})]},t.materialID))})]})})}function Ap(e){let t=r(od),n=r(e.checkAnalysisMonth&&t.type===`SpecificMonth`?Hl:Bl);return(0,Y.jsx)(`div`,{style:{display:`flex`,justifyContent:`space-evenly`},children:e.job===null?void 0:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Dp,{job:e.job}),(0,Y.jsx)(kp,{unique:e.job.unique,fullWidth:!1,matsFromEvents:n.matsById,matIdsForJob:n.matIdsForJob})]})})}function jp(e){return typeof e==`object`&&!!e&&`mat`in e}function Mp(e){return typeof e==`number`?e:null}var Np=(0,K.memo)(function(e){let[t,n]=(0,K.useState)(void 0),i=j(ed),o=r(ga),s=(0,K.useMemo)(()=>e.matIds.slice(),[e.matIds]),c=sn(a(nt),a(p,{coordinateGetter:tr}));return(0,Y.jsx)(cr,{sensors:c,collisionDetection:v,onDragStart:({active:e})=>n(jp(e.data.current)?e.data.current.mat:void 0),onDragCancel:()=>n(void 0),onDragEnd:({active:t,over:r})=>{let a=Mp(t.id),s=r?Mp(r.id):null,c=jp(t.data.current)?t.data.current.mat:null;r&&t.id!==r.id&&a!==null&&s!==null&&c!==null&&Hd(c,e.queueName)&&i({queue:e.queueName,matId:a,newIdx:e.matIds.indexOf(s),operator:o}).catch(console.error),n(void 0)},children:(0,Y.jsxs)(Qt,{items:s,strategy:e.direction===`vertical`?jt:Ct,children:[e.children,(0,Y.jsx)(Qe,{children:t===void 0?void 0:e.renderDragOverlay(t)})]})})}),Pp=e(zt(),1);function Fp(e){let t=(0,K.useRef)(null),n=(0,K.useCallback)(n=>{n&&(0,Pp.default)(n,e.text,{format:`CODE128`}),t.current=n},[e.text]);return(0,K.useEffect)(()=>{t.current&&(0,Pp.default)(t.current,e.text,{format:`CODE128`,fontSize:30})},[e.text]),(0,Y.jsx)(`svg`,{ref:n})}function Ip(){let e=r(va);return new Date(e*1e3).toLocaleString(void 0,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`})}function Lp(e){return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{style:{marginTop:`4em`,display:`flex`,justifyContent:`center`},children:(0,Y.jsx)(`h2`,{children:`SeedTactic: FMS Insight`})}),(0,Y.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`},children:(0,Y.jsx)(`p`,{style:{fontSize:`x-large`},children:(0,Y.jsx)(Ip,{})})}),(0,Y.jsxs)(`div`,{style:{marginTop:`2em`,display:`flex`,justifyContent:`space-around`},children:[(0,Y.jsx)(Fp,{text:e.materialName??e.partName}),e.count>=2?(0,Y.jsx)(Fp,{text:e.count.toString()}):void 0]}),e.serial1&&e.serial1!==``?(0,Y.jsxs)(`div`,{style:{marginTop:`2em`,display:`flex`,justifyContent:`space-around`},children:[(0,Y.jsx)(Fp,{text:e.serial1}),e.serial2&&e.serial2!==``?(0,Y.jsx)(Fp,{text:e.serial2||``}):void 0]}):void 0,(0,Y.jsx)(`div`,{style:{marginTop:`2em`,marginLeft:`4em`,marginRight:`4em`,marginBottom:`9em`},children:e.uniq===null||e.uniq===``?(0,Y.jsx)(`p`,{style:{fontSize:`x-large`},children:`Not currently assigned to any jobs`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{style:{fontSize:`x-large`},children:`Assigned To`}),(0,Y.jsxs)(`div`,{style:{marginTop:`1em`,marginLeft:`2em`,display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(Fp,{text:e.partName}),(0,Y.jsxs)(`h3`,{style:{marginLeft:`4em`},children:[`assigned to `,e.uniq,e.jobCycles&&e.jobCycles>0?` (`+e.jobCycles.toString()+` scheduled)`:``]})]})]})}),e.note?(0,Y.jsx)(`div`,{style:{marginBottom:`2em`},children:(0,Y.jsx)(`p`,{style:{fontSize:`xxx-large`,textAlign:`center`},children:e.note})}):void 0,(0,Y.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`},children:e.operator?(0,Y.jsx)(`p`,{style:{fontSize:`x-large`},children:e.operator}):void 0})]})}function Rp(e){let t=r(q).jobs,n=(0,K.useMemo)(()=>D.of(e.material||[]).filter(e=>e.jobUnique!==null&&e.jobUnique!==void 0&&e.jobUnique!==``).groupBy(e=>e.jobUnique).map(([e,n])=>[e,{cycles:t[e]?.cycles??0,length:n.length,part:n[0]?.partName??``,comment:t[e]?.comment,serial1:n[0]?.serial,serial2:n[n.length-1]?.serial}]).toSortedArray(([,e])=>e.part),[e.material,t]);return!e.material||e.material.length===0?(0,Y.jsx)(`div`,{}):n.length===0?(0,Y.jsx)(Lp,{partName:e.material[0].partName,materialName:e.materialName,count:e.material.length,uniq:null,note:null,operator:e.operator,serial1:e.material[0].serial,serial2:e.material[e.material.length-1]?.serial}):(0,Y.jsx)(`div`,{children:n.map(([t,r],i)=>(0,Y.jsxs)(K.Fragment,{children:[(0,Y.jsx)(Lp,{partName:r.part,materialName:e.materialName,count:r.length,uniq:t,jobCycles:r.cycles,note:r.comment,operator:e.operator,serial1:r.serial1,serial2:r.serial2}),i<n.length-1?(0,Y.jsx)(`div`,{style:{pageBreakAfter:`always`}}):void 0]},i))})}function zp(e){let t=(0,K.useMemo)(()=>D.of(e.material||[]).filter(e=>e.jobUnique!==null&&e.jobUnique!==void 0&&e.jobUnique!==``).groupBy(e=>e.jobUnique).map(([e,t])=>[e,{length:t.length,part:t[0]?.partName??``}]).toSortedArray(([,e])=>e.part),[e.material]),n=r(q).jobs,i=(0,K.useMemo)(()=>D.of(e.material||[]).collect(e=>e.jobUnique?n[e.jobUnique]?.comment:void 0).distinct().toSortedArray(e=>e),[e.material,n]);return!e.material||e.material.length===0?(0,Y.jsx)(`div`,{}):(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{style:{marginTop:`4em`,display:`flex`,justifyContent:`center`},children:(0,Y.jsx)(`h2`,{children:`SeedTactic: FMS Insight`})}),(0,Y.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`},children:(0,Y.jsx)(`p`,{style:{fontSize:`x-large`},children:(0,Y.jsx)(Ip,{})})}),(0,Y.jsxs)(`div`,{style:{marginTop:`2em`,display:`flex`,justifyContent:`space-around`},children:[(0,Y.jsx)(Fp,{text:e.materialName??e.material[0].partName}),e.material.length>=2?(0,Y.jsx)(Fp,{text:e.material.length.toString()}):void 0]}),e.material[0].serial&&e.material[0].serial!==``?(0,Y.jsxs)(`div`,{style:{marginTop:`2em`,display:`flex`,justifyContent:`space-around`},children:[(0,Y.jsx)(Fp,{text:e.material[0].serial}),e.material.length>=2&&e.material[e.material.length-1].serial&&e.material[e.material.length-1].serial!==``?(0,Y.jsx)(Fp,{text:e.material[e.material.length-1].serial||``}):void 0]}):void 0,(0,Y.jsx)(`div`,{style:{marginTop:`2em`,marginLeft:`4em`,marginRight:`4em`,marginBottom:`9em`},children:t.length===0?(0,Y.jsx)(`p`,{style:{fontSize:`x-large`},children:`Not currently assigned to any jobs`}):e.materialName?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{style:{fontSize:`x-large`},children:`Assigned To`}),t.map(([e,t],n)=>(0,Y.jsxs)(`div`,{style:{marginTop:`1em`,marginLeft:`2em`,display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(Fp,{text:t.part}),(0,Y.jsxs)(`h3`,{style:{marginLeft:`4em`},children:[`x`,t.length]}),(0,Y.jsxs)(`h3`,{style:{marginLeft:`4em`},children:[`assigned to `,e]})]},n))]}):t.length===1?(0,Y.jsx)(`div`,{style:{marginTop:`1em`,display:`flex`,justifyContent:`space-around`},children:(0,Y.jsxs)(`p`,{style:{fontSize:`x-large`},children:[(0,Y.jsxs)(`span`,{children:[`Assigned to `,t[0][0]]}),t[0][1].length>1?(0,Y.jsxs)(`span`,{style:{marginLeft:`1em`},children:[`x`,t[0][1].length]}):void 0]})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{style:{fontSize:`x-large`},children:`Assigned To`}),t.map(([e,t],n)=>(0,Y.jsxs)(`h3`,{style:{marginTop:`1em`,marginLeft:`2em`},children:[(0,Y.jsx)(`span`,{children:e}),t.length>1?(0,Y.jsxs)(`span`,{style:{marginLeft:`1em`},children:[`x`,t.length]}):void 0]},n))]})}),i.length>0?(0,Y.jsx)(`div`,{style:{marginBottom:`2em`},children:i.map((e,t)=>(0,Y.jsx)(`p`,{style:{fontSize:`xxx-large`,textAlign:`center`},children:e},t))}):void 0,(0,Y.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`},children:e.operator?(0,Y.jsx)(`p`,{style:{fontSize:`x-large`},children:e.operator}):void 0})]})}function Bp(e){return e.oneJobPerPage?(0,Y.jsx)(Rp,{...e}):(0,Y.jsx)(zp,{...e})}function Vp({mat:e,materialName:t,operator:n}){let r=(0,K.useRef)(null),i=Kt({contentRef:r,ignoreGlobalStyles:!0});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{color:`primary`,onClick:()=>i(),children:`Print Label`}),(0,Y.jsx)(`div`,{style:{display:`none`},children:(0,Y.jsx)(`div`,{ref:r,children:(0,Y.jsx)(Bp,{materialName:t,material:Array.isArray(e)?e:[e],oneJobPerPage:!1,operator:n})})})]})}function Hp(){let e=r(G),t=r(Xs),n=r(tc),[i,a,o]=xc();return!e.usingLabelPrinterForSerials||t===null||t.materialID<0?null:e.useClientPrinterForLabels?n===null?null:(0,Y.jsx)(Vp,{mat:n}):(0,Y.jsx)(z,{color:`primary`,disabled:a||o,onClick:()=>i({materialId:t.materialID,proc:n?.process??0}),children:o?`Printed`:`Print Label`})}function Up({suspended:e,title:t=``,children:n}){return(0,Y.jsx)(S,{title:e?`System alarm`:t,describeChild:!0,children:(0,Y.jsx)(`span`,{style:{display:`inline-flex`},tabIndex:e?0:void 0,children:n})})}var Wp=F(null),Gp=F(null);function Kp(){let[e,t]=A(Gp),n=r(q),i=(0,K.useRef)(null),a=(0,K.useRef)(!1),o=Kt({contentRef:i,onAfterPrint:()=>t(null),ignoreGlobalStyles:!0}),s=e?n.material.filter(t=>e.materialIds.has(t.materialID)):null;return s?.length!==e?.materialIds.size&&(s=null),(0,K.useEffect)(()=>{e===null?a.current&&=!1:a.current||s===null||(o(),a.current=!0)},[e,s,a,o]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(I,{open:e!==null,children:[(0,Y.jsx)($n,{children:`Waiting for Material Assignment`}),(0,Y.jsx)(M,{children:s===null?e===null?(0,Y.jsx)(`div`,{}):(0,Y.jsxs)(E,{direction:`column`,spacing:2,sx:{mt:`0.5em`,mb:`0.5em`},children:[(0,Y.jsx)(pn,{color:`secondary`}),(0,Y.jsx)(`div`,{children:`Waiting for material assignment. This could take a while if a download is currently in progress.`})]}):(0,Y.jsx)(`div`,{children:`Printing...`})}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{color:`primary`,onClick:()=>t(null),children:`Cancel`})})]}),(0,Y.jsx)(`div`,{style:{display:`none`},children:(0,Y.jsx)(`div`,{ref:i,children:(0,Y.jsx)(Bp,{materialName:e?.selectedCasting,material:s,operator:e?.operator,oneJobPerPage:!0})})})]})}function qp({casting:e,queue:t}){let n=r(q),i=(0,K.useMemo)(()=>yp(n.jobs,n.material,t).filter(t=>t.rawMatName===e),[n.jobs,n.material,e,t]);return i.length===0?null:(0,Y.jsxs)(he,{size:`small`,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Job`}),(0,Y.jsx)(w,{align:`right`,children:`Plan`}),(0,Y.jsx)(w,{align:`right`,children:`Remaining`}),(0,Y.jsx)(w,{align:`right`,children:`Assigned`}),(0,Y.jsx)(w,{align:`right`,children:`Required`}),(0,Y.jsx)(w,{align:`right`,children:`Available`})]})}),(0,Y.jsxs)(ae,{children:[i.map((e,t)=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:e.job.unique}),(0,Y.jsx)(w,{align:`right`,children:e.job.cycles}),(0,Y.jsx)(w,{align:`right`,children:e.remainingToStart}),(0,Y.jsx)(w,{align:`right`,children:e.assignedRaw}),(0,Y.jsx)(w,{align:`right`,children:Math.max(e.remainingToStart-e.assignedRaw,0)}),(0,Y.jsx)(w,{align:`right`,children:e.availableUnassigned})]},t)),i.length>=2?(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Total`}),(0,Y.jsx)(w,{align:`right`,children:D.of(i).sumBy(e=>e.job.cycles)}),(0,Y.jsx)(w,{align:`right`,children:D.of(i).sumBy(e=>e.remainingToStart)}),(0,Y.jsx)(w,{align:`right`,children:D.of(i).sumBy(e=>e.assignedRaw)}),(0,Y.jsx)(w,{align:`right`,children:D.of(i).sumBy(e=>Math.max(e.remainingToStart-e.assignedRaw,0))}),(0,Y.jsx)(w,{align:`right`,children:D.of(i).sumBy(e=>e.availableUnassigned)})]}):void 0]})]})}var Jp=(0,K.memo)(function(){let[e,t]=A(Wp),n=r(ga),i=r(G),a=i.usingLabelPrinterForSerials&&i.useClientPrinterForLabels,[o]=Dc(),s=j(Gp),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(!1),g=r(q),ee=r(Zc),te=As(g,{}),ne=(0,K.useMemo)(()=>D.ofObject(g.jobs).flatMap(([,e])=>e.procsAndPaths[0].paths).filter(e=>e.casting!==void 0&&e.casting!==``).map(e=>({casting:e.casting??``,cnt:1})).concat(D.of(ee).map(e=>({casting:e,cnt:0}))).buildOrderedMap(e=>e.casting,(e,t)=>e===void 0?t.cnt:e+t.cnt).toAscLazySeq(),[g.jobs,ee]);function v(){t(null),l(null),p(null),h(!1),d(null)}function y(){te.length>0||(e!==null&&c!==null&&u!==null&&!isNaN(u)&&u>0&&o({casting:c,quantity:u,queue:e,workorder:null,operator:i.requireOperatorNamePromptWhenAddingMaterial?f:n}).catch(console.log),v())}function b(){te.length>0||e!==null&&c!==null&&u!==null&&!isNaN(u)&&(h(!0),o({casting:c,quantity:u,queue:e,operator:n,workorder:null,onNewMaterial:e=>{s({selectedCasting:c,operator:i.requireOperatorNamePromptWhenAddingMaterial?f:n,materialIds:new Set(e.map(e=>e.materialID))}),v()},onError:()=>{v()}}).catch(()=>{}))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(I,{open:e!==null,onClose:()=>v(),maxWidth:`md`,children:[(0,Y.jsx)($n,{children:`Add Raw Material`}),(0,Y.jsx)(M,{children:(0,Y.jsxs)(E,{direction:`column`,spacing:2,sx:{mt:`0.5em`},children:[(0,Y.jsx)(_,{style:{minWidth:`15em`},value:c||``,onChange:e=>l(e.target.value),select:!0,fullWidth:!0,label:`Raw Material`,slotProps:{select:{renderValue:c===null?void 0:()=>(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(`div`,{style:{marginRight:`0.5em`},children:(0,Y.jsx)($,{part:c,size:25})}),(0,Y.jsx)(`div`,{children:c})]})}},children:ne.map(([e,t],n)=>(0,Y.jsxs)(L,{value:e,children:[(0,Y.jsx)(mt,{children:(0,Y.jsx)($,{part:e})}),(0,Y.jsx)(_t,{primary:e,slotProps:{primary:{variant:`h4`}},secondary:t===0?`Not used by any current jobs`:`Used by ${t} current job${t>1?`s`:``}`})]},n))}),(0,Y.jsx)(_,{fullWidth:!0,type:`number`,label:`Quantity`,disabled:c===null,slotProps:{htmlInput:{min:`1`}},value:u===null||isNaN(u)||u<=0?``:u,onChange:e=>d(parseInt(e.target.value))}),i.requireOperatorNamePromptWhenAddingMaterial?(0,Y.jsx)(_,{fullWidth:!0,label:`Operator`,value:f||``,onChange:e=>p(e.target.value)}):void 0,c!==null&&e!==null?(0,Y.jsx)(qp,{casting:c,queue:e}):void 0]})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(Up,{suspended:te.length>0,children:a?(0,Y.jsxs)(z,{color:`primary`,disabled:te.length>0||m||c===null||u===null||isNaN(u)||i.requireOperatorNamePromptWhenAddingMaterial&&(f===null||f===``),onClick:b,children:[m?(0,Y.jsx)(pn,{size:10}):void 0,`Add `,u!==null&&!isNaN(u)?u.toString()+` `:``,`to`,` `,e]}):(0,Y.jsxs)(z,{color:`primary`,disabled:te.length>0||c===null||u===null||isNaN(u)||i.requireOperatorNamePromptWhenAddingMaterial&&(f===null||f===``),onClick:y,children:[`Add `,u!==null&&!isNaN(u)?u.toString()+` `:``,`to`,` `,e]})}),(0,Y.jsx)(z,{color:`primary`,disabled:m&&a,onClick:v,children:`Cancel`})]})]}),(0,Y.jsx)(Kp,{})]})}),Yp=(0,K.memo)(function(e){let t=r(G),n=r(q),i=n.jobs,a=js(n,e.material??[]),[o,s]=xc(),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)([]),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(NaN),[g,ee]=(0,K.useState)(void 0);(0,K.useEffect)(()=>{if(e.material===null)return;let t=!0;return(async()=>{if(e.material!==null){l(!0);try{let n=await wp(e.material);if(t){d(n);let e;for(let t of n)t.type===V.AddToQueue&&t.details?.operator!==void 0&&(e=t.details.operator);ee(e)}}catch(e){console.error(e)}finally{l(!1)}}})().catch(console.error),()=>{t=!1}},[e.material]);let te=(0,K.useMemo)(()=>{if(!e.material||e.material.length===0)return;let t=e.material[0].jobUnique;if(t&&t!==``&&i[t])return D.of(i[t].procsAndPaths[0].paths).filter(e=>e.casting!==void 0&&e.casting!==``).head()?.casting},[e.material,i]);function ne(){e.closeDialog(),p(!1),h(NaN),l(!1),d([])}function v(){a.length>0||(f?isNaN(m)||(l(!0),Bi.bulkRemoveMaterialFromQueues(e.operator,D.of(e.material||[]).take(m).map(e=>e.materialID).toRArray()).catch(console.error).finally(ne)):p(!0))}let y=e.material?.[0];return(0,Y.jsxs)(I,{open:e.material!==null,onClose:ne,maxWidth:`md`,children:[(0,Y.jsx)($n,{children:y&&e.material&&e.material.length>0?(0,Y.jsx)(uf,{partName:y.partName,subtitle:e.material.length.toString()+(y.jobUnique&&y.jobUnique!==``?` assigned to `+y.jobUnique:` unassigned`)}):`Material`}),(0,Y.jsxs)(M,{children:[c?(0,Y.jsx)(pn,{color:`secondary`}):(0,Y.jsx)(Ks,{entries:u,copyToClipboard:!0}),f&&e.material?(0,Y.jsx)(`div`,{style:{marginTop:`1em`},children:(0,Y.jsx)(_,{type:`number`,variant:`outlined`,fullWidth:!0,label:`Quantity to Remove`,slotProps:{htmlInput:{min:`1`,max:e.material.length.toString()}},value:isNaN(m)?``:m,onChange:e=>h(parseInt(e.target.value))})}):void 0]}),(0,Y.jsxs)(N,{children:[e.material&&e.material.length>0&&t.usingLabelPrinterForSerials?t.useClientPrinterForLabels?(0,Y.jsx)(Vp,{mat:e.material||[],materialName:te,operator:g}):(0,Y.jsx)(z,{color:`primary`,disabled:s,onClick:()=>e.material&&e.material.length>0?o({materialId:e.material[0].materialID,proc:0}):void 0,children:`Print Label`}):void 0,(0,Y.jsx)(Up,{suspended:a.length>0,children:(0,Y.jsx)(z,{color:`primary`,onClick:v,disabled:a.length>0||c||f&&isNaN(m),children:c&&f?`Removing...`:f&&!isNaN(m)?`Remove ${m} material`:`Remove Material`})}),(0,Y.jsx)(z,{color:`primary`,onClick:ne,children:`Close`})]})]})}),Xp=(0,K.memo)(function(){let[e,t]=(0,K.useState)(null),[n,r]=(0,K.useState)(!1),i=j(X);function a(){r(!1),t(null)}function o(){e&&e!==``&&(i({type:`ManuallyEnteredSerial`,serial:e}),a())}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{title:`Enter Serial`,children:(0,Y.jsx)(C,{onClick:()=>r(!0),size:`large`,children:(0,Y.jsx)(at,{})})}),(0,Y.jsxs)(I,{open:n,onClose:a,maxWidth:`md`,children:[(0,Y.jsx)($n,{children:`Enter a part's serial`}),(0,Y.jsx)(M,{children:(0,Y.jsx)(`div`,{style:{minWidth:`20em`},children:(0,Y.jsx)(_,{sx:{mt:`5px`},label:e===null||e===``?`Serial`:`Serial (press enter)`,value:e??``,fullWidth:!0,autoFocus:!0,onChange:e=>t(e.target.value),onKeyDown:t=>{t.key===`Enter`&&e&&e!==``&&(t.preventDefault(),o())}})})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(z,{onClick:o,disabled:e===null||e===``,color:`secondary`,children:`Open`}),(0,Y.jsx)(z,{onClick:a,color:`secondary`,children:`Cancel`})]})]})]})}),Zp=F(null),Qp=(0,K.memo)(function(){let[e,t]=A(Zp),n=j(X),[r,i]=(0,K.useState)(void 0);function a(){r&&r!==``&&e!==null&&(n({type:`AddMatWithEnteredSerial`,serial:r,toQueue:e}),t(null),i(void 0))}function o(){t(null),i(void 0)}return(0,Y.jsxs)(I,{open:e!==null,onClose:o,maxWidth:`md`,children:[(0,Y.jsxs)($n,{children:[`Lookup Material To Add To `,e]}),(0,Y.jsx)(M,{children:(0,Y.jsx)(_,{label:`Serial`,style:{marginTop:`0.5em`},autoFocus:!0,fullWidth:!0,value:r||``,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r&&r!==``&&(e.preventDefault(),a())}})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(z,{onClick:a,color:`secondary`,children:`Lookup Serial`}),(0,Y.jsx)(z,{onClick:o,color:`primary`,children:`Cancel`})]})]})});function $p(e){let t=r(Xs),n=r(tc),i=r(Ys);return!(!Bd(n)||n?.location.type===H.InQueue&&n.location.currentQueue!==void 0&&e.includes(n.location.currentQueue)||t===null&&!i)}var em=_r(St,{shouldForwardProp:e=>e.toString()[0]!==`$`})(({theme:e,$expandedOpen:t})=>({transform:t?`rotate(0deg)`:`rotate(-90deg)`,transition:e.transitions.create(`transform`,{duration:e.transitions.duration.shortest})}));function tm({newMaterialTy:e,setNewMaterialTy:t,castings:r,indent:i}){return(0,Y.jsx)(Wt,{sx:i?e=>({pl:e.spacing(4)}):void 0,children:r.map(r=>(0,Y.jsx)(xt,{children:(0,Y.jsxs)(n,{selected:e?.kind===`RawMat`&&e?.rawMatName===r.casting,onClick:()=>t({kind:`RawMat`,rawMatName:r.casting}),children:[(0,Y.jsx)(mt,{children:(0,Y.jsx)($,{part:r.casting})}),(0,Y.jsx)(_t,{primary:r.casting,secondary:r.message??void 0,slotProps:{primary:{variant:`h4`}}})]})},r.casting))})}function nm({newMaterialTy:e,setNewMaterialTy:t,curCollapse:r,setCurCollapse:i,indent:a,jobs:o}){return(0,Y.jsx)(Wt,{sx:a?e=>({pl:e.spacing(4)}):void 0,children:o.map((o,s)=>o.machinedProcs.length===1?(0,Y.jsx)(`div`,{children:(0,Y.jsx)(xt,{children:(0,Y.jsxs)(n,{alignItems:`flex-start`,selected:e?.kind===`JobAndProc`&&e?.jobUnique===o.jobUnique&&e?.last_proc===o.machinedProcs[0].lastProc,onClick:()=>t({kind:`JobAndProc`,jobUnique:o.jobUnique,last_proc:o.machinedProcs[0].lastProc,workorder:o.workorder}),children:[o.job?(0,Y.jsx)(mt,{children:(0,Y.jsx)($,{part:o.job.partName})}):void 0,(0,Y.jsx)(_t,{primary:(o.job?.partName??``)+` (`+o.jobUnique+`)`,slotProps:{primary:{variant:`h4`}},secondary:(0,Y.jsxs)(b,{variant:`body2`,children:[o.machinedProcs[0].lastProc===0?`Raw Material`:`Last machined process `+o.machinedProcs[0].lastProc.toString(),`, `,o.job?.routeStartUTC.toLocaleDateString()??``,`,`,` `,o.machinedProcs[0].details]})})]})})},s):(0,Y.jsxs)(K.Fragment,{children:[(0,Y.jsx)(xt,{children:(0,Y.jsxs)(n,{onClick:()=>{e&&t(null),i(r&&r.kind===`Job`&&r.unique===o.jobUnique?null:{kind:`Job`,unique:o.jobUnique})},children:[(0,Y.jsx)(mt,{children:(0,Y.jsx)(em,{$expandedOpen:r!==null&&r.kind===`Job`&&r.unique===o.jobUnique})}),o.job?(0,Y.jsx)(mt,{children:(0,Y.jsx)($,{part:o.job.partName})}):void 0,(0,Y.jsx)(_t,{primary:(o.job?.partName??``)+` (`+o.jobUnique+`)`,slotProps:{primary:{variant:`h4`}},secondary:o.job?.routeStartUTC.toLocaleDateString()})]})}),(0,Y.jsx)(x,{in:r!==null&&r.kind===`Job`&&r.unique===o.jobUnique,timeout:`auto`,children:o.machinedProcs.map((r,i)=>(0,Y.jsx)(`div`,{children:(0,Y.jsx)(xt,{sx:e=>({pl:e.spacing(a?8:4)}),children:(0,Y.jsx)(n,{selected:e?.kind===`JobAndProc`&&e?.jobUnique===o.jobUnique&&e?.last_proc===r.lastProc,onClick:()=>t({kind:`JobAndProc`,jobUnique:o.jobUnique,last_proc:r.lastProc,workorder:o.workorder}),children:(0,Y.jsx)(_t,{primary:r.lastProc===0?`Raw Material`:`Last machined process `+r.lastProc.toString(),secondary:r.details})})})},i))})]},s))})}function rm({newMaterialTy:e,options:t,setNewMaterialTy:r,curCollapse:i,setCurCollapse:a}){return(0,Y.jsxs)(Wt,{children:[(0,Y.jsx)(xt,{children:(0,Y.jsxs)(n,{onClick:()=>{e&&r(null),a(i&&i.kind===`RawMat`?null:{kind:`RawMat`})},children:[(0,Y.jsx)(mt,{children:(0,Y.jsx)(em,{$expandedOpen:i!==null&&i.kind===`RawMat`})}),(0,Y.jsx)(_t,{primary:`Raw Material`})]})}),(0,Y.jsx)(x,{in:i!==null&&i.kind===`RawMat`,timeout:`auto`,children:(0,Y.jsx)(tm,{castings:t.castings,newMaterialTy:e,setNewMaterialTy:r,indent:!0})}),(0,Y.jsx)(xt,{children:(0,Y.jsxs)(n,{onClick:()=>{e&&r(null),a(i&&(i.kind===`AllJobs`||i.kind===`Job`)?null:{kind:`AllJobs`})},children:[(0,Y.jsx)(mt,{children:(0,Y.jsx)(em,{$expandedOpen:i!==null&&(i.kind===`AllJobs`||i.kind===`Job`)})}),(0,Y.jsx)(_t,{primary:`Specify Job`})]})}),(0,Y.jsx)(x,{in:i!==null&&(i.kind===`AllJobs`||i.kind===`Job`),timeout:`auto`,children:(0,Y.jsx)(nm,{newMaterialTy:e,jobs:t.jobs,setNewMaterialTy:r,curCollapse:i,setCurCollapse:a,indent:!0})})]})}function im({newMaterialTy:e,setNewMaterialTy:t,toQueue:n}){let i=r(nc),a=r(Xs),[o,s]=(0,K.useState)(null),c=gp(n);return a||i===null||n===null?null:c.castings.length===0&&c.jobs.length===0?(0,Y.jsxs)(`div`,{children:[`No jobs are currently scheduled for `,n]}):c.jobs.length===0?(0,Y.jsx)(tm,{newMaterialTy:e,setNewMaterialTy:t,castings:c.castings}):c.castings.length===0?(0,Y.jsx)(nm,{jobs:c.jobs,newMaterialTy:e,setNewMaterialTy:t,curCollapse:o,setCurCollapse:s}):(0,Y.jsx)(rm,{options:c,newMaterialTy:e,setNewMaterialTy:t,curCollapse:o,setCurCollapse:s})}function am({selectedQueue:e,setSelectedQueue:t,queueNames:r}){let i=(0,K.useRef)(null);return(0,K.useEffect)(()=>{i.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[i]),(0,Y.jsxs)(`div`,{ref:i,children:[(0,Y.jsx)(`p`,{children:`Select a queue`}),(0,Y.jsx)(Wt,{children:r.map((r,i)=>(0,Y.jsx)(n,{selected:r===e,onClick:()=>t(r),children:r},i))})]})}function om({enteredOperator:e,setEnteredOperator:t}){return r(G).requireOperatorNamePromptWhenAddingMaterial?(0,Y.jsx)(`div`,{style:{marginLeft:`1em`},children:(0,Y.jsx)(_,{fullWidth:!0,label:`Operator`,value:e||``,required:!0,onChange:e=>t(e.target.value)})}):null}function sm({st:e,queueNames:t,setState:n}){return $p(t)?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(nf,{}),t.length>1?(0,Y.jsx)(am,{selectedQueue:e.toQueue,setSelectedQueue:t=>{n({toQueue:t,newMaterialTy:null,enteredOperator:e.enteredOperator})},queueNames:t}):void 0,(0,Y.jsx)(im,{newMaterialTy:e.newMaterialTy,toQueue:t.length>1?e.toQueue:t[0]??null,setNewMaterialTy:t=>n({...e,newMaterialTy:t})}),(0,Y.jsx)(om,{enteredOperator:e.enteredOperator,setEnteredOperator:t=>n({...e,enteredOperator:t})})]}):null}function cm({st:{enteredOperator:e,newMaterialTy:t,toQueue:n},queueNames:i,onClose:a}){let o=r(G),s=r(ga),c=j(X),l=r(nc),u=r(ic),d=r(Xs),f=r(tc),p=r(fc),m=hc(),[h,g]=Tc(),[ee,_]=Ec(),[te,ne]=Dc(),[v,y]=(0,K.useState)(null);if(!$p(i))return null;n===null&&i.length===1&&(n=i[0]);let b=``;if(d!==null){if(p&&p.process>=p.totalNumProcesses)return null;b=` To Run Process `+((p?.process??0)+1).toString()}else t?.kind===`JobAndProc`&&t?.last_proc!==void 0&&(b=` To Run Process `+(t.last_proc+1).toString()),t?.kind===`RawMat`&&t?.rawMatName&&(b=` As `+t.rawMatName);let re=``;!d&&l&&l!==``&&(re=` With Serial `+l);let ie=f?.location.currentQueue??null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Up,{suspended:m.length>0,title:n===null?`Select a queue to add the material to`:o.requireOperatorNamePromptWhenAddingMaterial&&(e===null||e===``)?`Please enter an operator name`:``,children:(0,Y.jsx)(z,{color:`primary`,disabled:m.length>0||n===null||g||_||ne||d===null&&t===null||o.requireOperatorNamePromptWhenAddingMaterial&&(e===null||e===``),onClick:async()=>{if(!(m.length>0)){y(null);try{d?await h({materialId:d.materialID,queue:n??``,queuePosition:-1,operator:e??s}):t&&t.kind===`JobAndProc`&&t.jobUnique?await ee({jobUnique:t.jobUnique,lastCompletedProcess:t.last_proc,serial:l??void 0,workorder:u??t?.workorder,queue:n??``,queuePosition:-1,operator:e??s}):t&&t.kind===`RawMat`&&t.rawMatName&&await te({casting:t.rawMatName,quantity:1,queue:n??``,serials:l?[l]:void 0,workorder:u,operator:e??s}),c(null),a()}catch(e){y(Dd(e))}}},children:n===null?`Add to Queue`:(0,Y.jsxs)(`span`,{children:[ie===null?`Add To`:`Move From ${ie} To`,` `,n,re,b]})})}),v?(0,Y.jsx)(`p`,{role:`alert`,children:v}):null]})}function lm(e,t){let n=t.jobs[e.jobUnique];if(!n)return!1;let r=Ud(e),i=n.procsAndPaths[r.process-1]?.paths[r.path-1];return i?r.process===n.procsAndPaths.length||!!i.outputQueue:!1}function um(){let e=r(G),t=r(tc),n=r(q);if(t===null||t.materialID<0||t.quarantineAfterUnload)return null;let i=e.quarantineQueue?.length?e.quarantineQueue:null,a=D.ofObject(n.jobs).flatMap(([,e])=>e.procsAndPaths).flatMap(e=>e.paths).flatMap(e=>{let t=[];return e.inputQueue!==void 0&&t.push(e.inputQueue),e.outputQueue!==void 0&&t.push(e.outputQueue),t}).concat(D.ofObject(n.queues).filter(([,e])=>e.role===oi.RawMaterial||e.role===oi.InProcessTransfer).map(([e])=>e)).toRSet(e=>e),o=D.ofObject(n.queues).filter(([e])=>!a.has(e)).toRSet(([e])=>e);if(Rd(t)&&t.location.type===H.InQueue&&t.location.currentQueue&&o.has(t.location.currentQueue))return{type:`Remove`,material:t,quarantineQueueDestination:null,canRemoveFromQueues:!1};let s=null;if(Id(t)){if(!lm(t,n))return null;s=`SignalForScrap`}else if(Ld(t)){if(t.location.currentQueue===void 0||o.has(t.location.currentQueue))return null;s=`Scrap`}return s?{type:s,material:t,quarantineQueueDestination:i,canRemoveFromQueues:t.location.type===H.InQueue&&t.location.currentQueue!==void 0&&!o.has(t.location.currentQueue)&&Rd(t)}:null}function dm({material:e,removeFromQueues:t,removing:n}){let[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),c=j(X),l=js(r(q),[e]);async function u(){if(!(l.length>0)){s(null);try{await t(),a(!1),c({type:`MatSummary`,summary:{materialID:e.materialID,partName:e.partName,serial:e.serial}})}catch(e){s(Dd(e))}}}function d(){s(null),a(!0)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Up,{suspended:l.length>0,title:`Remove from the current queue so it can be rescanned`,children:(0,Y.jsx)(z,{color:`primary`,disabled:n||l.length>0,onClick:d,children:`Remove from Queue`})}),(0,Y.jsxs)(I,{open:i,onClose:()=>a(!1),children:[(0,Y.jsx)($n,{children:`Remove Material from Queue`}),(0,Y.jsxs)(M,{children:[(0,Y.jsx)(`p`,{children:`Remove this material from its current queue. Its production history will remain available. You can scan it again to correct its history or assignment and then add it back to a queue.`}),o?(0,Y.jsx)(`p`,{role:`alert`,children:o}):null]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(Up,{suspended:l.length>0,children:(0,Y.jsx)(z,{color:`primary`,disabled:n||l.length>0,onClick:u,children:`Remove from Queue`})}),(0,Y.jsx)(z,{color:`secondary`,disabled:n,onClick:()=>a(!1),children:`Cancel`})]})]})]})}function fm({onClose:e,ignoreOperator:t}){let[n,i]=(0,K.useState)(!1),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(null),p=um(),[m,h]=Sc(),[g,ee]=Cc(),[te,ne]=wc(),v=r(ga),y=t?null:v,b=j(X),re=p===null?null:{material:p.material,materialId:p.material.materialID,operation:p.type===`SignalForScrap`?`DeferredQuarantine`:p.type===`Scrap`?`DirectQuarantine`:`RemoveFromSystem`,destination:p.quarantineQueueDestination,operator:y},ie=d??re,ae=r(q),x=js(ae,re?[re.material]:[]),oe=js(ae,d?[d.material]:[]);function se(){re!==null&&(c(null),o(``),f(re),i(!0))}function ce(){l||(i(!1),f(null))}if(ie===null)return null;let le,ue;switch(ie.operation){case`RemoveFromSystem`:le=`Remove from system`,ue=`Remove`;break;case`DirectQuarantine`:le=ie.destination?`Move to ${ie.destination}`:`Remove from queue and treat as scrap`,ue=ie.destination?`Quarantine`:`Scrap`;break;case`DeferredQuarantine`:le=ie.destination?`The current automated operation will continue. When the material leaves automation control, move it to ${ie.destination}`:`The current automated operation will continue. When the material leaves automation control, remove it from normal production flow as scrap`,ue=ie.destination?`Signal for quarantine`:`Scrap`}async function de(){if(!(d===null||oe.length>0)){u(!0),c(null);try{switch(d.operation){case`DeferredQuarantine`:await g(d.materialId,d.operator,a);break;case`DirectQuarantine`:await te(d.materialId,d.operator,a);break;case`RemoveFromSystem`:await m(d.materialId,d.operator)}i(!1),f(null),o(``),d.operation===`RemoveFromSystem`?b({type:`MatSummary`,summary:{materialID:d.materialId,partName:d.material.partName,serial:d.material.serial}}):(b(null),e?.())}catch(e){c(Dd(e))}finally{u(!1)}}}let S=l||(ie.operation===`DeferredQuarantine`?ee:ie.operation===`DirectQuarantine`?ne:h),fe=p?.canRemoveFromQueues===!0?()=>m(p.material.materialID,y):null;return(0,Y.jsxs)(Y.Fragment,{children:[p?(0,Y.jsx)(Up,{suspended:x.length>0,title:le,children:(0,Y.jsx)(z,{color:`primary`,disabled:S||x.length>0,onClick:se,children:ue})}):null,fe&&p?(0,Y.jsx)(dm,{material:p.material,removeFromQueues:fe,removing:h}):null,(0,Y.jsxs)(I,{open:n&&d!==null,onClose:ce,children:[(0,Y.jsx)($n,{children:`Quarantine Material`}),(0,Y.jsxs)(M,{children:[(0,Y.jsx)(`p`,{children:le}),(0,Y.jsx)(_,{label:`Reason`,value:a,onChange:e=>o(e.target.value),fullWidth:!0,autoFocus:!0,multiline:!0}),s?(0,Y.jsx)(`p`,{role:`alert`,children:s}):null]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(Up,{suspended:oe.length>0,children:(0,Y.jsx)(z,{color:`primary`,disabled:S||oe.length>0,onClick:de,children:ue})}),(0,Y.jsx)(z,{color:`secondary`,disabled:S,onClick:ce,children:`Cancel`})]})]})]})}function pm({onClose:e,ignoreOperator:t=!1}){let n=r(tc),i=r(q),a=r(ga),o=j(X),[s,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(null),ee=n?.action.loadCancellationId??null,te=n===null||ee===null||!Fd(n)?null:{material:n,cancellationId:ee,group:D.of(i.material).filter(e=>e.action.loadCancellationId===ee).toRArray()};if(te===null&&h===null)return null;let ne=js(i,te?.group??[]),v=js(i,h?.group??[]);async function y(){if(!(h===null||v.length>0)){f(!0),m(null);try{await Bi.cancelLoad(h.material.materialID,t?null:a,new ki({expectedLoadCancellationId:h.cancellationId,reason:l||void 0})),c(!1),g(null),o(null),e?.()}catch(e){m(Dd(e))}finally{f(!1)}}}return(0,Y.jsxs)(Y.Fragment,{children:[te?(0,Y.jsx)(Up,{suspended:ne.length>0,title:`Cancel the displayed load instruction`,children:(0,Y.jsx)(z,{color:`primary`,disabled:d||ne.length>0,onClick:()=>{g(te),u(``),m(null),c(!0)},children:`Cancel Load`})}):null,(0,Y.jsxs)(I,{open:s&&h!==null,onClose:()=>c(!1),children:[(0,Y.jsx)($n,{children:`Cancel Load`}),(0,Y.jsxs)(M,{children:[(0,Y.jsx)(`p`,{children:`The displayed load instruction will be cancelled and recalculated for:`}),(0,Y.jsx)(`ul`,{children:h?.group.map((e,t)=>(0,Y.jsx)(`li`,{children:e.materialID<0?`${e.partName} raw material`:e.serial||`Material ID ${e.materialID}`},e.materialID>=0?e.materialID:`raw-${t}`))}),(0,Y.jsx)(_,{label:`Reason (optional)`,value:l,onChange:e=>u(e.target.value),fullWidth:!0,multiline:!0}),p?(0,Y.jsx)(`p`,{role:`alert`,children:p}):null]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(Up,{suspended:v.length>0,children:(0,Y.jsx)(z,{color:`primary`,disabled:d||v.length>0,onClick:y,children:`Cancel Load`})}),(0,Y.jsx)(z,{color:`secondary`,disabled:d,onClick:()=>c(!1),children:`Keep Load`})]})]})]})}var mm=D.of([V.AddToQueue,V.RemoveFromQueue,V.LoadUnloadCycle,V.MachineCycle]).toRSet(e=>e);function hm(e,t,n){let r=T.empty();for(let i of e)if(mm.has(i.type)&&!Rs(i)&&i.material.some(e=>e.id===t&&(n===null||e.proc>=n)))for(let e of i.material)r=r.set(e.id,e.serial??null);return r}function gm(e){let t=r(fc),n=r(Ys),i=r(q),a=r(ia),o=Object.values(n?.possibleCastingsByQueue??{}).flatMap(e=>e),s=Object.values(n?.possibleJobsByQueue??{}).flatMap(e=>e).filter(e=>e.lastCompletedProcess===0).map(e=>({jobUnique:e.jobUnique,job:i.jobs[e.jobUnique]??a.get(e.jobUnique)??null})),c=t!==null&&t.process>=1,l=t===null||t.process<=1,u=l&&(o.length>0||s.length>0),d=e.st?.changeRawMat!==null&&e.st?.changeRawMat!==void 0&&l&&o.includes(e.st.changeRawMat),f=e.st?.changeJobUnique!==null&&e.st?.changeJobUnique!==void 0&&l&&s.some(t=>t.jobUnique===e.st?.changeJobUnique);function p(t){e.setState({updating:!1,error:null,process:t.startsWith(`proc`)?parseInt(t.substring(4)):1,changeRawMat:t.startsWith(`rawMat`)?t.substring(6):null,changeJobUnique:t.startsWith(`job`)?t.substring(3):null})}return(0,Y.jsx)(_,{value:d?`rawMat`+e.st.changeRawMat:f?`job`+e.st.changeJobUnique:e.st?.process&&c&&e.st.process===t.process?`proc`+e.st.process.toString():``,select:!0,onChange:e=>p(e.target.value),variant:`outlined`,label:e.st?.changeRawMat?`Change Raw Material`:e.st?.changeJobUnique?`Change Assigned Job`:e.st?.process||!u?`Invalidate Process`:c?``:`Change Assignment`,children:[c&&u?[(0,Y.jsx)(h,{children:`Invalidate Selected Process`},`procheader`)]:[],c?[(0,Y.jsxs)(L,{value:`proc`+t.process.toString(),children:[`Invalidate Process `,t.process]},t.process)]:[],c&&u?[(0,Y.jsx)(h,{children:`Change Material Type`},`matheader`)]:[],u?[...o.map(e=>(0,Y.jsxs)(L,{value:`rawMat`+e,children:[c?`Invalidate Process 1 and Change to `:`Change to `,e]},`rawMat`+e)),...s.map(({jobUnique:e,job:t})=>(0,Y.jsxs)(L,{value:`job`+e,children:[t?(0,Y.jsx)(mt,{children:(0,Y.jsx)($,{part:t.partName})}):void 0,(0,Y.jsx)(_t,{primary:(c?`Invalidate Process 1 and Change to Job `:`Change to Job `)+e,secondary:t?.partName})]},`job`+e))]:[]]})}function _m(e){let t=r(Xs),n=Ke(uc),i=r(q),a=e.st!==null&&t!==null,o=(0,K.useRef)(null);if((0,K.useEffect)(()=>{o.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[o]),!a)return(0,Y.jsx)(`div`,{});let s=e.st.process!==null||e.st.changeRawMat!==null||e.st.changeJobUnique!==null,c=e.st.changeRawMat!==null||e.st.changeJobUnique!==null?null:e.st.process,l=[...s?hm(n,t.materialID,c):T.empty()].map(([e,t])=>({materialId:e,serial:t,queued:i.material.find(t=>t.materialID===e)?.location.type===H.InQueue}));return(0,Y.jsx)(B,{ref:o,sx:{display:`flex`,flexDirection:`column`,alignItems:`center`,marginTop:`1em`},children:(0,Y.jsxs)(E,{spacing:2,children:[(0,Y.jsx)(`p`,{style:{maxWidth:`35em`},children:`Invalidating removes whole recorded cycle events from active material reconstruction while retaining them in the event log.`}),(0,Y.jsx)(gm,{st:e.st,setState:e.setState}),l.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:`All material recorded on these events will be affected:`}),(0,Y.jsx)(`ul`,{children:l.map(e=>(0,Y.jsxs)(`li`,{children:[e.serial||`Material ID ${e.materialId}`,e.queued?` (currently in a queue)`:``]},e.materialId))})]}):null,e.st.error?(0,Y.jsx)(`p`,{role:`alert`,children:e.st.error}):null]})})}function vm(e){let t=r(G),n=r(Xs),i=r(tc),a=r(fc),o=r(Ys),s=j(X),c=hc().length>0,l=r(ga);if(e.loadStation&&!t.allowInvalidateMaterialAtLoadStation||!e.loadStation&&!t.allowInvalidateMaterialOnQueuesPage||n===null||!zd(i))return null;let u=(a===null||a.process<=1)&&o!==null&&(!D.ofObject(o.possibleCastingsByQueue??{}).isEmpty()||!D.ofObject(o.possibleJobsByQueue??{}).isEmpty());if(!u&&(a===null||a.process<1))return null;e.ignoreOperator&&(l=null);let d=e.st!==null&&(e.st.changeRawMat!==null||e.st.changeJobUnique!==null);function f(){e.setState({process:null,updating:!1,error:null,changeRawMat:null,changeJobUnique:null})}function p(){c||n&&(e.st?.process||e.st?.changeRawMat||e.st?.changeJobUnique)&&(e.setState({...e.st,updating:!0}),Bi.invalidatePalletCycle(n.materialID,l,e.st?.changeRawMat,e.st?.changeJobUnique,e.st?.process??0).then(t=>{t?(s({type:`MatDetails`,details:t}),e.setState(null)):(s(null),e.onClose())}).catch(t=>{e.setState({...e.st,updating:!1,error:Dd(t)})}))}return(0,Y.jsx)(Up,{suspended:c,children:e.st===null?(0,Y.jsx)(z,{color:`primary`,disabled:c,onClick:f,children:`Invalidate Cycle`}):(0,Y.jsx)(z,{color:`primary`,onClick:p,disabled:c||e.st.updating||d&&!u||!d&&e.st.process!==null&&e.st.process!==a?.process||e.st.process===null&&e.st.changeRawMat===null&&e.st.changeJobUnique===null,children:e.st.changeJobUnique===null?e.st.changeRawMat===null?e.st.process===null?`Invalidate Cycle`:`Invalidate Process `+e.st.process.toString():(a?.process===1?`Invalidate Process 1 and Change to `:`Change to `)+e.st.changeRawMat:(a?.process===1?`Invalidate Process 1 and Change to Job `:`Change to Job `)+e.st.changeJobUnique})})}var ym=_r(o,{shouldForwardProp:e=>e.toString()[0]!==`$`})(({$noBorderBottom:e,$highlightedRow:t,$noncompletedRow:n})=>({...e&&{"& > *":{borderBottom:`unset`}},backgroundColor:t?`#FF8A65`:n?`#E0E0E0`:void 0})),bm=[/\bhold\b/,/\bmissing\b/,/\bwait\b/,/\bwaiting\b/,/\bnone\b/];function xm(e){let t=e.comment;return!t||t===``?!1:D.of(bm).some(e=>e.test(t))}function Sm(e){let t=(r(G).allowEditJobPlanQuantityFromQueuesPage??null)!=null,[n,i]=(0,K.useState)(!1),a=e.job,o=xm(a.job);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(ym,{$noBorderBottom:!0,$highlightedRow:o,$noncompletedRow:a.remainingToStart-a.assignedRaw>0,children:[(0,Y.jsx)(w,{children:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:a.job.partName,size:25})}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(b,{variant:`body2`,component:`span`,sx:{display:`block`},children:a.job.unique})})]})}),(0,Y.jsx)(w,{children:a.startingTime?a.startingTime.toLocaleString():``}),(0,Y.jsx)(w,{children:a.rawMatName===a.job.partName?a.rawMatName:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:a.rawMatName,size:25})}),(0,Y.jsx)(b,{variant:`body2`,sx:{display:`block`},children:a.rawMatName})]})}),(0,Y.jsxs)(w,{children:[a.job.comment,(0,Y.jsx)(S,{title:`Edit`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>e.editNote(a.job),children:(0,Y.jsx)(Jn,{})})})]}),(0,Y.jsxs)(w,{align:`right`,children:[a.job.cycles??0,t?(0,Y.jsx)(S,{title:`Edit`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>e.editQty(a),children:(0,Y.jsx)(Jn,{})})}):void 0]}),(0,Y.jsx)(w,{align:`right`,children:a.remainingToStart}),(0,Y.jsx)(w,{align:`right`,children:a.assignedRaw}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(S,{title:a.remainingToStart>0||a.assignedRaw>0?`${a.remainingToStart} - ${a.assignedRaw}`:``,children:(0,Y.jsx)(`span`,{children:Math.max(a.remainingToStart-a.assignedRaw,0)})})}),(0,Y.jsx)(w,{align:`right`,children:a.availableUnassigned}),(0,Y.jsx)(w,{children:(0,Y.jsx)(S,{title:`Show Details`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>i(!n),children:n?(0,Y.jsx)(ke,{}):(0,Y.jsx)(f,{})})})})]}),(0,Y.jsx)(ym,{$highlightedRow:o,$noncompletedRow:a.remainingToStart-a.assignedRaw>0,children:(0,Y.jsx)(w,{sx:{pb:`0`,pt:`0`},colSpan:10,children:(0,Y.jsx)(x,{in:n,timeout:`auto`,unmountOnExit:!0,children:(0,Y.jsx)(Ap,{job:a.job,checkAnalysisMonth:!1})})})})]})}function Cm(e){let t=r(q),n=(0,K.useMemo)(()=>yp(t.jobs,t.material,e.queue),[t,e.queue]);return n.length===0?null:(0,Y.jsxs)(he,{size:`small`,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Job`}),(0,Y.jsx)(w,{children:`Starting Time`}),(0,Y.jsx)(w,{children:`Material`}),(0,Y.jsx)(w,{children:`Note`}),(0,Y.jsx)(w,{align:`right`,children:`Planned Quantity`}),(0,Y.jsx)(w,{align:`right`,children:`Remaining To Start`}),(0,Y.jsx)(w,{align:`right`,children:`Assigned Raw Material`}),(0,Y.jsx)(w,{align:`right`,children:`Required`}),(0,Y.jsx)(w,{align:`right`,children:`Available Unassigned`}),(0,Y.jsx)(w,{})]})}),(0,Y.jsx)(ae,{children:n.map((t,n)=>(0,Y.jsx)(Sm,{job:t,editNote:e.editNote,editQty:e.editQty},n))})]})}var wm=(0,K.memo)(function({workorder:e,inProc:t}){let n=j(Om);return(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:e.workorderId}),(0,Y.jsx)(w,{children:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:e.part,size:25})}),(0,Y.jsx)(b,{variant:`body2`,sx:{display:`block`},children:e.part})]})}),(0,Y.jsxs)(w,{children:[e.comments&&e.comments.length>0?e.comments[e.comments.length-1].comment:``,(0,Y.jsx)(S,{title:`Edit`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>n(e),children:(0,Y.jsx)(Jn,{})})})]}),(0,Y.jsx)(w,{children:e.dueDate.toLocaleDateString()}),(0,Y.jsx)(w,{children:e.priority}),(0,Y.jsx)(w,{children:e.plannedQuantity}),(0,Y.jsx)(w,{children:e.completedQuantity}),(0,Y.jsx)(w,{children:t}),(0,Y.jsx)(w,{children:Math.max(0,e.plannedQuantity-e.completedQuantity-t)})]})}),Tm=(0,K.memo)(function(){let e=r(q);if(!e.workorders||e.workorders.length===0)return null;let t=D.of(e.workorders).sortBy(e=>e.dueDate.getTime(),e=>e.priority),n=D.of(e.material).filter(e=>!!e.workorderId&&e.workorderId!==``).toLookupMap(e=>e.workorderId??``,e=>e.partName,()=>1,(e,t)=>e+t);return(0,Y.jsxs)(he,{size:`small`,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Workorder`}),(0,Y.jsx)(w,{children:`Part`}),(0,Y.jsx)(w,{children:`Comment`}),(0,Y.jsx)(w,{children:`Due Date`}),(0,Y.jsx)(w,{children:`Priority`}),(0,Y.jsx)(w,{children:`Planned Qty`}),(0,Y.jsx)(w,{children:`Completed Qty`}),(0,Y.jsx)(w,{children:`In Process`}),(0,Y.jsx)(w,{children:`Remaining To Assign`})]})}),(0,Y.jsx)(ae,{children:t.map(e=>(0,Y.jsx)(wm,{workorder:e,inProc:n.get(e.workorderId)?.get(e.part)??0},`${e.workorderId}-${e.part}`))})]})}),Em=(0,K.memo)(function(e){let[t,n]=(0,K.useState)(null),r=j(ba);function i(){e.closeDialog(),n(null)}function a(){t!==null&&e.job!==null&&t!==e.job.comment&&(r(e.job.unique,t),i())}return(0,Y.jsx)(I,{open:e.job!==null,onClose:i,children:e.job===null?void 0:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($n,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)($,{part:e.job.partName,size:40})}),(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`,flexGrow:1},children:[`Edit Note For `,e.job.unique]})]})}),(0,Y.jsx)(M,{children:(0,Y.jsx)(_,{variant:`outlined`,fullWidth:!0,autoFocus:!0,value:t===null?e.job.comment||``:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.keyCode===13&&t!==null&&(a(),e.preventDefault())}})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(z,{color:`primary`,disabled:t===null,onClick:a,children:`Save Note`}),(0,Y.jsx)(z,{color:`primary`,onClick:i,children:`Cancel`})]})]})})}),Dm=(0,K.memo)(function(e){let[t,n]=(0,K.useState)(!1),[i,a]=(0,K.useState)(null),o=r(G).allowEditJobPlanQuantityFromQueuesPage??null;function s(){t||(e.closeDialog(),a(null))}async function c(){if(!(o===null||e.job===null||i==null||isNaN(i))){n(!0);try{await fetch(o,{method:`PUT`,headers:new Headers({"Content-Type":`application/json`}),body:JSON.stringify({Unique:e.job.job.unique,Quantity:i})}),e.closeDialog(),a(null)}finally{n(!1)}}}return(0,Y.jsx)(I,{open:o!=null&&e.job!==null,onClose:s,children:e.job===null?void 0:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($n,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)($,{part:e.job.job.partName,size:40})}),(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`,flexGrow:1},children:[`Edit Planned Quantity For `,e.job.job.unique]})]})}),(0,Y.jsxs)(M,{children:[(0,Y.jsxs)(`p`,{children:[e.job.job.cycles,` currently planned, `,e.job.remainingToStart,` remaining to start`]}),(0,Y.jsx)(_,{variant:`outlined`,fullWidth:!0,autoFocus:!0,type:`number`,value:i===null?``:i,onChange:e=>a(parseInt(e.target.value)),slotProps:{htmlInput:{style:{textAlign:`right`},min:(e.job.job.cycles??0)-e.job.remainingToStart}}})]}),(0,Y.jsxs)(N,{children:[(0,Y.jsxs)(z,{color:`primary`,disabled:t||i===null||isNaN(i),onClick:()=>void c(),children:[t?(0,Y.jsx)(pn,{size:10}):void 0,`Set Quantity`]}),(0,Y.jsx)(z,{color:`primary`,disabled:t,onClick:s,children:`Cancel`})]})]})})}),Om=F(null);function km(){let[e,t]=A(Om),[n,r]=(0,K.useState)(null),i=j(xa);function a(){t(null),r(null)}function o(){e&&n&&n!==``&&i({workorder:e.workorderId,comment:n}),a()}return(0,Y.jsx)(I,{open:e!==null,onClose:a,children:e===null?void 0:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($n,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)($,{part:e.part,size:40})}),(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`,flexGrow:1},children:[`Add Comment For `,e.workorderId]})]})}),(0,Y.jsxs)(M,{children:[(0,Y.jsx)(`ul`,{children:(e.comments??[]).map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(b,{variant:`body1`,children:[e.timeUTC.toLocaleString(),`: `,e.comment]})},t))}),(0,Y.jsx)(_,{variant:`outlined`,sx:{mt:`1em`},fullWidth:!0,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n!==null&&n!==``&&(o(),e.preventDefault())}})]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(z,{color:`primary`,onClick:o,children:`Save Comment`}),(0,Y.jsx)(z,{color:`primary`,onClick:a,children:`Cancel`})]})]})})}var Am=(0,K.memo)(function(e){let t=r(G),n=j(Wp),i=j(Zp),a=j(op);if(!t.addToQueueButton||t.addToQueueButton===wr.DoNotShow)return null;function o(){switch(t.addToQueueButton){case wr.DoNotShow:return;case wr.AddBulkUnassigned:e.rawMatQueue?n(e.label):i(e.label);break;case wr.LookupExistingSerial:i(e.label);return;case wr.ManualBarcodeScan:a(e.label);return}}return e.rawMatQueue?(0,Y.jsx)(S,{title:`Add Raw Material`,children:(0,Y.jsx)(Lt,{color:`secondary`,onClick:o,size:`large`,style:{marginBottom:`-30px`,zIndex:1},children:(0,Y.jsx)(m,{})})}):e.inProcQueue?(0,Y.jsx)(S,{title:`Add Material`,children:(0,Y.jsx)(Lt,{color:`secondary`,onClick:o,size:`medium`,style:{marginBottom:`-30px`,zIndex:1},children:(0,Y.jsx)(lr,{fontSize:`inherit`})})}):null});function jm(e){let t=r(X);return t&&t.type===`AddMatWithEnteredSerial`||t&&t.type===`Barcode`&&t.toQueue?e.includes(t.toQueue)?[t.toQueue]:[]:e}var Mm=(0,K.memo)(function({queueNames:e}){let[t,n]=(0,K.useState)({toQueue:null,enteredOperator:null,newMaterialTy:null}),[r,i]=(0,K.useState)(null),a=(0,K.useCallback)(()=>{n({toQueue:null,enteredOperator:null,newMaterialTy:null}),i(null)},[]);return e=jm(e),(0,Y.jsx)(xf,{allowNote:!0,onClose:a,highlightProcsGreaterOrEqualTo:r?.process??void 0,extraDialogElements:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_m,{st:r,setState:i}),(0,Y.jsx)(sm,{queueNames:e,st:t,setState:n})]}),buttons:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Hp,{}),(0,Y.jsx)(fm,{onClose:a}),(0,Y.jsx)(pm,{onClose:a}),(0,Y.jsx)(vm,{onClose:a,st:r,setState:i}),(0,Y.jsx)(cm,{st:t,queueNames:e,onClose:a})]})})}),Nm=e=>{let t=r(ga),n=r(q),i=r(qc),a=r(Yc),o=(0,K.useMemo)(()=>Cp(e.queues,n,i,a),[n,e.queues,i,a]),s=!D.ofObject(n.jobs).isEmpty(),[c,l]=(0,K.useState)(null),u=(0,K.useCallback)(()=>l(null),[]),[d,f]=(0,K.useState)(null),p=(0,K.useCallback)(()=>f(null),[]),[m,h]=(0,K.useState)(null),g=(0,K.useCallback)(()=>h(null),[]);return(0,Y.jsxs)(B,{sx:{padding:`8px`,width:`100%`},children:[o.map((e,t)=>(0,Y.jsx)(`div`,{style:t<o.length-1?{borderBottom:`1px solid black`}:void 0,children:(0,Y.jsx)(Np,{matIds:e.material.map(e=>e.materialID),direction:`rect`,queueName:e.label,renderDragOverlay:t=>(0,Y.jsx)(cf,{mat:t,hideEmptySerial:!0,displayJob:s&&e.rawMaterialQueue,fsize:`normal`}),children:(0,Y.jsxs)(B,{sx:{minHeight:`134px`},children:[(0,Y.jsxs)(B,{sx:{display:`flex`,margin:`4px`},children:[(0,Y.jsx)(b,{variant:`h4`,sx:{flexGrow:1},children:e.label}),e.free?void 0:(0,Y.jsx)(Am,{label:e.label,rawMatQueue:e.rawMaterialQueue,inProcQueue:e.inProcQueue})]}),(0,Y.jsxs)(B,{sx:{justifyContent:`flex-start`,display:`flex`,flexWrap:`wrap`},children:[e.material.map((t,n)=>(0,Y.jsx)(sf,{mat:t,hideEmptySerial:!0,fsize:`normal`,displayJob:s&&e.rawMaterialQueue},n)),e.groupedRawMat&&e.groupedRawMat.length>0?e.groupedRawMat.map((n,r)=>n.material.length===1?(0,Y.jsx)(of,{mat:n.material[0],hideEmptySerial:!0,fsize:`normal`,displayJob:s&&e.rawMaterialQueue},r):(0,Y.jsx)(lf,{partOrCasting:n.partOrCasting,assignedJobUnique:n.assignedJobUnique,material:n.material,fsize:`normal`,onOpen:()=>h(n.material)},t)):void 0,e.rawMaterialQueue?s?(0,Y.jsx)(Cm,{queue:e.label,editNote:l,editQty:f}):(0,Y.jsx)(Tm,{}):void 0]})]})})},t)),(0,Y.jsx)(Mm,{queueNames:e.queues}),(0,Y.jsx)(Qp,{}),(0,Y.jsx)(sp,{}),(0,Y.jsx)(Jp,{}),(0,Y.jsx)(Em,{job:c,closeDialog:u}),(0,Y.jsx)(Dm,{job:d,closeDialog:p}),(0,Y.jsx)(km,{}),(0,Y.jsx)(Yp,{material:m,closeDialog:g,operator:t})]})};function Pm(e){return Q(`Queues`),(0,Y.jsx)(B,{component:`main`,sx:{backgroundColor:`#F8F8F8`,minHeight:{xs:`calc(100vh - 64px - 32px)`,sm:`calc(100vh - 64px - 40px)`,md:`calc(100vh - 64px)`}},children:(0,Y.jsx)(Nm,{...e})})}var Fm=_r(o,{shouldForwardProp:e=>e.toString()[0]!==`$`})(e=>({"& > *":{borderBottom:`unset`},...e.$darkRow&&{backgroundColor:`#F5F5F5`}})),Im=_r(o,{shouldForwardProp:e=>e.toString()[0]!==`$`})(e=>({...e.$darkRow&&{backgroundColor:`#F5F5F5`}}));function Lm(e){let[t,n]=(0,K.useState)(!1),r=10;e.showMaterial&&(r+=1);let i=e.job;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Fm,{$darkRow:e.showDarkRow&&i.darkRow,children:[(0,Y.jsx)(w,{children:i.routeStartTime.toLocaleString()}),(0,Y.jsx)(w,{children:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:i.partName,size:25})}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(b,{variant:`body2`,component:`span`,sx:{display:`block`},children:i.partName})})]})}),e.showMaterial?(0,Y.jsx)(w,{children:i.casting?(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:i.casting,size:25})}),(0,Y.jsx)(b,{variant:`body2`,sx:{display:`block`},children:i.casting})]}):void 0}):void 0,(0,Y.jsxs)(w,{children:[i.comment,(0,Y.jsx)(S,{title:`Edit`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>e.setCurEditNoteJob(i),children:(0,Y.jsx)(Jn,{})})})]}),(0,Y.jsx)(w,{children:i.inProcJob===null?`Archived`:`Active`}),(0,Y.jsx)(w,{align:`right`,children:i.scheduledQty}),(0,Y.jsx)(w,{align:`right`,sx:{backgroundColor:i.decrementedQty>0?`#FF8A65`:void 0},children:i.decrementedQty}),(0,Y.jsx)(w,{align:`right`,children:i.completedQty}),(0,Y.jsx)(w,{align:`right`,children:i.inProcessQty}),(0,Y.jsx)(w,{align:`right`,children:i.remainingQty}),(0,Y.jsx)(w,{children:(0,Y.jsx)(S,{title:`Show Details`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>n(!t),children:t?(0,Y.jsx)(ke,{}):(0,Y.jsx)(f,{})})})})]}),(0,Y.jsx)(Im,{$darkRow:e.showDarkRow&&i.darkRow,children:(0,Y.jsx)(w,{sx:{pb:`0`,pt:`0`},colSpan:r,children:(0,Y.jsx)(x,{in:t,timeout:`auto`,unmountOnExit:!0,children:(0,Y.jsx)(Ap,{job:i.inProcJob?i.inProcJob:i.historicJob,checkAnalysisMonth:!1})})})})]})}function Rm(e,t,n,r){let i;switch(t){case 0:i=e=>e.routeStartTime.getTime();break;case 1:i=e=>e.partName;break;case 2:i=e=>e.casting;break;case 3:i=e=>e.comment??null;break;case 4:i=e=>e.scheduledQty;break;case 5:i=e=>e.decrementedQty;break;case 6:i=e=>e.completedQty;break;case 7:i=e=>e.inProcessQty;break;case 8:i=e=>e.remainingQty}return(r?D.of(e):D.of(e).filter(e=>e.inProcJob!==null)).toSortedArray(n===`asc`?{asc:i}:{desc:i})}function zm(e){return(0,Y.jsx)(S,{title:`Sort`,enterDelay:300,children:(0,Y.jsx)(w,{align:e.align,sortDirection:e.sortBy===e.col&&e.order,children:(0,Y.jsx)(fn,{active:e.sortBy===e.col,direction:e.order,onClick:()=>{e.col===e.sortBy?e.setOrder(e.order===`asc`?`desc`:`asc`):(e.setSortBy(e.col),e.setOrder(`asc`))},children:e.children})})})}var Bm=(0,K.memo)(function(e){let t={sortBy:e.sortBy,setSortBy:e.setSortBy,order:e.order,setOrder:e.setOrder};return(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(zm,{align:`left`,col:0,...t,children:`Date`}),(0,Y.jsx)(zm,{align:`left`,col:1,...t,children:`Part`}),e.showMaterial?(0,Y.jsx)(zm,{align:`left`,col:2,...t,children:`Material`}):void 0,(0,Y.jsx)(zm,{align:`left`,col:3,...t,children:`Note`}),(0,Y.jsxs)(w,{align:`left`,children:[`Active`,(0,Y.jsx)(S,{title:e.showArchived?`Hide Archived`:`Show Archived`,children:(0,Y.jsx)(C,{size:`small`,onClick:t=>{e.setShowArchived(e=>!e),t.stopPropagation()},children:e.showArchived?(0,Y.jsx)(Et,{}):(0,Y.jsx)(Zt,{})})})]}),(0,Y.jsx)(zm,{align:`right`,col:4,...t,children:`Scheduled`}),(0,Y.jsx)(zm,{align:`right`,col:5,...t,children:`Removed`}),(0,Y.jsx)(zm,{align:`right`,col:6,...t,children:`Completed`}),(0,Y.jsx)(zm,{align:`right`,col:7,...t,children:`In Process`}),(0,Y.jsx)(zm,{align:`right`,col:8,...t,children:`Remaining To Run`}),(0,Y.jsx)(w,{children:(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},onClick:()=>up(e.jobs,e.showMaterial),size:`large`,children:(0,Y.jsx)(ct,{})})})})]})})}),Vm=(0,K.memo)(function(){let[e,t]=(0,K.useState)(null),[n,i]=(0,K.useState)(0),[a,o]=(0,K.useState)(`desc`),[s,c]=(0,K.useState)(!0),l=r(Bl),u=r(ia),d=r(q),f=(0,K.useMemo)(()=>{for(let[,e]of u)for(let t of e.procsAndPaths[0]?.paths??[])if(t.casting!==null&&t.casting!==void 0&&t.casting!==``)return!0;return!1},[u]),p=(0,K.useMemo)(()=>cp({start:P(k(),-6),end:P(k(),1)},l.matsById,u,d),[l.matsById,u,d]),m=(0,K.useMemo)(()=>Rm(p,n,a,s),[p,n,a,s]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(Bm,{jobs:p,showMaterial:f,sortBy:n,setSortBy:i,order:a,setOrder:o,showArchived:s,setShowArchived:c}),(0,Y.jsx)(ae,{children:m.map((e,r)=>(0,Y.jsx)(Lm,{job:e,showDarkRow:n===0,showMaterial:f,setCurEditNoteJob:t},e.inProcJob?.unique??e.historicJob?.unique??r))})]}),(0,Y.jsx)(Em,{job:e?.historicJob??null,closeDialog:()=>t(null)})]})});function Hm(){return Q(`Scheduled Jobs`),(0,Y.jsx)(`main`,{style:{padding:`24px`},children:(0,Y.jsx)(Vm,{})})}var Um=`__FMS_INSIGHT_LOAD_STATION_BIN__`,Wm=`__FMS_INSIGHT_PALLETS_BIN__`,Gm=`__FMS_INSIGHT_ACTIVE_QUEUE_BIN__`,Km=`__FMS_INSIGHT_BASKETS_BIN__`,qm=l(`material-bins`,[]);function Jm(e,t,n){let r=Array.from(e),[i]=r.splice(t,1);return r.splice(n,0,i),r}function Ym(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}var Xm=function(e){return e.LoadStations=`Bin_LoadStations`,e.Pallets=`Bin_Pallets`,e.ActiveQueues=`Bin_ActiveQueues`,e.Baskets=`Bin_Baskets`,e.QuarantineQueues=`Bin_Quarantine`,e}({});function Zm(e){let t=e.position;if(t===void 0)return`Unknown`;let n;return n=t.locationTitle&&t.locationTitle.length>0?t.locationTitle:t.location+` `+t.locationNum.toString(),t.zone&&(n+=`-${t.zone}`),n}function Qm(e,t){let n=new Map,r=new Map,i=new Map,a=new Map,o=D.ofObject(e.pallets).toRMap(([,e])=>[e.palletNum,e.palletNum.toString()+` (`+e.currentPalletLocation.group+` #`+e.currentPalletLocation.num.toString()+`)`]);for(let t of e.material)switch(t.location.type){case H.InQueue:if(t.action.type===U.Loading){let r=e.pallets[t.action.loadOntoPalletNum??0];if(r&&r.currentPalletLocation.loc===Qr.LoadUnload){let e=r.currentPalletLocation.num;Ym(n,e,t)}else Ym(i,t.location.currentQueue||`Queue`,t)}else Ym(i,t.location.currentQueue||`Queue`,t);break;case H.OnPallet:if(t.location.palletNum){let i=e.pallets[t.location.palletNum];i.currentPalletLocation.loc===Qr.LoadUnload?Ym(n,i.currentPalletLocation.num,t):Ym(r,o.get(t.location.palletNum)??``,t)}else Ym(r,`Pallet`,t);break;case H.Free:switch(t.action.type){case U.Loading:{let r=e.pallets[t.action.loadOntoPalletNum??0]?.currentPalletLocation.num;Ym(n,r,t);break}case U.LoadingToBasket:{let r=e.baskets?.[t.action.loadToBasketId??0]?.position;r?.location===gi.LoadUnload?Ym(n,r.locationNum,t):Ym(i,`Free Material`,t);break}default:Ym(i,`Free Material`,t)}break;case H.InBasket:t.location.basketId!==void 0&&Ym(a,t.location.basketId,t)}let s=D.ofObject(e.jobs).flatMap(([,e])=>e.procsAndPaths).flatMap(e=>e.paths).flatMap(e=>{let t=[];return e.inputQueue!==void 0&&t.push(e.inputQueue),e.outputQueue!==void 0&&t.push(e.outputQueue),t}).concat(D.ofObject(e.queues).filter(([,e])=>e.role===oi.RawMaterial||e.role===oi.InProcessTransfer).map(([e])=>e)).toRSet(e=>e),c=D.ofObject(e.queues).filter(([e])=>!s.has(e)).toRSet(([e])=>e),l=t.filter(e=>e===`__FMS_INSIGHT_LOAD_STATION_BIN__`||e===`__FMS_INSIGHT_PALLETS_BIN__`||e===`__FMS_INSIGHT_ACTIVE_QUEUE_BIN__`||e===`__FMS_INSIGHT_BASKETS_BIN__`||c.has(e));l.indexOf(`__FMS_INSIGHT_ACTIVE_QUEUE_BIN__`)<0&&l.unshift(Gm),a.size>0&&l.indexOf(`__FMS_INSIGHT_BASKETS_BIN__`)<0&&l.unshift(Km),l.indexOf(`__FMS_INSIGHT_PALLETS_BIN__`)<0&&l.unshift(Wm),l.indexOf(`__FMS_INSIGHT_LOAD_STATION_BIN__`)<0&&l.unshift(Um);for(let e of D.of(c).sortBy(e=>e))l.indexOf(e)<0&&l.push(e);return l.map(t=>{if(t===`__FMS_INSIGHT_LOAD_STATION_BIN__`)return{type:`Bin_LoadStations`,binId:Um,byLul:n};if(t===`__FMS_INSIGHT_PALLETS_BIN__`)return{type:`Bin_Pallets`,binId:Wm,byPallet:r};if(t===`__FMS_INSIGHT_ACTIVE_QUEUE_BIN__`)return{type:`Bin_ActiveQueues`,binId:Gm,byQueue:D.of(s).toRMap(e=>{let t=i.get(e)??[];return t.sort((e,t)=>(e.location.queuePosition??0)-(t.location.queuePosition??0)),[e,t]},(e,t)=>e.concat(t))};if(t===`__FMS_INSIGHT_BASKETS_BIN__`)return{type:`Bin_Baskets`,binId:Km,byBasket:new Map(a),basketLocations:D.ofObject(e.baskets??{}).collect(([e,t])=>parseInt(e)>0?[parseInt(e),Zm(t)]:null).toRMap(e=>e)};{let e=t,n=i.get(e)??[];return n.sort((e,t)=>(e.location.queuePosition??0)-(t.location.queuePosition??0)),{type:`Bin_Quarantine`,binId:e,queueName:e,material:n}}})}function $m(e,t,n,r){return e.map(e=>{switch(e.type){case`Bin_Quarantine`:if(e.queueName===n){let n=e.material.filter(e=>e.materialID!==t.materialID);return n.splice(r,0,t),{...e,material:n}}return{...e,material:e.material.filter(e=>e.materialID!==t.materialID)};default:return e}})}function eh(e,t){for(let n of t)switch(n.type){case`Bin_Quarantine`:for(let t=0;t<n.material.length;t++)if(n.material[t].materialID===e)return{bin:n,idx:t}}return null}function th(e,t){for(let n of t)if(n.type===`Bin_Quarantine`&&n.queueName===e)return{bin:n,idx:0};return null}var nh=(0,K.forwardRef)(function(e,t){return(0,Y.jsxs)(B,{sx:{margin:e.isDragOverlay?void 0:`0.75em`,opacity:e.isActiveDrag?.2:1,border:`1px solid black`,padding:`4px`},ref:t,...e.dragRootProps,children:[(0,Y.jsx)(B,{role:`button`,tabIndex:0,sx:{cursor:e.isDragOverlay?`grabbing`:`grab`},...e.dragHandleProps,children:(0,Y.jsx)(b,{variant:`h4`,children:e.label})}),(0,Y.jsx)(B,{sx:{display:`flex`,flexDirection:`column`,flexWrap:`nowrap`,width:`18em`,minHeight:`20em`},children:e.children})]})});function rh(e){let t={type:`container`,bin:e.bin},{active:n,isDragging:r,attributes:i,listeners:a,setNodeRef:o,setActivatorNodeRef:s,transform:c,transition:l}=fr({id:e.binId,data:t}),u={...a};for(let[e,t]of Object.entries(i))e.startsWith(`aria`)&&(u[e]=t);let d={transform:c?`translate3d(${Math.round(c.x)}px, ${Math.round(c.y)}px, 0)`:void 0,transition:n===null?void 0:l};return(0,Y.jsx)(nh,{ref:o,dragRootProps:{style:d},dragHandleProps:u,setDragHandleRef:s,isActiveDrag:r,...e})}var ih=(0,K.memo)(function(e){return e.isDragOverlay?(0,Y.jsx)(nh,{binId:e.binId,label:e.queue,isDragOverlay:!0,children:e.material.map(e=>(0,Y.jsx)(of,{mat:e,hideAvatar:!0,showHandle:!0},e.materialID))}):(0,Y.jsx)(rh,{binId:e.binId,label:e.queue,bin:e.bin,children:(0,Y.jsx)(Qt,{items:e.material.map(e=>e.materialID),strategy:jt,children:e.material.map(e=>(0,Y.jsx)(sf,{mat:e,hideAvatar:!0},e.materialID))})})});function ah(e,t){return e-t}function oh(e){return`Pallet `+e}function sh(e,t){let n=parseInt(e),r=parseInt(t);return isNaN(n)||isNaN(r)?e.localeCompare(t):n-r}function ch(e){return e}function lh(e,t){return e.localeCompare(t)}function uh(e,t){return e-t}var dh=class extends K.PureComponent{render(){let e=this.props.isDragOverlay?nh:rh;return(0,Y.jsx)(e,{label:this.props.name,binId:this.props.binId,bin:this.props.bin,isDragOverlay:this.props.isDragOverlay,children:D.of(this.props.material).sortWith(([e,t],[n,r])=>this.props.compareLabel(e,n)).map(([e,t],n)=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(b,{variant:`caption`,children:this.props.renderLabel(e)}),t.map((e,t)=>(0,Y.jsx)(of,{mat:e,hideAvatar:!0},t))]},n))})}};function fh({matBin:e,isDragOverlay:t}){let n=r(G),i=eo(n.basketName);switch(e.type){case Xm.LoadStations:return(0,Y.jsx)(dh,{name:`Load Stations`,binId:e.binId,renderLabel:e=>Za(e,n.loadStationNames),compareLabel:ah,material:e.byLul,bin:e,isDragOverlay:t});case Xm.Pallets:return(0,Y.jsx)(dh,{name:`Pallets`,binId:e.binId,renderLabel:oh,compareLabel:sh,material:e.byPallet,bin:e,isDragOverlay:t});case Xm.ActiveQueues:return(0,Y.jsx)(dh,{name:`Queues`,binId:e.binId,renderLabel:ch,compareLabel:lh,material:e.byQueue,bin:e,isDragOverlay:t});case Xm.Baskets:return(0,Y.jsx)(dh,{name:i+`s`,binId:e.binId,renderLabel:t=>i+` `+t.toString()+(typeof t==`number`&&e.basketLocations.get(t)?` (${e.basketLocations.get(t)})`:``),compareLabel:uh,material:e.byBasket,bin:e,isDragOverlay:t});case Xm.QuarantineQueues:return(0,Y.jsx)(ih,{binId:e.binId,queue:e.queueName,material:e.material,bin:e,isDragOverlay:t})}}var ph=(0,K.memo)(function(){let[e,t]=(0,K.useState)(null);function n(){t(null)}return(0,Y.jsx)(xf,{onClose:n,allowNote:!0,highlightProcsGreaterOrEqualTo:e?.process??void 0,extraDialogElements:(0,Y.jsx)(Y.Fragment,{children:e===null?null:(0,Y.jsx)(_m,{st:e,setState:t})}),buttons:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(fm,{onClose:n,ignoreOperator:!0}),(0,Y.jsx)(pm,{onClose:n,ignoreOperator:!0}),(0,Y.jsx)(vm,{st:e,setState:t,onClose:n,ignoreOperator:!0})]})})});function mh(e){return(0,K.useCallback)(t=>{if(typeof t.active.id==`string`)return v({...t,droppableContainers:t.droppableContainers.filter(e=>typeof e.id==`string`)});let n=Re(t),r=n.length>0?n:dn(t),i=ee(r,`id`);if(i!=null){if(typeof i==`string`){let n=th(i,e);n&&n.bin.material.length>0&&(i=v({...t,droppableContainers:t.droppableContainers.filter(e=>e.id!==i&&n.bin.material.findIndex(t=>t.materialID===e.id)>=0)})[0]?.id)}return[{id:i}]}return[]},[e])}function hh(e){Q(`All Material`);let t=r(q),[n,i]=A(qm),a=j(ed),[o,s]=(0,K.useState)(null),c=(0,K.useMemo)(()=>{let e=Qm(t,n);return o&&o.type===`material`&&o.curOverBinId!==null?$m(e,o.mat,o.curOverBinId,o.initialIdx):e},[t,n,o]),l=e.displaySystemBins?c:c.filter(e=>e.type===Xm.QuarantineQueues),u=mh(c);return(0,Y.jsxs)(cr,{collisionDetection:u,measuring:{droppable:{strategy:ir.Always}},onDragStart:({active:e})=>{typeof e.id==`string`&&typeof e.data.current==`object`&&e.data.current!==null&&`bin`in e.data.current?s({type:`column`,bin:e.data.current.bin}):typeof e.data.current==`object`&&e.data.current!==null&&`mat`in e.data.current&&s({type:`material`,mat:e.data.current.mat,curOverBinId:null,initialIdx:0})},onDragOver:({over:e})=>{if(!e||o===null||o.type===`column`)return;let t=typeof e.id==`string`?th(e.id,c):eh(e.id,c);t&&Hd(o.mat,t.bin.queueName)&&t.bin.binId!==o.curOverBinId&&s({...o,curOverBinId:t.bin.binId,initialIdx:t.idx})},onDragEnd:({over:e})=>{if(o!==null){if(!e)s(null);else{if(o.type===`column`)typeof e.id==`number`?console.log(`Invalid, collision should never allow a column drag to be over a material`):i(Jm(l.map(e=>e.binId),l.findIndex(e=>e.binId===o.bin.binId),l.findIndex(t=>t.binId===e.id)));else{let t=typeof e.id==`string`?th(e.id,c):eh(e.id,c);t&&Hd(o.mat,t.bin.queueName)&&a({queue:t.bin.queueName,matId:o.mat.materialID,newIdx:t.idx,operator:null}).catch(console.error)}s(null)}}},onDragCancel:()=>s(null),children:[(0,Y.jsx)(Qt,{items:l.map(e=>e.binId),strategy:Jt,children:(0,Y.jsx)(B,{component:`main`,sx:{display:`flex`,flexWrap:`nowrap`,backgroundColor:`#F8F8F8`,minHeight:{xs:`calc(100vh - 64px - 48px)`,md:`calc(100vh - 64px)`}},children:l.map(e=>(0,Y.jsx)(fh,{matBin:e},e.binId))})}),(0,Y.jsx)(Qe,{children:o?.type===`material`?(0,Y.jsx)(cf,{mat:o.mat,hideAvatar:!0}):o?.type===`column`?(0,Y.jsx)(fh,{matBin:o.bin,isDragOverlay:!0}):void 0}),(0,Y.jsx)(ph,{})]})}function gh(e){let t=[];for(let n of e)for(let e of n.stops)t.push(`P${n.pallet},M${e.stationNum}`);return t.join(` -> `)}function _h(e,t,n){let r=D.of(e).collect(e=>e.result.type===kl.Completed&&!e.result.success?e.materialID:null).toRSet(e=>e);return D.of(e).collect(e=>{if(t&&(e.time<t.start||e.time>t.end))return null;switch(e.result.type){case kl.Triggered:return{time:e.time,materialID:e.materialID,partName:e.part,serial:e.serial,workorder:e.workorder,toInspect:e.result.toInspect,path:gh(e.result.actualPath),failed:r.has(e.materialID)};default:return null}}).buildHashMap(e=>e.path,(e,t)=>{let n=e??[];return n.push(t),n}).mapValues(e=>({material:D.of(e).toSortedArray(n,e=>e.time.getTime()),failedCnt:e.reduce((e,t)=>e+ +!!t.failed,0)}))}function vh(e,t,n){return D.of(e).collect(e=>e.time<t||e.time>n?null:e.result.type===kl.Completed&&!e.result.success?{time:e.time,materialID:e.materialID,serial:e.serial,workorder:e.workorder,inspType:e.inspType,part:e.part}:null).toSortedArray(e=>e.time.getTime())}function yh(e){for(let t of e)if(t.type===V.Inspection){let e=JSON.parse((t.details||{}).ActualPath||`[]`);if(!Array.isArray(e))continue;let n=[];for(let t of e)typeof t==`object`&&t&&n.push(kr.fromJS(t));if(n.length>0)return n}return[]}function bh(e,t,n){let r=`<table>
|
|
40
|
+
<thead><tr>`;r+=`<th>Path</th><th>Date</th><th>Part</th><th>Inspection</th>`,r+=`<th>Serial</th><th>Workorder</th><th>Inspected</th><th>Failed</th>`,r+=`</tr></thead>
|
|
41
|
+
<tbody>
|
|
42
|
+
`;let i=_h(n,void 0,{asc:e=>e.time.getTime()}),a=D.of(i.keys()).toSortedArray(e=>e);for(let n of a){let a=i.get(n);if(a)for(let i of a.material)r+=`<tr>`,r+=`<td>`+n+`</td>`,r+=`<td>`+i.time.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`})+`</td>`,r+=`<td>`+e+`</td>`,r+=`<td>`+t+`</td>`,r+=`<td>`+(i.serial||``)+`</td>`,r+=`<td>`+(i.workorder||``)+`</td>`,r+=`<td>`+(i.toInspect?`inspected`:``)+`</td>`,r+=`<td>`+(i.failed?`failed`:``)+`</td>`,r+=`</tr>
|
|
43
|
+
`}return r+=`</tbody>
|
|
44
|
+
</table>`,r}function xh(e,t,n){Je(bh(e,t,n))}function Sh(e){let t=`<table>
|
|
45
|
+
<thead><tr>`;t+=`<th>Date</th><th>Part</th><th>Inspection</th><th>Serial</th><th>Workorder</th>`,t+=`</tr></thead>
|
|
46
|
+
<tbody>
|
|
47
|
+
`;for(let n of D.of(e).sortBy({desc:e=>e.time.getTime()}))t+=`<tr>`,t+=`<td>`+n.time.toLocaleString()+`</td>`,t+=`<td>`+n.part+`</td>`,t+=`<td>`+n.inspType+`</td>`,t+=`<td>`+(n.serial||``)+`</td>`,t+=`<td>`+(n.workorder||``)+`</td>`,t+=`</tr>
|
|
48
|
+
`;return t+=`</tbody>
|
|
49
|
+
</table>`,t}function Ch(e){Je(Sh(e))}var wh=class{constructor(e,t){this.unique=e,this.name=t}compare(e){let t=this.unique.localeCompare(e.unique);return t===0?this.name.localeCompare(e.name):t}hash(){return ve(this.unique,this.name)}toString(){return`{unique: ${this.unique}}, name: ${this.name}}`}},Th=class{constructor(e,t){this.from=e,this.to=t}compare(e){let t=this.from.compare(e.from);return t===0?this.to.compare(e.to):t}hash(){return ve(this.from,this.to)}toString(){return`{from: ${this.from.toString()}}, to: ${this.to.toString()}}`}};function Eh(e,t,n){let r=``,i=new wh(``,`raw`),a=[];for(let t of e)for(let e of t.stops){let n=`P`+t.pallet+`,M`+e.stationNum.toString();r+=`->`+n;let o=new wh(r,n);a.push(new Th(i,o)),i=o}return t&&n!==void 0?n?a.push(new Th(i,new wh(`@@success`,`success`))):a.push(new Th(i,new wh(`@@failed`,`failed`))):a.push(new Th(i,new wh(`@@uninspected`,`uninspected`))),a}function Dh(e){let t=D.of(e).filter(e=>e.result.type===kl.Completed).toRMap(e=>[e.materialID,e.result.type===kl.Completed&&e.result.success]),n=D.of(e).flatMap(e=>e.result.type===kl.Triggered?Eh(e.result.actualPath,e.result.toInspect,t.get(e.materialID)??!1):[]),r=n.flatMap(e=>[e.from,e.to]).distinctBy(e=>e).map((e,t)=>({idx:t,node:e})),i=r.map(e=>({unique:e.node.unique,name:e.node.name})).toMutableArray(),a=r.toHashMap(e=>[e.node,e.idx],e=>e);return{nodes:i,links:n.toHashMap(e=>[e,1],(e,t)=>e+t).toLazySeq().map(([e,t])=>({source:a.get(e.from),target:a.get(e.to),value:t})).toMutableArray()}}var Oh=_r(w,{shouldForwardProp:e=>e!==`expand`})(({expand:e})=>({width:e?`100%`:void 0}));function kh({open:e}){let t=j(e);return(0,Y.jsx)(S,{title:`Filter`,enterDelay:300,children:(0,Y.jsx)(C,{onClick:()=>t(!0),size:`small`,children:(0,Y.jsx)(yt,{})})})}function Ah(e){let t=e.copyToClipboardRows;return(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[e.columns.map(t=>(0,Y.jsxs)(Oh,{align:t.numeric?`right`:`left`,expand:t.expanded,sortDirection:e.sort.orderBy===t.id&&e.sort.order,children:[(0,Y.jsx)(S,{title:`Sort`,placement:t.numeric?`bottom-end`:`bottom-start`,enterDelay:300,children:(0,Y.jsx)(fn,{active:e.sort.orderBy===t.id,direction:e.sort.order,onClick:()=>e.sort.handleRequestSort(t.id),children:t.label})}),t.openFilterDialog?(0,Y.jsx)(kh,{open:t.openFilterDialog}):void 0]},t.id)),e.showDetailsCol?(0,Y.jsx)(Oh,{padding:`checkbox`,children:t?(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},onClick:()=>Vh(e.columns,t),size:`large`,children:(0,Y.jsx)(ct,{})})}):void 0}):void 0]})})}var jh=new Intl.DateTimeFormat([],{year:`numeric`,month:`short`,day:`numeric`}),Mh=new Intl.DateTimeFormat([],{year:`numeric`,month:`long`}),Nh=_r(Un)(({theme:e})=>({width:`350px`,"& .react-calendar__month-view__weekdays":{textAlign:`center`,textTransform:`uppercase`,fontWeight:`bold`},"& .react-calendar__tile":{textAlign:`center`,padding:`.75em .5em`,margin:0,border:0,background:`none`,outline:`none`,cursor:`pointer`,"&:hover":{backgroundColor:`rgb(230, 230, 230)`},"&--active":{backgroundColor:e.palette.primary.light,"&:hover":{backgroundColor:e.palette.primary.dark}}},"&.react-calendar--selectRange .react-calendar__tile--hover":{backgroundColor:`rgb(230, 230, 230)`}}));function Ph(e){let[t,n]=(0,K.useState)(!1),r=e.zoom.current_date_zoom?e.zoom.current_date_zoom.start:e.zoom.default_date_range[0],i=P(e.zoom.current_date_zoom?e.zoom.current_date_zoom.end:e.zoom.default_date_range[1],-1);function a(t){e.zoom.set_date_zoom_range({start:t[0],end:P(t[1],1)}),n(!1)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[jh.format(e.zoom.current_date_zoom?.start??e.zoom.default_date_range[0]),` `,`- `,jh.format(e.zoom.current_date_zoom?.end??e.zoom.default_date_range[1])]}),(0,Y.jsx)(S,{title:`Zoom To Date Range`,children:(0,Y.jsx)(C,{onClick:()=>n(!0),size:`large`,children:(0,Y.jsx)(Sn,{})})}),(0,Y.jsx)(S,{title:`Reset Date Range`,children:(0,Y.jsx)(C,{onClick:()=>e.zoom.set_date_zoom_range(void 0),size:`large`,children:(0,Y.jsx)(Pn,{})})}),(0,Y.jsxs)(I,{open:t,onClose:()=>n(!1),children:[(0,Y.jsxs)($n,{children:[`Select Date Range `,Mh.format(e.zoom.default_date_range[0])]}),(0,Y.jsx)(M,{children:(0,Y.jsx)(Nh,{minDate:e.zoom.default_date_range[0],maxDate:e.zoom.default_date_range[1],calendarType:`gregory`,selectRange:!0,showNavigation:!1,showNeighboringMonth:!1,value:[r,i],onChange:e=>{Array.isArray(e)&&e[0]instanceof Date&&e[1]instanceof Date&&a([e[0],e[1]])}})}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{onClick:()=>n(!1),children:`Close`})})]})]})}var Fh=(0,K.memo)(function({zoom:e,tpage:t,count:n}){let r;return e&&e.type===`Last30Days`?r=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{title:`Last 24 hours`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(1),style:{color:`rgba(0, 0, 0, 0.54)`},children:`24h`})}),(0,Y.jsx)(S,{title:`Last 2 days`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(2),style:{color:`rgba(0, 0, 0, 0.54)`},children:`2d`})}),(0,Y.jsx)(S,{title:`Last 3 days`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(3),style:{color:`rgba(0, 0, 0, 0.54)`},children:`3d`})}),(0,Y.jsx)(S,{title:`Last 4 days`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(4),style:{color:`rgba(0, 0, 0, 0.54)`},children:`4d`})}),(0,Y.jsx)(S,{title:`Last 5 days`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(5),style:{color:`rgba(0, 0, 0, 0.54)`},children:`5d`})}),(0,Y.jsx)(S,{title:`Last 6 days`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(6),style:{color:`rgba(0, 0, 0, 0.54)`},children:`6d`})}),(0,Y.jsx)(S,{title:`Last 1 week`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(7),style:{color:`rgba(0, 0, 0, 0.54)`},children:`1w`})}),(0,Y.jsx)(S,{title:`Last 2 weeks`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(14),style:{color:`rgba(0, 0, 0, 0.54)`},children:`2w`})}),(0,Y.jsx)(S,{title:`Last 3 weeks`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(21),style:{color:`rgba(0, 0, 0, 0.54)`},children:`3w`})}),(0,Y.jsx)(S,{title:`Last 30 days`,children:(0,Y.jsx)(z,{onClick:()=>e.set_days_back(null),style:{color:`rgba(0, 0, 0, 0.54)`},children:`30d`})})]}):e&&e.type===`ZoomIntoRange`?r=(0,Y.jsx)(Ph,{zoom:e}):e&&e.type===`ExtendDays`&&(r=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{title:`Extend 1 day previous`,children:(0,Y.jsx)(C,{onClick:()=>e.extend(-1),size:`large`,children:(0,Y.jsx)(dr,{})})}),(0,Y.jsx)(b,{variant:`caption`,children:e.curStart.toLocaleDateString()+` to `+e.curEnd.toLocaleDateString()}),(0,Y.jsx)(S,{title:`Extend 1 day`,children:(0,Y.jsx)(C,{onClick:()=>e.extend(1),size:`large`,children:(0,Y.jsx)(tt,{})})})]})),(0,Y.jsxs)(cn,{children:[(0,Y.jsx)(b,{color:`textSecondary`,variant:`caption`,children:`Rows per page:`}),(0,Y.jsx)(O,{style:{marginLeft:8,marginRight:`1em`},value:t.rowsPerPage,SelectDisplayProps:{style:{color:`rgba(0, 0, 0, 0.54)`}},input:(0,Y.jsx)(Xe,{}),onChange:e=>{t.setRowsPerPage(e.target.value);let r=Math.ceil(n/e.target.value)-1;t.page>r&&t.setPage(r)},children:[10,15,20,50].map(e=>(0,Y.jsx)(L,{value:e,children:e},e))}),(0,Y.jsx)(b,{color:`textSecondary`,variant:`caption`,children:`${n===0?0:t.page*t.rowsPerPage+1}-${Math.min(n,(t.page+1)*t.rowsPerPage)} of ${n}`}),(0,Y.jsx)(C,{onClick:()=>t.setPage(0),disabled:t.page===0,"aria-label":`First Page`,size:`large`,children:(0,Y.jsx)(xe,{})}),(0,Y.jsx)(C,{onClick:()=>t.setPage(t.page-1),disabled:t.page===0,"aria-label":`Previous Page`,size:`large`,children:(0,Y.jsx)(vr,{})}),(0,Y.jsx)(C,{onClick:()=>t.setPage(t.page+1),disabled:t.page>=Math.ceil(n/t.rowsPerPage)-1,"aria-label":`Next Page`,size:`large`,children:(0,Y.jsx)(Ze,{})}),(0,Y.jsx)(C,{onClick:()=>t.setPage(Math.max(0,Math.ceil(n/t.rowsPerPage)-1)),disabled:t.page>=Math.ceil(n/t.rowsPerPage)-1,"aria-label":`Last Page`,size:`large`,children:(0,Y.jsx)(_e,{})}),e?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{style:{flexGrow:1}}),r]}):void 0]})}),Ih=class extends K.PureComponent{render(){let e=this.props.onClickDetails,t=[...this.props.pageData],n=this.props.rowsPerPage===void 0?0:Math.max(0,this.props.rowsPerPage-t.length);return(0,Y.jsxs)(ae,{children:[t.map((t,n)=>(0,Y.jsxs)(o,{children:[this.props.columns.map(e=>(0,Y.jsx)(Oh,{align:e.numeric?`right`:`left`,expand:e.expanded,children:e.Cell?(0,Y.jsx)(e.Cell,{row:t}):e.getDisplay(t)},e.id)),e?(0,Y.jsx)(Oh,{padding:`checkbox`,children:(0,Y.jsx)(C,{onClick:n=>e(n,t),size:`large`,children:(0,Y.jsx)(Le,{})})}):void 0]},n)),n>0?(0,Y.jsx)(o,{style:{height:53*n},children:(0,Y.jsx)(w,{colSpan:this.props.columns.length+ +!!this.props.onClickDetails,style:{textAlign:`center`},children:t.length===0?this.props.emptyMessage:void 0})}):void 0]})}};function Lh(e){let[t,n]=(0,K.useState)(void 0);return(0,K.useMemo)(()=>{let r;return r=e.type===`Last30`?{type:`Last30Days`,set_days_back:e=>{if(e){let t=new Date;n({start:P(t,-e),end:er(t,1)})}else n(void 0)}}:{type:`ZoomIntoRange`,default_date_range:[e.month,Vt(e.month,1)],current_date_zoom:t,set_date_zoom_range:n},{zoom:r,zoomRange:t}},[e,t,n])}function Rh(){let[e,t]=(0,K.useState)(0),[n,r]=(0,K.useState)(10);return(0,K.useMemo)(()=>({page:e,setPage:t,rowsPerPage:n,setRowsPerPage:r}),[e,t,n,r])}function zh(e,t,n){let[r,i]=(0,K.useState)(e),[a,o]=(0,K.useState)(n??`asc`);return(0,K.useMemo)(()=>{function e(e){r===e?o(a===`asc`?`desc`:`asc`):(i(e),o(`asc`))}let n={asc:t[0].getForSort??t[0].getDisplay};for(let e of t)e.id===r&&a===`asc`?n={asc:e.getForSort??e.getDisplay}:e.id===r&&(n={desc:e.getForSort??e.getDisplay});return{orderBy:r,order:a,sortOn:n,handleRequestSort:e}},[r,i,a,o,t])}function Bh(e,t){let n=`<table>
|
|
50
|
+
<thead><tr>`;for(let t of e)t.ignoreDuringExport||(n+=`<th>`+t.label+`</th>`);n+=`</tr></thead>
|
|
51
|
+
<tbody>
|
|
52
|
+
`;for(let r of t){n+=`<tr>`;for(let t of e)if(!t.ignoreDuringExport){let e=t.getForExport?t.getForExport(r):t.getDisplay(r);n+=`<td>`+e+`</td>`}n+=`</tr>
|
|
53
|
+
`}return n+=`</tbody>
|
|
54
|
+
</table>`,n}function Vh(e,t){Je(Bh(e,t))}var Hh=[{id:0,numeric:!1,label:`Date`,getDisplay:e=>e.time.toLocaleString(),getForSort:e=>e.time.getTime()},{id:1,numeric:!1,label:`Serial`,getDisplay:e=>e.serial||``},{id:2,numeric:!1,label:`Workorder`,getDisplay:e=>e.workorder||``},{id:3,numeric:!1,label:`Inspected`,getDisplay:e=>e.toInspect?`inspected`:``},{id:4,numeric:!1,label:`Failed`,getDisplay:e=>e.failed?`failed`:``}];function Uh(e,t,n){let[r,i]=(0,K.useState)(void 0),a;return e&&e===`Last30Days`?a={type:`Last30Days`,set_days_back:e=>{if(e){let t=new Date;i({start:P(t,-e),end:er(t,1)})}else i(void 0)}}:e&&e===`ZoomIntoRange`?a={type:`ZoomIntoRange`,default_date_range:n,current_date_zoom:r,set_date_zoom_range:i}:e&&t&&e===`ExtendDays`&&(a={type:`ExtendDays`,curStart:n[0],curEnd:n[1],extend:t}),{zoom:a,zoomRange:r}}var Wh=(0,K.memo)(function(e){let t=j(X),n=zh(0,Hh),[r,i]=(0,K.useState)(T.empty()),[a,o]=(0,K.useState)(10),[c,l]=(0,K.useState)(void 0),u=Uh(e.zoomType,e.extendDateRange,e.default_date_range),d=_h(e.points,u.zoomRange,n.sortOn),f=D.of(d).toSortedArray(([e])=>e);return(0,Y.jsx)(`div`,{style:{width:`100%`,marginTop:`1em`},children:f.map(([d,f])=>{let p=Math.min(r.get(d)??0,Math.ceil(f.material.length/a));return(0,Y.jsxs)(Ie,{expanded:d===c,onChange:(e,t)=>l(t?d:void 0),children:[(0,Y.jsxs)(s,{expandIcon:(0,Y.jsx)(St,{}),children:[(0,Y.jsx)(b,{variant:`h6`,style:{flexBasis:`33.33%`,flexShrink:0},children:d}),(0,Y.jsxs)(b,{variant:`caption`,children:[f.material.length,` total parts, `,f.failedCnt,` failed`]})]}),(0,Y.jsx)(Me,{children:(0,Y.jsxs)(`div`,{style:{width:`100%`},children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)(Ah,{columns:Hh,sort:n,showDetailsCol:!0}),(0,Y.jsx)(Ih,{columns:Hh,pageData:D.of(f.material).drop(p*a).take(a),rowsPerPage:a,onClickDetails:e.hideOpenDetailColumn?void 0:(e,n)=>t({type:`MatSummary`,summary:{materialID:n.materialID,partName:n.partName,serial:n.serial,workorderId:n.workorder}})})]}),(0,Y.jsx)(Fh,{tpage:{page:p,rowsPerPage:a,setPage:e=>i(r.set(d,e)),setRowsPerPage:o},count:f.material.length,zoom:u.zoom})]})})]},d)})})}),Gh=20,Kh=20,qh=120,Jh=20;function Yh({link:e,path:t,strokeWidth:n,setTooltip:r}){let[i,a]=(0,K.useState)(!1);if(t===null)return null;function o(t){let n=Ho(t);n!==null&&(r({left:n.x,top:n.y,data:e}),a(!0))}function s(){a(!1),r(null)}return(0,Y.jsx)(`path`,{d:t,stroke:i?we[600]:we[300],strokeWidth:n,opacity:.2,fill:`none`,onMouseMove:o,onMouseLeave:s})}function Xh({node:e}){return e.x1===void 0||e.x0===void 0||e.y1===void 0||e.y0===void 0?null:(0,Y.jsxs)(`g`,{transform:`translate(${e.x0}, ${e.y0})`,children:[(0,Y.jsx)(`rect`,{width:e.x1-e.x0,height:e.y1-e.y0,fill:we[800],opacity:.8,stroke:`none`}),(0,Y.jsx)(`text`,{x:18,y:(e.y1-e.y0)/2,children:e.name})]})}var Zh=(0,K.memo)(function({data:e,setTooltip:t,parentHeight:n,parentWidth:r}){let{nodes:i,links:a}=(0,K.useMemo)(()=>{let t=Dh(e);if(t.nodes.length===0)return{nodes:[],links:[]};let i=hn().nodeWidth(10).nodePadding(10).nodeAlign(Zn).extent([[Gh,Kh],[r-qh,n-Jh-Kh]])({nodes:t.nodes,links:t.links});return{nodes:i.nodes,links:i.links.flatMap(e=>typeof e.source==`object`&&typeof e.target==`object`&&e.width!==void 0?[{...e,source:e.source,target:e.target,width:e.width}]:[])}},[e,r,n]),o=Ft();return(0,Y.jsxs)(`svg`,{width:r,height:n,children:[(0,Y.jsx)(`g`,{children:i.map((e,t)=>(0,Y.jsx)(Xh,{node:e},t))}),(0,Y.jsx)(`g`,{children:a.map((e,n)=>(0,Y.jsx)(Yh,{link:e,path:o(e),strokeWidth:Math.max(e.width??1,1),setTooltip:t},n))})]})});function Qh({tooltip:e}){return e===null?null:(0,Y.jsxs)(`div`,{children:[e.data.source.name,` ➞ `,e.data.target.name,`: `,e.data.value,` parts`]})}var $h=(0,K.memo)(function({data:e}){let t=(0,K.useMemo)(()=>F(null),[]),n=j(t);return(0,Y.jsx)(`div`,{style:{position:`relative`},children:(0,Y.jsx)(qo,{sx:{height:{xs:`calc(100vh - 230px)`,md:`calc(100vh - 182px)`,xl:`calc(100vh - 130px)`},width:`100%`},chart:({height:t,width:r})=>(0,Y.jsx)(Zh,{data:e,setTooltip:n,parentHeight:t,parentWidth:r}),tooltipAtom:t,TooltipContent:Qh})})}),eg=lt(e=>e(Mc)?`aaa`:void 0),tg=lt(e=>e(Mc)?`CMM`:void 0),ng=F(!1);function rg(e){let[t,n]=A(eg),[r,i]=A(tg),[a,o]=A(ng),s,c=e.restrictToPart||t;c&&r&&(s=e.inspectionlogs.get(new Al(c,r))?.valuesToLazySeq()??[]);let l=e.inspectionlogs.keysToLazySeq().map(e=>e.part).distinct().toSortedArray(e=>e),u=e.inspectionlogs.keysToLazySeq().map(e=>e.inspType).distinct().toSortedArray(e=>e);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[e.subtitle?(0,Y.jsx)(b,{variant:`subtitle1`,children:e.subtitle}):void 0,(0,Y.jsx)(B,{sx:{flexGrow:1}}),e.onlyTable?void 0:(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,value:a?`table`:`sankey`,onChange:e=>o(e.target.value===`table`),children:[(0,Y.jsx)(L,{value:`sankey`,children:`Sankey`},`sankey`),(0,Y.jsx)(L,{value:`table`,children:`Table`},`table`)]})}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{name:`inspection-sankey-select-type`,autoWidth:!0,displayEmpty:!0,style:{marginRight:`1em`,marginLeft:`1em`},value:r||``,onChange:e=>i(e.target.value),children:[r?void 0:(0,Y.jsx)(L,{value:``,children:(0,Y.jsx)(`em`,{children:`Select Inspection Type`})},0),u.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})}),e.restrictToPart===void 0?(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{name:`inspection-sankey-select-part`,autoWidth:!0,displayEmpty:!0,value:c||``,onChange:e=>n(e.target.value),children:[c?void 0:(0,Y.jsx)(L,{value:``,children:(0,Y.jsx)(`em`,{children:`Select Part`})},0),l.map(e=>(0,Y.jsx)(L,{value:e,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e,size:30}),(0,Y.jsx)(`span`,{style:{marginRight:`1em`},children:e})]})},e))]})}):void 0,s?(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:()=>s?xh(c||``,r||``,s):void 0,style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,children:(0,Y.jsx)(ct,{})})}):void 0]}),(0,Y.jsx)(`main`,{children:s?a||e.onlyTable?(0,Y.jsx)(Wh,{zoomType:e.zoomType,points:s,default_date_range:e.default_date_range,extendDateRange:e.extendDateRange,hideOpenDetailColumn:e.hideOpenDetailColumn}):(0,Y.jsx)($h,{data:s}):void 0})]})}var ig=F(null),ag=F(async(e,{signal:t})=>{let n=e(ig);if(n==null||Vi===void 0)return T.empty();let r=await Vi.get(n.curStart,n.curEnd,t);return D.of(r).flatMap(Fl).filter(e=>e.key.part===n.part).toLookupMap(e=>e.key,e=>e.entry.cntr,e=>e.entry)}),og=hr(ag,e=>e??T.empty()),sg=F(async e=>{let t=e(ig);if(t==null)return T.empty();let n=[];for(let e of Wi)n.push(await e.get(t.curStart,t.curEnd));return D.of(n).flatMap(e=>e).flatMap(Fl).filter(e=>e.key.part===t.part).toLookupMap(e=>e.key,e=>e.entry.cntr,e=>e.entry)}),cg=hr(sg,e=>e??T.empty()),lg=F(e=>T.union((e,t)=>e.union(t),e(og),e(cg)));function ug(e){return t=>t===null?null:e<0?{curStart:P(t.curStart,e),curEnd:t.curEnd,part:t.part}:{curStart:t.curStart,curEnd:P(t.curEnd,e),part:t.part}}var dg=[{id:0,numeric:!1,label:`Date`,getDisplay:e=>e.time.toLocaleString(),getForSort:e=>e.time.getTime()},{id:1,numeric:!1,label:`Part`,getDisplay:e=>e.part},{id:2,numeric:!1,label:`Inspection`,getDisplay:e=>e.inspType},{id:3,numeric:!1,label:`Serial`,getDisplay:e=>e.serial||``},{id:4,numeric:!1,label:`Workorder`,getDisplay:e=>e.workorder||``}];function fg(e){let t=Ic(),n=zh(0,dg),r=Rh(),i=j(X),a=Math.min(r.page,Math.ceil(e.failed.length/r.rowsPerPage)),o=D.of(e.failed).sortBy(n.sortOn);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)(Ah,{columns:dg,sort:n,showDetailsCol:!t}),(0,Y.jsx)(Ih,{columns:dg,pageData:o.drop(a*r.rowsPerPage).take(r.rowsPerPage),rowsPerPage:r.rowsPerPage,onClickDetails:t?void 0:(e,t)=>{i({type:`MatSummary`,summary:{materialID:t.materialID,partName:t.part,serial:t.serial,workorderId:t.workorder}})}})]}),(0,Y.jsx)(Fh,{tpage:{...r,page:a},count:e.failed.length})]})}function pg(){let e=r(Ml),t=(0,K.useMemo)(()=>{let t=k();return vh(D.of(e).flatMap(([,e])=>e.valuesToLazySeq()),P(t,-4),P(t,1))},[e]);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsx)(b,{variant:`subtitle1`,children:`Inspections marked as failed in the last 5 days`}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},onClick:()=>Ch(t),size:`large`,children:(0,Y.jsx)(ct,{})})})]}),(0,Y.jsx)(fg,{failed:t})]})}function mg(){let e=Ic(),t=j(X),[n,r]=(0,K.useState)(e?`00000000i9`:``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null);function c(){n&&n!==``&&(a(!0),s(null),Vi.materialForSerial(n).then(e=>{let i=D.of(e).maxBy(e=>e.materialID);i?(t({type:`MatDetails`,details:i}),r(``),s(null)):s(`No material found with serial `+n)}).catch(e=>s(Dd(e))).finally(()=>a(!1)))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(E,{direction:`row`,spacing:2,sx:{alignItems:`center`,marginLeft:`auto`,marginRight:`auto`},children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(_,{label:n===``?`Serial`:`Serial (press enter)`,value:n,onChange:e=>r(e.target.value),onKeyPress:e=>{e.key===`Enter`&&n!==``&&(e.preventDefault(),c())}})}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(z,{variant:`contained`,color:`secondary`,disabled:n===``||i,onClick:c,children:i?(0,Y.jsxs)(E,{direction:`row`,spacing:2,children:[(0,Y.jsx)(pn,{}),` Searching`]}):(0,Y.jsx)(Y.Fragment,{children:`Lookup`})})})]}),o&&o!==``?(0,Y.jsx)(`div`,{children:o}):void 0]})}function hg(e){let t=e[0];if(t===void 0)return k();let n=t.endUTC;for(let t of e)t.type===V.MachineCycle&&(n=t.endUTC);return n}function gg(){let e=r(Zs),t=r(dc);return e?(0,Y.jsx)(uf,{partName:e.partName,serial:e.serial,subtitle:`Path `+gh(yh(t))+` at `+hg(t).toLocaleString()}):(0,Y.jsx)(`div`,{children:`Serial Details`})}function _g({setStep:e}){let t=r(Zs),n=r(dc),i=j(ig),a=j(X);return(0,Y.jsxs)(E,{direction:`row`,spacing:2,sx:{mt:`2em`},children:[t?(0,Y.jsx)(z,{variant:`contained`,color:`secondary`,onClick:()=>{let r=hg(n);i({part:t?.partName??``,curStart:Rt(P(r,-5)),curEnd:Gt(P(r,5))}),e(2)},children:`Lookup Similar Paths`}):void 0,(0,Y.jsx)(z,{variant:`contained`,style:{marginLeft:`2em`},onClick:()=>{a(null),i(null),e(0)},children:`Reset`})]})}function vg(e){let t=r(Xs),n=r(dc),[i,a]=A(ig),o=r(lg),s=j(X);if(t===null)return null;function c(e){a(ug(e))}return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(rg,{inspectionlogs:o,restrictToPart:t.partName,subtitle:`Paths for `+t.partName+` around `+hg(n).toLocaleString(),default_date_range:i?[i.curStart,i.curEnd]:[],zoomType:i?`ExtendDays`:void 0,extendDateRange:c,hideOpenDetailColumn:!0,onlyTable:!0}),(0,Y.jsx)(z,{variant:`contained`,style:{marginTop:`2em`},onClick:()=>{s(null),a(null),e.setStep(0)},children:`Reset`})]})}function yg(){let[e,t]=(0,K.useState)(0),n=r(X),i=e;return i===0&&n&&(i=1),(0,Y.jsxs)(E,{direction:`column`,spacing:2,children:[(0,Y.jsxs)(Ye,{activeStep:i,orientation:`horizontal`,children:[(0,Y.jsx)(u,{children:(0,Y.jsx)(gr,{children:`Select Material`})}),(0,Y.jsx)(u,{children:(0,Y.jsx)(gr,{children:(0,Y.jsx)(gg,{})})}),(0,Y.jsx)(u,{children:(0,Y.jsx)(gr,{children:`Lookup similar paths`})})]}),i===0?(0,Y.jsxs)(E,{direction:`column`,spacing:4,children:[(0,Y.jsx)(b,{children:`Enter a serial number, scan a barcode, or click on a material in the table below to see details.`}),(0,Y.jsx)(mg,{}),(0,Y.jsx)(pg,{})]}):i===1?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(jd,{fallback:(0,Y.jsx)(yf,{}),children:(0,Y.jsx)(_f,{})}),(0,Y.jsx)(_g,{setStep:t})]}):i===2?(0,Y.jsx)(jd,{children:(0,Y.jsx)(vg,{setStep:t})}):void 0]})}function bg(){return Q(`Quality Material`),(0,Y.jsx)(`main`,{style:{padding:`24px`},children:(0,Y.jsx)(yg,{})})}var xg=(0,K.memo)(function(){Q(`Paths`);let e=r(Ml),t=(0,K.useMemo)(()=>{let t=k(),n=P(t,-6),r=P(t,1);return e.collectValues(e=>{let t=e.filter(e=>e.time>=n&&e.time<=r);return t.size===0?null:t})},[e]);return(0,Y.jsx)(rg,{inspectionlogs:t,default_date_range:[P(k(),-6),P(k(),1)],subtitle:`Paths from the last 7 days`})}),Sg=F(!1);function Cg(e){let t=``;return e.comments&&e.comments.length>0&&(t=`; `+e.comments[e.comments.length-1].comment),`Due ${e.dueDate.toLocaleDateString()}; Completed ${e.completedQuantity} of ${e.plannedQuantity}${t}`}function wg({work:e}){return e.plannedQuantity<=e.completedQuantity?(0,Y.jsx)(qt,{}):(0,Y.jsx)(g,{})}function Tg(){let[e,t]=(0,K.useState)(null),n=r(Xs),[i]=yc(),a=j(Sg);return(0,Y.jsx)(_,{sx:{mt:`5px`},label:e===null||e===``?`Workorder`:`Workorder (press enter)`,value:e??``,onChange:e=>t(e.target.value),onKeyPress:t=>{t.key===`Enter`&&n&&e&&e!==``&&(t.preventDefault(),i(n,e),a(!1))}})}function Eg(){let e=r(Xs),t=r(mc),i=j(Sg),[a]=yc();return(0,Y.jsx)(Wt,{children:(t??[]).map(t=>(0,Y.jsx)(xt,{children:(0,Y.jsxs)(n,{onClick:()=>{e&&a(e,t.workorderId),i(!1)},children:[(0,Y.jsx)(mt,{children:(0,Y.jsx)(wg,{work:t})}),(0,Y.jsx)(_t,{primary:t.workorderId,secondary:Cg(t)})]})},t.workorderId))})}var Dg=(0,K.memo)(function(){let[e,t]=A(Sg),n;return n=e?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($n,{children:`Select Workorder`}),(0,Y.jsx)(M,{children:(0,Y.jsxs)(jd,{children:[(0,Y.jsx)(Tg,{}),(0,Y.jsx)(Eg,{})]})}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{onClick:()=>t(!1),color:`primary`,children:`Cancel`})})]}):(0,Y.jsx)(`p`,{children:`None`}),(0,Y.jsx)(I,{open:e,onClose:()=>t(!1),maxWidth:`md`,children:n})}),Og=F(!1);function kg(){let[e,t]=(0,K.useState)(null),n=r(Xs),[i]=gc(),a=j(Og);return(0,Y.jsx)(_,{sx:{mt:`5px`},label:e===``||e===null?`Inspection Type`:`Inspection Type (press enter)`,value:e??``,onChange:e=>t(e.target.value),onKeyPress:t=>{t.key===`Enter`&&n&&e&&e!==``&&(t.preventDefault(),i({mat:n,inspType:e,inspect:!0}),a(!1))}})}function Ag(){let e=r(Xs),[t]=gc(),i=r($c),a=D.of(i).sortBy(e=>e),o=j(Og);return e===null?null:(0,Y.jsx)(Wt,{children:a.map(r=>(0,Y.jsx)(xt,{children:(0,Y.jsxs)(n,{onClick:()=>{t({mat:e,inspType:r,inspect:!0}),o(!1)},children:[(0,Y.jsx)(mt,{children:(0,Y.jsx)(at,{})}),(0,Y.jsx)(_t,{primary:r})]})},r))})}function jg(){let e=j(Og),t=r(tc);return t===null||t.materialID<0?null:(0,Y.jsx)(z,{color:`primary`,onClick:()=>e(!0),children:`Signal Inspection`})}var Mg=(0,K.memo)(function(){let[e,t]=A(Og),n;return n=e?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($n,{children:`Select Inspection Type`}),(0,Y.jsx)(M,{children:(0,Y.jsxs)(jd,{children:[(0,Y.jsx)(kg,{}),(0,Y.jsx)(Ag,{})]})}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{onClick:()=>t(!1),color:`primary`,children:`Cancel`})})]}):(0,Y.jsx)(`p`,{children:`None`}),(0,Y.jsx)(I,{open:e,onClose:()=>t(!1),maxWidth:`md`,children:n})}),Ng=function(e){return e[e.Material=0]=`Material`,e[e.FreeMaterialZone=1]=`FreeMaterialZone`,e[e.CompletedCollapsedMaterialZone=2]=`CompletedCollapsedMaterialZone`,e[e.CompletedExpandedMaterialZone=3]=`CompletedExpandedMaterialZone`,e[e.PalletFaceZone=4]=`PalletFaceZone`,e[e.QueueZone=5]=`QueueZone`,e[e.BasketZone=6]=`BasketZone`,e[e.BasketSlotZone=7]=`BasketSlotZone`,e}({});function Pg(e){switch(e.type){case 0:return`Material-`+(e.identifier??(e.material?.materialID??-1).toString());case 1:return`FreeMaterialZone`;case 2:return`CompletedCollapsedMaterialZone`;case 3:return`CompletedExpandedMaterialZone`;case 4:return`PalletFaceZone-${e.palletNum}-${e.face}`;case 5:return`QueueZone-`+e.queue;case 6:return`BasketZone-`+e.basketId.toString();case 7:return`BasketSlotZone-${e.basketId}-${e.slot}`}}function Fg(e){switch(e.type){case 0:return[e.type,e.material,e.identifier];case 1:case 2:case 3:return[e.type,null];case 4:return[e.type,e.palletNum,e.face];case 5:return[e.type,e.queue];case 6:return[e.type,e.basketId];case 7:return[e.type,e.basketId,e.slot]}}function Ig(e,t){return`${e??``}:${t}`}function Lg(e){let t,n,r=new Map,i=new Map,a=new Map,o=new Map,s=[];for(let c of e.values())switch(c.type){case 1:t=c.elem;break;case 2:case 3:n=c.elem;break;case 4:r.set(Ig(c.palletNum,c.face),c.elem);break;case 5:i.set(c.queue,c.elem);break;case 6:a.set(c.basketId,c.elem);break;case 7:o.set(`${c.basketId}:${c.slot}`,c.elem);break;case 0:c.material&&s.push([c.elem,c.material])}return{freeMaterial:t,completedMaterial:n,faces:r,queues:i,baskets:a,basketSlots:o,material:s}}function Rg(e){return e.location.type===H.InBasket&&e.location.basketId!==void 0&&e.location.basketSlot!==void 0?`${e.location.basketId}:${e.location.basketSlot}`:null}function zg(e,t){let n=Math.min(e.left,t.left),r=Math.min(e.top,t.top),i=Math.max(e.right,t.right),a=Math.max(e.bottom,t.bottom);return{left:n,top:r,right:i,bottom:a,width:i-n,height:a-r}}function Bg(e){let t=D.of(e).sortBy(([e])=>e.left,([e])=>e.top).toRArray(),n=D.of(t).collect(([e,t])=>{let n=Rg(t);return n===null?null:[n,e]}).buildHashMap(([e])=>e,(e,[,t])=>e?zg(e,t):t),r=new Set;return t.flatMap(([e,t])=>{let i=Rg(t);return i===null?[[e,t]]:r.has(i)?[]:(r.add(i),[[n.get(i)??e,t]])})}function Vg(e,t){if(!e)return[];let n=Lg(t);if(!n.completedMaterial)return[];let r=[],i=[],a=new Map,o=new Map,s=new Map,c=new Map,l=0,u=Bg(n.material),d=D.of(u).filter(([,e])=>e.action.type===U.LoadingToBasket&&Rg(e)!==`${e.action.loadToBasketId}:${e.action.loadToBasketSlot}`).groupBy(([,e])=>`${e.action.loadToBasketId}:${e.action.loadToBasketSlot}`).toHashMap(([e,t])=>[e,t.length]);for(let[t,f]of u)switch(f.action.type){case U.UnloadToCompletedMaterial:case U.UnloadToInProcess:if(f.action.unloadToBasketId){let i=n.baskets.get(f.action.unloadToBasketId),a=s.get(f.action.unloadToBasketId)??0;s.set(f.action.unloadToBasketId,a+1),r.push({fromX:t.left,fromY:t.top+t.height/2,toX:i===void 0?e.left+2:i.right-5,toY:i===void 0?t.top+t.height/2:i.top+20*(a+1),curveDirection:1})}else if(f.action.type===U.UnloadToCompletedMaterial&&(!f.action.unloadIntoQueue||f.action.unloadIntoQueue===``))r.push({fromX:t.right,fromY:t.top+t.height/2,toY:t.top+t.height/2,toX:n.completedMaterial?n.completedMaterial.left+2:e.right-10,curveDirection:1});else{let i,a;f.action.unloadIntoQueue?(i=n.queues.get(f.action.unloadIntoQueue),a=o.get(f.action.unloadIntoQueue)??0,o.set(f.action.unloadIntoQueue,a+1)):(i=n.freeMaterial,a=l,l+=1),r.push({fromX:t.left,fromY:t.top+t.height/2,toX:i===void 0?e.left+2:i.right-5,toY:i===void 0?t.top+t.height/2:i.top+20*(a+1),curveDirection:1})}break;case U.Loading:if(f.action.loadFromBasketId&&f.action.loadOntoFace){let e=Ig(f.action.loadOntoPalletNum,f.action.loadOntoFace),i=n.faces.get(e);if(i!==void 0){let n=a.get(e)??0;a.set(e,n+1),r.push({fromX:t.right,fromY:t.top+t.height/2,toX:i.left+20,toY:i.top+50+20*n,curveDirection:-1})}}else if(f.action.loadFromBasketId){let i=n.baskets.get(f.action.loadFromBasketId),a=s.get(f.action.loadFromBasketId)??0;s.set(f.action.loadFromBasketId,a+1),r.push({fromX:t.right,fromY:t.top+t.height/2,toX:i===void 0?e.right-10:i.left+20,toY:i===void 0?t.top+t.height/2:i.top+50+20*a,curveDirection:-1})}else if(f.action.loadOntoFace){if(f.location.type===H.OnPallet){if(f.location.palletNum===f.action.loadOntoPalletNum&&f.location.face===f.action.loadOntoFace)r.push({fromX:t.right,fromY:t.top+t.height*3/4,toX:t.left+t.width*7/8,toY:t.bottom,curveDirection:-1});else{let e=n.faces.get(Ig(f.action.loadOntoPalletNum,f.action.loadOntoFace));e&&(f.action.loadOntoFace<(f.location.face??0)?r.push({fromX:t.left,fromY:t.top+t.height/2,toX:t.left,toY:e.bottom+20,curveDirection:-1}):r.push({fromX:t.left,fromY:t.top+t.height/2,toX:t.left,toY:e.top-20,curveDirection:1}))}}else{let e=Ig(f.action.loadOntoPalletNum,f.action.loadOntoFace),i=n.faces.get(e);if(i!==void 0){let n=a.get(e)??0;a.set(e,n+1),r.push({fromX:t.right,fromY:t.top+t.height/2,toX:i.left+20,toY:i.top+50+20*n,curveDirection:-1})}}}break;case U.LoadingToBasket:{let a=f.action.loadToBasketId;if(a===void 0)break;if(f.location.type===H.InBasket&&f.location.basketId===a&&f.location.basketSlot===f.action.loadToBasketSlot){i.push({type:`loop`,centerX:t.left-20-e.left,centerY:t.top+t.height/2-e.top,radius:12});break}let o=`${a}:${f.action.loadToBasketSlot}`,l=f.action.loadToBasketSlot===void 0?void 0:n.basketSlots.get(o);if(l!==void 0){let e=c.get(o)??0;c.set(o,e+1),r.push({fromX:t.right,fromY:t.top+t.height/2,toX:l.left-20,toY:l.top+l.height*(e+1)/((d.get(o)??1)+1),curveDirection:-1});break}let u=n.baskets.get(a);if(u===void 0)break;let p=s.get(a)??0;s.set(a,p+1),r.push({fromX:t.right,fromY:t.top+t.height/2,toX:u.left+20,toY:u.top+50+20*p,curveDirection:-1});break}}return[...r.map(t=>({type:`curve`,fromX:t.fromX-e.left,fromY:t.fromY-e.top,toX:t.toX-e.left,toY:t.toY-e.top,curveDirection:t.curveDirection})),...i]}function Hg(e){let t=e.getBoundingClientRect();return{left:t.left+window.scrollX,top:t.top+window.scrollY,width:t.width,height:t.height,bottom:t.bottom+window.scrollY,right:t.right+window.scrollX}}function Ug(e){if(e.type===`loop`){let t=t=>{let n=t*Math.PI/180;return`${e.centerX+e.radius*Math.cos(n)} ${e.centerY+e.radius*Math.sin(n)}`};return`M ${t(120)} A ${e.radius} ${e.radius} 0 1 1 ${t(60)}`}let t=(e.fromX+e.toX)/2,n=(e.fromY+e.toY)/2,r=Math.atan2(e.toY-e.fromY,e.toX-e.fromX)+Math.PI*e.curveDirection/2,i=t+50*Math.cos(r),a=n+50*Math.sin(r);return`M${e.fromX},${e.fromY} Q ${i} ${a} ${e.toX} ${e.toY}`}var Wg=(0,K.memo)(function({container:e,arrowsWithRefs:t}){let n=r(q),[,i]=(0,K.useState)({height:window.innerHeight,width:window.innerWidth});(0,K.useEffect)(()=>{function e(){i({height:window.innerHeight,width:window.innerWidth})}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[i]);let a=Vg(e.current?Hg(e.current):null,t.collectValues(e=>e.type===Ng.Material&&e.material&&Ms(n,e.material)?null:e.elem.current?{...e,elem:Hg(e.elem.current)}:null));return(0,Y.jsx)(`g`,{children:a.map((e,t)=>(0,Y.jsx)(`path`,{"data-testid":`material-movement-arrow`,style:{fill:`none`,stroke:`rgba(0,0,0,0.15)`,strokeWidth:2},d:Ug(e),markerEnd:`url(#arrow)`},t))})}),Gg=(0,K.createContext)(void 0),Kg=(0,K.memo)(function({children:e,hideArrows:t,whiteBackground:n}){let r=(0,K.useRef)(null),[i,a]=(0,K.useState)(T.empty()),o=(0,K.useMemo)(()=>({registerNode(e,t,n){a(t&&n?r=>r.set(e,{...t,elem:n}):t=>t.delete(e))}}),[a]);return(0,Y.jsxs)(`div`,{style:{position:`relative`},children:[(0,Y.jsxs)(`svg`,{style:{position:`absolute`,pointerEvents:`none`,width:`100%`,height:`100%`,top:0,right:0,zIndex:-1,backgroundColor:n?`white`:`#F8F8F8`},children:[(0,Y.jsx)(`defs`,{children:(0,Y.jsx)(`marker`,{id:`arrow`,markerWidth:6,markerHeight:10,refX:`0`,refY:`3`,orient:`auto`,markerUnits:`strokeWidth`,children:(0,Y.jsx)(`path`,{d:`M0,0 L0,6 L5,3 z`,fill:`rgba(0,0,0,0.15)`})})}),t?void 0:(0,Y.jsx)(Wg,{container:r,arrowsWithRefs:i})]}),(0,Y.jsx)(`div`,{ref:r,children:(0,Y.jsx)(Gg.Provider,{value:o,children:e})})]})});function qg(e){let t=(0,K.useContext)(Gg);if(!t)throw Error(`useMoveMaterialArrowRef must be used within a MoveMaterialArrowContainer`);let n=(0,K.useRef)(null);return(0,K.useEffect)(()=>{let r=Pg(e);return t.registerNode(r,e,n),()=>{t.registerNode(r,null,null)}},[t,...Fg(e)]),n}function Jg({kind:e,children:t}){let n=qg(e);return(0,Y.jsx)(`div`,{ref:n,"data-move-material-identifier":Pg(e),children:t})}var Yg=45,Xg=55;function Zg(){let e=r(ya),t=r(q),n=r(ia),i=r(G),a=D.of(t.material).filter(e=>e.location.type===H.OnPallet||e.action.type===U.Loading).toRLookup(e=>e.location.palletNum??e.action.loadOntoPalletNum??0),o=D.of(t.material).filter(e=>e.location.type===H.InBasket&&e.location.basketId!==null&&e.location.basketId!==void 0||e.action.type===U.LoadingToBasket&&e.action.loadToBasketId!==null&&e.action.loadToBasketId!==void 0).toRLookup(e=>e.location.basketId??e.action.loadToBasketId??0),s=D.ofObject(t.pallets).filter(([,e])=>e.currentPalletLocation.loc===Qr.LoadUnload).toOrderedMap(([,e])=>[e.currentPalletLocation.num,{lulNum:e.currentPalletLocation.num,pal:{pallet:e,mats:a.get(e.palletNum)??[]},basket:null,staging:[],sources:[]}]),c=D.ofObject(t.pallets).filter(([,e])=>e.currentPalletLocation.loc===Qr.Machine||e.currentPalletLocation.loc===Qr.MachineQueue).map(([,e])=>e).groupBy(e=>e.currentPalletLocation.group,e=>e.currentPalletLocation.num).toLookupOrderedMap(([[e,t],n])=>e,([[e,t],n])=>t,([[e,n],r])=>{let i=r.find(e=>e.currentPalletLocation.loc===Qr.Machine),o=i?a.get(i.palletNum)??[]:null,s=r.find(e=>e.currentPalletLocation.loc===Qr.MachineQueue),c=s?a.get(s.palletNum)??[]:null,l=!0,u=c?.[0];if(u&&u.lastCompletedMachiningRouteStopIndex!==null&&u.lastCompletedMachiningRouteStopIndex!==void 0){let r=t.jobs[u.jobUnique]?.procsAndPaths?.[u.process-1]?.paths?.[u.path-1]?.stops?.[u.lastCompletedMachiningRouteStopIndex];r.stationGroup===e&&r.stationNums.includes(n)&&(l=!1)}return l?{name:e+` `+n.toString(),inbound:s?{pallet:s,mats:c??[]}:null,worktable:i?{pallet:i,mats:o??[]}:null,outbound:null}:{name:e+` `+n.toString(),inbound:null,worktable:i?{pallet:i,mats:o??[]}:null,outbound:s?{pallet:s,mats:c??[]}:null}}),l=D.ofObject(t.pallets).filter(([,e])=>e.currentPalletLocation.loc===Qr.Buffer||e.currentPalletLocation.loc===Qr.Cart).collect(([,e])=>{let t=a.get(e.palletNum);return!t||t.length===0?null:{pallet:e,mats:t}}).toOrderedMap(e=>[e.pallet.palletNum,e]),u=1,d=1,f=P(new Date(e*6e4),-7),p=n.valuesToLazySeq().filter(e=>e.routeEndUTC>f).concat(D.ofObject(t.jobs).map(([,e])=>e)).flatMap(e=>e.procsAndPaths).toRArray();for(let e of p)for(let t of(e.basketLoadStations??[]).concat(e.basketUnloadStations??[]))u=Math.max(u,t);let m=D.of(p).flatMap(e=>e.paths);for(let e of m){for(let t of e.load.concat(e.unload))u=Math.max(u,t);e.face&&(d=Math.max(d,e.face));for(let t of e.stops)c=c.alter(t.stationGroup,e=>{e??=se.empty();for(let n of t.stationNums)e=e.alter(n,e=>e||{name:t.stationGroup+` `+n.toString(),inbound:null,worktable:null,outbound:null});return e})}let h=D.ofObject(i.loadStationNames??{}).map(([e])=>parseInt(e)).toRArray(),g=h.length>0?D.of(h).concat(D.ofObject(t.baskets??{}).collect(([,e])=>e.position?.location===gi.LoadUnload||e.position?.location===gi.LoadStationStaging?e.position.locationNum??null:null)):D.ofRange(1,u+1);for(let e of g)s=s.alter(e,t=>t||{lulNum:e,pal:null,basket:null,staging:[],sources:[]});for(let e of Object.values(t.pallets))d=Math.max(d,e.numFaces);for(let e of t.material)e.location.face!==null&&e.location.face!==void 0&&(d=Math.max(d,e.location.face)),e.location.type===H.InBasket&&e.location.basketSlot!==void 0&&(d=Math.max(d,e.location.basketSlot));for(let e of Object.values(t.baskets??{}))(e.position?.location===gi.LoadUnload||e.position?.location===gi.LoadStationStaging)&&(d=Math.max(d,e.slotCount??1,...e.emptySlots??[],...e.unknownSlots??[]));let ee=se.empty();if(t.machineLocations&&t.machineLocations.length>0)for(let e of t.machineLocations){c=c.alter(e.machineGroup,t=>{if(!t||e.machineNum===void 0)return t;let n=t.delete(e.machineNum);if(n.size!==0)return n});for(let n of e.possibleLoadStations){let r=s.get(n);s=s.delete(n);let i=D.of(r?.pal?.mats??[]).toLookup(n=>{if(n.action.type===U.Machining)return`Machining`;if(n.action.type!==U.Waiting)return`Loading`;if(n.lastCompletedMachiningRouteStopIndex!==null&&n.lastCompletedMachiningRouteStopIndex!==void 0){let r=t.jobs[n.jobUnique]?.procsAndPaths?.[n.process-1]?.paths?.[n.path-1]?.stops?.[n.lastCompletedMachiningRouteStopIndex];if(!r||r.stationGroup===e.machineGroup&&r.stationNums.includes(e.machineNum))return`Loading`}return`Ready`}),a={lulNum:n,machineMoving:e.moving,machineCurrentlyAtLoad:n===e.currentLoadStation?{group:e.machineGroup,num:e.machineNum}:null,readyMats:i.get(`Ready`)??[],machiningMats:i.get(`Machining`)??[],loadingMats:i.get(`Loading`)??[]};ee=ee.set(n,a)}}let _=new Map,te=new Map,ne=new Map,v=0,y=0;for(let e of D.ofObject(t.baskets??{}).map(([,e])=>e).sortBy(e=>e.basketId)){let t={basket:e,mats:o.get(e.basketId)??[]},n=e.position;if(n===void 0)ne.set(e.basketId,t);else switch(n.location){case gi.Storage:t.mats.length>0?y+=1:v+=1;break;case gi.LoadUnload:case gi.LoadStationStaging:{let r=n.locationNum;if(r===null){ne.set(e.basketId,t);break}let i=n.location===gi.LoadUnload?te:_,a=i.get(r)??[];a.push(t),i.set(r,a);break}case gi.InTransit:ne.set(e.basketId,t)}}return s=s.mapValues(e=>{let t=D.of(te.get(e.lulNum)??[]).sortBy(e=>e.basket.position?.locationNum??0).toRArray();for(let e of t.slice(1))ne.set(e.basket.basketId,e);let n=t[0]?.basket.basketId,r=new Map,a=D.of(e.pal?.mats??t[0]?.mats??[]).filter(e=>e.location.type!==H.OnPallet&&(e.location.type!==H.InBasket||e.location.basketId!==n)).toRArray();for(let e of a)if(e.location.type===H.Free){let t=`free`,n=r.get(t)??{label:`To Load`,mats:[]};n.mats.push(e),r.set(t,n)}else if(e.action.loadFromBasketId!==null&&e.action.loadFromBasketId!==void 0){let t=`basket:${e.action.loadFromBasketId}`,n=r.get(t)??{label:`From ${eo(i.basketName)} ${e.action.loadFromBasketId}`,mats:[]};n.mats.push(e),r.set(t,n)}else if(e.location.type===H.InQueue&&e.location.currentQueue){let t=`queue:${e.location.currentQueue}`,n=r.get(t)??{label:`From ${e.location.currentQueue}`,mats:[]};n.mats.push(e),r.set(t,n)}let o=new Set(D.of(e.pal?.mats??[]).collect(e=>e.action.loadFromBasketId??null).toRArray()),s=D.of(_.get(e.lulNum)??[]).filter(e=>!o.has(e.basket.basketId)).sortBy(e=>e.basket.position?.locationNum??0).toRArray(),c=D.of(r).map(([e,t])=>({key:e,label:t.label,mats:t.mats})).sortBy(e=>e.label).toRArray();return{...e,basket:t[0]??null,staging:s,sources:c}}),{machines:c.mapValues(e=>e.valuesToAscLazySeq().toRArray()),loads:s.valuesToAscLazySeq().toRArray(),stockerPals:l.valuesToAscLazySeq().toRArray(),floatingBaskets:D.of(ne.values()).toRArray(),storageBaskets:v+y>0?{empty:v,filled:y}:null,machineAtLoad:ee.valuesToAscLazySeq().toRArray(),maxNumFacesOnPallet:d,maxNumStagingRows:s.valuesToAscLazySeq().map(e=>e.staging.length).maxBy(e=>e)??0,maxNumSourceRows:s.valuesToAscLazySeq().map(e=>e.sources.length).maxBy(e=>e)??0}}function Qg({mats:e}){let[t,n]=(0,K.useState)(!1),i=(0,K.useRef)(null),[a,o]=(0,K.useState)(null),s=j(X),c=r(q);function l(){i.current!==null&&(clearTimeout(i.current),i.current=null),n(!0)}function u(){i.current=setTimeout(()=>{n(!1),i.current=null},200)}function d(t){e.length===1?s({type:`MatDetails`,details:e[0]}):o(t.currentTarget)}function f(e,t){return t==null?null:(e!=null&&e!=null?c.pallets[e]?.faceNames?.[t-1]:null)??`Face: `+t.toString()}return(0,Y.jsxs)(B,{sx:{width:Yg,height:Yg,overflow:`visible`},children:[(0,Y.jsx)(He,{elevation:4,onPointerEnter:l,onPointerLeave:u,sx:{position:`relative`,zIndex:t?10:0,width:`max-content`,height:`max-content`},children:(0,Y.jsx)(Nt,{badgeContent:e.length>1?e.length:0,color:`secondary`,children:(0,Y.jsx)(ln,{focusRipple:!0,onClick:d,children:(0,Y.jsx)(x,{orientation:`horizontal`,in:t,collapsedSize:Yg,children:(0,Y.jsxs)(B,{sx:{display:`flex`},children:[(0,Y.jsx)($,{part:e[0].partName,size:Yg}),(0,Y.jsx)(B,{sx:{marginLeft:`10px`,marginRight:`10px`,whiteSpace:`nowrap`,textAlign:`left`},children:(0,Y.jsx)(x,{in:t,collapsedSize:Yg,children:(0,Y.jsxs)(E,{direction:`column`,sx:{marginBottom:`0.2em`},children:[(0,Y.jsxs)(b,{variant:`h6`,children:[e[0].partName,`-`,e[0].process]}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(`small`,{children:f(e[0].location.palletNum,e[0].location.face)??f(e[0].action.loadOntoPalletNum,e[0].action.loadOntoFace)})}),D.of(e).collect(e=>e.serial?(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(`small`,{children:[`Serial: `,e.serial]})},e.materialID):void 0),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Zd,{mat:e[0]})})]})})})]})})})})}),(0,Y.jsx)(ye,{anchorEl:a,open:!!a,onClose:()=>o(null),anchorOrigin:{vertical:`top`,horizontal:`left`},children:D.of(e).map((e,t)=>(0,Y.jsx)(L,{onClick:()=>{o(null),s({type:`MatDetails`,details:e})},children:e.serial&&e.serial!==``?e.serial:(t+1).toString()},e.materialID))})]})}function $g({maxNumFaces:e,mats:t,loadingOntoPallet:n,noFilter:r,showExpanded:i}){if(i&&e===1)return(0,Y.jsx)(B,{sx:{display:`flex`,flexDirection:`column`,flexWrap:`wrap`},children:t.map(e=>(0,Y.jsx)(of,{mat:e},e.materialID))});{let i=n?D.of(t).filter(e=>r||e.location.type!==H.OnPallet).orderedGroupBy(e=>e.action.loadOntoFace??e.action.loadToBasketSlot??1):D.of(t).filter(e=>r||e.location.type===H.OnPallet).orderedGroupBy(e=>e.action.type===U.Loading?e.action.loadOntoFace??1:e.location.face??1);return(0,Y.jsx)(B,{sx:{display:`grid`,gridTemplateRows:`${Yg}px`,gridTemplateColumns:`repeat(${e}, ${Yg}px)`,columnGap:`5px`,height:`100%`,alignContent:`center`,justifyContent:`center`},children:i.map(([e,t])=>(0,Y.jsx)(B,{sx:{gridColumn:e,gridRow:1},children:(0,Y.jsx)(Qg,{mats:t})},e))})}}function e_({basketId:e,mats:t,maxNumFaces:n}){let r=D.of(t).filter(t=>t.location.type===H.InBasket&&t.location.basketId===e).orderedGroupBy(e=>e.location.basketSlot??1);return n===void 0?(0,Y.jsx)(B,{sx:{display:`flex`,flexWrap:`wrap`,justifyContent:`flex-start`,alignItems:`flex-start`,gap:`5px`,minHeight:`${Yg}px`,paddingLeft:`5px`,paddingRight:`5px`,height:`100%`,alignContent:`center`},children:r.map(([e,t])=>(0,Y.jsx)(B,{children:(0,Y.jsx)(Qg,{mats:t})},e))}):(0,Y.jsx)(B,{sx:{display:`grid`,gridTemplateRows:`${Yg}px`,gridTemplateColumns:`repeat(${n}, ${Yg}px)`,columnGap:`5px`,height:`100%`,alignContent:`center`,justifyContent:`center`},children:r.map(([e,t])=>(0,Y.jsx)(B,{sx:{gridColumn:Math.min(e,n),gridRow:1},children:(0,Y.jsx)(Qg,{mats:t})},e))})}function t_({mats:e,maxNumFaces:t}){return(0,Y.jsx)(B,{sx:{minHeight:`${Xg}px`,display:`flex`,alignItems:`center`,justifyContent:`flex-start`,paddingLeft:`5px`,gap:`5px`,paddingRight:`5px`},children:(0,Y.jsx)($g,{mats:e,maxNumFaces:t,loadingOntoPallet:!0})})}function n_(e,t){let n=Yg*e+5*(e+1);return t?`60px ${Math.max(n,100)}px`:`${Math.max(n,100)}px`}function r_(e){e=Math.round(e);let t=Math.abs(e)%60,n=Math.floor(Math.abs(e)/60),r=n%60,i=Math.floor(n/60);return i>0?`${e<0?`-`:``}${i}:${r.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`:`${e<0?`-`:``}${r}:${t.toString().padStart(2,`0`)}`}function i_(e){let t=e?.find(e=>e.action.type===U.Machining),n=t?.action?.elapsedMachiningTime,i=t?.action.expectedRemainingMachiningTime,a=r(q).timeOfCurrentStatusUTC,o=r(va),s=null;i&&(s=Oa(i)-(o-Math.floor(a.getTime()/1e3)));let c=null;return n&&(c=Oa(n)+(o-Math.floor(a.getTime()/1e3))),s!==null&&c!==null?[!0,`${r_(c)} / ${r_(s)}`,s<0?-1:c/(c+s)*100]:s===null?c===null?[!!t,`Idle`,null]:[!0,r_(c),null]:[!0,` / `+r_(s),s<0?-1:null]}function a_({machine:e}){let[t,n,r]=i_(e.worktable?.mats);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(b,{variant:`h5`,children:e.name}),(0,Y.jsx)(b,{variant:`subtitle1`,children:n}),t?r===null?(0,Y.jsx)(En,{}):r<0?(0,Y.jsx)(En,{color:`error`}):(0,Y.jsx)(En,{variant:`determinate`,value:r}):void 0]})}function o_({maxNumFaces:e,machine:t}){return(0,Y.jsxs)(B,{sx:{display:`grid`,border:`1px solid black`,margin:`5px`,gridTemplateRows:`auto ${Xg}px ${Xg}px ${Xg}px`,gridTemplateColumns:n_(e,!0),gridTemplateAreas:`"machname machname" "inboundpal inboundmat" "worktablepal worktablemat" "outboundpal outboundmat"`},children:[(0,Y.jsx)(B,{sx:{gridArea:`machname`,padding:`0.2em`,borderBottom:`1px solid black`},children:(0,Y.jsx)(a_,{machine:t})}),(0,Y.jsx)(B,{sx:{gridArea:`inboundpal`,borderRight:`1px solid black`,borderBottom:`1px solid black`,padding:`2px`},children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(b,{variant:`body1`,sx:{textAlign:`center`},children:`In`}),t.inbound?(0,Y.jsx)(b,{variant:`h6`,sx:{textAlign:`center`},children:t.inbound.pallet.palletNum}):void 0]})}),(0,Y.jsx)(B,{sx:{gridArea:`inboundmat`,borderBottom:`1px solid black`},children:t.inbound?(0,Y.jsx)($g,{mats:t.inbound.mats,maxNumFaces:e}):void 0}),(0,Y.jsx)(B,{sx:{gridArea:`worktablepal`,borderRight:`1px solid black`,borderBottom:`1px solid black`,padding:`2px`},children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(b,{variant:`body1`,sx:{textAlign:`center`},children:`Work`}),t.worktable?(0,Y.jsx)(b,{variant:`h6`,sx:{textAlign:`center`},children:t.worktable.pallet.palletNum}):void 0]})}),(0,Y.jsx)(B,{sx:{gridArea:`worktablemat`,borderBottom:`1px solid black`},children:t.worktable?(0,Y.jsx)($g,{mats:t.worktable.mats,maxNumFaces:e}):void 0}),(0,Y.jsx)(B,{sx:{gridArea:`outboundpal`,borderRight:`1px solid black`,padding:`2px`},children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(b,{variant:`body1`,sx:{textAlign:`center`},children:`Out`}),t.outbound?(0,Y.jsx)(b,{variant:`h6`,sx:{textAlign:`center`},children:t.outbound.pallet.palletNum}):void 0]})}),(0,Y.jsx)(B,{sx:{gridArea:`outboundmat`},children:t.outbound?(0,Y.jsx)($g,{mats:t.outbound.mats,maxNumFaces:e}):void 0})]})}function s_(e){let t=(e?.find(e=>e.action.type===U.Loading||e.action.type===U.LoadingToBasket||e.action.type===U.UnloadToCompletedMaterial||e.action.type===U.UnloadToInProcess))?.action?.elapsedLoadUnloadTime,n=r(q).timeOfCurrentStatusUTC,i=r(va),a=null;return t&&(a=Oa(t)+(i-Math.floor(n.getTime()/1e3))),a===null?`Idle`:r_(a)}function c_({load:e}){let t=s_(e.pal?.mats??e.basket?.mats),n=r(G);return(0,Y.jsxs)(B,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`baseline`},children:[(0,Y.jsx)(b,{variant:`h5`,children:Za(e.lulNum,n.loadStationNames)}),(0,Y.jsx)(b,{variant:`body1`,children:t})]})}function l_({maxNumFaces:e,maxNumStagingRows:t,maxNumSourceRows:n,load:i}){let a=eo(r(G).basketName),o=i.pal?`Pallet`:i.basket?a:null,s=i.pal?i.pal.pallet.palletNum.toString():i.basket?i.basket.basket.basketId.toString():null,c=Math.max(1,n),l=Math.max(1,t),u=Array.from({length:c},(e,t)=>`"source${t} sourcemat${t}"`),d=Array.from({length:l},(e,t)=>`"stage${t} stagemat${t}"`),f=[`"lulname lulname"`,...u,`"current currentmat"`,...d].join(` `),p=c+1+l;return(0,Y.jsxs)(B,{sx:{display:`grid`,border:`1px solid black`,margin:`5px`,gridTemplateRows:`auto repeat(${p}, ${Xg}px)`,gridTemplateColumns:n_(e,!0),gridTemplateAreas:f},children:[(0,Y.jsx)(B,{sx:{gridArea:`lulname`,padding:`0.2em`,borderBottom:`1px solid black`},children:(0,Y.jsx)(c_,{load:i})}),Array.from({length:c},(t,n)=>{let r=i.sources[n]??null;return(0,Y.jsxs)(K.Fragment,{children:[(0,Y.jsx)(B,{sx:{gridArea:`source${n}`,borderRight:`1px solid black`,borderBottom:`1px solid black`,padding:`2px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:r?(0,Y.jsx)(b,{variant:`body2`,sx:{textAlign:`center`},children:r.label}):void 0}),(0,Y.jsx)(B,{sx:{gridArea:`sourcemat${n}`,borderBottom:`1px solid black`,display:`flex`,flexDirection:`column`,justifyContent:`center`},children:r?(0,Y.jsx)(t_,{mats:r.mats,maxNumFaces:e}):void 0})]},`source-${n}`)}),(0,Y.jsx)(B,{sx:{gridArea:`current`,borderRight:`1px solid black`,borderBottom:`1px solid black`,padding:`2px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,Y.jsxs)(E,{children:[o?(0,Y.jsx)(b,{variant:`body1`,sx:{textAlign:`center`},children:o}):void 0,s?(0,Y.jsx)(b,{variant:`h6`,sx:{textAlign:`center`},children:s}):void 0]})}),(0,Y.jsxs)(B,{sx:{gridArea:`currentmat`,display:`flex`,flexDirection:`column`,justifyContent:`center`,borderBottom:`1px solid black`},children:[i.pal?(0,Y.jsx)($g,{mats:i.pal.mats,maxNumFaces:e}):void 0,!i.pal&&i.basket?(0,Y.jsx)(e_,{basketId:i.basket.basket.basketId,mats:i.basket.mats,maxNumFaces:e}):void 0]}),Array.from({length:l},(t,n)=>{let r=i.staging[n]??null,o=n===l-1;return(0,Y.jsxs)(K.Fragment,{children:[(0,Y.jsx)(B,{sx:{gridArea:`stage${n}`,borderRight:`1px solid black`,...o?{}:{borderBottom:`1px solid black`},padding:`2px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:r?(0,Y.jsxs)(b,{variant:`body2`,sx:{textAlign:`center`},children:[`Staging `,a,` `,r.basket.basketId]}):void 0}),(0,Y.jsx)(B,{sx:{gridArea:`stagemat${n}`,...o?{}:{borderBottom:`1px solid black`},display:`flex`,flexDirection:`column`,justifyContent:`center`},children:r?(0,Y.jsx)(e_,{basketId:r.basket.basketId,mats:r.mats,maxNumFaces:e}):void 0})]},`stage-${n}`)})]})}function u_({status:e}){let t=s_(e.loadingMats),[n,r,i]=i_(e.machiningMats);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(b,{variant:`h5`,children:[`Station `,e.lulNum]}),e.machineCurrentlyAtLoad?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(b,{variant:`h5`,children:[e.machineCurrentlyAtLoad.group,` `,e.machineCurrentlyAtLoad.num]}),(0,Y.jsx)(b,{variant:`subtitle1`,children:r===`Idle`?t:r}),n?i===null?(0,Y.jsx)(En,{}):i<0?(0,Y.jsx)(En,{color:`error`}):(0,Y.jsx)(En,{variant:`determinate`,value:i}):void 0]}):(0,Y.jsxs)(Y.Fragment,{children:[e.machineMoving?(0,Y.jsx)(b,{variant:`subtitle2`,children:`Machine Moving`}):void 0,(0,Y.jsxs)(b,{variant:`subtitle1`,children:[`Loading `,t]})]})]})}function d_({maxNumFaces:e,status:t}){return(0,Y.jsxs)(B,{sx:{display:`grid`,border:`1px solid black`,margin:`5px`,gridTemplateRows:`minmax(104px, max-content) repeat(3, ${e>1?Xg.toString()+`px`:`minmax(110px, max-content)`})`,gridTemplateColumns:e===1?`60px minmax(230px, max-content)`:n_(e,!0),gridTemplateAreas:`"name name" "ready readymat" "machining machiningmat" "loadstation loadstationmat"`},children:[(0,Y.jsx)(B,{sx:{gridArea:`name`,padding:`0.2em`,borderBottom:`1px solid black`},children:(0,Y.jsx)(u_,{status:t})}),(0,Y.jsx)(B,{sx:{gridArea:`ready`,borderRight:`1px solid black`,borderBottom:`1px solid black`,padding:`2px`},children:(0,Y.jsx)(b,{variant:`body1`,sx:{textAlign:`center`},children:`Ready`})}),(0,Y.jsx)(B,{sx:{gridArea:`readymat`,borderBottom:`1px solid black`,display:`flex`,flexDirection:`column`,justifyContent:`center`},children:(0,Y.jsx)($g,{mats:t.readyMats,maxNumFaces:e,showExpanded:!0})}),(0,Y.jsx)(B,{sx:{gridArea:`machining`,borderRight:`1px solid black`,borderBottom:`1px solid black`,padding:`2px`},children:(0,Y.jsx)(b,{variant:`body1`,sx:{textAlign:`center`},children:`Work`})}),(0,Y.jsx)(B,{sx:{gridArea:`machiningmat`,borderBottom:`1px solid black`,display:`flex`,flexDirection:`column`,justifyContent:`center`},children:(0,Y.jsx)($g,{mats:t.machiningMats,maxNumFaces:e,showExpanded:!0})}),(0,Y.jsx)(B,{sx:{gridArea:`loadstation`,borderRight:`1px solid black`,padding:`2px`},children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(b,{variant:`body1`,sx:{textAlign:`center`},children:`Load`}),(0,Y.jsx)(b,{variant:`body1`,sx:{textAlign:`center`},children:`Station`})]})}),(0,Y.jsx)(B,{sx:{gridArea:`loadstationmat`,display:`flex`,flexDirection:`column`,justifyContent:`center`},children:(0,Y.jsx)($g,{mats:t.loadingMats,maxNumFaces:e,showExpanded:!0,noFilter:!0})})]})}function f_({maxNumFaces:e,pallet:t}){return(0,Y.jsxs)(B,{sx:{display:`grid`,border:`1px solid black`,margin:`5px`,gridTemplateRows:`auto ${Xg}px`,gridTemplateColumns:n_(e,!1),gridTemplateAreas:`"palname" "palmat"`},children:[(0,Y.jsxs)(b,{variant:`h5`,sx:{gridArea:`palname`,padding:`0.2em`,borderBottom:`1px solid black`},children:[`Pallet `,t.pallet.palletNum]}),(0,Y.jsx)(B,{sx:{gridArea:`palmat`},children:(0,Y.jsx)($g,{mats:t.mats,maxNumFaces:e})})]})}function p_({basket:e}){let t=eo(r(G).basketName);return(0,Y.jsxs)(B,{sx:{display:`grid`,border:`1px solid black`,margin:`5px`,gridTemplateRows:`auto ${Xg}px`,gridTemplateColumns:`minmax(120px, max-content)`,gridTemplateAreas:`"basketname" "basketmat"`},children:[(0,Y.jsxs)(b,{variant:`h5`,sx:{gridArea:`basketname`,padding:`0.2em`,borderBottom:`1px solid black`},children:[t,` `,e.basket.basketId]}),(0,Y.jsx)(B,{sx:{gridArea:`basketmat`},children:(0,Y.jsx)(e_,{basketId:e.basket.basketId,mats:e.mats})})]})}function m_({empty:e,filled:t}){let n=eo(r(G).basketName);return(0,Y.jsxs)(B,{sx:{display:`grid`,border:`1px solid black`,margin:`5px`,padding:`0.5em 1em`,alignContent:`center`,minWidth:`170px`},children:[(0,Y.jsxs)(b,{variant:`h5`,children:[n,` Storage`]}),(0,Y.jsxs)(b,{variant:`body1`,children:[`Empty: `,e]}),(0,Y.jsxs)(b,{variant:`body1`,children:[`Filled: `,t]})]})}var h_=(0,K.memo)(function({overview:e}){return(0,Y.jsxs)(`div`,{children:[e.machines.toAscLazySeq().map(([t,n])=>(0,Y.jsx)(B,{sx:{display:`flex`,flexWrap:`wrap`,justifyContent:`space-evenly`},children:n.map(t=>(0,Y.jsx)(o_,{machine:t,maxNumFaces:e.maxNumFacesOnPallet},t.name))},t)),e.loads.length>0?(0,Y.jsx)(B,{sx:{display:`flex`,flexWrap:`wrap`,justifyContent:`space-evenly`},children:e.loads.map(t=>(0,Y.jsx)(l_,{load:t,maxNumFaces:e.maxNumFacesOnPallet,maxNumStagingRows:e.maxNumStagingRows,maxNumSourceRows:e.maxNumSourceRows},t.lulNum))}):void 0,e.machineAtLoad.length>0?(0,Y.jsx)(B,{sx:{display:`flex`,flexWrap:`wrap`,justifyContent:`space-evenly`},children:e.machineAtLoad.map(t=>(0,Y.jsx)(d_,{status:t,maxNumFaces:e.maxNumFacesOnPallet},t.lulNum))}):void 0,e.stockerPals.length>0||e.floatingBaskets.length>0||e.storageBaskets?(0,Y.jsxs)(B,{sx:{display:`flex`,flexWrap:`wrap`,justifyContent:`space-evenly`},children:[e.stockerPals.map(t=>(0,Y.jsx)(f_,{pallet:t,maxNumFaces:e.maxNumFacesOnPallet},t.pallet.palletNum)),e.floatingBaskets.map(e=>(0,Y.jsx)(p_,{basket:e},e.basket.basketId)),e.storageBaskets?(0,Y.jsx)(m_,{empty:e.storageBaskets.empty,filled:e.storageBaskets.filled}):void 0]}):void 0]})}),g_=(0,K.memo)(function({ignoreOperator:e}){let[t,n]=(0,K.useState)(null);function r(){n(null)}return(0,Y.jsx)(xf,{onClose:r,allowNote:!0,highlightProcsGreaterOrEqualTo:t?.process??void 0,extraDialogElements:(0,Y.jsx)(Y.Fragment,{children:t===null?null:(0,Y.jsx)(_m,{st:t,setState:n})}),buttons:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(fm,{ignoreOperator:e}),(0,Y.jsx)(pm,{onClose:r,ignoreOperator:e}),(0,Y.jsx)(jg,{}),(0,Y.jsx)(vm,{st:t,setState:n,onClose:r,ignoreOperator:e})]})})});function __({ignoreOperator:e,whiteBackground:t}){Q(`System Overview`);let n=Zg();return(0,Y.jsxs)(`main`,{style:{padding:`10px`,minHeight:`calc(100vh - 64px)`,backgroundColor:t?`white`:`#F8F8F8`},children:[(0,Y.jsx)(h_,{overview:n}),(0,Y.jsx)(g_,{ignoreOperator:e}),(0,Y.jsx)(Mg,{})]})}var v_=30;function y_({machine:e}){let t=d(),[,,n]=i_(e.worktable?.mats);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`rect`,{x:3,y:3,width:24,height:24,stroke:`black`}),`;`,(0,Y.jsx)(`rect`,{x:3,y:3,width:24,height:8,fill:e.inbound===null?`white`:t.palette.secondary.main}),(0,Y.jsx)(`rect`,{x:3,y:11,width:24,height:8,fill:e.worktable===null?`white`:n!=null&&n<0?t.palette.error.main:t.palette.secondary.main}),(0,Y.jsx)(`rect`,{x:3,y:19,width:24,height:8,fill:e.outbound===null?`white`:t.palette.secondary.main})]})}function b_({load:e}){let t=d();return(0,Y.jsx)(`polygon`,{points:`3,27 27,27 15,3`,fill:e.pal===null&&e.basket===null&&e.staging.length===0?`white`:t.palette.secondary.main,stroke:`black`})}function x_({status:e}){let t=d(),[,,n]=i_(e.machiningMats);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`rect`,{x:3,y:3,width:24,height:24,stroke:`black`}),`;`,(0,Y.jsx)(`rect`,{x:3,y:3,width:24,height:8,fill:e.readyMats.length===0?`white`:t.palette.secondary.main}),(0,Y.jsx)(`rect`,{x:3,y:11,width:24,height:8,fill:e.machiningMats.length===0?`white`:n!=null&&n<0?t.palette.error.main:t.palette.secondary.main}),(0,Y.jsx)(`rect`,{x:3,y:19,width:24,height:8,fill:e.loadingMats.length===0?`white`:t.palette.secondary.main})]})}var S_=(0,K.memo)(function({overview:e}){let t=e.machines.toAscLazySeq().sumBy(([,e])=>e.length);return(0,Y.jsx)(B,{sx:{height:`1.5em`,"&:hover":{backgroundColor:`primary.light`}},children:(0,Y.jsxs)(`svg`,{viewBox:`0 0 ${(t+e.loads.length+e.machineAtLoad.length)*v_} ${v_}`,preserveAspectRatio:`none`,width:`140px`,height:`1.5em`,children:[(0,Y.jsx)(`g`,{children:e.machines.toAscLazySeq().flatMap(([,e])=>e).map((e,t)=>(0,Y.jsx)(`g`,{transform:`translate(${t*v_})`,children:(0,Y.jsx)(y_,{machine:e})},e.name))}),(0,Y.jsx)(`g`,{transform:`translate(${t*v_})`,children:e.loads.map((e,t)=>(0,Y.jsx)(`g`,{transform:`translate(${t*v_})`,children:(0,Y.jsx)(b_,{load:e})},e.lulNum))}),(0,Y.jsx)(`g`,{transform:`translate(${(t+e.loads.length)*v_})`,children:e.machineAtLoad.map((e,t)=>(0,Y.jsx)(`g`,{transform:`translate(${t*v_})`,children:(0,Y.jsx)(x_,{status:e})},e.lulNum))})]})})}),C_=(0,K.memo)(function({full:e}){let[t,n]=(0,K.useState)(!1),r=Zg();return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{onClick:()=>n(!0),children:(0,Y.jsx)(S_,{overview:r})}),(0,Y.jsxs)(I,{open:t,onClose:()=>n(!1),maxWidth:`xl`,fullScreen:e,children:[e?(0,Y.jsx)(or,{sx:{position:`relative`},children:(0,Y.jsxs)(cn,{children:[(0,Y.jsx)(C,{edge:`start`,color:`inherit`,onClick:()=>n(!1),"aria-label":`close`,children:(0,Y.jsx)(It,{})}),(0,Y.jsx)(b,{sx:{ml:2,flex:1},variant:`h6`,component:`div`,children:`System Overview`})]})}):void 0,(0,Y.jsx)(M,{children:(0,Y.jsx)(B,{sx:{paddingBottom:`2em`,paddingLeft:`5em`,paddingRight:`5em`},children:(0,Y.jsx)(h_,{overview:r})})})]})]})});function w_(e){return Number.isInteger(e)&&(e??0)>0}function T_(e){return typeof e==`string`&&e.trim()!==``}function E_(e,t){if(e.location.type===H.InBasket&&e.location.basketId===t&&(e.action.type===U.UnloadToInProcess||e.action.type===U.UnloadToCompletedMaterial))return w_(e.location.basketSlot)?{type:`valid`,workId:e.action.workId}:{type:`invalid`};if(e.action.type===U.LoadingToBasket){if(!w_(e.action.loadToBasketId))return{type:`invalid`};if(e.action.loadToBasketId!==t)return;let n=e.location.type===H.InBasket&&e.location.basketId===t&&e.location.basketSlot===e.action.loadToBasketSlot;return!w_(e.action.loadToBasketSlot)||!n&&e.location.type!==H.Free&&(e.location.type!==H.InQueue||!T_(e.location.currentQueue))?{type:`invalid`}:{type:`valid`,workId:e.action.workId}}}function D_(e,t){let n=D.of(e).collect(e=>E_(e,t.basketId)).toRArray();if(n.some(e=>e.type===`invalid`))return{type:`inconsistent`};let r=n.filter(e=>e.type===`valid`),i=t.loadStationWork;if(i!==void 0){if(!i||!T_(i.workId)||typeof i.readyToConfirm!=`boolean`)return{type:`inconsistent`};let n=i.awaitingMaterialSlots??[];if(!Array.isArray(n)||!n.every(w_)||new Set(n).size!==n.length||i.readyToConfirm&&n.length>0||r.some(e=>e.workId!==i.workId))return{type:`inconsistent`};let a=i.type===mi.ConfirmEmptyBasket;if(a){if(r.length>0||n.length>0||e.some(e=>e.location.type===H.InBasket&&e.location.basketId===t.basketId))return{type:`inconsistent`}}else if(i.type!==mi.Material||i.readyToConfirm&&r.length===0)return{type:`inconsistent`};return{type:`active`,work:{workId:i.workId,ready:i.readyToConfirm,confirmEmpty:a,awaitingSlots:n}}}return{type:r.length===0?`none`:`inconsistent`}}function O_({material:e,basketId:t,fsize:n}){return e.map(e=>(0,Y.jsx)(Jg,{kind:{type:Ng.Material,material:e},children:(0,Y.jsx)(of,{mat:e,displayActionForSingleBasket:t,fsize:n})},e.materialID))}function k_({basket:e,material:t,fsize:n,title:i,elapsed:a}){let[o,s]=(0,K.useState)(),c=j(Kf),[l,u]=(0,K.useState)(),d=(0,K.useMemo)(()=>D_(t,e),[e,t]),f=As(r(q),{activity:ii.BasketLoadStation,basketId:e.basketId}).length>0,p=e.loadStationWork?.confirmationBlockedReason?.trim(),m=e.loadStationWork?.instructionWarning?.trim(),h=d.type===`active`?d.work:void 0,g=o!==void 0&&o.workId===h?.workId&&(o.state!==`conflict`||o.basket===e&&o.material===t)?o.state:`idle`,ee=g===`idle`?null:o?.reason??null,_=(0,K.useMemo)(()=>D.of(t).filter(t=>t.location.type===H.InBasket&&t.location.basketId===e.basketId&&t.location.basketSlot!==void 0).groupBy(e=>e.location.basketSlot??0).toHashMap(e=>e),[e,t]),ne=(0,K.useMemo)(()=>D.of(t).filter(t=>t.action.type===U.LoadingToBasket&&t.action.loadToBasketId===e.basketId&&t.action.loadToBasketSlot!==void 0).groupBy(e=>e.action.loadToBasketSlot??0).toHashMap(e=>e),[e,t]),v=(0,K.useMemo)(()=>D.of(e.emptySlots??[]).concat(e.unknownSlots??[]).concat(_.keysToLazySeq()).concat(ne.keysToLazySeq()).distinctBy(e=>e).toSortedArray(e=>e),[e.emptySlots,e.unknownSlots,_,ne]);async function y(e){u(void 0);try{await c(AbortSignal.timeout(5e3))||u({workId:e,message:`The connection changed while refreshing status.`})}catch(t){u({workId:e,message:Ed(t)??`Unable to refresh status.`})}}async function re(){if(h===void 0||!h.ready||f)return;let n=h.workId,r={workId:n,basket:e,material:t,state:`submitting`,reason:null};s(r);try{await Bi.completeBasketLoadStation(new Di({workId:n})),s(e=>e===r?{...r,state:`accepted`}:e)}catch(e){let t=Ri.isApiException(e)&&e.status===409?`conflict`:`error`,n=Ed(e);s(e=>e===r?{...r,state:t,reason:n}:e)}await y(n)}let ie=f||!h?.ready||g===`submitting`||g===`accepted`||g===`conflict`;return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(B,{sx:{display:`grid`,gridTemplateColumns:`minmax(max-content, 1fr) auto auto`,alignItems:`center`,columnGap:4},children:[i,(0,Y.jsx)(B,{role:`group`,"aria-label":`Basket confirmation`,sx:{display:`flex`,alignItems:`center`,gap:2},children:h?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(b,{color:`error`,noWrap:!0,sx:{visibility:f?`visible`:`hidden`},children:`System alarm`}),(0,Y.jsx)(z,{variant:`contained`,color:`secondary`,size:`large`,disabled:ie,onClick:()=>void re(),children:`Confirm`})]}):null}),(0,Y.jsx)(B,{sx:{justifySelf:`flex-end`,minWidth:`8ch`,textAlign:`right`,fontVariantNumeric:`tabular-nums`},children:a})]}),(0,Y.jsxs)(E,{spacing:2,sx:{ml:`4em`,mr:`4em`,mt:2},children:[l?.workId===h?.workId&&l&&(0,Y.jsxs)(te,{severity:`warning`,action:(0,Y.jsx)(z,{onClick:()=>void y(l.workId),children:`Refresh status`}),children:[l.message,` Refresh current status to review the latest work.`]}),h?.confirmEmpty&&h.ready&&!f&&(0,Y.jsxs)(b,{children:[`Confirm basket `,e.basketId,` is empty.`]}),m&&(0,Y.jsx)(te,{severity:`warning`,children:m}),h&&!h.ready&&(0,Y.jsx)(te,{severity:`info`,children:p||(h.awaitingSlots.length>0?`Waiting for material for slots ${h.awaitingSlots.map($a).join(`, `)}.`:`Basket work is not ready for confirmation.`)}),!h&&d.type===`inconsistent`?(0,Y.jsx)(te,{severity:`warning`,children:`Basket work is inconsistent. Wait for refreshed material actions before confirming.`}):null,g===`accepted`?(0,Y.jsx)(te,{severity:`success`,children:`Confirmation accepted. Waiting for refreshed work.`}):g===`conflict`?(0,Y.jsx)(te,{severity:`warning`,children:ee??`Basket work changed before confirmation. Review the refreshed slots and try again.`}):g===`error`?(0,Y.jsxs)(te,{severity:`error`,children:[`Unable to confirm basket work`,ee?`: ${ee}`:`.`,` No work was assumed complete.`]}):null]}),(0,Y.jsx)(Jg,{kind:{type:Ng.BasketZone,basketId:e.basketId},children:v.map((t,r)=>{let i=_.get(t)??[],a=e.unknownSlots?.includes(t)===!0,o=D.of(i).filter(e=>e.action.type!==U.UnloadToInProcess&&e.action.type!==U.UnloadToCompletedMaterial).concat(ne.get(t)??[]).map(e=>{let t=e.action.type===U.LoadingToBasket?e.action.processAfterLoad:e.process;return`${e.partName}${t===void 0?``:` proc ${t}`}`}).distinctBy(e=>e).toRArray(),s=h?.confirmEmpty||!a&&(i.length>0||e.emptySlots?.includes(t)===!0),c=h&&!h.awaitingSlots.includes(t)?o.length>0?`Fill with ${o.join(`, `)}`:s?`Leave empty`:void 0:void 0;return(0,Y.jsxs)(B,{component:`section`,"data-testid":`basket-load-station-slot-${t}`,sx:{borderTop:r===0?void 0:`1px solid black`,py:3},children:[(0,Y.jsxs)(B,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,flexWrap:`wrap`,columnGap:1,color:`text.secondary`,mb:2},children:[(0,Y.jsxs)(b,{variant:`h6`,sx:{color:`text.primary`},children:[`Slot `,$a(t)]}),c&&(0,Y.jsxs)(B,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,gap:1},children:[(0,Y.jsx)(b,{component:`span`,variant:`body2`,color:`inherit`,"aria-hidden":!0,children:`·`}),(0,Y.jsx)(b,{component:`span`,variant:`body2`,color:`inherit`,children:f?`Saved target: ${c}`:c})]})]}),(0,Y.jsx)(B,{sx:{ml:`4em`,mr:`4em`},children:(0,Y.jsx)(Jg,{kind:{type:Ng.BasketSlotZone,basketId:e.basketId,slot:t},children:(0,Y.jsx)(B,{sx:{display:`flex`,flexWrap:`wrap`,justifyContent:`space-around`,minHeight:`4em`},children:i.length>0?(0,Y.jsx)(O_,{material:i,basketId:e.basketId,fsize:n}):a?(0,Y.jsx)(b,{color:`warning.main`,children:`Unknown`}):null})})})]},t)})})]})}function A_(e){return encodeURIComponent(e.toString())}function j_(e){switch(e.kind){case`queue`:return`load-station-queue-${A_(e.label)}`;case`baskets`:return`load-station-baskets`;case`free`:return`load-station-material`}}function M_(e,t,n){switch(e.action.type){case U.Loading:return t!==void 0&&e.action.loadOntoPalletNum===t.palletNum||n!==void 0&&e.action.loadFromBasketId===n.basketId;case U.LoadingToBasket:return n!==void 0&&e.action.loadToBasketId===n.basketId;default:return!1}}function N_(e,t,n,r){let i,a,o=new Set;if(e>=0){for(let t of Object.values(n.pallets))if(t.currentPalletLocation.loc===Qr.LoadUnload&&t.currentPalletLocation.num===e){i=t;break}for(let t of Object.values(n.baskets??{})){let n=t.position;n!==void 0&&n.locationNum===e&&(n.location===gi.LoadUnload?a=t:n.location===gi.LoadStationStaging&&o.add(t.basketId))}}let s=new Set(t);if(i!==void 0)for(let e of n.material)e.action.type===U.Loading&&e.action.loadOntoPalletNum===i.palletNum&&e.location.type===H.InQueue&&e.location.currentQueue&&s.add(e.location.currentQueue),e.action.type===U.Loading&&e.action.loadOntoPalletNum===i.palletNum&&e.action.loadFromBasketId&&o.add(e.action.loadFromBasketId),(e.action.type===U.UnloadToInProcess||e.action.type===U.UnloadToCompletedMaterial)&&e.action.unloadToBasketId&&e.location.type===H.OnPallet&&e.location.palletNum===i.palletNum&&o.add(e.action.unloadToBasketId),(e.action.type===U.UnloadToInProcess||e.action.type===U.UnloadToCompletedMaterial)&&e.action.unloadIntoQueue&&e.location.type===H.OnPallet&&e.location.palletNum===i.palletNum&&s.add(e.action.unloadIntoQueue);else if(a!==void 0)for(let e of n.material)e.location.type===H.InBasket&&e.location.basketId===a.basketId&&(e.action.type===U.UnloadToInProcess||e.action.type===U.UnloadToCompletedMaterial)&&e.action.unloadIntoQueue&&s.add(e.action.unloadIntoQueue),e.location.type===H.InQueue&&e.location.currentQueue&&M_(e,void 0,a)&&s.add(e.location.currentQueue);let c=new Map(D.of(s).map(e=>[e,{mats:[],hiddenCnt:0}])),l=new Map(D.of(o).map(e=>[e,{mats:[],hiddenCnt:0}])),u=[],d=se.empty(),f=null;if(i)for(let e=1;e<=i.numFaces;e++)d=d.set(e,[]);else a&&(d=d.set(1,[]));for(let e of n.material){if(i?(e.action.type===U.Loading&&e.action.loadOntoPalletNum===i.palletNum&&(e.action.elapsedLoadUnloadTime&&(f=e.action.elapsedLoadUnloadTime),e.action.loadOntoFace&&!d.has(e.action.loadOntoFace)&&(d=d.set(e.action.loadOntoFace,[])),e.location.type===H.Free&&u.push(e)),e.location.type===H.OnPallet&&e.location.palletNum===i.palletNum&&((e.action.type===U.UnloadToCompletedMaterial||e.action.type===U.UnloadToInProcess)&&e.action.elapsedLoadUnloadTime&&(f=e.action.elapsedLoadUnloadTime),d=d.alter(e.location.face??1,t=>t?(t.push(e),t):[e]))):a&&(M_(e,i,a)&&e.action.elapsedLoadUnloadTime&&(f=e.action.elapsedLoadUnloadTime),e.action.type===U.LoadingToBasket&&e.action.loadToBasketId===a.basketId&&e.location.type===H.Free&&u.push(e),e.location.type===H.InBasket&&e.location.basketId===a.basketId&&((e.action.type===U.UnloadToCompletedMaterial||e.action.type===U.UnloadToInProcess)&&e.action.elapsedLoadUnloadTime&&(f=e.action.elapsedLoadUnloadTime),d=d.alter(1,t=>t?(t.push(e),t):[e]))),e.location.type===H.InQueue&&e.location.currentQueue&&c.has(e.location.currentQueue)){let t=c.get(e.location.currentQueue);r&&!M_(e,i,a)?t===void 0?c.set(e.location.currentQueue,{mats:[],hiddenCnt:1}):t.hiddenCnt+=1:t===void 0?c.set(e.location.currentQueue,{mats:[e],hiddenCnt:0}):t.mats.push(e)}if(e.location.type===H.InBasket&&e.location.basketId&&l.has(e.location.basketId)){let t=l.get(e.location.basketId);r&&!M_(e,i,a)?t===void 0?l.set(e.location.basketId,{mats:[],hiddenCnt:1}):t.hiddenCnt+=1:t===void 0?l.set(e.location.basketId,{mats:[e],hiddenCnt:0}):t.mats.push(e)}}let p=new Map([...c].map(([e,t])=>[e,{...t,mats:D.of(t.mats).sortBy(e=>e.location.queuePosition??0).toRArray()}])),m=new Map([...l].map(([e,t])=>[e,{...t,mats:D.of(t.mats).sortBy(e=>e.location.basketSlot??0).toRArray()}])),h=u.length+d.valuesToAscLazySeq().sumBy(e=>e.length),g=a?D.of(a.emptySlots??[]).concat(a.unknownSlots??[]).concat(D.of(n.material).collect(e=>e.location.type===H.InBasket&&e.location.basketId===a.basketId?e.location.basketSlot:void 0)).concat(D.of(n.material).collect(e=>e.action.type===U.LoadingToBasket&&e.action.loadToBasketId===a.basketId?e.action.loadToBasketSlot:void 0)).distinctBy(e=>e).toRArray().length:0,ee=Math.max(h,g),_=a?D.of(n.material).filter(e=>e.location.type===H.InBasket&&e.location.basketId===a.basketId).groupBy(e=>e.location.basketSlot??0).map(([,e])=>e.length).maxBy(e=>e)??0:0;return{pallet:i,activeBasket:a,allMaterial:n.material,face:d,freeLoadingMaterial:u,queues:p,baskets:m,elapsedLoadingTime:f,fsize:ee>6||_>=3?`normal`:ee<=2?`x-large`:`large`}}function P_({loadData:e}){let t=Ic(),n=r(ga),i=(0,K.useMemo)(()=>{let t=e.pallet;return t?D.of(e.face.values()).append(e.freeLoadingMaterial).concat(D.of(e.queues).collect(([,e])=>e.mats)).flatMap(e=>e).collect(e=>e.action.type===U.Loading&&e.action.loadOntoPalletNum===t.palletNum&&e.location.type===H.OnPallet&&e.location.palletNum===t.palletNum?Xi(e.partName,`unload`,e.materialID,t.palletNum,e.process,n):e.action.type===U.Loading&&e.action.loadOntoPalletNum===t.palletNum?Xi(e.partName,`load`,e.materialID,t.palletNum,e.action.processAfterLoad??e.process,n):e.location.type===H.OnPallet&&e.location.palletNum===t.palletNum&&(e.action.type===U.UnloadToCompletedMaterial||e.action.type===U.UnloadToInProcess)?Xi(e.partName,`unload`,e.materialID,t.palletNum,e.process,n):null).toRArray():[]},[e,n]);if(i.length===0||t)return(0,Y.jsx)(`div`,{});function a(){for(let e of i)window.open(e,`_blank`)}return(0,Y.jsx)(B,{sx:{position:`fixed`,bottom:`5px`,right:`5px`},children:(0,Y.jsx)(S,{title:`Open All Instructions`,children:(0,Y.jsx)(Lt,{onClick:a,color:`secondary`,children:(0,Y.jsx)(Ln,{})})})})}function F_({elapsedLoadTime:e}){let t=r(q).timeOfCurrentStatusUTC,n=r(va);if(e){let r=Oa(e)+(n-t.getTime()/1e3);return(0,Y.jsx)(`span`,{children:r_(Math.max(0,r))})}return null}function I_({data:e,faceNum:t}){let n=e.face.get(t),i=eo(r(G).basketName);return n?e.activeBasket&&!e.pallet?(0,Y.jsx)(`div`,{"data-testid":`load-station-active-basket`,children:(0,Y.jsx)(k_,{basket:e.activeBasket,material:e.allMaterial,fsize:e.fsize,title:(0,Y.jsxs)(b,{variant:`h4`,children:[i,` `,e.activeBasket.basketId]}),elapsed:(0,Y.jsx)(F_,{elapsedLoadTime:e.elapsedLoadingTime})})}):e.pallet?(0,Y.jsxs)(`div`,{"data-testid":`load-station-pallet-face-${t}`,children:[t===1?(0,Y.jsxs)(B,{sx:{display:`grid`,gridTemplateColumns:e.pallet.numFaces>1?`1fr 1fr 1fr`:`1fr 1fr`},children:[(0,Y.jsxs)(b,{variant:`h4`,children:[`Pallet `,e.pallet.palletNum]}),e.pallet.numFaces>1?(0,Y.jsx)(b,{variant:`h6`,sx:{justifySelf:`center`},children:e.pallet.faceNames?.[t-1]??`Face 1`}):void 0,(0,Y.jsx)(B,{sx:{justifySelf:`flex-end`},children:(0,Y.jsx)(F_,{elapsedLoadTime:e.elapsedLoadingTime})})]}):e.pallet.numFaces>1?(0,Y.jsx)(B,{sx:{display:`flex`,justifyContent:`center`},children:(0,Y.jsx)(b,{variant:`h6`,children:e.pallet.faceNames?.[t-1]??`Face ${t}`})}):void 0,(0,Y.jsx)(B,{sx:{ml:`4em`,mr:`4em`},children:(0,Y.jsx)(Jg,{kind:{type:Ng.PalletFaceZone,palletNum:e.pallet.palletNum,face:t},children:(0,Y.jsx)(B,{sx:{display:`flex`,flexWrap:`wrap`,justifyContent:`space-around`},children:n.map((t,n)=>(0,Y.jsx)(Jg,{kind:{type:Ng.Material,material:t},children:(0,Y.jsx)(of,{mat:t,fsize:e.fsize})},n))})})})]}):null:null}function L_({data:e,mat:t}){return(0,Y.jsxs)(`div`,{children:[t.label===``?null:(0,Y.jsx)(b,{variant:`h4`,children:t.label}),(t.isFree?Sp(t.material.mats,e=>e.process===0):t.material.mats.map(e=>[e])).map((n,r)=>{let i=n[0];return(0,Y.jsx)(Jg,{kind:{type:Ng.Material,material:i,identifier:i.materialID<0?`raw-${t.isFree?`free`:`queue`}-${t.label}-${r}`:void 0},children:t.isFree||t.sortable===!1?(0,Y.jsx)(of,{mat:i,materialCount:n.length,displayActionForSinglePallet:e.pallet?e.pallet.palletNum:0,displayActionForSingleBasket:e.activeBasket?.basketId,fsize:e.fsize,showRawMaterial:!0,showJobComment:!0}):(0,Y.jsx)(sf,{mat:i,displayActionForSinglePallet:e.pallet?e.pallet.palletNum:0,displayActionForSingleBasket:e.activeBasket?.basketId,shake:M_(i,e.pallet,e.activeBasket),fsize:M_(i,e.pallet,e.activeBasket)?e.fsize:void 0,showRawMaterial:!0,showJobComment:!0})},r)}),t.material.hiddenCnt>0?(0,Y.jsxs)(b,{variant:`body2`,color:`textSecondary`,sx:{textAlign:`center`,mt:`0.5em`},children:[`+`,t.material.hiddenCnt,` hidden`]}):null]})}function R_({data:e,label:t,baskets:n}){return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(b,{variant:`h4`,children:t}),n.map((t,n)=>(0,Y.jsxs)(B,{"data-testid":`load-station-basket-${A_(t.basketId)}`,sx:{mt:n===0?`0.5em`:`1.5em`,pt:n===0?void 0:`1em`},children:[(0,Y.jsx)(b,{variant:`h6`,sx:{mb:`0.5em`},children:t.label}),(0,Y.jsxs)(Jg,{kind:{type:Ng.BasketZone,basketId:t.basketId},children:[t.empty&&(0,Y.jsx)(b,{color:`textSecondary`,children:`Empty`}),(0,Y.jsx)(L_,{data:e,mat:{label:``,material:t.material,isFree:!1,sortable:!1}})]})]},t.basketId))]})}function z_({data:e,region:t}){switch(t.kind){case`free`:return(0,Y.jsx)(Jg,{kind:{type:Ng.FreeMaterialZone},children:(0,Y.jsx)(L_,{data:e,mat:{label:t.label,material:t.material,isFree:!0,sortable:!1}})});case`queue`:return(0,Y.jsx)(Jg,{kind:{type:Ng.QueueZone,queue:t.label},children:(0,Y.jsx)(Np,{matIds:t.material.mats.map(e=>e.materialID),direction:`vertical`,queueName:t.label,renderDragOverlay:t=>(0,Y.jsx)(cf,{mat:t,displayActionForSinglePallet:e.pallet?e.pallet.palletNum:0,displayActionForSingleBasket:e.activeBasket?.basketId,fsize:M_(t,e.pallet,e.activeBasket)?e.fsize:void 0}),children:(0,Y.jsx)(L_,{data:e,mat:{label:t.label,material:t.material,isFree:!1,sortable:!0}})})});case`baskets`:return(0,Y.jsx)(R_,{data:e,label:t.label,baskets:t.baskets})}}function B_(){let e=r(ya),t=r(Bl),n=(0,K.useMemo)(()=>{let n=er(new Date(e*6e4),-5);return t.matsById.valuesToLazySeq().filter(e=>e.completed_last_proc_machining===!0&&e.last_unload_time!==void 0&&e.last_unload_time>=n).toSortedArray({desc:e=>e.last_unload_time?.getTime()??0})},[t,e]);return(0,Y.jsx)(`div`,{children:n.map((e,t)=>(0,Y.jsx)(af,{mat:e},t))})}var V_=(0,K.memo)(function({fillViewPort:e,showMaterial:t}){let n=qg({type:t?Ng.CompletedExpandedMaterialZone:Ng.CompletedCollapsedMaterialZone});return t&&e?(0,Y.jsxs)(B,{ref:n,sx:{padding:`8px`,display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,Y.jsx)(b,{variant:`h4`,children:`Completed`}),(0,Y.jsx)(B,{sx:{position:`relative`,flexGrow:1},children:(0,Y.jsx)(B,{sx:{position:`absolute`,top:`0`,left:`0`,right:`0`,bottom:`0`,overflow:`auto`},children:(0,Y.jsx)(B_,{})})})]}):t?(0,Y.jsxs)(B,{ref:n,sx:{padding:`8px`},children:[(0,Y.jsx)(b,{variant:`h4`,children:`Completed`}),(0,Y.jsx)(B_,{})]}):(0,Y.jsx)(B,{ref:n,sx:{display:`flex`,justifyContent:e?`flex-end`:void 0,padding:`8px`},children:(0,Y.jsx)(b,{variant:`h4`,sx:{margin:`4px`,...e?{textOrientation:`mixed`,writingMode:`vertical-rl`}:{}},children:`Completed`})})});function H_({pallet:e}){let t=r(tc),n=r(ga),i=Ic();if(t===null)return null;let a;if(t.action.type===U.Loading&&t.action.loadOntoPalletNum===e?a=`load`:(t.action.type===U.UnloadToInProcess||t.action.type===U.UnloadToCompletedMaterial)&&t.location.type===H.OnPallet&&t.location.palletNum===e&&(a=`unload`),a===void 0)return null;let o=Xi(t.partName,a,t.materialID,e,t.action.type===U.Loading?t.action.processAfterLoad??t.process:t.process,n);return i?(0,Y.jsx)(z,{color:`primary`,children:`Instructions`}):(0,Y.jsx)(z,{href:o,target:`bms-instructions`,color:`primary`,children:`Instructions`})}function U_({queues:e,onClose:t,toQueue:n,showAddToQueue:i,setShowAddToQueue:a}){let o=j(X),s=r(fc),c=r(Xs),l=r(tc),u=r(ga),[d,f]=Tc(),[p,m]=(0,K.useState)(null),h=hc().length>0;return!c||!Bd(l)||e.length===0||l?.location.type===H.InQueue&&l?.location.currentQueue&&e.includes(l?.location.currentQueue)?null:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Up,{suspended:h,children:(0,Y.jsxs)(z,{color:`primary`,disabled:h||n===null||f,onClick:async()=>{if(!h){m(null);try{await d({materialId:c.materialID,queue:n??``,queuePosition:-1,operator:u}),o(null),t()}catch(e){m(Dd(e))}}},children:[`Add To `,n??`Queue`,` `,s?` To Run Process ${s.process+1}`:``]})}),p?(0,Y.jsx)(b,{role:`alert`,children:p}):null]}):(0,Y.jsx)(Up,{suspended:h,children:(0,Y.jsx)(z,{color:`primary`,disabled:h,onClick:()=>a(!0),children:`Add To Queue`})})}function W_(){let e=r(G),t=j(Sg),n=r(Xs);return!e.allowChangeWorkorderAtLoadStation||n===null||n.materialID<0?null:(0,Y.jsx)(z,{color:`primary`,onClick:()=>t(!0),children:`Assign Workorder`})}var G_=(0,K.memo)(function(e){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(!1),[a,o]=(0,K.useState)(null),s=(0,K.useCallback)(function(){n(null),i(!1),o(null)},[n]);return(0,Y.jsx)(xf,{onClose:s,allowNote:!0,highlightProcsGreaterOrEqualTo:t?.process??void 0,extraDialogElements:(0,Y.jsxs)(Y.Fragment,{children:[t===null?null:(0,Y.jsx)(_m,{st:t,setState:n}),r?(0,Y.jsx)(am,{selectedQueue:a,setSelectedQueue:o,queueNames:e.queues}):void 0]}),buttons:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(H_,{pallet:e.pallet}),(0,Y.jsx)(Hp,{}),(0,Y.jsx)(fm,{}),(0,Y.jsx)(pm,{onClose:s}),(0,Y.jsx)(jg,{}),(0,Y.jsx)(U_,{toQueue:a,queues:e.queues,onClose:s,showAddToQueue:r,setShowAddToQueue:i}),(0,Y.jsx)(vm,{st:t,setState:n,onClose:s,loadStation:!0}),(0,Y.jsx)(W_,{})]})})});function K_({numMatCols:e,maxNumFaces:t,horizontal:n,showMatInCompleted:r}){let i=``,a=``;if(t<=0&&(t=1),n){let n=``;for(let t=0;t<e;t++)a+=`minmax(16em, max-content) `,n+=`mat${t} `;a+=`1fr `,a+=r?`minmax(16em, max-content)`:` 4.5em`;let o=`minmax(calc((100vh - 64px) / ${t}), max-content)`;for(let e=0;e<t;e++){let r=e===t-1?`1fr`:o;i+=`"${n} palface${e} completed" ${r}\n`}}else{a=`1fr`;for(let e=0;e<t;e++)i+=`"palface${e}" minmax(134px, max-content)\n`;for(let t=0;t<e;t++)i+=`"mat${t}" minmax(134px, max-content)\n`;i+=`"completed" minmax(134px, max-content)
|
|
55
|
+
`}return`${i} / ${a}`}function q_(e){let t=eo(r(G).basketName),n=t.endsWith(`s`)?t:`${t}s`,i=r(q),a=r(dp),o=(0,K.useMemo)(()=>N_(e.loadNum,e.queues,i,a),[i,e.loadNum,e.queues,a]),s=[...D.of(o.queues).sortBy(([e])=>e).map(([e,t])=>({kind:`queue`,label:e,material:t})).toRArray()];if(o.baskets.size>0){let e=D.of(o.baskets).filter(([e])=>e!==o.activeBasket?.basketId).sortBy(([e])=>e).map(([e,n])=>{let r=i.baskets?.[e];return{basketId:e,label:`${t} ${e}`,material:n,empty:n.mats.length===0&&n.hiddenCnt===0&&(r?.slotCount??0)>0&&r?.emptySlots?.length===r?.slotCount&&(r?.unknownSlots?.length??0)===0}}).toRArray();e.length>0&&s.push({kind:`baskets`,label:n,baskets:e})}(o.queues.size===0&&o.baskets.size===0||o.freeLoadingMaterial.length>0)&&s.push({kind:`free`,label:`Material`,material:{mats:o.freeLoadingMaterial,hiddenCnt:0}});let c=s.length+ +!!e.completed,l=rt(c<=1?`(min-width: 720px)`:c===2?`(min-width: 1030px)`:`(min-width: 1320px)`),u=K_({numMatCols:s.length,maxNumFaces:o.face.size,horizontal:l,showMatInCompleted:e.completed});return(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(Kg,{hideArrows:!l,whiteBackground:e.whiteBackground,children:(0,Y.jsxs)(B,{component:`main`,sx:{width:`100%`,display:`grid`,gridTemplate:u,minHeight:{xs:`calc(100vh - 64px - 32px)`,sm:`calc(100vh - 64px - 40px)`,md:`calc(100vh - 64px)`},padding:l?void 0:`8px`},children:[s.map((e,t)=>(0,Y.jsx)(B,{"data-testid":j_(e),sx:{gridArea:`mat${t}`,padding:`8px`,borderRight:l?`1px solid black`:void 0,borderBottom:l?void 0:`1px solid black`},children:(0,Y.jsx)(z_,{data:o,region:e})},t)),o.face.keysToAscLazySeq().map((e,t)=>(0,Y.jsx)(B,{sx:{marginLeft:`15px`,gridArea:`palface${t}`,padding:`8px`,borderTop:o.pallet&&t!==0?`1px solid black`:void 0},children:(0,Y.jsx)(I_,{data:o,faceNum:e})},e)),(0,Y.jsx)(B,{"data-testid":`load-station-completed`,sx:{borderLeft:l?`1px solid black`:void 0,borderTop:l?void 0:`1px solid black`,gridArea:`completed`},children:(0,Y.jsx)(V_,{fillViewPort:l,showMaterial:e.completed})}),(0,Y.jsx)(P_,{loadData:o}),(0,Y.jsx)(Dg,{}),(0,Y.jsx)(Mg,{}),(0,Y.jsx)(G_,{pallet:o.pallet?.palletNum??null,queues:e.queues})]})})})}function J_(e){let t=r(G);return Q(Za(e.loadNum,t.loadStationNames)),(0,Y.jsx)(q_,{...e})}function Y_(e){let t=Ic(),n=r(ga),i=r(Xs),a=r(fc)?.process,[o,s]=_c(),c=j(X);if(i===null)return null;function l(t){i&&(o({mat:i,inspType:e.inspection_type,success:t,operator:n}),c(null))}let u=Xi(i.partName,e.inspection_type,i.materialID,null,a,n);return(0,Y.jsxs)(Y.Fragment,{children:[i.partName===``?void 0:t?(0,Y.jsx)(z,{color:`primary`,children:`Instructions`}):(0,Y.jsx)(z,{href:u,target:`bms-instructions`,color:`primary`,children:`Instructions`}),(0,Y.jsx)(fm,{}),(0,Y.jsx)(pm,{}),(0,Y.jsxs)(z,{color:`primary`,disabled:s,onClick:()=>l(!0),children:[`Mark `,e.inspection_type,` Success`]}),(0,Y.jsxs)(z,{color:`primary`,disabled:s,onClick:()=>l(!1),children:[`Mark `,e.inspection_type,` Failed`]})]})}function X_({focusInspectionType:e}){let t=r(pc);return t===null||e||t.signaledInspections.length===1?null:(0,Y.jsx)(Y.Fragment,{children:t.signaledInspections.map(e=>(0,Y.jsx)(N,{children:(0,Y.jsx)(Y_,{inspection_type:e})},e))})}function Z_({focusInspectionType:e}){let t=r(pc),n;if(e)n=e;else if(t&&t.signaledInspections.length===1)n=t.signaledInspections[0];else return null;return(0,Y.jsx)(Y_,{inspection_type:n})}var Q_=(0,K.memo)(function(e){return(0,Y.jsx)(xf,{allowNote:!0,extraDialogElements:(0,Y.jsx)(X_,{focusInspectionType:e.focusInspectionType}),buttons:(0,Y.jsx)(Z_,{focusInspectionType:e.focusInspectionType})})});function $_({focusInspectionType:e,forceSingleColumn:t}){let n=r(Bl),i=(0,K.useMemo)(()=>tv(n.matsById,e),[n,e]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{sx:{display:t?void 0:{md:`flex`}},children:[(0,Y.jsxs)(B,{sx:{padding:`8px`,minHeight:t?void 0:{md:`calc(100vh - 64px)`},width:t?`100%`:{md:`50vw`},borderRight:t?void 0:{md:`1px solid black`},borderBottom:t?`1px solid black`:{sm:`1px solid black`,md:`none`}},children:[(0,Y.jsx)(b,{variant:`h4`,children:`Parts to Inspect`}),(0,Y.jsx)(B,{sx:{display:`flex`,justifyContent:`flex-start`,flexWrap:`wrap`},children:i.waiting_to_inspect.map((t,n)=>(0,Y.jsx)(af,{mat:t,focusInspectionType:e,hideWarningIcon:!0},n))})]}),(0,Y.jsxs)(B,{sx:{padding:`8px`,width:t?`100%`:{md:`50vw`}},children:[(0,Y.jsx)(b,{variant:`h4`,children:`Recently Inspected`}),(0,Y.jsx)(B,{sx:{display:`flex`,justifyContent:`flex-start`,flexWrap:`wrap`},children:i.inspect_completed.map((t,n)=>(0,Y.jsx)(af,{mat:t,focusInspectionType:e,hideWarningIcon:!0},n))})]})]}),(0,Y.jsx)(Q_,{focusInspectionType:e})]})}function ev(e){let t=e.completedInspections;return t===void 0?e.signaledInspections.length===0:D.of(e.signaledInspections).every(e=>e in t)}function tv(e,t){let n=P(new Date,-7),r=P(new Date,-1),i=Array.from(t===null?e.valuesToLazySeq().filter(e=>e.last_unload_time!==void 0&&e.last_unload_time>=n&&e.signaledInspections.length>0&&!ev(e)):e.valuesToLazySeq().filter(e=>e.last_unload_time!==void 0&&e.last_unload_time>=n&&e.signaledInspections.includes(t)&&(e.completedInspections||{})[t]===void 0));i.sort((e,t)=>e.last_unload_time&&t.last_unload_time?t.last_unload_time.getTime()-e.last_unload_time.getTime():0);let a=Array.from(t===null?e.valuesToLazySeq().filter(e=>e.completed_inspect_time!==void 0&&e.completed_inspect_time>=r&&e.signaledInspections.length>0&&ev(e)):e.valuesToLazySeq().filter(e=>e.completed_inspect_time!==void 0&&e.completed_inspect_time>=r&&e.signaledInspections.includes(t)&&(e.completedInspections||{})[t]!==void 0));return a.sort((e,t)=>e.completed_inspect_time&&t.completed_inspect_time?t.completed_inspect_time.getTime()-e.completed_inspect_time.getTime():0),{waiting_to_inspect:i,inspect_completed:a}}function nv(e){return Q(e.focusInspectionType&&e.focusInspectionType!==``?`Inspection ${e.focusInspectionType}`:`Inspection`),(0,Y.jsx)(B,{component:`main`,sx:{backgroundColor:`#F8F8F8`,minHeight:{sm:`calc(100vh - 64px - 40px)`,md:`calc(100vh - 64px)`}},children:(0,Y.jsx)($_,{...e})})}function rv(){let e=r(G),t=r(Xs),[n,i]=vc(),a=r(ga),[o,s]=A(X);if(t===null)return null;let c=e.requireScanAtCloseout,l=e.requireWorkorderBeforeAllowCloseoutComplete,u;c?(o===null||o.type!==`Barcode`&&o.type!==`ManuallyEnteredSerial`)&&(u=`Scan Required`):l&&(t.workorderId===void 0||t.workorderId===``)&&(u=`No workorder assigned`);function d(e){t!==null&&(n({mat:t,operator:a,failed:e}),s(null))}return u?(0,Y.jsx)(S,{title:u,placement:`top`,children:(0,Y.jsx)(`div`,{children:(0,Y.jsx)(z,{color:`primary`,disabled:!0,children:`Close Out`})})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{color:`primary`,disabled:i,onClick:()=>d(!0),children:`Fail Close Out`}),(0,Y.jsx)(z,{color:`primary`,disabled:i,onClick:()=>d(!1),children:`Pass Close Out`})]})}function iv(){let e=Ic(),t=r(Xs),n=r(ga),i=r(fc)?.process;if(t===null||t.partName===``)return null;let a=Xi(t.partName,`closeout`,t.materialID,null,i,n);return e?(0,Y.jsx)(z,{color:`primary`,children:`Instructions`}):(0,Y.jsx)(z,{href:a,target:`bms-instructions`,color:`primary`,children:`Instructions`})}function av(){let e=j(Sg);return r(Xs)===null?null:(0,Y.jsx)(z,{color:`primary`,onClick:()=>e(!0),children:`Assign Workorder`})}var ov=(0,K.memo)(function(){return(0,Y.jsx)(xf,{allowNote:!0,buttons:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(iv,{}),(0,Y.jsx)(fm,{}),(0,Y.jsx)(pm,{}),(0,Y.jsx)(av,{}),(0,Y.jsx)(rv,{})]})})}),sv=F(new Date);sv.onMount=e=>{e(new Date);let t=setInterval(()=>{e(new Date)},6e4);return()=>clearInterval(t)};function cv({forceSingleColumn:e}){let t=r(Bl),n=r(sv),i=(0,K.useMemo)(()=>{let e=er(n,-48),r=er(n,-2),i=[],a=[];for(let n of t.matsById.values())n.completed_last_proc_machining===!0&&n.last_unload_time&&n.last_unload_time>=e&&(n.closeout_completed===void 0?i.push(n):n.closeout_completed>=r&&a.push(n));return i.sort((e,t)=>e.last_unload_time&&t.last_unload_time?e.last_unload_time.getTime()-t.last_unload_time.getTime():0),a.sort((e,t)=>e.last_unload_time&&t.last_unload_time?t.last_unload_time.getTime()-e.last_unload_time.getTime():0),{uncompleted:i,closed:a}},[t,n]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{sx:{display:e?void 0:{md:`flex`}},children:[(0,Y.jsxs)(B,{sx:{padding:`8px`,minHeight:e?void 0:{md:`calc(100vh - 64px)`},width:e?`100%`:{md:`50vw`},borderRight:e?void 0:{md:`1px solid black`},borderBottom:e?`1px solid black`:{sm:`1px solid black`,md:`none`}},children:[(0,Y.jsx)(b,{variant:`h4`,children:`Recently Completed`}),(0,Y.jsx)(B,{sx:{display:`flex`,justifyContent:`flex-start`,flexWrap:`wrap`},children:i.uncompleted.map((e,t)=>(0,Y.jsx)(af,{mat:e},t))})]}),(0,Y.jsxs)(B,{sx:{padding:`8px`,width:e?`100%`:{md:`50vw`}},children:[(0,Y.jsx)(b,{variant:`h4`,children:`Recently Closed Out`}),(0,Y.jsx)(B,{sx:{display:`flex`,justifyContent:`flex-start`,flexWrap:`wrap`},children:i.closed.map((e,t)=>(0,Y.jsx)(af,{mat:e},t))})]})]}),(0,Y.jsx)(Dg,{}),(0,Y.jsx)(ov,{})]})}function lv(){return Q(`Close Out`),(0,Y.jsx)(B,{component:`main`,sx:{backgroundColor:`#F8F8F8`,minHeight:{sm:`calc(100vh - 64px - 40px)`,md:`calc(100vh - 64px)`}},children:(0,Y.jsx)(cv,{})})}function uv(e,t){return e.mapValues(e=>{let n=D.of(e.recentCycles).flatMap(e=>e.tools).filter(e=>!e.toolChangedDuringMiddleOfCycle).groupBy(e=>e.toolName).map(([e,t])=>({toolName:e,cycleUsageMinutes:D.of(t).sumBy(e=>e.cycleUsageMinutes)/t.length,cycleUsageCnt:D.of(t).sumBy(e=>e.cycleUsageCnt)/t.length,toolChangedDuringMiddleOfCycle:!1})).toMutableArray();return t&&n.sort((e,t)=>e.toolName.localeCompare(t.toolName)),{tools:n}})}var dv=class{constructor(e,t){this.statGroup=e,this.operation=t}compare(e){let t=this.statGroup.localeCompare(e.statGroup);return t===0?this.operation.localeCompare(e.operation):t}hash(){return ve(this.statGroup,this.operation)}toString(){return`{statGroup: ${this.statGroup}, operation: ${this.operation}}`}};function fv(e,t){let n=0,r=0;for(let i of D.of(e).filter(e=>e.machines.has(t)??!1))n+=i.quantity*(i.scheduledUseMinutes/i.scheduledUseCnt),r+=i.quantity;return r===0?0:n/r}function pv(e,t,n){let r=T.empty();for(let[t,n]of D.ofObject(e.jobs)){let i=n.cycles??0;for(let a=0;a<n.procsAndPaths.length;a++){let o=0,s=T.empty();for(let r=0;r<n.procsAndPaths[a].paths.length;r++){o+=n.completed?.[a]?.[r]??0;let i=n.procsAndPaths[a].paths[r];for(let n=0;n<i.stops.length;n+=1){let o=i.stops[n],c=D.of(e.material).filter(e=>e.jobUnique===t&&e.process==a+1&&e.path===r+1&&(e.action.type===U.UnloadToCompletedMaterial||e.action.type===U.UnloadToInProcess||e.lastCompletedMachiningRouteStopIndex!==void 0&&e.lastCompletedMachiningRouteStopIndex>n)).length();o.program!==void 0&&o.program!==``&&(s=s.modify(new dv(o.stationGroup,o.program),e=>(e??0)+c))}}for(let[e,t]of s)r=r.modify(new ka(n.partName,e.statGroup,e.operation),e=>(e??0)+i-o-t)}}let i=D.of(uv(n,!1)).flatMap(([e,t])=>{let i=window.bmsToolReportOverridePartQuantity??r.get(e);return i!==void 0&&i>0?t.tools.map(t=>({toolName:t.toolName,part:{partAndProg:e,quantity:i,scheduledUseMinutes:t.cycleUsageMinutes,scheduledUseCnt:t.cycleUsageCnt===0?1:t.cycleUsageCnt,machines:n.get(e)?.machines??Se.empty()}})):[]}).sortBy(e=>e.part.partAndProg.part,e=>e.part.partAndProg.operation).toLookup(e=>e.toolName,e=>e.part);return D.of(t).orderedGroupBy(e=>e.toolName).map(([e,t])=>{let n=!1;return{toolName:e,machines:D.of(t).sortBy(e=>e.machineGroupName,e=>e.machineNum,e=>e.pocket).map(t=>{let r=t.currentUse!==null&&t.currentUse!==void 0&&t.currentUse!==``?J(t.currentUse):null,a=t.totalLifeTime!==null&&t.totalLifeTime!==void 0&&t.totalLifeTime!==``?J(t.totalLifeTime):null,o=Xa(t.machineGroupName,t.machineNum),s=t.currentUseCount??null,c=t.totalLifeCount??null;if(s===null&&c===null){let t=fv(i.get(e)??[],o);t>0&&(n=!0,s=r===null?null:r/t,c=a===null?null:a/t)}return{machineName:o,pocket:t.pocket,serial:t.serial,currentUseMinutes:r,lifetimeMinutes:a,remainingMinutes:r!==null&&a!==null?Math.max(0,a-r):null,currentUseCnt:s??null,lifetimeCnt:c??null,remainingCnt:s!==null&&c!==null?Math.max(0,c-s):null}}).toRArray(),parts:i.get(e)??[],estimatedToolCounts:n}}).toRArray()}var mv=F(null),hv=F(e=>e(mv)?.time??null,async(e,t,n)=>{t(mv,{tools:await Hi.getToolsInMachines(),time:n})}),gv=F(e=>{let t=e(mv);return t===null?[]:D.of(t.tools).toOrderedSet(e=>Xa(e.machineGroupName,e.machineNum)).toAscLazySeq().toRArray()}),_v=F(e=>{let t=e(mv);if(t===null)return null;let n=e(q),r=e(Xl);return pv(n,t.tools,r)}),vv=F(e=>{let t=e(_v);return t?D.of(t).flatMap(e=>e.machines).some(e=>e.serial!=null&&e.serial!==``):!1}),yv=F(e=>{let t=e(_v);return t?D.of(t).some(e=>e.estimatedToolCounts):!1});function bv(e){let t=D.of(e).flatMap(e=>e.machines).some(e=>e.currentUseMinutes!=null),n=D.of(e).flatMap(e=>e.machines).some(e=>e.currentUseCnt!=null),r=`<table>
|
|
56
|
+
<thead><tr>`;r+=`<th>Tool</th><th>Machine</th><th>Pocket</th>`,t&&(r+=`<th>Scheduled Use (min)</th><th>Current Use (min)</th><th>Lifetime (min)</th><th>Remaining Life (min)</th>`),n&&(r+=`<th>Scheduled Use (cnt)</th><th>Current Use (cnt)</th><th>Lifetime (cnt)</th><th>Remaining Life (cnt)</th>`),r+=`</tr></thead>
|
|
57
|
+
<tbody>
|
|
58
|
+
`;for(let i of e)for(let e of i.machines){if(r+=`<tr><td>${i.toolName}</td><td>${e.machineName}</td><td>${e.pocket}</td>`,t){let t=D.of(i.parts).sumBy(e=>e.scheduledUseMinutes*e.quantity);r+=`<td>`+t.toFixed(1)+`</td>`,r+=`<td>`+(e.currentUseMinutes?e.currentUseMinutes.toFixed(1):``)+`</td>`,r+=`<td>`+(e.lifetimeMinutes?e.lifetimeMinutes.toFixed(1):``)+`</td>`,r+=`<td>`+(e.remainingMinutes?e.remainingMinutes.toFixed(1):``)+`</td>`}if(n){let t=D.of(i.parts).sumBy(e=>e.scheduledUseCnt*e.quantity);r+=`<td>`+t.toFixed(1)+`</td>`,r+=`<td>`+(e.currentUseCnt?e.currentUseCnt.toFixed(1):``)+`</td>`,r+=`<td>`+(e.lifetimeCnt?e.lifetimeCnt.toFixed(1):``)+`</td>`,r+=`<td>`+(e.remainingCnt?e.remainingCnt.toFixed(1):``)+`</td>`}r+=`</tr>
|
|
59
|
+
`}return r+=`</tbody></table>`,r}function xv(){let e=qn();return(0,K.useCallback)(()=>{let t=e.get(_v);t&&Je(bv(t))},[e])}function Sv(e,t,n,r,i){let a=uv(e,!0),o=e.keysToLazySeq().toRMap(e=>[e.operation,e],(e,t)=>t),s=D.of(r);i!=null&&(s=s.filter(e=>i.has(e.programName)));let c=n?.valuesToLazySeq().flatMap(e=>D.of(e.procsAndPaths).flatMap(e=>e.paths).flatMap(t=>D.of(t.stops).collect(n=>{let r=J(n.expectedCycleTime);return n.program&&r>0?{program:n.program,plannedMins:r/t.partsPerPallet,start:e.routeStartUTC}:null}))).toOrderedMap(e=>[e.program,e],(e,t)=>e.start>t.start?e:t),l=s.map(e=>{let n=o.get(e.programName);return{programName:e.programName,cellControllerProgramName:e.cellControllerProgramName,comment:e.comment??null,revision:e.revision??null,partName:n?.part??null,statisticalCycleTime:n?t.get(n)??null:null,toolUse:n?a.get(n)??null:null,plannedMins:c?.get(e.programName)?.plannedMins??null}}).toRArray();return{time:new Date,programs:l,hasRevisions:l.some(e=>e.revision!==null),cellNameDifferentFromProgName:l.some(e=>e.cellControllerProgramName!==e.programName)}}var Cv=F(`AllPrograms`),wv=F(null),Tv=F(e=>e(wv)?.time??null,async(e,t,n)=>{t(wv,{progs:await Hi.getProgramsInCellController(),time:n})}),Ev=F(e=>{if(e(Tv)===null)return null;let t=e(Cv),n=null;if(t===`ActivePrograms`){let t=e(q);n=new Set(D.ofObject(t.jobs).flatMap(([,e])=>e.procsAndPaths).flatMap(e=>e.paths).flatMap(e=>e.stops).filter(e=>e.program!==null&&e.program!==void 0&&e.program!==``).map(e=>e.program??``))}let r=e(wv);return r===null?null:Sv(e(Xl),e(ja),e(ia),r.progs,n)}),Dv=F(null),Ov=F(async e=>{let t=e(Dv);return t===null?``:t.revision===null?await Hi.getLatestProgramRevisionContent(t.programName):await Hi.getProgramRevisionContent(t.programName,t.revision)}),kv=F(null),Av=new Intl.NumberFormat(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:1}),jv=_r(o,{shouldForwardProp:e=>e.toString()[0]!==`$`})(({theme:e,$noBorderBottom:t,$highlightedRow:n,$noticeRow:r})=>({...t&&{"& > *":{borderBottom:`unset`}},[e.breakpoints.up(`lg`)]:{"& td:not(:last-child), & th:not(:last-child)":{whiteSpace:`nowrap`},"& td:last-child, & th:last-child":{width:`100%`}},backgroundColor:n?`#BDBDBD`:r?`#E0E0E0`:void 0})),Mv=_r(o,{shouldForwardProp:e=>e.toString()[0]!==`$`})(({$borderBottom:e})=>({...e&&{"&:not(:last-child)":{borderBottom:`2px solid black`}}})),Nv=_r(`span`)({fontSize:`x-large`,fontWeight:`lighter`});function Pv({min:e,cnt:t,showZero:n,extraMin:r,extraCnt:i}){e??=0,t??=0;let a=r?(0,Y.jsx)(S,{title:r,children:(0,Y.jsxs)(`span`,{children:[e.toFixed(1),` min`]})}):e.toFixed(1)+` min`,o=i?(0,Y.jsx)(S,{title:i,children:(0,Y.jsxs)(`span`,{children:[Av.format(t),` cnt`]})}):Av.format(t)+` cnt`;return e===0&&t===0?n?`0`:``:e>0&&t===0?a:e===0&&t>0?o:(0,Y.jsxs)(`span`,{children:[a,` `,(0,Y.jsx)(Nv,{children:`|`}),` `,o]})}function Fv({tool:e,machine:t}){let n=t?D.of(e.parts).filter(e=>e.machines.has(t)):D.of(e.parts);return(0,Y.jsxs)(he,{size:`small`,sx:{width:`auto`,ml:`10em`,mb:`1em`},children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Part`}),(0,Y.jsx)(w,{children:`Program`}),t?void 0:(0,Y.jsx)(w,{children:`Machines`}),(0,Y.jsx)(w,{align:`right`,children:`Quantity`}),(0,Y.jsx)(w,{align:`right`,children:`Use/Cycle (min)`}),(0,Y.jsx)(w,{align:`right`,children:`Use/Cycle (cnt)`})]})}),(0,Y.jsx)(ae,{children:n.isEmpty()?(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{colSpan:5,children:`No programs use this machine`})}):n.map((e,n)=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.partAndProg.part,size:20}),(0,Y.jsx)(`span`,{children:e.partAndProg.part})]})}),(0,Y.jsx)(w,{children:e.partAndProg.operation}),t?void 0:(0,Y.jsx)(w,{children:e.machines.foldl((e,t)=>(e.length>0?e+`, `:``)+t,``)}),(0,Y.jsx)(w,{align:`right`,children:e.quantity}),(0,Y.jsx)(w,{align:`right`,children:e.scheduledUseMinutes>0?e.scheduledUseMinutes.toFixed(1):``}),(0,Y.jsx)(w,{align:`right`,children:e.scheduledUseCnt>0?Av.format(e.scheduledUseCnt):``})]},n))})]})}function Iv({machines:e}){let t=r(vv),n=D.of(e).toLookupOrderedMap(e=>e.machineName,e=>e.pocket),i=n.size>1&&n.valuesToAscLazySeq().some(e=>e.size>1);return(0,Y.jsxs)(he,{size:`small`,sx:{width:`auto`,ml:`10em`,mb:`1em`},children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Machine`}),(0,Y.jsx)(w,{align:`right`,children:`Pocket`}),t?(0,Y.jsx)(w,{children:`Serial`}):void 0,(0,Y.jsx)(w,{align:`right`,children:`Current Use `}),(0,Y.jsx)(w,{align:`right`,children:`Lifetime `}),(0,Y.jsx)(w,{align:`right`,children:`Remaining Use `})]})}),(0,Y.jsxs)(ae,{children:[n.toAscLazySeq().map(([e,r])=>(0,Y.jsxs)(K.Fragment,{children:[r.valuesToAscLazySeq().map((e,n)=>(0,Y.jsxs)(Mv,{$borderBottom:i&&r.size===1,children:[(0,Y.jsx)(w,{children:e.machineName}),(0,Y.jsx)(w,{align:`right`,children:e.pocket}),t?(0,Y.jsx)(w,{children:e.serial??``}):void 0,(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:e.currentUseMinutes,cnt:e.currentUseCnt})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:e.lifetimeMinutes,cnt:e.lifetimeCnt})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:e.remainingMinutes,cnt:e.remainingCnt,showZero:!0})})]},n)),n.size>1&&r.size>1?(0,Y.jsxs)(Mv,{$borderBottom:!0,children:[(0,Y.jsx)(w,{colSpan:t?4:3}),(0,Y.jsx)(w,{children:`Subtotal`}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:r.valuesToAscLazySeq().sumBy(e=>e.remainingMinutes??0),cnt:r.valuesToAscLazySeq().sumBy(e=>e.remainingCnt??0)})})]}):void 0]},e)),(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{colSpan:t?4:3}),(0,Y.jsx)(w,{children:`Total`}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:D.of(e).sumBy(e=>e.remainingMinutes??0),cnt:D.of(e).sumBy(e=>e.remainingCnt??0)})})]})]})]})}function Lv(){let e=r(yv);return(0,Y.jsxs)(jv,{children:[(0,Y.jsx)(w,{}),(0,Y.jsx)(w,{children:`Tool`}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(S,{title:`Expected use for all currently scheduled parts.`+(e?` Counts are estimates.`:``),children:(0,Y.jsx)(`span`,{children:`Scheduled Use`})})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(S,{title:`Remaining use summed over all machines which have a scheduled part.`+(e?` Counts are estimates.`:``),children:(0,Y.jsx)(`span`,{children:`Total Remaining Use`})})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(S,{title:`Machine with the least remaining use.`+(e?` Counts are estimates.`:``),children:(0,Y.jsx)(`span`,{children:`Smallest Remaining Use`})})}),(0,Y.jsx)(w,{})]})}function Rv({tool:e}){let[t,n]=(0,K.useState)(!1),r=D.of(e.machines).filter(t=>e.parts.some(e=>e.machines.has(t.machineName))),i=D.of(e.parts).sumBy(e=>e.scheduledUseMinutes*e.quantity),a=D.of(e.parts).sumBy(e=>e.scheduledUseCnt*e.quantity),s=r.sumBy(e=>e.remainingMinutes??0),c=r.sumBy(e=>e.remainingCnt??0),l=r.groupBy(e=>e.machineName).map(([e,t])=>({mach:e,remainMin:D.of(t).sumBy(e=>e.remainingMinutes??0)})).minBy(({remainMin:e})=>e),u=r.groupBy(e=>e.machineName).map(([e,t])=>({mach:e,remainCnt:D.of(t).sumBy(e=>e.remainingCnt??0)})).minBy(({remainCnt:e})=>e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(jv,{$noBorderBottom:!0,$highlightedRow:i>s||a>c,$noticeRow:i<=s&&a<=c&&(l&&i>l.remainMin||u&&a>u.remainCnt),children:[(0,Y.jsx)(w,{children:(0,Y.jsx)(C,{size:`small`,onClick:()=>n(!t),children:t?(0,Y.jsx)(ke,{}):(0,Y.jsx)(f,{})})}),(0,Y.jsx)(w,{children:e.toolName}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:i,cnt:a})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:s,cnt:c})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:l?.remainMin,cnt:u?.remainCnt,showZero:!0,extraMin:l?.mach,extraCnt:u?.mach})}),(0,Y.jsx)(w,{})]}),(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{sx:{pb:`0`,pt:`0`},colSpan:6,children:(0,Y.jsx)(x,{in:t,timeout:`auto`,unmountOnExit:!0,children:(0,Y.jsxs)(B,{sx:{display:`flex`,flexWrap:`wrap`,justifyContent:`space-around`,ml:`1em`,mr:`1em`},children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Iv,{machines:e.machines})}),e.parts.length===0?void 0:(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Fv,{tool:e})})]})})})})]})}function zv({machine:e}){let t=r(yv),n=r(vv);return(0,Y.jsxs)(jv,{children:[(0,Y.jsx)(w,{}),(0,Y.jsxs)(w,{children:[`Tool In `,e]}),(0,Y.jsx)(w,{align:`right`,children:`Pocket`}),n?(0,Y.jsx)(w,{children:`Serial`}):void 0,(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(S,{title:`Expected use for all currently scheduled parts.`+(t?` Counts are estimates.`:``),children:(0,Y.jsx)(`span`,{children:`Scheduled Use`})})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(S,{title:`Current recorded usage of this tool.`+(t?` Counts are estimates.`:``),children:(0,Y.jsx)(`span`,{children:`Current Use`})})}),(0,Y.jsxs)(w,{align:`right`,children:[(0,Y.jsx)(S,{title:`Current configured lifetime of this tool.`+(t?` Counts are estimates.`:``),children:(0,Y.jsx)(`span`,{children:`Lifetime`})}),` `]}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(S,{title:`Lifetime minus current use.`+(t?` Counts are estimates.`:``),children:(0,Y.jsx)(`span`,{children:`Remaining Use`})})}),(0,Y.jsx)(w,{})]})}function Bv({report:e,pocket:t}){let[n,i]=(0,K.useState)(!1),a=r(vv),s=a?9:8,c=D.of(e.parts).filter(e=>e.machines.has(t.machineName)).sumBy(e=>e.scheduledUseMinutes*e.quantity),l=D.of(e.parts).filter(e=>e.machines.has(t.machineName)).sumBy(e=>e.scheduledUseCnt*e.quantity);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(jv,{$noBorderBottom:!0,children:[(0,Y.jsx)(w,{children:(0,Y.jsx)(C,{size:`small`,onClick:()=>i(!n),children:n?(0,Y.jsx)(ke,{}):(0,Y.jsx)(f,{})})}),(0,Y.jsx)(w,{children:e.toolName}),(0,Y.jsx)(w,{align:`right`,children:t.pocket}),a?(0,Y.jsx)(w,{children:t.serial??``}):void 0,(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:c,cnt:l})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:t.currentUseMinutes,cnt:t.currentUseCnt})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:t.lifetimeMinutes,cnt:t.lifetimeCnt})}),(0,Y.jsx)(w,{align:`right`,children:(0,Y.jsx)(Pv,{min:t.remainingMinutes,cnt:t.remainingCnt})}),(0,Y.jsx)(w,{})]}),(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{sx:{pb:`0`,pt:`0`},colSpan:s,children:(0,Y.jsx)(x,{in:n,timeout:`auto`,unmountOnExit:!0,children:(0,Y.jsx)(Fv,{tool:e,machine:t.machineName})})})})]})}var Vv=`__Insight__FilterAnyMachine__`,Hv=F(null);function Uv(){let e=r(Hv),t=r(_v);return t===null?(0,Y.jsx)(`div`,{}):(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(je,{children:e===null?(0,Y.jsx)(Lv,{}):(0,Y.jsx)(zv,{machine:e})}),(0,Y.jsx)(ae,{children:t.map(t=>e===null?(0,Y.jsx)(Rv,{tool:t},t.toolName):(0,Y.jsx)(K.Fragment,{children:t.machines.filter(t=>t.machineName===e).map(e=>(0,Y.jsx)(Bv,{report:t,pocket:e},e.pocket))},t.toolName))})]})}function Wv(){let[e,t]=A(Hv),[n,i]=A(hv),[a,o]=(0,K.useState)(!1),s=r(gv),c=xv(),l=Ic();function u(){o(!0),i(new Date).catch(console.log).finally(()=>o(!1))}return l?(0,Y.jsx)(`div`,{}):n===null?(0,Y.jsx)(`main`,{style:{margin:`2em`,display:`flex`,justifyContent:`center`},children:(0,Y.jsx)(Lt,{color:`secondary`,size:`large`,variant:`extended`,style:{margin:`2em`},onClick:u,disabled:a,children:(0,Y.jsxs)(Y.Fragment,{children:[a?(0,Y.jsx)(pn,{size:10,style:{marginRight:`1em`}}):(0,Y.jsx)(Be,{fontSize:`inherit`,style:{marginRight:`1em`}}),`Load Tools`]})})}):(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsx)(S,{title:`Refresh Tools`,children:(0,Y.jsx)(`div`,{children:(0,Y.jsx)(C,{onClick:u,disabled:a,size:`small`,children:a?(0,Y.jsx)(pn,{size:10}):(0,Y.jsx)(Be,{fontSize:`inherit`})})})}),(0,Y.jsxs)(`span`,{style:{marginLeft:`1em`},children:[`Tools from `,(0,Y.jsx)(Ae,{date:n})]}),(0,Y.jsx)(`div`,{style:{flexGrow:`1`}}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:e??Vv,style:{marginLeft:`1em`},onChange:e=>{e.target.value===Vv?t(null):t(e.target.value)},children:[(0,Y.jsx)(L,{value:Vv,children:(0,Y.jsx)(`em`,{children:`All Machines`})}),s.map(e=>(0,Y.jsx)(L,{value:e,children:(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,Y.jsx)(`span`,{style:{marginRight:`1em`},children:e})})},e))]})}),(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},onClick:c,size:`large`,children:(0,Y.jsx)(ct,{})})})]})}function Gv(){return Q(`Tool Report`),(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsx)(Wv,{}),(0,Y.jsx)(`main`,{children:(0,Y.jsx)(jd,{children:(0,Y.jsx)(Uv,{})})})]})}var Kv=_r(o)(()=>({"& > *":{borderBottom:`unset`}}));function qv(e){if(e.length===0)return``;let t=e.lastIndexOf(`\\`);return t>=0&&t<e.length-2?e.substr(t+1):e}var Jv=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:2});function Yv(e){let[t,n]=(0,K.useState)(!1),r=j(Dv),i=j(kv),a=8+ +!!e.showCellCtrlCol+ +!!e.showRevCol,s=e.program.toolUse!==null&&e.program.toolUse.tools.length>0&&D.of(e.program.toolUse.tools).some(e=>e.cycleUsageMinutes>0),c=e.program.toolUse!==null&&e.program.toolUse.tools.length>0&&D.of(e.program.toolUse.tools).some(e=>e.cycleUsageCnt>0);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Kv,{children:[(0,Y.jsx)(w,{children:e.program.toolUse===null||e.program.toolUse.tools.length===0?void 0:(0,Y.jsx)(C,{size:`small`,onClick:()=>n(!t),children:t?(0,Y.jsx)(ke,{}):(0,Y.jsx)(f,{})})}),(0,Y.jsx)(w,{children:qv(e.program.programName)}),e.showCellCtrlCol?(0,Y.jsx)(w,{children:e.program.cellControllerProgramName}):void 0,(0,Y.jsx)(w,{children:e.program.partName===null?void 0:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.program.partName,size:20}),(0,Y.jsx)(`span`,{children:e.program.partName})]})}),(0,Y.jsx)(w,{children:e.program.comment??``}),e.showRevCol?(0,Y.jsx)(w,{children:e.program.revision===null?``:e.program.revision.toFixed()}):void 0,(0,Y.jsx)(w,{align:`right`,children:e.program.statisticalCycleTime===null?``:e.program.statisticalCycleTime.medianMinutesForSingleMat.toFixed(2)}),(0,Y.jsx)(w,{align:`right`,children:e.program.statisticalCycleTime===null?``:e.program.statisticalCycleTime.MAD_aboveMinutes.toFixed(2)}),(0,Y.jsx)(w,{align:`right`,children:e.program.statisticalCycleTime===null?``:e.program.statisticalCycleTime.MAD_belowMinutes.toFixed(2)}),(0,Y.jsx)(w,{align:`right`,children:e.program.plannedMins===null?``:Jv.format(e.program.plannedMins)}),(0,Y.jsxs)(w,{children:[(0,Y.jsx)(S,{title:`Load Program Content`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>r(e.program),children:(0,Y.jsx)(Wn,{})})}),e.program.revision===null?void 0:(0,Y.jsx)(S,{title:`Revision History`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>i(e.program),children:(0,Y.jsx)(ue,{})})})]})]}),(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{sx:{pb:`0`,pt:`0`},colSpan:a,children:(0,Y.jsx)(x,{in:t,timeout:`auto`,unmountOnExit:!0,children:(0,Y.jsx)(B,{sx:{mr:`1em`,ml:`3em`},children:e.program.toolUse===null||e.program.toolUse.tools.length===0?void 0:(0,Y.jsxs)(he,{size:`small`,sx:{width:`auto`,ml:`10em`,mr:`1em`},children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Tool`}),s?(0,Y.jsx)(w,{align:`right`,children:`Estimated Usage (min)`}):void 0,c?(0,Y.jsx)(w,{align:`right`,children:`Estimated Usage (count)`}):void 0]})}),(0,Y.jsx)(ae,{children:D.of(e.program.toolUse.tools).map((e,t)=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:e.toolName}),s?(0,Y.jsx)(w,{align:`right`,children:e.cycleUsageMinutes===0?``:e.cycleUsageMinutes.toFixed(1)}):void 0,c?(0,Y.jsx)(w,{align:`right`,children:e.cycleUsageCnt===0?``:e.cycleUsageCnt.toFixed(1)}):void 0]},t))})]})})})})})]})}function Xv(){let e=r(Ev),[t,n]=(0,K.useState)(`ProgramName`),[i,a]=(0,K.useState)(`asc`);if(e===null)return(0,Y.jsx)(`div`,{});let s=D.of(e.programs).sortWith((e,n)=>{let r=0;switch(t){case`ProgramName`:r=qv(e.programName).localeCompare(qv(n.programName));break;case`CellProgName`:r=e.cellControllerProgramName.localeCompare(n.cellControllerProgramName);break;case`Comment`:r=e.comment===null&&n.comment===null?0:e.comment===null?1:n.comment===null?-1:e.comment.localeCompare(n.comment);break;case`Revision`:r=e.revision===null&&n.revision===null?0:e.revision===null?1:n.revision===null?-1:e.revision-n.revision;break;case`PartName`:r=e.partName===null&&n.partName===null?0:e.partName===null?1:n.partName===null?-1:e.partName.localeCompare(n.partName);break;case`MedianTime`:r=e.statisticalCycleTime===null&&n.statisticalCycleTime===null?0:e.statisticalCycleTime===null?1:n.statisticalCycleTime===null?-1:e.statisticalCycleTime.medianMinutesForSingleMat-n.statisticalCycleTime.medianMinutesForSingleMat;break;case`DeviationAbove`:r=e.statisticalCycleTime===null&&n.statisticalCycleTime===null?0:e.statisticalCycleTime===null?1:n.statisticalCycleTime===null?-1:e.statisticalCycleTime.MAD_aboveMinutes-n.statisticalCycleTime.MAD_aboveMinutes;break;case`DeviationBelow`:r=e.statisticalCycleTime===null&&n.statisticalCycleTime===null?0:e.statisticalCycleTime===null?1:n.statisticalCycleTime===null?-1:e.statisticalCycleTime.MAD_belowMinutes-n.statisticalCycleTime.MAD_belowMinutes;break;case`Planned`:r=e.plannedMins===null&&n.plannedMins===null?0:e.plannedMins===null?1:n.plannedMins===null?-1:e.plannedMins-n.plannedMins}return r===0?0:r<0&&i===`asc`||r>0&&i===`desc`?-1:1});function c(e){e===t?a(i===`asc`?`desc`:`asc`):n(e)}return(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{}),(0,Y.jsx)(w,{sortDirection:t===`ProgramName`&&i,children:(0,Y.jsx)(fn,{active:t===`ProgramName`,direction:i,onClick:()=>c(`ProgramName`),children:`Program Name`})}),e.cellNameDifferentFromProgName?(0,Y.jsx)(w,{sortDirection:t===`CellProgName`&&i,children:(0,Y.jsx)(fn,{active:t===`CellProgName`,direction:i,onClick:()=>c(`CellProgName`),children:`Cell Controller Program`})}):void 0,(0,Y.jsx)(w,{sortDirection:t===`PartName`&&i,children:(0,Y.jsx)(fn,{active:t===`PartName`,direction:i,onClick:()=>c(`PartName`),children:`Part`})}),(0,Y.jsx)(w,{sortDirection:t===`Comment`&&i,children:(0,Y.jsx)(fn,{active:t===`Comment`,direction:i,onClick:()=>c(`Comment`),children:`Comment`})}),e.hasRevisions?(0,Y.jsx)(w,{sortDirection:t===`Revision`&&i,children:(0,Y.jsx)(fn,{active:t===`Revision`,direction:i,onClick:()=>c(`Revision`),children:`Revision`})}):void 0,(0,Y.jsx)(w,{sortDirection:t===`MedianTime`&&i,align:`right`,children:(0,Y.jsx)(fn,{active:t===`MedianTime`,direction:i,onClick:()=>c(`MedianTime`),children:`Median Time / Material (min)`})}),(0,Y.jsx)(w,{sortDirection:t===`DeviationAbove`&&i,align:`right`,children:(0,Y.jsx)(fn,{active:t===`DeviationAbove`,direction:i,onClick:()=>c(`DeviationAbove`),children:`Deviation Above Median`})}),(0,Y.jsx)(w,{sortDirection:t===`DeviationBelow`&&i,align:`right`,children:(0,Y.jsx)(fn,{active:t===`DeviationBelow`,direction:i,onClick:()=>c(`DeviationBelow`),children:`Deviation Below Median`})}),(0,Y.jsx)(w,{sortDirection:t===`Planned`&&i,align:`right`,children:(0,Y.jsx)(fn,{active:t===`Planned`,direction:i,onClick:()=>c(`Planned`),children:`Planned Time (min)`})}),(0,Y.jsx)(w,{})]})}),(0,Y.jsx)(ae,{children:D.of(s).map((t,n)=>(0,Y.jsx)(Yv,{program:t,showCellCtrlCol:e.cellNameDifferentFromProgName,showRevCol:e.hasRevisions},n))})]})}function Zv(){let e=r(Ov),[t,n]=(0,K.useState)(null),i=(0,K.useMemo)(()=>new Worker(new URL(`/assets/ProgramHighlight-C5uXGNDz.js`,``+import.meta.url),{type:`module`}),[]);return(0,K.useEffect)(()=>{let e=e=>n(e),t=t=>e(t.data);return i.addEventListener(`message`,t),()=>{e=()=>null,i.removeEventListener(`message`,t),i.terminate(),n(null)}},[i]),(0,K.useEffect)(()=>{e&&e!==``&&i.postMessage(e,[])},[e,i]),(0,Y.jsx)(`pre`,{children:t===null?(0,Y.jsx)(`code`,{className:`gcode`,children:e}):(0,Y.jsx)(`code`,{className:`gcode`,dangerouslySetInnerHTML:{__html:t}})})}function Qv(){let[e,t]=A(Dv),n=r(kv);return(0,Y.jsxs)(I,{open:e!==null&&n===null,onClose:()=>t(null),maxWidth:`lg`,children:[(0,Y.jsx)($n,{children:e?.partName?(0,Y.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.partName}),(0,Y.jsxs)(`div`,{style:{marginLeft:`10px`,marginRight:`3em`},children:[e?.programName??`Program`,` `,e?.revision?` rev`+e.revision.toFixed():``,` `,(0,Y.jsxs)(b,{variant:`subtitle1`,component:`span`,children:[`(`,e.partName,`)`]})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[e?.programName??`Program`,` `,e?.revision?` rev`+e.revision.toFixed():``]})}),(0,Y.jsx)(M,{children:e===null||n!==null?(0,Y.jsx)(`div`,{}):(0,Y.jsx)(jd,{children:(0,Y.jsx)(Zv,{})})}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{onClick:()=>t(null),children:`Close`})})]})}var $v=10;function ey(e){let t=r(kv),n=j(Dv);return(0,Y.jsxs)(he,{children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Revision`}),(0,Y.jsx)(w,{children:`Comment`}),(0,Y.jsx)(w,{children:`Cell Controller Program`}),(0,Y.jsx)(w,{})]})}),(0,Y.jsx)(ae,{children:e.loading?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{colSpan:4,children:(0,Y.jsx)(pn,{})})}),D.ofRange(0,9).map(e=>(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{colSpan:4})},e))]}):D.of(e.revisions).drop(e.page*$v).take($v).map(e=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:e.revision}),(0,Y.jsx)(w,{children:e.comment??``}),(0,Y.jsx)(w,{children:e.cellControllerProgramName??``}),(0,Y.jsx)(w,{children:(0,Y.jsx)(S,{title:`Load Program Content`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>n({...e,partName:t?.partName??null}),children:(0,Y.jsx)(Wn,{})})})})]},e.revision))})]})}function ty(){let[e,t]=A(kv),[n,r]=A(Dv),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)({page:0,hasMore:!1}),[c,l]=(0,K.useState)(0),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null);(0,K.useEffect)(()=>{(async()=>{if(e===null)a(null),l(0),s({page:0,hasMore:!1});else if(e!==null&&i===null){d(!0),p(null);try{let t=await Hi.getProgramRevisionsInDescendingOrderOfRevision(e.programName,$v,void 0);a(t),s({page:0,hasMore:t.length===$v})}catch(e){p(e instanceof Error?e:String(e))}finally{d(!1)}}})().catch(console.error)},[e,i]);function m(){if(c<o.page)l(c+1);else if(o.hasMore&&e!==null&&i!==null&&i.length>0){d(!0),p(null);let t=i[i.length-1];Hi.getProgramRevisionsInDescendingOrderOfRevision(e.programName,$v,t?t.revision-1:void 0).then(e=>{a(t=>t===null?e:t.concat(e)),s({page:c+1,hasMore:e.length===$v}),l(c+1)}).catch(p).finally(()=>d(!1))}}return(0,Y.jsxs)(I,{open:e!==null,onClose:()=>t(null),maxWidth:`lg`,children:[(0,Y.jsx)($n,{children:e?.partName?(0,Y.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.partName}),(0,Y.jsxs)(`div`,{style:{marginLeft:`10px`,marginRight:`3em`},children:[e.programName??`Program`,` `,(0,Y.jsxs)(b,{variant:`subtitle1`,component:`span`,children:[`(`,e.partName,`)`]})]})]}):(0,Y.jsx)(Y.Fragment,{children:e?.programName??`Program`})}),(0,Y.jsxs)(M,{children:[f===null?void 0:(0,Y.jsx)(Tt,{children:(0,Y.jsx)(Xt,{children:typeof f==`string`?f:f.message})}),n===null?i===null?u?(0,Y.jsx)(pn,{}):void 0:(0,Y.jsx)(ey,{page:c,revisions:i,loading:u}):(0,Y.jsx)(jd,{children:(0,Y.jsx)(Zv,{})})]}),(0,Y.jsx)(N,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`},children:[n===null?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{title:`Latest Revisions`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(C,{onClick:()=>l(0),disabled:u||c===0,size:`large`,children:(0,Y.jsx)(xe,{})})})}),(0,Y.jsx)(S,{title:`Previous Page`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(C,{onClick:()=>l(c-1),disabled:u||c===0,size:`large`,children:(0,Y.jsx)(vr,{})})})}),(0,Y.jsx)(S,{title:`Next Page`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(C,{onClick:()=>m(),disabled:u||c===o.page&&!o.hasMore,size:`large`,children:(0,Y.jsx)(Ze,{})})})})]}):void 0,(0,Y.jsx)(`div`,{style:{flexGrow:1}}),n===null?void 0:(0,Y.jsx)(z,{onClick:()=>r(null),children:`Back to History`}),(0,Y.jsx)(z,{onClick:()=>t(null),children:`Close`})]})})]})}function ny(){let[e,t]=A(Tv),[n,r]=(0,K.useState)(!1),i=Ic(),[a,o]=A(Cv);function s(){r(!0),t(new Date).catch(console.log).finally(()=>r(!1))}return i?(0,Y.jsx)(`div`,{}):e===null?(0,Y.jsx)(`main`,{style:{margin:`2em`,display:`flex`,justifyContent:`center`},children:(0,Y.jsx)(Lt,{color:`secondary`,size:`large`,variant:`extended`,style:{margin:`2em`},onClick:s,disabled:n,children:(0,Y.jsxs)(Y.Fragment,{children:[n?(0,Y.jsx)(pn,{size:10,style:{marginRight:`1em`}}):(0,Y.jsx)(Be,{fontSize:`inherit`,style:{marginRight:`1em`}}),`Load Programs`]})})}):(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsx)(S,{title:`Refresh Programs`,children:(0,Y.jsx)(`div`,{children:(0,Y.jsx)(C,{onClick:s,disabled:n,size:`small`,children:n?(0,Y.jsx)(pn,{size:10}):(0,Y.jsx)(Be,{fontSize:`inherit`})})})}),(0,Y.jsxs)(`span`,{style:{marginLeft:`1em`},children:[`Programs from `,(0,Y.jsx)(Ae,{date:e})]}),(0,Y.jsx)(`div`,{style:{flexGrow:1}}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,value:a,onChange:e=>o(e.target.value),children:[(0,Y.jsx)(L,{value:`AllPrograms`,children:`All Programs`},`AllPrograms`),(0,Y.jsx)(L,{value:`ActivePrograms`,children:`Active Programs`},`ActivePrograms`)]})})]})}function ry(){return Q(`Programs`),(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsx)(ny,{}),(0,Y.jsx)(`main`,{children:(0,Y.jsx)(jd,{children:(0,Y.jsx)(Xv,{})})}),(0,Y.jsx)(Qv,{}),(0,Y.jsx)(ty,{})]})}var iy=[{id:0,label:`Date`,numeric:!1,getDisplay:e=>e.routeStartTime.toLocaleString(),getForSort:e=>e.routeStartTime.getTime(),getForExport:e=>e.routeStartTime.toISOString()},{id:1,label:`Part`,numeric:!1,getDisplay:e=>e.partName},{id:2,label:`Scheduled`,numeric:!0,getDisplay:e=>e.scheduledQty.toString(),getForSort:e=>e.scheduledQty},{id:3,label:`Removed`,numeric:!0,getDisplay:e=>e.decrementedQty.toString(),getForSort:e=>e.decrementedQty},{id:4,label:`Completed`,numeric:!0,getDisplay:e=>e.completedQty.toString()}];function ay({job:e}){let[t,n]=(0,K.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Fm,{children:[iy.map(t=>(0,Y.jsx)(w,{align:t.numeric?`right`:`left`,children:t.id===1?(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:e.partName,size:25})}),(0,Y.jsx)(`div`,{children:e.partName})]}):t.getDisplay(e)},t.id)),(0,Y.jsx)(w,{children:(0,Y.jsx)(S,{title:`Show Details`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>n(!t),children:t?(0,Y.jsx)(ke,{}):(0,Y.jsx)(f,{})})})})]}),(0,Y.jsx)(Im,{children:(0,Y.jsx)(w,{sx:{pb:`0`,pt:`0`},colSpan:iy.length+1,children:(0,Y.jsx)(x,{in:t,timeout:`auto`,unmountOnExit:!0,children:(0,Y.jsx)(Ap,{job:e.inProcJob?e.inProcJob:e.historicJob,checkAnalysisMonth:!0})})})})]})}function oy(){let e=r(od),t=Rh(),n=Lh(e),i=zh(0,iy),a=r(e.type===`Last30`?Bl:Hl),o=r(e.type===`Last30`?ia:ca),s=(0,K.useMemo)(()=>cp(n.zoomRange,a.matsById,o,null),[n,a.matsById,o]),c=(0,K.useMemo)(()=>D.of(s).sortBy(i.sortOn).drop(t.page*t.rowsPerPage).take(t.rowsPerPage),[s,i,t]);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(Ah,{columns:iy,sort:i,showDetailsCol:!0,copyToClipboardRows:s}),(0,Y.jsx)(ae,{children:c.map((e,t)=>(0,Y.jsx)(ay,{job:e},e.historicJob?.unique??e.inProcJob?.unique??t))})]}),(0,Y.jsx)(Fh,{tpage:t,zoom:n.zoom,count:s.length})]})}function sy(){return Q(`Scheduled Jobs`),(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(`main`,{style:{padding:`24px`},children:(0,Y.jsx)(oy,{})})})}function cy(){Q(`Quality`);let e=r(od),t=r(e.type===`Last30`?Ml:Pl),n=e.type===`Last30`?`Last30Days`:`ZoomIntoRange`,i=e.type===`Last30`?[P(k(),-29),P(k(),1)]:[e.month,Vt(e.month,1)];return(0,Y.jsx)(rg,{subtitle:`Inspection decisions grouped by path`,inspectionlogs:t,zoomType:n,default_date_range:i})}var ly={display:`flex`,backgroundColor:`#E0E0E0`,paddingLeft:`24px`,paddingRight:`24px`,paddingBottom:`4px`,height:`2.5em`,alignItems:`flex-end`},uy={display:`flex`,alignSelf:`center`,alignItems:`flex-end`},dy=`@@all_inspection_display@@`,fy=`@@recent_completed_material@@`;function py(e){return typeof e==`string`?e.split(`,`):e}function my(){let[e,t]=A(dp);return(0,Y.jsx)(An,{control:(0,Y.jsx)(en,{size:`small`,checked:e,onChange:e=>t(e.target.checked)}),label:`Hide Non-Loading Material`,sx:{pl:2,pr:2}})}function hy(){let[e,t]=A(Nc),n=r($c),i=D.of(Object.keys(r(q).queues)).toSortedArray(e=>e),a=r(G),o=d(),s=rt(o.breakpoints.down(`md`));function c(n){let r=parseFloat(n);!isNaN(r)&&isFinite(r)&&(e.route===Z.Station_LoadMonitor?t({route:Z.Station_LoadMonitor,loadNum:r,queues:e.queues,completed:e.completed}):t({route:Z.Station_LoadMonitor,loadNum:r,queues:[],completed:!1}))}function l(e){t(e===dy?{route:Z.Station_InspectionMonitor}:{route:Z.Station_InspectionMonitorWithType,inspType:e})}function u(n){let r=n.includes(fy);n=n.filter(e=>e!==fy).slice(0,2),e.route===Z.Station_LoadMonitor?t({route:Z.Station_LoadMonitor,loadNum:e.loadNum,queues:n,completed:r}):t({route:Z.Station_LoadMonitor,loadNum:1,queues:n,completed:r})}function f(e){t({route:Z.Station_Queues,queues:e})}let p=`LoadUnload`,m=1,h=null,g=[];switch(e.route){case Z.Station_LoadMonitor:p=`LoadUnload`,m=e.loadNum,g=e.queues,e.completed&&(g=g.concat(fy));break;case Z.Station_InspectionMonitor:p=`Inspection`,h=``;break;case Z.Station_InspectionMonitorWithType:p=`Inspection`,h=e.inspType;break;case Z.Station_Queues:p=`Queues`,g=e.queues;break;case Z.Station_Closeout:p=`CloseOut`;break;default:p=`AllMaterial`}return(0,Y.jsxs)(B,{component:`nav`,sx:s?ly:uy,children:[p===`LoadUnload`?a.loadStationNames&&Object.keys(a.loadStationNames).length>0?(0,Y.jsx)(O,{value:m,onChange:e=>c(e.target.value.toString()),variant:`standard`,style:{marginLeft:`1em`,minWidth:`8em`},children:D.of(Object.entries(a.loadStationNames)).sortBy(([e])=>parseInt(e)).map(([e,t])=>(0,Y.jsx)(L,{value:parseInt(e),children:t},e))},`loadnumselect`):(0,Y.jsx)(an,{type:`number`,placeholder:`Load Station Number`,value:m,onChange:e=>c(e.target.value),style:{width:`3em`,marginLeft:`1em`}},`loadnumselect`):void 0,p===`Inspection`?(0,Y.jsxs)(O,{value:h||dy,onChange:e=>l(e.target.value),variant:`standard`,style:{marginLeft:`1em`},children:[(0,Y.jsx)(L,{value:dy,children:(0,Y.jsx)(`em`,{children:`All`})},dy),D.of(n).concat(h?[h]:[]).distinctAndSortBy(e=>e).map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]},`inspselect`):void 0,p===`LoadUnload`?(0,Y.jsxs)(R,{style:{marginLeft:`1em`},children:[g.length===0?(0,Y.jsx)(`label`,{style:{position:`absolute`,top:`10px`,left:0,color:`rgba(0,0,0,0.54)`,fontSize:`0.9rem`},children:`Display queue(s)`}):void 0,(0,Y.jsxs)(O,{multiple:!0,displayEmpty:!0,variant:`standard`,value:g,inputProps:{id:`queueselect`},style:{minWidth:`10em`,marginTop:`0`},onChange:e=>u(py(e.target.value)),children:[i.map((e,t)=>(0,Y.jsx)(L,{value:e,children:e},t)),(0,Y.jsx)(L,{value:fy,children:(0,Y.jsx)(`i`,{children:`Completed`})}),(0,Y.jsx)(_n,{}),(0,Y.jsx)(my,{})]})]}):void 0,p===`Queues`?(0,Y.jsxs)(R,{style:{marginLeft:`1em`,minWidth:`10em`},children:[g.length===0?(0,Y.jsx)(`label`,{style:{position:`absolute`,top:`10px`,left:0,color:`rgba(0,0,0,0.54)`,fontSize:`0.9rem`},children:`Select queue(s)`}):void 0,(0,Y.jsx)(O,{multiple:!0,displayEmpty:!0,variant:`standard`,value:g,inputProps:{id:`queueselect`},style:{marginTop:`0`},onChange:e=>f(py(e.target.value)),children:i.map((e,t)=>(0,Y.jsx)(L,{value:e,children:e},t))})]}):void 0]})}function gy(){let e=d(),t=rt(e.breakpoints.down(`md`));return(0,Y.jsx)(B,{sx:{display:`flex`,alignItems:`center`,height:`100%`,bgcolor:t?`#E0E0E0`:void 0},children:(0,Y.jsx)(C_,{full:t})})}var _y=l(`shift-starts`,[[1,360],[2,840],[3,1320]]),vy=F(e=>new Map(e(_y)),(e,t,n)=>{let r=new Map(e(_y));n(r),t(_y,Array.from(r.entries()))});function yy(e){let t=r(vy);return(0,K.useMemo)(()=>{let n=[];for(let e=1;e<=3;e++){let r=t.get(e);r!==void 0&&(n.length>=1&&n[n.length-1]>=r||n.push(r))}if(n.length===0)return[{start:e,end:P(e,1)}];let r=Gn(P(e,1),n[0]),i=[];for(let t=0;t<n.length;t++)i.push({start:Gn(e,n[t]),end:t===n.length-1?r:Gn(e,n[t+1])});return i},[t,e])}function by(e){let[t,n]=e.split(`:`);return parseInt(t,10)*60+parseInt(n,10)}function xy(e){let t=Math.floor(e/60),n=e%60;return`${t.toString().padStart(2,`0`)}:${n.toString().padStart(2,`0`)}`}function Sy(e,t){let n=t.get(e);if(n===void 0)return!1;if(e===1){let e=t.get(2)??t.get(3);return e!==void 0&&e<=n}if(e===2){let e=t.get(1),r=t.get(3);return e!==void 0&&e>=n||r!==void 0&&r<=n}if(e===3){let e=t.get(2)??t.get(1);return e!==void 0&&e>=n}return!1}function Cy({shiftNum:e}){let[t,n]=A(vy),r=t.get(e);return(0,Y.jsx)(_,{type:`time`,label:`Shift ${e} Start`,error:Sy(e,t),value:r===void 0?``:xy(r),onChange:t=>{let r=t.target.value;n(r===``?t=>t.delete(e):t=>t.set(e,by(r)))},variant:`standard`,size:`small`,slotProps:{inputLabel:{shrink:!0},input:e===1?void 0:{endAdornment:(0,Y.jsx)(S,{title:`Clear/Disable Shift`,children:(0,Y.jsx)(ln,{sx:{mb:`4px`},onClick:()=>n(t=>t.delete(e)),children:(0,Y.jsx)(gn,{fontSize:`small`})})})}}})}function wy(){return(0,Y.jsxs)(E,{direction:`row`,spacing:2,children:[(0,Y.jsx)(Cy,{shiftNum:1}),(0,Y.jsx)(Cy,{shiftNum:2}),(0,Y.jsx)(Cy,{shiftNum:3})]})}function Ty(e,t){return n=>{let r=e(n);for(let e=0;e<t.length;e++){let i=t[e];if(r>=i.start&&r<i.end)return{val:n,shift:e}}return null}}function Ey(e,t){return D.of(e).filter(e=>e.finalProcess).collect(Ty(e=>e.completeTime,t)).toLookupOrderedMap(e=>e.val.partName,e=>e.shift,e=>e.val.quantity,(e,t)=>e+t)}function Dy(e,t){return e.valuesToLazySeq().filter(e=>Wa(e)&&e.operation===`UNLOAD`&&D.of(e.material).some(e=>e.proc===e.numproc)).collect(Ty(e=>e.endTime,t)).toLookupOrderedMap(e=>e.val.part,e=>e.shift,e=>D.of(e.val.material).sumBy(e=>+(e.proc===e.numproc)),(e,t)=>e+t)}function Oy(e){let t=r(ao),n=r(ml),i=yy(e);return(0,K.useMemo)(()=>{let e=Ey(n,i),r=Dy(t,i);return e.mapValues(e=>({planned:e})).adjust(r,(e,t)=>e?{...e,completed:t}:{completed:t}).toAscLazySeq().map(([e,{planned:t,completed:n}])=>({part:e,planned:t??se.empty(),completed:n??se.empty()})).toRArray()},[t,n,i])}var ky=new Intl.DateTimeFormat(void 0,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`});function Ay({row:e}){return(0,Y.jsxs)(E,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,Y.jsx)($,{part:e.part,size:25}),(0,Y.jsx)(`span`,{children:e.part})]})}function jy(e){let t=yy(e).length;return(0,K.useMemo)(()=>{let e=[{id:0,numeric:!1,label:`Part`,getDisplay:e=>e.part,getForTotal:()=>0,Cell:Ay},{id:1,numeric:!0,label:`Shift 1 Planned`,getDisplay:e=>e.planned.get(0)?.toString()??``,getForSort:e=>e.planned.get(0)??0,getForTotal:e=>e.planned.get(0)??0},{id:4,numeric:!0,label:`Shift 1 Completed`,getDisplay:e=>e.completed.get(0)?.toString()??``,getForSort:e=>e.completed.get(0)??0,getForTotal:e=>e.completed.get(0)??0}];return t>=2&&(e.push({id:2,numeric:!0,label:`Shift 2 Planned`,getDisplay:e=>e.planned.get(1)?.toString()??``,getForSort:e=>e.planned.get(1)??0,getForTotal:e=>e.planned.get(1)??0}),e.push({id:5,numeric:!0,label:`Shift 2 Completed`,getDisplay:e=>e.completed.get(1)?.toString()??``,getForSort:e=>e.completed.get(1)??0,getForTotal:e=>e.completed.get(1)??0})),t===3&&(e.push({id:3,numeric:!0,label:`Shift 3 Planned`,getDisplay:e=>e.planned.get(2)?.toString()??``,getForSort:e=>e.planned.get(2)??0,getForTotal:e=>e.planned.get(2)??0}),e.push({id:6,numeric:!0,label:`Shift 3 Completed`,getDisplay:e=>e.completed.get(2)?.toString()??``,getForSort:e=>e.completed.get(2)??0,getForTotal:e=>e.completed.get(2)??0})),e},[t])}function My({columns:e,rows:t}){return(0,Y.jsx)(o,{children:e.map(e=>(0,Y.jsx)(w,{align:e.numeric?`right`:`left`,children:e.id===0?`Total`:D.of(t).sumBy(e.getForTotal)},e.id))})}var Ny=(0,K.memo)(function({columns:e,rows:t}){let n=zh(0,e);return(0,Y.jsx)(B,{sx:{overflowX:`auto`},children:(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(Ah,{columns:e,sort:n,showDetailsCol:!1}),(0,Y.jsx)(Ih,{columns:e,pageData:D.of(t).toSortedArray(n.sortOn,e=>e.part)}),(0,Y.jsx)(Fe,{children:(0,Y.jsx)(My,{columns:e,rows:t})})]})})});function Py({day:e,setDay:t}){let n=k();return(0,Y.jsxs)(E,{direction:`row`,spacing:2,sx:{alignItems:`center`},children:[(0,Y.jsx)(S,{title:`Previous Day`,children:(0,Y.jsx)(`div`,{children:(0,Y.jsx)(C,{disabled:e<=P(n,-28),onClick:()=>t(e=>P(e,-1)),children:(0,Y.jsx)(dr,{})})})}),(0,Y.jsx)(b,{sx:{minWidth:`14em`,textAlign:`center`},children:ky.format(e)}),(0,Y.jsx)(S,{title:`Next Day`,children:(0,Y.jsx)(`div`,{children:(0,Y.jsx)(C,{disabled:e>=n,onClick:()=>t(e=>P(e,1)),children:(0,Y.jsx)(tt,{})})})})]})}var Fy=`"shifts day export" auto / 1fr 1fr 1fr`,Iy=`"shifts export" auto
|
|
60
|
+
"day day" auto / 1fr auto`,Ly=function({day:e,setDay:t,columns:n,rows:r}){return(0,Y.jsxs)(B,{component:`nav`,sx:{display:`grid`,gridTemplate:{md:Fy,xs:Iy},minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsx)(B,{sx:{gridArea:`shifts`,justifySelf:`flex-start`},children:(0,Y.jsx)(wy,{})}),(0,Y.jsx)(B,{sx:{gridArea:`day`,justifySelf:`center`},children:(0,Y.jsx)(Py,{day:e,setDay:t})}),(0,Y.jsx)(B,{sx:{gridArea:`export`,justifySelf:`flex-end`},children:(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:()=>Vh(n,r),children:(0,Y.jsx)(ct,{})})})})]})};function Ry(){Q(`Recent Completed Parts`);let[e,t]=(0,K.useState)(k),n=jy(e),r=Oy(e);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsx)(Ly,{day:e,setDay:t,rows:r,columns:n}),(0,Y.jsx)(`main`,{children:(0,Y.jsx)(Ny,{rows:r,columns:n})})]})}function zy(){let[e,t]=(0,K.useState)(!1);function n(){t(!0),zi.enableVerboseLoggingForFiveMinutes(),setTimeout(()=>t(!1),3e5)}return(0,Y.jsx)(`main`,{style:{marginTop:`4em`},children:(0,Y.jsxs)(`div`,{style:{maxWidth:`50em`,marginLeft:`auto`,marginRight:`auto`,textAlign:`center`},children:[(0,Y.jsx)(`p`,{style:{marginBottom:`1em`},children:`Verbose logging generates a large amount of additional data in the FMS Insight Server debug log file.`}),(0,Y.jsx)(z,{disabled:e,onClick:n,variant:`contained`,children:e?(0,Y.jsx)(`span`,{children:`Verbose Logging is Enabled`}):(0,Y.jsx)(`span`,{children:`Enable Verbose Logging For 5 minutes`})})]})})}function By(){return(0,Y.jsxs)(`svg`,{width:`30px`,height:`30px`,viewBox:`0 0 170 170`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,Y.jsxs)(`defs`,{children:[(0,Y.jsx)(`path`,{id:`t`,d:`m307.5 125v77.5h-40c6.92-6.52 11.25-10.6 12.98-12.23 10.65-10.04 13.56-25.81 7.21-38.99-1.7-3.5-5.92-12.26-12.69-26.28z`}),(0,Y.jsx)(`path`,{id:`ag`,d:`m273.88 120.52c-0.13 0.28-4.87 3.3-11.17 0.5-6.3-2.81-11.99-9.96-11.67-10.67 0.32-0.72 9.44-1.27 15.74 1.53 6.3 2.81 7.23 8.35 7.1 8.64z`}),(0,Y.jsx)(`path`,{id:`m`,d:`m259 102.25c-0.13 0.29-4.2 3.61-9.02 1.46-4.81-2.14-8.75-8.51-8.43-9.23 0.31-0.71 7.69-2.05 12.5 0.1 4.82 2.14 5.07 7.39 4.95 7.67z`}),(0,Y.jsx)(`path`,{id:`x`,d:`m282.79 114.2c-0.2 0.24-5.59 1.84-10.87-2.59-5.29-4.44-8.78-12.88-8.28-13.48 0.5-0.59 9.42 1.38 14.7 5.82 5.29 4.43 4.65 10.02 4.45 10.25z`}),(0,Y.jsx)(`path`,{id:`k`,d:`m268.39 125.43c-0.12-0.28-4.33-3.54-9.45-1.26s-9.41 8.81-9.1 9.52c0.32 0.71 8.05 1.89 13.17-0.39s5.51-7.58 5.38-7.87z`}),(0,Y.jsx)(`path`,{id:`ae`,d:`m243.83 111.58c0 0.31-2.61 5-8.43 5s-12.65-4.22-12.65-5 6.83-5 12.65-5 8.43 4.69 8.43 5z`}),(0,Y.jsx)(`path`,{id:`l`,d:`m304.24 109.88c-0.31 0.04-5.38-2.38-6.34-9.21s2.09-15.44 2.86-15.55 6.08 7.33 7.04 14.16-3.25 10.55-3.56 10.6z`}),(0,Y.jsx)(`path`,{id:`u`,d:`m306.79 80.57c-0.31 0.05-5.31-1.83-6.1-7.47-0.79-5.63 2.45-12.84 3.23-12.95 0.77-0.11 5.88 5.92 6.67 11.56s-3.49 8.82-3.8 8.86z`}),(0,Y.jsx)(`path`,{id:`a`,d:`m306.13 58.04c-0.31 0.05-5.23-1.3-5.86-5.74-0.62-4.43 2.83-10.24 3.6-10.34 0.77-0.11 5.68 4.51 6.31 8.95 0.62 4.44-3.74 7.09-4.05 7.13z`}),(0,Y.jsx)(`path`,{id:`f`,d:`m295.52 118.45c-0.29 0.13-6.1-1.39-9.5-9.02-3.39-7.64-3.53-18.31-2.82-18.63 0.72-0.32 8.56 6.93 11.96 14.56s0.64 12.97 0.36 13.09z`}),(0,Y.jsx)(`path`,{id:`b`,d:`m272.35 90.11c-0.26 0.19-5.76 0.58-9.58-4.67-3.82-5.26-4.88-13.9-4.25-14.36s8.52 3.23 12.34 8.48 1.74 10.37 1.49 10.55z`}),(0,Y.jsx)(`path`,{id:`s`,d:`m289.97 85.66c-0.28 0.13-5.97-0.97-9.17-7.84-3.21-6.87-3.15-16.73-2.44-17.06s8.3 5.96 11.5 12.83 0.4 11.94 0.11 12.07z`}),(0,Y.jsx)(`path`,{id:`n`,d:`m270.16 65.57c-0.28 0.14-5.38 0.38-7.35-3.65-1.96-4.03-0.48-10.62 0.22-10.96s6.8 2.54 8.77 6.58c1.97 4.03-1.36 7.9-1.64 8.03z`}),(0,Y.jsx)(`path`,{id:`ah`,d:`m250 80c-0.17 0.26-4.4 3.11-8.12 0.69s-5.79-8.79-5.37-9.45c0.43-0.65 7.1-1.35 10.82 1.06 3.72 2.42 2.84 7.44 2.67 7.7z`}),(0,Y.jsx)(`path`,{id:`y`,d:`m236.47 96.58c-0.11 0.29-3.72 3.89-7.83 2.23-4.12-1.66-7.37-7.53-7.07-8.25 0.29-0.72 6.7-2.68 10.81-1.02 4.12 1.66 4.21 6.75 4.09 7.04z`}),(0,Y.jsx)(`path`,{id:`aa`,d:`m290.52 56.48c-0.28 0.14-5.35 0.58-7.44-3.33-2.08-3.92-0.8-10.5-0.11-10.87s6.86 2.25 8.94 6.17c2.09 3.92-1.12 7.88-1.39 8.03z`}),(0,Y.jsx)(`path`,{id:`af`,d:`m274.18 138.46c-0.16-0.26-5.28-2.6-11.13 1.06s-10.48 11.53-10.07 12.19 9.52-0.05 15.37-3.71 6-9.27 5.83-9.54z`}),(0,Y.jsx)(`path`,{id:`z`,d:`m247.89 137.78c0.11 0.29-0.65 5.6-6.08 7.69-5.43 2.08-13.32 0.59-13.6-0.14s4.58-7.11 10.01-9.2c5.44-2.08 9.56 1.36 9.67 1.65z`}),(0,Y.jsx)(`path`,{id:`h`,d:`m235.06 125.39c0.1 0.3-0.26 5.38-4.46 6.83-4.19 1.44-10.49-0.85-10.75-1.59-0.25-0.74 3.3-6.42 7.5-7.87 4.19-1.44 7.61 2.34 7.71 2.63z`}),(0,Y.jsx)(`path`,{id:`ab`,d:`m317.14 85.63c0.28 0.13 5.97-0.98 9.17-7.85 3.21-6.87 3.14-16.72 2.44-17.05-0.71-0.33-8.3 5.95-11.5 12.82-3.21 6.87-0.4 11.94-0.11 12.08z`}),(0,Y.jsx)(`path`,{id:`ac`,d:`m299.61 124.96v77.5h40c-6.93-6.52-11.25-10.6-12.99-12.23-10.64-10.03-13.56-25.81-7.2-38.99 1.69-3.5 5.92-12.26 12.69-26.28z`}),(0,Y.jsx)(`path`,{id:`c`,d:`m348.11 102.22c0.13 0.28 4.2 3.6 9.01 1.46 4.82-2.15 8.76-8.52 8.44-9.23-0.32-0.72-7.69-2.05-12.5 0.09-4.82 2.14-5.08 7.39-4.95 7.68z`}),(0,Y.jsx)(`path`,{id:`p`,d:`m324.32 114.17c0.2 0.24 5.59 1.83 10.87-2.6 5.29-4.43 8.78-12.87 8.28-13.47s-9.42 1.38-14.71 5.81c-5.28 4.43-4.64 10.02-4.44 10.26z`}),(0,Y.jsx)(`path`,{id:`o`,d:`m338.71 125.4c0.13-0.29 4.34-3.55 9.46-1.27s9.41 8.81 9.09 9.52c-0.31 0.72-8.04 1.9-13.16-0.38s-5.51-7.59-5.39-7.87z`}),(0,Y.jsx)(`path`,{id:`j`,d:`m363.28 111.54c0 0.32 2.61 5 8.43 5s12.65-4.21 12.65-5c0-0.78-6.83-5-12.65-5s-8.43 4.69-8.43 5z`}),(0,Y.jsx)(`path`,{id:`w`,d:`m311.59 118.42c0.29 0.12 6.1-1.4 9.49-9.03 3.4-7.63 3.54-18.31 2.82-18.63-0.71-0.32-8.55 6.93-11.95 14.56s-0.64 12.97-0.36 13.1z`}),(0,Y.jsx)(`path`,{id:`i`,d:`m334.76 90.08c0.25 0.18 5.76 0.57 9.58-4.68 3.81-5.25 4.88-13.9 4.25-14.36s-8.53 3.23-12.34 8.48c-3.82 5.26-1.74 10.37-1.49 10.56z`}),(0,Y.jsx)(`path`,{id:`r`,d:`m333.23 120.48c0.12 0.29 4.86 3.31 11.17 0.5 6.3-2.81 11.98-9.96 11.67-10.67-0.32-0.71-9.44-1.27-15.74 1.53-6.3 2.81-7.23 8.35-7.1 8.64z`}),(0,Y.jsx)(`path`,{id:`ad`,d:`m336.95 65.54c0.28 0.13 5.38 0.38 7.35-3.66 1.96-4.03 0.48-10.61-0.22-10.96-0.7-0.34-6.81 2.55-8.77 6.58-1.97 4.03 1.36 7.9 1.64 8.04z`}),(0,Y.jsx)(`path`,{id:`ai`,d:`m357.11 79.96c0.17 0.27 4.39 3.11 8.12 0.69 3.72-2.41 5.79-8.79 5.36-9.44-0.42-0.66-7.09-1.36-10.81 1.06-3.72 2.41-2.84 7.43-2.67 7.69z`}),(0,Y.jsx)(`path`,{id:`d`,d:`m370.63 96.55c0.12 0.29 3.73 3.89 7.84 2.22 4.11-1.66 7.37-7.52 7.07-8.25-0.29-0.72-6.7-2.68-10.82-1.02-4.11 1.66-4.2 6.76-4.09 7.05z`}),(0,Y.jsx)(`path`,{id:`q`,d:`m316.59 56.44c0.28 0.15 5.35 0.59 7.43-3.33 2.09-3.92 0.81-10.5 0.12-10.87-0.69-0.36-6.86 2.26-8.95 6.17-2.08 3.92 1.12 7.88 1.4 8.03z`}),(0,Y.jsx)(`path`,{id:`v`,d:`m332.93 138.42c0.16-0.26 5.28-2.59 11.13 1.06 5.85 3.66 10.48 11.53 10.07 12.19-0.42 0.66-9.52-0.05-15.37-3.71-5.85-3.65-6-9.27-5.83-9.54z`}),(0,Y.jsx)(`path`,{id:`g`,d:`m359.22 137.74c-0.11 0.29 0.65 5.61 6.08 7.69 5.43 2.09 13.32 0.59 13.6-0.13 0.28-0.73-4.59-7.12-10.02-9.21-5.43-2.08-9.55 1.36-9.66 1.65z`}),(0,Y.jsx)(`path`,{id:`e`,d:`m372.05 125.36c-0.1 0.29 0.26 5.37 4.45 6.82 4.2 1.44 10.5-0.85 10.75-1.59 0.26-0.74-3.29-6.42-7.49-7.87-4.2-1.44-7.61 2.34-7.71 2.64z`})]}),(0,Y.jsx)(`g`,{transform:`translate(-219.32 -33)`,visibility:`inherit`,children:(0,Y.jsxs)(`g`,{visibility:`inherit`,children:[(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#t`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#t`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#ag`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#ag`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#m`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#m`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#x`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#x`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#k`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#k`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#ae`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#ae`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#l`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#l`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#u`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#u`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#a`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#a`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#f`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#f`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#b`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#b`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#s`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#s`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#n`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#n`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#ah`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#y`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#y`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#aa`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#aa`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#af`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#af`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#z`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#z`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#h`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#h`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#ab`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#ab`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#ac`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#ac`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#c`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#c`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#p`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#p`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#o`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#o`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#j`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#j`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#w`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#w`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#i`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#i`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#r`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#r`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#ad`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#ad`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#ai`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#d`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#d`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#q`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#q`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#v`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#v`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#g`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#g`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fill:`#DBA72E`,href:`#e`}),(0,Y.jsx)(`use`,{width:`100%`,height:`100%`,fillOpacity:`0`,stroke:`#DBA72E`,href:`#e`})]})})]})}var Vy=`__FMS_INSIGHT_NEW_OPERATOR__`,Hy=(0,K.memo)(function(){let e=r(G),[t,n]=A(ga),[i,a]=A(ha),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(``);function u(e){e.target.value===Vy?s(!0):n(e.target.value)}function d(e){a(t=>t.filter(t=>t!==e))}function f(){c!==``&&(a(e=>[...e.filter(e=>e!==c),c]),n(c),l(``),s(!1))}return e.user?(0,Y.jsx)(`div`,{children:e.user.profile.name||e.user.profile.sub}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(O,{value:t||``,onChange:u,variant:`standard`,renderValue:e=>e,children:[D.of(i).sortBy(e=>e).map((e,t)=>(0,Y.jsxs)(L,{value:e,children:[(0,Y.jsx)(_t,{primary:e}),(0,Y.jsx)(Ge,{children:(0,Y.jsx)(C,{edge:`end`,onClick:()=>d(e),size:`large`,children:(0,Y.jsx)(kn,{})})})]},t)),(0,Y.jsx)(L,{value:Vy,children:(0,Y.jsx)(`em`,{children:`Create New Operator`})},`new`)]}),(0,Y.jsxs)(I,{open:o,onClose:()=>{s(!1),l(``)},children:[(0,Y.jsx)($n,{children:`Create New Operator`}),(0,Y.jsx)(M,{children:(0,Y.jsx)(_,{value:c,onChange:e=>l(e.target.value),label:`New Name`,variant:`outlined`,autoFocus:!0,sx:{mt:`0.5em`},onKeyUp:e=>{e.keyCode===13&&f()}})}),(0,Y.jsxs)(N,{children:[(0,Y.jsxs)(z,{disabled:c===``,onClick:f,children:[`Create `,c]}),(0,Y.jsx)(z,{onClick:()=>{l(``),s(!1)},children:`Cancel`})]})]})]})}),Uy=(0,K.memo)(function(){let e=r(zf),t=r(ld),n=r(Wf),i=r(dd),a=r(Nc).route===Z.ChooseMode,[o,s]=(0,K.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[!a&&(n!=null||i!=null)?(0,Y.jsx)(S,{title:`Error`,children:(0,Y.jsx)(C,{"aria-label":`Error`,onClick:()=>s(!0),size:`large`,children:(0,Y.jsx)(Ut,{})})}):void 0,e||t?(0,Y.jsx)(S,{title:`Loading`,children:(0,Y.jsx)(pn,{"data-testid":`loading-icon`,color:`secondary`})}):void 0,(0,Y.jsxs)(I,{open:o&&!a,onClose:()=>s(!1),children:[(0,Y.jsx)($n,{children:`Error`}),(0,Y.jsxs)(M,{children:[n===null?void 0:(0,Y.jsx)(`p`,{children:n}),i===null?void 0:(0,Y.jsx)(`p`,{children:i})]}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{onClick:()=>s(!1),children:`Close`})})]})]})}),Wy=(0,K.memo)(function(){let e=r(G)?.customStationMonitorDialogUrl,[t,n]=(0,K.useState)(!1);if(!e)return null;let i=e.split(`/`),a=i[i.length-1];return a=a[0].toUpperCase()+a.substr(1),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{title:a,children:(0,Y.jsx)(C,{onClick:()=>n(!0),size:`large`,children:(0,Y.jsx)(sr,{})})}),(0,Y.jsxs)(I,{open:t,onClose:()=>n(!1),fullWidth:!0,maxWidth:`md`,children:[(0,Y.jsx)($n,{children:a}),(0,Y.jsx)(M,{children:(0,Y.jsx)(`iframe`,{width:`100%`,src:e,sandbox:`allow-scripts`,style:{border:0,height:`calc(100vh - 250px)`}})}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{color:`primary`,onClick:()=>n(!1),children:`Close`})})]})]})});function Gy({d:e}){let t=k(),n=Dn(e,t);return n>7?null:n>=0?(0,Y.jsxs)(b,{variant:`subtitle1`,children:[`License expires on `,e.toDateString()]}):(0,Y.jsxs)(b,{variant:`h6`,children:[`License expired on `,e.toDateString()]})}function Ky(){let e=r(G),t=``;return t=e.name?(e.name||``)+` `+(e.version||``):`SeedTactic FMS Insight`,(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{title:t,children:(0,Y.jsx)(`div`,{children:(0,Y.jsx)(By,{})})}),(0,Y.jsx)(b,{variant:`h6`,style:{marginLeft:`1em`,marginRight:`2em`},children:`Insight`}),e?.licenseExpires?(0,Y.jsx)(Gy,{d:e.licenseExpires}):void 0]})}function qy(){let e=r(q).alarms,[t,n]=(0,K.useState)(!1),i=(0,K.useId)(),a=e.length,o=a===0?`No alarms`:`${a} ${a===1?`alarm`:`alarms`}`,s=a===1?e[0]:o;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{title:s,children:(0,Y.jsx)(C,{"aria-label":o,"aria-haspopup":`dialog`,color:a>0?`error`:`inherit`,size:`large`,onClick:()=>n(!0),children:(0,Y.jsx)(Nt,{badgeContent:a,color:`error`,children:(0,Y.jsx)(Ne,{})})})}),(0,Y.jsxs)(I,{open:t,onClose:()=>n(!1),"aria-labelledby":i,fullWidth:!0,maxWidth:`sm`,scroll:`paper`,children:[(0,Y.jsx)($n,{id:i,children:`System alarms`}),(0,Y.jsx)(M,{dividers:!0,children:a===0?(0,Y.jsx)(b,{children:`No alarms.`}):(0,Y.jsx)(Wt,{disablePadding:!0,children:e.map((e,t)=>(0,Y.jsx)(xt,{disableGutters:!0,divider:t<a-1,children:(0,Y.jsx)(_t,{primary:e,slotProps:{primary:{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`}}}})},t))})}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{onClick:()=>n(!1),children:`Close`})})]})]})}function Jy(){let e=r(Nc);return(0,Y.jsx)(S,{title:`Help`,children:(0,Y.jsx)(C,{"aria-label":`Help`,href:Lc(e),target:`_help`,size:`large`,children:(0,Y.jsx)(Te,{})})})}function Yy(){return(0,Y.jsx)(S,{title:`Logout`,children:(0,Y.jsx)(C,{"aria-label":`Logout`,onClick:ta,size:`large`,children:(0,Y.jsx)(qe,{})})})}function Xy({showAlarms:e,showLogout:t,showSearch:n}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Uy,{}),(0,Y.jsx)(Wy,{}),n?(0,Y.jsx)(ap,{}):void 0,n?(0,Y.jsx)(Xp,{}):void 0,(0,Y.jsx)(Jy,{}),t?(0,Y.jsx)(Yy,{}):void 0,e?(0,Y.jsx)(qy,{}):void 0]})}function Zy({menuNavs:e}){let t=r(G),[n,i]=A(Nc),[a,o]=(0,K.useTransition)();return(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsx)(O,{value:n.route,sx:{width:`16.5em`},onChange:t=>o(()=>{let n=e.find(e=>`separator`in e?!1:e.route.route===t.target.value);!n||`separator`in n||i(n.route)}),renderValue:()=>{let r=e.find(e=>`separator`in e?!1:e.route.route===n.route);return!r||`separator`in r?null:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[r.icon,(0,Y.jsxs)(b,{variant:`h6`,style:{marginLeft:`1em`},children:[typeof r.name==`string`?r.name:r.name(t),a?`...`:``]})]})},children:e.map((e,n)=>`separator`in e?(0,Y.jsx)(h,{children:e.separator},e.separator):e.hidden?.(t)?void 0:(0,Y.jsxs)(L,{value:e.route.route,children:[(0,Y.jsx)(mt,{children:e.icon}),(0,Y.jsx)(_t,{primary:typeof e.name==`string`?e.name:e.name(t)})]},n))})})}function Qy({showAlarms:e,showLogout:t,showSearch:n,showOperator:r,Nav1:i,Nav2:a,menuNavs:o}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(or,{position:`static`,sx:{display:{xs:`none`,md:`block`}},children:(0,Y.jsx)(cn,{children:(0,Y.jsxs)(B,{sx:{display:`grid`,gridTemplateColumns:a?`1fr auto 1fr`:`minmax(200px, 1fr) auto`,width:`100vw`,gridTemplateAreas:a?`"nav navCenter tools"`:`"nav tools"`},children:[(0,Y.jsxs)(B,{sx:{gridArea:`nav`,display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(Ky,{}),i?(0,Y.jsx)(i,{}):void 0]}),a?(0,Y.jsx)(B,{sx:{gridArea:`navCenter`},children:(0,Y.jsx)(a,{})}):void 0,(0,Y.jsxs)(B,{sx:{gridArea:`tools`,display:`flex`,alignItems:`center`,justifyContent:`flex-end`},children:[r?(0,Y.jsx)(Hy,{}):void 0,(0,Y.jsx)(Xy,{showAlarms:e,showLogout:t,showSearch:n})]})]})})}),(0,Y.jsxs)(or,{position:`static`,sx:{display:{xs:`block`,md:`none`}},children:[(0,Y.jsxs)(cn,{children:[(0,Y.jsx)(Ky,{}),(0,Y.jsx)(`div`,{style:{flexGrow:1}}),(0,Y.jsx)(Xy,{showAlarms:e,showLogout:t,showSearch:n})]}),(0,Y.jsxs)(B,{sx:{display:`grid`,gridTemplateColumns:`minmax(200px, 1fr) auto`},children:[(0,Y.jsx)(B,{sx:{gridColumn:`1`},children:i?(0,Y.jsx)(i,{}):void 0}),(0,Y.jsx)(B,{sx:{gridColumn:`2`},children:a?(0,Y.jsx)(a,{}):void 0})]})]}),o&&o.length>0?(0,Y.jsx)(He,{elevation:4,square:!0,component:`nav`,sx:{display:{xs:`block`,xl:`none`},padding:`2px`},children:(0,Y.jsx)(Zy,{menuNavs:o})}):void 0]})}function $y({menuItems:e}){let t=r(G),[i,a]=A(Nc),[o,s]=(0,K.useTransition)();return!e||e.length===0?null:(0,Y.jsx)(He,{elevation:3,square:!0,sx:{flexShrink:0,display:{xs:`none`,xl:`block`},minHeight:`calc(100vh - 64px)`,zIndex:1},children:(0,Y.jsx)(Wt,{dense:!0,children:e?.map((e,r)=>`separator`in e?(0,Y.jsx)(h,{children:e.separator},e.separator):e.hidden?.(t)?void 0:(0,Y.jsx)(xt,{children:(0,Y.jsxs)(n,{selected:i.route===e.route.route,onClick:()=>s(()=>a(e.route)),children:[(0,Y.jsx)(mt,{children:e.icon}),(0,Y.jsx)(_t,{primary:typeof e.name==`string`?e.name:e.name(t),sx:o?e=>({color:e.palette.grey[700]}):void 0})]})},r))})})}function eb(e,t,n){return[{id:0,numeric:!1,label:`Date`,getDisplay:e=>e.endTime.toLocaleString(),getForSort:e=>e.endTime.getTime()},{id:1,numeric:!1,label:`Part`,getDisplay:e=>e.part+`-`+D.of(e.material).map(e=>e.proc).distinctAndSortBy(e=>e).toRArray().join(`:`)},{id:2,numeric:!1,label:`Station`,getDisplay:e=>Qa(e.stationGroup,e.stationNumber,t)},{id:6,numeric:!1,label:`Operation`,getDisplay:e=>e.operation},{id:3,numeric:!1,label:`Carrier`,getDisplay:e=>to(e,n),getForSort:e=>no(e)},{id:4,numeric:!1,label:`Serial`,getDisplay:e=>e.material.filter(e=>e.serial).map(e=>e.serial).join(`, `)},{id:5,numeric:!1,label:`Workorder`,getDisplay:e=>e.material.filter(e=>e.workorder).map(e=>e.workorder).join(`, `)},{id:7,numeric:!1,label:`Inspection`,getDisplay:t=>To(t,e),getForSort:t=>D.of(t.material).collect(t=>e.get(t.id)).flatMap(e=>e.signaledInspections).distinct().toSortedArray(e=>e).join(`,`)},{id:8,numeric:!0,label:`Elapsed Min`,getDisplay:e=>(e.elapsedMinsPerMaterial*e.material.length).toFixed(1)},{id:9,numeric:!0,label:`Target Min`,getDisplay:e=>e.activeMinutes.toFixed(1)},{id:10,numeric:!0,label:`Median Elapsed Min`,getDisplay:e=>e.medianCycleMinutes.toFixed(1)},{id:11,numeric:!0,label:`Median Deviation`,getDisplay:e=>e.MAD_aboveMinutes.toFixed(1)}]}function tb(e,t,n,r,i){let a;for(let e of t)e.id===r&&(a=e.getForSort||e.getDisplay);a===void 0&&(a=t[0].getForSort||t[0].getDisplay);let o=a,s=D.of(e.values()).flatMap(e=>e);return(n?s.filter(e=>e.endTime>=n.start&&e.endTime<=n.end):s).toSortedArray(i===`desc`?{desc:o}:{asc:o},i===`desc`?{desc:e=>e.endTime.getTime()}:{asc:e=>e.endTime.getTime()})}function nb(e){let t,n=e.set_date_zoom_range;return n&&(t=e.period.type===`Last30`?{type:`Last30Days`,set_days_back:e=>{if(e){let t=new Date;n({zoom:{start:P(t,-e),end:er(t,1)}})}else n({zoom:void 0})}}:{type:`ZoomIntoRange`,default_date_range:[e.period.month,Vt(e.period.month,1)],current_date_zoom:e.current_date_zoom,set_date_zoom_range:e=>n({zoom:e})}),{zoom:t,zoomRange:e.current_date_zoom}}var rb=(0,K.memo)(function(e){let t=r(G),n=eb(e.matsById,t.loadStationNames,eo(t.basketName)),i=zh(0,n),a=Rh(),o=nb(e),[s,c]=(0,K.useState)(null),l=j(X),u=tb(e.points,n,e.current_date_zoom,i.orderBy,i.order),d=u.length,f=u.slice(a.page*a.rowsPerPage,(a.page+1)*a.rowsPerPage),p=n.filter(t=>!(!e.showWorkorderAndInspect&&t.id===5||!e.showWorkorderAndInspect&&t.id===7||e.hideMedian&&t.id===10||e.hideMedian&&t.id===11));return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)(Ah,{columns:p,sort:i,showDetailsCol:!0}),(0,Y.jsx)(Ih,{columns:p,pageData:f,rowsPerPage:a.rowsPerPage,onClickDetails:(e,t)=>{t.material.length!==0&&(t.material.length===1?l({type:`LogMat`,logMat:t.material[0]}):c({anchorEl:e.currentTarget,material:t.material}))},emptyMessage:e.emptyMessage})]}),(0,Y.jsx)(Fh,{zoom:o.zoom,tpage:a,count:d}),(0,Y.jsx)(ye,{anchorEl:s?.anchorEl,keepMounted:!0,open:s!==null,onClose:()=>c(null),children:s?.material.map((e,t)=>(0,Y.jsx)(L,{onClick:()=>{l({type:`LogMat`,logMat:e}),c(null)},children:e.serial||`Material`},t))})]})});function ib({outlierTy:e}){Q(e===`machine`?`Machine Outliers`:`L/U Outliers`);let t=r(Bl),n=r(G),i=k(),a=r(ao),o=(0,K.useMemo)(()=>{let t=k(),n=P(t,-4),r=P(t,1);return{seriesLabel:`Part`,data:a.valuesToLazySeq().filter(t=>t.isOutlier&&t.endTime>=n&&t.endTime<r&&Wa(t)===(e===`labor`)).toRLookup(e=>e.part+`-`+e.material[0].proc.toString())}},[e,a]);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsxs)(b,{variant:`subtitle1`,children:[e===`labor`?`Load/Unload`:`Machine`,` cycles from the past 5 days statistically outside expected range`]}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},onClick:()=>Do(o,t.matsById,void 0,void 0,n.loadStationNames,n.basketName),size:`large`,children:(0,Y.jsx)(ct,{})})})]}),(0,Y.jsx)(`main`,{children:(0,Y.jsx)(rb,{points:o.data,matsById:t.matsById,current_date_zoom:{start:P(i,-4),end:P(i,1)},set_date_zoom_range:void 0,period:{type:`Last30`},showWorkorderAndInspect:!1,defaultSortDesc:!0})})]})}var ab=class e{constructor(e,t){this.day=e,this.station=t}compare(e){let t=this.day.getTime()-e.day.getTime();return t===0?this.station.localeCompare(e.station):t}hash(){return ve(this.day,this.station)}toString(){return`{day: ${this.day.toISOString()}}, station: ${this.station}}`}adjustDay(t){return new e(t(this.day),this.station)}};function ob(e,t,n){let r=Rt(e),i=Rt(t);if(r.getTime()===i.getTime())return[{day:r,value:n}];{let a=[],o=t.getTime()-e.getTime();for(let s=r;s<=i;s=P(s,1)){let r=on([s,e]),i=(Hn([P(s,1),t]).getTime()-r.getTime())/o;a.push({day:s,value:n*i})}return a}}function sb(e,t){return Ra(D.of(e),e=>e.stationLabel,e=>e.endTime).flatMap(([e,n])=>n.flatMap(e=>{let n=D.of(e).sumBy(e=>e.elapsedMinsPerMaterial*e.material.length),r=jn(e[0].endTime,-n*60),i=D.of(e).sumBy(e=>t(e));return ob(r,e[0].endTime,i)}).map(t=>({...t,statNameAndNum:e}))).buildHashMap(e=>new ab(e.day,e.statNameAndNum),(e,t)=>t.value+(e??0))}function cb(e){return sb(e,e=>e.activeMinutes)}function lb(e){return sb(e,e=>e.elapsedMinsPerMaterial*e.material.length)}function ub(e){let t=[];for(let n of e)if(t.length===0)t.push(n);else{let e=t[t.length-1];n.start<=e.end?t[t.length-1]={start:e.start,end:on([e.end,n.end])}:t.push(n)}return t}function db(e){return D.of(e).filter(e=>e.plannedDown).toLookupOrderedMap(e=>e.stationLabel,e=>e.start).toAscLazySeq().flatMap(([e,t])=>ub(t.valuesToAscLazySeq()).flatMap(t=>ob(t.start,t.end,Xn(t.end,t.start)).map(t=>({...t,station:e})))).toHashMap(e=>[new ab(e.day,e.station),e.value],(e,t)=>e+t)}function fb(e){let t=D.of(e).filter(e=>e.plannedDown).toLookupOrderedMap(e=>e.stationLabel,e=>e.start).mapValues(e=>ub(e.valuesToAscLazySeq()));return D.of(e).filter(e=>!e.plannedDown).toLookupOrderedMap(e=>e.stationLabel,e=>e.start).toAscLazySeq().flatMap(([e,n])=>{let r=ub(n.valuesToAscLazySeq()),i=t.get(e)??[];for(let e=0,t=0;t<r.length;)if(e<i.length&&i[e].end<=r[t].start)e++;else if(e<i.length&&i[e].start<r[t].end){let n=r[t].start,a=r[t].end,o=i[e].start,s=i[e].end;o<=n&&s>=a?r.splice(t,1):o<=n?(r[t]={start:s,end:a},e+=1):s>=a?(r[t]={start:n,end:o},t+=1):(r[t]={start:n,end:o},r.splice(t+1,0,{start:s,end:a}),e++,t++)}else t++;return r.flatMap(t=>ob(t.start,t.end,Xn(t.end,t.start)).map(t=>({...t,station:e})))}).toHashMap(e=>[new ab(e.day,e.station),e.value],(e,t)=>e+t)}function pb(e,t,n,r,i){let a=cb(D.of(r).filter(r=>n===`labor`===Wa(r)&&r.endTime>=e&&r.endTime<=t)),o=D.of(i).filter(r=>n===`labor`===r.station.startsWith(`L/U`)&&r.end>=e&&r.start<=t),s=db(o),c=fb(o),l=[],u=a.keysToLazySeq().concat(c.keysToLazySeq()).map(e=>e.station).distinct().toSortedArray(e=>e);for(let n of u){let r=[];for(let i=e;i<t;i=P(i,1)){let e=new ab(i,n),t=a.get(e),o=c.get(e),l=s.get(e)??0;r.push({x:i.toLocaleDateString(),y:(t??0)/60,plannedHours:(o??0)/60,actualOee:l<1440?(t??0)/(1440-l):0,plannedOee:l<1440?(o??0)/(1440-l):0,station:n,day:i})}l.push({station:n,points:r})}return l}var mb=class{constructor(e,t){this.x=e,this.y=t}compare(e){let t=this.x-e.x;return t===0?this.y.localeCompare(e.y):t}hash(){return ve(this.x,this.y)}toString(){return`{x: ${new Date(this.x).toISOString()}, y: ${this.y}}`}};function hb(e,t){let n=D.of(t).toHashMap(e=>[new mb(e.x.getTime(),e.y),e],(e,t)=>t),r=D.of(t).map(e=>e.x.getTime()).distinct().toSortedArray(e=>e),i=D.of(t).map(e=>e.y).distinct().toSortedArray(e=>e),a=`<table>
|
|
61
|
+
<thead><tr><th>`+e+`</th>`;for(let e of r)a+=`<th>`+new Date(e).toDateString()+`</th>`;a+=`</tr></thead>
|
|
62
|
+
<tbody>
|
|
63
|
+
`;for(let e of i){a+=`<tr><th>`+e+`</th>`;for(let t of r){let r=n.get(new mb(t,e));a+=r===void 0?`<td></td>`:`<td>`+r.label+`</td>`}a+=`</tr>
|
|
64
|
+
`}return a+=`</tbody>
|
|
65
|
+
</table>`,a}function gb(e,t){Je(hb(e,t))}function _b(e){let t=`<table>
|
|
66
|
+
<thead><tr>`;t+=`<th>Day</th><th>Station</th><th>Actual Hours</th><th>Planned Hours</th>`,t+=`</tr></thead>
|
|
67
|
+
<tbody>
|
|
68
|
+
`;for(let n of e)for(let e of n.points)t+=`<tr>`,t+=`<td>`+e.day.toLocaleDateString()+`</td>`,t+=`<td>`+e.station+`</td>`,t+=`<td>`+e.y.toFixed(1)+`</td>`,t+=`<td>`+e.plannedHours.toFixed(1)+`</td>`,t+=`</tr>
|
|
69
|
+
`;return t+=`</tbody>
|
|
70
|
+
</table>`,t}function vb(e){Je(_b(e))}var yb=[[`4477aa`],[`4477aa`,`cc6677`],[`4477aa`,`ddcc77`,`cc6677`],[`4477aa`,`117733`,`ddcc77`,`cc6677`],[`332288`,`88ccee`,`117733`,`ddcc77`,`cc6677`],[`332288`,`88ccee`,`117733`,`ddcc77`,`cc6677`,`aa4499`],[`332288`,`88ccee`,`44aa99`,`117733`,`ddcc77`,`cc6677`,`aa4499`],[`332288`,`88ccee`,`44aa99`,`117733`,`999933`,`ddcc77`,`cc6677`,`aa4499`],[`332288`,`88ccee`,`44aa99`,`117733`,`999933`,`ddcc77`,`cc6677`,`882255`,`aa4499`],[`332288`,`88ccee`,`44aa99`,`117733`,`999933`,`ddcc77`,`661100`,`cc6677`,`882255`,`aa4499`],[`332288`,`6699cc`,`88ccee`,`44aa99`,`117733`,`999933`,`ddcc77`,`661100`,`cc6677`,`882255`,`aa4499`],[`332288`,`6699cc`,`88ccee`,`44aa99`,`117733`,`999933`,`ddcc77`,`661100`,`cc6677`,`aa4466`,`882255`,`aa4499`]],bb=`ff0029.377eb8.66a61e.984ea3.00d2d5.ff7f00.af8d00.7f80cd.b3e900.c42e60.a65628.f781bf.8dd3c7.bebada.fb8072.80b1d3.fdb462.fccde5.bc80bd.ffed6f.c4eaff.cf8c00.1b9e77.d95f02.e7298a.e6ab02.a6761d.0097ff.00d067.000000.252525.525252.737373.969696.bdbdbd.f43600.4ba93b.5779bb.927acc.97ee3f.bf3947.9f5b00.f48758.8caed6.f2b94f.eff26e.e43872.d9b100.9d7a00.698cff.d9d9d9.00d27e.d06800.009f82.c49200.cbe8ff.fecddf.c27eb6.8cd2ce.c4b8d9.f883b0.a49100.f48800.27d0df.a04a9b`.split(`.`);function xb(e,t){return t<=yb.length?`#`+yb[t-1][e]:`#`+bb[e%bb.length]}var Sb=xb(0,2),Cb=xb(1,2),wb=50,Tb=30,Eb=10,Db=10;function Ob({width:e,height:t,points:n,setTooltip:r}){let i=t-Eb-Tb,a=(0,K.useMemo)(()=>ie().domain([0,24]).range([i,0]),[i]),o=(0,K.useMemo)(()=>Ve().domain(D.of(n).map(e=>e.x).distinct()).range([0,e-wb-Db]).padding(.1),[n,e]),s=(0,K.useMemo)(()=>Ve().domain([`Actual`,`Planned`]).range([0,o.bandwidth()]).padding(.05),[o]);return(0,Y.jsx)(`svg`,{width:e,height:t,children:(0,Y.jsxs)(`g`,{transform:`translate(${wb},${Eb})`,children:[(0,Y.jsx)(is,{scale:o,top:i}),(0,Y.jsx)(as,{scale:a,left:0,label:`Hours`}),(0,Y.jsx)($o,{scale:a,width:e-wb-Db}),n.map((e,t)=>(0,Y.jsxs)(`g`,{transform:`translate(${o(e.x)},0)`,children:[(0,Y.jsx)(`rect`,{x:s(`Actual`),y:a(e.y),width:s.bandwidth(),height:i-a(e.y),fill:Sb,onMouseEnter:t=>{let n=Ho(t);r({left:n?.x??0,top:n?.y??0,datum:e})},onMouseLeave:()=>r(null)}),(0,Y.jsx)(`rect`,{x:s(`Planned`),y:a(e.plannedHours),width:s.bandwidth(),height:i-a(e.plannedHours),fill:Cb,onMouseEnter:t=>{let n=Ho(t);r({left:n?.x??0,top:n?.y??0,datum:e})},onMouseLeave:()=>r(null)})]},t))]})})}function kb({station:e}){return(0,Y.jsxs)(`div`,{style:{marginTop:`1em`,display:`flex`,flexWrap:`wrap`,justifyContent:`space-evenly`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(`div`,{style:{width:`14px`,height:`14px`,backgroundColor:Sb}}),(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`},children:[e,` Actual`]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(`div`,{style:{width:`14px`,height:`14px`,backgroundColor:Cb}}),(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`},children:[e,` Planned`]})]})]})}function Ab({tooltip:e}){return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{children:e.datum.x}),(0,Y.jsxs)(`div`,{children:[`Actual Hours: `,e.datum.y?.toFixed(1)]}),(0,Y.jsxs)(`div`,{children:[`Planned Hours: `,e.datum?.plannedHours?.toFixed(1)]})]})}function jb({series:e}){let t=(0,K.useMemo)(()=>F(null),[]),n=j(t);return(0,Y.jsxs)(kt,{size:{xs:12,md:6},onMouseLeave:()=>n(null),children:[(0,Y.jsx)(qo,{sx:{height:`calc(100vh / 2 - 200px)`},chart:({width:t,height:r})=>(0,Y.jsx)(Ob,{width:t,height:r,points:e.points,setTooltip:n}),tooltipAtom:t,TooltipContent:Ab}),(0,Y.jsx)(kb,{station:e.station})]})}function Mb({points:e}){return(0,Y.jsx)(kt,{container:!0,children:e.map((e,t)=>(0,Y.jsx)(jb,{series:e},t))})}var Nb=[{id:0,numeric:!1,label:`Date`,getDisplay:e=>e.x,getForSort:e=>e.day.getTime()},{id:1,numeric:!1,label:`Station`,getDisplay:e=>e.station},{id:2,numeric:!0,label:`Actual Hours`,getDisplay:e=>e.y.toFixed(1),getForSort:e=>e.y},{id:3,numeric:!0,label:`Actual OEE`,getDisplay:e=>(e.actualOee*100).toFixed(0)+`%`,getForSort:e=>e.actualOee},{id:4,numeric:!0,label:`Planned Hours`,getDisplay:e=>e.plannedHours.toFixed(1),getForSort:e=>e.plannedHours},{id:5,numeric:!0,label:`Planned OEE`,getDisplay:e=>(e.plannedOee*100).toFixed(0)+`%`,getForSort:e=>e.plannedOee}];function Pb(e,t){return D.of(e).flatMap(e=>e.points).toSortedArray(t)}var Fb=(0,K.memo)(function({points:e}){let t=zh(0,Nb);return(0,Y.jsxs)(he,{children:[(0,Y.jsx)(Ah,{columns:Nb,sort:t,showDetailsCol:!1}),(0,Y.jsx)(Ih,{columns:Nb,pageData:Pb(e,t.sortOn)})]})}),Ib=F(!0),Lb=F(!0);function Rb({ty:e}){Q(e===`labor`?`L/U OEE`:`Machine OEE`);let[t,n]=A(e===`labor`?Ib:Lb),i=P(k(),-6),a=P(k(),1),o=r(ao),s=r(Fo),c=(0,K.useMemo)(()=>pb(i,a,e,o.valuesToLazySeq(),s),[i,a,e,o,s]);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsxs)(b,{variant:`subtitle1`,children:[e===`labor`?`Load/Unload`:`Machine`,` OEE: comparing flexplan hours between actual and simulated production`]}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,value:t?`chart`:`table`,onChange:e=>n(e.target.value===`chart`),children:[(0,Y.jsx)(L,{value:`chart`,children:`Chart`},`chart`),(0,Y.jsx)(L,{value:`table`,children:`Table`},`table`)]})}),(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},onClick:()=>vb(c),size:`large`,children:(0,Y.jsx)(ct,{})})})]}),(0,Y.jsx)(`main`,{children:t?(0,Y.jsx)(Mb,{points:c}):(0,Y.jsx)(Fb,{points:c})})]})}function zb({points:e,stats:t,partCntPerPoint:n}){return{series:(0,K.useMemo)(()=>D.of(e).toSortedArray(([e])=>e).map(([t,n],r)=>({name:t,color:xb(r,e.size),points:n??[]})),[e]),median:(0,K.useMemo)(()=>t?{low:(n??1)*(t.medianMinutesForSingleMat-t.MAD_belowMinutes),high:(n??1)*(t.medianMinutesForSingleMat+t.MAD_aboveMinutes)}:null,[t,n])}}var Bb=50,Vb=30,Hb=10,Ub=2;function Wb({points:e,yZoom:t,default_date_range:n,current_date_zoom:r,containerWidth:i,containerHeight:a}){let o=i===0?400:i,s=a===0?400:a,c=o-Bb-Ub,l=s-Hb-Vb,u=(0,K.useMemo)(()=>r?me().domain([r.start,r.end]).range([0,c]):me().domain([n[0],n[1]]).range([0,c]),[r,n,c]),d=(0,K.useMemo)(()=>{if(e.size===0)return 60;let t=D.of(e).flatMap(([,e])=>e.map(e=>e.y)).maxBy(e=>e)??1;return Math.ceil(t/5)*5},[e]);return{height:s,width:o,xScale:u,yScale:(0,K.useMemo)(()=>t?ie().domain([t.y_low,t.y_high]).range([l,0]):ie().domain([0,d]).range([l,0]),[l,t,d])}}var Gb=(0,K.memo)(function({xScale:e,yScale:t}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(is,{scale:e,top:t.range()[0]}),(0,Y.jsx)(as,{scale:t,left:e.range()[0],label:`Minutes`}),(0,Y.jsx)(ts,{width:e.range()[1]-e.range()[0],height:t.range()[0]-t.range()[1],xScale:e,yScale:t})]})}),Kb=(0,K.memo)(function(e){let[t,n]=(0,K.useState)(),[r,i]=(0,K.useState)(),[a,o]=(0,K.useState)(!1);function s(){o(!1),n(void 0),i(void 0)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(C,{size:`small`,onClick:()=>o(!0),children:(0,Y.jsx)(Sn,{fontSize:`inherit`})}),(0,Y.jsxs)(I,{open:a,onClose:s,children:[(0,Y.jsxs)(M,{children:[(0,Y.jsx)(`div`,{style:{marginBottom:`1em`},children:(0,Y.jsx)(_,{type:`number`,label:`Y Low`,value:t===void 0?e.yZoom?.y_low??``:isNaN(t)?``:t,onChange:e=>n(parseFloat(e.target.value)),onBlur:()=>{t&&e.setZoom(e=>e?{...e,y_low:t}:{y_low:t,y_high:60})}})}),(0,Y.jsx)(`div`,{style:{marginBottom:`1em`},children:(0,Y.jsx)(_,{type:`number`,label:`Y High`,value:r===void 0?e.yZoom?.y_high??``:isNaN(r)?``:r,onChange:e=>i(parseFloat(e.target.value)),onBlur:()=>{r&&e.setZoom(e=>e?{...e,y_high:r}:{y_low:0,y_high:r})}})})]}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{onClick:s,children:`Close`})})]})]})}),qb=(0,K.memo)(function({median:e,plannedMinutes:t,xScale:n,yScale:r}){let i=Dt({to:{x:n.range()[0],y:e?r(e.high):r.range()[0],width:n.range()[1]-n.range()[0],height:e?r(e.low)-r(e.high):0},from:{x:n.range()[0],y:r.range()[0],width:n.range()[1]-n.range()[0],height:0}}),a=Dt({to:{y:t?r(t):r.range()[0]},from:{y:r.range()[0]}});return(0,Y.jsxs)(`g`,{children:[e?(0,Y.jsx)(nn.rect,{x:i.x,y:i.y,width:i.width,height:i.height,fill:ft[700],opacity:.2,pointerEvents:`none`}):void 0,t?(0,Y.jsx)(nn.line,{stroke:`black`,x1:n.range()[0],x2:n.range()[1],y1:a.y,y2:a.y}):void 0]})}),Jb=(0,K.memo)(function({seriesName:e,points:t,color:n,xScale:r,yScale:i,showTooltip:a}){let o=(0,K.useCallback)(n=>{let r=Ho(n);if(r===null)return;let i=n.currentTarget.dataset.idx;i!==void 0&&a({left:r.x,top:r.y,pt:t[parseInt(i)],seriesName:e})},[a,t,e]),s=On(t.length,t.map(e=>({from:{x:r(e.x),y:i.range()[0]+15},to:{x:r(e.x),y:i(e.y)}})));return(0,Y.jsx)(`g`,{children:s.map((e,t)=>(0,Y.jsx)(nn.circle,{className:`bms-cycle-chart-pt`,fill:n,r:5,cx:e.x,cy:e.y,"data-idx":t,onClick:o},t))})}),Yb=(0,K.memo)(function({series:e,xScale:t,yScale:n,showTooltip:r,disabledSeries:i}){return(0,Y.jsx)(`g`,{children:e.filter(e=>!i.has(e.name)).map(e=>(0,Y.jsx)(Jb,{points:e.points,seriesName:e.name,color:e.color,xScale:t,yScale:n,showTooltip:r},e.name))})}),Xb=(0,K.memo)(function({series:e,disabledSeries:t,adjustDisabled:n}){return(0,Y.jsx)(`div`,{style:{marginTop:`1em`,display:`flex`,flexWrap:`wrap`,justifyContent:`space-around`},children:e.map(e=>(0,Y.jsx)(y,{selected:!t.has(e.name),value:e,onChange:()=>n(t=>t.has(e.name)?t.delete(e.name):t.add(e.name)),children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(`div`,{style:{width:`14px`,height:`14px`,backgroundColor:e.color}}),(0,Y.jsx)(`div`,{style:{marginLeft:`1em`},children:e.name})]})},e.name))})}),Zb=_r(`g`,{shouldForwardProp:e=>e.toString()[0]!==`$`})(({$noPtrEvents:e})=>e?{"& .bms-cycle-chart-pt":{pointerevents:`none`}}:void 0),Qb=(0,K.memo)(function({setYZoom:e,setXZoom:t,setTooltip:n,xScale:r,yScale:i,highlightStart:a,setHighlightStart:o}){let[s,c]=(0,K.useState)(null),l=(0,K.useCallback)(e=>{let t=Ho(e);t!==null&&(c(null),o({x:t.x-Bb,y:t.y-Hb,nowMS:Date.now()}),n(null))},[o,n]),u=(0,K.useCallback)(e=>{let t=Ho(e);t!==null&&c({x:t.x-Bb,y:t.y-Hb})},[c]),d=(0,K.useCallback)(n=>{if(a!==null){if(Date.now()-a.nowMS>500){let o=Ho(n);if(o!==null){let n=r.invert(a.x),s=r.invert(o.x-Bb),c=i.invert(a.y),l=i.invert(o.y-Hb);e(c<l?{y_low:c,y_high:l}:{y_low:l,y_high:c}),t?.({zoom:n.getTime()<s.getTime()?{start:n,end:s}:{start:s,end:n}})}}o(null),c(null)}},[a,o,c,t,e,r,i]);return(0,Y.jsxs)(`g`,{children:[(0,Y.jsx)(`rect`,{x:0,y:0,width:r.range()[1],height:i.range()[0],fill:`transparent`,onPointerDown:l,onPointerMove:a===null?void 0:u,onPointerUp:a===null?void 0:d}),a!==null&&s!==null?(0,Y.jsx)(`rect`,{x:Math.min(a.x,s.x),y:Math.min(a.y,s.y),width:Math.abs(a.x-s.x),height:Math.abs(a.y-s.y),color:`red`,pointerEvents:`none`,opacity:.3}):void 0]})}),$b=(0,K.memo)(function({set_date_zoom_range:e,current_date_zoom:t,yZoom:n,setYZoom:r,median:i}){return(0,Y.jsxs)(`div`,{children:[e&&(t||n)?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{size:`small`,onClick:()=>{e?.({zoom:void 0}),r(null)},children:`Reset Zoom`}),(0,Y.jsx)(Kb,{yZoom:n,setZoom:r})]}):void 0,e&&!t&&!n?(0,Y.jsxs)(`span`,{style:{color:`#6b6b76`},children:[`Zoom via mouse drag`,i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{children:` or `}),(0,Y.jsx)(z,{size:`small`,onClick:()=>{let e=i.high,t=i.low,n=.2*(e-t);r({y_low:t-n,y_high:e+n})},children:`Zoom To Inliers`})]}):void 0,(0,Y.jsx)(Kb,{yZoom:n,setZoom:r})]}):void 0]})}),ex=(0,K.memo)(function({tooltip:e,extraTooltip:t,seriesLabel:n}){return e===null?null:(0,Y.jsxs)(E,{direction:`column`,spacing:.6,children:[(0,Y.jsxs)(`div`,{children:[`Time:`,` `,e.pt.x.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`})]}),(0,Y.jsxs)(`div`,{children:[n,`: `,e.seriesName]}),(0,Y.jsxs)(`div`,{children:[`Cycle Time: `,e.pt.y.toFixed(1),` minutes`]}),t?t(e.pt).map((e,t)=>(0,Y.jsxs)(`div`,{children:[e.title,`:`,` `,e.link?(0,Y.jsx)(`a`,{style:{color:`white`,pointerEvents:`auto`,cursor:`pointer`,borderBottom:`1px solid`},onClick:e.link,children:e.value}):(0,Y.jsx)(`span`,{children:`e.value`})]},t)):void 0]})});function tx(e){let{width:t,height:n,xScale:r,yScale:i}=Wb({points:e.points,yZoom:e.yZoom,setYZoom:e.setYZoom,default_date_range:e.default_date_range,current_date_zoom:e.current_date_zoom,set_date_zoom_range:e.set_date_zoom_range,containerWidth:e.containerWidth,containerHeight:e.containerHeight});return(0,Y.jsx)(`svg`,{width:t,height:n,children:(0,Y.jsxs)(`g`,{transform:`translate(${Bb}, ${Hb})`,children:[(0,Y.jsx)(Gb,{xScale:r,yScale:i}),(0,Y.jsx)(qb,{median:e.median,plannedMinutes:e.plannedTimeMinutes,xScale:r,yScale:i}),(0,Y.jsx)(Qb,{setYZoom:e.setYZoom,setXZoom:e.set_date_zoom_range,xScale:r,setTooltip:e.showTooltip,yScale:i,highlightStart:e.highlightStart,setHighlightStart:e.setHighlightStart}),(0,Y.jsx)(Zb,{$noPtrEvents:e.highlightStart!==null,children:(0,Y.jsx)(Yb,{series:e.series,disabledSeries:e.disabledSeries,xScale:r,yScale:i,showTooltip:e.showTooltip})})]})})}var nx=(0,K.memo)(function(e){let t=(0,K.useMemo)(()=>F(null),[]),n=j(t),[r,i]=(0,K.useState)(Fn.empty()),[a,o]=(0,K.useState)(null),{series:s,median:c}=zb({points:e.points,stats:e.stats,partCntPerPoint:e.partCntPerPoint}),l=(0,K.useCallback)(()=>{n(null),o(null)},[n,o]);return(0,Y.jsxs)(`div`,{onPointerLeave:l,children:[(0,Y.jsx)(qo,{sx:{height:{xs:`calc(100vh - 320px)`,md:`calc(100vh - 280px)`,xl:`calc(100vh - 220px)`}},tooltipAtom:t,TooltipContent:({tooltip:t})=>(0,Y.jsx)(ex,{tooltip:t,seriesLabel:e.series_label,extraTooltip:e.extra_tooltip}),chart:({width:t,height:i})=>(0,Y.jsx)(tx,{...e,containerHeight:i,containerWidth:t,series:s,median:c,yZoom:e.yZoom,setYZoom:e.setYZoom,highlightStart:a,setHighlightStart:o,showTooltip:n,disabledSeries:r})}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`},children:[(0,Y.jsx)(`div`,{style:{color:`#6b6b76`},children:`Click on a point for details`}),(0,Y.jsx)(`div`,{style:{flexGrow:1}}),(0,Y.jsx)($b,{set_date_zoom_range:e.set_date_zoom_range,current_date_zoom:e.current_date_zoom,yZoom:e.yZoom,setYZoom:e.setYZoom,median:c})]}),(0,Y.jsx)(Xb,{series:s,disabledSeries:r,adjustDisabled:i})]})});function rx(e){return`operations`in e&&(e.operations===void 0||Array.isArray(e.operations))}var ix=F(!0),ax=F(!0),ox=F(void 0),sx=F(void 0),cx=F(void 0),lx=F(`Any`),ux=F(void 0),dx=F(void 0),fx=F({}),px=F({}),mx=F(null),hx=F(null);function gx({ty:e}){Q(e===`labor`?`L/U Cycles`:`Machine Cycles`);let t=j(X),n=(0,K.useCallback)(function(e){if(!rx(e))return[];let n=[];if(e.operations)for(let r of e.operations)n.push({title:(r.mat.serial?r.mat.serial:`Material`)+` `+r.operation,value:`Open Card`,link:()=>t({type:`LogMat`,logMat:r.mat})});else if(`material`in e&&Array.isArray(e.material))for(let r of e.material)n.push({title:r.serial?r.serial:`Material`,value:`Open Card`,link:()=>t({type:`LogMat`,logMat:r})});return n},[t]),[i,a]=A(e===`labor`?ix:ax),[o,s]=A(e===`labor`?fx:px),[c,l]=A(e===`labor`?ox:sx),[u,d]=A(cx),[f,p]=A(lx),[m,h]=A(e===`labor`?ux:dx),[g,ee]=A(e===`labor`?mx:hx),_=r(G),te=eo(_.basketName),ne=r(oo),v=go(f,e!==`labor`||ne),y=r(ja),re=[P(k(),-4),P(k(),1)],ie=r(ao),ae=r(Bl),x=(0,K.useMemo)(()=>{let t=k();return u?xo(ie.valuesToLazySeq(),{zoom:{start:P(t,-4),end:P(t,1)},partAndProc:c,pallet:m,operation:u,carrierKind:v}):e===`labor`&&i?So(ie.valuesToLazySeq(),{zoom:{start:P(t,-4),end:P(t,1)},partAndProc:c,pallet:m,carrierKind:v}):xo(ie.valuesToLazySeq(),{zoom:{start:P(t,-4),end:P(t,1)},partAndProc:c,pallet:m,station:e===`labor`?yo:vo,carrierKind:v})},[ie,e,c,m,u,i,v]),oe=c?u??(x.allMachineOperations.length===1?x.allMachineOperations[0]:void 0):void 0,se=(0,K.useMemo)(()=>{if(oe&&e===`machine`)return Co(x,!1)},[x,e,oe]);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsxs)(b,{variant:`subtitle1`,children:[`Recent `,e===`labor`?`Load/Unload Occupancy`:`Machine Cycles`]}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{name:`Station-Cycles-chart-or-table-select`,autoWidth:!0,value:i?`graph`:`table`,onChange:e=>a(e.target.value===`graph`),children:[(0,Y.jsx)(L,{value:`graph`,children:`Graph`},`graph`),(0,Y.jsx)(L,{value:`table`,children:`Table`},`table`)]})}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:c?x.allPartAndProcNames.findIndex(e=>c.part===e.part&&c.proc===e.proc):-1,style:{marginLeft:`1em`},onChange:e=>{l(e.target.value===-1?void 0:x.allPartAndProcNames[e.target.value]),d(void 0)},children:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsx)(`em`,{children:`Any Part`})},0),x.allPartAndProcNames.map((e,t)=>(0,Y.jsx)(L,{value:t,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.part,size:20}),(0,Y.jsxs)(`span`,{style:{marginRight:`1em`},children:[e.part,`-`,e.proc]})]})},t))]})}),e===`machine`?(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsx)(O,{name:`Station-Cycles-cycle-chart-station-select`,autoWidth:!0,displayEmpty:!0,value:oe?x.allMachineOperations.findIndex(e=>oe.compare(e)===0):-1,style:{marginLeft:`1em`},onChange:e=>d(x.allMachineOperations[e.target.value]),children:[...x.allMachineOperations.length===1?[]:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsx)(`em`,{children:`Any Operation`})},-1)],...x.allMachineOperations.map((e,t)=>(0,Y.jsxs)(L,{value:t,children:[e.statGroup,` `,e.operation]},t))]})}):void 0,e===`labor`&&ne?(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:v,style:{marginLeft:`1em`},onChange:e=>{let t=e.target.value;p(t),t===`Basket`&&h(void 0)},children:[(0,Y.jsx)(L,{value:`Any`,children:(0,Y.jsx)(`em`,{children:`Any Carrier`})}),(0,Y.jsx)(L,{value:`Pallet`,children:`Pallet`}),(0,Y.jsx)(L,{value:`Basket`,children:te})]})}):void 0,e!==`labor`||v!==`Basket`?(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{name:`Station-Cycles-cycle-chart-station-pallet`,autoWidth:!0,displayEmpty:!0,value:m||``,style:{marginLeft:`1em`},onChange:e=>h(e.target.value===``?void 0:e.target.value),children:[(0,Y.jsx)(L,{value:``,children:(0,Y.jsx)(`em`,{children:`Any Pallet`})},0),x.allPalletNames.map(e=>(0,Y.jsx)(L,{value:e,children:(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,Y.jsx)(`span`,{style:{marginRight:`1em`},children:e})})},e))]})}):void 0,(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:()=>Do(x,ae.matsById,void 0,e===`labor`,_.loadStationNames,te),style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,children:(0,Y.jsx)(ct,{})})})]}),(0,Y.jsx)(`main`,{children:i?(0,Y.jsx)(nx,{points:x.data,series_label:x.seriesLabel,default_date_range:re,extra_tooltip:n,current_date_zoom:o.zoom,set_date_zoom_range:s,yZoom:g,setYZoom:ee,stats:oe&&e===`machine`?y.get(oe):void 0,partCntPerPoint:oe?D.of(x.data).head()?.[1]?.[0]?.material?.length:void 0,plannedTimeMinutes:se}):(0,Y.jsx)(rb,{points:x.data,matsById:ae.matsById,period:{type:`Last30`},current_date_zoom:void 0,set_date_zoom_range:void 0,showWorkorderAndInspect:!0,hideMedian:e===`labor`})})]})}var _x=D.ofRange(0,12,1).map(e=>new Date(2019,e,1)).chunk(3).toRArray(),vx=(0,K.memo)(function(e){let[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)(void 0);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(an,{type:`text`,value:(r||e.curMonth).toLocaleDateString(void 0,{month:`long`,year:`numeric`}),readOnly:!0,endAdornment:(0,Y.jsx)(Vn,{position:`end`,children:(0,Y.jsx)(C,{"aria-label":`Open month select`,"data-testid":`open-month-select`,onClick:()=>{i(We(e.curMonth)),n(!0)},size:`large`,children:(0,Y.jsx)(Yt,{})})})}),(0,Y.jsx)(I,{open:t,onClose:()=>{n(!1),i(void 0)},children:(0,Y.jsxs)(M,{children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(C,{"data-testid":`select-month-dialog-previous-year`,onClick:()=>i(At(r||e.curMonth,-1)),size:`large`,children:(0,Y.jsx)(vr,{})}),(0,Y.jsx)(`div`,{style:{flexGrow:1},children:(0,Y.jsx)(b,{variant:`h5`,align:`center`,"data-testid":`select-month-dialog-current-year`,children:(r||e.curMonth).toLocaleDateString(void 0,{year:`numeric`})})}),(0,Y.jsx)(C,{onClick:()=>i(At(r||e.curMonth,1)),size:`large`,children:(0,Y.jsx)(Ze,{})})]}),(0,Y.jsx)(`div`,{"data-testid":`select-month-dialog-choose-month`,children:_x.map((t,a)=>(0,Y.jsx)(`div`,{style:a>0?{marginTop:`1.2em`}:void 0,children:t.map((t,a)=>(0,Y.jsx)(z,{color:`primary`,style:a>0?{marginLeft:`1.2em`}:void 0,onClick:()=>{e.onSelectMonth(new Date((r||e.curMonth).getFullYear(),t.getMonth(),1)),i(void 0),n(!1)},children:t.toLocaleDateString(void 0,{month:`short`})},a))},a))})]})})]})}),yx=(0,K.memo)(function(){let e=r(od),[t,n]=A(ad),i=md(),a=pd();return(0,Y.jsxs)(E,{component:`nav`,direction:`row`,spacing:3,sx:{paddingLeft:`24px`,paddingRight:`24px`,alignItems:`center`},children:[(0,Y.jsx)(An,{control:(0,Y.jsx)(Ce,{checked:e.type===`Last30`,color:`secondary`,onChange:(e,t)=>t?a():null}),label:`Last 30 days`}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(An,{control:(0,Y.jsx)(Ce,{checked:e.type===`SpecificMonth`,color:`secondary`,onChange:(e,r)=>r?n(t):null}),label:`Select Month`}),(0,Y.jsx)(vx,{curMonth:t,onSelectMonth:t=>{e.type===`SpecificMonth`?n(t):i(t)}})]})]})});function bx(e){switch(e.type){case`Queue`:return e.queue;case`Rotary`:return`Rotary `+e.machineGroup+` #`+e.machineNum.toString();case`StockerWaitForMC`:return`Stocker[Waiting For Machining]`;case`StockerWaitForUnload`:return`Stocker[Waiting For Unload]`}}function xx(e,t,n){let r=Math.max(t.x.getTime()-e,n.endTime.getTime()-n.elapsedSeconds*1e3),i=Math.min(t.x.getTime()+e,n.endTime.getTime());t.y+=(i-r)/(2*e)*n.numMaterial}function Sx(e,t,n,r){let i=new Date(e.getTime()+n),a=new Date(t.getTime()-n),o=(a.getTime()-i.getTime())/149,s=[];for(let e=0;e<149;e++)s.push({x:new Date(i.getTime()+e*o),y:0});s.push({x:a,y:0});for(let e of r){let t=Math.max(0,Math.ceil((e.endTime.getTime()-e.elapsedSeconds*1e3-n-i.getTime())/o)),r=Math.min(149,Math.floor((e.endTime.getTime()+n-i.getTime())/o));for(let i=t;i<=r;i++)xx(n,s[i],e)}return s}function Cx(e,t,n,r,i){let a=n*60*60*1e3;return D.of(i).filter(e=>e.buffer.type!==`Queue`||!r.has(e.buffer.queue)).groupBy(e=>bx(e.buffer)).map(([n,r])=>({label:n,points:Sx(e,t,a,r)})).toSortedArray(e=>e.label)}var wx=(0,K.memo)(function({series:e,xScale:t,yScale:n,color:r}){let i=Rn().curve(Cn).x(e=>t(e.x)).y(e=>n(e.y))(e.points)??``,a=(0,K.useRef)(i),o=(0,K.useCallback)(ge(e=>{a.current=e},50),[]),s=Kn(a.current,i);o(i);let{t:c}=Dt({from:{t:0},to:{t:1},reset:!0,delay:0});return(0,Y.jsx)(nn.path,{d:c.to(s),stroke:r,strokeWidth:2,strokeLinecap:`round`,fill:`transparent`})}),Tx=60,Ex=50,Dx=20,Ox=20;function kx({width:e,height:t,series:n,disabled:r}){let[i]=(0,K.useState)(()=>new Date),[a,o]=(0,K.useMemo)(()=>{let e=null,t=null;for(let r of n)for(let n of r.points)(e===null||n.x<e)&&(e=n.x),(t===null||n.x>t)&&(t=n.x);return[e??i,t??i]},[n,i]),s=(0,K.useMemo)(()=>me().range([0,e-Tx-Ox]).domain([a,o]),[e,a,o]),c=t-Ex-Dx,l=(0,K.useMemo)(()=>ie().domain([0,D.of(n).flatMap(e=>e.points).map(e=>e.y).maxBy(e=>e)??1]).range([c,0]),[n,c]);return(0,Y.jsx)(`svg`,{width:e,height:t,children:(0,Y.jsxs)(`g`,{transform:`translate(${Tx},${Dx})`,children:[(0,Y.jsx)(is,{scale:s,top:c}),(0,Y.jsx)(as,{scale:l,left:0,label:`Buffer Size`}),(0,Y.jsx)(ts,{xScale:s,yScale:l,width:e-Tx-Ox,height:c}),n.map((e,t)=>r.has(e.label)?void 0:(0,Y.jsx)(wx,{series:e,xScale:s,yScale:l,color:xb(t,n.length)},e.label))]})})}var Ax=(0,K.memo)(function(e){let t=r(od),n=t.type===`Last30`?[P(k(),-29),P(k(),1)]:[t.month,Vt(t.month,1)],i=r(t.type===`Last30`?Sl:wl),a=r(qc),[o,s]=(0,K.useState)(Fn.empty()),c=n[0],l=n[1],u=(0,K.useMemo)(()=>Cx(c,l,e.movingAverageDistanceInHours,a,i.valuesToLazySeq()),[c,l,i,e.movingAverageDistanceInHours,a]),{width:d,height:f,ref:p}=Ee({refreshMode:`debounce`,refreshRate:100});return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(B,{ref:p,sx:{height:{xs:`calc(100vh - 350px)`,md:`calc(100vh - 285px)`,xl:`calc(100vh - 220px)`},overflow:`hidden`},children:d&&f&&d>0&&f>0&&(0,Y.jsx)(kx,{width:d,height:f,series:u,disabled:o})}),(0,Y.jsx)(`div`,{style:{marginTop:`1em`,display:`flex`,flexWrap:`wrap`,justifyContent:`space-around`},children:u.map((e,t)=>(0,Y.jsx)(y,{selected:!o.has(e.label),value:e.label,onChange:()=>s(t=>t.has(e.label)?t.delete(e.label):t.add(e.label)),children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(`div`,{style:{width:`14px`,height:`14px`,backgroundColor:xb(t,u.length)}}),(0,Y.jsx)(`div`,{style:{marginLeft:`1em`},children:e.label})]})},e.label))})]})}),jx=ot;function Mx(){Q(`Buffer Occupancy`);let[e,t]=(0,K.useState)(12);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsx)(b,{variant:`subtitle1`,children:`Average material occupancy of rotary tables and stocker positions over time`}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(`span`,{style:{fontSize:`small`,marginRight:`1em`},children:`Moving Average Window: `}),(0,Y.jsx)(jx,{style:{width:`10em`},min:1,max:36,steps:.2,valueLabelDisplay:`off`,value:e,onChange:(e,n)=>t(n)})]}),(0,Y.jsx)(`main`,{children:(0,Y.jsx)(Ax,{movingAverageDistanceInHours:e})})]})}function Nx(e,t){return e.some(e=>e===t)}var Px=20,Fx=10,Ix=2,Lx=`#E8F5E9`,Rx=`#1B5E20`;function zx({yType:e,dateRange:t,containerWidth:n,points:r}){let i=n==null||n===0?400:n,a=(0,K.useMemo)(()=>D.of(r).map(e=>e.y).distinct().map(Wo).maxBy(e=>e??0)??20,[r])+5,o=i-a-Ix,s=t[0],c=t[1],l=(0,K.useMemo)(()=>{let e=[];if(c<s)e.push(s);else{let t=s;for(;t<c;)e.push(t),t=P(t,1)}return Ve().domain(e).range([0,o]).align(0).padding(.05)},[s,c,o]),{yScale:u,height:d,colorScale:f}=(0,K.useMemo)(()=>{let t=new Set;for(let e of r)t.add(e.y);let n=60*t.size,i=n+Fx+Px,a=Ve().domain(D.of(t).toSortedArray(e=>e)).range([0,n]).align(0).padding(.05),o;if(e===`Station`)o=ie().domain([0,1]).range([Lx,Rx]);else{let e=D.of(r).maxBy(e=>e.color)?.color??1;o=ie().domain([0,e]).range([Lx,Rx])}return{yScale:a,height:i,colorScale:o}},[r,e]);return{height:d,width:i,xScale:l,yScale:u,colorScale:f,marginLeft:a}}var Bx=(0,K.memo)(function({xScale:e,yScale:t}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(is,{scale:e,top:t.range()[1],tickFormat:e=>e.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}),(0,Y.jsx)(as,{scale:t,left:e.range()[0]})]})}),Vx=(0,K.memo)(function({points:e,xScale:t,yScale:n,colorScale:r,setTooltip:i}){let a=(0,K.useRef)(null),o=(0,K.useCallback)(t=>{let n=Ho(t);if(n===null)return;a.current!==null&&(clearTimeout(a.current),a.current=null);let r=t.currentTarget.dataset.idx;if(r===void 0)return;let o=e[parseInt(r)];i({left:n.x,top:n.y,data:o})},[e,i]),s=(0,K.useCallback)(()=>{a.current===null&&(a.current=window.setTimeout(()=>{a.current=null,i(null)},100))},[i]);return(0,Y.jsx)(`g`,{children:e.map((e,i)=>(0,Y.jsx)(`rect`,{"data-idx":i,x:t(e.x)??0,width:t.bandwidth(),y:n(e.y)??0,height:n.bandwidth(),rx:6,fill:r(e.color),onPointerEnter:o,onPointerLeave:s},i))})}),Hx=(0,K.memo)(function({yType:e,seriesLabel:t,tooltip:n}){return n===null?null:(0,Y.jsxs)(E,{direction:`column`,spacing:.6,children:[(0,Y.jsxs)(`div`,{children:[e,`: `,n.data.y]}),(0,Y.jsxs)(`div`,{children:[`Day: `,n.data.x.toDateString()]}),(0,Y.jsxs)(`div`,{children:[t,`: `,n.data.label]})]})});function Ux(e){let{width:t,height:n,xScale:r,yScale:i,colorScale:a,marginLeft:o}=zx({yType:e.y_title,points:e.points,dateRange:e.dateRange,containerWidth:e.parentWidth});return(0,Y.jsx)(`svg`,{width:t,height:n,children:(0,Y.jsxs)(`g`,{transform:`translate(${o}, ${Fx})`,children:[(0,Y.jsx)(Vx,{points:e.points,xScale:r,yScale:i,colorScale:a,setTooltip:e.setTooltip}),(0,Y.jsx)(Bx,{xScale:r,yScale:i,colorScale:a})]})})}function Wx(e){let t=e.setSelected;return(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsx)(b,{variant:`subtitle1`,children:e.label}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),t?(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsx)(O,{autoWidth:!0,displayEmpty:!0,value:e.cur_selected,onChange:n=>{Nx(e.options,n.target.value)&&t(n.target.value)},children:e.options.map((e,t)=>(0,Y.jsx)(L,{value:e,children:e},t))})}):void 0,(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:e.onExport,style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,children:(0,Y.jsx)(ct,{})})})]})}function Gx(e){let t=(0,K.useMemo)(()=>F(null),[]),n=j(t),r=(0,K.useCallback)(()=>{n(null)},[n]);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsx)(Wx,{label:e.label,setSelected:e.setSelected,cur_selected:e.cur_selected,onExport:e.onExport,options:e.options}),(0,Y.jsx)(`main`,{onPointerLeave:r,children:(0,Y.jsx)(qo,{sx:{width:`100%`},tooltipAtom:t,autoHeight:!0,chart:({width:t})=>(0,Y.jsx)(Ux,{points:e.points,y_title:e.y_title,dateRange:e.dateRange,parentWidth:t,setTooltip:n}),TooltipContent:({tooltip:t})=>(0,Y.jsx)(Hx,{yType:e.y_title,seriesLabel:e.label_title,tooltip:t})})})]})}var Kx=class e{constructor(e,t){this.day=e,this.part=t}compare(e){let t=this.day.getTime()-e.day.getTime();return t===0?this.part.localeCompare(e.part):t}hash(){return ve(this.day,this.part)}toString(){return`{day: ${this.day.toISOString()}}, part: ${this.part}}`}adjustDay(t){return new e(t(this.day),this.part)}},qx=class{constructor(e,t){this.matId=e,this.proc=t}compare(e){let t=this.matId-e.matId;return t===0?this.proc-e.proc:t}hash(){return ve(this.matId,this.proc)}toString(){return this.matId.toString()+`-`+this.proc.toString()}};function Jx(e,t,n,r){let i=D.of(e).filter(e=>e.endTime>=n&&e.endTime<=r&&Ga(e)&&e.activeMinutes>0&&e.material.length>0).flatMap(e=>e.material.map(t=>({matId:t.id,proc:t.proc,active:e.activeMinutes/e.material.length}))).toHashMap(e=>[new qx(e.matId,e.proc),e.active],(e,t)=>e+t);return D.of(t).flatMap(([e,t])=>D.ofObject(t.unloaded_processes??{}).filter(([,e])=>e>=n&&e<=r).map(([n,r])=>({day:Rt(r),part:t.partName+`-`+n,value:{count:1,activeMachineMins:i.get(new qx(e,parseInt(n)))??0}}))).toHashMap(e=>[new Kx(e.day,e.part),e.value],(e,t)=>({count:e.count+t.count,activeMachineMins:e.activeMachineMins+t.activeMachineMins}))}function Yx(e){return D.of(e).toHashMap(e=>[new Kx(Rt(e.completeTime),e.partName+`-`+e.process.toString()),{count:e.quantity,activeMachineMins:e.expectedMachineMins}],(e,t)=>({count:e.count+t.count,activeMachineMins:e.activeMachineMins+t.activeMachineMins}))}var Xx=class{constructor(e,t){this.x=e,this.y=t}compare(e){let t=this.x-e.x;return t===0?this.y.localeCompare(e.y):t}hash(){return ve(this.x,this.y)}toString(){return`{x: ${new Date(this.x).toISOString()}, y: ${this.y}}`}};function Zx(e){let t=D.of(e).toHashMap(e=>[new Xx(e.x.getTime(),e.y),e],(e,t)=>t),n=D.of(e).map(e=>e.x.getTime()).distinct().toSortedArray(e=>e),r=D.of(e).aggregate(e=>e.y,e=>e.activeMachineMins/e.count,(e,t)=>isNaN(e)?t:e).sortBy(([e,t])=>e),i=`<table>
|
|
71
|
+
<thead><tr><th>Part</th><th>Expected Cycle Mins</th>`;for(let e of n)i+=`<th>`+new Date(e).toDateString()+` Completed</th>`,i+=`<th>`+new Date(e).toDateString()+` Std. Hours</th>`;i+=`</tr></thead>
|
|
72
|
+
<tbody>
|
|
73
|
+
`;for(let[e,a]of r){i+=`<tr><th>`+e+`</th><th>`+a.toFixed(1)+`</th>`;for(let r of n){let n=t.get(new Xx(r,e));n===void 0?(i+=`<td></td>`,i+=`<td></td>`):(i+=`<td>`+n.count.toFixed(0)+`</td>`,i+=`<td>`+(n.activeMachineMins/60).toFixed(1)+`</td>`)}i+=`</tr>
|
|
74
|
+
`}return i+=`</tbody>
|
|
75
|
+
</table>`,i}function Qx(e){Je(Zx(e))}function $x(e,t){return D.of(e).map(([e,n])=>{let r=t.get(e)??0,i=r<1440?Math.max(n/(1440-r),0):0;return{x:e.day,y:e.station,color:Math.min(i,1),label:r<1440?(i*100).toFixed(1)+`%`:`Planned Downtime`}}).toSortedArray(e=>e.x.getTime(),{desc:e=>e.y})}var eS=F(`Standard OEE`);function tS(){Q(`Station OEE`);let[e,t]=A(eS),n=r(od),i=n.type===`Last30`?[P(k(),-29),P(k(),1)]:[n.month,Vt(n.month,1)],a=r(n.type===`Last30`?ao:co),o=r(n.type===`Last30`?Fo:Lo),s=(0,K.useMemo)(()=>{let t=db(o);return $x(e===`Standard OEE`?cb(a.valuesToLazySeq()):e===`Occupied`?lb(a.valuesToLazySeq()):fb(o),t)},[e,a,o]);return(0,Y.jsx)(Gx,{label:`Station Usage Per Day`,y_title:`Station`,label_title:e===`Occupied`?`Occupied`:`OEE`,dateRange:i,cur_selected:e,options:[`Standard OEE`,`Occupied`,`Planned OEE`],setSelected:t,points:s,onExport:()=>gb(`Station`,s)})}var nS=F(`Completed`);function rS(e,t,n,r){let i=Jx(e,t,n,r);return D.of(i).map(([e,t])=>({x:e.day,y:e.part,color:t.activeMachineMins,label:t.count.toFixed(0)+` (`+(t.activeMachineMins/60).toFixed(1)+` hours)`,count:t.count,activeMachineMins:t.activeMachineMins})).toSortedArray(e=>e.x.getTime(),{desc:e=>e.y})}function iS(e){let t=Yx(e);return D.of(t).map(([e,t])=>({x:e.day,y:e.part,color:t.activeMachineMins,label:t.count.toFixed(0)+` (`+(t.activeMachineMins/60).toFixed(1)+` hours)`,count:t.count,activeMachineMins:t.activeMachineMins})).toSortedArray(e=>e.x.getTime(),{desc:e=>e.y})}function aS(){Q(`Part Production`);let[e,t]=A(nS),n=r(od),i=n.type===`Last30`?[P(k(),-29),P(k(),1)]:[n.month,Vt(n.month,1)],a=r(n.type===`Last30`?ao:co),o=r(n.type===`Last30`?ml:gl),s=r(n.type===`Last30`?Bl:Hl),c=(0,K.useMemo)(()=>{if(e===`Completed`){let e=k(),t=n.type===`Last30`?P(e,-30):n.month,r=n.type===`Last30`?P(e,1):Vt(n.month,1);return rS(a.valuesToLazySeq(),s.matsById,t,r)}return iS(o)},[e,a,s,o,n]);return(0,Y.jsx)(Gx,{label:`Part Production Per Day`,y_title:`Part`,label_title:e,dateRange:i,cur_selected:e,options:[`Completed`,`Planned`],setSelected:t,points:c,onExport:()=>Qx(c)})}var oS=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`});function sS(e){return`material`in e&&Array.isArray(e.material)}function cS(e){return`operations`in e&&(e.operations===void 0||Array.isArray(e.operations))}function lS({range:e}){let t=r(od);if(!e)return null;let n=`start`in e?e.start:e[0],i=`end`in e?e.end:e[1];return t.type===`SpecificMonth`?n.toDateString()+` to `+i.toDateString():oS.format(n)+` to `+oS.format(i)}var uS=F(!0),dS=lt(e=>e(Mc)?{part:`aaa`,proc:2}:void 0),fS=F(vo),pS=F(void 0),mS=F(void 0),hS=F(void 0),gS=F(se.empty()),_S=F(e=>{let t=e(od);return t.type===`Last30`?e(hS):e(gS).get(t.month)},(e,t,n)=>{let r=e(od);r.type===`Last30`?t(hS,n):t(gS,e=>e.alter(r.month,()=>n))}),vS=F(null);function yS(){Q(`Machine Cycles`);let e=j(X),t=(0,K.useCallback)(function(t){if(!sS(t))return[];let n=[];for(let r of t.material)n.push({title:r.serial?r.serial:`Material`,value:`Open Card`,link:()=>e({type:`LogMat`,logMat:r})});return n},[e]),n=r(od),i=r(n.type===`Last30`?ja:Na),a=r(n.type===`Last30`?Bl:Hl),[o,s]=A(uS),[c,l]=A(dS),[u,d]=A(fS),[f,p]=A(pS),[m,h]=A(mS),[g,ee]=A(_S),[_,te]=A(vS),ne=n.type===`Last30`?[P(k(),-29),P(k(),1)]:[n.month,Vt(n.month,1)],v=r(n.type===`Last30`?ao:co),y=(0,K.useMemo)(()=>c?f?xo(v.valuesToLazySeq(),{partAndProc:c,pallet:m,operation:f}):xo(v.valuesToLazySeq(),{partAndProc:c,pallet:m,station:vo}):m||u!==`@@@_FMSInsight_FilterAnyMachineKey_@@@`?xo(v.valuesToLazySeq(),{pallet:m,station:u}):bo(v.valuesToLazySeq()),[c,m,u,f,v]),re=c?f??(y.allMachineOperations.length===1?y.allMachineOperations[0]:void 0):void 0,ie=(0,K.useMemo)(()=>{if(re)return Co(y,!1)},[y,re]);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsxs)(b,{variant:`subtitle1`,children:[`Machine Cycles for `,(0,Y.jsx)(lS,{range:g??ne})]}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,value:o?`graph`:`table`,onChange:e=>s(e.target.value===`graph`),children:[(0,Y.jsx)(L,{value:`graph`,children:`Graph`},`graph`),(0,Y.jsx)(L,{value:`table`,children:`Table`},`table`)]})}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:c?y.allPartAndProcNames.findIndex(e=>c.part===e.part&&c.proc===e.proc):-1,style:{marginLeft:`1em`},onChange:e=>{l(e.target.value===-1?void 0:y.allPartAndProcNames[e.target.value]),p(void 0)},children:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsx)(`em`,{children:`Any Part`})},0),y.allPartAndProcNames.map((e,t)=>(0,Y.jsx)(L,{value:t,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.part,size:20}),(0,Y.jsxs)(`span`,{style:{marginRight:`1em`},children:[e.part,`-`,e.proc]})]})},t))]})}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsx)(O,{autoWidth:!0,displayEmpty:!0,value:c?re?y.allMachineOperations.findIndex(e=>re.compare(e)===0):-1:u,style:{marginLeft:`1em`},onChange:e=>{if(c){let t=typeof e.target.value==`number`?e.target.value:Number.parseInt(e.target.value,10);Number.isNaN(t)||p(t===-1?void 0:y.allMachineOperations[t])}else typeof e.target.value==`string`&&d(e.target.value)},children:c?[...y.allMachineOperations.length===1?[]:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsx)(`em`,{children:`Any Operation`})},-1)],...y.allMachineOperations.map((e,t)=>(0,Y.jsxs)(L,{value:t,children:[e.statGroup,` `,e.operation]},t))]:[(0,Y.jsx)(L,{value:vo,children:(0,Y.jsx)(`em`,{children:`Any Machine`})},-1),y.allMachineNames.map(e=>(0,Y.jsx)(L,{value:e,children:(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,Y.jsx)(`span`,{style:{marginRight:`1em`},children:e})})},e))]})}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:m||``,style:{marginLeft:`1em`},onChange:e=>h(e.target.value===``?void 0:e.target.value),children:[(0,Y.jsx)(L,{value:``,children:(0,Y.jsx)(`em`,{children:`Any Pallet`})},0),y.allPalletNames.map(e=>(0,Y.jsx)(L,{value:e,children:(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,Y.jsx)(`span`,{style:{marginRight:`1em`},children:e})})},e))]})}),y.data.size>0?(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:()=>Do(y,a.matsById,g),style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,children:(0,Y.jsx)(ct,{})})}):void 0]}),(0,Y.jsx)(`main`,{children:o?(0,Y.jsx)(nx,{points:y.data,series_label:y.seriesLabel,default_date_range:ne,extra_tooltip:t,current_date_zoom:g,set_date_zoom_range:e=>ee(e.zoom),yZoom:_,setYZoom:te,stats:re?i.get(re):void 0,partCntPerPoint:re?D.of(y.data).head()?.[1]?.[0]?.material?.length:void 0,plannedTimeMinutes:ie}):(0,Y.jsx)(rb,{points:y.data,matsById:a.matsById,period:n,current_date_zoom:g,set_date_zoom_range:e=>ee(e.zoom),showWorkorderAndInspect:!0,emptyMessage:c||m||f?`No Cycles`:`Select part, station, or pallet to see cycles.`})})]})}var bS=F(!0),xS=lt(e=>e(Mc)?{part:`aaa`,proc:2}:void 0),SS=lt(e=>e(Mc)?`LoadOp`:`LULOccupancy`),CS=F(yo),wS=F(`Any`),TS=F(void 0),ES=F(void 0),DS=F(se.empty()),OS=F(e=>{let t=e(od);return t.type===`Last30`?e(ES):e(DS).get(t.month)},(e,t,n)=>{let r=e(od);r.type===`Last30`?t(ES,n):t(DS,e=>e.alter(r.month,()=>n))}),kS=F(null);function AS(){Q(`L/U Cycles`);let e=j(X),t=(0,K.useCallback)(function(t){if(!cS(t))return[];let n=[];if(t.operations)for(let r of t.operations)n.push({title:(r.mat.serial?r.mat.serial:`Material`)+` `+r.operation,value:`Open Card`,link:()=>e({type:`LogMat`,logMat:r.mat})});return n},[e]),n=r(od),[i,a]=A(bS),[o,s]=A(xS),[c,l]=A(SS),[u,d]=A(CS),[f,p]=A(wS),[m,h]=A(TS),[g,ee]=A(OS),[_,te]=A(kS),ne=r(G),v=eo(ne.basketName),y=r(n.type===`Last30`?oo:lo),re=go(f,y),ie=(0,K.useMemo)(()=>o&&c===`LoadOp`?new ka(o.part,`L/U`,`LOAD-${o.proc}`):o&&c===`UnloadOp`?new ka(o.part,`L/U`,`UNLOAD-${o.proc}`):null,[o,c]),ae=n.type===`Last30`?[P(k(),-29),P(k(),1)]:[n.month,Vt(n.month,1)],x=r(n.type===`Last30`?ao:co),oe=r(n.type===`Last30`?Bl:Hl),se=r(n.type===`Last30`?ja:Na),ce=(0,K.useMemo)(()=>o||m||u!==`@@@_FMSInsigt_FilterAnyLoadKey_@@@`||re!==`Any`?ie?xo(x.valuesToLazySeq(),{operation:ie,pallet:m,station:u,carrierKind:re}):i?So(x.valuesToLazySeq(),{partAndProc:o,pallet:m,station:u,carrierKind:re}):xo(x.valuesToLazySeq(),{partAndProc:o,pallet:m,station:u,carrierKind:re}):bo(x.valuesToLazySeq()),[o,m,ie,u,x,i,re]),le=(0,K.useMemo)(()=>{if(c===`LoadOp`||c===`UnloadOp`)return Co(ce,!0)},[ce,c]);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsxs)(b,{variant:`subtitle1`,children:[`Load/Unload Cycles for `,(0,Y.jsx)(lS,{range:g??ae})]}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,value:i?`graph`:`table`,onChange:e=>a(e.target.value===`graph`),children:[(0,Y.jsx)(L,{value:`graph`,children:`Graph`},`graph`),(0,Y.jsx)(L,{value:`table`,children:`Table`},`table`)]})}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:o?ce.allPartAndProcNames.findIndex(e=>o.part===e.part&&o.proc===e.proc):-1,style:{marginLeft:`1em`},onChange:e=>{e.target.value===-1?(s(void 0),l(`LULOccupancy`)):s(e.target.value===-1?void 0:ce.allPartAndProcNames[e.target.value])},children:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsx)(`em`,{children:`Any Part`})},0),ce.allPartAndProcNames.map((e,t)=>(0,Y.jsx)(L,{value:t,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.part,size:20}),(0,Y.jsxs)(`span`,{style:{marginRight:`1em`},children:[e.part,`-`,e.proc]})]})},t))]})}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:c,style:{marginLeft:`1em`},onChange:e=>l(e.target.value),children:[(0,Y.jsx)(L,{value:`LULOccupancy`,children:`L/U Occupancy`}),o?(0,Y.jsx)(L,{value:`LoadOp`,children:`Load Operation (estimated)`}):void 0,o?(0,Y.jsx)(L,{value:`UnloadOp`,children:`Unload Operation (estimated)`}):void 0]})}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:u,style:{marginLeft:`1em`},onChange:e=>{d(e.target.value)},children:[(0,Y.jsx)(L,{value:yo,children:(0,Y.jsx)(`em`,{children:`Any Station`})},-1),ce.allLoadStationNames.map(e=>(0,Y.jsx)(L,{value:e,children:(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,Y.jsx)(`span`,{style:{marginRight:`1em`},children:e})})},e))]})}),y?(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:re,style:{marginLeft:`1em`},onChange:e=>{let t=e.target.value;p(t),t===`Basket`&&h(void 0)},children:[(0,Y.jsx)(L,{value:`Any`,children:(0,Y.jsx)(`em`,{children:`Any Carrier`})}),(0,Y.jsx)(L,{value:`Pallet`,children:`Pallet`}),(0,Y.jsx)(L,{value:`Basket`,children:v})]})}):void 0,re===`Basket`?void 0:(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:m||``,style:{marginLeft:`1em`},onChange:e=>h(e.target.value===``?void 0:e.target.value),children:[(0,Y.jsx)(L,{value:``,children:(0,Y.jsx)(`em`,{children:`Any Pallet`})},0),ce.allPalletNames.map(e=>(0,Y.jsx)(L,{value:e,children:(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,Y.jsx)(`span`,{style:{marginRight:`1em`},children:e})})},e))]})}),ce.data.size>0?(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:()=>Do(ce,oe.matsById,g,c===`LULOccupancy`,ne.loadStationNames,v),style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,children:(0,Y.jsx)(ct,{})})}):void 0]}),(0,Y.jsx)(`main`,{children:i?(0,Y.jsx)(nx,{points:ce.data,series_label:ce.seriesLabel,default_date_range:ae,extra_tooltip:t,current_date_zoom:g,set_date_zoom_range:e=>ee(e.zoom),yZoom:_,setYZoom:te,stats:ie?se.get(ie):void 0,plannedTimeMinutes:le}):(0,Y.jsx)(rb,{points:ce.data,matsById:oe.matsById,period:n,current_date_zoom:g,set_date_zoom_range:e=>ee(e.zoom),showWorkorderAndInspect:!0,hideMedian:c===`LULOccupancy`,emptyMessage:o||m?`No Cycles`:`Select part, operation, or pallet to see cycles.`})})]})}var jS=lt(e=>e(Mc)?3:void 0),MS=F(void 0),NS=F(void 0),PS=F(null);function FS(e){return`mats`in e&&Array.isArray(e.mats)}var IS=F(e=>{let t=e(jS),n=e(MS);if(!t&&!n)return new Map;let r=e(e(od).type===`Last30`?tu:ru);if(t){let e=r.get(t)?.valuesToLazySeq()??D.of([]);return n&&(e=e.filter(e=>e.mats.some(e=>e.part===n.part&&e.proc===n.proc))),new Map([[t.toString(),Array.from(e)]])}return n?D.of(r).collect(([e,t])=>{let r=t.valuesToLazySeq().filter(e=>e.mats.some(e=>e.part===n.part&&e.proc===n.proc)).toRArray();return r.length>0?[e,r]:null}).toRMap(([e,t])=>[e.toString(),t]):new Map}),LS=F(e=>{let t=e(e(od).type===`Last30`?tu:ru);return D.of(t).flatMap(([,e])=>e).flatMap(([,e])=>e.mats).distinctAndSortBy(e=>e.part,e=>e.proc).map(e=>({part:e.part,proc:e.proc})).toRArray()});function RS(){Q(`Pallet Cycles`);let[e,t]=A(jS),[n,i]=A(MS),[a,o]=A(NS),[s,c]=A(PS),l=r(od),u=l.type===`Last30`?[P(k(),-29),P(k(),1)]:[l.month,Vt(l.month,1)],d=r(l.type===`Last30`?tu:ru),f=r(IS),p=r(LS),m=j(X),h=(0,K.useCallback)(function(e){return FS(e)?e.mats.map(e=>({title:e.part+`-`+e.proc,value:e.serial??``,link:e.serial?()=>m({type:`LogMat`,logMat:e}):void 0})):[]},[m]);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsx)(b,{variant:`subtitle1`,children:`Pallet Cycles`}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:e??-1,onChange:e=>t(e.target.value===-1?void 0:e.target.value),children:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsx)(`em`,{children:`Any Pallet`})},0),d.keysToLazySeq().sortBy(e=>e).map(e=>(0,Y.jsx)(L,{value:e,children:(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,Y.jsx)(`span`,{style:{marginRight:`1em`},children:e})})},e))]})}),p.length>0?(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:n?p.findIndex(e=>n.part===e.part&&n.proc===e.proc):-1,style:{marginLeft:`1em`},onChange:e=>{i(e.target.value===-1?void 0:p[e.target.value])},children:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsx)(`em`,{children:`Any Part`})},0),p.map((e,t)=>(0,Y.jsx)(L,{value:t,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.part,size:20}),(0,Y.jsxs)(`span`,{style:{marginRight:`1em`},children:[e.part,`-`,e.proc]})]})},t))]})}):void 0,(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:()=>ko(d),style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,children:(0,Y.jsx)(ct,{})})})]}),(0,Y.jsx)(`main`,{children:(0,Y.jsx)(nx,{points:f,series_label:`Pallet`,default_date_range:u,current_date_zoom:a,set_date_zoom_range:e=>o(e.zoom),yZoom:s,setYZoom:c,extra_tooltip:h})})]})}var zS=F(void 0),BS=F(void 0),VS=F(void 0);function HS(e){return`mats`in e&&Array.isArray(e.mats)}var US=F(null),WS=F(e=>{let t=e(zS),n=e(BS);if(!t&&!n)return new Map;let r=e(e(od).type===`Last30`?lu:fu);if(t){let e=r.get(t)?.valuesToLazySeq()??D.of([]);return n&&(e=e.filter(e=>e.mats.some(e=>e.part===n.part&&e.proc===n.proc))),new Map([[t.toString(),Array.from(e)]])}return n?D.of(r).collect(([e,t])=>{let r=t.valuesToLazySeq().filter(e=>e.mats.some(e=>e.part===n.part&&e.proc===n.proc)).toRArray();return r.length>0?[e,r]:null}).toRMap(([e,t])=>[e.toString(),t]):new Map}),GS=F(e=>{let t=e(e(od).type===`Last30`?lu:fu);return D.of(t).flatMap(([,e])=>e).flatMap(([,e])=>e.mats).distinctAndSortBy(e=>e.part,e=>e.proc).map(e=>({part:e.part,proc:e.proc})).toRArray()});function KS(){let e=eo(r(G).basketName);Q(`${e} Cycles`);let[t,n]=A(zS),[i,a]=A(BS),[o,s]=A(VS),[c,l]=A(US),u=r(od),d=u.type===`Last30`?[P(k(),-29),P(k(),1)]:[u.month,Vt(u.month,1)],f=r(u.type===`Last30`?lu:fu),p=r(WS),m=r(GS),h=j(X),g=(0,K.useCallback)(function(e){return HS(e)?e.mats.map(e=>({title:e.part+`-`+e.proc,value:e.serial??``,link:e.serial?()=>h({type:`LogMat`,logMat:e}):void 0})):[]},[h]);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsxs)(b,{variant:`subtitle1`,children:[e,` Cycles`]}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:t??-1,onChange:e=>n(e.target.value===-1?void 0:e.target.value),children:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsxs)(`em`,{children:[`Any `,e]})},0),f.keysToLazySeq().sortBy(e=>e).map(e=>(0,Y.jsx)(L,{value:e,children:(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,Y.jsx)(`span`,{style:{marginRight:`1em`},children:e})})},e))]})}),m.length>0?(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,displayEmpty:!0,value:i?m.findIndex(e=>i.part===e.part&&i.proc===e.proc):-1,style:{marginLeft:`1em`},onChange:e=>{a(e.target.value===-1?void 0:m[e.target.value])},children:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsx)(`em`,{children:`Any Part`})},0),m.map((e,t)=>(0,Y.jsx)(L,{value:t,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.part,size:20}),(0,Y.jsxs)(`span`,{style:{marginRight:`1em`},children:[e.part,`-`,e.proc]})]})},t))]})}):void 0,(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:()=>ko(f,e),style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,children:(0,Y.jsx)(ct,{})})})]}),(0,Y.jsx)(`main`,{children:(0,Y.jsx)(nx,{points:p,series_label:e,default_date_range:d,current_date_zoom:o,set_date_zoom_range:e=>s(e.zoom),yZoom:c,setYZoom:l,extra_tooltip:g})})]})}function qS(e,t,n){let r=e?.zoomRange;return n?(t.get(n)??se.empty()).valuesToAscLazySeq().transform(e=>r?e.filter(e=>e.time>=r.start&&e.time<=r.end):e).flatMap(e=>e.replacements.map(t=>({...t,station:n,time:e.time}))):t.toAscLazySeq().flatMap(([e,t])=>t.valuesToAscLazySeq().transform(e=>r?e.filter(e=>e.time>=r.start&&e.time<=r.end):e).flatMap(t=>t.replacements.map(n=>({...n,station:e,time:t.time}))))}function JS(e,t,n,r){return qS(e,t,n).groupBy(e=>e.tool).map(([e,t])=>{let n=0,r=null,i=0,a=null;for(let e of t){let t=e.type===`ReplaceBeforeCycleStart`?e.useAtReplacement:e.totalUseAtBeginningOfCycle;t&&(r===null||t>r)&&(r=t),t&&(n+=t);let o=e.type===`ReplaceBeforeCycleStart`?e.cntAtReplacement:e.totalCntAtBeginningOfCycle;o&&(a===null||o>a)&&(a=o),o&&(i+=o)}return{tool:e,numReplacements:t.length,totalUseOfAllReplacements:n,totalCntOfAllReplacements:i,maxY:r??a??1,yAxisType:r===null?`Count`:`Time`,replacements:t}}).toSortedArray(r)}function YS(e,t){let n=e.maxY/2;return t.type===`ReplaceBeforeCycleStart`?e.yAxisType===`Time`?t.useAtReplacement??n:t.cntAtReplacement??n:e.yAxisType===`Time`?t.totalUseAtBeginningOfCycle??n:t.totalCntAtBeginningOfCycle??n}var XS=Intl.NumberFormat(void 0,{maximumFractionDigits:1}),ZS=(0,K.createContext)({start:new Date,end:new Date});function QS({tooltip:e}){return(0,Y.jsxs)(E,{spacing:.5,children:[(0,Y.jsxs)(`div`,{children:[`Tool: `,e.r.tool]}),(0,Y.jsxs)(`div`,{children:[`Pocket: `,e.r.pocket]}),(0,Y.jsxs)(`div`,{children:[`Time: `,e.r.time.toLocaleString()]}),(0,Y.jsxs)(`div`,{children:[`Station: `,e.r.station.group,` #`,e.r.station.num]}),e.r.type===`ReplaceBeforeCycleStart`?(0,Y.jsxs)(Y.Fragment,{children:[e.r.useAtReplacement===null?void 0:(0,Y.jsxs)(`div`,{children:[`Minutes at replacement: `,XS.format(e.r.useAtReplacement)]}),e.r.cntAtReplacement===null?void 0:(0,Y.jsxs)(`div`,{children:[`Count at replacement: `,XS.format(e.r.cntAtReplacement)]})]}):(0,Y.jsxs)(Y.Fragment,{children:[e.r.totalUseAtBeginningOfCycle===null?void 0:(0,Y.jsxs)(`div`,{children:[`Minutes at beginning of cycle:`,` `,XS.format(e.r.totalUseAtBeginningOfCycle)]}),e.r.totalUseAtEndOfCycle===null?void 0:(0,Y.jsxs)(`div`,{children:[`Minutes at end of cycle: `,XS.format(e.r.totalUseAtEndOfCycle)]}),e.r.totalCntAtBeginningOfCycle===null?void 0:(0,Y.jsxs)(`div`,{children:[`Count at beginning of cycle:`,` `,XS.format(e.r.totalCntAtBeginningOfCycle)]}),e.r.totalCntAtEndOfCycle===null?void 0:(0,Y.jsxs)(`div`,{children:[`Count at end of cycle: `,XS.format(e.r.totalCntAtEndOfCycle)]})]})]})}function $S({row:e,tooltip:t,timeScale:n,yScale:r}){let[i,a]=A(t);return(0,Y.jsx)(`g`,{children:e.replacements.map((t,o)=>(0,Y.jsx)(`circle`,{cx:n(t.time),cy:r(YS(e,t)),r:t===i?.r?4:2,onMouseEnter:e=>a({top:0,left:Ho(e)?.x??0,r:t}),fill:`black`},o))})}var eC=[{id:0,numeric:!1,label:`Tool`,getDisplay:e=>e.tool},{id:1,numeric:!0,label:`Num Replacements`,getDisplay:e=>e.numReplacements.toString(),getForSort:e=>e.numReplacements},{id:2,numeric:!0,label:`Avg Use (min) at Replacement`,getDisplay:e=>XS.format(e.totalUseOfAllReplacements/e.numReplacements),getForSort:e=>e.totalUseOfAllReplacements/e.numReplacements},{id:3,numeric:!0,label:`Avg Use (count) at Replacement`,getDisplay:e=>XS.format(e.totalCntOfAllReplacements/e.numReplacements),getForSort:e=>e.totalCntOfAllReplacements/e.numReplacements},{id:4,numeric:!1,ignoreDuringExport:!0,label:`All Replacements`,getDisplay:()=>``,expanded:!0,Cell:(0,K.memo)(function({row:e}){let t=(0,K.useContext)(ZS),n=(0,K.useMemo)(()=>F(null),[]),r=j(n),{ref:i,width:a}=Ee({refreshMode:`debounce`,refreshRate:100,handleHeight:!1}),o=me().domain([t.start,t.end]).range([0,a??1e3]),s=ie().domain([0,e.maxY]).range([33,3]),c=e.numReplacements===0?null:s(e.totalUseOfAllReplacements/e.numReplacements);return(0,Y.jsxs)(`div`,{ref:i,style:{position:`relative`,width:`100%`,height:`35px`},children:[(0,Y.jsxs)(`svg`,{height:`35`,width:a??1e3,onMouseLeave:()=>r(null),children:[c===null?void 0:(0,Y.jsx)(`line`,{x1:`0`,y1:c,x2:a??1e3,y2:c,stroke:`red`,strokeWidth:.5}),(0,Y.jsx)($S,{row:e,tooltip:n,timeScale:o,yScale:s})]}),(0,Y.jsx)(Ko,{atom:n,TooltipContent:QS,chartHeight:35,chartWidth:a??1e3})]})})}],tC=(0,K.memo)(function(e){let t=r(od),n=Rh(),i=Lh(t),a=zh(0,eC),o=r(t.type===`Last30`?xu:Cu),s=(0,K.useMemo)(()=>JS(i,o,e.station,a.sortOn),[i,o,e.station,a]),c=n?s.slice(n.page*n.rowsPerPage,(n.page+1)*n.rowsPerPage):s,l=i?.zoomRange??(t.type===`Last30`?{start:P(k(),-29),end:P(k(),1)}:{start:t.month,end:Vt(t.month,1)});return(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(ZS.Provider,{value:l,children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)(Ah,{columns:eC,sort:a,showDetailsCol:!1}),(0,Y.jsx)(Ih,{columns:eC,pageData:c,rowsPerPage:n.rowsPerPage})]}),(0,Y.jsx)(Fh,{tpage:n,zoom:i.zoom,count:s.length})]})})}),nC=[{id:0,numeric:!1,label:`Date`,getDisplay:e=>e.time.toLocaleString(),getForSort:e=>e.time.getTime(),getForExport:e=>e.time.toISOString()},{id:1,numeric:!1,label:`Machine`,getDisplay:e=>e.station.group+` #`+e.station.num.toString(),getForSort:e=>e.station},{id:2,numeric:!1,label:`Tool`,getDisplay:e=>e.tool},{id:3,numeric:!0,label:`Pocket`,getDisplay:e=>e.pocket===-1?``:e.pocket.toString(),getForSort:e=>e.pocket},{id:4,numeric:!1,label:`Type`,getDisplay:e=>e.type===`ReplaceBeforeCycleStart`?`Between Cycles`:`During Cycle`},{id:5,numeric:!0,label:`Use At Replacement / Start of Cycle (min)`,getDisplay:e=>{let t=e.type===`ReplaceBeforeCycleStart`?e.useAtReplacement:e.totalUseAtBeginningOfCycle;return t==null?``:XS.format(t)},getForSort:e=>e.type===`ReplaceBeforeCycleStart`?e.useAtReplacement:e.totalUseAtBeginningOfCycle},{id:6,numeric:!0,label:`Use At End of Cycle (min)`,getDisplay:e=>{if(e.type===`ReplaceBeforeCycleStart`)return``;let t=e.totalUseAtEndOfCycle;return t==null?``:XS.format(t)},getForSort:e=>e.type===`ReplaceBeforeCycleStart`?0:e.totalUseAtEndOfCycle},{id:7,numeric:!0,label:`Use At Replacement / Start of Cycle (count)`,getDisplay:e=>{let t=e.type===`ReplaceBeforeCycleStart`?e.cntAtReplacement:e.totalCntAtBeginningOfCycle;return t==null?``:XS.format(t)},getForSort:e=>e.type===`ReplaceBeforeCycleStart`?e.cntAtReplacement:e.totalCntAtBeginningOfCycle},{id:8,numeric:!0,label:`Use At End of Cycle (count)`,getDisplay:e=>{if(e.type===`ReplaceBeforeCycleStart`)return``;let t=e.totalCntAtEndOfCycle;return t==null?``:XS.format(t)},getForSort:e=>e.type===`ReplaceBeforeCycleStart`?0:e.totalCntAtEndOfCycle}],rC=(0,K.memo)(function(e){let t=r(od),n=Rh(),i=Lh(t),a=zh(0,nC),o=r(t.type===`Last30`?xu:Cu),s=(0,K.useMemo)(()=>qS(i,o,e.station).toSortedArray(a.sortOn),[a,i,o,e.station]),c=n?s.slice(n.page*n.rowsPerPage,(n.page+1)*n.rowsPerPage):s;return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)(Ah,{columns:nC,sort:a,showDetailsCol:!1}),(0,Y.jsx)(Ih,{columns:nC,pageData:c})]}),(0,Y.jsx)(Fh,{tpage:n,zoom:i.zoom,count:s.length})]})});function iC(e,t){t===`summary`?Vh(eC,JS(void 0,e,void 0,e=>e.tool)):Vh(nC,qS(void 0,e,void 0).toSortedArray(e=>e.tool,e=>e.time))}var aC=(0,K.memo)(function(e){let t=r(od),n=r(t.type===`Last30`?xu:Cu),i=Array.from(n.keys()),a=e.station===null?-1:i.indexOf(e.station);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,value:a,style:{marginLeft:`1em`},onChange:t=>{let n=t.target.value;n===-1?e.setSelectedStation(null):e.setSelectedStation(i[n])},children:[(0,Y.jsx)(L,{value:-1,children:(0,Y.jsx)(`em`,{children:`Any Machine`})}),i.map((e,t)=>(0,Y.jsx)(L,{value:t,children:(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,Y.jsxs)(`span`,{style:{marginRight:`1em`},children:[e.group,` #`,e.num]})})},t))]})}),(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{onClick:()=>iC(n,e.displayType),style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,children:(0,Y.jsx)(ct,{})})})]})}),oC=F(null),sC=F(`summary`),cC=(0,K.memo)(function(){Q(`Tool Replacements`);let[e,t]=A(oC),[n,r]=A(sC);return(0,Y.jsxs)(B,{sx:{paddingLeft:`24px`,paddingRight:`24px`,paddingTop:`10px`},children:[(0,Y.jsxs)(B,{component:`nav`,sx:{display:`flex`,minHeight:`2.5em`,alignItems:`center`,maxWidth:`calc(100vw - 24px - 24px)`},children:[(0,Y.jsx)(b,{variant:`subtitle1`,children:`Tool Replacements`}),(0,Y.jsx)(B,{sx:{flexGrow:1}}),(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{autoWidth:!0,value:n,style:{marginLeft:`1em`},onChange:e=>r(e.target.value),children:[(0,Y.jsx)(L,{value:`summary`,children:`Summary`}),(0,Y.jsx)(L,{value:`details`,children:`Details`})]})}),(0,Y.jsx)(aC,{station:e,setSelectedStation:t,displayType:n})]}),(0,Y.jsx)(`main`,{children:n===`summary`?(0,Y.jsx)(tC,{station:e}):(0,Y.jsx)(rC,{station:e})})]})}),lC=F(null),uC=150,dC=40,fC=10,pC=20,mC=10,hC=80;function gC(e){return`${e.workorderId}-${e.part}`}function _C(e){return e?new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()):null}function vC(e){let t=e.map(gC),n=D.of(e).flatMap(e=>{let t=_C(e.simulatedFilled);return[_C(e.simulatedStart),t?P(t,2):null]}).collect(e=>e),r=n.minBy(e=>e)??new Date,i=n.maxBy(e=>e)??P(new Date,7),a=Math.max(Dn(i,r)*50,30),o=Math.max(t.length*hC,hC);return{xScale:me().domain([r,i]).range([0,a]),yScale:Ve().domain(t).range([0,o])}}function yC({tooltip:e}){return(0,Y.jsxs)(E,{children:[(0,Y.jsxs)(`div`,{children:[`Workorder: `,e.data.workorderId]}),(0,Y.jsxs)(`div`,{children:[`Part: `,e.data.part]}),(0,Y.jsxs)(`div`,{children:[`Due Date: `,e.data.dueDate.toLocaleDateString()]}),(0,Y.jsxs)(`div`,{children:[`Priority: `,e.data.priority]}),(0,Y.jsxs)(`div`,{children:[`Planned Quantity: `,e.data.plannedQuantity]}),(0,Y.jsxs)(`div`,{children:[`Completed Quantity: `,e.data.completedQuantity]}),(0,Y.jsxs)(`div`,{children:[`Projected Start: `,_C(e.data.simulatedStart)?.toLocaleDateString()]}),(0,Y.jsxs)(`div`,{children:[`Projected Filled: `,_C(e.data.simulatedFilled)?.toLocaleDateString()]})]})}function bC({workorders:e}){return(0,Y.jsx)(`div`,{children:e.map(e=>(0,Y.jsxs)(E,{direction:`column`,sx:{height:hC,alignItems:`flex-end`,paddingRight:`10px`,justifyContent:`center`},children:[(0,Y.jsx)(B,{children:e.workorderId}),(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)($,{part:e.part,size:18}),(0,Y.jsx)(B,{sx:{ml:`3px`},children:e.part})]})]},gC(e)))})}function xC({xScale:e,yScale:t}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(os,{scale:e,top:0}),(0,Y.jsx)(es,{scale:e,height:t.range()[1]-t.range()[0]})]})}function SC({workorders:e,xScale:t,yScale:n}){let r=j(lC),i=(0,K.useRef)(null);function a(e){return t=>{let n=Ho(t);n&&(i.current!==null&&(clearTimeout(i.current),i.current=null),r({left:n.x,top:n.y,data:e}))}}let o=(0,K.useCallback)(()=>{i.current=setTimeout(()=>{r(null)},300)},[i,r]);return(0,Y.jsx)(`g`,{children:e.map(e=>{let r=gC(e);return(0,Y.jsx)(`g`,{onMouseOver:a(e),onMouseLeave:o,children:e.simulatedStart&&e.simulatedFilled?(0,Y.jsx)(`rect`,{x:t(_C(e.simulatedStart)),y:(n(r)??0)+20,width:t(P(_C(e.simulatedFilled),1))-t(_C(e.simulatedStart)),height:40,fill:we[600]}):void 0},r)})})}function CC(){let e=r(q),t=(0,K.useMemo)(()=>D.of(e.workorders??[]).toSortedArray(e=>e.simulatedFilled?.getTime()??null,e=>e.simulatedStart?.getTime()??null,e=>e.workorderId,e=>e.part),[e.workorders]),{xScale:n,yScale:i}=vC(t);return(0,Y.jsxs)(B,{sx:{display:`flex`},children:[(0,Y.jsx)(B,{sx:{height:i.range()[1]+dC+fC,width:uC,paddingTop:`${dC}px`},children:(0,Y.jsx)(bC,{workorders:t})}),(0,Y.jsxs)(B,{sx:{flexGrow:1,width:0,position:`relative`},children:[(0,Y.jsx)(`div`,{style:{overflowX:`visible`},children:(0,Y.jsx)(`svg`,{height:i.range()[1]+dC+fC,width:n.range()[1]+mC+pC,children:(0,Y.jsxs)(`g`,{transform:`translate(${pC}, ${dC})`,children:[(0,Y.jsx)(xC,{yScale:i,xScale:n}),(0,Y.jsx)(SC,{workorders:t,xScale:n,yScale:i})]})})}),(0,Y.jsx)(Ko,{atom:lC,TooltipContent:yC,chartHeight:i.range()[1]+dC+fC,chartWidth:n.range()[1]+mC+pC})]})]})}var wC=F(e=>{let t=e(Nc);return t.route===Z.Operations_CurrentWorkorders?t.workorder??null:null},(e,t,n)=>{e(Nc).route===Z.Operations_CurrentWorkorders&&(n===``&&(n=null),t(Nc,{route:Z.Operations_CurrentWorkorders,workorder:n??void 0}))}),TC=l(`recentSearchedWorkorders`,[]),EC=F(async(e,{signal:t})=>{let n=e(wC);return n===null?null:await Vi.getActiveWorkorder(n,t)??[]}),DC=_r(o)({"& > *":{borderBottom:`unset !important`}}),OC=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),kC=(0,K.memo)(function({workorder:e}){let t=j(X),n=j(UC),r=D.ofObject(e.activeStationTime??{}).concat(D.ofObject(e.elapsedStationTime??{})).map(([e])=>e).distinctAndSortBy(e=>e);function a(n){t({type:`MatSummary`,summary:{materialID:n.materialID,partName:e.part,serial:n.serial,workorderId:e.workorderId}})}return(0,Y.jsxs)(E,{direction:`row`,sx:{flexWrap:`wrap`,justifyContent:`space-around`,ml:`1em`,mr:`1em`},children:[(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(he,{size:`small`,stickyHeader:!0,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Serial`}),(0,Y.jsx)(w,{children:`Quarantine?`}),(0,Y.jsx)(w,{sx:{whiteSpace:`nowrap`},children:`Inspect Failed?`}),(0,Y.jsx)(w,{sx:{whiteSpace:`nowrap`},children:`Close Out`}),(0,Y.jsx)(w,{padding:`checkbox`})]})}),(0,Y.jsx)(ae,{children:(e.material??[]).map(e=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:e.serial??``}),(0,Y.jsx)(w,{sx:{textAlign:`center`},padding:`checkbox`,children:e.quarantined?(0,Y.jsx)(re,{fontSize:`inherit`}):``}),(0,Y.jsx)(w,{sx:{textAlign:`center`},padding:`checkbox`,children:e.inspectionFailed?(0,Y.jsx)(i,{fontSize:`inherit`}):``}),(0,Y.jsx)(w,{sx:{textAlign:`center`},padding:`checkbox`,children:e.closeout===di.None?``:e.closeout===di.ClosedOut?(0,Y.jsx)(qt,{fontSize:`inherit`}):(0,Y.jsx)(i,{fontSize:`inherit`})}),(0,Y.jsx)(w,{padding:`checkbox`,children:(0,Y.jsx)(C,{onClick:()=>a(e),size:`large`,children:(0,Y.jsx)(Le,{fontSize:`inherit`})})})]},e.materialID))})]})}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(he,{size:`small`,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Station`}),(0,Y.jsx)(w,{children:`Active Minutes`}),(0,Y.jsx)(w,{children:`Elapsed Minutes`})]})}),(0,Y.jsx)(ae,{children:r.map(t=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:t}),(0,Y.jsx)(w,{children:OC.format(J(e.activeStationTime?.[t]??0))}),(0,Y.jsx)(w,{children:OC.format(J(e.elapsedStationTime?.[t]??0))})]},t))})]})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(he,{size:`small`,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Time`}),(0,Y.jsx)(w,{children:`Comment`})]})}),(0,Y.jsx)(ae,{children:(e.comments??[]).map((e,t)=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:e.timeUTC.toLocaleString(void 0,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`})}),(0,Y.jsx)(w,{children:e.comment})]},t))})]}),(0,Y.jsx)(z,{sx:{mt:`0.5em`},onClick:()=>n(e),children:`Add Comment`})]})]})});function AC(e){return e?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())).toLocaleDateString():``}function jC(e){return e.closeout===di.ClosedOut?!1:e.quarantined||e.inspectionFailed||e.closeout===di.CloseOutFailed}function MC({workorder:e,showSim:t}){let[n,r]=(0,K.useState)(!1),i=t?10:8;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(DC,{children:[(0,Y.jsx)(w,{children:e.workorderId}),(0,Y.jsx)(w,{children:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:e.part,size:25})}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(b,{variant:`body2`,component:`span`,sx:{display:`block`},children:e.part})})]})}),(0,Y.jsx)(w,{children:e.dueDate===null?``:e.dueDate.toLocaleDateString()}),(0,Y.jsx)(w,{align:`right`,children:e.priority}),(0,Y.jsx)(w,{align:`right`,children:e.plannedQuantity}),(0,Y.jsx)(w,{align:`right`,children:e.material?.length??0}),(0,Y.jsx)(w,{align:`right`,children:e.material?.filter(jC).length??0}),(0,Y.jsx)(w,{align:`right`,children:e.completedQuantity}),t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(w,{align:`right`,children:AC(e.simulatedStart)}),(0,Y.jsx)(w,{align:`right`,children:AC(e.simulatedFilled)})]}):void 0,(0,Y.jsx)(w,{children:(0,Y.jsx)(S,{title:`Show Details`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>r(!n),children:n?(0,Y.jsx)(ke,{}):(0,Y.jsx)(f,{})})})})]}),(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{sx:{pb:`0`,pt:`0`},colSpan:i,children:(0,Y.jsx)(x,{in:n,timeout:`auto`,unmountOnExit:!0,children:(0,Y.jsx)(kC,{workorder:e})})})})]})}function NC(e,t,n){let r;switch(t){case 0:r=e=>e.workorderId;break;case 1:r=e=>e.part;break;case 2:r=e=>e.plannedQuantity;break;case 3:r=e=>e.dueDate.getTime();break;case 4:r=e=>e.priority;break;case 5:r=e=>e.completedQuantity;break;case 7:r=e=>e.material?.filter(jC).length??0;break;case 6:r=e=>e.material?.length??0;break;case 8:r=e=>e.simulatedStart?.getTime()??null;break;case 9:r=e=>e.simulatedFilled?.getTime()??null}return D.of(e).toSortedArray(n===`asc`?{asc:r}:{desc:r})}function PC({sortBy:e,order:t,showSim:n}){let i=r(q),a=r(EC),s=(0,K.useMemo)(()=>NC(a??i.workorders??[],e,t),[i.workorders,e,t,a]);return a&&a.length===0?(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{colSpan:n?10:8,children:`No workorders found`})}):(0,Y.jsx)(Y.Fragment,{children:s.map(e=>(0,Y.jsx)(MC,{workorder:e,showSim:n},`${e.workorderId}-${e.part}`))})}function FC(e,t){let n=`<table>
|
|
76
|
+
<thead><tr>`;n+=`<th>Workorder</th>`,n+=`<th>Part</th>`,n+=`<th>Due Date</th>`,n+=`<th>Priority</th>`,n+=`<th>Planned Qty</th>`,n+=`<th>Completed Qty</th>`,t&&(n+=`<th>Simulated Start</th>`,n+=`<th>Simulated Filled</th>`),n+=`<th>Serials</th>`,n+=`<th>Active Time (mins)</th>`,n+=`<th>Elapsed Time (mins)</th>`,n+=`</tr></thead>
|
|
77
|
+
<tbody>
|
|
78
|
+
`;for(let r of e)n+=`<tr>`,n+=`<td>${r.workorderId}</td>`,n+=`<td>${r.part}</td>`,n+=`<td>${r.dueDate===null?``:r.dueDate.toLocaleDateString()}</td>`,n+=`<td>${r.priority}</td>`,n+=`<td>${r.plannedQuantity}</td>`,n+=`<td>${r.completedQuantity}</td>`,t&&(n+=`<td>${AC(r.simulatedStart)}</td>`,n+=`<td>${AC(r.simulatedFilled)}</td>`),n+=`<td>${(r.material??[]).map(e=>e.serial??``).join(`;`)}</td>`,n+=`<td>${D.ofObject(r.activeStationTime??{}).map(([e,t])=>`${e}: ${J(t)}`).toRArray().join(`;`)}</td>`,n+=`<td>${D.ofObject(r.elapsedStationTime??{}).map(([e,t])=>`${e}: ${J(t)}`).toRArray().join(`;`)}</td>`,n+=`</tr>
|
|
79
|
+
`;n+=`</tbody></table>
|
|
80
|
+
`,Je(n)}function IC(e){return(0,Y.jsxs)(w,{align:e.align,sortDirection:e.sortBy===e.col&&e.order,children:[(0,Y.jsx)(S,{title:`Sort`,enterDelay:300,children:(0,Y.jsx)(fn,{active:e.sortBy===e.col,direction:e.order,onClick:()=>{e.col===e.sortBy?e.setOrder(e.order===`asc`?`desc`:`asc`):(e.setSortBy(e.col),e.setOrder(`asc`))},children:e.children})}),e.extraIcon]})}var LC=F(`table`),RC=(0,K.memo)(function({showSim:e}){let[t,n]=A(LC);return(0,Y.jsxs)(E,{direction:`row`,spacing:2,sx:{justifyContent:`flex-end`,alignItems:`center`},children:[e?(0,Y.jsxs)(E,{direction:`row`,spacing:2,sx:{alignItems:`center`,flexGrow:1},children:[(0,Y.jsx)(tn,{fontSize:`small`}),(0,Y.jsx)(b,{variant:`caption`,children:`Projected dates are estimates`})]}):void 0,(0,Y.jsx)(R,{size:`small`,children:(0,Y.jsxs)(O,{variant:`outlined`,value:t,onChange:e=>n(e.target.value),children:[(0,Y.jsx)(L,{value:`table`,children:`Table`}),(0,Y.jsx)(L,{value:`gantt`,children:`Gantt`})]})})]})}),zC=st`
|
|
81
|
+
0% {
|
|
82
|
+
transform: rotate(0deg);
|
|
83
|
+
}
|
|
84
|
+
100% {
|
|
85
|
+
transform: rotate(360deg);
|
|
86
|
+
}
|
|
87
|
+
`,BC=_r(oe)(()=>({animation:`${zC} 1.5s linear infinite`}));function VC(){let[e,t]=(0,K.useState)(!1),[r,i]=(0,K.useTransition)(),[a,o]=A(wC),[s,c]=(0,K.useState)(null),[l,u]=A(TC);function d(e){e!==null&&e!==``&&(i(()=>{o(e)}),t(!1),c(null),u(t=>{let n=t.filter(t=>t!==e);return n.unshift(e),n.slice(0,5)}))}return(0,Y.jsxs)(Y.Fragment,{children:[r?(0,Y.jsx)(S,{title:`Searching.... Click to cancel`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>o(null),children:(0,Y.jsx)(BC,{fontSize:`inherit`})})}):a?(0,Y.jsx)(S,{title:`Clear Search`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>o(null),children:(0,Y.jsx)(gn,{fontSize:`inherit`})})}):(0,Y.jsx)(S,{title:`Search`,children:(0,Y.jsx)(C,{size:`small`,onClick:e=>{t(!0),e.currentTarget.blur()},children:(0,Y.jsx)(at,{fontSize:`inherit`})})}),(0,Y.jsxs)(I,{open:e,onClose:()=>t(!1),children:[(0,Y.jsx)($n,{children:`Search Workorder`}),(0,Y.jsxs)(M,{children:[(0,Y.jsx)(_,{variant:`outlined`,fullWidth:!0,autoFocus:!0,sx:{mt:`0.5em`,minWidth:`15em`},label:`Workorder ID`,value:s??``,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(d(s),e.preventDefault())}}),l.length>0?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(Wt,{dense:!0,sx:{mt:`1em`},subheader:(0,Y.jsx)(h,{children:`Previous Searches`}),children:l.map(e=>(0,Y.jsx)(xt,{onClick:()=>d(e),children:(0,Y.jsx)(n,{children:(0,Y.jsx)(_t,{primary:e})})},e))})}):void 0]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(z,{color:`primary`,onClick:()=>d(s),children:`Search`}),(0,Y.jsx)(z,{color:`secondary`,onClick:()=>t(!1),children:`Cancel`})]})]})]})}var HC=(0,K.memo)(function(e){let t={sortBy:e.sortBy,setSortBy:e.setSortBy,order:e.order,setOrder:e.setOrder};return(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(IC,{align:`left`,col:0,...t,extraIcon:e.disableSearch?void 0:(0,Y.jsx)(VC,{}),children:`Workorder`}),(0,Y.jsx)(IC,{align:`left`,col:1,...t,children:`Part`}),(0,Y.jsx)(IC,{align:`left`,col:3,...t,children:`Due Date`}),(0,Y.jsx)(IC,{align:`right`,col:4,...t,children:`Priority`}),(0,Y.jsx)(IC,{align:`right`,col:2,...t,children:`Planned Quantity`}),(0,Y.jsx)(IC,{align:`right`,col:6,...t,children:`Started Quantity`}),(0,Y.jsx)(IC,{align:`right`,col:7,...t,children:`Abnormal Quantity`}),(0,Y.jsx)(IC,{align:`right`,col:5,...t,children:`Completed Quantity`}),e.showSim?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(IC,{align:`right`,col:8,...t,children:`Projected Start`}),(0,Y.jsx)(IC,{align:`right`,col:9,...t,children:`Projected Filled`})]}):void 0,(0,Y.jsx)(w,{children:(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,onClick:()=>FC(e.workorders,e.showSim),children:(0,Y.jsx)(ct,{})})})})]})})}),UC=F(null);function WC(){let[e,t]=A(UC),[n,r]=(0,K.useState)(null),i=j(xa);function a(){t(null),r(null)}function o(){e&&n&&n!==``&&i({workorder:e.workorderId,comment:n}),a()}return(0,Y.jsx)(I,{open:e!==null,onClose:a,children:e===null?void 0:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($n,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)($,{part:e.part,size:40})}),(0,Y.jsxs)(`div`,{style:{marginLeft:`1em`,flexGrow:1},children:[`Add Comment For `,e.workorderId]})]})}),(0,Y.jsx)(M,{children:(0,Y.jsx)(_,{variant:`outlined`,sx:{mt:`1em`},fullWidth:!0,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n!==null&&n!==``&&(o(),e.preventDefault())}})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(z,{color:`primary`,onClick:o,children:`Save Comment`}),(0,Y.jsx)(z,{color:`primary`,onClick:a,children:`Cancel`})]})]})})}function GC(){let[e,t]=A(wC);return(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{colSpan:10,children:(0,Y.jsxs)(E,{direction:`column`,sx:{mt:`3em`,flex:`flex`,alignItems:`center`,width:`100%`},children:[(0,Y.jsxs)(E,{direction:`row`,spacing:`3`,children:[(0,Y.jsx)(pn,{}),e&&e!==``?(0,Y.jsxs)(b,{variant:`h6`,children:[`Searching for workorder `,e]}):(0,Y.jsx)(b,{variant:`h6`,children:`Searching`})]}),(0,Y.jsx)(z,{onClick:()=>t(null),children:`Cancel`})]})})})}function KC({showSim:e,disableSearch:t}){let[n,i]=(0,K.useState)(0),[a,o]=(0,K.useState)(`asc`),s=r(q);return(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(HC,{workorders:s?.workorders??[],sortBy:n,setSortBy:i,showSim:e,order:a,setOrder:o,disableSearch:t}),(0,Y.jsx)(ae,{children:(0,Y.jsx)(K.Suspense,{fallback:(0,Y.jsx)(GC,{}),children:(0,Y.jsx)(PC,{sortBy:n,order:a,showSim:e})})})]})}function qC(){let e=j(Sg),t=r(Xs),[n,i]=vc(),a=j(X);if(t===null||t.materialID<0)return null;function o(e){t!==null&&(n({mat:t,operator:`Manager`,failed:e}),a(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{color:`primary`,disabled:i,onClick:()=>o(!0),children:`Fail CloseOut`}),(0,Y.jsx)(z,{color:`primary`,disabled:i,onClick:()=>o(!1),children:`Pass CloseOut`}),(0,Y.jsx)(z,{color:`primary`,onClick:()=>e(!0),children:`Change Workorder`})]})}var JC=(0,K.memo)(function(){return(0,Y.jsx)(xf,{buttons:(0,Y.jsx)(qC,{})})}),YC=(0,K.memo)(function({disableSearch:e}){Q(`Workorders`);let t=r(q),n=r(LC),i=(0,K.useMemo)(()=>t.workorders?.some(e=>!!e.simulatedStart||!!e.simulatedFilled)??!1,[t.workorders]);return(0,Y.jsxs)(B,{component:`main`,sx:{padding:`24px`},children:[i?(0,Y.jsx)(RC,{showSim:i}):void 0,n===`table`?(0,Y.jsx)(KC,{showSim:i,disableSearch:e}):(0,Y.jsx)(CC,{}),(0,Y.jsx)(WC,{}),(0,Y.jsx)(JC,{}),(0,Y.jsx)(Dg,{})]})}),XC=we[50],ZC=we[600],QC=ft[100],$C=`3em`,ew=`calc(${$C} * 7)`,tw=F(e=>{let t=e(ku);return t===null?null:D.of(t.usage).toLookupOrderedMap(e=>e.machineGroup,e=>new Date(e.day.getUTCFullYear(),e.day.getUTCMonth(),e.day.getUTCDate()))}),nw=F(e=>{let t=e(ku);return t===null?Se.empty():Se.build(t.usage,e=>e.machineGroup)}),rw=F(e=>{let t=e(ku);return t===null?Se.empty():Se.build(t.usage,e=>new Date(e.day.getUTCFullYear(),e.day.getUTCMonth(),1))}),iw=F(e=>{let t=e(ku);return t===null?0:D.of(t.usage).map(e=>Math.ceil(e.usage)).maxBy(e=>e)??1}),aw=F(e=>{let t=e(ku);return t===null?[null,null]:[D.of(t.usage).map(e=>new Date(e.day.getUTCFullYear(),e.day.getUTCMonth(),e.day.getUTCDate())).minBy(e=>e)??null,D.of(t.usage).map(e=>new Date(e.day.getUTCFullYear(),e.day.getUTCMonth(),e.day.getUTCDate())).maxBy(e=>e)??null]});function ow({date:e,dayColor:t,tooltip:n}){let r=new Date(e.getFullYear(),e.getMonth(),1).getDay(),i=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return(0,Y.jsxs)(B,{sx:{width:ew},children:[(0,Y.jsx)(b,{variant:`h6`,sx:{textAlign:`center`},children:e.toLocaleString(`default`,{month:`long`,year:`numeric`})}),(0,Y.jsxs)(B,{sx:{display:`flex`,flexWrap:`wrap`},children:[D.ofRange(0,r).map((e,t)=>(0,Y.jsx)(B,{sx:{height:$C,width:$C}},t)),D.ofRange(1,i+1).map((r,i)=>(0,Y.jsx)(`div`,{style:{width:$C,height:$C,cursor:`default`,backgroundColor:t(new Date(e.getFullYear(),e.getMonth(),r))},children:(0,Y.jsx)(S,{title:n(new Date(e.getFullYear(),e.getMonth(),r)),children:(0,Y.jsx)(B,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100%`},children:r})})},i))]})]})}function sw(){return(0,Y.jsxs)(E,{direction:`row`,spacing:2,sx:{alignItems:`center`},children:[(0,Y.jsx)(tn,{fontSize:`small`}),(0,Y.jsx)(b,{variant:`caption`,children:`Projected dates are estimates`})]})}function cw({group:e,month:t}){let n=r(tw),[i,a]=r(aw),o=r(iw),s=(0,K.useMemo)(()=>{let t=ie().domain([0,o]).range([XC,ZC]);return r=>{if(a&&r>a||i&&r<i)return`white`;let o=n?.get(e)?.get(r);return o?t(o.usage):QC}},[n,o,i,a,e]);function c(t){let r=n?.get(e)?.get(t);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{children:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}),a&&t>a?(0,Y.jsx)(`div`,{children:`Not Simulated`}):i&&t<i?(0,Y.jsx)(`div`,{}):r?(0,Y.jsxs)(`div`,{children:[`Usage: `,r.usage.toFixed(2)]}):(0,Y.jsx)(`div`,{children:`Downtime`})]})}return(0,Y.jsx)(ow,{date:t,dayColor:s,tooltip:c})}function lw(){Q(`Projected Machine Usage`);let e=r(nw),t=r(rw);return(0,Y.jsx)(B,{component:`main`,sx:{padding:`24px`},children:(0,Y.jsxs)(E,{direction:`column`,spacing:5,children:[(0,Y.jsx)(sw,{}),e.toAscLazySeq().map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(b,{variant:`h4`,children:e}),(0,Y.jsx)(B,{sx:{display:`flex`,flexWrap:`wrap`,columnGap:`50px`},children:t.toAscLazySeq().map(t=>(0,Y.jsx)(cw,{group:e,month:t},t.getTime()))})]},e))]})})}function uw(){let e=j(Sg),t=r(Xs),[n,i]=vc(),a=j(X);if(t===null||t.materialID<0)return null;function o(e){t!==null&&(n({mat:t,operator:`Manager`,failed:e}),a(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{color:`primary`,disabled:i,onClick:()=>o(!0),children:`Fail CloseOut`}),(0,Y.jsx)(z,{color:`primary`,disabled:i,onClick:()=>o(!1),children:`Pass CloseOut`}),(0,Y.jsx)(z,{color:`primary`,onClick:()=>e(!0),children:`Change Workorder`})]})}var dw=(0,K.memo)(function(){return(0,Y.jsx)(xf,{buttons:(0,Y.jsx)(uw,{})})}),fw=new Intl.DateTimeFormat(void 0,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`});function pw({day:e,setDay:t}){let n=k();return(0,Y.jsxs)(E,{direction:`row`,spacing:2,sx:{alignItems:`center`},children:[(0,Y.jsx)(S,{title:`Previous Day`,children:(0,Y.jsx)(`div`,{children:(0,Y.jsx)(C,{disabled:e<=P(n,-28),onClick:()=>t(e=>P(e,-1)),children:(0,Y.jsx)(dr,{})})})}),(0,Y.jsx)(b,{sx:{minWidth:`14em`,textAlign:`center`},children:fw.format(e)}),(0,Y.jsx)(S,{title:`Next Day`,children:(0,Y.jsx)(`div`,{children:(0,Y.jsx)(C,{disabled:e>=n,onClick:()=>t(e=>P(e,1)),children:(0,Y.jsx)(tt,{})})})})]})}function mw(e,t,n){let r;switch(t){case 0:r=e=>e.last_unload_time??null;break;case 2:r=e=>e.partName;break;case 1:r=e=>e.serial??null;break;case 3:r=e=>e.workorderId??null;break;case 4:r=e=>e.closeout_failed??null;break;case 5:r=e=>e.closeout_completed??null}return D.of(e).toSortedArray(n===`asc`?{asc:r}:{desc:r},{asc:e=>e.last_unload_time??null})}function hw({sortBy:e,setSortBy:t,sortOrder:n,setSortOrder:r}){function i(i){i===e?r(n===`asc`?`desc`:`asc`):(t(i),r(`asc`))}return(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{sortDirection:e===0&&n,children:(0,Y.jsx)(fn,{active:e===0,direction:n,onClick:()=>i(0),children:`Completed Time`})}),(0,Y.jsx)(w,{sortDirection:e===1&&n,children:(0,Y.jsx)(fn,{active:e===1,direction:n,onClick:()=>i(1),children:`Serial`})}),(0,Y.jsx)(w,{sortDirection:e===2&&n,children:(0,Y.jsx)(fn,{active:e===2,direction:n,onClick:()=>i(2),children:`Part`})}),(0,Y.jsx)(w,{sortDirection:e===3&&n,children:(0,Y.jsx)(fn,{active:e===3,direction:n,onClick:()=>i(3),children:`Workorder`})}),(0,Y.jsx)(w,{sortDirection:e===4&&n,children:(0,Y.jsx)(fn,{active:e===4,direction:n,onClick:()=>i(4),children:`Closeout`})}),(0,Y.jsx)(w,{sortDirection:e===5&&n,children:(0,Y.jsx)(fn,{active:e===5,direction:n,onClick:()=>i(5),children:`Closeout Time`})}),(0,Y.jsx)(w,{})]})}var gw=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`numeric`,second:`numeric`}),_w=new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}),vw=(0,K.memo)(function({mat:e}){let t=j(X);return(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:e.last_unload_time?gw.format(e.last_unload_time):``}),(0,Y.jsx)(w,{children:e.serial}),(0,Y.jsx)(w,{children:(0,Y.jsxs)(E,{direction:`row`,spacing:`2`,sx:{alignItems:`center`},children:[(0,Y.jsx)($,{part:e.partName,size:25}),(0,Y.jsx)(b,{variant:`body2`,children:e.partName})]})}),(0,Y.jsx)(w,{children:e.workorderId}),(0,Y.jsx)(w,{children:e.closeout_completed===null||e.closeout_completed===void 0?``:e.closeout_failed?(0,Y.jsx)(i,{fontSize:`inherit`}):(0,Y.jsx)(qt,{fontSize:`inherit`})}),(0,Y.jsx)(w,{children:e.closeout_completed?_w.format(e.closeout_completed):``}),(0,Y.jsx)(w,{padding:`checkbox`,children:e.serial!==null&&e.serial!==``?(0,Y.jsx)(C,{onClick:()=>{e.serial&&t({type:`ManuallyEnteredSerial`,serial:e.serial})},size:`large`,children:(0,Y.jsx)(Le,{fontSize:`inherit`})}):void 0})]})});function yw({day:e}){let t=r(Bl),n=(0,K.useMemo)(()=>{let n=P(e,1),r=[];for(let i of t.matsById.values())i.completed_last_proc_machining===!0&&i.last_unload_time&&i.last_unload_time>=e&&i.last_unload_time<n&&r.push(i);return r},[t,e]),[i,a]=(0,K.useState)(0),[o,s]=(0,K.useState)(`asc`),c=(0,K.useMemo)(()=>mw(n,i,o),[n,i,o]);return(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(je,{children:(0,Y.jsx)(hw,{sortBy:i,setSortBy:a,sortOrder:o,setSortOrder:s})}),(0,Y.jsx)(ae,{children:c.map(e=>(0,Y.jsx)(vw,{mat:e},e.materialID))})]})}function bw(){Q(`Close Out`);let[e,t]=(0,K.useState)(k());return(0,Y.jsxs)(B,{sx:{padding:`24px`},children:[(0,Y.jsx)(B,{component:`nav`,sx:{display:`flex`,justifyContent:`center`},children:(0,Y.jsx)(pw,{day:e,setDay:t})}),(0,Y.jsx)(`main`,{children:(0,Y.jsx)(yw,{day:e})}),(0,Y.jsx)(Dg,{}),(0,Y.jsx)(dw,{})]})}var xw=F(!1),Sw=F(!1),Cw=F(!1),ww=[{id:0,numeric:!1,label:`ID`,getDisplay:e=>e.bookingId,Cell:({row:e})=>e.canceled?(0,Y.jsx)(b,{sx:{textDecoration:`line-through`,fontSize:`inherit`},children:e.bookingId}):e.bookingId},{id:1,numeric:!1,label:`Part`,getDisplay:e=>e.partName,Cell:({row:e})=>(0,Y.jsxs)(E,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,Y.jsx)($,{part:e.partName,size:25}),e.partName]})},{id:2,numeric:!0,label:`Quantity`,getDisplay:e=>e.quantity.toString(),getForSort:e=>e.quantity},{id:3,numeric:!1,label:`Request Time`,getDisplay:e=>e.timeUTC.toLocaleString(),getForSort:e=>e.timeUTC.getTime()},{id:4,numeric:!1,label:`Priority`,getDisplay:e=>e.priority?e.priority.toString():``,getForSort:e=>e.priority??0},{id:5,numeric:!1,label:`Workorder`,getDisplay:e=>e.workorder??``},{id:6,numeric:!1,label:`Canceled`,getDisplay:e=>e.canceled?.toLocaleString()??``,getForSort:e=>e.canceled?.getTime()??0,openFilterDialog:xw},{id:7,numeric:!1,label:`Scheduled Job`,getDisplay:e=>e.job??``,openFilterDialog:xw},{id:8,numeric:!1,label:`Scheduled Time`,getDisplay:e=>e.schTime?e.schTime.toLocaleString():``,getForSort:e=>e.schTime?e.schTime.getTime():0}],Tw=(0,K.memo)(function({setRebookingToShow:e}){let t=zh(3,ww,`desc`),n=Rh(),i=r(Iu),a=r(Ru),o=r(Bu),s=r(Sw),c=r(Cw),l=(0,K.useMemo)(()=>i.adjust(o,(e,t)=>e?{...e,job:t?.jobUnique,schTime:t?.scheduledTime}:void 0).adjust(a,(e,t)=>e?{...e,canceled:t}:void 0).valuesToAscLazySeq().transform(e=>s?e.filter(e=>!e.job):e).transform(e=>c?e.filter(e=>!e.canceled):e).toSortedArray(t.sortOn),[t.sortOn,i,a,o,s,c]);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)(Ah,{columns:ww,sort:t,showDetailsCol:!0,copyToClipboardRows:l}),(0,Y.jsx)(Ih,{columns:ww,pageData:l,rowsPerPage:n.rowsPerPage,onClickDetails:(t,n)=>e(n)})]}),(0,Y.jsx)(Fh,{tpage:n,count:l.length})]})}),Ew=new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}),Dw=(0,K.memo)(function({rebooking:e,close:t}){let[n,r]=Ku();function i(){e&&n(e.bookingId).then(()=>t(void 0)).catch(console.log)}return(0,Y.jsxs)(I,{open:e!==void 0,onClose:()=>t(void 0),children:[(0,Y.jsx)($n,{children:e?.canceled?(0,Y.jsx)(b,{sx:{textDecoration:`line-through`},children:e?.bookingId}):e?.bookingId}),(0,Y.jsx)(M,{children:(0,Y.jsxs)(E,{direction:`column`,spacing:1,children:[e?.canceled&&(0,Y.jsxs)(b,{variant:`h5`,children:[`Canceled at `,Ew.format(e.canceled)]}),(0,Y.jsxs)(E,{direction:`row`,spacing:1,children:[(0,Y.jsx)(`span`,{children:`Part:`}),e?.partName&&(0,Y.jsx)($,{part:e?.partName,size:25}),(0,Y.jsx)(`span`,{children:e?.partName})]}),(0,Y.jsxs)(b,{children:[`Quantity: `,e?.quantity]}),(0,Y.jsxs)(b,{children:[`Request Time: `,Ew.format(e?.timeUTC)]}),(0,Y.jsxs)(b,{children:[`Priority: `,e?.priority]}),e?.workorder&&(0,Y.jsxs)(b,{children:[`Workorder: `,e?.workorder]}),(0,Y.jsxs)(b,{children:[`Note: `,e?.notes]}),e?.job&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_n,{}),(0,Y.jsxs)(b,{children:[`Scheduled Job: `,e?.job]}),(0,Y.jsxs)(b,{children:[`Scheduled Time: `,e?.schTime?.toLocaleString()]})]})]})}),(0,Y.jsxs)(N,{children:[!e?.canceled&&!e?.job&&(0,Y.jsxs)(z,{onClick:i,color:`secondary`,disabled:r,children:[r?(0,Y.jsx)(pn,{size:24}):void 0,`Cancel Rebooking Request`]}),(0,Y.jsx)(z,{onClick:()=>t(void 0),children:`Close`})]})]})}),Ow=F(e=>D.ofObject(e(q).jobs).map(([,e])=>e.partName).concat(e(ia).valuesToLazySeq().map(e=>e.partName)).distinctAndSortBy(e=>e).toRArray()),kw=(0,K.memo)(function(){let[e,t]=(0,K.useState)(!1),[n,i]=(0,K.useState)({part:``}),a=r(Ow),[o,s]=qu(),c=n.part!==``&&!!n.qty&&!isNaN(n.qty);function l(){t(!1),i({part:``})}function u(){c&&o(n).then(l).catch(console.log)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(I,{open:e,onClose:l,children:[(0,Y.jsx)($n,{children:`Create New`}),(0,Y.jsx)(M,{children:(0,Y.jsxs)(E,{direction:`column`,spacing:2,sx:{mt:`0.5em`,minWidth:`25em`},children:[(0,Y.jsx)(et,{freeSolo:!0,selectOnFocus:!0,clearOnBlur:!0,handleHomeEndKeys:!0,disableClearable:!0,options:a,value:n.part,onChange:(e,t)=>i(e=>({...e,part:t})),renderInput:e=>(0,Y.jsx)(_,{...e,label:`Part Name`,slotProps:{input:{...e.slotProps.input,startAdornment:(0,Y.jsxs)(Y.Fragment,{children:[n.part===``?void 0:(0,Y.jsx)(Vn,{position:`start`,children:(0,Y.jsx)($,{part:n.part,size:25})}),e.slotProps.input?.startAdornment]})}}}),renderOption:(e,t)=>(0,Y.jsx)(`li`,{...e,children:(0,Y.jsxs)(E,{direction:`row`,spacing:`1`,sx:{alignItems:`center`},children:[(0,Y.jsx)($,{part:t,size:25}),t]})}),filterOptions:(e,t)=>{let n=e.filter(e=>e.toLowerCase().includes(t.inputValue.toLowerCase()));return n.length===0&&t.inputValue!==``?[t.inputValue]:n}}),(0,Y.jsx)(_,{label:`Quantity`,type:`number`,value:n.qty&&!isNaN(n.qty)?n.qty:``,onChange:e=>i(t=>({...t,qty:parseInt(e.target.value)}))}),(0,Y.jsx)(_,{label:`Priority (optional)`,type:`number`,value:n.priority&&!isNaN(n.priority)?n.priority:``,onChange:e=>i(t=>({...t,priority:parseInt(e.target.value)}))}),(0,Y.jsx)(_,{label:`Workorder (optional)`,value:n.workorder??``,onChange:e=>i(t=>({...t,workorder:e.target.value}))}),(0,Y.jsx)(_,{label:`Notes (optional)`,multiline:!0,minRows:2,value:n.notes??``,onChange:e=>i(t=>({...t,notes:e.target.value}))})]})}),(0,Y.jsxs)(N,{children:[(0,Y.jsxs)(z,{color:`secondary`,onClick:u,disabled:!c||s,children:[s?(0,Y.jsx)(pn,{size:24}):void 0,`Create`]}),(0,Y.jsx)(z,{onClick:l,children:`Cancel`})]})]}),(0,Y.jsx)(S,{title:`Add Rebooking`,children:(0,Y.jsx)(Lt,{onClick:()=>t(!0),sx:{position:`fixed`,bottom:`24px`,right:`24px`},color:`primary`,children:(0,Y.jsx)(m,{})})})]})}),Aw=(0,K.memo)(function(){let[e,t]=A(xw),[n,r]=A(Sw),[i,a]=A(Cw);return(0,Y.jsxs)(I,{open:e,onClose:()=>t(!1),children:[(0,Y.jsx)($n,{children:`Filter`}),(0,Y.jsx)(M,{children:(0,Y.jsxs)(E,{direction:`column`,spacing:2,children:[(0,Y.jsx)(An,{control:(0,Y.jsx)(en,{checked:n,onChange:e=>r(e.target.checked)}),label:`Hide scheduled`}),(0,Y.jsx)(An,{control:(0,Y.jsx)(en,{checked:i,onChange:e=>a(e.target.checked)}),label:`Hide canceled`})]})}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{onClick:()=>t(!1),children:`Close`})})]})});function jw(){Q(r(G).supportsRebookings??`Rebookings`);let[e,t]=(0,K.useState)(void 0);return(0,Y.jsxs)(B,{component:`main`,sx:{padding:`24px`},children:[(0,Y.jsx)(Tw,{setRebookingToShow:t}),(0,Y.jsx)(Dw,{rebooking:e,close:t}),(0,Y.jsx)(kw,{}),(0,Y.jsx)(Aw,{})]})}var Mw=F(Math.floor(Date.now()/6e4));Mw.onMount=e=>{let t=setInterval(()=>{e(Math.floor(Date.now()/6e4))},6e4);return()=>clearInterval(t)};var Nw=l(`charts_last30WeekdayStartIdx`,0),Pw=l(`charts_last30WeekdayStartMinuteOffset`,360),Fw=de(e=>F(t=>{let n=t(Nw),r=t(Pw),i=new Date(t(Mw)*6e4),a=Gn(Rt(i),r),o=Gn(vn(i,{weekStartsOn:n}),r);switch(e){case`StartOfToday`:return a;case`StartOfYesterday`:return P(a,-1);case`StartOfWeek`:return o;case`StartOfLastWeek`:return P(o,-7);case`Last30`:return P(i,-30)}})),Iw=de(e=>F(t=>{if(e===`Now`)return null;let n=t(Nw),r=t(Pw),i=new Date(t(Mw)*6e4);switch(e){case`EndOfYesterday`:return Gn(Rt(i),r);case`EndOfLastWeek`:return Gn(vn(i,{weekStartsOn:n}),r)}}));function Lw(e){let t=l(`charts_${e}_start`,`StartOfWeek`),n=l(`charts_${e}_end`,`Now`);return F(e=>{let r=e(t),i=e(n);return{startType:r,endType:i,startDate:r instanceof Date?r:e(Fw(r)),endDate:i instanceof Date?i:e(Iw(i))}},(e,r,i)=>{`start`in i&&r(t,i.start),`end`in i&&r(n,i.end)})}function Rw(e){return e.closeout_completed===void 0?!!(D.ofObject(e.completedInspections??{}).some(([,e])=>!e.success)||e.currently_quarantined):e.closeout_failed!==!1}var zw=Lw(`part-summary`),Bw=F(e=>{let t=e(Bl),n=e(ao),r=e(zw),i=n.valuesToLazySeq().filter(e=>(r.startDate===null||e.endTime>=r.startDate)&&(r.endDate===null||e.endTime<=r.endDate)).toLookupOrderedMap(e=>e.part,e=>e.stationGroup,e=>({isLoadUnload:Wa(e),elapsed:e.elapsedMinsPerMaterial*e.material.length,active:e.activeMinutes,medianElapsed:e.medianCycleMinutes}),(e,t)=>({isLoadUnload:e.isLoadUnload||t.isLoadUnload,elapsed:e.elapsed+t.elapsed,active:e.active+t.active,medianElapsed:e.medianElapsed+t.medianElapsed}));return t.matsById.valuesToLazySeq().filter(e=>!!(e.numProcesses&&e.unloaded_processes?.[e.numProcesses]&&(r.startDate===null||e.unloaded_processes[e.numProcesses]>=r.startDate)&&(r.endDate===null||e.unloaded_processes[e.numProcesses]<=r.endDate))).toOrderedLookup(e=>e.partName).mapValues((e,t)=>({part:t,completedQty:e.length,abnormalQty:D.of(e).sumBy(e=>+!!Rw(e)),mats:e,stationMins:se.empty(),workorders:D.of(e).toOrderedSet(e=>e.workorderId??``).delete(``)})).adjust(i,(e,t,n)=>e?{...e,stationMins:t}:{part:n,completedQty:0,abnormalQty:0,mats:[],stationMins:t,workorders:Se.empty()}).valuesToAscLazySeq().toRArray()});function Vw(e){return e===`CustomDate`||e===`StartOfToday`||e===`StartOfYesterday`||e===`StartOfWeek`||e===`StartOfLastWeek`||e===`Last30`}function Hw(e){return e===`CustomDate`||e===`Now`||e===`EndOfYesterday`||e===`EndOfLastWeek`}function Uw(e){switch(e){case`0`:return 0;case`1`:return 1;case`2`:return 2;case`3`:return 3;case`4`:return 4;case`5`:return 5;case`6`:return 6;default:return null}}function Ww({label:e,date:t}){return(0,Y.jsxs)(B,{children:[(0,Y.jsx)(b,{children:e}),t?(0,Y.jsxs)(b,{variant:`subtitle2`,children:[`(`,t.toLocaleString(),`)`]}):void 0]})}function Gw({date:e,setDate:t,enabled:n}){let i=r(Fw(`Last30`));return(0,Y.jsx)(_,{type:`datetime-local`,value:e?new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16):``,onChange:e=>t(new Date(e.target.value)),disabled:!n,label:`Custom Date`,slotProps:{inputLabel:{shrink:!0},htmlInput:{min:new Date(i.getTime()-i.getTimezoneOffset()*6e4).toISOString().slice(0,16)}}})}function Kw({chartAtom:e}){let[t,n]=A(e),i=r(Pw),[a,o]=(0,K.useState)(t.startType instanceof Date?t.startType:Gn(k(),i));function s(e){n(e===`CustomDate`?{start:a??new Date}:{start:e})}function c(e){o(e),n({start:e})}let l=r(Fw(`StartOfToday`)),u=r(Fw(`StartOfYesterday`)),d=r(Fw(`StartOfWeek`)),f=r(Fw(`StartOfLastWeek`)),p=r(Fw(`Last30`));return(0,Y.jsxs)(B,{children:[(0,Y.jsx)(b,{variant:`h6`,children:`Range Start`}),(0,Y.jsx)(ce,{value:t.startType instanceof Date?`CustomDate`:t.startType,onChange:e=>{Vw(e.target.value)&&s(e.target.value)},children:(0,Y.jsxs)(E,{direction:`column`,spacing:2,children:[(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`StartOfToday`}),(0,Y.jsx)(Ww,{label:`Start of Today`,date:l})]}),(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`StartOfYesterday`}),(0,Y.jsx)(Ww,{label:`Start of Yesterday`,date:u})]}),(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`StartOfWeek`}),(0,Y.jsx)(Ww,{label:`Start of This Week`,date:d})]}),(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`StartOfLastWeek`}),(0,Y.jsx)(Ww,{label:`Start of Last Week`,date:f})]}),(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`Last30`}),(0,Y.jsx)(Ww,{label:`Last 30 Days`,date:p})]}),(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`CustomDate`}),(0,Y.jsx)(Gw,{enabled:t.startType instanceof Date,date:a,setDate:c})]})]})})]})}function qw({chartAtom:e}){let[t,n]=A(e),i=r(Pw),[a,o]=(0,K.useState)(t.endType instanceof Date?t.endType:Gn(k(),i));function s(e){n(e===`CustomDate`?{end:a??new Date}:{end:e})}function c(e){o(e),n({end:e})}let l=r(Iw(`EndOfYesterday`)),u=r(Iw(`EndOfLastWeek`));return(0,Y.jsxs)(B,{children:[(0,Y.jsx)(b,{variant:`h6`,children:`Range End`}),(0,Y.jsx)(ce,{value:t.endType instanceof Date?`CustomDate`:t.endType,onChange:e=>{Hw(e.target.value)&&s(e.target.value)},children:(0,Y.jsxs)(E,{direction:`column`,spacing:2,children:[(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`Now`}),(0,Y.jsx)(b,{children:`Now`})]}),(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`EndOfYesterday`}),(0,Y.jsx)(Ww,{label:`End of Yesterday`,date:l})]}),(0,Y.jsx)(B,{sx:{height:`3em`}}),(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`EndOfLastWeek`}),(0,Y.jsx)(Ww,{label:`End of Last Week`,date:u})]}),(0,Y.jsx)(B,{sx:{height:`3em`}}),(0,Y.jsxs)(E,{direction:`row`,sx:{alignItems:`center`,minHeight:`3em`},children:[(0,Y.jsx)(Ce,{value:`CustomDate`}),(0,Y.jsx)(Gw,{enabled:t.endType instanceof Date,date:a,setDate:c})]})]})})]})}function Jw(e){let t=Math.floor(e/60),n=e%60;return`${t.toString().padStart(2,`0`)}:${n.toString().padStart(2,`0`)}`}function Yw({chartAtom:e,open:t,setOpen:n}){let[r,i]=A(Nw),[a,o]=A(Pw);return(0,Y.jsxs)(I,{open:t,onClose:()=>n(!1),maxWidth:`md`,children:[(0,Y.jsx)(M,{children:(0,Y.jsxs)(E,{direction:`column`,spacing:2,divider:(0,Y.jsx)(_n,{orientation:`horizontal`,flexItem:!0}),children:[(0,Y.jsxs)(E,{direction:`row`,spacing:2,divider:(0,Y.jsx)(_n,{orientation:`vertical`,flexItem:!0}),children:[(0,Y.jsx)(Kw,{chartAtom:e}),(0,Y.jsx)(qw,{chartAtom:e})]}),(0,Y.jsxs)(E,{direction:`row`,sx:{justifyContent:`space-around`},children:[(0,Y.jsxs)(_,{select:!0,label:`First Day Of Week`,sx:{minWidth:`10em`},value:r,onChange:e=>{let t=Uw(e.target.value);t!==null&&i(t)},children:[(0,Y.jsx)(L,{value:0,children:`Sunday`}),(0,Y.jsx)(L,{value:1,children:`Monday`}),(0,Y.jsx)(L,{value:2,children:`Tuesday`}),(0,Y.jsx)(L,{value:3,children:`Wednesday`}),(0,Y.jsx)(L,{value:4,children:`Thursday`}),(0,Y.jsx)(L,{value:5,children:`Friday`}),(0,Y.jsx)(L,{value:6,children:`Saturday`})]}),(0,Y.jsx)(_,{type:`time`,label:`Day Start Time`,sx:{minWidth:`10em`},value:Jw(a),onChange:e=>{let t=e.target.value;if(t===``)o(0);else{let[e,n]=t.split(`:`).map(Number);o(e*60+n)}}})]})]})}),(0,Y.jsx)(N,{children:(0,Y.jsx)(z,{onClick:()=>n(!1),children:`Close`})})]})}function Xw(e,t){if(e instanceof Date)return e.toLocaleString();switch(e){case`StartOfToday`:return`Start of Today${t?` (${t.toLocaleString()})`:``}`;case`StartOfYesterday`:return`Start of Yesterday${t?` (${t.toLocaleString()})`:``}`;case`StartOfWeek`:return`Start of This Week${t?` (${t.toLocaleString()})`:``}`;case`StartOfLastWeek`:return`Start of Last Week${t?` (${t.toLocaleString()})`:``}`;case`Last30`:return`Last 30 Days${t?` (${t.toLocaleString()})`:``}`}}function Zw(e,t){if(e instanceof Date)return e.toLocaleString();switch(e){case`Now`:return`Now`;case`EndOfYesterday`:return`End of Yesterday${t?` (${t.toLocaleString()})`:``}`;case`EndOfLastWeek`:return`End of Last Week${t?` (${t.toLocaleString()})`:``}`}}var Qw=(0,K.memo)(function({chartAtom:e}){let t=r(e),[n,i]=(0,K.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(E,{direction:`row`,spacing:2,sx:{alignItems:`center`},children:[(0,Y.jsxs)(b,{variant:`body2`,color:`textSecondary`,children:[`Range: `,Xw(t.startType,t.startDate),` -`,` `,Zw(t.endType,t.endDate)]}),(0,Y.jsx)(S,{title:`Edit Range`,children:(0,Y.jsx)(C,{onClick:()=>i(!0),children:(0,Y.jsx)(Jn,{})})})]}),(0,Y.jsx)(Yw,{open:n,setOpen:i,chartAtom:e})]})}),$w=new Intl.NumberFormat(void 0,{maximumFractionDigits:1});function eT(e,t,n){let r;switch(t){case`PartName`:r=e=>e.part;break;case`CompletedQty`:r=e=>e.completedQty;break;case`AbnormalQty`:r=e=>e.abnormalQty;break;case`Workorders`:r=e=>e.workorders.lookupMin()?.[0]??null;break;case`Elapsed`:r=e=>e.stationMins.toAscLazySeq().filter(([,e])=>!e.isLoadUnload).sumBy(([,e])=>e.elapsed);break;case`Active`:r=e=>e.stationMins.toAscLazySeq().filter(([,e])=>!e.isLoadUnload).sumBy(([,e])=>e.active);break;case`Median`:r=e=>e.stationMins.toAscLazySeq().filter(([,e])=>!e.isLoadUnload).sumBy(([,e])=>e.medianElapsed)}let i=[...e];return i.sort(gt(n===`asc`?{asc:r}:{desc:r})),i}var tT=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`});function nT(e,t,n){let r;switch(t){case`Serial`:r=e=>e.serial??null;break;case`CompletedDate`:r=e=>e.last_unload_time??null;break;case`Workorder`:r=e=>e.workorderId??null;break;case`Quarantined`:r=e=>e.currently_quarantined??null;break;case`InspectFailed`:r=e=>D.ofObject(e.completedInspections??{}).some(([,e])=>!e.success)?-1:0;break;case`CloseOut`:r=e=>e.closeout_failed===void 0?1:e.closeout_failed?-1:0}let i=[...e];return i.sort(gt(n===`asc`?{asc:r}:{desc:r})),i}function rT(e){return(0,Y.jsxs)(w,{align:e.align,sortDirection:e.sortBy===e.col&&e.order,sx:e.noWhitespaceWrap?{whiteSpace:`nowrap`}:void 0,children:[(0,Y.jsx)(S,{title:`Sort`,enterDelay:300,children:(0,Y.jsx)(fn,{active:e.sortBy===e.col,direction:e.order,onClick:()=>{e.col===e.sortBy?e.setOrder(e.order===`asc`?`desc`:`asc`):(e.setSortBy(e.col),e.setOrder(`asc`))},children:e.children})}),e.extraIcon]})}var iT=(0,K.memo)(function({workorderId:e}){return!e||e===``?(0,Y.jsx)(`span`,{}):(0,Y.jsx)(Pc,{to:{route:Z.Operations_CurrentWorkorders,workorder:e},children:e})});function aT({material:e}){let t=j(X),[n,r]=(0,K.useState)(`Serial`),[a,s]=(0,K.useState)(`asc`),c=(0,K.useMemo)(()=>nT(e,n,a),[e,n,a]),l={sortBy:n,setSortBy:r,order:a,setOrder:s},[u,d]=(0,K.useState)(10),[f,p]=(0,K.useState)(0),m=c.slice(f*u,(f+1)*u);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(he,{size:`small`,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(rT,{col:`Serial`,...l,children:`Serial`}),(0,Y.jsx)(rT,{col:`CompletedDate`,...l,children:`Completed`}),(0,Y.jsx)(rT,{col:`Workorder`,...l,children:`Workorder`}),(0,Y.jsx)(rT,{col:`Quarantined`,...l,children:`Quarantine?`}),(0,Y.jsx)(rT,{col:`InspectFailed`,noWhitespaceWrap:!0,...l,children:`Inspect Failed?`}),(0,Y.jsx)(rT,{col:`CloseOut`,noWhitespaceWrap:!0,...l,children:`Close Out`}),(0,Y.jsx)(w,{padding:`checkbox`})]})}),(0,Y.jsxs)(ae,{children:[m.map(e=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:e.serial??``}),(0,Y.jsx)(w,{children:e.last_unload_time?tT.format(e.last_unload_time):``}),(0,Y.jsx)(w,{children:(0,Y.jsx)(iT,{workorderId:e.workorderId})}),(0,Y.jsx)(w,{sx:{textAlign:`center`},padding:`checkbox`,children:e.currently_quarantined?(0,Y.jsx)(re,{fontSize:`inherit`}):``}),(0,Y.jsx)(w,{sx:{textAlign:`center`},padding:`checkbox`,children:D.ofObject(e.completedInspections??{}).some(([,e])=>!e.success)?(0,Y.jsx)(i,{fontSize:`inherit`}):``}),(0,Y.jsx)(w,{sx:{textAlign:`center`},padding:`checkbox`,children:e.closeout_completed===void 0?``:e.closeout_failed===!1?(0,Y.jsx)(qt,{fontSize:`inherit`}):(0,Y.jsx)(i,{fontSize:`inherit`})}),(0,Y.jsx)(w,{padding:`checkbox`,children:(0,Y.jsx)(C,{onClick:()=>t({type:`MatSummary`,summary:e}),size:`large`,children:(0,Y.jsx)(Le,{fontSize:`inherit`})})})]},e.materialID)),D.ofRange(0,u-m.length).map(e=>(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{colSpan:7,children:`\xA0`})},e))]})]}),(0,Y.jsxs)(cn,{variant:`dense`,sx:{mb:`0.5em`},children:[(0,Y.jsx)(b,{color:`textSecondary`,variant:`caption`,children:`Rows per page:`}),(0,Y.jsx)(O,{style:{marginLeft:8,marginRight:`1em`},value:u,SelectDisplayProps:{style:{color:`rgba(0, 0, 0, 0.54)`}},input:(0,Y.jsx)(Xe,{}),onChange:t=>{let n=t.target.value;d(n);let r=Math.ceil(e.length/n)-1;f>r&&p(r)},children:[10,15,20,50].map(e=>(0,Y.jsx)(L,{value:e,children:e},e))}),(0,Y.jsx)(b,{color:`textSecondary`,variant:`caption`,children:`${e.length===0?0:f*u+1}-${Math.min(e.length,(f+1)*u)} of ${e.length}`}),(0,Y.jsx)(C,{onClick:()=>p(0),disabled:f===0,"aria-label":`First Page`,size:`large`,children:(0,Y.jsx)(xe,{})}),(0,Y.jsx)(C,{onClick:()=>p(f-1),disabled:f===0,"aria-label":`Previous Page`,size:`large`,children:(0,Y.jsx)(vr,{})}),(0,Y.jsx)(C,{onClick:()=>p(f+1),disabled:f>=Math.ceil(e.length/u)-1,"aria-label":`Next Page`,size:`large`,children:(0,Y.jsx)(Ze,{})}),(0,Y.jsx)(C,{onClick:()=>p(Math.max(0,Math.ceil(e.length/u)-1)),disabled:f>=Math.ceil(e.length/u)-1,"aria-label":`Last Page`,size:`large`,children:(0,Y.jsx)(_e,{})})]})]})}var oT=(0,K.memo)(function({part:e}){return(0,Y.jsxs)(E,{direction:`row`,sx:{flexWrap:`wrap`,justifyContent:`space-around`,ml:`1em`,mr:`1em`},children:[(0,Y.jsx)(B,{sx:{width:`60em`,overflow:`auto`},children:(0,Y.jsx)(aT,{material:e.mats})}),(0,Y.jsx)(B,{sx:{width:`40em`,overflow:`auto`},children:(0,Y.jsxs)(he,{size:`small`,children:[(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:`Station`}),(0,Y.jsx)(w,{children:`Active Hours`}),(0,Y.jsx)(w,{children:`Elapsed Hours`}),(0,Y.jsx)(w,{children:`Total Median Hours`})]})}),(0,Y.jsx)(ae,{children:e.stationMins.toAscLazySeq().map(([e,t])=>(0,Y.jsxs)(o,{children:[(0,Y.jsx)(w,{children:e}),(0,Y.jsx)(w,{children:$w.format(t.active/60)}),(0,Y.jsx)(w,{children:$w.format(t.elapsed/60)}),(0,Y.jsx)(w,{children:$w.format(t.medianElapsed/60)})]},e))})]})})]})}),sT=_r(o)({"& > *":{borderBottom:`unset !important`}}),cT=(0,K.memo)(function({part:e}){let[t,n]=(0,K.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(sT,{children:[(0,Y.jsx)(w,{children:(0,Y.jsxs)(B,{sx:{display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(B,{sx:{mr:`0.2em`},children:(0,Y.jsx)($,{part:e.part,size:25})}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(b,{variant:`body2`,component:`span`,sx:{display:`block`},children:e.part})})]})}),(0,Y.jsx)(w,{align:`right`,children:e.completedQty}),(0,Y.jsx)(w,{align:`right`,children:e.abnormalQty}),(0,Y.jsx)(w,{align:`right`,children:$w.format(e.stationMins.toAscLazySeq().filter(([,e])=>!e.isLoadUnload).sumBy(([,e])=>e.active)/60)}),(0,Y.jsx)(w,{align:`right`,children:$w.format(e.stationMins.toAscLazySeq().filter(([,e])=>!e.isLoadUnload).sumBy(([,e])=>e.elapsed)/60)}),(0,Y.jsx)(w,{align:`right`,children:$w.format(e.stationMins.toAscLazySeq().filter(([,e])=>!e.isLoadUnload).sumBy(([,e])=>e.medianElapsed)/60)}),(0,Y.jsx)(w,{align:`left`,children:e.workorders.size<=1?(0,Y.jsx)(iT,{workorderId:e.workorders.lookupMin()??null}):e.workorders.size===2?(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(iT,{workorderId:e.workorders.lookupMin()}),` &`,` `,(0,Y.jsx)(iT,{workorderId:e.workorders.lookupMax()})]}):`${e.workorders.size} workorders`}),(0,Y.jsx)(w,{children:(0,Y.jsx)(S,{title:`Show Details`,children:(0,Y.jsx)(C,{size:`small`,onClick:()=>n(!t),children:t?(0,Y.jsx)(ke,{}):(0,Y.jsx)(f,{})})})})]}),(0,Y.jsx)(o,{children:(0,Y.jsx)(w,{sx:{pb:`0`,pt:`0`},colSpan:7,children:(0,Y.jsx)(x,{in:t,timeout:`auto`,unmountOnExit:!0,children:(0,Y.jsx)(oT,{part:e})})})})]})});function lT({partsAtom:e}){let t=r(e);return(0,Y.jsx)(S,{title:`Copy to Clipboard`,children:(0,Y.jsx)(C,{style:{height:`25px`,paddingTop:0,paddingBottom:0},size:`large`,onClick:()=>vT(t),children:(0,Y.jsx)(ct,{})})})}function uT(){return(0,Y.jsx)(S,{title:`Total Median Hours are calculated by taking the median cycle time (excluding outliers) and adding up for each piece of material.`,children:(0,Y.jsx)(`span`,{style:{verticalAlign:`middle`,marginLeft:`0.5em`,fontSize:16},children:(0,Y.jsx)(Te,{fontSize:`inherit`})})})}function dT(){return(0,Y.jsx)(S,{title:`The entire cycle time is credited at the time the cycle completes, so it may be that a day has more than 24 hours of credited time for example.`,children:(0,Y.jsx)(`span`,{style:{verticalAlign:`middle`,marginLeft:`0.5em`,fontSize:16},children:(0,Y.jsx)(Te,{fontSize:`inherit`})})})}function fT(){return(0,Y.jsx)(S,{title:`An abnormal part is one which was quarantined, had a failed inspection, or was explicitly marked as failing closeout. A successful closeout overrides this and will never be an abnormal part.`,children:(0,Y.jsx)(`span`,{style:{verticalAlign:`middle`,marginLeft:`0.5em`,fontSize:16},children:(0,Y.jsx)(Te,{fontSize:`inherit`})})})}var pT=(0,K.memo)(function({partsAtom:e,order:t,setOrder:n,sortBy:r,setSortBy:i}){let a={sortBy:r,setSortBy:i,order:t,setOrder:n};return(0,Y.jsx)(je,{children:(0,Y.jsxs)(o,{children:[(0,Y.jsx)(rT,{align:`left`,col:`PartName`,...a,children:`Part`}),(0,Y.jsx)(rT,{align:`right`,col:`CompletedQty`,...a,children:`Completed Quantity`}),(0,Y.jsx)(rT,{align:`right`,col:`AbnormalQty`,...a,extraIcon:(0,Y.jsx)(fT,{}),children:`Abnormal Quantity`}),(0,Y.jsx)(rT,{align:`right`,col:`Active`,...a,extraIcon:(0,Y.jsx)(dT,{}),children:`Active Hours`}),(0,Y.jsx)(rT,{align:`right`,col:`Elapsed`,...a,extraIcon:(0,Y.jsx)(dT,{}),children:`Elapsed Hours`}),(0,Y.jsx)(rT,{align:`right`,col:`Median`,...a,extraIcon:(0,Y.jsx)(uT,{}),children:`Total Median Hours`}),(0,Y.jsx)(rT,{align:`left`,col:`Workorders`,...a,children:`Workorders`}),(0,Y.jsx)(w,{children:(0,Y.jsx)(lT,{partsAtom:e})})]})})}),mT=(0,K.memo)(function({partsAtom:e}){let t=r(e),[n,i]=(0,K.useState)(`PartName`),[a,o]=(0,K.useState)(`asc`),s=eT(t,n,a);return(0,Y.jsxs)(he,{stickyHeader:!0,children:[(0,Y.jsx)(pT,{partsAtom:e,sortBy:n,setSortBy:i,order:a,setOrder:o}),(0,Y.jsx)(ae,{children:s.map(e=>(0,Y.jsx)(cT,{part:e},e.part))})]})});function hT(){let e=j(Sg),t=r(Xs),[n,i]=vc(),a=j(X);if(t===null||t.materialID<0)return null;function o(e){t!==null&&(n({mat:t,operator:`Manager`,failed:e}),a(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{color:`primary`,disabled:i,onClick:()=>o(!0),children:`Fail CloseOut`}),(0,Y.jsx)(z,{color:`primary`,disabled:i,onClick:()=>o(!1),children:`Pass CloseOut`}),(0,Y.jsx)(z,{color:`primary`,onClick:()=>e(!0),children:`Change Workorder`})]})}var gT=(0,K.memo)(function(){return(0,Y.jsx)(xf,{buttons:(0,Y.jsx)(hT,{})})});function _T(){return Q(`Completed Parts`),(0,Y.jsxs)(B,{component:`main`,sx:{padding:`24px`},children:[(0,Y.jsxs)(E,{direction:`row`,spacing:2,sx:{alignItems:`center`,justifyContent:`space-between`},children:[(0,Y.jsx)(`span`,{children:`Completed Parts`}),(0,Y.jsx)(Qw,{chartAtom:zw})]}),(0,Y.jsx)(mT,{partsAtom:Bw}),(0,Y.jsx)(gT,{}),(0,Y.jsx)(Dg,{})]})}function vT(e){let t=`<table>
|
|
88
|
+
<thead><tr>`;t+=`<th>Part</th>`,t+=`<th>Completed Qty</th>`,t+=`<th>Abnormal Qty</th>`,t+=`<th>Workorders</th>`,t+=`<th>Active Machine Time (mins)</th>`,t+=`<th>Elapsed Machine Time (mins)</th>`,t+=`<th>Total Median Machine Time (mins)</th>`,t+=`<th>Active L/U Time (mins)</th>`,t+=`<th>Elapsed L/U Time (mins)</th>`,t+=`<th>Total Median L/U Time (mins)</th>`,t+=`</tr></thead>
|
|
89
|
+
<tbody>
|
|
90
|
+
`;for(let n of e){t+=`<tr>`,t+=`<td>${n.part}</td>`,t+=`<td>${n.completedQty}</td>`,t+=`<td>${n.abnormalQty}</td>`,t+=`<td>${n.workorders.toAscLazySeq().toRArray().join(`;`)}</td>`;for(let e of[!1,!0]){let r=n.stationMins.toAscLazySeq().filter(([,t])=>t.isLoadUnload===e).toRArray();r.length===0?t+=`<td>0</td><td>0</td><td>0</td>`:r.length===1?(t+=`<td>${r[0][1].active}</td>`,t+=`<td>${r[0][1].elapsed}</td>`,t+=`<td>${r[0][1].medianElapsed}</td>`):(t+=`<td>${r.map(([e,t])=>`${e}: ${t.active}`).join(`;`)}</td>`,t+=`<td>${r.map(([e,t])=>`${e}: ${t.elapsed}`).join(`;`)}</td>`,t+=`<td>${r.map(([e,t])=>`${e}: ${t.medianElapsed}`).join(`;`)}</td>`)}t+=`</tr>
|
|
91
|
+
`}t+=`</tbody></table>
|
|
92
|
+
`,Je(t,{format:`text/html`})}var yT=`bms-operations-reports-tab`,bT=[{separator:`Load/Unload`},{name:`L/U Outliers`,route:{route:Z.Operations_LoadOutliers},icon:(0,Y.jsx)(pr,{})},{name:`L/U Hours`,route:{route:Z.Operations_LoadHours},icon:(0,Y.jsx)(pt,{})},{name:`L/U Cycles`,route:{route:Z.Operations_LoadCycles},icon:(0,Y.jsx)(rr,{})},{separator:`Machines`},{name:`MC Outliers`,route:{route:Z.Operations_MachineOutliers},icon:(0,Y.jsx)(pr,{})},{name:`MC Hours`,route:{route:Z.Operations_MachineHours},icon:(0,Y.jsx)(pt,{})},{name:`MC Cycles`,route:{route:Z.Operations_MachineCycles},icon:(0,Y.jsx)(rr,{})},{name:`Tools`,route:{route:Z.Operations_Tools},icon:(0,Y.jsx)(rn,{})},{name:`Programs`,route:{route:Z.Operations_Programs},icon:(0,Y.jsx)(mn,{})},{separator:`Material`},{name:`Quality`,route:{route:Z.Operations_Quality},icon:(0,Y.jsx)(nr,{})},{name:`Inspections`,route:{route:Z.Operations_Inspections},icon:(0,Y.jsx)($e,{})},{name:`Close Out`,route:{route:Z.Operations_CloseoutReport},icon:(0,Y.jsx)(un,{})},{separator:`Cell`},{name:`Schedules`,route:{route:Z.Operations_RecentSchedules},icon:(0,Y.jsx)(wt,{})},{name:`Workorders`,route:{route:Z.Operations_CurrentWorkorders},icon:(0,Y.jsx)(ht,{})},{name:`Production`,route:{route:Z.Operations_Production},icon:(0,Y.jsx)(Bt,{})},{name:`Part Summary`,route:{route:Z.Operations_Parts},icon:(0,Y.jsx)(mr,{})},{name:e=>e.supportsRebookings??`Rebooking`,route:{route:Z.Operations_Rebookings},icon:(0,Y.jsx)(ne,{}),hidden:e=>e.supportsRebookings===null||e.supportsRebookings===``}];function xT(e){return[{separator:`Efficiency`},{name:`Buffers`,route:{route:Z.Analysis_Buffers},icon:(0,Y.jsx)(Bn,{})},{name:`Station OEE`,route:{route:Z.Analysis_StationOEE},icon:(0,Y.jsx)(pt,{})},{name:`Completed Parts`,route:{route:Z.Analysis_PartsCompleted},icon:(0,Y.jsx)(ht,{})},{separator:`Cycles`},{name:`Machine Cycles`,route:{route:Z.Analysis_MachineCycles},icon:(0,Y.jsx)(rr,{})},{name:`L/U Cycles`,route:{route:Z.Analysis_LoadCycles},icon:(0,Y.jsx)(ar,{})},{name:`Pallet Cycles`,route:{route:Z.Analysis_PalletCycles},icon:(0,Y.jsx)(g,{})},{name:e=>eo(e.basketName)+` Cycles`,route:{route:Z.Analysis_BasketCycles},icon:(0,Y.jsx)(g,{}),hidden:()=>!e},{separator:`Cell`},{name:`Quality`,route:{route:Z.Analysis_Quality},icon:(0,Y.jsx)(nr,{})},{name:`Tool Replacements`,route:{route:Z.Analysis_ToolReplacements},icon:(0,Y.jsx)(rn,{})},{name:`Schedules`,route:{route:Z.Analysis_Schedules},icon:(0,Y.jsx)(wt,{})},{separator:`Costs`},{name:`Percentages`,route:{route:Z.Analysis_CostPercents},icon:(0,Y.jsx)(bn,{})},{name:`Cost/Piece`,route:{route:Z.Analysis_CostPerPiece},icon:(0,Y.jsx)(Mt,{})}]}function ST(e){return typeof e==`string`&&Object.values(Z).includes(e)}function CT(e){return ST(e)&&e!==Z.Client_Custom&&e!==Z.Operations_CurrentWorkorders&&e!==Z.Station_InspectionMonitorWithType&&e!==Z.Station_LoadMonitor&&e!==Z.Station_Queues}function wT(e){return{route:e}}function TT({children:e}){let[t,n]=A(Nc),r=d(),i=rt(r.breakpoints.down(`md`)),[,a]=(0,K.useTransition)(),o=bT.some(e=>`separator`in e?!1:e.route.route===t.route);return(0,Y.jsx)(ze,{variant:i&&(!Array.isArray(e)||e.length<5)?`fullWidth`:`scrollable`,value:o?yT:t.route,onChange:(e,t)=>a(()=>{t===yT?n({route:Z.Operations_MachineCycles}):CT(t)&&n(wT(t))}),textColor:`inherit`,scrollButtons:!0,allowScrollButtonsMobile:!0,indicatorColor:`secondary`,children:e})}function ET(){return(0,Y.jsxs)(TT,{children:[(0,Y.jsx)(De,{label:`Operations`,value:Z.Operations_Dashboard}),(0,Y.jsx)(De,{label:`Cell`,value:Z.Operations_SystemOverview}),(0,Y.jsx)(De,{label:`Material`,value:Z.Operations_AllMaterial}),(0,Y.jsx)(De,{label:`Reports`,value:yT})]})}function DT(){return(0,Y.jsxs)(TT,{children:[(0,Y.jsx)(De,{label:`Material`,value:Z.Quality_Dashboard}),(0,Y.jsx)(De,{label:`Paths`,value:Z.Quality_Paths}),(0,Y.jsx)(De,{label:`Quarantine Material`,value:Z.Quality_Quarantine})]})}function OT(){return(0,Y.jsxs)(TT,{children:[(0,Y.jsx)(De,{label:`Tools`,value:Z.Tools_Dashboard}),(0,Y.jsx)(De,{label:`Programs`,value:Z.Tools_Programs})]})}function kT(){return(0,Y.jsxs)(TT,{children:[(0,Y.jsx)(De,{label:`Cycles`,value:Z.Engineering_Cycles}),(0,Y.jsx)(De,{label:`Hours`,value:Z.Engineering_Hours}),(0,Y.jsx)(De,{label:`Outliers`,value:Z.Engineering_Outliers})]})}function AT(){return r(ku)===null?null:(0,Y.jsxs)(TT,{children:[(0,Y.jsx)(De,{label:`Workorders`,value:Z.Sales_Dashboard}),(0,Y.jsx)(De,{label:`Projections`,value:Z.Sales_ProjectedUsage})]})}var jT=(0,K.memo)(function(e){Fc();let t=r(G),n=r(uu),i=r(pu),[a,o]=A(Nc),s=xT(n||i),c=t.user!==null&&t.user!==void 0,l,u,d,f,p=!0,m=!0,h=!1,g=!0;if(Qi(t)&&!t.user)l=(0,Y.jsxs)(`div`,{style:{textAlign:`center`,marginTop:`4em`},children:[(0,Y.jsx)(`h3`,{children:`Please Login`}),(0,Y.jsx)(z,{variant:`contained`,color:`primary`,onClick:()=>ea(t),children:`Login`})]}),p=!1,m=!1;else switch(a.route){case Z.Station_LoadMonitor:l=(0,Y.jsx)(J_,{loadNum:a.loadNum,queues:a.queues,completed:a.completed},a.loadNum),u=hy,d=gy,h=!0,g=!1;break;case Z.Station_InspectionMonitor:l=(0,Y.jsx)(nv,{focusInspectionType:null}),u=hy,d=gy,h=!0,g=!1;break;case Z.Station_InspectionMonitorWithType:l=(0,Y.jsx)(nv,{focusInspectionType:a.inspType}),u=hy,d=gy,h=!0,g=!1;break;case Z.Station_Closeout:l=(0,Y.jsx)(lv,{}),u=hy,d=gy,h=!0,g=!1;break;case Z.Station_Queues:l=(0,Y.jsx)(Pm,{queues:a.queues}),u=hy,d=gy,h=!0,g=!1;break;case Z.Station_Overview:l=(0,Y.jsx)(__,{}),g=!1;break;case Z.Analysis_Quality:l=(0,Y.jsx)(cy,{}),u=yx,f=s,p=!1;break;case Z.Analysis_ToolReplacements:l=(0,Y.jsx)(cC,{}),u=yx,f=s,p=!1;break;case Z.Analysis_Schedules:l=(0,Y.jsx)(sy,{}),u=yx,f=s,p=!1;break;case Z.Analysis_Buffers:l=(0,Y.jsx)(Mx,{}),u=yx,f=s,p=!1;break;case Z.Analysis_StationOEE:l=(0,Y.jsx)(tS,{}),u=yx,f=s,p=!1;break;case Z.Analysis_PartsCompleted:l=(0,Y.jsx)(aS,{}),u=yx,f=s,p=!1;break;case Z.Analysis_MachineCycles:l=(0,Y.jsx)(yS,{}),u=yx,f=s,p=!1;break;case Z.Analysis_LoadCycles:l=(0,Y.jsx)(AS,{}),u=yx,f=s,p=!1;break;case Z.Analysis_PalletCycles:l=(0,Y.jsx)(RS,{}),u=yx,f=s,p=!1;break;case Z.Analysis_BasketCycles:l=(0,Y.jsx)(KS,{}),u=yx,f=s,p=!1;break;case Z.Analysis_CostPercents:l=(0,Y.jsx)(Ff,{}),u=yx,f=s,p=!1;break;case Z.Analysis_CostPerPiece:l=(0,Y.jsx)(Lf,{}),u=yx,f=s,p=!1;break;case Z.Operations_Dashboard:l=(0,Y.jsx)(Uc,{}),u=ET;break;case Z.Operations_SystemOverview:l=(0,Y.jsx)(__,{ignoreOperator:!0}),u=ET,g=!1;break;case Z.Operations_AllMaterial:l=(0,Y.jsx)(hh,{displaySystemBins:!0}),u=ET,g=!1;break;case Z.Operations_LoadOutliers:l=(0,Y.jsx)(ib,{outlierTy:`labor`}),u=ET,f=bT;break;case Z.Operations_LoadHours:l=(0,Y.jsx)(Rb,{ty:`labor`}),u=ET,f=bT;break;case Z.Operations_LoadCycles:l=(0,Y.jsx)(gx,{ty:`labor`}),u=ET,f=bT;break;case Z.Operations_MachineOutliers:l=(0,Y.jsx)(ib,{outlierTy:`machine`}),u=ET,f=bT;break;case Z.Operations_MachineHours:l=(0,Y.jsx)(Rb,{ty:`machine`}),u=ET,f=bT;break;case Z.Operations_MachineCycles:l=(0,Y.jsx)(gx,{ty:`machine`}),u=ET,f=bT;break;case Z.Operations_RecentSchedules:l=(0,Y.jsx)(Hm,{}),u=ET,f=bT;break;case Z.Operations_CurrentWorkorders:l=(0,Y.jsx)(YC,{}),u=ET,f=bT,g=!1;break;case Z.Operations_Production:l=(0,Y.jsx)(Ry,{}),u=ET,f=bT;break;case Z.Operations_Quality:l=(0,Y.jsx)(bg,{}),u=ET,f=bT,g=!1;break;case Z.Operations_Inspections:l=(0,Y.jsx)(xg,{}),u=ET,f=bT;break;case Z.Operations_CloseoutReport:l=(0,Y.jsx)(bw,{}),u=ET,f=bT,g=!1;break;case Z.Operations_Tools:l=(0,Y.jsx)(Gv,{}),u=ET,f=bT;break;case Z.Operations_Programs:l=(0,Y.jsx)(ry,{}),u=ET,f=bT;break;case Z.Operations_Rebookings:l=(0,Y.jsx)(jw,{}),u=ET,f=bT;break;case Z.Operations_Parts:l=(0,Y.jsx)(_T,{}),u=ET,f=bT,g=!1;break;case Z.Engineering_Cycles:l=(0,Y.jsx)(gx,{ty:`machine`}),p=!1,u=kT;break;case Z.Engineering_Hours:l=(0,Y.jsx)(Rb,{ty:`machine`}),p=!1,u=kT;break;case Z.Engineering_Outliers:l=(0,Y.jsx)(ib,{outlierTy:`machine`}),p=!1,u=kT;break;case Z.Quality_Dashboard:l=(0,Y.jsx)(bg,{}),u=DT,p=!1,g=!1;break;case Z.Quality_Paths:l=(0,Y.jsx)(xg,{}),u=DT,p=!1;break;case Z.Quality_Quarantine:l=(0,Y.jsx)(hh,{displaySystemBins:!1}),u=DT,g=!1;break;case Z.Tools_Dashboard:l=(0,Y.jsx)(Gv,{}),u=OT;break;case Z.Tools_Programs:l=(0,Y.jsx)(ry,{}),u=OT;break;case Z.Sales_Dashboard:l=(0,Y.jsx)(YC,{disableSearch:!0}),u=AT,p=!1;break;case Z.Sales_ProjectedUsage:l=(0,Y.jsx)(lw,{}),u=AT,p=!1;break;case Z.VerboseLogging:l=(0,Y.jsx)(zy,{}),m=!1,p=!1;break;case Z.Client_Custom:{let n=e.renderCustomPage?.(a.custom);u=n?.nav,l=n?.page??(0,Y.jsx)(rp,{setRoute:o,modes:e.chooseModes?.(t)}),p=!1;break}case Z.ChooseMode:default:l=(0,Y.jsx)(rp,{setRoute:o,modes:e.chooseModes?.(t)}),m=!1,p=!1}return(0,Y.jsxs)(`div`,{id:`App`,children:[(0,Y.jsx)(Qy,{showAlarms:p,showSearch:m,showLogout:c,showOperator:h,Nav1:u,Nav2:d,menuNavs:f}),(0,Y.jsxs)(`div`,{style:{display:`flex`},children:[(0,Y.jsx)($y,{menuItems:f}),(0,Y.jsx)(`div`,{style:{flexGrow:1},children:l})]}),g?(0,Y.jsx)(xf,{}):void 0,(0,Y.jsx)(tp,{}),(0,Y.jsx)(ip,{})]})});function MT(e,t,n){let r=ut({palette:{primary:we,secondary:le}});(0,na.createRoot)(t).render((0,Y.jsxs)(Oe,{theme:r,children:[(0,Y.jsx)(xn,{}),(0,Y.jsx)(K.StrictMode,{children:(0,Y.jsx)(Ht,{store:n,children:(0,Y.jsx)(jT,{...e})})})]}))}async function NT(e={},t){let n=t??document.getElementById(`root`);if(!n)throw Error(`Unable to start FMS Insight: no root element was provided or found`);Ki();let r=zn();r.set(G,await $i()),MT(e,n,r)}async function PT(){await NT()}PT().catch(e=>{console.log(e);let t=`Error loading Insight`;e instanceof Ri&&(t=`Error loading Insight: `+e.message+` `+e.response);let n=document.createElement(`p`);n.textContent=t,(document.getElementById(`loading`)??document.body).appendChild(n)});
|