@jield/solodb-react-components 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -27,10 +27,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
27
27
  `});++r<e.length;)r&&n.push({type:`text`,value:`
28
28
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
29
29
  `}),n}function HE(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function UE(e,t){let n=LE(e,t),r=n.one(e,void 0),i=SE(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
30
- `},i)),a}function WE(e,t){return e&&`run`in e?async function(n,r){let i=UE(n,{file:r,...t});await e.run(i,r)}:function(n,r){return UE(n,{file:r,...e||t})}}function GE(e){if(e)throw e}var KE=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function qE(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function JE(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?YE(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function YE(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var XE={basename:ZE,dirname:QE,extname:$E,join:eD,sep:`/`};function ZE(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);rD(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function QE(e){if(rD(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function $E(e){rD(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function eD(...e){let t=-1,n;for(;++t<e.length;)rD(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:tD(n)}function tD(e){rD(e);let t=e.codePointAt(0)===47,n=nD(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function nD(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function rD(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var iD={cwd:aD};function aD(){return`/`}function oD(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function sD(e){if(typeof e==`string`)e=new URL(e);else if(!oD(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return cD(e)}function cD(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var lD=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],uD=class{constructor(e){let t;t=e?oD(e)?{path:e}:typeof e==`string`||mD(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:iD.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<lD.length;){let e=lD[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)lD.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?XE.basename(this.path):void 0}set basename(e){fD(e,`basename`),dD(e,`basename`),this.path=XE.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?XE.dirname(this.path):void 0}set dirname(e){pD(this.basename,`dirname`),this.path=XE.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?XE.extname(this.path):void 0}set extname(e){if(dD(e,`extname`),pD(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=XE.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){oD(e)&&(e=sD(e)),fD(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?XE.basename(this.path,this.extname):void 0}set stem(e){fD(e,`stem`),dD(e,`stem`),this.path=XE.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new $x(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function dD(e,t){if(e&&e.includes(XE.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+XE.sep+"`")}function fD(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function pD(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function mD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var hD=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),gD=l(KE(),1),_D={}.hasOwnProperty,vD=new class e extends hD{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=JE()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,gD.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(xD(`data`,this.frozen),this.namespace[e]=t,this):_D.call(this.namespace,e)&&this.namespace[e]||void 0:e?(xD(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=wD(e),n=this.parser||this.Parser;return yD(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),yD(`process`,this.parser||this.Parser),bD(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=wD(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);ED(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),yD(`processSync`,this.parser||this.Parser),bD(`processSync`,this.compiler||this.Compiler),this.process(e,r),CD(`processSync`,`process`,t),n;function r(e,r){t=!0,GE(e),n=r}}run(e,t,n){SD(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=wD(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),CD(`runSync`,`run`,n),r;function i(e,t){GE(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=wD(t),r=this.compiler||this.Compiler;return bD(`stringify`,r),SD(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(xD(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,gD.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];qE(o)&&qE(r)&&(r=(0,gD.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function yD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function bD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function xD(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function SD(e){if(!qE(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function CD(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function wD(e){return TD(e)?e:new uD(e)}function TD(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function ED(e){return typeof e==`string`||DD(e)}function DD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var OD=[],kD={allowDangerousHtml:!0},AD=/^(https?|ircs?|mailto|xmpp)$/i,jD=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function MD(e){let t=ND(e),n=PD(e);return FD(t.runSync(t.parse(n),n),e)}function ND(e){let t=e.rehypePlugins||OD,n=e.remarkPlugins||OD,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...kD}:kD;return vD().use(kT).use(n).use(WE,r).use(t)}function PD(e){let t=e.children||``,n=new uD;return typeof t==`string`?n.value=t:``+t,n}function FD(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||ID;for(let e of jD)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return PE(e,l),oS(e,{Fragment:p.Fragment,components:i,ignoreInvalidStyle:!0,jsx:p.jsx,jsxs:p.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in OS)if(Object.hasOwn(OS,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=OS[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function ID(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||AD.test(e.slice(0,t))?e:``}function LD(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;let t=new Date(e);return isNaN(t.getTime())?null:t}function RD(e,t){let n=LD(e);if(!n)return``;let r=e=>e.toString().padStart(2,`0`),i={YYYY:n.getFullYear().toString(),YY:n.getFullYear().toString().slice(-2),MMMM:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`][n.getMonth()],MMM:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][n.getMonth()],MM:r(n.getMonth()+1),DD:r(n.getDate()),HH:r(n.getHours()),mm:r(n.getMinutes()),H:n.getHours().toString(),m:n.getMinutes().toString()},a=Object.keys(i).sort((e,t)=>t.length-e.length).join(`|`);return t.replace(new RegExp(a,`g`),e=>i[e])}function zD(e,t=`DD-MM-YY HH:mm`){return RD(e,t)}function BD({ecn:e,equipment:t,ecnAttachments:n,reloadQueryFn:r,expanded:i=!0}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(e),[f,m]=(0,d.useState)(i),h=e=>{r([`ecn`,`attachment`,`status_mail`]),u({...l,...e})},g=()=>n.filter(t=>t.ecn.id===e.id);return(0,p.jsxs)(`div`,{className:`p-3 mb-4 border-bottom`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(wr,{bg:`dark`,children:`ECN`}),(0,p.jsx)(`h4`,{className:l.date_closed?`text-danger mb-0`:`mb-0`,children:l.date_closed?(0,p.jsx)(`s`,{children:l.ecn}):l.ecn})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(U,{variant:`outline-primary`,size:`sm`,onClick:()=>m(e=>!e),"aria-label":`Toggle Details`,children:f?`Hide Details`:`Show Details`}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{o((0,p.jsx)(Qb,{equipment:t,showModal:!0,onClose:e=>{c(!1),e&&(r([`ecn`,`attachment`,`status_mail`]),h(e))},ecn:l,attachments:g()})),c(!0)},"aria-label":`Edit ECN`,children:`Edit`})]})]}),f&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mb-3`,children:(0,p.jsx)(MD,{children:l.description})}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap text-muted`,children:[(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Creator`}),(0,p.jsx)(`div`,{className:`text-body`,children:l.owner.full_name})]}),(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Created`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(l.date_created,`DD MMMM YYYY`)})]}),l.date_closed&&(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Closed`}),(0,p.jsx)(`div`,{className:`text-danger`,children:RD(l.date_closed,`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Attachments`}),(0,p.jsx)(`div`,{className:`text-body`,children:l.attachments})]}),l.updated_by&&(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update By`}),(0,p.jsx)(`div`,{className:`text-body`,children:l.updated_by.full_name})]}),l.last_update&&(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(l.last_update,`DD MMMM YYYY`)})]})]})]}),s&&a]})}var VD=({equipment:e,showModal:t,onClose:n,issue:r,attachments:i})=>{let[a,o]=(0,d.useState)([]),[s,c]=(0,d.useState)([]),{user:l}=(0,d.useContext)(v),[u,m]=(0,d.useState)(i),{register:h,handleSubmit:g,reset:_,control:y}=Id({defaultValues:{issue:r?.issue||``,description:r?.description||``,issue_type:r?.issue_type||ut.DEFAULT,status:r?.status||dt.ACTIVE,forecast_up:r?.forecast_up?new Date(r?.forecast_up).toISOString().split(`T`)[0]:``,actions:r?.actions||``,owner:r?.owner||{}}});(0,d.useEffect)(()=>{r&&_({issue:r?.issue||``,description:r?.description||``,issue_type:r?.issue_type||ut.DEFAULT,status:r?.status||dt.ACTIVE,forecast_up:r?.forecast_up?new Date(r?.forecast_up).toISOString().split(`T`)[0]:``,actions:r?.actions||``,owner:r?.owner||{}})},[r,_]);let{getRootProps:b,getInputProps:x,isDragActive:S}=Hb({accept:{"application/*":[],"image/*":[]},onDrop:e=>{o(t=>[...t,...e])}});(0,d.useEffect)(()=>{t&&(async()=>{if(e?.id)try{let t=await re({equipment:e});c(t.items||[])}catch(e){console.error(`Error fetching modules:`,e)}})()},[e,t]);async function w(){await f.default.delete(`/delete/equipment/module/issue/${r?.id}`),n({...r,date_closed:new Date().toISOString(),last_update:new Date().toISOString(),updated_by:l?.full_name})}let T=e=>{o(t=>t.filter((t,n)=>n!==e))},E=e=>{u&&m(t=>t?.filter((t,n)=>n!==e))},D=(e,t)=>new Promise(async(n,r)=>{try{if(u&&i&&i!=u){let e=new Set(u.map(e=>e.id)),t=[];for(let n of i)e.has(n.id)||t.push(f.default.delete(`/delete/equipment/module/issue/attachment/${n.id}`));await Promise.all(t)}e.length>0&&t&&await Promise.all(e.map(async e=>{let n=await C(e),r={issue_id:t,filename:e.name,type:e.type,content:n};await f.default.post(`/create/equipment/module/issue/attachment`,r)})),n()}catch(e){r(e)}});return(0,d.useEffect)(()=>{t&&(async()=>{if(e?.id)try{let t=await re({equipment:e});c(t.items||[])}catch(e){console.error(`Error fetching modules:`,e)}})()},[e,t]),(0,p.jsx)(K,{show:t,size:`lg`,centered:!0,onHide:()=>n(r),children:(0,p.jsxs)(G,{onSubmit:g(async e=>{try{let t,i={module_id:e.module_id,issue:e.issue,description:e.description,owner:e?.owner.value||r?.owner,status:e.status,issue_type:e.issue_type,actions:e.actions,forecast_up:e.forecast_up};r?(await D(a,r.id),t=(await f.default.patch(`/update/equipment/module/issue/${r?.id}`,i)).data):(t=(await f.default.post(`/create/equipment/module/issue`,i)).data,D(a,t.id),t.attachments=a.length),n(t)}catch(e){console.error(`Error submitting the form:`,e)}}),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:r?`Edit Issue for ${e.name}`:`Create new Issue for ${e.name}`})}),(0,p.jsxs)(K.Body,{children:[!r&&(0,p.jsxs)(G.Group,{controlId:`module`,className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Module`}),(0,p.jsxs)(G.Select,{...h(`module_id`,{required:`Module is required`}),children:[(0,p.jsx)(`option`,{value:``,children:`— Select a module`}),s.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,p.jsxs)(G.Group,{controlId:`issue`,children:[(0,p.jsx)(G.Label,{children:`Issue`}),(0,p.jsx)(G.Control,{type:`text`,...h(`issue`,{required:`Issue content is required`}),autoFocus:!0})]}),(0,p.jsxs)(G.Group,{controlId:`description`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Description`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:3,...h(`description`,{required:`Description is required`})})]}),(0,p.jsxs)(G.Group,{controlId:`issueType`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Issue`}),(0,p.jsxs)(G.Control,{as:`select`,...h(`issue_type`,{required:`Issue type is required`}),children:[(0,p.jsx)(`option`,{value:ut.DEFAULT,children:`Default`}),(0,p.jsx)(`option`,{value:ut.PRIORITY,children:`Priority`}),(0,p.jsx)(`option`,{value:ut.ESCALATION,children:`Escalation`})]})]}),(0,p.jsxs)(G.Group,{controlId:`status`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Status`}),(0,p.jsxs)(G.Control,{as:`select`,...h(`status`,{required:`Status is required`}),children:[(0,p.jsx)(`option`,{value:dt.ACTIVE,children:`Active`}),(0,p.jsx)(`option`,{value:dt.CLOSED,children:`Closed`})]})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:y,...h(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(G.Group,{controlId:`forecastUp`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Forecast Up`}),(0,p.jsx)(G.Control,{type:`date`,...h(`forecast_up`,{required:`Forecast Up date is required`})})]}),(0,p.jsxs)(G.Group,{controlId:`actions`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Actions`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:5,...h(`actions`,{required:!1})})]}),(0,p.jsxs)(G.Group,{children:[(0,p.jsx)(G.Label,{children:`Attachments`}),(0,p.jsxs)(`div`,{...b({className:`dropzone ${S?`active`:``}`,style:{border:`2px dashed #007bff`,padding:`10px`,textAlign:`center`}}),children:[(0,p.jsx)(`input`,{...x()}),S?(0,p.jsx)(`p`,{children:`Drop the files here...`}):(0,p.jsx)(`p`,{children:`Drag & drop files here, or click to select files`})]}),a.length>0&&(0,p.jsx)(`ul`,{children:a.map((e,t)=>(0,p.jsxs)(`li`,{children:[e.name,` `,(0,p.jsx)(U,{variant:`secondary`,onClick:()=>T(t),children:`cancel`})]},`${e.name}-${e.lastModified}`))})]}),u&&u.length>0&&(0,p.jsxs)(G.Group,{controlId:`uploaded_files`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Uploaded files`}),(0,p.jsx)(`ul`,{children:u.map((e,t)=>(0,p.jsxs)(`li`,{children:[e.filename,` `,(0,p.jsx)(U,{variant:`secondary`,onClick:()=>E(t),children:`delete`})]},e.id))})]})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{variant:`secondary`,onClick:()=>n(r),children:`Cancel`}),(0,p.jsx)(U,{variant:`primary`,type:`submit`,children:r?`Update Issue`:`Create Issue`}),r&&(0,p.jsx)(U,{variant:`danger`,onClick:()=>w(),children:`Close Issue`})]})]})})};function HD({issue:e,equipment:t,issueAttachments:n,reloadQueryFn:r,expanded:i=!0}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(i),f=e=>{r([`issue`,`attachment`,`status_mail`]),r([`issue`,`status_mail`])},m=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(`div`,{className:`p-3 mb-4 border-bottom`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(wr,{bg:`dark`,children:`Issue`}),(0,p.jsx)(`h4`,{className:e.date_closed?`text-danger mb-0`:`mb-0`,children:e.date_closed?(0,p.jsx)(`s`,{children:e.issue}):e.issue})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(U,{variant:`outline-primary`,size:`sm`,onClick:()=>u(e=>!e),"aria-label":`Toggle Details`,children:l?`Hide Details`:`Show Details`}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{o((0,p.jsx)(VD,{equipment:t,showModal:!0,onClose:e=>{c(!1),e&&f(e)},issue:e,attachments:m()})),c(!0)},"aria-label":`Edit Issue`,children:`Edit`})]})]}),l&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mb-2`,children:(0,p.jsx)(MD,{children:e.description})}),(0,p.jsx)(`p`,{className:`mb-3`,children:e.actions}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-4 text-muted`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Creator`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.owner.full_name})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Created`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(e.date_created,`DD MMMM YYYY`)})]}),e.date_closed&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Closed`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(e.date_closed,`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Forecast Up`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(e.forecast_up,`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Issue Type`}),(0,p.jsxs)(`div`,{className:`text-body`,children:[e.issue_type===ut.DEFAULT&&`Issue`,e.issue_type===ut.ESCALATION&&`Escalation`,e.issue_type===ut.PRIORITY&&`Priority`]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Attachments`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.attachments})]}),e.updated_by&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update By`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.updated_by.full_name})]}),e.last_update&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(e.last_update,`DD MMMM YYYY`)})]})]})]}),s&&a]})}function UD({reservations:e}){if(!e||e.length<1)return(0,p.jsx)(p.Fragment,{});let t=e[0];return(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsxs)(fl,{id:`tooltip-${t.id}`,children:[(0,p.jsx)(`h5`,{children:t.title}),(0,p.jsx)(`p`,{children:e[0].active?`Currently active`:`Upcoming in: ${RD(e[0].start,`DD MMMM YYYY`)}`}),(0,p.jsx)(`p`,{children:e[1]?`Next upcoming reservation in: ${RD(e[1].start,`DD MMMM YYYY`)}`:`No next upcoming reservations`})]}),children:(0,p.jsxs)(wr,{bg:e[0].active?`info`:`dark`,children:[`Reserved by: `,e[0].user.full_name]})})}function WD({equipment:e,modules:t,issues:n,issueAttachments:r,ecnNotes:i,ecnAttachments:a,reloadQueryFn:o,showIssues:s,reservations:c}){let[l,u]=(0,d.useState)(null),[f,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)([]),[x,S]=(0,d.useState)(void 0),[C,w]=(0,d.useState)([]),[T,E]=(0,d.useState)([]),D=e=>{o([`ecn`,`attachment`,`status_mail`]),w([...C,e])},O=e=>{o([`issue`,`status_mail`]),o([`issue`,`attachment`,`status_mail`]),E([...T,e])};(0,d.useEffect)(()=>{w(i),E(n),b(t.filter(t=>t.equipment.id===e.id&&t.id!==e.main_tool_module_id)),S(t.findLast(t=>t.equipment.id===e.id&&t.id===e.main_tool_module_id))},[i,n,e,t]);let k=e=>C.filter(t=>t.module_id===e),A=e=>T.filter(t=>t.module_id===e);return(0,p.jsxs)(`div`,{className:`card mb-4`,children:[(0,p.jsxs)(`div`,{className:`card-header d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsxs)(`h4`,{className:`mb-0`,children:[e.number,` - `,e.name]}),x&&(0,p.jsx)(Ld,{module:x}),x&&(0,p.jsx)(UD,{reservations:c.filter(e=>e.modules.some(e=>e.id===x.id))})]}),(0,p.jsxs)(ms,{as:Tr,title:`Action`,id:`bg-nested-dropdown`,children:[(0,p.jsx)(fs.Item,{eventKey:`1`,onClick:()=>{g((0,p.jsx)(Qb,{equipment:e,showModal:!0,onClose:e=>{v(!1),e&&D(e)}})),v(!0)},children:`New ECN`}),s!==1&&(0,p.jsx)(fs.Item,{eventKey:`1`,onClick:()=>{u((0,p.jsx)(VD,{equipment:e,showModal:!0,onClose:e=>{m(!1),e&&O(e)}})),m(!0)},children:`New Issue`})]})]}),(0,p.jsx)(`div`,{className:`card-body`,children:(0,p.jsxs)(jl,{children:[x&&(0,p.jsx)(qr,{xs:12,md:y.length>0?6:12,children:(0,p.jsx)(W,{className:`mb-3`,children:(0,p.jsxs)(W.Body,{children:[(0,p.jsxs)(W.Title,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{children:`Main module`}),(0,p.jsx)(`div`,{className:`ms-2`})]}),(0,p.jsxs)(`div`,{className:`mt-3`,children:[k(x.id).map(t=>(0,p.jsx)(BD,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},t.id)),s!==1&&A(x.id).map(t=>(0,p.jsx)(HD,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},t.id))]})]})})}),y.length>0&&(0,p.jsx)(qr,{xs:12,md:x?6:12,children:y.map(t=>(0,p.jsx)(W,{className:`mb-3`,children:(0,p.jsxs)(W.Body,{children:[(0,p.jsx)(W.Title,{className:`d-flex align-items-center`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(`span`,{children:t.name}),(0,p.jsx)(Ld,{module:t}),(0,p.jsx)(UD,{reservations:c.filter(e=>e.modules.some(e=>e.id===t.id))})]})}),(0,p.jsxs)(`div`,{className:`mt-3`,children:[k(t.id).map(t=>(0,p.jsx)(BD,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},t.id)),s!==1&&A(t.id).map(t=>(0,p.jsx)(HD,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},t.id))]})]})},t.id))})]})}),_&&h,f&&l]})}var GD=()=>document.documentElement.getAttribute(`data-bs-theme`)===`dark`,KD={control:e=>({...e,backgroundColor:GD()?`#212529`:e.backgroundColor,borderColor:GD()?`#495057`:e.borderColor,color:GD()?`#fff`:e.color}),menu:e=>({...e,backgroundColor:GD()?`#212529`:e.backgroundColor}),option:(e,t)=>({...e,backgroundColor:GD()?t.isSelected?`#0d6efd`:t.isFocused?`#343a40`:`#212529`:e.backgroundColor,color:GD()?`#fff`:e.color}),singleValue:e=>({...e,color:GD()?`#fff`:e.color}),multiValue:e=>({...e,backgroundColor:GD()?`#343a40`:e.backgroundColor}),multiValueLabel:e=>({...e,color:GD()?`#fff`:e.color}),input:e=>({...e,color:GD()?`#fff`:e.color})},qD=(e,t)=>{let n=[];for(let r of e??[]){let e=t.get(r.id);e&&n.push(e)}return n},JD=({showModal:e,onClose:t,message:n})=>{let{register:r,handleSubmit:i,setValue:a,reset:o,control:s}=Id({defaultValues:{title:n?.title,description:n?.description,rooms:n?.rooms,type:n?.type,owner:n?.owner}}),[c,l]=(0,d.useState)([]),[u,m]=(0,d.useState)([]),[h,g]=(0,d.useState)(``),_=(0,d.useMemo)(()=>new Map(c.map(e=>[e.value.id,e])),[c]),{statusMail:v}=(0,d.useContext)(uy);(0,d.useEffect)(()=>{f.default.get(`/list/room`).then(e=>{let t=(e.data._embedded.items||[]).map(e=>({value:e,label:e.name}));l(t)}).catch(e=>{console.error(`Error fetching rooms:`,e),g(`Error fetching rooms:`+e)}),f.default.get(`/list/location/message/type`).then(e=>{let t=new Set(v.filter.messageType),r=e.data._embedded.items||[],i=[];for(let e of r)t.has(e.id.toString())&&i.push({value:e,label:e.type});m(i),a(`type`,n?.type||i[0].value)}).catch(e=>{console.error(`Error fetching message types:`,e),g(`Error fetching message types:`+e)})},[]);let y=e=>e.title?e?.owner.value===void 0&&n?.owner===void 0?`owner`:e.rooms===void 0||e.rooms.map(e=>e.id).length<=0?`room`:e.type?``:`type`:`title`;return(0,p.jsx)(K,{show:e,size:`lg`,centered:!0,onHide:()=>t(n),children:(0,p.jsxs)(G,{onSubmit:i(async e=>{let r=y(e);if(r!==``){g(`Please fill: `+r);return}try{let r={title:e.title,description:e.description,owner:e?.owner.value||n?.owner.id,type:e.type.id,rooms:e.rooms.map(e=>e.id)},i;if(i=n?await f.default.patch(`/update/location/message/${n.id}`,r):await f.default.post(`/create/location/message`,r),i){t(i?.data),o();return}console.error(`No response received`),g(`No response received`)}catch(e){console.error(`Error submitting the form:`,e),g(`Error submitting the form:`+e)}}),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Edit status mail message`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Title`}),(0,p.jsx)(G.Control,{type:`text`,placeholder:`Enter the title`,...r(`title`)})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Message`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:3,placeholder:`Give the message`,...r(`description`)})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:s,...r(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Rooms`}),(0,p.jsx)(wu,{name:`rooms`,control:s,render:({field:e})=>(0,p.jsx)(pv,{isMulti:!0,options:c,classNamePrefix:`react-select`,placeholder:`Select one or more rooms`,value:qD(e.value,_),onChange:t=>e.onChange(t.map(e=>e.value)),styles:KD})})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Type`}),(0,p.jsx)(wu,{name:`type`,control:s,render:({field:e})=>(0,p.jsx)(pv,{options:u,classNamePrefix:`react-select`,placeholder:`— Select a message type`,value:u.find(t=>t.value.id===e.value?.id)||null,onChange:t=>e.onChange(t?.value),styles:KD})})]})]}),(0,p.jsxs)(K.Footer,{children:[h!=``&&(0,p.jsx)(`span`,{className:`text-danger`,children:h}),(0,p.jsx)(U,{variant:`secondary`,onClick:()=>t(n),children:`Cancel`}),(0,p.jsx)(U,{variant:`primary`,type:`submit`,children:n?`Update Message`:`Create Message`})]})]})})};function YD({message:e}){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(e),s=e=>{o({...a,...e})};return(0,p.jsxs)(`div`,{className:`card mb-4`,children:[(0,p.jsxs)(`div`,{className:`card-header d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(wr,{bg:`dark`,children:a.type.type}),(0,p.jsx)(`h5`,{className:`mb-0`,children:a.title})]}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{n((0,p.jsx)(JD,{showModal:!0,onClose:e=>{i(!1),e&&s(e)},message:a})),i(!0)},children:`Edit`})]}),(0,p.jsx)(`div`,{className:`card-body`,children:(0,p.jsx)(MD,{children:a.description})}),(0,p.jsx)(`div`,{className:`card-footer bg-transparent`,children:(0,p.jsxs)(`small`,{className:`text-muted d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`span`,{children:[`Created: `,RD(a.date_created,`DD MMM YYYY`)]}),a.last_update&&(0,p.jsxs)(`span`,{children:[`Updated: `,RD(a.last_update,`DD MMM YYYY`)]}),a.rooms.length>0&&(0,p.jsxs)(`span`,{children:[`Rooms:`,` `,a.rooms.map((e,t)=>(0,p.jsxs)(d.default.Fragment,{children:[t>0&&`, `,e.name]},e.id))]}),(0,p.jsxs)(`span`,{children:[`Owner: `,a.owner.full_name]})]})}),r&&t]})}function XD({messageList:e,refetchFn:t}){let[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex gap-3`,children:[(0,p.jsx)(`h2`,{children:`Messages`}),(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`secondary`,onClick:()=>{r((0,p.jsx)(JD,{showModal:!0,onClose:e=>{a(!1),t()}})),a(!0)},children:`New message`})})]}),e.map((e,t)=>(0,p.jsx)(`div`,{children:(0,p.jsx)(YD,{message:e})},e.id)),i&&n]})}function ZD({issue:e,moduleName:t,issueAttachments:n,equipment:r,reloadQueryFn:i}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),l=e=>{i([`issue`,`status_mail`]),i([`issue`,`attachment`,`status_mail`])},u=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:`align-middle`,children:[(0,p.jsx)(`td`,{className:`text-nowrap`,children:t??`-`}),(0,p.jsx)(`td`,{children:e.issue}),(0,p.jsx)(`td`,{children:(0,p.jsx)(MD,{children:e.description})}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:RD(e.forecast_up,`DD MMMM YYYY`)}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:e.owner.full_name}),(0,p.jsx)(`td`,{className:`text-center`,children:(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-outline-light`,onClick:()=>{if(!r){console.error(`equipment is null in the table`);return}c(!0),o((0,p.jsx)(VD,{equipment:r,showModal:!0,onClose:e=>{c(!1),e&&l(e)},issue:e,attachments:u()}))},children:`Edit`})})]},e.id),s&&a]})}function QD({issues:e,modules:t,issueAttachments:n,reloadQueryFn:r}){return(0,p.jsx)(`div`,{className:`table-responsive`,children:(0,p.jsxs)(`table`,{className:`table table-hover table-striped table-bordered table-sm`,children:[(0,p.jsx)(`thead`,{className:`bg-primary text-white`,children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{scope:`col`,children:`Module`}),(0,p.jsx)(`th`,{scope:`col`,children:`Issue`}),(0,p.jsx)(`th`,{scope:`col`,children:`Description`}),(0,p.jsx)(`th`,{scope:`col`,children:`Forecast Up`}),(0,p.jsx)(`th`,{scope:`col`,children:`Owner`}),(0,p.jsx)(`th`,{scope:`col`,className:`text-center`,children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:e.map(e=>(0,p.jsx)(ZD,{issue:e,moduleName:t.find(t=>t.id===e.module_id)?.name,issueAttachments:n,equipment:t.find(t=>t.id===e.module_id)?.equipment,reloadQueryFn:r},e.id))})]})})}function $D({statusMail:e}){let[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(!1);return(0,p.jsx)(U,{variant:`primary`,size:`sm`,onClick:async()=>{try{if(n(!0),!e.id||e.id<=0)throw Error(`Status Mail ID is not correctly set`);let t={status_mail:e.id};await f.default.post(`/send/status-mail`,t),i(!0)}catch(e){console.error(`Error sending status mail:`,e),alert(`Error sending status mail. Please try again.`)}finally{n(!1)}},disabled:t,"aria-label":`Toggle Details`,children:t?`Sending...`:r?`Sending successful`:`Send Status Mail`})}function eO(){let{statusMail:e}=(0,d.useContext)(uy),[t,n]=(0,d.useState)([]),r=(0,m.useQueryClient)(),i=(0,m.useQueries)({queries:[{queryKey:[`equipment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>N({statusMail:e})},{queryKey:[`module`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>re({statusMail:e})},{queryKey:[`ecn`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ee({statusMail:e})},{queryKey:[`issue`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ne({statusMail:e})},{queryKey:[`messages`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ae({statusMail:e})},{queryKey:[`ecn`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>F({statusMail:e})},{queryKey:[`issue`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>L({statusMail:e})},{queryKey:[`reservation`,`active`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ie({which:`active`})},{queryKey:[`reservation`,`upcoming`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ie({which:`upcoming`})}]}),a=t=>{let n=t;n.push(JSON.stringify(e.filter)),r.refetchQueries({queryKey:n})},[o,s,c,l,u,f,h,g,_]=i,v=i.some(e=>e.isLoading),y=i.some(e=>e.isError),b=i.every(e=>e.isSuccess);return(0,d.useEffect)(()=>{b&&n(o.data.items)},[b]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[`Status mail `,e.name]}),(0,p.jsx)(`div`,{children:(0,p.jsx)($D,{statusMail:e})})]}),(0,p.jsx)(`p`,{children:e.subject}),v&&(0,p.jsx)(Cr,{variant:`info`,children:`Loading status mail`}),y&&(0,p.jsx)(Cr,{variant:`danger`,children:`Error loading status mail`}),b&&e.show_issues_with_priority&&(()=>{let e=l.data.items.filter(e=>e.issue_type===2);return e.length===0?(0,p.jsx)(p.Fragment,{}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{children:`Issues with priority`}),(0,p.jsx)(QD,{issues:e,modules:s.data.items,issueAttachments:h.data.items,reloadQueryFn:a})]})})(),b&&u.data&&(0,p.jsx)(XD,{messageList:u.data.items,refetchFn:u.refetch}),b&&(()=>{if(!t.length)return(0,p.jsx)(`p`,{children:`No equipment available.`});let n=[...t].sort((t,n)=>e.classification===ft.ROOM?t.room.name.localeCompare(n.room.name):t.area&&n.area&&e.classification===ft.AREA?t.area.title.localeCompare(n.area.title):t.area&&n.area&&e.classification===ft.AREA_PER_FACILITY?t.area.facility.title.localeCompare(n.area.facility.title)||t.area.title.localeCompare(n.area.title):0),r,i=null,o=``;return n.map(t=>{let n=[];return e.classification===ft.ROOM?t.room.name!==o&&(n.push((0,p.jsxs)(`h2`,{children:[`Room: `,t.room.name]},`room-${t.room.name}`)),o=t.room.name):e.classification===ft.AREA?t.area&&t.area!==i&&(n.push((0,p.jsxs)(`h2`,{children:[`Area: `,t.area.title]},`area-${t.area.id}`)),i=t.area):e.classification===ft.AREA_PER_FACILITY&&(t.area&&t.area.facility!==r&&(n.push((0,p.jsxs)(`h2`,{children:[`Facility: `,t.area.facility.title]},`facility-${t.area.facility.id}`)),r=t.area.facility),t.area&&t.area!==i&&(n.push((0,p.jsxs)(`h4`,{children:[`Area: `,t.area.title]},`area-${t.area.id}`)),i=t.area)),n.push((0,p.jsx)(WD,{equipment:t,modules:s.data.items,issues:l.data.items,issueAttachments:h.data.items,ecnNotes:c.data.items,ecnAttachments:f.data.items,reloadQueryFn:a,showIssues:e.show_issues,reservations:e.show_reservations?g.data.items.concat(_.data.items):[]},t.id)),n})})()]})}function tO({monitor:e}){let{environment:t}=(0,g.useParams)(),[n]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,e],queryFn:()=>ue({monitorId:e.id})}]});return n.isLoading?(0,p.jsx)(`div`,{children:`Loading requirements...`}):n.data?.items.map(n=>{let r=`bg-secondary-subtle`;if(n.latest_result)for(let e=0;e<n.latest_result.values.length;e++){if(n.latest_result.values[e].value_is_valid===!1){r=`bg-danger-subtle`;break}if(n.latest_result.values[e].value_is_valid===!0){r=`bg-success-subtle`;break}}return(0,p.jsx)(W,{className:`mb-2 me-2`,children:(0,p.jsxs)(W.Body,{className:r,children:[(0,p.jsx)(W.Title,{children:(0,p.jsx)(g.Link,{to:`/${t}/operator/monitor/`+e.id,children:e.name})}),(0,p.jsxs)(W.Text,{children:[n.title,n.latest_result&&(0,p.jsxs)(p.Fragment,{children:[`Latest measurement: `,zD(n.latest_result.date_created,`DD-MM-YY HH:mm`)]})]})]})},n.id)})}function nO({show:e,onClose:t}){return(0,p.jsx)(Hl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Bl,{onClose:t,show:e,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Bl.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Assist logged`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Bl.Body,{children:`Assist was logged successfully`})]})})}var rO=({moduleId:e,size:t})=>{let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(``);function c(){f.default.create().post(`create/equipment/module/changelog`,{module:e,changelog:o}).finally(()=>{r(!1),a(!0),s(``)})}let l=e=>{s(e.target.value)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{variant:`primary`,size:t,onClick:()=>r(!0),children:`Log assist`}),(0,p.jsxs)(K,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Log assist`})}),(0,p.jsx)(K.Body,{children:(0,p.jsx)(G,{children:(0,p.jsxs)(G.Group,{className:`mb-3`,controlId:`modal.ControlTextarea1`,children:[(0,p.jsx)(G.Label,{children:`Describe the assist`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:3,value:o,onChange:e=>l(e)})]})})}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,variant:`primary`,onClick:()=>c(),children:`Log assist`}),(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{r(!1)},children:`Close`})]})]}),(0,p.jsx)(nO,{show:i,onClose:()=>a(!1)})]})},iO=(0,d.createContext)({equipment:{},reloadEquipment:()=>{}});function aO({issue:e,equipment:t,issueAttachments:n,reloadQueryFn:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(e),u=e=>{r([`issue`,t.name]),r([`issue`,`attachment`,t.name]),l({...c,...e})},f=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(W,{className:`my-2`,children:[(0,p.jsxs)(W.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(W.Title,{children:[(0,p.jsx)(wr,{bg:`dark`,children:`Issue`}),` `,c.issue]}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(VD,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},issue:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(W.Text,{children:(0,p.jsx)(MD,{children:c.description})})]}),(0,p.jsxs)(nc,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Created:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:zD(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Owner:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.owner.full_name})]}),c.updated_by&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Updated:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.updated_by.full_name}),(0,p.jsxs)(`span`,{className:`ms-1`,children:[`(`,zD(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},c.module_id),o&&i]})}function oO({ecn:e,equipment:t,ecnAttachments:n,reloadQueryFn:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(e),u=e=>{r([`ecn`,t.name]),r([`ecn`,`attachment`,t.name]),l({...c,...e})},f=()=>n.filter(t=>t.ecn.id===e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(W,{className:`my-2`,children:[(0,p.jsxs)(W.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(W.Title,{children:[(0,p.jsx)(wr,{bg:`dark`,children:`ECN`}),` `,e.ecn]}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(Qb,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},ecn:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(W.Text,{children:(0,p.jsx)(MD,{children:e.description})})]}),(0,p.jsxs)(nc,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Created:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:zD(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Owner:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.owner.full_name})]}),c.updated_by&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Updated:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.updated_by.full_name}),(0,p.jsxs)(`span`,{className:`ms-1`,children:[`(`,zD(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},e.module_id),o&&i]})}var sO=e=>{if(e<60)return`${e} min`;let t=Math.floor(e/60),n=e%60;return`${t}h ${n>0?`${n}min`:``}`.trim()};function cO(){let{id:e}=(0,g.useParams)(),[t,n]=(0,d.useState)([]),r=(0,m.useQueries)({queries:[{queryKey:[`service`,`equipment`,e],queryFn:()=>qe({equipmentId:Number(e)})}]}),[i]=r,a=r.some(e=>e.isLoading),o=r.some(e=>e.isError),s=r.every(e=>e.isSuccess);return(0,d.useEffect)(()=>{s&&n(i.data.items)},[s,i.data]),a?(0,p.jsx)(`div`,{children:`Loading...`}):o?(0,p.jsx)(`div`,{children:`Error loading services.`}):i.data.items.length===0?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsx)(Cr,{variant:`info`,children:`No services found`})]}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsxs)(Nl,{striped:!0,bordered:!0,hover:!0,responsive:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Id`}),(0,p.jsx)(`th`,{children:`Name`}),(0,p.jsx)(`th`,{children:`Type`}),(0,p.jsx)(`th`,{children:`Team`}),(0,p.jsx)(`th`,{children:`Department`}),(0,p.jsx)(`th`,{children:`Duration`}),(0,p.jsx)(`th`,{children:`Report2`})]})}),(0,p.jsx)(`tbody`,{children:t.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.id}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${window.location.pathname.split(`/`)[1]}/service/details/${e.id}/general.html`,children:e.name})}),(0,p.jsx)(`td`,{children:e.type?.name||`N/A`}),(0,p.jsx)(`td`,{children:e.team?.name||`N/A`}),(0,p.jsx)(`td`,{children:e.department?.name||`N/A`}),(0,p.jsx)(`td`,{children:sO(e.minutes_needed_for_service)}),(0,p.jsx)(`td`,{children:e.latest_event_report_id&&(0,p.jsx)(`a`,{className:`btn btn-primary btn-sm`,href:`/${window.location.pathname.split(`/`)[1]}/service/event/report/${e.latest_event_report_id}/results`,children:`View Report`})})]},e.id))})]})]})}function lO(){let{environment:e}=(0,g.useParams)(),{equipment:t}=(0,d.useContext)(iO),n=(0,m.useQueryClient)(),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(!1),[f,h,_,v,y,b,x]=(0,m.useQueries)({queries:[{queryKey:[`runs`,t.name,e],queryFn:()=>je({firstUnfinishedStepEquipment:t,environment:e})},{queryKey:[`monitors`,t.name],queryFn:()=>de({equipment:t})},{queryKey:[`ecn`,t.name],queryFn:()=>ee({equipment:t})},{queryKey:[`issue`,t.name],queryFn:()=>ne({equipment:t})},{queryKey:[`module`,t.name],queryFn:()=>re({equipment:t})},{queryKey:[`ecn`,`attachment`,t.name],queryFn:()=>F({equipment:t})},{queryKey:[`issue`,`attachment`,t.name],queryFn:()=>L({equipment:t})}]}),S=e=>{n.invalidateQueries({queryKey:e})},C=e=>e?_.data?.items.filter(t=>t.module_id===e):[],w=e=>e?v.data?.items.filter(t=>t.module_id===e):[],T=()=>{c((0,p.jsx)(Qb,{equipment:t,showModal:!0,onClose:()=>{u(!1),setTimeout(()=>{S([`ecn`,t.name]),S([`ecn`,`attachment`,t.name])},100)}})),u(!0)},E=()=>{i((0,p.jsx)(VD,{equipment:t,showModal:!0,onClose:()=>{o(!1),setTimeout(()=>{S([`issue`,t.name]),S([`issue`,`attachment`,t.name])},100)}})),o(!0)};return(0,p.jsxs)(Jr,{fluid:!0,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-left`,children:h.data?.items&&h.data.items.map(e=>(0,p.jsx)(tO,{monitor:e},e.id))}),(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{md:8,children:[(0,p.jsx)(`h2`,{children:`Runs`}),f.isLoading&&(0,p.jsx)(`div`,{children:`Loading...`}),` `,f.isError&&(0,p.jsx)(`div`,{children:`Error...`}),f.isFetched&&f.data&&f.data?.items.length===0&&(0,p.jsx)(Cr,{variant:`info`,children:`No runs found`}),f.isFetched&&f.data&&f.data?.items.length>0&&(0,p.jsxs)(Nl,{striped:!0,bordered:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Run`}),(0,p.jsx)(`th`,{children:`Priority`}),(0,p.jsx)(`th`,{children:`Hold Code`}),(0,p.jsx)(`th`,{children:`Batch Card`}),(0,p.jsx)(`th`,{children:`Project`})]})}),(0,p.jsx)(`tbody`,{children:f.data?.items.map(t=>(0,p.jsxs)(`tr`,{children:[(0,p.jsxs)(`td`,{children:[t.first_unfinished_step&&(0,p.jsx)(g.Link,{to:`/${e}/operator/run/step/${t.first_unfinished_step.id}`,children:t.name}),t.first_unfinished_step===void 0&&t.last_finished_step&&(0,p.jsx)(g.Link,{to:`/${e}/operator/run/step/${t.last_finished_step.id}`,children:t.name})]}),(0,p.jsxs)(`td`,{children:[t.priority&&(0,p.jsx)(`span`,{className:`badge`,style:{backgroundColor:t.priority.priority.back_color,color:t.priority.priority.front_color},children:t.priority.priority.code}),!t.priority&&(0,p.jsx)(`span`,{className:`badge bg-info`,children:`NORMAL`})]}),(0,p.jsx)(`td`,{children:t.hold_code&&(0,p.jsx)(`span`,{className:`badge handle`,style:{backgroundColor:t.hold_code.hold_code.back_color,color:t.hold_code.hold_code.front_color},children:t.hold_code.hold_code.code})}),(0,p.jsx)(`td`,{children:t.batch_card&&t.batch_card.content&&(0,p.jsx)(`span`,{className:`text-danger`,children:t.batch_card.content})}),(0,p.jsx)(`td`,{children:t.project.name})]},t.id))})]}),(0,p.jsx)(cO,{})]}),(0,p.jsxs)(qr,{md:4,children:[(0,p.jsx)(`h2`,{children:`Assistance`}),y.data?.items.map(e=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`h3`,{children:e.id===t.main_tool_module_id?`Main tool`:e.name}),(0,p.jsx)(`div`,{children:(0,p.jsx)(Ld,{module:e,refetchFn:()=>S([`module`,t.name])})})]}),(0,p.jsxs)(`div`,{className:`pb-lg-5`,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between`,children:(0,p.jsxs)(`div`,{className:`d-flex gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`primary`,size:`sm`,onClick:E,children:`New Issue`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`primary`,size:`sm`,onClick:T,children:`New ECN`})}),(0,p.jsx)(`div`,{children:e.id===t.main_tool_module_id&&(0,p.jsx)(rO,{size:`sm`,moduleId:e.id})})]})}),C(e.id)?.map(e=>(0,p.jsx)(oO,{ecn:e,equipment:t,ecnAttachments:b.data?.items??[],reloadQueryFn:S},e.id)),w(e.id)?.map(e=>(0,p.jsx)(aO,{issue:e,equipment:t,issueAttachments:x.data?.items??[],reloadQueryFn:S},e.id))]})]},e.id))]})]}),l&&s,a&&r]})}var uO=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&k({id:parseInt(n)}).then(t)},[n,e]);function r(){k({id:parseInt(n)}).then(t)}return{equipment:e,setEquipment:t,reloadEquipment:r}};function dO({children:e}){let{equipment:t,reloadEquipment:n}=uO();return t===null?(0,p.jsx)(Ot,{children:(0,p.jsx)(Ct,{message:`Loading equipment...`})}):(0,p.jsx)(Ot,{children:(0,p.jsx)(iO.Provider,{value:{equipment:t,reloadEquipment:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}function fO(){let{equipment:e}=(0,d.useContext)(iO),t=(0,m.useQueries)({queries:[{queryKey:[`activeReservationQuery`,e],queryFn:()=>ie({equipment:e,which:`active`})},{queryKey:[`upcomingReservationQuery`,e],queryFn:()=>ie({equipment:e,which:`upcoming`})},{queryKey:[`modules`,e],queryFn:()=>re({equipment:e})}]}),[n,r,i]=t,a=t.some(e=>e.isLoading),o=t.every(e=>e.isSuccess);return a?(0,p.jsx)(`div`,{children:`Loading...`}):o&&(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between mb-3`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[e.name,` Operator Dashboard`]}),(0,p.jsxs)(`div`,{children:[n.data?.items.map(e=>(0,p.jsxs)(`div`,{className:`mx-2 p-2 rounded border-danger`,style:{backgroundColor:e.color},children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-o text-white pe-2`,"aria-hidden":`true`}),`Active reservation`,(0,p.jsx)(`br`,{}),`Until `,zD(e.end,`DD-MM-YY HH:mm`),` by `,e.user.full_name]},e.id)),r.data?.items.map(e=>(0,p.jsxs)(`div`,{className:`mx-2 p-2 rounded border-success border-2`,style:{backgroundColor:e.color},children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-o text-white pe-2`,"aria-hidden":`true`}),`Next reservation`,(0,p.jsx)(`br`,{}),zD(e.start,`DD-MM-YY HH:mm`),(0,p.jsx)(`br`,{}),e.user.full_name]},e.id))]})]})}function pO(){return(0,p.jsxs)(dO,{children:[(0,p.jsx)(fO,{}),(0,p.jsx)(g.Outlet,{})]})}function mO({children:e}){let{id:t}=(0,g.useParams)(),{data:n,isFetching:r,isLoading:i}=(0,m.useQuery)({queryKey:[`statusMail`,t],queryFn:()=>j({id:parseInt(t)}),enabled:!!t});return i||r?(0,p.jsx)(Ot,{children:(0,p.jsx)(Ct,{message:`Loading status mail...`})}):(0,p.jsx)(Ot,{children:(0,p.jsx)(uy.Provider,{value:{statusMail:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}var hO=()=>yt(),gO,_O;function vO(e){let[t,n]=(0,d.useState)(!0),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),s=()=>{n(!1),o(!0)};return(0,d.useEffect)(()=>{if(!document){let t=Error(`[ScriptLoadingError] document not defined when attempting to load ${e}`);i(t);return}let t=document.querySelector(`script[src="${e}"]`);if(t?.dataset.loaded){s();return}let n=t||document.createElement(`script`);t||(n.src=e),n.addEventListener(`load`,()=>{n.dataset.loaded=`1`,s()}),n.addEventListener(`error`,t=>{console.error(`Failed to load script:`,e,t);let n=Error(`[ScriptLoadingError] Failed to load script: ${e}`);i(n)}),t||document.head.append(n)},[]),{isLoading:t,error:r,isSuccess:a}}var yO=e=>e&&e.charts,bO=(e,t)=>{let{controls:n,toolbarItems:r,getChartEditor:i}=e;return t&&t.charts&&t.visualization&&t.visualization.ChartWrapper&&t.visualization.Dashboard&&(!n||t.visualization.ChartWrapper)&&(!i||t.visualization.ChartEditor)&&(!r||t.visualization.drawToolbar)},xO=e=>window.google;function SO(e){let{chartVersion:t=`current`,chartPackages:n=[`corechart`,`controls`],chartLanguage:r=`en`,mapsApiKey:i}=e,[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),{isLoading:f,error:p,isSuccess:m}=vO(e.chartLoaderScriptUrl||`https://www.gstatic.com/charts/loader.js`);return(0,d.useEffect)(()=>{if(!m)return;let a=xO();if(!yO(a)){c(Error(`[ScriptInitializationError] Script loaded but Google not attached to window.`));return}if(bO(e,a)){o(a);return}a.charts.load(t,{packages:n,language:r,mapsApiKey:i}),a.charts.setOnLoadCallback(()=>{if(!bO(e,a)){let e=Error(`[GoogleChartsInitializationError] Google Charts not ready after load callback.`);console.error(e),u(e);return}o(a)})},[m]),{error:p||s||l,isLoading:f,google:a}}var CO={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:`https://www.gstatic.com/charts/loader.js`},wO=e=>{let{isReady:t,chartControls:n,filter:r}=e;return!t||!n||!n?.length?null:d.default.createElement(d.default.Fragment,null,n.filter(e=>{let{controlProp:t,control:n}=e;return!r||r({control:n,controlProp:t})}).map(e=>{let{control:t}=e;return d.default.createElement(`div`,{key:t.getContainerId(),id:t.getContainerId()})}))},TO=0,EO=()=>(TO+=1,`reactgooglegraph-${TO}`),DO=class{};gO=DO,Dt(DO,`initializeControls`,e=>{for(let t=0;t<e.length;t+=1){let{controlType:n,options:r,controlWrapperParams:i}=e[t].controlProp;i&&`state`in i&&e[t].control.setState(i.state),e[t].control.setOptions(r),e[t].control.setControlType(n)}}),Dt(DO,`listenToControlEvents`,(e,t)=>{let{google:n}=t;return e.flatMap(e=>{let{control:r,controlProp:i}=e,{controlEvents:a=[]}=i;return a.map(e=>{let{callback:i,eventName:a}=e;return n.visualization.events.addListener(r,a,function(){for(var e=arguments.length,a=Array(e),o=0;o<e;o++)a[o]=arguments[o];i({chartWrapper:null,controlWrapper:r,props:t,google:n,eventArgs:a})})})})}),Dt(DO,`createControlId`,e=>{let t;return t=e===void 0?`googlechart-control-${EO()}`:e,t}),Dt(DO,`createChartControls`,e=>{let{controls:t,google:n}=e;return t?t.map((e,t)=>{let{controlID:r,controlType:i,options:a,controlWrapperParams:o}=e,s=gO.createControlId(r);return{controlProp:e,control:new n.visualization.ControlWrapper({containerId:s,controlType:i,options:a,...o})}}):null}),Dt(DO,`addControls`,e=>{let{chartWrapper:t,chartDashboard:n}=e,r=gO.createChartControls(e);return!r||!n||!t?null:(n.bind(r.map(e=>{let{control:t}=e;return t}),t),gO.initializeControls(r),r)});var OO=e=>{let[t,n]=d.useState(null);return[d.useMemo(()=>!t||!e?null:e.map((e,n)=>{let r=t[n];return r?{controlProp:e,control:r}:void 0}).flatMap(e=>e?[e]:[]),[t,e]),n]},kO=(e,t)=>{d.useEffect(()=>{let n=DO.listenToControlEvents(e??[],t);return()=>{n.forEach(e=>{t.google.visualization.events.removeListener(e)})}},[e,t])},AO=e=>{let[t,n]=OO(e.controls);return kO(t??[],e),{addControls:e=>{let t=DO.addControls(e);n(t?.map(e=>e.control)??null)},renderControl:n=>{let{chartWrapper:r,chartDashboard:i}=e;return d.createElement(wO,{...e,isReady:!!(r&&i),chartControls:t,filter:n})}}},jO=e=>{let t=d.useRef(null);return{chartId:(()=>{let{graphID:n,graph_id:r}=e,i=n||r,a;return a=i||t.current||EO(),t.current=a,t.current})()}},MO=[`#3366CC`,`#DC3912`,`#FF9900`,`#109618`,`#990099`,`#3B3EAC`,`#0099C6`,`#DD4477`,`#66AA00`,`#B82E2E`,`#316395`,`#994499`,`#22AA99`,`#AAAA11`,`#6633CC`,`#E67300`,`#8B0707`,`#329262`,`#5574A6`,`#3B3EAC`],NO=async function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return new Promise((r,i)=>{let a=`${n.headers?`headers=${n.headers}`:`headers=0`}`,o=`${n.query?`&tq=${encodeURIComponent(n.query)}`:``}`,s=`${t}/gviz/tq?${`${a}${`${n.gid?`&gid=${n.gid}`:``}`}${`${n.sheet?`&sheet=${n.sheet}`:``}`}${o}${`${n.access_token?`&access_token=${n.access_token}`:``}`}`}`;new e.visualization.Query(s).send(e=>{e.isError()?i(`Error in query: ${e.getMessage()} ${e.getDetailedMessage()}`):r(e.getDataTable())})})},PO=`#CCCCCC`,FO=class{};_O=FO,Dt(FO,`grayOutHiddenColumnsLabel`,(e,t)=>{let{googleChartWrapper:n,options:r}=e;if(!n){console.error(`googleChartWrapper is not defined`);return}let i=n.getDataTable();if(!i)return;let a=i.getNumberOfColumns();if(!(t.length>0))return;let o=Array.from({length:a-1}).map((e,n)=>{let a=_O.getColumnId(i,n+1);return t.includes(a)?PO:r&&r.colors?r.colors[n]:MO[n]});n.setOptions({...r,colors:o}),n.draw()}),Dt(FO,`listenToLegendToggle`,(e,t)=>{let[n,r]=t,{google:i,googleChartWrapper:a}=e;if(!a){console.error(`googleChartWrapper is not defined`);return}return i.visualization.events.addListener(a,`select`,()=>{let e=a.getChart().getSelection(),t=a.getDataTable();if(e.length===0||e[0].row!==null||!t)return;let i=e[0].column,o=_O.getColumnId(t,i);n?.includes(o)?r(e=>[...e.filter(e=>e!==o)]):r(e=>[...e,o])})}),Dt(FO,`draw`,async e=>{let{data:t,diffdata:n,rows:r,columns:i,options:a,chartType:o,formatters:s,spreadSheetUrl:c,spreadSheetQueryParameters:l,googleChartDashboard:u,googleChartWrapper:d,google:f,hiddenColumns:p,legendToggle:m,legend_toggle:h}=e;if(!d){console.error(`draw was called with googleChartWrapper = null`);return}let g,_=null;if(n){let e=f.visualization.arrayToDataTable(n.old),t=f.visualization.arrayToDataTable(n.new);_=f.visualization[o].prototype.computeDiff(e,t)}g=t?t instanceof f.visualization.DataTable?t:Array.isArray(t)?f.visualization.arrayToDataTable(t):new f.visualization.DataTable(t):r&&i?f.visualization.arrayToDataTable([i,...r]):c?await NO(f,c,l):f.visualization.arrayToDataTable([]);let v=g.getNumberOfColumns(),y=Array(v).fill(0).map((e,t)=>{let n=_O.getColumnId(g,t);return p.includes(n)?{label:g.getColumnLabel(t),type:g.getColumnType(t),calc:()=>null}:t}),b=d.getChart();d.getChartType()===`Timeline`&&b&&b.clearChart(),d.setChartType(o),d.setOptions(a||{});let x=new f.visualization.DataView(g);x.setColumns(y),d.setDataTable(x),d.draw(),u&&u.draw(g),_&&(d.setDataTable(_),d.draw()),s&&(_O.applyFormatters({dataTable:g,formatters:s,google:f}),d.setDataTable(g),d.draw()),(m===!0||h===!0)&&_O.grayOutHiddenColumnsLabel(e,p)}),Dt(FO,`getColumnId`,(e,t)=>e.getColumnId(t)||e.getColumnLabel(t)),Dt(FO,`applyFormatters`,e=>{let{dataTable:t,formatters:n,google:r}=e;for(let e of n)switch(e.type){case`ArrowFormat`:new r.visualization.ArrowFormat(e.options).format(t,e.column);return;case`BarFormat`:new r.visualization.BarFormat(e.options).format(t,e.column);return;case`ColorFormat`:{let n=new r.visualization.ColorFormat(e.options),{ranges:i}=e;if(i)for(let e of i)n.addRange(...e);n.format(t,e.column);return}case`DateFormat`:new r.visualization.DateFormat(e.options).format(t,e.column);return;case`NumberFormat`:new r.visualization.NumberFormat(e.options).format(t,e.column);return;case`PatternFormat`:new r.visualization.PatternFormat(e.options).format(t,e.column);return;default:console.warn(`Unknown formatter type: ${e.type}`);return}});var IO=e=>{let{google:t,googleChartWrapper:n,googleChartDashboard:r}=e,[i,a]=d.useState([]);d.useEffect(()=>{n&&FO.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t})},[i,e.data,e.rows,e.columns,e.options,e.chartLoaderScriptUrl,e.chartType,e.formatters,e.spreadSheetUrl,e.spreadSheetQueryParameters,e.legendToggle,e.legend_toggle]);let o=()=>{let{googleChartWrapper:t}=e;t&&t.draw()},s=n=>{let s=[],{legendToggle:c,legend_toggle:l}=e;if(FO.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t}),window.addEventListener(`resize`,o),l||c){let t=FO.listenToLegendToggle(e,[i,a]);t&&s.push(t)}return s},c=(e,n)=>{window.removeEventListener(`resize`,o),n.forEach(e=>{t.visualization.events.removeListener(e)}),e.getChartType()===`Timeline`&&e.getChart()&&e.getChart().clearChart()};d.useEffect(()=>{if(!n)return;let e=s(n);return()=>{c(n,e)}},[n,s,c])},LO=e=>{let{chartEvents:t,google:n,googleChartWrapper:r}=e;if(t){if(!r){console.warn(`listenToEvents was called before chart wrapper ready.`);return}return t.map(t=>{let{eventName:i,callback:a}=t;return n.visualization.events.addListener(r,i,function(){for(var t=arguments.length,i=Array(t),o=0;o<t;o++)i[o]=arguments[o];a({chartWrapper:r,props:e,google:n,eventArgs:i})})})}},RO=e=>{(0,d.useEffect)(()=>{if(!e.googleChartWrapper)return;let t=LO(e);return()=>{t?.forEach(t=>{e.google.visualization.events.removeListener(t)})}},[e])},zO=e=>{let[t,n]=d.useState(null),[r,i]=d.useState(null),{addControls:a,renderControl:o}=AO({...e,chartDashboard:r,chartWrapper:t});RO({...e,googleChartWrapper:t});let{chartId:s}=jO(e),c=d.useRef(null),l=d.useRef(null);d.useEffect(()=>{let{options:t,google:r,chartType:o,chartWrapperParams:u,toolbarItems:d,getChartEditor:f,getChartWrapper:p,onLoad:m}=e,h={chartType:o,options:t,containerId:s,...u},g=new r.visualization.ChartWrapper(h);g.setOptions(t||{}),p?.(g,r);let _=new r.visualization.Dashboard(c.current);d&&r.visualization.drawToolbar(l.current,d);let v=null;f&&(v=new r.visualization.ChartEditor,f({chartEditor:v,chartWrapper:g,google:r})),a({...e,chartDashboard:_,chartWrapper:g}),n(g),i(_),m?.(r,{google:r,chartWrapper:g,chartEditor:v,chartDashboard:_})},[]),IO({...e,googleChartWrapper:t,googleChartDashboard:r});let u=()=>{let{width:t,height:n,options:r,style:i,className:a,rootProps:o,google:c}=e,l={height:n||r&&r.height,width:t||r&&r.width,...i};return d.createElement(`div`,{id:s,style:l,className:a,...o})},f=()=>e.toolbarItems?d.createElement(`div`,{ref:l}):null,{width:p,height:m,options:h,style:g}=e,_={height:m||h&&h.height,width:p||h&&h.width,...g};return e.render?d.createElement(`div`,{ref:c,style:_},d.createElement(`div`,{ref:l,id:`toolbar`}),e.render({renderChart:u,renderControl:o,renderToolbar:f})):d.createElement(`div`,{ref:c,style:_},o(e=>{let{controlProp:t}=e;return t.controlPosition!==`bottom`}),u(),o(e=>{let{controlProp:t}=e;return t.controlPosition===`bottom`}),f())},BO=d.createContext(CO),VO=e=>{let{children:t,value:n}=e;return d.createElement(BO.Provider,{value:n},t)},HO=e=>{let{google:t,isLoading:n,error:r}=SO(e);return n?e.loader??null:r?e.errorElement??null:t?d.default.createElement(zO,{google:t,...e}):null},UO=e=>{let t={...CO,...e};return d.default.createElement(VO,{value:t},d.default.createElement(HO,t))},WO;(function(e){e.annotation=`annotation`,e.annotationText=`annotationText`,e.certainty=`certainty`,e.emphasis=`emphasis`,e.interval=`interval`,e.scope=`scope`,e.style=`style`,e.tooltip=`tooltip`,e.domain=`domain`})(WO||(WO={}));function GO({target:e,results:t}){let n={title:e.logging_parameter.name,curveType:`function`,series:{0:{pointSize:10},1:{},2:{},3:{}},legend:{position:`bottom`}},r=[[{type:`date`,label:`Date`},`Value`]],i=1;return e.target&&(r[0].push(`Target`),n.series[i]={color:`#38e22c`,lineWidth:2,pointShape:{type:`square`}},i++),e.min_value&&(r[0].push(`Min`),n.series[i]={color:`#e2431e`,lineWidth:2,pointShape:{type:`triangle`},pointSize:10},i++),e.max_value&&(r[0].push(`Max`),n.series[i]={color:`#e2431e`,lineWidth:2,pointShape:{type:`triangle`,rotation:180},pointSize:10}),t.forEach(t=>{for(let n of t.values){if(n.logging_parameter.id!==e.logging_parameter.id||n.float_value===0)continue;let i=new Date(t.date_created);r.push([i,n.float_value]),e.target&&r[r.length-1].push(e.target),e.min_value&&r[r.length-1].push(e.min_value),e.max_value&&r[r.length-1].push(e.max_value)}}),r.length===1?(0,p.jsx)(`div`,{className:`text-center`,children:`No data available`}):(0,p.jsx)(UO,{chartType:`ScatterChart`,width:`100%`,height:`400px`,data:r,options:n})}var KO=({data:e,setPage:t,setPageSize:n,pageSize:r,isPlaceholderData:i})=>{if(e===void 0||i)return(0,p.jsx)(p.Fragment,{});let a=[];for(let n=1;n<=e.amountOfPages;n++)a.push((0,p.jsx)(Dl.Item,{active:n===e.currentPage,onClick:()=>t(e=>n),children:n},n));return(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`div`,{className:`d-flex gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{size:`sm`,onClick:()=>t(e=>Math.max(e-1,0)),disabled:e.currentPage===1,children:`Previous Page`})}),(0,p.jsx)(Dl,{size:`sm`,children:a.map((e,t)=>(0,p.jsx)(`div`,{children:e},t))}),(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{size:`sm`,onClick:()=>{!i&&e.hasMore&&t(e=>e+1)},disabled:i||!e.hasMore,children:`Next Page`})})]}),n===void 0?null:(0,p.jsx)(`div`,{children:(0,p.jsxs)(G.Select,{onChange:e=>{n(t=>parseInt(e.target.value))},value:r,size:`sm`,children:[(0,p.jsx)(`option`,{value:10,children:`10`}),(0,p.jsx)(`option`,{value:25,children:`25`}),(0,p.jsx)(`option`,{value:50,children:`50`}),(0,p.jsx)(`option`,{value:100,children:`100`})]})})]})};function qO({show:e,onClose:t}){return(0,p.jsx)(Hl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Bl,{onClose:t,show:e,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Bl.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Bl.Body,{children:`Measurement results were saved successfully`})]})})}var JO=new Date().toISOString().split(`T`)[0],YO=({requirement:e,targets:t,refetchResults:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),{control:l,register:u,handleSubmit:m,reset:h,watch:g,formState:{errors:_,isValid:v}}=Id({defaultValues:{date:JO}}),{fields:y,append:b,remove:x}=Fd({control:l,name:`results`,rules:{required:!0}});(0,d.useEffect)(()=>{x(),t.forEach(e=>{b({id:e.id,label:e.logging_parameter.name,logging_parameter_id:e.logging_parameter.id,value:``})})},[t]),(0,d.useEffect)(()=>{c(v)},[g(),v]);async function S(t){await f.default.post(`create/monitor/requirement/result`,{requirement:e.id,date:t.date,values:t.results}),o(!0),i(!1),n(),h()}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{variant:`primary`,onClick:()=>i(!0),children:`Add manual result`}),(0,p.jsx)(K,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(G,{onSubmit:m(e=>S(e)),validated:s,children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Add manual result`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Date`}),(0,p.jsx)(G.Control,{type:`date`,placeholder:`Date`,required:!0,...u(`date`,{required:`This field is required`})},`date`),_.date&&(0,p.jsx)(G.Control.Feedback,{children:_.date.message})]}),y.map((e,t)=>(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:e.label}),(0,p.jsxs)(zs,{hasValidation:!0,children:[(0,p.jsx)(G.Control,{type:`number`,step:.01,placeholder:e.label,required:!0,...u(`results.${t}.value`,{required:`This field is required`})},e.id),_?.results?.[t]?.value&&(0,p.jsx)(G.Control.Feedback,{children:_.results[t].value.message})]})]},e.id))]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{h(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(qO,{show:a,onClose:()=>o(!1)})]})};function XO({show:e,onClose:t}){return(0,p.jsx)(Hl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Bl,{onClose:t,show:e,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Bl.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Bl.Body,{children:`Measurement results were saved successfully`})]})})}var ZO=({requirement:e,result:t,refetchMonitorStepParameterValues:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)([]),{control:m,register:h,handleSubmit:g,reset:_,watch:v,formState:{errors:y,isValid:b}}=Id({defaultValues:{}});(0,d.useEffect)(()=>{async function n(){let[n,r,i]=await Promise.all([pe({result:t}),ge({requirement:e}),te({module:e.step.process_module.module})]);r.items=r.items.filter(e=>!n.items.map(e=>e.step_parameter.id).includes(e.id)),r.items=r.items.filter(e=>i.items.map(e=>e.parameter.id).includes(e.parameter.id)),u(r.items)}r&&n()},[r]),(0,d.useEffect)(()=>{c(b)},[v(),b]);async function x(e){await f.default.post(`create/monitor/requirement/result/step-parameter-value`,{result:t.id,step_parameter:e.module_step_parameter_id,value:e.value}),o(!0),i(!1),n(),_()}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{variant:`primary`,size:`sm`,onClick:()=>i(!0),children:`+`}),(0,p.jsx)(K,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(G,{onSubmit:g(e=>x(e)),validated:s,children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Add process parameter`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Date`}),(0,p.jsx)(G.Control,{type:`text`,value:t.date_created,readOnly:!0})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Module Step Parameter`}),(0,p.jsxs)(G.Select,{...h(`module_step_parameter_id`,{required:!0}),children:[(0,p.jsx)(`option`,{value:``,children:`— Select a parameter`}),l.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.parameter.name},e.id))]}),(0,p.jsx)(G.Text,{className:`text-muted`,children:`Only parameters are shown here which are active on the Equipment Module and in the monitor step. In case parameters are missing you should replace the process in the monitor with the same process from the process library to reload the parameters`})]}),(0,p.jsxs)(zs,{hasValidation:!0,children:[(0,p.jsx)(G.Control,{type:`number`,step:.01,required:!0,...h(`value`,{required:`This field is required`})}),y?.value&&(0,p.jsx)(G.Control.Feedback,{children:y.value.message})]})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{_(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(XO,{show:a,onClose:()=>o(!1)})]})};function QO({show:e,onClose:t}){return(0,p.jsx)(Hl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Bl,{onClose:t,show:e,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Bl.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Bl.Body,{children:`Measurement results were saved successfully`})]})})}var $O=({monitorResultStepParameterValue:e,refetchMonitorStepParameterValues:t})=>{let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(!1),{control:c,register:l,handleSubmit:u,reset:m,watch:h,formState:{errors:g,isValid:_}}=Id({defaultValues:{value:e.value.toString()}});(0,d.useEffect)(()=>{s(_)},[h(),_]);async function v(n){await f.default.patch(`update/monitor/requirement/result/step-parameter-value/`+e.id,{value:n.value}),a(!0),r(!1),t(),m()}async function y(){await f.default.delete(`delete/monitor/requirement/result/step-parameter-value/`+e.id,{}),a(!0),r(!1),t(),m()}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{role:`button`,tabIndex:0,onClick:()=>r(!0),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},children:e.value}),(0,p.jsx)(K,{show:n,size:`lg`,onHide:()=>r(!1),children:(0,p.jsxs)(G,{onSubmit:u(e=>v(e)),validated:o,children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Add process parameter`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Date`}),(0,p.jsx)(G.Control,{type:`text`,value:e.date_created,readOnly:!0})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Module Step Parameter`}),(0,p.jsx)(G.Control,{type:`text`,value:e.step_parameter.parameter.name,readOnly:!0})]}),(0,p.jsxs)(zs,{hasValidation:!0,children:[(0,p.jsx)(G.Control,{type:`number`,step:.01,required:!0,...l(`value`,{required:`This field is required`})}),g?.value&&(0,p.jsx)(G.Control.Feedback,{children:g.value.message})]})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,type:`submit`,variant:`primary`,children:`Update value`}),(0,p.jsx)(U,{className:`float-end`,variant:`danger`,onClick:()=>y(),children:`Delete value`}),(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{m(),r(!1)},children:`Close`})]})]})}),(0,p.jsx)(QO,{show:i,onClose:()=>a(!1)})]})};function ek({requirement:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(1),[a,o]=(0,d.useState)(15),[s,c,l,u]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`files`,e.step,11],queryFn:()=>he({step:e.step,pageSize:11,order:`date-created`,direction:`desc`})},{queryKey:[`requirement`,`target`,e],queryFn:()=>me({requirement:e})},{queryKey:[`requirement`,`results`,e,r,a],queryFn:()=>fe({requirement:e,pageSize:a,order:`date-created`,direction:`desc`,page:r}),placeholderData:m.keepPreviousData},{queryKey:[`requirement`,`monitor_step_parameters`,e,r,a],queryFn:()=>pe({requirement:e,pageSize:a,order:`date-created`,direction:`desc`,page:r}),placeholderData:m.keepPreviousData}]}),h=(0,d.useMemo)(()=>u.data?Array.from(new Map(u.data.items.map(e=>[e.step_parameter.id,e.step_parameter])).values()):[],[u.data]),g=s.data?.items??[],{getRootProps:_,getInputProps:v,isDragActive:y,isDragAccept:b,isDragReject:x}=Hb({onDrop:(0,d.useCallback)(t=>{t.forEach(t=>{let r=new FileReader;r.onload=async()=>{let i=r.result;try{await f.default.create().post(`update/monitor/requirement/upload-file/`+e.id,{content:i,filename:t.name,type:t.type})}catch(e){n(`Upload failed due to: `+e.response.data.detail)}await s.refetch(),await l.refetch()},r.readAsDataURL(t)})},[e.id,s,l])}),S=(0,d.useMemo)(()=>({...y?{borderColor:`#83afee`}:{},...b?{borderColor:`#00e676`}:{},...x?{borderColor:`#ff1744`}:{}}),[b,x,y]);return c.isLoading||c.isFetching?(0,p.jsx)(Cr,{variant:`info`,children:`Loading targets...`}):l.isLoading||l.isFetching?(0,p.jsx)(Cr,{variant:`info`,children:`Loading results...`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`h1`,{className:`display-5`,children:[`Requirement: `,e.title]}),(0,p.jsx)(`p`,{className:`lead`,children:e.definition}),(0,p.jsx)(jl,{className:`my-3`,children:(0,p.jsxs)(qr,{children:[(0,p.jsx)(`h2`,{children:`Charts`}),(0,p.jsx)(`div`,{className:`d-flex`,children:c.data?.items.map(e=>(0,p.jsx)(GO,{target:e,results:l.data.items},e.id))})]})}),(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{md:8,children:[e.method&&e.method!==`-`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{children:`Method`}),(0,p.jsx)(`p`,{children:e.method})]}),c.data?.items.length===0&&(0,p.jsx)(Cr,{variant:`danger`,children:`No targets found`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`h2`,{children:`Results`}),(0,p.jsx)(`div`,{children:(0,p.jsx)(YO,{requirement:e,targets:c.data.items,refetchResults:l.refetch})})]}),(0,p.jsxs)(Nl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:[(0,p.jsxs)(`thead`,{children:[(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`Date`}),c.data?.items.map(e=>(0,p.jsx)(`th`,{children:e.logging_parameter.name},e.id)),h.map(e=>(0,p.jsx)(`th`,{children:e.parameter.name},e.id)),(0,p.jsx)(`th`,{children:`+`})]}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2}),c.data?.items.map(e=>(0,p.jsxs)(`td`,{children:[e.min_value,e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`≤`}),!e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`<`}),e.target??`X`,e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`≥`}),!e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`>`}),e.max_value]},e.id)),h.map(e=>(0,p.jsx)(`th`,{className:`table-secondary`},e.id)),(0,p.jsx)(`th`,{})]})]}),(0,p.jsx)(`tbody`,{children:l.data?.items.map(t=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t.id})}),(0,p.jsx)(`td`,{children:zD(t.date_created,`DD-MM-YY HH:mm`)}),c.data?.items.map(e=>{let n=[];for(let r of t.values)r.logging_parameter.id===e.logging_parameter.id&&n.push((0,p.jsx)(`span`,{className:r.value_is_valid?`text-success`:`text-danger`,children:r.float_value},`${r.logging_parameter.id}-${r.float_value}`));return(0,p.jsx)(`td`,{children:n},e.id)}),h.map(e=>{let n=[];for(let r of u.data?.items??[])r.step_parameter.id!==e.id||r.result.id!==t.id||n.push((0,p.jsx)($O,{monitorResultStepParameterValue:r,refetchMonitorStepParameterValues:u.refetch},r.id));return(0,p.jsx)(`td`,{className:`table-secondary`,children:n},e.id)}),(0,p.jsx)(`td`,{children:(0,p.jsx)(ZO,{result:t,requirement:e,refetchMonitorStepParameterValues:u.refetch})})]},t.id))})]}),(0,p.jsx)(KO,{data:l.data,setPage:i,setPageSize:o,pageSize:a,isPlaceholderData:l.isPlaceholderData})]}),(0,p.jsxs)(qr,{md:4,children:[(0,p.jsx)(`h2`,{children:`Upload new results`}),(0,p.jsx)(`p`,{children:`Drop your results file here`}),(0,p.jsxs)(`div`,{..._({style:S,className:`dropzone`}),children:[(0,p.jsx)(`input`,{...v()}),y?(0,p.jsx)(`p`,{children:`Drop file(s) here ...`}):(0,p.jsx)(`p`,{children:`Drag and drop file(s) here, or click to select files`}),(0,p.jsx)(`p`,{children:t})]}),g.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{className:`mt-2`,children:`Uploaded files`}),(0,p.jsxs)(`p`,{children:[`Last `,11,` uploaded files`]}),(0,p.jsx)(`ul`,{className:`list-group`,children:g.map((e,t)=>(0,p.jsxs)(`li`,{className:`list-group-item`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`span`,{children:[t+1,` `,(0,p.jsx)(`a`,{href:hO()+e.url,children:e.name}),e.has_monitor_step_loggings&&(0,p.jsx)(wr,{className:`ms-1 bg-primary`,children:`Logging`})]}),(0,p.jsxs)(`span`,{children:[Math.round(e.size/1024),`kiB`]})]}),(0,p.jsx)(`small`,{className:`text-muted`,children:zD(e.date_created,`DD-MM-YY HH:mm`)})]},e.url))})]})]})]})]})}function tk(){let{id:e}=(0,g.useParams)(),[t,n]=(0,m.useQueries)({queries:[{queryKey:[`monitor`,e],queryFn:()=>R({id:parseInt(e)})},{queryKey:[`requirements`,e],queryFn:()=>ue({monitorId:parseInt(e)})}]});return t.isLoading?(0,p.jsx)(`div`,{children:`Loading...`}):(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[`SPC Test `,t.data?.name]}),n.data?.items.map((e,t)=>(0,p.jsx)(`div`,{className:`border border-1 p-3 my-3`,children:(0,p.jsx)(ek,{requirement:e})},t))]})}function nk(){return(0,p.jsx)(Jr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}var rk=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&R({id:parseInt(n)}).then(t)},[n,e]);function r(){R({id:parseInt(n)}).then(t)}return{monitor:e,setMonitor:t,reloadMonitor:r}},ik=(0,d.createContext)({monitor:{},reloadMonitor:()=>{}});function ak({children:e}){let{monitor:t,reloadMonitor:n}=rk();return t===null?(0,p.jsx)(Ot,{children:(0,p.jsx)(Ct,{message:`Loading monitor...`})}):(0,p.jsx)(Ot,{children:(0,p.jsx)(ik.Provider,{value:{monitor:t,reloadMonitor:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}var ok=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||n!==e.id.toString())&&we({id:parseInt(n)}).then(t)},[n,e]);function r(){we({id:parseInt(n)}).then(t)}return{run:e,reloadRun:r}},sk=(0,d.createContext)({run:{},reloadRun:()=>{}});function ck({children:e}){let{run:t,reloadRun:n}=ok();return t===null?(0,p.jsx)(Ct,{message:`Loading run...`}):(0,p.jsx)(Ot,{children:(0,p.jsx)(sk.Provider,{value:{run:t,reloadRun:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading rest of run...`}),children:e})})})}function lk({text:e}){if(!e)return null;let t=e.split(/\r\n|\n|\r/);return(0,p.jsx)(p.Fragment,{children:t.map((e,n)=>(0,p.jsxs)(d.default.Fragment,{children:[e,n<t.length-1&&(0,p.jsx)(`br`,{})]},n))})}var uk=({children:e,format:t=`d-M-Y`})=>(0,p.jsx)(p.Fragment,{children:RD(e,t)}),dk=({run:e})=>{let[t,n]=(0,d.useState)(e.batch_card),[r,i]=(0,d.useState)(!1),{register:a,handleSubmit:o,formState:s,resetField:c}=Id({defaultValues:{content:t?.content}}),{isSubmitting:l,errors:u}=s,m=async t=>{await f.default.create().patch(`update/run/batch-card/`+e.id,{content:t.content}),i(!1);let r=await f.default.get(`view/run/`+e.id);n(r.data.batch_card)},h=async()=>{await f.default.create().delete(`delete/run/batch-card/`+e.id),i(!1),n(void 0),c(`content`)};return r?(0,p.jsxs)(G,{onSubmit:o(m),className:`mb-3`,children:[(0,p.jsxs)(zs,{hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:6,...a(`content`,{required:!0}),isInvalid:u.content!==void 0}),u.content&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:`This field is required`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-md-row gap-2 justify-content-between mt-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-2`,children:[(0,p.jsxs)(U,{variant:`primary`,type:`submit`,disabled:l,className:`text-nowrap`,children:[l&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Save batch card`]}),(0,p.jsx)(U,{variant:`secondary`,onClick:()=>i(!1),children:`Cancel`})]}),t&&(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`outline-danger`,className:`text-nowrap`,onClick:h,children:`Delete batch card`})})]})]}):t?t&&(0,p.jsxs)(W,{className:`rounded my-4 shadow-sm border-0`,children:[(0,p.jsxs)(W.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-start justify-content-between gap-3`,children:[(0,p.jsx)(W.Title,{className:`text-danger mb-0`,children:`Batch card`}),(0,p.jsx)(U,{variant:`outline-primary`,size:`sm`,className:`text-nowrap`,onClick:()=>i(!0),children:`Update batch card`})]}),(0,p.jsx)(W.Text,{className:`mt-3 mb-2 fs-5 text-body`,children:t&&(0,p.jsx)(lk,{text:t.content})})]}),(0,p.jsx)(W.Footer,{className:`bg-transparent border-0 pt-0 pb-3`,children:(0,p.jsxs)(`div`,{className:`text-muted small`,children:[`Created `,(0,p.jsx)(uk,{format:`DD-MM-YY`,children:t.date_created}),` by`,` `,t.user.first_name,` `,t.user.last_name,t.last_update&&(0,p.jsxs)(`span`,{children:[` (`,`Updated `,(0,p.jsx)(uk,{format:`DD-MM-YY H:m`,children:t.last_update}),`)`]})]})})]}):(0,p.jsx)(U,{variant:`outline-primary`,className:`mb-4`,onClick:()=>i(!0),children:`Create Batch Card`})};function fk(){let{run:e}=(0,d.useContext)(sk);return(0,p.jsxs)(p.Fragment,{children:[e.run_type===pt.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),e.run_type===pt.PRODUCTION&&(0,p.jsx)(`small`,{children:`Production run`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:(0,p.jsxs)(`h1`,{className:`display-4`,children:[e.name,` (`,e.project.name,`)`]})}),(0,p.jsx)(dk,{run:e})]})}function pk(e){let{run:t,reloadRun:n}=(0,d.useContext)(sk),{environment:r}=(0,g.useParams)(),i=window.location.pathname,a=[{title:`Information`,link:`/${r}/operator/run/details/${t.id}/information`},{title:`Steps`,link:`/${r}/operator/run/details/${t.id}/steps`},{title:`Layout`,link:`/${r}/operator/run/details/${t.id}/layout`}];return(0,p.jsx)($c,{variant:`tabs`,className:e.className,defaultActiveKey:`/home`,activeKey:i,children:a.map(e=>(0,p.jsx)($c.Item,{children:(0,p.jsx)(g.Link,{to:e.link,className:`nav-link `+(e.link===i?`active`:``),children:e.title})},e.link))})}function mk(){return(0,p.jsx)(ck,{children:(0,p.jsxs)(Jr,{fluid:!0,children:[(0,p.jsx)(fk,{}),(0,p.jsx)(pk,{className:`mb-4`}),(0,p.jsx)(g.Outlet,{})]})})}var hk=(0,d.createContext)({showOnlyEmphasizedParameters:!1,setShowOnlyEmphasizedParameters:()=>{}}),gk=({parameter:e,value:t,refetchFn:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(t.value),s=async r=>{let a={value:r};try{t.id===void 0?(a.parameter=e.id,await f.default.post(`/create/run/step/parameter/value`,a)):await f.default.patch(`/update/run/step/parameter/value/${t.id}`,a)}catch(e){console.error(`Failed to update parameter value with error: `,e)}n(),i(!1)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{role:`button`,tabIndex:0,style:{cursor:`pointer`,borderBottom:`1px dashed #999`,display:r?`none`:``},className:t.value==``||t.value==null?`text-muted`:``,onClick:()=>{i(!r)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i(!r))},children:t.value!==``&&t.value!==null?t.value:`edit`}),(0,p.jsxs)(`div`,{style:{display:r?``:`none`},className:`btn-group`,children:[(0,p.jsx)(`input`,{type:`text`,"aria-label":`Parameter value`,value:a??``,className:`form-control`,onChange:e=>o(e.target.value)}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Save`,onClick:()=>{s(a)},className:`btn btn-success btn-sm`,children:(0,p.jsx)(`i`,{className:`fa fa-check`})}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Cancel`,onClick:()=>{i(!1)},className:`btn btn-danger btn-sm`,children:(0,p.jsx)(`i`,{className:`fa fa-times`})})]})]})},_k=({runStep:e,showOnlyEmphasizedParameters:t,editableParameters:n=!0,refetchFn:r})=>{let{data:i,isLoading:a}=(0,m.useQuery)({queryKey:[`runStepParameters`,e.id],queryFn:()=>Le({runStep:e})}),o=(0,m.useQueryClient)(),s=()=>{o.refetchQueries({queryKey:[`runStepParameters`,e.id]}),r&&r()},c=i?.items??[],l=t?c.filter(e=>e.emphasize):c;return a?(0,p.jsxs)(Nl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Pos`}),(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:Array.from({length:2}).map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:3})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:7})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:4})})})]},t))})]}):c.length===0?(0,p.jsx)(Cr,{variant:`info`,children:`No parameters found`}):(0,p.jsxs)(Nl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Pos`}),(0,p.jsx)(`th`,{children:`Parameter`}),c[0].values.map((e,t)=>(0,p.jsx)(`th`,{children:`Value`},t)),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:l.length>0?l.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:e.sequence})}),(0,p.jsx)(`td`,{children:e.parameter.name}),e.values.map((t,r)=>(0,p.jsx)(`td`,{children:n?(0,p.jsx)(gk,{parameter:e,refetchFn:s,value:t}):(0,p.jsx)(`span`,{children:t.value})},t.id??`${e.id}-${r}`)),(0,p.jsx)(`td`,{children:e.unit?.abbr??``})]},e.id)):(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:3+c[0].values.length,children:`No emphasized parameters found.`})})})]})},vk=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};function yk({runStep:e,refetchFn:t}){let[n,r]=(0,d.useState)([]),[i,a]=(0,d.useState)(``),{data:o,isLoading:s}=(0,m.useQuery)({queryKey:[`files`,e.id],queryFn:()=>Ie({step:e})}),c=(0,m.useQueryClient)(),l=()=>{c.refetchQueries({queryKey:[`files`,e.id]}),t&&t()},u=o?.items??[],h=async e=>{if(confirm(`Are you sure you want to delete ${e.name}? You can not undo this action`))try{await f.default.delete(`delete/run/step/file/${e.id}`),l()}catch(e){console.error(e)}},{getRootProps:g,getInputProps:_,isDragActive:v,isDragAccept:y,isDragReject:b}=Hb({onDrop:e=>{r(t=>[...t,...e]),a(`${e.length} file(s) selected`)}}),x=(0,d.useMemo)(()=>({...v?{borderColor:`#83afee`}:{},...y?{borderColor:`#00e676`}:{},...b?{borderColor:`#ff1744`}:{}}),[y,b,v]),S=()=>{n.forEach(t=>{let n=new FileReader;n.onload=async()=>{let i=n.result;try{await f.default.create().post(`update/run/step/upload-file/`+e.id,{content:i,filename:t.name,type:t.type})}catch(e){a(`Upload failed due to: `+e.response.data.detail)}try{l(),a(`Files uploaded succesfully`),r([])}catch(e){a(`Error refetching file data`),console.error(e)}},n.readAsDataURL(t)})};return s?(0,p.jsx)(`div`,{children:`Loading...`}):(0,p.jsxs)(`div`,{children:[u&&u.length>0&&(0,p.jsxs)(Nl,{hover:!0,striped:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`No`}),(0,p.jsx)(`th`,{children:`File`}),(0,p.jsx)(`th`,{children:`Size`}),(0,p.jsx)(`th`,{children:`Date`})]})}),(0,p.jsx)(`tbody`,{children:u.map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t+1})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(`a`,{href:`${hO()}${e.url}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(wr,{className:`ms-1 bg-primary`,children:`Logging`})]}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":`Delete file`,className:`fa fa-trash-o remove-file handle`,style:{cursor:`pointer`},onClick:()=>h(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),h(e))}}),` `,vk(e.size)]}),(0,p.jsx)(`td`,{children:zD(e.date_created,`DD-MM-YY HH:mm`)})]},e.url))})]}),(0,p.jsxs)(`div`,{...g({style:x,className:`dropzone bg-secondary-subtle border rounded dz-clickable`}),children:[(0,p.jsx)(`input`,{..._()}),v?(0,p.jsx)(`p`,{children:`Drop files here...`}):(0,p.jsx)(`p`,{children:`Drag and drop files here or click to select`})]}),n.length>0&&(0,p.jsx)(nc,{className:`mt-3`,children:n.map(e=>(0,p.jsx)(nc.Item,{children:e.name},e.name))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(U,{className:`mt-3`,onClick:S,disabled:n.length===0,children:`Upload Selected Files`}),(0,p.jsx)(`p`,{className:`mt-2 text-muted`,children:i})]})]})}var bk=({runStepPart:e,setRunStepPart:t,editable:n=!0})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(e.comment),{register:s,handleSubmit:c,formState:l,resetField:u}=Id({defaultValues:{comment:a}}),{isSubmitting:m,errors:h}=l;return n?r?(0,p.jsxs)(G,{onSubmit:c(async n=>{await f.default.create().patch(`update/run/step/part/`+e.id,{comment:n.comment}).then(n=>{t({...e,comment:n.data.comment}),o(n.data.comment),i(!1)})}),children:[(0,p.jsx)(G.Group,{className:`mb-3`,controlId:`formBasicEmail`,children:(0,p.jsx)(G.Control,{as:`textarea`,...s(`comment`)})}),(0,p.jsx)(U,{size:`sm`,type:`submit`,disabled:m,children:`Save`}),(0,p.jsx)(U,{variant:`warning`,size:`sm`,className:`ms-2`,onClick:()=>i(!1),children:`Cancel`})]}):a===null?(0,p.jsx)(U,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Add comment`}):(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`div`,{className:`text-break`,children:a}),(0,p.jsx)(U,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Edit`})]}):(0,p.jsx)(`div`,{children:a})},xk=({runStepPart:e,setRunStepPartAction:t,createRunStepPart:n})=>(0,p.jsxs)(fs,{align:`end`,children:[(0,p.jsx)(fs.Toggle,{size:`sm`,variant:`outline-secondary`,children:`Actions`}),(0,p.jsxs)(fs.Menu,{children:[e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(fs.Item,{onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n)),(0,p.jsx)(fs.Item,{onClick:()=>n(),children:`Init`})]})]}),Sk={[He.START]:`btn-start`,[He.FINISH]:`btn-success`,[He.FAIL]:`btn-failed`,[He.REWORK]:`btn-rework`,[He.SET_REPAIR]:`btn-repair`,[He.CLEAR_REPAIR]:`btn-secondary`,[He.SET_TESTING]:`btn-test`,[He.CLEAR_TESTING]:`btn-secondary`},Ck=({runStepPart:e,setRunStepPartAction:t})=>e.available_actions.length===0?null:(0,p.jsx)(p.Fragment,{children:e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm me-2 ${Sk[n]}`,onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n))}),wk=(e,t)=>{let{status:n,processed:r,failed:i,started:a,available_actions:o}=t.updated_run_step_part_state;return{...e,status:n,processed:r,failed:i,started:a,available_actions:o}},Tk=(e,t)=>e&&(Array.isArray(e.pages)?{...e,pages:e.pages.map(e=>!e||!Array.isArray(e.items)?e:{...e,items:t(e.items)})}:Array.isArray(e.items)?{...e,items:t(e.items)}:e),Ek=e=>e?Array.isArray(e.pages)?e.pages.flatMap(e=>Array.isArray(e?.items)?e.items:[]):Array.isArray(e.items)?e.items:[]:[],Dk=(e,t)=>{let{runStepPart:n,latestAction:r}=t;return Tk(e,e=>e.map(e=>e.id===n.id?wk(e,r):e))},Ok=(e,t)=>Tk(e,e=>e.map(e=>t.get(e.id)??e)),kk=e=>Array.isArray(e)?e:Array.isArray(e.items)?e.items:[],Ak=(e,t)=>{let n=kk(t);if(n.length===0)return e;let r=new Map(n.map(e=>[e.updated_run_step_part_state.run_step_part_id,e])),i=new Map(n.map(e=>[e.updated_run_step_part_state.run_part_id,e]));return Tk(e,e=>e.map(e=>{let t=r.get(e.id)??i.get(e.part_id);return t?wk(e,t):e}))},jk=(e,t,n,r)=>{if(e.id===n.id||e.part_id!==n.part_id)return!1;let i=r.get(e.step_id);return i?i.run_id===t.run_id&&i.part_level===0&&i.sequence>t.sequence:!1},Mk=(e,t,n,r={},i=new Map)=>{if(!e)return e;let a=e=>e.id===n.id?n:r.updateSubsequent&&jk(e,t,n,i)?{...e,tray_id:n.tray_id,tray_row:n.tray_row,tray_column:n.tray_column}:e;if(Array.isArray(e.pages)){let t=e.pages;if(t.some(e=>Array.isArray(e?.items)&&e.items.some(e=>e.id===n.id)))return Tk(e,e=>e.map(a));if(t.length>0){let r=t.length-1;return{...e,pages:t.map((e,t)=>{if(!e||!Array.isArray(e.items))return e;let i=e.items.map(a);return{...e,items:t===r?[...i,n]:i}})}}return e}if(Array.isArray(e.items)){let t=e.items,r=t.some(e=>e.id===n.id);return{...e,items:r?t.map(a):[...t.map(a),n]}}return e},Nk=e=>{let t=new Map;return e.getQueriesData({queryKey:[`runSteps`]}).forEach(([,e])=>{Ek(e).forEach(e=>{t.set(e.id,e)})}),t},Pk=async(e,t)=>{if(t.length===0)return;let n=Array.from(new Set(t.map(e=>e.part_id))).map(e=>({id:e}));if(n.length===0)return;let r=await Re({runPart:n}),i=new Map(r.items.map(e=>[e.id,e]));i.size!==0&&e.setQueriesData({queryKey:[`runStepParts`]},e=>Ok(e,i))},Fk=async(e,t)=>{let n=Array.from(new Set(t.map(e=>e.step_id)));if(n.length===0)return;let r=await Promise.all(n.map(e=>Te({id:e}))),i=new Map(r.map(e=>[e.id,e]));e.setQueriesData({queryKey:[`runSteps`]},e=>Tk(e,e=>e.map(e=>i.get(e.id)??e)))},Ik=(e,t)=>{e.setQueriesData({queryKey:[`runStepParts`]},e=>Dk(e,t)),Pk(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step part cache from run part.`,e)}),Fk(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step cache from run step part.`,e)})},Lk=(e,t)=>{Ik(e,t)},Rk=(e,t,n)=>{if(`latestActions`in n){e.setQueriesData({predicate:e=>Array.isArray(e.queryKey)&&e.queryKey[0]===`runStepParts`&&(e.queryKey.length===1||e.queryKey[1]===t.id)},e=>Ak(e,n.latestActions)),Pk(e,kk(n.latestActions).map(e=>({id:e.updated_run_step_part_state.run_step_part_id,part_id:e.updated_run_step_part_state.run_part_id}))).catch(e=>{console.error(`Failed to refresh run step part cache from run parts.`,e)}),Fk(e,[{step_id:t.id}]).catch(e=>{console.error(`Failed to refresh run step cache from run step.`,e)});return}Ik(e,n)},zk=(e,t,n,r={})=>{let i=r.updateSubsequent?Nk(e):new Map;e.setQueriesData({queryKey:[`runStepParts`]},e=>Mk(e,t,n,r,i))};function Bk(e){return!0}var Vk=e=>!!e.closest(`button, a, input, textarea, select, option, label`),Hk=({runPart:e,partIsSelected:t,setPartAsSelected:n,runStepParts:r,canInit:i,runStep:a,dropdown:o})=>{let[s,c]=(0,d.useState)(),l=(0,m.useQueryClient)();(0,d.useEffect)(()=>{let t=r.find(t=>t.part_id===e.id);c(t)},[r,e.id]);let u=t=>{if(!n)return;let r=t.target;if(Vk(r))return;let i=s?s.part_id:e.id;i!==void 0&&n(i)},h=()=>{i||f.default.post(`/create/run/step/part`,{run_part_id:e.id,run_step_id:a.id}).then(e=>{let t={...e.data};c(t),zk(l,a,t)})},g=async({runStepPart:e,runStepPartAction:t})=>{let n=await Be({runStepPart:e,runStepPartAction:t});c(e=>{if(!e)return e;let{status:t,processed:r,failed:i,started:a,available_actions:o}=n.updated_run_step_part_state;return{...e,status:t,processed:r,failed:i,started:a,available_actions:o}}),Rk(l,a,{runStepPart:e,latestAction:n})};return s?(0,p.jsxs)(`tr`,{onClick:u,style:n?{cursor:`pointer`}:void 0,children:[(0,p.jsx)(`td`,{children:n&&Bk(a)&&(0,p.jsx)(`input`,{type:`checkbox`,id:`part-select-${s.part_id}`,name:`tomato`,"aria-label":`Select part`,className:`form-check-input`,checked:t,onChange:()=>n?.(s.part_id)})}),(0,p.jsx)(`td`,{children:e.scanner_label}),(0,p.jsx)(`td`,{children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-1`,children:[(0,p.jsx)(`span`,{className:`badge ${s.status.class??``}`.trim(),children:s.status.key}),(0,p.jsx)(`small`,{className:`text-muted`,children:s.status.text})]})}),Bk(a)&&(0,p.jsx)(`td`,{children:o?(0,p.jsx)(xk,{runStepPart:s,setRunStepPartAction:g,createRunStepPart:h}):(0,p.jsx)(Ck,{runStepPart:s,setRunStepPartAction:g})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(bk,{runStepPart:s,setRunStepPart:c})})]}):null},Uk=(0,d.createContext)(null),Wk=()=>{let e=(0,d.useContext)(Uk);if(e===null)throw Error(`useScannerContext must be used within a ScannerProvider`);return e},Gk=function(e){return e[e.WILD_CARD=0]=`WILD_CARD`,e[e.PERFORM_RUN_ACTION=1]=`PERFORM_RUN_ACTION`,e[e.RESET_FORM=2]=`RESET_FORM`,e}({});function Kk(e){return e.startsWith(`_qr`)?1:e.toUpperCase().includes(`RESET-FORM`)?2:0}function qk({parts:e}){let[t,n]=(0,d.useState)(new Map),r=(0,d.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(e,!(t.get(e)??!1)),n})},[]),{lastlyReadedKeys:i,addCallbackFn:a,removeCallbackFn:o}=Wk(),s=(0,d.useId)(),c=(0,d.useRef)(new Set),l=(0,d.useCallback)(t=>{if(Kk(t)!=Gk.WILD_CARD)return;let n=t.replace(/_/g,`-`).toUpperCase();if(!n)return;if(e.length==0){if(c.current.size>=15){let e=c.current.values().next().value;e!==void 0&&c.current.delete(e)}c.current.add(n);return}let i=e.find(e=>n.includes(e.scanner_label.toUpperCase()));i&&r(i.id)},[e,r]);return(0,d.useEffect)(()=>(o(Gk.WILD_CARD,s),l(i),a(Gk.WILD_CARD,s,l),()=>{o(Gk.WILD_CARD,s)}),[e]),(0,d.useEffect)(()=>{let r=new Map;for(let n of e){let e=n.id;r.set(e,t.get(e)??!1)}r.size!==t.size&&n(()=>r),e.length>0&&(c.current.forEach(e=>{l(e)}),c.current.clear())},[e,t,r]),{selectedParts:t,setPartAsSelected:r,setPartsSelection:(0,d.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return e.forEach(e=>{r.set(e,t)}),r})},[]),selectAllParts:(0,d.useCallback)(()=>{n(e=>new Map([...e.keys()].map(e=>[e,!0])))},[]),selectNoneParts:(0,d.useCallback)(()=>{n(e=>new Map([...e.keys()].map(e=>[e,!1])))},[]),hasSelectedParts:Array.from(t.values()).some(e=>e)}}var Jk=null;function Yk(e){if(!Jk){console.warn(`notification() called before NotificationProvider is mounted`);return}Jk(e)}function Xk({children:e}){let[t,n]=(0,d.useState)([]),r=(0,d.useRef)(0),i=(0,d.useCallback)(e=>{let t=++r.current;n(n=>[...n,{...e,id:t}])},[]);(0,d.useEffect)(()=>(Jk=i,()=>{Jk=null}),[i]);let a=(0,d.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,p.jsxs)(p.Fragment,{children:[e,(0,p.jsx)(Hl,{containerPosition:`fixed`,position:`top-end`,children:t.map(({id:e,notificationHeader:t,notificationBody:n,notificationType:r})=>(0,p.jsxs)(Bl,{show:!0,delay:3e3+(r==`danger`?150:0),autohide:!0,bg:r,onClose:()=>a(e),className:`m-5`,children:[(0,p.jsx)(Bl.Header,{children:(0,p.jsx)(`span`,{className:`me-auto`,children:t})}),(0,p.jsx)(Bl.Body,{children:n})]},e))})]})}var Zk=e=>`step_id`in e&&`part_id`in e;function Qk({runStep:e,parts:t,selectedParts:n,getRunPart:r,getRunStepPart:i,actionsFromScanner:a=!0}){let o=(0,m.useQueryClient)(),{addCallbackFn:s,removeCallbackFn:c}=Wk(),l=(0,d.useId)(),u=(0,d.useCallback)(()=>{if(t.length===0)return[];if(Zk(t[0]))return t.filter(e=>{let t=r?r(e):e.part_id;return n.get(t)});let e=[];for(let r of t){if(!n.get(r.id))continue;let t=i?i(r):void 0;t&&e.push(t)}return e},[t,n,r,i]),f=(0,d.useCallback)(async t=>{let n=u();if(n.length===0)return;let r=n.filter(e=>e.available_actions.some(({id:e})=>e===t));if(r.length===0)return;if(r.length===1){let e=r[0],n=await Be({runStepPart:e,runStepPartAction:t});Lk(o,{runStepPart:e,latestAction:n});return}let i=await Ve({runStepPartActions:r.map(e=>({runStepPart:e,runStepPartAction:t}))});Rk(o,e,{latestActions:i})},[u,o,e]),p=(0,d.useCallback)(e=>{if(!e||!$k(e))return;let t=We(e.split(`/`)[1]);if(!t){Yk({notificationHeader:`Part scanner`,notificationBody:`Non valid action found in the scanned text`,notificationType:`danger`});return}Yk({notificationHeader:`Part scanner`,notificationBody:`Performing action ${Ue(t)} on selected parts`,notificationType:`success`}),f(t)},[f]);return(0,d.useEffect)(()=>{if(a)return c(Gk.PERFORM_RUN_ACTION,l),s(Gk.PERFORM_RUN_ACTION,l,p),()=>{c(Gk.PERFORM_RUN_ACTION,l)}},[a,p,s,c,l]),{performActionToSelectedParts:f,getAvailableActionsForSelection:(0,d.useCallback)(()=>{let e=new Map;for(let t of u())for(let{id:n,name:r}of t.available_actions)e.has(n)||e.set(n,r);return Array.from(e.entries()).map(([e,t])=>({id:e,name:t}))},[u])}}function $k(e){return RegExp(`^_qr/.+`).test(e)}var eA=({onSelectAll:e,onSelectNone:t,hasSelectedParts:n,actionsDropdown:r,traySelections:i,onToggleTray:a})=>{let o=(i??[]).length>0;return(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`div`,{className:`btn-group btn-group-sm`,role:`group`,"aria-label":`Part selection controls`,children:[(0,p.jsx)(`button`,{type:`button`,className:`part-check-all btn btn-outline-secondary`,onClick:e,children:`All`}),(0,p.jsx)(`button`,{type:`button`,className:`part-check-none btn btn-outline-secondary`,onClick:t,children:`None`})]}),o&&(0,p.jsx)(`div`,{className:`btn-group btn-group-sm`,role:`group`,"aria-label":`Tray selection controls`,children:i?.map(e=>{let t=e.allSelected;return(0,p.jsx)(`button`,{type:`button`,className:`btn ${t?`btn-secondary`:`btn-outline-secondary`}`,"aria-pressed":t,onClick:()=>a?.(e.partIds,!t),children:e.label},e.id)})}),n&&r]})},tA=({availableActions:e,onActionSelected:t})=>{let[n,r]=(0,d.useState)(null);if(e.length===0)return null;let i=async e=>{if(n===null){r(e);try{await t(e)}finally{r(null)}}};return(0,p.jsx)(p.Fragment,{children:e.map(({id:e,name:t})=>(0,p.jsxs)(`button`,{type:`button`,className:`btn btn-sm ${Sk[e]}`,onClick:()=>void i(e),disabled:n!==null,children:[n===e&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),t]},e))})},nA=({run:e,runStep:t})=>{let n=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>ke({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Re({step:t})}]}),[r,i]=n,a=n.some(e=>e.isLoading),o=n.some(e=>e.isError),s=(0,d.useMemo)(()=>r.data?.items??[],[r.data]),c=(0,d.useMemo)(()=>i.data?.items??[],[i.data]),l=(0,d.useMemo)(()=>s.filter(e=>e.part_level===t.part_level),[s,t.part_level]),[u,f]=(0,d.useState)(!1),{selectedParts:h,selectAllParts:g}=qk({parts:l});aA({runStepParts:c,runParts:l});let _=(0,d.useMemo)(()=>l.filter(e=>h.get(e.id)&&(u||!rA(c,e))),[l,c,h,u]);return o?(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run parts.`}):(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(Nl,{size:`sm`,striped:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2,children:`Part`}),(0,p.jsx)(`th`,{children:`Status`}),(0,p.jsx)(`th`,{children:`Actions`}),(0,p.jsx)(`th`,{children:`Comment`})]})}),(0,p.jsxs)(`tbody`,{children:[a&&Array.from({length:1}).map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:7})})})]},`placeholder-${t}`)),!a&&_.map((e,n)=>(0,p.jsx)(Hk,{runStep:t,runPart:e,runStepParts:c,canInit:!1,partIsSelected:h.get(e.id)??!1,dropdown:!1},`${e.parsed_label}${n}`))]})]}),(0,p.jsx)(iA,{runStepParts:c,selectedPartsLength:_.length,totalParts:l.length,onSelectAll:g,toggleShowCompletedParts:()=>{f(!u)}})]})},rA=(e,t)=>{let n=e.find(e=>e.part_id==t.id);return n!=null&&n.processed},iA=({runStepParts:e,selectedPartsLength:t,totalParts:n,onSelectAll:r,toggleShowCompletedParts:i})=>{let a=(0,d.useMemo)(()=>{let t=0;return e.forEach(e=>e.processed?t++:null),t},[e]);return(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-sm-row flex-wrap gap-2 mt-2`,children:[(0,p.jsxs)(`span`,{className:`badge rounded-pill bg-warning-subtle text-warning-emphasis border border-warning-subtle px-3 py-2 fw-semibold`,role:`button`,tabIndex:0,title:`Show all the parts`,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},style:{cursor:`pointer`},children:[`This step has `,(0,d.useMemo)(()=>n-t,[n,t]),` more parts`]}),(0,p.jsxs)(`span`,{className:`badge rounded-pill bg-info-subtle text-info-emphasis border border-info-subtle px-3 py-2 fw-semibold`,children:[`This step has `,t,` scanned parts`]}),(0,p.jsxs)(`span`,{role:`button`,tabIndex:0,title:`Show all the parts`,style:{cursor:`pointer`},onClick:i,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},className:`badge rounded-pill bg-success-subtle text-success-emphasis border border-success-subtle px-3 py-2 fw-semibold`,children:[`This step has `,a,` finished parts`]})]})};function aA({runStepParts:e,runParts:t}){let{addCallbackFn:n,removeCallbackFn:r}=Wk(),i=(0,d.useId)(),a=(0,d.useCallback)(n=>{let r=n.replace(/_/g,`-`).toUpperCase();if(!r)return;let i=t.find(e=>r.includes(e.scanner_label.toUpperCase()));if(i){if(rA(e,i)){Yk({notificationHeader:`Run parts table`,notificationBody:`Part ${i.parsed_label??i.scanner_label} is already completed`,notificationType:`danger`});return}Yk({notificationHeader:`Part scanner`,notificationBody:`Found part: ${i.scanner_label}`,notificationType:`success`})}},[t,e]);(0,d.useEffect)(()=>(r(Gk.WILD_CARD,i),n(Gk.WILD_CARD,i,a),()=>{r(Gk.WILD_CARD,i)}),[t,e])}var oA=!1,sA=({run:e,runStep:t})=>{let n=(0,m.useQueryClient)(),r=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>ke({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Re({step:t})}]}),[i,a]=r,o=r.some(e=>e.isLoading),s=r.some(e=>e.isError),c=(0,d.useMemo)(()=>i.data?.items??[],[i.data]),l=(0,d.useMemo)(()=>a.data?.items??[],[a.data]),{selectedParts:u,setPartAsSelected:f,setPartsSelection:h,selectAllParts:g,selectNoneParts:_,hasSelectedParts:v}=qk({parts:c});aA({runStepParts:l,runParts:c}),(0,d.useEffect)(()=>{let e=[];for(let[t,n]of u.entries())n&&e.push(t);n.setQueryData([`runPartSelection`,t.id],e)},[n,t.id,u]);let{performActionToSelectedParts:y,getAvailableActionsForSelection:b}=Qk({runStep:t,parts:c,selectedParts:u,getRunPart:void 0,getRunStepPart:e=>l.find(t=>t.part_id===e.id)}),x=(0,d.useMemo)(()=>b(),[b]),S=(0,d.useMemo)(()=>{let t=new Map,n=new Map(c.map(e=>[e.id,e]));if(l.forEach(e=>{let r=n.get(e.part_id)?.tray;if(!r)return;let i=t.get(r.id)??{id:r.id,label:r.name??r.label??`Tray ${r.id}`,partIds:[]};i.partIds.push(e.part_id),t.set(r.id,i)}),t.size===0)return[];let r=[...e.run_trays??[]].sort((e,t)=>e.sequence-t.sequence);return(r.length>0?(()=>{let e=[];for(let n of r){let r=t.get(n.id);r&&e.push({...r,label:n.name??n.label??r.label})}return e})():Array.from(t.values()).sort((e,t)=>e.label.localeCompare(t.label))).map(e=>({...e,allSelected:e.partIds.every(e=>u.get(e))}))},[e.run_trays,u,c,l]),C=(0,d.useMemo)(()=>(0,p.jsx)(tA,{availableActions:x,onActionSelected:y}),[x,y]);if(o)return(0,p.jsx)(Ct,{message:`Loading run parts`});if(s)return(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run parts.`});if(c.length===0)return(0,p.jsx)(Cr,{variant:`warning`,children:`No parts found for this run step.`});if(l.length===0)return(0,p.jsx)(Cr,{variant:`warning`,children:`No step parts found for this run step.`});let w=Bk(t),T=()=>(0,p.jsx)(p.Fragment,{children:w&&(0,p.jsx)(eA,{onSelectAll:g,onSelectNone:_,hasSelectedParts:v,traySelections:S,onToggleTray:(e,t)=>h(e,t),actionsDropdown:C})});return(0,p.jsxs)(d.Fragment,{children:[T(),c&&c.length>0&&(0,p.jsxs)(p.Fragment,{children:[!w&&(0,p.jsxs)(Cr,{variant:`warning`,className:`py-2 mb-2`,children:[(0,p.jsx)(`strong`,{children:`Step locked.`}),` Finish the previous step before processing these parts.`]}),(0,p.jsxs)(Nl,{size:`sm`,striped:!0,hover:!0,className:w?void 0:`text-muted`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2,children:`Part`}),(0,p.jsx)(`th`,{children:`Status`}),w&&(0,p.jsx)(`th`,{children:`Actions`}),(0,p.jsx)(`th`,{children:`Comment`})]})}),(0,p.jsx)(`tbody`,{children:c.map((n,r)=>{let i=u.get(n.id)??!1;return(0,p.jsx)(Hk,{runStep:t,runPart:n,runStepParts:l,canInit:e.run_type===pt.PRODUCTION,partIsSelected:i,setPartAsSelected:w?f:void 0,dropdown:oA},`key-${r}-${n.id}`)})})]})]}),l.length>=25&&T()]})};function cA({run:e,step:t,refetchFn:n=()=>null}){let{run:r}=(0,d.useContext)(sk),{showOnlyEmphasizedParameters:i}=(0,d.useContext)(hk),a=e??r;return a?(0,p.jsx)(W,{className:`p-4 my-3`,children:(0,p.jsx)(W.Body,{children:(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Experimental split`}),(0,p.jsx)(sA,{run:a,runStep:t}),t.has_remark&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{children:`Remark`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.remark}})]})]}),(0,p.jsxs)(qr,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(_k,{runStep:t,showOnlyEmphasizedParameters:i,refetchFn:()=>{n([JSON.stringify(t),`parameters`])}}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(yk,{runStep:t,refetchFn:()=>{n([`runSteps`])}})]})]})})}):null}var lA=(e,t)=>e==null&&t==null?0:e==null?1:t==null?-1:e-t,uA=(e,t)=>lA(e.left,t.left)||e.id-t.id,dA=e=>e.parent?.id??e.root_id??e.id,fA=(e,t)=>{let n=e[0],r=t[0];return lA(n?.parent?.left,r?.parent?.left)||lA(n?.parent?.id,r?.parent?.id)||uA(n,r)},pA=({parts:e,slotCount:t,getSlotIndex:n})=>{let r=Array.from({length:t},()=>[]),i=new Map;e.forEach(e=>{let t=dA(e),n=i.get(t)??[];n.push(e),i.set(t,n)});for(let e of i.values()){let i=[...e].sort(uA),a=n(i[0]),o=a!==null&&a>=0&&a<t?a:r.reduce((e,t,n)=>e===-1||t.length<r[e].length?n:e,-1);o!==-1&&r[o].push(i)}return r.map(e=>e.sort(fA).flat())},mA=({parts:e,getOverrideSlotIndex:t,getDirectSlotIndex:n,slotCount:r})=>{let i=new Map,a=[...new Set(e.map(e=>e.part_level))].sort((e,t)=>e-t),o=[...e].sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:lA(e.left,t.left)||e.id-t.id);return a.forEach(e=>{let a=o.filter(t=>t.part_level===e),s=new Set,c=[];a.forEach(e=>{let a=t?.(e);if(a!=null&&a>=0&&(r===void 0||a<r)){i.set(e.id,a),s.add(a);return}let o=e.parent?.id?i.get(e.parent.id):void 0;if(o!==void 0){i.set(e.id,o),s.add(o);return}let l=n(e);if(l!==null&&l>=0&&(r===void 0||l<r)&&!s.has(l)){i.set(e.id,l),s.add(l);return}c.push(e)}),c.forEach(e=>{let t=0;for(;s.has(t);)t+=1;r!==void 0&&t>=r||(i.set(e.id,t),s.add(t))})}),i},hA=({runPart:e,stepPart:t,statusClass:n,withTrayCell:r=!1,allowCreate:i=!1,isSelected:a=!1,runStep:o})=>{let s=(0,m.useQueryClient)(),c=t?.id!==void 0,[l,u]=(0,d.useState)(!1),h=(0,d.useRef)(null),g=(0,d.useRef)(null),_=(0,d.useRef)(null),v=()=>{_.current&&(clearTimeout(_.current),_.current=null),!l&&(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{u(!0)},500))},y=()=>{g.current&&(clearTimeout(g.current),g.current=null),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>u(!1),150)};(0,d.useEffect)(()=>()=>{g.current&&clearTimeout(g.current),_.current&&clearTimeout(_.current)},[]);let b=()=>{!e||!o||f.default.post(`/create/run/step/part`,{run_part_id:e.id,run_step_id:o.id}).then(e=>{let t={...e.data};zk(s,o,t)})},x=async({runStepPart:e,runStepPartAction:t})=>{let n=await Be({runStepPart:e,runStepPartAction:t});o&&Rk(s,o,{runStepPart:e,latestAction:n})},S=!c||!e?null:i&&!c?(0,p.jsxs)(U,{size:`sm`,variant:`outline-secondary`,className:`tray-grid__badge tray-grid__badge--init`,onClick:b,children:[`Init `,e.scanner_label]}):(0,p.jsx)(`span`,{className:`tray-grid__badge ${n??`step-part-inactive`}${a?` step-part-selected`:``}`,children:e.scanner_label});return r?(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`div`,{ref:h,role:`button`,tabIndex:0,onMouseEnter:v,onMouseLeave:y,onClick:()=>l?y():v(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l?y():v())},className:`tray-grid__cell${e?``:` tray-grid__cell--empty`}`,children:S}),t&&(0,p.jsx)(hl,{target:h.current,show:l,placement:`top`,children:({placement:e,arrowProps:n,show:r,popper:i,hasDoneInitialMeasure:a,...o})=>(0,p.jsx)(`div`,{...o,onMouseEnter:v,onMouseLeave:y,style:{position:`absolute`,backgroundColor:`rgba(33, 37, 41, 0.95)`,padding:`12px 16px`,border:`1px solid rgba(255, 255, 255, 0.2)`,borderRadius:6,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.2)`,display:`flex`,alignItems:`center`,gap:4,whiteSpace:`nowrap`,...o.style},children:(0,p.jsx)(Ck,{runStepPart:t,setRunStepPartAction:x})})})]}):S},gA=(e,t)=>t.get(e.id)?.status.class??`step-part-inactive`,_A=({runPart:e,context:t})=>{let{step:n,stepPartsById:r,allowCreate:i,selectedPartIds:a}=t;return(0,p.jsx)(hA,{runPart:e,statusClass:gA(e,r),allowCreate:i,stepPart:r.get(e.id),isSelected:a.includes(e.id),runStep:n})},vA=({runParts:e,context:t})=>(0,p.jsx)(`div`,{className:`tray-grid__cell${e.length?``:` tray-grid__cell--empty`}${e.length>1?` tray-grid__cell--multi`:``}`,children:e.map(e=>(0,p.jsx)(_A,{runPart:e,context:t},e.id))}),yA=({runPart:e,context:t})=>{let{step:n,stepPartsById:r,allowCreate:i,selectedPartIds:a}=t;return(0,p.jsx)(hA,{runPart:e,statusClass:e?gA(e,r):void 0,withTrayCell:!0,allowCreate:i,stepPart:e?r.get(e.id):void 0,isSelected:e?a.includes(e.id):!1,runStep:n})},bA=12,xA=({leveledParts:e,allNonTrayParts:t,isSplitLevel:n,context:r})=>{let i=mA({parts:t,getDirectSlotIndex:e=>e.left>=1?e.left-1:null}),a=n?e.reduce((e,t)=>Math.max(e,(i.get(t.id)??-1)+1),0):Math.max(e.length,e.reduce((e,t)=>Math.max(e,t.left??0),0)),o=Math.max(1,Math.ceil(a/bA)),s=bA,c={"--tray-columns":s,"--tray-rows":o},l=n?pA({parts:e,slotCount:o*s,getSlotIndex:e=>i.get(e.id)??null}):Array.from({length:o*s},()=>[]);if(!n){let t=[];e.forEach(e=>{let n=e.left,r=n>=1&&n<=l.length?n-1:null;if(r!==null&&!l[r].length){l[r].push(e);return}t.push(e)}),t.forEach(e=>{let t=l.findIndex(e=>e.length===0);t!==-1&&l[t].push(e)})}return(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":`ltr`,style:c,children:l.map((e,t)=>n?(0,p.jsx)(vA,{runParts:e,context:r},`slot-no-tray-${t}`):(0,p.jsx)(yA,{runPart:e[0]??null,context:r},`slot-no-tray-${t}`))})},SA=({label:e,trayStepParts:t,runStep:n,children:r})=>{let i=(0,m.useQueryClient)(),a=(0,d.useRef)(null),o=(0,d.useRef)(null),[s,c]=(0,d.useState)(!1),l=()=>{o.current&&(clearTimeout(o.current),o.current=null),c(!0)},u=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>c(!1),150)},f=(()=>{let e=new Map;for(let n of t)for(let{id:t,name:r}of n.available_actions)e.has(t)||e.set(t,r);return Array.from(e.entries()).map(([e,t])=>({id:e,name:t}))})(),h=async e=>{let r=t.filter(t=>t.available_actions.some(({id:t})=>t===e));if(r.length===0)return;let a=await Ve({runStepPartActions:r.map(t=>({runStepPart:t,runStepPartAction:e}))});Rk(i,n,{latestActions:a})};return(0,p.jsxs)(`div`,{ref:a,className:`tray-grid-wrapper`,onMouseEnter:l,onMouseLeave:u,children:[(0,p.jsx)(`div`,{className:`tray-grid__label`,children:e}),r,f.length>0&&(0,p.jsx)(hl,{target:a.current,show:s,placement:`top`,children:({placement:e,arrowProps:t,show:n,popper:r,hasDoneInitialMeasure:i,...a})=>(0,p.jsx)(`div`,{...a,onMouseEnter:l,onMouseLeave:u,style:{position:`absolute`,backgroundColor:`rgba(33, 37, 41, 0.95)`,padding:`12px 16px`,border:`1px solid rgba(255, 255, 255, 0.2)`,borderRadius:6,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.2)`,display:`flex`,alignItems:`center`,gap:4,whiteSpace:`nowrap`,...a.style},children:(0,p.jsx)(tA,{availableActions:f,onActionSelected:h})})})]})},CA=(e,t,n)=>!t||!n||t<1||n<1||t>e.rows||n>e.columns?null:e.orientation===`ttb`?(n-1)*e.rows+(t-1):(t-1)*e.columns+(n-1),wA=(e,t)=>e.map(e=>t.get(e.id)).filter(e=>e!==void 0),TA=e=>e?.tray_id!=null&&!e?.failed?1:e?.tray_id==null?3:2,EA=({tray:e,trayParts:t,trayAllParts:n,stepParts:r,isSplitLevel:i,context:a})=>{let{step:o,stepPartsById:s}=a,c=e.tray_type,l=e.name??e.label??``,u=wA(t,s),d=new Map;if(r.forEach(e=>{e.step_id===o.id&&d.set(e.part_id,e)}),!c?.rows||!c?.columns)return(0,p.jsx)(SA,{label:l,trayStepParts:u,runStep:o,children:(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-2`,children:t.map(e=>(0,p.jsx)(_A,{runPart:e,context:a},e.id))})});let f=c.rows*c.columns,m=new Set((c.forbidden_slots??[]).map(e=>CA(c,e.y,e.x)).filter(e=>e!==null)),h=c.orientation===`ttb`?`ttb`:`ltr`,g={"--tray-columns":c.columns,"--tray-rows":c.rows},_=mA({parts:n,slotCount:f,getOverrideSlotIndex:e=>{let t=d.get(e.id);return!t||t.tray_row==null&&t.tray_column==null?null:CA(c,t.tray_row??e.tray_row,t.tray_column??e.tray_column)},getDirectSlotIndex:e=>CA(c,e.tray_row,e.tray_column)}),v=i?pA({parts:t,slotCount:f,getSlotIndex:e=>_.get(e.id)??null}):Array.from({length:f},()=>[]);return i||t.forEach(e=>{let t=d.get(e.id),n=CA(c,t?.tray_row??e.tray_row,t?.tray_column??e.tray_column);if(n===null)return;let r=TA(t),i=v[n][0],a=i?TA(d.get(i.id)):null;a!==null&&a<r||(v[n]=[e])}),(0,p.jsx)(SA,{label:l,trayStepParts:u,runStep:o,children:(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":h,style:g,children:v.map((t,n)=>m.has(n)?(0,p.jsx)(`div`,{"aria-hidden":`true`},`slot-${e.id}-${n}`):i?(0,p.jsx)(vA,{runParts:t,context:a},`slot-${e.id}-${n}`):(0,p.jsx)(yA,{runPart:t[0]??null,context:a},`slot-${e.id}-${n}`))})})},DA=(e,t)=>!t||!t.tray_id?e.tray?.id??0:t.tray_id,OA=(e,t)=>{let n=new Map(t.map(e=>[e.part_id,e]));return e.reduce((e,t)=>{if(!t.tray)return e;let r=DA(t,n.get(t.id)),i=e.get(r)??[];return i.push(t),e.set(r,i),e},new Map)},kA=({step:e,parts:t,stepParts:n,run:r})=>{let i=(0,d.useMemo)(()=>t.filter(t=>t.part_level===e.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),[t]),a=(0,d.useMemo)(()=>{let t=new Map;for(let r of n)r.step_id===e.id&&t.set(r.part_id,r);return t},[n,e]),o=(0,d.useMemo)(()=>[...r.run_trays??[]].sort((e,t)=>e.sequence-t.sequence),[r]),s=(0,d.useMemo)(()=>OA(i,n),[i,n]),c=(0,d.useMemo)(()=>t.filter(e=>!e.tray),[t]),l=(0,d.useMemo)(()=>OA(t,n),[t,n]),u=r.run_type===pt.PRODUCTION,f=e.part_level>0,{data:h=[]}=(0,m.useQuery)({queryKey:[`runPartSelection`,e.id],queryFn:async()=>[],initialData:[],enabled:!1}),g={step:e,stepPartsById:a,allowCreate:u,selectedPartIds:h};return o.length===0||i[0]?.part_level>0?(0,p.jsx)(xA,{leveledParts:i,allNonTrayParts:c,isSplitLevel:f,context:g}):(0,p.jsx)(`div`,{className:`tray-grid-group`,children:o.map(e=>(0,p.jsx)(EA,{tray:e,trayParts:s.get(e.id)??[],trayAllParts:l.get(e.id)??[],stepParts:n,isSplitLevel:f,context:g},`tray-${e.id}`))})};function AA({run:e,step:t,parts:n,monitoredBy:r,refetchFn:i}){let{environment:a}=(0,g.useParams)(),[o,s]=(0,d.useState)(!1),c=()=>{s(!o)},[l,u]=(0,d.useState)(t.process_module.module);(0,d.useEffect)(()=>{u(t.process_module.module)},[t.process_module.module]);let[f]=(0,m.useQueries)({queries:[{queryKey:[`runStepParts`,t.id],queryFn:()=>Re({step:t}),placeholderData:m.keepPreviousData}]}),h=(0,d.useMemo)(()=>f.data?.items??[],[f.data?.items]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":o?`Collapse details`:`Expand details`,className:`fa ms-2 `+(o?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())}})}),(0,p.jsx)(`td`,{className:l.latest_module_status&&l.latest_module_status.status.is_down_status?`table-danger`:``,children:f.isLoading?(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(kA,{step:t,parts:n,stepParts:h,run:e})}),(0,p.jsxs)(`td`,{children:[r&&(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-${r.id}`,children:`Monitored by step: ${r.step.number}`}),children:(0,p.jsx)(`i`,{className:`fa fa-search me-2`})}),t.amount_of_files>0&&(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip`}),` `,t.amount_of_files]}),t.has_remark&&(0,p.jsx)(`i`,{className:`fa fa-comment-o text-warning me-3`}),t.is_finished&&(0,p.jsx)(`i`,{className:`fa fa-check text-success me-3`})]}),(0,p.jsxs)(`td`,{className:t.has_step_group?`ps-4`:``,children:[t.number,` - `,(0,p.jsx)(g.Link,{to:`/${a}/operator/run/step/${t.id}`,children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.name}})}),` `]}),(0,p.jsxs)(`td`,{children:[l.equipment&&(0,p.jsx)(g.Link,{to:`/${a}/operator/equipment/${l.equipment.id}`,className:`me-2`,children:l.equipment.name}),(0,p.jsx)(Ld,{module:l,refetchFn:()=>{i([`runSteps`])}})]})]}),o&&(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:n.length+6,children:(0,p.jsx)(cA,{step:t,refetchFn:i})})})]})}var jA=({requirement:e,result:t,show:n,setShow:r,refetchFn:i,part:a,stepPart:o})=>{let[s,c]=(0,d.useState)({}),[l,u]=(0,d.useState)(!1),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),v=(0,d.useMemo)(()=>new Map(t?.values.map(e=>[e.logging_parameter.id,e])??[]),[t?.values]);(0,d.useEffect)(()=>{if(Object.keys(s).length>0)return;let n={};for(let r of e.targets){let e=``;t!==void 0&&(e=v.get(r.logging_parameter.id)?.string_value??``),n[r.logging_parameter.id]=e}c(n)},[e,v]),(0,d.useEffect)(()=>{_(!1),h(null),u(!1)},[n]);let y=async()=>{try{h(null),_(!1),u(!0),await f.default.delete(`/delete/run/measurement/result/${t?.id??0}`),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},b=async()=>{try{h(null),_(!1),u(!0),await Promise.all(Object.entries(s).map(([e,t])=>{let n=Number.parseInt(e),r={value:t},i=v.get(n)?.id;return f.default.patch(`/update/run/measurement/result/value/${i??0}`,r)})),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},x=async()=>{let t={measurement:e.measurement.id,values:Object.entries(s).flatMap(e=>({logging_parameter:Number.parseInt(e[0]),value:e[1]}))};o&&(t.step_part=o?.id??0,t.part=a?.id??0,t.step=e.step.id??0);try{h(null),_(!1),u(!0),await f.default.post(`/create/run/measurement/result`,t),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}};return(0,p.jsxs)(K,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:t?(0,p.jsx)(p.Fragment,{children:`Update results`}):(0,p.jsx)(p.Fragment,{children:`Create result`})})}),(0,p.jsxs)(G,{onSubmit:e=>{e.preventDefault(),t?b():x()},children:[(0,p.jsxs)(K.Body,{children:[m&&(0,p.jsx)(Cr,{variant:`danger`,children:m}),g&&(0,p.jsx)(Cr,{variant:`success`,children:`Results have been updated successfully`}),e.targets.map(e=>(t?.values.find(t=>t.logging_parameter.id===e.logging_parameter.id)?.string_value,(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:e.logging_parameter.name}),(0,p.jsx)(G.Control,{type:`number`,step:`any`,placeholder:`Thickness`,value:s[e.logging_parameter.id]??``,onChange:t=>c(n=>({...n,[e.logging_parameter.id]:t.target.value}))})]},e.id)))]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{variant:`warning`,onClick:()=>r(!1),children:`Close`}),l?(0,p.jsxs)(U,{type:`submit`,variant:`info`,disabled:l,children:[(0,p.jsx)(Ml,{animation:`border`,size:`sm`,className:`me-2`}),` Updating results...`]}):t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{variant:`danger`,disabled:l,onClick:y,children:`Delete result`}),(0,p.jsx)(U,{type:`submit`,variant:`info`,disabled:l,children:`Update result`})]}):(0,p.jsx)(U,{type:`submit`,variant:`info`,disabled:l,children:`Create result`})]})]})]})},MA=(0,d.createContext)({runStep:{},setRunStep:e=>{},reloadRunStep:()=>{},run:{},modalProperties:{},setModalProperties:e=>{}});function NA({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a,editOnly:o=!1}){let{run:s}=(0,d.useContext)(MA),[c,l]=(0,d.useState)(r??[]),[u,f]=(0,d.useState)(n??[]),[h,g]=(0,d.useState)(i??[]),_=(0,m.useQueryClient)(),v=(0,m.useQueries)({queries:[{queryKey:[`runParts`,`${s?.id??`unknown`}`],queryFn:async()=>await ke({run:s}),enabled:!r||r.length===0,retry:1},{queryKey:[`runStepParts`,`${t?.run_id??`unknown`}`,`${t?.id??`unknown`}`],queryFn:async()=>await Re({step:e.requirement_for_step??e.step}),enabled:!n||n.length===0,retry:1},{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Ne({measurement:e.measurement}),enabled:!i||i.length===0,retry:1}]}),y=()=>{_.refetchQueries({queryKey:[`requirement`,`measurementResults`,e.measurement.id]})},[b,x,S]=v;(0,d.useEffect)(()=>{r&&r.length>0?l(r):b?.data&&l(b.data.items)},[r,b?.data]),(0,d.useEffect)(()=>{n&&n.length>0?f(n):x?.data&&f(x.data.items)},[n,x?.data]),(0,d.useEffect)(()=>{i&&i.length>0?g(i):S?.data&&g(S.data.items)},[i,S?.data]);let[C,w]=(0,d.useState)(null),T=r&&r.length>0?r:c,E=((n&&n.length>0?n:u)??[]).filter(e=>(T??[]).find(n=>n.id===e.part_id&&n.part_level===t.part_level)!==void 0),D=!r||r.length===0,O=!n||n.length===0,k=!i||i.length===0,A=D&&b?.isLoading||O&&x?.isLoading||k&&S?.isLoading,j=D&&b?.isError||O&&x?.isError||k&&S?.isError;if(A&&E.length===0)return(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(Ml,{animation:`border`,size:`sm`}),` `,(0,p.jsx)(`span`,{children:`Loading data…`})]});if(j&&E.length===0)return(0,p.jsxs)(Cr,{variant:`danger`,className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsx)(`div`,{children:`Failed to load required data. Please try again.`}),(0,p.jsxs)(`div`,{children:[D&&b?.isError&&(0,p.jsx)(U,{size:`sm`,variant:`outline-light`,onClick:()=>b.refetch(),children:`Retry parts`}),` `,O&&x?.isError&&(0,p.jsx)(U,{size:`sm`,variant:`outline-light`,onClick:()=>x.refetch(),children:`Retry step parts`}),` `,k&&S?.isError&&(0,p.jsx)(U,{size:`sm`,variant:`outline-light`,onClick:()=>S.refetch(),children:`Retry results`})]})]});let M=t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return``;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id===t.logging_parameter.id);return r?(r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n))?`table-danger`:`table-success`:``};return(0,p.jsx)(p.Fragment,{children:E.length>0?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Nl,{size:`sm`,striped:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{style:{width:`26%`},children:`Part`}),(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`}),!o&&(0,p.jsx)(`th`,{style:{width:`1%`}})]})}),(0,p.jsx)(`tbody`,{children:E.map(t=>{let n=h.find(e=>e.values.some(e=>e.step_part_id===t.id)),r=(n?.values??[]).filter(e=>e.step_part_id===t.id),i=e.targets.length;return e.targets.map((e,a)=>{let s=r.find(t=>t.logging_parameter.id===e.logging_parameter.id)??null;return(0,p.jsxs)(`tr`,{className:s?M(s):``,children:[a===0&&(0,p.jsxs)(`td`,{rowSpan:i,children:[T.find(e=>e.id===t.part_id)?.short_label??t.part_id,` `,(0,p.jsxs)(`small`,{className:`text-muted`,children:[`(`,t.id,`)`]})]}),(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{children:s?s.string_value:(0,p.jsx)(`span`,{className:`text-muted`,children:`not set`})}),(0,p.jsx)(`td`,{children:e.logging_parameter.unit?.abbr??``}),!o&&a===0&&(0,p.jsx)(`td`,{rowSpan:i,className:`align-middle text-nowrap`,children:(0,p.jsxs)(U,{size:`sm`,variant:n?`outline-primary`:`outline-success`,onClick:()=>w(String(t.id)),children:[(0,p.jsx)(`i`,{className:`fa fa-edit`}),` `,n?`Edit values`:`Add values`]})})]},`${t.id}:${e.logging_parameter.id}`)})})})]}),!o&&E.map(t=>{let n=h.find(e=>e.values.some(e=>e.step_part_id===t.id));return(0,p.jsx)(jA,{requirement:e,...n?{result:n}:{part:T.find(e=>e.id===t.part_id),stepPart:t},show:C===String(t.id),setShow:e=>{e||w(null)},refetchFn:a??y},`modal:${t.id}`)})]}):(0,p.jsx)(Cr,{variant:`secondary`,className:`mb-0`,children:`No selected parts`})})}function PA({requirement:e,measurementResults:t,refetchFn:n,editOnly:r=!1}){let[i,a]=(0,d.useState)(t??[]),o=(0,m.useQueryClient)(),s=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Ne({measurement:e.measurement}),enabled:!t||t.length===0,retry:1}]}),c=()=>{o.refetchQueries({queryKey:[`requirement`,`measurementResults`,e.measurement.id]})},[l]=s;(0,d.useEffect)(()=>{t&&t.length>0?a(t.filter(e=>e.values.some(e=>!e.step_part_id))):l?.data&&a(l.data.items.filter(e=>e.values.some(e=>!e.step_part_id)))},[t,l?.data]);let[u,f]=(0,d.useState)(null),[h,g]=(0,d.useState)(!1),_=s.some(e=>e.isLoading);if(s.some(e=>e.isError))return s.forEach((e,t)=>{e.isError&&console.error(`StepDashboard query error`,{index:t,error:e.error})}),(0,p.jsx)(p.Fragment,{children:`Error fetching data`});if(_)return(0,p.jsx)(`div`,{children:`Loading...`});let v=t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return``;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id===t.logging_parameter.id);return r&&(r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n))?`table-danger text-light`:``};return(0,p.jsxs)(`div`,{className:`d-flex flex-column gap-4`,children:[i.map(t=>(0,p.jsxs)(`div`,{className:`border rounded p-3 shadow-sm`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:[(0,p.jsxs)(`h6`,{className:`mb-0`,children:[`Result `,(0,p.jsxs)(`small`,{className:`text-muted`,children:[`#`,t.id]})]}),!r&&(0,p.jsxs)(U,{size:`sm`,variant:`outline-primary`,onClick:()=>f(t.id),children:[(0,p.jsx)(`i`,{className:`fa fa-edit`}),` Update value`]})]}),(0,p.jsxs)(`table`,{className:`table table-striped table-sm mb-0`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:t.values.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{className:e?v(e):``,children:e.string_value}),(0,p.jsx)(`td`,{children:e.logging_parameter.unit?.abbr??``})]},`value:${e.id}`))})]}),(0,p.jsx)(jA,{requirement:e,result:t,show:u===t.id,setShow:e=>{e||f(null)},refetchFn:n??c})]},t.id)),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(U,{size:`sm`,onClick:()=>g(!h),children:[(0,p.jsx)(`i`,{className:`fa fa-plus`}),` Add results`]})}),(0,p.jsx)(jA,{requirement:e,show:h,setShow:e=>{e||g(!1)},refetchFn:n??c})]})}function FA({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}){let{environment:o}=(0,g.useParams)();return(0,p.jsx)(W,{className:`p-4 my-3`,children:(0,p.jsx)(W.Body,{children:(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{md:`7`,children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(NA,{requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(PA,{requirement:e,measurementResults:i,refetchFn:a})]}),(0,p.jsxs)(qr,{md:`5`,children:[(0,p.jsx)(`h4`,{children:`Monitored Step`}),(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${e.requirement_for_step?.id??e.step.id}`,children:(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-search`}),` `,e.requirement_for_step?.name??e.step.name]})}),(0,p.jsx)(`h4`,{children:`Definition`}),(0,p.jsx)(`span`,{children:e.definition}),(0,p.jsx)(`h4`,{children:`Targets`}),(0,p.jsxs)(Nl,{size:`sm`,striped:!1,bordered:!1,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`parameter`}),(0,p.jsx)(`th`,{children:`min value`}),(0,p.jsx)(`th`,{children:`max value`}),(0,p.jsx)(`th`,{children:`inclusive`})]})}),(0,p.jsx)(`tbody`,{children:e.targets.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{children:e.min_value}),(0,p.jsx)(`td`,{children:e.max_value}),(0,p.jsx)(`td`,{children:e.inclusive?`yes`:`no`})]},e.id))})]}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(yk,{runStep:t,refetchFn:()=>{a([`requirements`])}})]})]})})})}var IA=({requirement:e,step:t,measurementResults:n,parts:r,stepParts:i})=>{let a=r.filter(e=>e.part_level===t.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),o=a.reduce((e,t)=>{let n=t.root_id??t.id;return e[n]||(e[n]=[]),e[n].push(t),e},{}),s=new Map(i.map(e=>[e.part_id,e])),c=new Map;for(let e of n)for(let t of e.values)t.step_part_id!==void 0&&t.step_part_id!==null&&!c.has(t.step_part_id)&&c.set(t.step_part_id,e);let l=new Map(e.targets.map(e=>[e.logging_parameter.id,e])),u=e=>{let t=s.get(e.id);if(!t)return`badge-inactive`;let n=c.get(t.id);if(!n)return``;for(let e of n.values){let t=parseFloat(e.string_value),n=l.get(e.logging_parameter.id);if(n){if(n.inclusive){if(!(n.min_value<=t&&n.max_value>=t))return`badge-failed`}else if(!(n.min_value<t&&n.max_value>t))return`badge-failed`}}return`badge-processed`},d=e=>(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-${e.id}`,children:`Level: ${e.part_level}${e.parent?`, Parent: ${e.parent.short_label}`:``}`}),children:(0,p.jsx)(`span`,{className:`badge badge-level-${e.part_level} ${u(e)} me-1`,children:e.short_label},e.id)},e.id);return(0,p.jsxs)(`div`,{children:[a[0].parent?Object.entries(o).map(([e,t])=>(0,p.jsxs)(`div`,{className:`mb-2`,children:[(0,p.jsxs)(`label`,{className:`text-muted me-1`,children:[t[0].parent?.short_label,`:`]}),` `,t.map(e=>d(e))]},e)):a.map(e=>d(e)),(0,p.jsx)(`span`,{children:`(measurements)`})]})};function LA({requirement:e,step:t,parts:n,refetchFn:r}){let{environment:i}=(0,g.useParams)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(t.process_module.module);(0,d.useEffect)(()=>{c(t.process_module.module)},[t.process_module.module]);let l=()=>{o(!a)},u=(0,m.useQueryClient)(),f=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Ne({measurement:e.measurement})},{queryKey:[`runStepParts`,e.requirement_for_step?.id??e.step.id],queryFn:()=>Re({step:e.requirement_for_step??e.step}),placeholderData:m.keepPreviousData}]}),h=e=>{e[0]===`requirement`&&u.refetchQueries({queryKey:e}),r(e)},[_,v]=f,y=f.some(e=>e.isLoading),b=(0,d.useMemo)(()=>v.data?.items??[],[v.data?.items]),x=(0,d.useMemo)(()=>_.data?.items??[],[_.data?.items]),S=(0,d.useMemo)(()=>new Map(e.targets.map(e=>[e.logging_parameter.id,e])),[e.targets]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:(e=>{if(e.length==0)return y?``:`table-info`;let t=!1;for(let n of e)if(n.values.some(e=>{if(!(e&&!isNaN(parseFloat(e.string_value))))return!1;let t=parseFloat(e.string_value),n=S.get(e.logging_parameter.id);return n?n.inclusive?!(n.min_value<=t&&n.max_value>=t):!(n.min_value<t&&n.max_value>t):!1})){t=!0;break}return t?`table-danger`:``})(x),children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":a?`Collapse details`:`Expand details`,className:`fa ms-2 `+(a?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:l,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l())}})}),(0,p.jsx)(`td`,{children:y?(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(IA,{requirement:e,step:t,measurementResults:x,parts:n,stepParts:b})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(wr,{bg:`info`,children:`requirement`}),t.amount_of_files>0&&(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip`}),` `,t.amount_of_files]}),t.has_remark&&(0,p.jsx)(`i`,{className:`fa fa-comment-o text-warning`})]}),(0,p.jsx)(`td`,{className:t.has_step_group?`ps-4`:``,children:(0,p.jsxs)(`div`,{children:[`(`,t.number,`)`,` `,(0,p.jsx)(g.Link,{to:`/${i}/operator/run/step/${t.id}`,children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.name}})}),` `]})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(g.Link,{to:`/${i}/operator/equipment/${s.equipment.id}`,className:`me-2`,children:s.equipment.name}),(0,p.jsx)(Ld,{module:s,refetchFn:()=>{r([`runSteps`])}})]})]}),a&&(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:n.length+5,children:y?`Loading...`:(0,p.jsx)(FA,{requirement:e,step:t,stepParts:b,parts:n,measurementResults:x,refetchFn:h})})})]})}var RA=e=>(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:5,style:{margin:0},className:`bg-info`,children:(0,p.jsx)(`span`,{children:e.step_group?.label})})});function zA(){let{run:e}=(0,d.useContext)(sk),{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n}=(0,d.useContext)(hk),[r,i]=(0,d.useState)(1),[a]=(0,d.useState)(25),[o,s]=(0,d.useState)(new Map),c=(0,m.useQueryClient)(),l=(0,m.useQueries)({queries:[{queryKey:[`runSteps`,JSON.stringify(e),r],queryFn:()=>Ae({run:e,page:r,pageSize:a}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>ke({run:e})},{queryKey:[`requirements`,JSON.stringify(e)],queryFn:()=>De({run:e})}]}),u=t=>{let n=[...t,JSON.stringify(e)];t[0]===`runSteps`&&n.push(r),c.refetchQueries({queryKey:n})},[f,h,g]=l,_=l.some(e=>e.isLoading),v=l.some(e=>e.isError);v&&l.forEach((t,n)=>{t.isError&&console.error(`RunStepsElement query error`,{index:n,error:t.error,run:e})});let y=(0,d.useMemo)(()=>f.data?.items??[],[f.data?.items]),b=(0,d.useMemo)(()=>h.data?.items??[],[h.data?.items]),x=(0,d.useMemo)(()=>g.data?.items??[],[g.data?.items]);if((0,d.useEffect)(()=>{s(e=>{let t=new Map(e);return y.forEach(e=>{let n=e.label?.id;n!==void 0&&!t.has(n)&&t.set(n,!0)}),t})},[y]),_)return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center`,children:(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`2rem`,height:`1rem`,borderRadius:`0.5rem`}})}),(0,p.jsx)(q,{animation:`glow`,as:`span`,className:`ms-2`,children:(0,p.jsx)(q,{style:{width:`15rem`}})})]})}),(0,p.jsxs)(Nl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Parts`}),(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Process`}),(0,p.jsx)(`th`,{children:`Equipment`})]})}),(0,p.jsx)(`tbody`,{children:[1,2].map(e=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:5,className:`bg-info`,children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`0.75rem`}})})}),(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`10rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`12rem`}})})})]})]},e))})]})]});if(v)return(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run steps.`});let S=new Set,C=y.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||S.has(String(e.step_group.id))?!1:(S.add(String(e.step_group.id)),!0)),w={};for(let e of x)e.requirement_for_step!=null&&(w[String(e.requirement_for_step.id)]=e);let T=e=>{let t=e.label,n=t?.id;if(!e.is_own_label||!t||n===void 0)return null;let r=e=>{s(t=>{let n=new Map(t);return n.set(e,!n.get(e)),n})};return(0,p.jsx)(`tr`,{style:{cursor:`pointer`},onClick:()=>r(n),children:(0,p.jsx)(`td`,{colSpan:5,style:{margin:0},className:`bg-secondary`,children:(0,p.jsxs)(`span`,{className:`label-toggle`,children:[(0,p.jsx)(`i`,{className:`fa `+(o.get(e.label?.id??-1)?`fa-caret-down`:`fa-caret-right`)}),` `,t.label]})})})};return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center`,children:(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(`input`,{type:`checkbox`,id:`showOnlyEmphasizedParameters`,checked:t,className:`form-check-input`,"data-toggle":`toggle`,onChange:()=>n(!t)}),(0,p.jsx)(`label`,{htmlFor:`showOnlyEmphasizedParameters`,className:`ms-2`,children:`Show only emphasized parameters`})]})}),(0,p.jsxs)(Nl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Parts`}),(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Process`}),(0,p.jsx)(`th`,{children:`Equipment`})]})}),(0,p.jsx)(`tbody`,{children:y.map(t=>{let n=`step-${t.id}`;return(0,p.jsxs)(d.default.Fragment,{children:[t.has_label&&T(t),(!t.has_label||o.get(t.label?.id??-1))&&(0,p.jsxs)(p.Fragment,{children:[t.has_step_group&&C.includes(t)&&RA(t),t.has_requirement?(0,p.jsx)(LA,{requirement:x.find(e=>e.step.id===t.id),step:t,parts:b,refetchFn:u}):(0,p.jsx)(AA,{run:e,step:t,parts:b,monitoredBy:w[t.id],refetchFn:u})]})]},n)})})]}),(0,p.jsx)(KO,{data:f.data,setPage:i,isPlaceholderData:f.isPlaceholderData})]})}var BA=[],VA=new Set,HA=(e,t,n)=>{let r=e[t]??[];if(r.length===n.length&&r.every((e,t)=>e===n[t])||n.length===0&&!(t in e))return e;let i={...e};return n.length>0?i[t]=n:delete i[t],i},UA=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n};function WA(){let[e,t]=(0,d.useState)([]),[n,r]=(0,d.useState)({}),[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)({}),c=(0,d.useMemo)(()=>{let e={};for(let[t,r]of Object.entries(n))e[Number(t)]=new Set(r);return e},[n]);return{selectedRuns:e,partIdsByRunId:n,amountPerPartByRunId:i,descriptionsByRunId:o,selectRun:(0,d.useCallback)(e=>{t(t=>t.some(t=>t.id===e.id)?t:[...t,e])},[]),deselectRun:(0,d.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e)),r(t=>HA(t,e,[])),a(t=>UA(t,e)),s(t=>UA(t,e))},[]),getSelectedPartIds:(0,d.useCallback)(e=>n[e]??BA,[n]),isPartSelected:(0,d.useCallback)((e,t)=>(c[e]??VA).has(t),[c]),setRunPartIds:(0,d.useCallback)((e,t)=>{r(n=>HA(n,e,t))},[]),togglePart:(0,d.useCallback)((e,t)=>{r(n=>{let r=n[e]??[];return HA(n,e,r.includes(t)?r.filter(e=>e!==t):[...r,t])})},[]),setPartsSelected:(0,d.useCallback)((e,t,n)=>{r(r=>{let i=r[e]??[],a;if(n){let e=new Set(i);t.forEach(t=>e.add(t)),a=[...e]}else{let e=new Set(t);a=i.filter(t=>!e.has(t))}return HA(r,e,a)})},[]),getPartAmount:(0,d.useCallback)((e,t)=>i[e]?.[t]??1,[i]),setPartAmount:(0,d.useCallback)((e,t,n)=>{let r=Number.isFinite(n)?Math.max(1,n):1;a(n=>(n[e]?.[t]??1)===r?n:{...n,[e]:{...n[e]??{},[t]:r}})},[]),setDescription:(0,d.useCallback)((e,t)=>{s(n=>{if((n[e]??``)===t||!t&&!(e in n))return n;let r={...n};return t?r[e]=t:delete r[e],r})},[])}}function GA(e,t){return t.selectedRuns.map(n=>{let r=t.partIdsByRunId[n.id]??[],i=t.amountPerPartByRunId[n.id]??{},a=r.length>0?Object.fromEntries(r.map(e=>[e,i[e]??1])):null;return{run_id:e,parent_run_id:n.id,part_ids:r,amount_per_part:a,description:t.descriptionsByRunId[n.id]||null}})}var KA=(e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left,qA=e=>{let t=new Map;for(let n of e){let e=t.get(n.part_level)??[];e.push(n),t.set(n.part_level,e)}return Array.from(t.entries()).toSorted(([e],[t])=>e-t).map(([e,t])=>({level:e,parts:t.toSorted(KA)}))},JA=e=>e.parsed_label||e.scanner_label||e.label||e.short_label;function YA({runId:e,part:t,selection:n}){let r=n.isPartSelected(e,t.id),i=JA(t),a=`part-amount-${e}-${t.id}`,o=`part-selected-${e}-${t.id}`;return(0,p.jsxs)(`div`,{className:`list-group-item d-flex align-items-center gap-3 flex-wrap${r?` border-primary border-top`:``}`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(G.Label,{htmlFor:a,className:`small text-secondary mb-0`,children:`Split`}),(0,p.jsx)(G.Control,{id:a,type:`number`,size:`sm`,min:1,step:`any`,inputMode:`decimal`,value:n.getPartAmount(e,t.id),onChange:r=>n.setPartAmount(e,t.id,Number(r.target.value)),"aria-label":`Experimental split amount for ${i}`,style:{maxWidth:`7rem`}})]}),(0,p.jsx)(`label`,{htmlFor:o,className:`flex-grow-1 mb-0`,style:{cursor:`pointer`},children:i}),(0,p.jsx)(G.Check,{id:o,type:`checkbox`,checked:r,onChange:()=>n.togglePart(e,t.id),"aria-label":`Select ${i}`,className:`ms-sm-auto`})]})}function XA({runId:e,part:t,selection:n}){let r=n.isPartSelected(e,t.id);return(0,p.jsx)(wr,{as:`button`,type:`button`,bg:r?`primary`:`dark`,onClick:()=>n.togglePart(e,t.id),"aria-pressed":r,title:t.label,className:`border-0 fs-6 fw-normal px-3 py-2${r?` step-part-selected`:``}`,style:{cursor:`pointer`},children:JA(t)})}function ZA({runId:e,group:t,selection:n,experimentalEdit:r}){let i=t.parts.length>0&&t.parts.every(t=>n.isPartSelected(e,t.id));return(0,p.jsxs)(`fieldset`,{className:`mb-4 border-0 p-0`,children:[(0,p.jsxs)(`legend`,{className:`d-flex align-items-center gap-2 fs-6 fw-semibold mb-2`,children:[(0,p.jsxs)(`span`,{children:[`Level `,t.level]}),(0,p.jsx)(wr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:t.parts.length}),(0,p.jsx)(U,{variant:`link`,size:`sm`,className:`p-0 ms-1`,onClick:()=>{n.setPartsSelected(e,t.parts.map(e=>e.id),!i)},children:i?`Deselect all`:`Select all`})]}),r?(0,p.jsx)(`div`,{className:`list-group`,children:t.parts.map(t=>(0,p.jsx)(YA,{runId:e,part:t,selection:n},t.id))}):(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-2`,children:t.parts.map(t=>(0,p.jsx)(XA,{runId:e,part:t,selection:n},t.id))})]})}function QA({run:e,selection:t,partGroups:n,isLoadingParts:r,experimentalEdit:i,onToggleExperimentalEdit:a}){let o=t.getSelectedPartIds(e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`h3`,{children:`Description`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:3,value:t.descriptionsByRunId[e.id]??``,onChange:n=>t.setDescription(e.id,n.target.value),placeholder:`Enter a description for ${e.label}`})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between mb-3`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`mb-1`,children:`Select parts`}),(0,p.jsx)(U,{variant:i?`outline-primary`:`primary`,size:`sm`,onClick:a,"aria-pressed":i,children:i?`Done editing split`:`Edit experimental split`}),i&&(0,p.jsx)(`p`,{className:`text-secondary small mb-0 mt-1`,children:`Amounts must be 1 or higher.`}),(0,p.jsxs)(`p`,{className:`text-secondary mb-0`,children:[e.label,` — `,e.name]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[o.length>0&&(0,p.jsxs)(`span`,{className:`text-secondary small`,children:[o.length,` selected`]}),(0,p.jsx)(U,{variant:`link`,size:`sm`,className:`p-0`,onClick:()=>t.setRunPartIds(e.id,[]),children:`Clear`})]})]}),r&&(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2 text-secondary`,children:[(0,p.jsx)(Ml,{animation:`border`,size:`sm`,role:`status`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{children:`Loading parts…`})]}),!r&&n.length===0&&(0,p.jsx)(`p`,{className:`text-secondary mb-0`,children:`This run has no parts to select.`}),!r&&n.map(n=>(0,p.jsx)(ZA,{runId:e.id,group:n,selection:t,experimentalEdit:i},n.level))]})}function $A({selectedRuns:e,onDeselect:t}){return(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between mb-2`,children:[(0,p.jsx)(`h3`,{className:`mb-0`,children:`Selected runs`}),e.length>0&&(0,p.jsx)(wr,{bg:`primary`,pill:!0,className:`fw-normal`,children:e.length})]}),e.length===0&&(0,p.jsx)(`p`,{className:`text-secondary mb-0`,children:`Select one or more parent runs to configure their parts.`}),e.length>0&&(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:e.map(e=>(0,p.jsxs)(`div`,{className:`d-flex flex-column gap-2 bg-body-secondary rounded p-2`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`fw-semibold`,children:[e.label,` — `,e.name]}),(0,p.jsx)(`div`,{className:`text-secondary small`,children:`Included in creation`})]}),(0,p.jsx)(`div`,{className:`d-flex align-items-center gap-2`,children:(0,p.jsx)(U,{variant:`outline-danger`,size:`sm`,onClick:()=>t(e.id),children:`Deselect`})})]},e.id))})]})}var ej=e=>qA(e.items??[]),tj=e=>({value:e.id,label:`${e.label} — ${e.name}`,run:e}),nj=Xb;function rj({selection:e,run:t}){let{environment:n}=(0,g.useParams)(),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),{selectedRuns:s}=e,{data:c,isFetching:l}=(0,m.useQuery)({queryKey:[n],queryFn:()=>je({environment:n,availableAsParentForRun:t})}),u=(0,m.useQueries)({queries:s.map(e=>({queryKey:[e.id],queryFn:()=>ke({run:e}),select:ej}))}),f=(0,d.useMemo)(()=>c?.items??[],[c]),h=(0,d.useMemo)(()=>f.map(tj),[f]),_=r===null?0:Math.max(0,s.findIndex(e=>e.id===r)),v=s[_]??null,y=u[_],b=async e=>{let t=e.toLowerCase(),n=[];for(let e of f)(!t||e.label.toLowerCase().includes(t)||e.name.toLowerCase().includes(t))&&n.push(tj(e));return n},x=t=>{e.selectRun(t),i(t.id)};return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`h3`,{children:`Select parent runs`}),(0,p.jsx)(qb,{isSearchable:!0,isClearable:!0,defaultOptions:h,placeholder:`— Select a run, or start typing`,loadOptions:b,isLoading:l,value:null,styles:nj,onChange:e=>{e&&x(e.run)}})]}),(0,p.jsx)($A,{selectedRuns:s,onDeselect:e.deselectRun}),s.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)($c,{variant:`tabs`,activeKey:v===null?void 0:`run-${v.id}`,onSelect:e=>{e?.startsWith(`run-`)&&i(Number(e.replace(`run-`,``)))},className:`mb-3`,children:s.map(e=>(0,p.jsx)($c.Item,{children:(0,p.jsx)($c.Link,{eventKey:`run-${e.id}`,children:e.label})},e.id))}),(0,p.jsx)(`div`,{className:`ms-2 ps-2`,children:v&&(0,p.jsx)(QA,{run:v,selection:e,partGroups:y?.data??[],isLoadingParts:y?.isFetching??!1,experimentalEdit:a,onToggleExperimentalEdit:()=>o(e=>!e)},v.id)})]})]})}function ij({title:e,children:t}){return(0,p.jsxs)(`fieldset`,{children:[(0,p.jsx)(`legend`,{className:`fs-5 mb-0`,children:e}),t]})}var aj=e=>{if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null};function oj({controlId:e,label:t,options:n,isLoading:r,value:i,onChange:a,showError:o,disabled:s,helpText:c}){let l=t.toLowerCase(),u=`${l}s`;return(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:e,children:[(0,p.jsxs)(G.Label,{column:!0,sm:3,children:[t,` `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsxs)(G.Select,{value:i??``,onChange:e=>a(aj(e.target.value)),required:!0,disabled:s,isInvalid:o,children:[(0,p.jsx)(`option`,{value:``,children:r?`Loading ${u}...`:`— Select a ${l}`}),n.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),o&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:r?`${t}s are still loading.`:`— Select a ${l}.`}),(0,p.jsx)(G.Text,{muted:!0,children:c})]})]})}function sj({title:e,isEmpty:t,children:n}){return t?``:(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`text-secondary mb-2`,children:[e,` `,(0,p.jsx)(`span`,{className:`text-body-tertiary`,children:`(selected previously)`})]}),(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:n})]})}function cj({selectedRuns:e,selectedSubstrates:t,partIdsByRunId:n}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(sj,{title:`Parent runs & parts`,isEmpty:e.length===0,children:e.map(e=>{let t=n[e.id]?.length??0;return(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between gap-3 bg-body-secondary border-0 rounded p-2`,children:[(0,p.jsxs)(`div`,{className:`fw-semibold`,children:[e.label,` — `,e.name]}),t>0?(0,p.jsxs)(wr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:[t,` `,t===1?`part`:`parts`]}):(0,p.jsx)(`span`,{className:`text-secondary fst-italic small`,children:`No parts selected`})]},e.id)})}),(0,p.jsx)(sj,{title:`Substrates`,isEmpty:t.length===0,children:t.map(({substrate:e,amount:t})=>(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between gap-3 bg-body-secondary rounded p-2`,children:[(0,p.jsxs)(`div`,{className:`fw-semibold`,children:[e.label,` — `,e.short_label]}),(0,p.jsxs)(wr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:[`Amount: `,t]})]},e.id))})]})}function lj({isSubmitting:e,errorMessage:t,selectedRuns:n,selectedSubstrates:r,partIdsByRunId:i,onBack:a,onSubmit:o}){let{environment:s}=(0,g.useParams)(),[c,l]=(0,d.useState)(``),[u,f]=(0,d.useState)(``),[h,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(pt.RESEARCH),[w,T]=(0,d.useState)(1),[E,D]=(0,d.useState)(``),[O,k]=(0,d.useState)(!1),{data:A,isError:j,isLoading:M}=(0,m.useQuery)({queryKey:[`organisation-groups`,s],queryFn:()=>_e({environment:s})}),{data:N,isError:P,isLoading:F}=(0,m.useQuery)({queryKey:[`organisation-teams`,s,ht.Run],queryFn:()=>ye({environment:s,purpose:ht.Run})}),{data:I,isError:L,isLoading:ee}=(0,m.useQuery)({queryKey:[`organisation-projects`,s,mt.Run],queryFn:()=>ve({environment:s,purpose:mt.Run})}),te=c.trim(),ne=u.trim(),re=M||F||ee,ie=j||P||L,ae=A?.items??[],oe=N?.items??[],se=I?.items??[],ce=h!==null&&ae.some(e=>e.id===h),le=v!==null&&oe.some(e=>e.id===v),R=b!==null&&se.some(e=>e.id===b),ue=te===``,de=ne===``,fe=O&&ue,pe=O&&de,me=!ue&&!de&&ce&&le&&R&&!re&&!ie&&!e;return(0,p.jsxs)(G,{noValidate:!0,onSubmit:e=>{e.preventDefault(),k(!0),me&&o({name:te,motivation:ne,groupId:h,teamId:v,projectId:b,parts:Number.isFinite(w)?Math.max(1,w):1,location:E,runType:S})},className:`form-horizontal`,children:[(0,p.jsxs)(ij,{title:`Details`,children:[(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-name`,children:[(0,p.jsxs)(G.Label,{column:!0,sm:3,children:[`Run name `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsx)(G.Control,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Give a run name`,required:!0,disabled:e,isInvalid:fe}),fe&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:`Run name is required.`}),(0,p.jsx)(G.Text,{muted:!0,children:`Give a short and descriptive name for the run`})]})]}),(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-location`,children:[(0,p.jsx)(G.Label,{column:!0,sm:3,children:`Sample location`}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsx)(G.Control,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`Location of the samples`,disabled:e}),(0,p.jsx)(G.Text,{muted:!0,children:`Give here the location where the run samples are stored`})]})]}),(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-motivation`,children:[(0,p.jsxs)(G.Label,{column:!0,sm:3,children:[`Motivation `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:3,value:u,onChange:e=>f(e.target.value),placeholder:`Why is this run being created?`,required:!0,disabled:e,isInvalid:pe}),pe&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:`Motivation is required.`}),(0,p.jsx)(G.Text,{muted:!0,children:`Explain here the motivation for this run`})]})]})]}),(0,p.jsxs)(ij,{title:`Organisation`,children:[O&&ie&&(0,p.jsx)(Cr,{variant:`warning`,children:`Could not load organisation values.`}),(0,p.jsx)(oj,{controlId:`create-run-group`,label:`Group`,options:ae,isLoading:M,value:h,onChange:_,showError:O&&!ce,disabled:e,helpText:`Select the group to which this run belongs`}),(0,p.jsx)(oj,{controlId:`create-run-team`,label:`Team`,options:oe,isLoading:F,value:v,onChange:y,showError:O&&!le,disabled:e,helpText:`Select the team to which this run belongs`}),(0,p.jsx)(oj,{controlId:`create-run-project`,label:`Project`,options:se,isLoading:ee,value:b,onChange:x,showError:O&&!R,disabled:e,helpText:`Select the project to which this run belongs`})]}),(0,p.jsx)(ij,{title:`Parts`,children:(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-parts`,children:[(0,p.jsx)(G.Label,{column:!0,sm:3,children:`Experimental split`}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsx)(G.Control,{type:`number`,min:1,step:1,value:w,onChange:e=>T(Number(e.target.value)),disabled:e}),(0,p.jsx)(G.Text,{muted:!0,children:`Select here the amount of parts (experimental split) this run has, give only the main amount of parts, individual parts can be split later`})]})]})}),(0,p.jsx)(ij,{title:`Type`,children:(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-type`,children:[(0,p.jsx)(G.Label,{column:!0,sm:3,children:`Run type`}),(0,p.jsx)(qr,{sm:9,children:(0,p.jsxs)(G.Select,{value:S,onChange:e=>C(e.target.value),disabled:e,children:[(0,p.jsx)(`option`,{value:pt.RESEARCH,children:`Research`}),(0,p.jsx)(`option`,{value:pt.PRODUCTION,children:`Production`})]})})]})}),(0,p.jsx)(jl,{className:`my-3`,children:(0,p.jsx)(qr,{sm:9,className:`offset-sm-3`,children:(0,p.jsx)(cj,{selectedRuns:n,selectedSubstrates:r,partIdsByRunId:i})})}),t&&(0,p.jsx)(Cr,{variant:`danger`,className:`mb-4`,children:t}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-end mt-4 gap-3`,children:[(0,p.jsx)(U,{variant:`outline-secondary`,type:`button`,onClick:a,disabled:e,children:`Back`}),(0,p.jsx)(U,{variant:`primary`,type:`submit`,disabled:e,children:e?`Creating...`:`Create Run`})]})]})}var uj=e=>{if(e instanceof Error&&e.message!==``)return e.message;if(typeof e==`object`&&e&&`response`in e&&typeof e.response==`object`&&e.response!==null){let t=e.response;if(typeof t.data?.message==`string`)return t.data.message;if(typeof t.data?.detail==`string`)return t.data.detail}return`Could not create the run.`},dj=e=>({value:e.id,label:`${e.label} — ${e.short_label}`,substrate:e}),fj=async e=>(await Xe({query:e||void 0})).items.map(dj),pj=Xb;function mj({selectedSubstrates:e,setSelectedSubstrates:t}){let n=e=>{t(t=>t.some(t=>t.substrate.id===e.id)?t:[...t,{substrate:e,amount:1}])},r=(e,n)=>{let r=Number.isFinite(n)?Math.max(0,n):0;t(t=>t.map(t=>t.substrate.id===e?{...t,amount:r}:t))},i=e=>{t(t=>t.filter(t=>t.substrate.id!==e))};return(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`h3`,{children:`Select substrate`}),(0,p.jsx)(qb,{isSearchable:!0,isClearable:!0,defaultOptions:!0,placeholder:`— Select a substrate, or start typing`,loadOptions:fj,value:null,styles:pj,onChange:e=>{e&&n(e.substrate)}}),e.length>0&&(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2 mt-3`,children:e.map(({substrate:e,amount:t})=>(0,p.jsxs)(`div`,{className:`d-flex flex-column gap-2 bg-body-secondary rounded p-2`,children:[(0,p.jsxs)(`div`,{className:`fw-semibold`,children:[e.label,` — `,e.short_label]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(U,{variant:`outline-danger`,size:`sm`,onClick:()=>i(e.id),"aria-label":`Deselect ${e.label}`,children:`Deselect`}),(0,p.jsx)(G.Control,{type:`number`,min:0,step:1,value:t,className:`flex-grow-1`,onChange:t=>r(e.id,Number(t.target.value)),"aria-label":`Amount for ${e.label}`})]})]},e.id))})]})}function hj(){let{environment:e}=(0,g.useParams)(),t=(0,g.useNavigate)(),n=(0,m.useQueryClient)(),[r,i]=(0,d.useState)(`parts`),[a,o]=(0,d.useState)([]),s=WA(),c=(0,m.useMutation)({mutationFn:async({runValues:e,parentRuns:t,substrates:n})=>{let r=await be({name:e.name,motivation:e.motivation,group_id:e.groupId,team_id:e.teamId,project_id:e.projectId,parts:e.parts,location:e.location||null,run_type:e.runType}),i=GA(r.id,t).map(e=>xe(e)),a=n.map(({substrate:e,amount:t})=>Se({run_id:r.id,substrate_id:e.id,amount:t}));return await Promise.all([...i,...a]),r},onSuccess:(r,i)=>{n.invalidateQueries({queryKey:[e]}),n.invalidateQueries({queryKey:[r.id]}),i.parentRuns.selectedRuns.forEach(e=>{n.invalidateQueries({queryKey:[e.id]})}),t(`/${e}/run/${r.id}/information.html`)}});return(0,p.jsxs)(`div`,{children:[r!==`details`&&(0,p.jsxs)($c,{variant:`tabs`,activeKey:r,onSelect:e=>{(e===`parts`||e===`substrate`)&&i(e)},className:`mb-4`,children:[(0,p.jsx)($c.Item,{children:(0,p.jsx)($c.Link,{eventKey:`parts`,children:`Parent run and parts`})}),(0,p.jsx)($c.Item,{children:(0,p.jsx)($c.Link,{eventKey:`substrate`,children:`Select Substrate`})})]}),(0,p.jsxs)(`div`,{className:`m-3`,children:[r===`parts`&&(0,p.jsx)(rj,{selection:s}),r===`substrate`&&(0,p.jsx)(mj,{selectedSubstrates:a,setSelectedSubstrates:o}),r===`details`&&(0,p.jsx)(lj,{isSubmitting:c.isPending,errorMessage:c.isError?uj(c.error):void 0,selectedRuns:s.selectedRuns,selectedSubstrates:a,partIdsByRunId:s.partIdsByRunId,onBack:()=>i(`parts`),onSubmit:e=>{c.mutate({runValues:e,parentRuns:s,substrates:a})}}),r!==`details`&&(0,p.jsx)(`div`,{className:`d-flex justify-content-end mt-4`,children:(0,p.jsx)(U,{variant:`primary`,disabled:c.isPending,onClick:()=>{i(`details`)},children:`Continue`})})]})]})}function gj(){let{environment:e}=(0,g.useParams)(),{run:t,reloadRun:n}=(0,d.useContext)(sk),r=(0,m.useQueryClient)(),i=WA(),a=(0,m.useMutation)({mutationFn:async e=>Promise.all(GA(t.id,e).map(e=>xe(e))),onSuccess:(i,a)=>{n(),r.invalidateQueries({queryKey:[e]}),r.invalidateQueries({queryKey:[t.id]}),a.selectedRuns.forEach(e=>{r.invalidateQueries({queryKey:[e.id]})})}});return(0,p.jsx)(`div`,{children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(rj,{selection:i,run:t}),(0,p.jsx)(`div`,{className:`d-flex justify-content-end mt-4`,children:(0,p.jsx)(U,{variant:`primary`,disabled:i.selectedRuns.length===0||a.isPending,onClick:()=>{i.selectedRuns.length>0&&a.mutate(i)},children:a.isPending?`Adding...`:`Add Parent Runs`})}),a.isSuccess&&a.data.length>0&&(0,p.jsxs)(Cr,{variant:`success`,className:`mt-3`,children:[`Parent runs added to `,t.label??`#${t.id}`,`.`]})]})})}function _j(){let{run:e}=(0,d.useContext)(sk),{environment:t}=(0,g.useParams)(),n=e.run_type===pt.RESEARCH,r=e.run_type===pt.PRODUCTION,i=n?`Research`:r?`Production`:String(e.run_type);return(0,p.jsxs)(`div`,{className:`row g-4 mt-1`,children:[(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-tag text-primary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Name`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.name??`—`}),`c`]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa ${n?`fa-flask text-info`:`fa-industry text-primary`} mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Run Type`}),(0,p.jsx)(`span`,{className:`badge ${n?`bg-info`:`bg-primary`}`,children:i})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-plus-o text-muted mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Created`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.date_created?new Date(e.date_created).toLocaleDateString():`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-certificate mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Status`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.status??`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-user-circle-o text-warning mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Responsible`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.responsible?.full_name??`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-play-circle-o text-success mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Start Date`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.start_date?new Date(e.start_date).toLocaleDateString():`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-briefcase text-secondary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Project`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.project?.name??`No project`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-tasks text-primary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Steps`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.amount_of_steps??`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-clock-o text-muted mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Last Update`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.last_update?new Date(e.last_update).toLocaleDateString():`—`})]})]})}),e.priority&&(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-flag text-danger mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Priority`}),(0,p.jsx)(`span`,{className:`badge bg-danger`,children:e.priority.priority.code}),e.priority.description&&(0,p.jsx)(`div`,{className:`text-muted small mt-1`,children:e.priority.description})]})]})}),e.hold_code&&(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-ban text-danger mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Hold Code`}),(0,p.jsx)(`span`,{className:`badge bg-danger`,children:e.hold_code.hold_code.code}),e.hold_code.description&&(0,p.jsx)(`div`,{className:`text-muted small mt-1`,children:e.hold_code.description})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-users text-secondary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Team`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:(0,p.jsx)(g.Link,{to:`${bt()}${t}/organisation/team/details/${e.team.id}/responsible-users.html`,children:e.team?.name??`—`})})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-object-group text-secondary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Group`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:(0,p.jsx)(g.Link,{to:`${bt()}${t}/organisation/group/details/${e.group.id}/responsible-users.html`,children:e.group?.name??`—`})})]})]})})]})}var vj=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};function yj(){let{run:e}=(0,d.useContext)(sk),[t,n]=(0,d.useState)([]),[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(!1),s=(0,m.useQueryClient)(),{environment:c}=(0,g.useParams)(),{data:l,isLoading:u}=(0,m.useQuery)({queryKey:[`run-files`,e.id],queryFn:()=>Ee({run:e}),enabled:!!e?.id}),f=l?.items??[],h=()=>{s.refetchQueries({queryKey:[`run-files`,e.id]})},{getRootProps:_,getInputProps:v,isDragActive:y,isDragAccept:b,isDragReject:x}=Hb({onDrop:e=>{n(t=>[...t,...e]),i(`${e.length} file(s) selected`)}}),S=(0,d.useMemo)(()=>({...y?{borderColor:`#83afee`}:{},...b?{borderColor:`#00e676`}:{},...x?{borderColor:`#ff1744`}:{}}),[b,x,y]),C=()=>{if(t.length===0)return;o(!0),i(`Uploading...`);let r=0,a=t.length,s=0;t.forEach(t=>{let c=new FileReader;c.onload=async()=>{let l=c.result;try{await Me({filename:t.name,type:t.type,content:l,run:e})}catch(e){s+=1,console.error(e)}finally{r+=1,r===a&&(o(!1),n([]),i(s===0?`Files uploaded successfully`:`Upload finished with ${s} error(s)`),h())}},c.readAsDataURL(t)})},w=async e=>{if(confirm(`Are you sure you want to delete ${e.name}? You can not undo this action`))try{await Ce({file:e}),h()}catch(e){console.error(e)}};return(0,p.jsxs)(`div`,{className:`mt-5`,children:[(0,p.jsxs)(`h3`,{className:`h5 mb-3`,children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip text-secondary me-2`,"aria-hidden":`true`}),`Files`]}),u?(0,p.jsxs)(Nl,{hover:!0,striped:!0,responsive:!0,className:`align-middle`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{style:{width:`3rem`},children:`No`}),(0,p.jsx)(`th`,{children:`File`}),(0,p.jsx)(`th`,{children:`Size`}),(0,p.jsx)(`th`,{children:`Date`}),(0,p.jsx)(`th`,{style:{width:`8rem`},className:`text-end`,children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:8})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:6})})}),(0,p.jsx)(`td`,{className:`text-end`,children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:10})})})]})})]}):f.length>0?(0,p.jsxs)(Nl,{hover:!0,striped:!0,responsive:!0,className:`align-middle`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{style:{width:`3rem`},children:`No`}),(0,p.jsx)(`th`,{children:`File`}),(0,p.jsx)(`th`,{children:`Size`}),(0,p.jsx)(`th`,{children:`Date`}),(0,p.jsx)(`th`,{style:{width:`8rem`},className:`text-end`,children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:f.map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t+1})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(g.Link,{to:`${bt()}/${c}/file/download/${e.id}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(wr,{className:`ms-2 bg-primary`,children:`Logging`})]}),(0,p.jsx)(`td`,{children:vj(e.size)}),(0,p.jsx)(`td`,{children:zD(e.date_created,`DD-MM-YY HH:mm`)}),(0,p.jsxs)(`td`,{className:`text-end`,children:[(0,p.jsx)(U,{size:`sm`,variant:`outline-primary`,className:`me-2`,onClick:()=>{window.location.href=`${bt()}/${c}/file/download/${e.id}`},"aria-label":`Download ${e.name}`,title:`Download`,children:(0,p.jsx)(`i`,{className:`fa fa-download`,"aria-hidden":`true`})}),(0,p.jsx)(U,{size:`sm`,variant:`outline-danger`,onClick:()=>w(e),"aria-label":`Delete ${e.name}`,title:`Delete`,children:(0,p.jsx)(`i`,{className:`fa fa-trash-o`,"aria-hidden":`true`})})]})]},e.id))})]}):(0,p.jsx)(`div`,{className:`text-muted fst-italic mb-3`,children:`No files uploaded yet`}),(0,p.jsxs)(`div`,{..._({style:S,className:`dropzone bg-secondary-subtle border rounded dz-clickable`}),children:[(0,p.jsx)(`input`,{...v()}),y?(0,p.jsx)(`p`,{children:`Drop files here...`}):(0,p.jsx)(`p`,{children:`Drag and drop files here or click to select`})]}),t.length>0&&(0,p.jsx)(nc,{className:`mt-3`,children:t.map(e=>(0,p.jsxs)(nc.Item,{className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsx)(`span`,{children:e.name}),(0,p.jsx)(`small`,{className:`text-muted`,children:vj(e.size)})]},`${e.name}-${e.lastModified}`))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(U,{className:`mt-3`,onClick:C,disabled:t.length===0||a,children:a?`Uploading...`:`Upload Selected Files`}),r&&(0,p.jsx)(`p`,{className:`mt-2 text-muted small`,children:r})]})]})}function bj(){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run information`}),(0,p.jsx)(_j,{}),(0,p.jsx)(yj,{})]})}var xj=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t.id))},Sj=e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`};function Cj({step:e,tray:t,parts:n,stepParts:r}){let i=(0,m.useQueryClient)(),a=t.tray_type,o=t.label?`${t.name} - ${t.label}`:t.name,s=(0,d.useMemo)(()=>new Map(n.map(e=>[e.id,e])),[n]),c=(0,d.useMemo)(()=>new Map(r.map(e=>[e.id,e])),[r]),l=async(t,n,o,l)=>{t.preventDefault();let u=Number(t.dataTransfer.getData(`text/plain`)),d=c.get(u);if(!d){console.error(`Unable to update run step part tray: stepPart not found`);return}if(a&&(a.forbidden_slots??[]).some(e=>e.x===l&&e.y===o))return;let f=s.get(d.part_id);if((d.tray_id??f?.tray?.id)===n.id&&(d.tray_column??f?.tray_column)===l&&(d.tray_row??f?.tray_row)===o)return;if(r.find(t=>{if(t.id===d.id||t.step_id!==e.id||t.has_failed_in_previouse_state||t.failed)return!1;let r=s.get(t.part_id);return(t.tray_id??r?.tray?.id)===n.id&&(t.tray_row??r?.tray_row)===o&&(t.tray_column??r?.tray_column)===l})){Yk({notificationHeader:`Tray part change`,notificationBody:`This position is occupied by a part that has not failed in this or a previous step.`,notificationType:`danger`});return}let p={...d,tray_id:n.id,tray_row:o,tray_column:l};zk(i,e,p);try{let t=await ze(d,n,o,l,!0);zk(i,e,t.data,{updateSubsequent:!0}),Yk({notificationHeader:`Tray part change`,notificationBody:`Part moved successfully`,notificationType:`success`})}catch(t){zk(i,e,d),Yk({notificationHeader:`Tray part change`,notificationBody:Ej(t),notificationType:`danger`})}};if(!a?.rows||!a?.columns)return(0,p.jsx)(`section`,{className:`tray-visual my-2`,"aria-label":t.name,children:`TODO HANDLE CASE WHERE TRAY TYPE IS WRONG`});let u=a.rows*a.columns,f={"--tray-rows":a.rows,"--tray-columns":a.columns},h=new Set((a.forbidden_slots??[]).map(e=>wj(a,e.y,e.x)).filter(e=>e!==null)),g=Array.from({length:u},()=>null);return r.forEach(e=>{let t=s.get(e.part_id);if(!t)return;let n=wj(a,e.tray_row??t.tray_row,e.tray_column??t.tray_column);if(n===null){console.log(e);return}if(e.has_failed_in_previouse_state)return;let r=Dj(e),i=g[n],o=i?Dj(i):null;o!==null&&o<r||(g[n]=e)}),(0,p.jsxs)(`section`,{className:`tray-visual my-2`,style:f,"aria-label":t.name,children:[(0,p.jsx)(`h4`,{className:`h6 mb-2`,children:o}),(0,p.jsx)(`div`,{className:`tray-visual__frame`,children:(0,p.jsx)(`div`,{className:`tray-visual__grid`,"data-orientation":a.orientation===`ttb`?`ttb`:`ltr`,children:g.map((e,n)=>{let r=n+1,{row:i,column:o}=Tj(a,n),c=e?s.get(e.part_id):null,u=Oj(e),d=kj(e);return h.has(n)?(0,p.jsx)(`div`,{className:`tray-visual__pocket`,"aria-hidden":`true`},`${t.id}-${r}`):(0,p.jsx)(`div`,{className:`tray-visual__pocket`,children:(0,p.jsx)(`div`,{className:`tray-visual__slot`,"data-tray-id":t.id,"data-tray-row":i,"data-tray-column":o,"data-pocket-number":r,onDragOver:Sj,onDrop:e=>l(e,t,i,o),children:c&&e?(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-tray-slot-part-${e.id}`,children:d}),children:(0,p.jsx)(`span`,{className:`tray-visual__part badge ${u} badge-level-${c.part_level}`,"data-part-id":c.id,"data-step-part-id":e.id,draggable:!0,onDragStart:t=>xj(t,e),children:c.scanner_label})},e.id):(0,p.jsx)(`span`,{className:`tray-visual__index`,children:r})})},`${t.id}-${r}`)})})})]})}var wj=(e,t,n)=>!t||!n||t<1||n<1||t>e.rows||n>e.columns?null:e.orientation===`ttb`?(n-1)*e.rows+(t-1):(t-1)*e.columns+(n-1),Tj=(e,t)=>e.orientation===`ttb`?{row:t%e.rows+1,column:Math.floor(t/e.rows)+1}:{row:Math.floor(t/e.columns)+1,column:t%e.columns+1},Ej=e=>{if(typeof e==`object`&&e&&`response`in e){let t=e.response;if(typeof t?.data?.detail==`string`&&t.data.detail!==``)return t.data.detail;if(typeof t?.data?.message==`string`&&t.data.message!==``)return t.data.message}return e instanceof Error&&e.message!==``?e.message:`Could not move part.`},Dj=e=>e.tray_id!=null&&!e.failed?1:e.tray_id==null?3:2,Oj=e=>e?.failed?`bg-danger`:e?.tray_id?`bg-primary`:`bg-grey`,kj=e=>e?.failed?`Part failed`:e==null?`In default postion`:e.tray_id==null?`In default position`:`Not in default postion`,Aj=({step:e,parts:t,stepParts:n,run:r})=>{let i=(0,d.useMemo)(()=>[...r.run_trays??[]].sort((e,t)=>e.sequence-t.sequence),[r]),a=(0,d.useMemo)(()=>n.filter(t=>t.step_id===e.id),[n,e.id]),o=(0,d.useMemo)(()=>t.filter(t=>t.part_level===e.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),[t]),s=(0,d.useMemo)(()=>OA(o,a),[o,a]);return i.length===0||o[0]?.part_level>0?(0,p.jsx)(kA,{step:e,parts:t,stepParts:n,run:r}):(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-4`,children:i.map(t=>(0,p.jsx)(Cj,{step:e,tray:t,parts:s.get(t.id)??[],stepParts:a},t.id))})};function jj({step:e,parts:t,run:n}){let{environment:r}=(0,g.useParams)(),[i]=(0,m.useQueries)({queries:[{queryKey:[`runStepParts`,e.id],queryFn:()=>Re({step:e}),placeholderData:m.keepPreviousData}]}),a=(0,d.useMemo)(()=>i.data?.items??[],[i.data?.items]),o=(0,d.useMemo)(()=>t.filter(t=>t.part_level===e.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),[t]);return(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsxs)(g.Link,{to:`/${r}/operator/run/step/${e.id}`,children:[` `,(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.name}})]})}),(0,p.jsx)(`td`,{children:i.isLoading?(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(Aj,{step:e,parts:o,stepParts:a,run:n})})]})}var Mj=e=>(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:2,style:{margin:0},className:`bg-info`,children:(0,p.jsx)(`span`,{children:e.step_group?.label})})});function Nj(){let{run:e}=(0,d.useContext)(sk),[t,n]=(0,d.useState)(1),[r]=(0,d.useState)(25),[i,a]=(0,d.useState)(new Map),o=(0,m.useQueries)({queries:[{queryKey:[`runSteps`,JSON.stringify(e),t],queryFn:()=>Ae({run:e,page:t,pageSize:r}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>ke({run:e})}]}),[s,c]=o,l=o.some(e=>e.isLoading),u=o.some(e=>e.isError),f=(0,d.useMemo)(()=>s.data?.items??[],[s.data?.items]),h=(0,d.useMemo)(()=>c.data?.items??[],[c.data?.items]);(0,d.useEffect)(()=>{a(e=>{let t=new Map(e);return f.forEach(e=>{let n=e.label?.id;n!==void 0&&!t.has(n)&&t.set(n,!0)}),t})},[f]),(0,d.useEffect)(()=>{u&&o.forEach((t,n)=>{t.isError&&console.error(`RunLayoutElement query error`,{index:n,error:t.error,run:e})})},[u,o,e]);let g=new Set,_=f.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||g.has(String(e.step_group.id))?!1:(g.add(String(e.step_group.id)),!0)),v=e=>{a(t=>{let n=new Map(t);return n.set(e,!n.get(e)),n})},y=e=>{let t=e.label,n=t?.id;return!e.is_own_label||!t||n===void 0?null:(0,p.jsx)(`tr`,{style:{cursor:`pointer`},onClick:()=>v(n),children:(0,p.jsx)(`td`,{colSpan:2,style:{margin:0},className:`bg-secondary`,children:(0,p.jsxs)(`span`,{className:`label-toggle`,children:[(0,p.jsx)(`i`,{className:`fa `+(i.get(e.label?.id??-1)?`fa-caret-down`:`fa-caret-right`)}),` `,t.label]})})})};return l?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run layout edit`}),(0,p.jsxs)(Nl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Step`}),(0,p.jsx)(`th`,{children:`Parts`})]})}),(0,p.jsx)(`tbody`,{children:[1,2].map(e=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:2,className:`bg-info`,children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`4rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))})})]})]},e))})]})]}):u?(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run layout.`}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run layout edit`}),(0,p.jsxs)(Nl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Step`}),(0,p.jsx)(`th`,{children:`Parts`})]})}),(0,p.jsx)(`tbody`,{children:f.map(t=>(0,p.jsxs)(d.default.Fragment,{children:[t.has_label&&y(t),(!t.has_label||!!i.get(t.label?.id??-1))&&(0,p.jsxs)(p.Fragment,{children:[t.has_step_group&&_.includes(t)&&Mj(t),(0,p.jsx)(jj,{step:t,parts:h,run:e},`step-${t.id}`)]})]},`step-${t.id}`))})]}),(0,p.jsx)(KO,{data:s.data,setPage:n,isPlaceholderData:s.isPlaceholderData})]})}var Pj=()=>{let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(null),{id:i}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||i!==e.id.toString())&&Te({id:parseInt(i)}).then(e=>(we({id:e.run_id}).then(r),e)).then(t)},[i,e]);function a(){Te({id:parseInt(i)}).then(e=>(we({id:e.run_id}).then(r),e)).then(t)}return{run:n,runStep:e,setRunStep:t,reloadRunStep:a}};function Fj({children:e}){let{runStep:t,setRunStep:n,run:r,reloadRunStep:i}=Pj(),[a,o]=(0,d.useState)({});if(t===null||r===null){let e=`Loading run...`;return t===null&&r===null?e=`Loading run and run step...`:r===null&&(e=`Loading run step...`),(0,p.jsx)(Ot,{children:(0,p.jsx)(Ct,{message:e})})}return(0,p.jsx)(Ot,{children:(0,p.jsx)(MA.Provider,{value:{runStep:t,setRunStep:n,reloadRunStep:i,run:r,modalProperties:a,setModalProperties:o},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}function Ij(){return(0,p.jsx)(Fj,{children:(0,p.jsx)(Jr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})})}var Lj=({label:e})=>(0,p.jsx)(`div`,{className:`p-2 h4 mb-1 bg-info text-white`,children:e.label}),Rj=({runStep:e})=>{let{environment:t}=(0,g.useParams)();return(0,p.jsxs)(`h2`,{children:[` `,e.number,` -`,e.process_module.process.name,` on`,` `,(0,p.jsxs)(g.Link,{to:`/${t}/operator/equipment/${e.process_module.module.equipment?.id}`,children:[e.process_module.module.equipment?.name,` (`,e.process_module.module.name,`)`]})]})},zj=({checklistItem:e,show:t,setModalShow:n,mutation:r})=>(0,p.jsxs)(K,{show:t,size:`lg`,onHide:()=>n(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Checklist item`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsx)(`h2`,{children:e.task}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.description}})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,variant:`primary`,onClick:()=>{r.mutate()},children:`Done`}),(0,p.jsx)(U,{variant:`secondary`,onClick:()=>n(!1),children:`Close`})]})]});function Bj({checklistItem:e,onOpenModal:t,onMarkDone:n}){return e.can_finish?e.description===``?(0,p.jsx)(U,{className:`float-end`,size:`sm`,variant:`success`,onClick:n,children:`Done checklist step`}):(0,p.jsx)(U,{className:`float-end`,variant:`primary`,onClick:t,children:`Execute checklist step`}):null}var Vj=({checklistItem:e,refetch:t})=>{let[n,r]=(0,d.useState)(!1),i=(0,m.useMutation)({mutationFn:async()=>(await f.default.create().patch(`update/run/step/checklist/done/`+e.id,{})).data,onSuccess:e=>{r(!1),t()}});return(0,p.jsxs)(nc.Item,{disabled:e.is_executed,className:`d-flex justify-content-between align-items-start`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[e.task,e.is_executed&&(0,p.jsxs)(`small`,{children:[`Executed on `,(0,p.jsx)(uk,{format:`DD-MM-YYYY`,children:e.date_executed})]})]}),(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(Bj,{checklistItem:e,onOpenModal:()=>r(!0),onMarkDone:()=>i.mutate()})}),(0,p.jsx)(zj,{checklistItem:e,show:n,setModalShow:r,mutation:i})]})},Hj={movingOut:`Moving out...`,skipping:`Skipping...`,unskipping:`Unskipping...`,operationFinished:`Operation finished`,operationSkipped:`Operation skipped`,operationUnskipped:`Operation unskipped`};function Uj({run:e,runStep:t,reloadRunStep:n}){let r=(0,g.useNavigate)(),{environment:i}=(0,g.useParams)(),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),{run:l,runStep:u,reloadRunStep:h}=(0,d.useContext)(MA);(0,d.useEffect)(()=>{if(a){let e=setTimeout(()=>{o(null)},3e3);return()=>clearTimeout(e)}},[a]);let _=e??l,v=t??u,y=n??h??(()=>null),{data:b,error:x,isLoading:S,refetch:C}=(0,m.useQuery)({queryKey:[`checklist`,v?.id],queryFn:()=>Pe({runStep:v}),enabled:!!v}),w=(0,d.useCallback)(async e=>{o(Hj.movingOut),c(!0);try{let t=await Fe(e);o(Hj.operationFinished),t.data.next_step_id===null?y():r(`/${i}/operator/run/step/${t.data.next_step_id}`)}finally{c(!1)}},[i,r,y]),T=(0,d.useCallback)(async e=>{o(Hj.skipping),c(!0);try{await f.default.create().patch(`update/run/step/skip/${e.id}`,{}),o(Hj.operationSkipped),y()}finally{c(!1)}},[y]),E=(0,d.useCallback)(async e=>{o(Hj.unskipping),c(!0);try{await f.default.create().patch(`update/run/step/un-skip/${e.id}`,{}),o(Hj.operationUnskipped),y()}finally{c(!1)}},[y]),{checklistItems:D,canFinishOperation:O}=(0,d.useMemo)(()=>{let e=b?.items??[],t=e.findIndex(e=>!e.is_executed);return{checklistItems:e.map((e,n)=>({...e,can_finish:n===t})),canFinishOperation:!!(v&&!v.is_finished&&t===-1)}},[b,v]);return!v||!_?(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext in RunStepChecklist`}):S?(0,p.jsx)(Ct,{message:`Loading...`}):x?(0,p.jsx)(Cr,{variant:`danger`,children:`Failed to load checklist.`}):(0,p.jsxs)(p.Fragment,{children:[D.length===0&&(0,p.jsx)(Cr,{variant:`info`,children:`No checklist found`}),D.length>0&&(0,p.jsx)(nc,{children:D.map(e=>(0,p.jsx)(Vj,{checklistItem:e,refetch:C},e.id))}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mt-3`,children:[(0,p.jsxs)(`div`,{className:`d-flex gap-2 align-items-center`,children:[O&&(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`success`,onClick:()=>w(v),disabled:s,children:a===Hj.operationFinished||a===Hj.movingOut?a:`Move out`})}),_.access.edit&&!v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`primary`,onClick:()=>T(v),disabled:s,children:a===Hj.operationSkipped||a===Hj.skipping?a:`Skip operation`})}),_.access.edit&&v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`warning`,onClick:()=>E(v),disabled:s,children:a===Hj.operationUnskipped||a===Hj.unskipping?a:`Unskip operation`})})]}),(0,p.jsx)(`div`,{className:`d-flex gap-2`,children:v.next_step_id&&(0,p.jsx)(`div`,{children:(0,p.jsx)(g.Link,{to:`/${i}/operator/run/step/${v.next_step_id}`,className:`btn btn-secondary`,children:`Next step`})})})]})]})}var Wj=()=>void 0;function Gj({runStep:e,reloadRunStep:t,title:n=`Remark`,titleClassName:r=`mb-2 text-start`}){let{runStep:i,setRunStep:a}=(0,d.useContext)(MA),o=e??i,s=t?()=>t():e?Wj:a??Wj,[c,l]=(0,d.useState)(!1),u=o?!o.is_finished:!1,m=!!o?.remark?.trim(),{register:h,handleSubmit:g,formState:_,reset:v}=Id({defaultValues:{remark:o?.remark_unparsed??``}}),{isSubmitting:y}=_;(0,d.useEffect)(()=>{v({remark:o?.remark_unparsed??``})},[v,o?.remark_unparsed]);let b=(0,d.useCallback)(async e=>{if(!o)return;await f.default.patch(`update/run/step/`+o.id,{remark:e.remark});let t=await f.default.get(`view/run/step/`+o.id);s({...o,remark:t.data.remark,remark_unparsed:t.data.remark_unparsed}),l(!1)},[o,s]);return o?!c||!u?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:r,children:n}),!m&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-muted`,children:`No remark.`}),u&&(0,p.jsx)(U,{variant:`primary`,className:`ms-auto`,size:`sm`,onClick:()=>l(!0),children:`Add remark`})]}),m&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-success`,dangerouslySetInnerHTML:{__html:o.remark}}),` `,u&&(0,p.jsx)(U,{variant:`primary`,className:`mt-3`,onClick:()=>l(!0),children:`Edit remark`})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{className:r,children:n}),(0,p.jsxs)(G,{onSubmit:g(b),children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:6,...h(`remark`)}),(0,p.jsx)(`p`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:`If a non-conformity happens, note it here`})}),(0,p.jsxs)(U,{variant:`primary`,type:`submit`,disabled:y,children:[y&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Save remark`]}),(0,p.jsx)(U,{variant:`secondary`,className:`ms-2`,onClick:()=>l(!1),children:`Cancel`})]})]}):(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext for StepRemark`})}var Kj=(e,t)=>{f.default.get(`list/run/hold-code`).then(e=>{let{data:t}=e;return t._embedded.items}).then(e=>{t(e.map(e=>({value:e.id,label:e.code})))})},qj=({run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})=>{let[a,o]=d.default.useState(!1),{register:s,control:c,setValue:l,handleSubmit:u,formState:m}=Id({defaultValues:{holdCode:r?{value:r.hold_code.id,label:r.hold_code.code}:{},description:r?r.description:``}}),{errors:h,isSubmitting:g}=m;return(0,p.jsx)(K,{show:t,size:`lg`,onHide:()=>n(!1),children:(0,p.jsxs)(G,{onSubmit:u(async t=>{try{let n=await f.default.patch(`update/run/hold-code/`+e.id,{holdcode:a?null:t.holdCode.value,description:t.description});n.data.hold_code?i(n.data):i(void 0),o(!1)}finally{n(!1)}}),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:a?`Reset hold code`:`Update hold code`})}),(0,p.jsxs)(K.Body,{children:[!a&&(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Hold code`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(wu,{name:`holdCode`,control:c,rules:{validate:{required:e=>e.value!==void 0||a||`A hold code is required`}},render:({field:e})=>(0,p.jsx)(qb,{isSearchable:!1,defaultOptions:!0,placeholder:`— Select a hold code`,loadOptions:Kj,value:e.value,onChange:t=>{e.onChange(t)}})}),h.holdCode&&(0,p.jsx)(`span`,{className:`text-danger`,children:h.holdCode.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`holdCodeDescription`,className:`col-sm-3 col-form-label text-end`,children:`Message`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:3,id:`holdCodeDescription`,...s(`description`,{required:`A message is required`}),isInvalid:h.description!==void 0}),h.description&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:h.description.message})]})]})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsxs)(U,{type:`submit`,variant:a?`success`:`primary`,disabled:g,children:[g&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),a?`Release lot`:`Update Hold code`]}),r&&(0,p.jsx)(U,{variant:`outline-danger`,onClick:()=>{l(`description`,a?r.description:``),o(!a)},children:a?`Update hold Code`:`Reset hold code`})]})]})})},Jj=()=>{let{run:e}=(0,d.useContext)(MA),[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(e.hold_code),a=()=>{n(!0)};return(0,p.jsxs)(p.Fragment,{children:[r&&(0,p.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`Edit hold code`,className:`badge handle`,style:{backgroundColor:r.hold_code.back_color,color:r.hold_code.front_color,fontSize:`1.5rem`,cursor:`pointer`},onClick:()=>a(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},children:r.hold_code.code}),!r&&(0,p.jsx)(wr,{bg:`secondary`,className:`handle`,onClick:()=>a(),style:{fontSize:`1.5rem`,cursor:`pointer`},children:`No hold code`}),(0,p.jsx)(qj,{run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})]})},Yj=()=>{let{run:e}=(0,d.useContext)(MA),[t,n]=(0,d.useState)(e.priority);return(0,p.jsxs)(d.default.Fragment,{children:[t&&(0,p.jsx)(`span`,{className:`badge`,style:{backgroundColor:t.priority.back_color,color:t.priority.front_color,fontSize:`1.5rem`},children:t.priority.code}),!t&&(0,p.jsx)(`span`,{className:`badge bg-info`,style:{fontSize:`1.5rem`},children:`NORMAL`})]})},Xj=({run:e,runStep:t,showOnlyEmphasizedParameters:n})=>(0,p.jsx)(`div`,{className:`border rounded px-3 py-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsx)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:(0,p.jsx)(sA,{run:e,runStep:t})}),(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[n&&(0,p.jsx)(`h4`,{children:`Emphasized parameters`}),!n&&(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(_k,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:n})]})]})}),Zj=({run:e,monitoredBy:t,runStep:n,runParts:r,runStepParts:i,hideLabel:a,firstInGroup:o})=>{let{environment:s}=(0,g.useParams)(),[c,l]=(0,d.useState)(!1),{runStep:u}=(0,d.useContext)(MA);return(0,p.jsxs)(p.Fragment,{children:[!a&&n.has_label&&n.is_own_label&&(0,p.jsx)(`div`,{className:`bg-info text-white rounded px-3 py-1`,children:n.label?.label}),n.step_group&&o&&(0,p.jsx)(`div`,{className:`bg-secondary text-white rounded px-3 py-1`,children:n.step_group?.label}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 border rounded px-3 py-2 ${n.has_step_group?`ms-4`:``}`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2 flex-shrink-0`,children:[n.id!==u.id&&(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":c?`Collapse details`:`Expand details`,className:`fa `+(c?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:()=>{l(!c)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l(!c))}}),n.id===u.id&&(0,p.jsx)(`i`,{className:`fa fa-chevron-right text-success`,style:{cursor:`pointer`},title:`This step is currently running`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 flex-grow-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(kA,{step:n,parts:r,stepParts:i,run:e})}),(0,p.jsxs)(`div`,{className:`flex-shrink-0 text-nowrap`,children:[n.number,` `,n.is_skipped&&(0,p.jsx)(wr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(g.Link,{to:`/${s}/operator/run/step/${n.id}`,dangerouslySetInnerHTML:{__html:n.name}}),` `,t&&(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-${t.id}`,children:`Monitored by step: ${t.step.number}`}),children:(0,p.jsx)(`i`,{className:`fa fa-search me-2`})})]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-3 flex-shrink-0 ms-auto`,children:[(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.finish_user?n.finish_user.initials:``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.has_rework?(0,p.jsx)(`span`,{className:`badge bg-primary`,children:`Rework`}):``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.is_finished?(0,p.jsx)(uk,{format:`DD-MM-YYYY`,children:n.finish_date}):``})]})]}),c&&(0,p.jsx)(Xj,{run:e,runStep:n,showOnlyEmphasizedParameters:!1})]})};function Qj({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i}){let a=n.filter(t=>t.step_id===(e.requirement_for_step?.id??e.step.id)),{environment:o}=(0,g.useParams)();return(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(`div`,{className:`border rounded px-3 py-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[(0,p.jsx)(`h4`,{children:`Measurement results`}),(0,p.jsx)(NA,{requirement:e,step:t,stepParts:a,parts:r,measurementResults:i,editOnly:!0})]}),(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[(0,p.jsx)(`h4`,{children:`Monitored Step`}),(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${e.requirement_for_step?.id??e.step.id}`,children:(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-search`}),` `,e.requirement_for_step?.name??e.step.name]})}),(0,p.jsx)(`h4`,{children:`Definition`}),(0,p.jsx)(`span`,{children:e.definition}),(0,p.jsx)(`h4`,{children:`Targets`}),(0,p.jsxs)(Nl,{size:`sm`,striped:!1,bordered:!1,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`min value`}),(0,p.jsx)(`th`,{children:`max value`}),(0,p.jsx)(`th`,{children:`inclusive`})]})}),(0,p.jsx)(`tbody`,{children:e.targets.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.min_value}),(0,p.jsx)(`td`,{children:e.max_value}),(0,p.jsx)(`td`,{children:e.inclusive?`yes`:`no`})]},e.id))})]})]})]})})})}function $j({requirement:e,runParts:t,runStepParts:n,hideLabel:r,firstInGroup:i}){let a=e.step,{environment:o}=(0,g.useParams)(),{runStep:s}=(0,d.useContext)(MA),[c,l]=(0,d.useState)(!1),[u]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Ne({measurement:e.measurement})}]});return(0,p.jsxs)(p.Fragment,{children:[!r&&a.has_label&&a.is_own_label&&(0,p.jsx)(`div`,{className:`bg-info text-white rounded px-3 py-1`,children:a.label?.label}),a.step_group&&i&&(0,p.jsx)(`div`,{className:`bg-secondary text-white rounded px-3 py-1`,children:a.step_group?.label}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 border rounded px-3 py-2 ${(()=>{if(!u.data)return``;let t=new Map;for(let e of u.data.items)for(let n of e.values)n.step_part_id!==void 0&&n.step_part_id!==null&&t.set(n.step_part_id,n);let r=!1;for(let i of n){let n=t.get(i.id);if(!(n&&!isNaN(parseFloat(n.string_value))))return a.id===s.id?`bg-success-subtle`:``;let o=parseFloat(n.string_value);if(e.targets.some(e=>e.inclusive?!(e.min_value<=o&&e.max_value>=o):!(e.min_value<o&&e.max_value>o))){r=!0;break}}return r?`bg-danger-subtle`:a.id===s.id?`bg-success-subtle`:``})()} ${a.has_step_group?`ms-4`:``}`,children:[(0,p.jsx)(`div`,{className:`d-flex align-items-center gap-2 flex-shrink-0`,children:a.id!==s.id&&(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":c?`Collapse details`:`Expand details`,className:`fa `+(c?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:()=>{l(!c)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l(!c))}})}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 flex-grow-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(IA,{requirement:e,step:a,parts:t,stepParts:n,measurementResults:u.data?.items??[]})}),(0,p.jsxs)(`div`,{className:`flex-shrink-0 text-nowrap`,children:[a.number,` `,a.is_skipped&&(0,p.jsx)(wr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(wr,{bg:`info`,children:`requirement`}),` `,(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${a.id}`,dangerouslySetInnerHTML:{__html:a.name}}),` `]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-3 flex-shrink-0 ms-auto`,children:[(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.finish_user?a.finish_user.initials:``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.has_rework?(0,p.jsx)(`span`,{className:`badge bg-primary`,children:`Rework`}):``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.is_finished?(0,p.jsx)(uk,{format:`DD-MM-YYYY`,children:a.finish_date}):``})]})]}),c&&(0,p.jsx)(Qj,{requirement:e,step:a,stepParts:n,parts:t,measurementResults:u.data?.items??[]})]})}var eM=({pageSize:e=25,hideLabel:t=!1})=>{let{runStep:n,run:r}=(0,d.useContext)(MA),[i,a]=(0,d.useState)(1);(0,d.useEffect)(()=>{n?.sequence&&a(Math.max(1,Math.ceil(n.sequence/e)))},[n?.sequence,e]);let o=r?.id??null,{data:s,error:c,isError:l,isLoading:u}=(0,m.useQuery)({queryKey:[`runParts`,`${o}`],queryFn:()=>ke({run:r}),enabled:!!o}),{data:f,error:h,isError:g,isLoading:_}=(0,m.useQuery)({queryKey:[`runStepParts`,`${o}`],queryFn:()=>Re({run:r}),enabled:!!o}),{data:v,error:y,isError:b,isFetching:x,isLoading:S,isPlaceholderData:C}=(0,m.useQuery)({queryKey:[`runSteps`,o,i,e],queryFn:()=>Ae({run:r,page:i,pageSize:e}),enabled:!!o,placeholderData:m.keepPreviousData}),{data:w,error:T,isError:E,isLoading:D}=(0,m.useQuery)({queryKey:[`requirements`,o],queryFn:()=>De({run:r}),enabled:!!o,placeholderData:m.keepPreviousData}),O=u||_||S||D,k=l||g||b||E,A=c||h||y||T,j=s?.items??[],M=f?.items??[],N=v?.items??[],P=w?.items??[],F=new Set,I=N.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||F.has(String(e.step_group.id))?!1:(F.add(String(e.step_group.id)),!0)),L={};for(let e of P)e.requirement_for_step!=null&&(L[String(e.requirement_for_step.id)]=e);return d.default.useEffect(()=>{k&&console.error(`RunStepSimpleList query error`,{runId:o,errors:[c,h,y,T]})},[k,o,c,h,y,T]),(0,p.jsxs)(`div`,{children:[O?(0,p.jsx)(`div`,{children:`Loading...`}):k?(0,p.jsxs)(`div`,{children:[`Error: `,String(A?.message??A)]}):(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:N.map((e,n)=>(0,p.jsx)(d.default.Fragment,{children:e.has_requirement?(0,p.jsx)($j,{requirement:P.find(t=>t.step.id===e.id),runParts:j,runStepParts:M,firstInGroup:I.includes(e)},e.id??e.sequence??n):(0,p.jsx)(Zj,{run:r,monitoredBy:L[e.id],runParts:j,runStepParts:M,hideLabel:t,firstInGroup:I.includes(e),runStep:e},e.id??e.sequence??n)},n))}),(0,p.jsx)(KO,{data:v,setPage:a,isPlaceholderData:C}),x?(0,p.jsx)(`span`,{children:` Loading...`}):null]})};function tM(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function nM(e){if(Array.isArray(e))return e}function rM(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function iM(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
31
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aM(e,t){return nM(e)||rM(e,t)||oM(e,t)||iM()}function oM(e,t){if(e){if(typeof e==`string`)return tM(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tM(e,t):void 0}}var sM=Object.entries,cM=Object.setPrototypeOf,lM=Object.isFrozen,uM=Object.getPrototypeOf,dM=Object.getOwnPropertyDescriptor,fM=Object.freeze,pM=Object.seal,mM=Object.create,hM=typeof Reflect<`u`&&Reflect,gM=hM.apply,_M=hM.construct;fM||(fM=function(e){return e}),pM||(pM=function(e){return e}),gM||(gM=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)}),_M||(_M=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)});var vM=RM(Array.prototype.forEach),yM=RM(Array.prototype.lastIndexOf),bM=RM(Array.prototype.pop),xM=RM(Array.prototype.push),SM=RM(Array.prototype.splice),CM=Array.isArray,wM=RM(String.prototype.toLowerCase),TM=RM(String.prototype.toString),EM=RM(String.prototype.match),DM=RM(String.prototype.replace),OM=RM(String.prototype.indexOf),kM=RM(String.prototype.trim),AM=RM(Number.prototype.toString),jM=RM(Boolean.prototype.toString),MM=typeof BigInt>`u`?null:RM(BigInt.prototype.toString),NM=typeof Symbol>`u`?null:RM(Symbol.prototype.toString),PM=RM(Object.prototype.hasOwnProperty),FM=RM(Object.prototype.toString),IM=RM(RegExp.prototype.test),LM=zM(TypeError);function RM(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return gM(e,t,r)}}function zM(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return _M(e,n)}}function BM(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wM;if(cM&&cM(e,null),!CM(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(lM(t)||(t[r]=e),i=e)}e[i]=!0}return e}function VM(e){for(let t=0;t<e.length;t++)PM(e,t)||(e[t]=null);return e}function HM(e){let t=mM(null);for(let r of sM(e)){var n=aM(r,2);let i=n[0],a=n[1];PM(e,i)&&(CM(a)?t[i]=VM(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=HM(a):t[i]=a)}return t}function UM(e){switch(typeof e){case`string`:return e;case`number`:return AM(e);case`boolean`:return jM(e);case`bigint`:return MM?MM(e):`0`;case`symbol`:return NM?NM(e):`Symbol()`;case`undefined`:return FM(e);case`function`:case`object`:{if(e===null)return FM(e);let t=e,n=WM(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:FM(e)}return FM(e)}default:return FM(e)}}function WM(e,t){for(;e!==null;){let n=dM(e,t);if(n){if(n.get)return RM(n.get);if(typeof n.value==`function`)return RM(n.value)}e=uM(e)}function n(){return null}return n}function GM(e){try{return IM(e,``),!0}catch{return!1}}var KM=fM(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),qM=fM(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),JM=fM([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),YM=fM([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),XM=fM(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),ZM=fM([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),QM=fM([`#text`]),$M=fM(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),eN=fM(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),tN=fM(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),nN=fM([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),rN=pM(/{{[\w\W]*|^[\w\W]*}}/g),iN=pM(/<%[\w\W]*|^[\w\W]*%>/g),aN=pM(/\${[\w\W]*/g),oN=pM(/^data-[\-\w.\u00B7-\uFFFF]+$/),sN=pM(/^aria-[\-\w]+$/),cN=pM(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),lN=pM(/^(?:\w+script|data):/i),uN=pM(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),dN=pM(/^html$/i),fN=pM(/^[a-z][.\w]*(-[.\w]+)+$/i),pN=pM(/<[/\w!]/g),mN=pM(/<[/\w]/g),hN=pM(/<\/no(script|embed|frames)/i),gN=pM(/\/>/i),_N={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},vN=function(){return typeof window>`u`?null:window},yN=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},bN=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},xN=function(e,t,n,r){return PM(e,t)&&CM(e[t])?BM(r.base?HM(r.base):{},e[t],r.transform):n};function SN(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:vN(),t=e=>SN(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==_N.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=WM(d,`cloneNode`),p=WM(d,`remove`),m=WM(d,`nextSibling`),h=WM(d,`childNodes`),g=WM(d,`parentNode`),_=WM(d,`shadowRoot`),v=WM(d,`attributes`),y=o&&o.prototype?WM(o.prototype,`nodeType`):null,b=o&&o.prototype?WM(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,w=!1,T=0,E=function(){if(T>0)throw LM(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},D=function(e){E(),T++;try{return x.createHTML(e)}finally{T--}},O=function(e){E(),T++;try{return x.createScriptURL(e)}finally{T--}},k=function(){return w||(C=yN(u,i),w=!0),C},A=n,j=A.implementation,M=A.createNodeIterator,N=A.createDocumentFragment,P=A.getElementsByTagName,F=r.importNode,I=bN();t.isSupported=typeof sM==`function`&&typeof g==`function`&&j&&j.createHTMLDocument!==void 0;let L=rN,ee=iN,te=aN,ne=oN,re=sN,ie=lN,ae=uN,oe=fN,se=cN,ce=null,le=BM({},[...KM,...qM,...JM,...XM,...QM]),R=null,ue=BM({},[...$M,...eN,...tN,...nN]),de=Object.seal(mM(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),fe=null,pe=null,me=Object.seal(mM(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),he=!0,ge=!0,_e=!1,ve=!0,ye=!1,be=!0,xe=!1,Se=!1,Ce=null,we=null,Te=!1,Ee=!1,De=!1,Oe=!1,ke=!0,Ae=!1,je=`user-content-`,Me=!0,Ne=!1,Pe={},Fe=null,Ie=BM({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Le=null,Re=BM({},[`audio`,`video`,`img`,`source`,`image`,`track`]),ze=null,Be=BM({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ve=`http://www.w3.org/1998/Math/MathML`,He=`http://www.w3.org/2000/svg`,Ue=`http://www.w3.org/1999/xhtml`,We=Ue,Ge=!1,Ke=null,qe=BM({},[Ve,He,Ue],TM),Je=fM([`mi`,`mo`,`mn`,`ms`,`mtext`]),Ye=BM({},Je),Xe=fM([`annotation-xml`]),Ze=BM({},Xe),Qe=BM({},[`title`,`style`,`font`,`a`,`script`]),$e=null,et=[`application/xhtml+xml`,`text/html`],tt=null,nt=null,rt=n.createElement(`form`),it=function(e){return e instanceof RegExp||e instanceof Function},at=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(nt&&nt===e)return;(!e||typeof e!=`object`)&&(e={}),e=HM(e),$e=et.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,tt=$e===`application/xhtml+xml`?TM:wM,ce=xN(e,`ALLOWED_TAGS`,le,{transform:tt}),R=xN(e,`ALLOWED_ATTR`,ue,{transform:tt}),Ke=xN(e,`ALLOWED_NAMESPACES`,qe,{transform:TM}),ze=xN(e,`ADD_URI_SAFE_ATTR`,Be,{transform:tt,base:Be}),Le=xN(e,`ADD_DATA_URI_TAGS`,Re,{transform:tt,base:Re}),Fe=xN(e,`FORBID_CONTENTS`,Ie,{transform:tt}),fe=xN(e,`FORBID_TAGS`,HM({}),{transform:tt}),pe=xN(e,`FORBID_ATTR`,HM({}),{transform:tt}),Pe=PM(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?HM(e.USE_PROFILES):e.USE_PROFILES:!1,he=e.ALLOW_ARIA_ATTR!==!1,ge=e.ALLOW_DATA_ATTR!==!1,_e=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ve=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ye=e.SAFE_FOR_TEMPLATES||!1,be=e.SAFE_FOR_XML!==!1,xe=e.WHOLE_DOCUMENT||!1,Ee=e.RETURN_DOM||!1,De=e.RETURN_DOM_FRAGMENT||!1,Oe=e.RETURN_TRUSTED_TYPE||!1,Te=e.FORCE_BODY||!1,ke=e.SANITIZE_DOM!==!1,Ae=e.SANITIZE_NAMED_PROPS||!1,Me=e.KEEP_CONTENT!==!1,Ne=e.IN_PLACE||!1,se=GM(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:cN,We=typeof e.NAMESPACE==`string`?e.NAMESPACE:Ue,Ye=PM(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?HM(e.MATHML_TEXT_INTEGRATION_POINTS):BM({},Je),Ze=PM(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?HM(e.HTML_INTEGRATION_POINTS):BM({},Xe);let t=PM(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?HM(e.CUSTOM_ELEMENT_HANDLING):mM(null);if(de=mM(null),PM(t,`tagNameCheck`)&&it(t.tagNameCheck)&&(de.tagNameCheck=t.tagNameCheck),PM(t,`attributeNameCheck`)&&it(t.attributeNameCheck)&&(de.attributeNameCheck=t.attributeNameCheck),PM(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(de.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),pM(de),ye&&(ge=!1),De&&(Ee=!0),Pe&&(ce=BM({},QM),R=mM(null),Pe.html===!0&&(BM(ce,KM),BM(R,$M)),Pe.svg===!0&&(BM(ce,qM),BM(R,eN),BM(R,nN)),Pe.svgFilters===!0&&(BM(ce,JM),BM(R,eN),BM(R,nN)),Pe.mathMl===!0&&(BM(ce,XM),BM(R,tN),BM(R,nN))),me.tagCheck=null,me.attributeCheck=null,PM(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?me.tagCheck=e.ADD_TAGS:CM(e.ADD_TAGS)&&(ce===le&&(ce=HM(ce)),BM(ce,e.ADD_TAGS,tt))),PM(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?me.attributeCheck=e.ADD_ATTR:CM(e.ADD_ATTR)&&(R===ue&&(R=HM(R)),BM(R,e.ADD_ATTR,tt))),PM(e,`ADD_URI_SAFE_ATTR`)&&CM(e.ADD_URI_SAFE_ATTR)&&BM(ze,e.ADD_URI_SAFE_ATTR,tt),PM(e,`FORBID_CONTENTS`)&&CM(e.FORBID_CONTENTS)&&(Fe===Ie&&(Fe=HM(Fe)),BM(Fe,e.FORBID_CONTENTS,tt)),PM(e,`ADD_FORBID_CONTENTS`)&&CM(e.ADD_FORBID_CONTENTS)&&(Fe===Ie&&(Fe=HM(Fe)),BM(Fe,e.ADD_FORBID_CONTENTS,tt)),Me&&(ce[`#text`]=!0),xe&&BM(ce,[`html`,`head`,`body`]),ce.table&&(BM(ce,[`tbody`]),delete fe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw LM(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw LM(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=D(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=k()),x&&typeof S==`string`&&(S=D(``)));fM&&fM(e),nt=e},ot=BM({},[...qM,...JM,...YM]),st=BM({},[...XM,...ZM]),ct=function(e,t,n){return t.namespaceURI===Ue?e===`svg`:t.namespaceURI===Ve?e===`svg`&&(n===`annotation-xml`||Ye[n]):!!ot[e]},lt=function(e,t,n){return t.namespaceURI===Ue?e===`math`:t.namespaceURI===He?e===`math`&&Ze[n]:!!st[e]},ut=function(e,t,n){return t.namespaceURI===He&&!Ze[n]||t.namespaceURI===Ve&&!Ye[n]?!1:!st[e]&&(Qe[e]||!ot[e])},dt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:We,tagName:`template`});let n=wM(e.tagName),r=wM(t.tagName);return Ke[e.namespaceURI]?e.namespaceURI===He?ct(n,t,r):e.namespaceURI===Ve?lt(n,t,r):e.namespaceURI===Ue?ut(n,t,r):!!($e===`application/xhtml+xml`&&Ke[e.namespaceURI]):!1},ft=function(e){xM(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw LM(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},pt=function(e){gt(e);let t=h(e);if(t){let e=[];vM(t,t=>{xM(e,t)}),vM(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},mt=function(e,n){try{xM(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{xM(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Ee||De)try{ft(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ht=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||R[tt(i)]))try{e.removeAttribute(i)}catch{}}},gt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===_N.element&&ht(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},_t=function(e){if(!be)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===_N.processingInstruction||n===_N.comment&&IM(mN,e.data)){try{p(e)}catch{}continue}if(n===_N.element){let t=e,n=tt(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},vt=function(e){let t=null,r=null;if(Te)e=`<remove></remove>`+e;else{let t=EM(e,/^[\r\n\t ]+/);r=t&&t[0]}$e===`application/xhtml+xml`&&We===Ue&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?D(e):e;if(We===Ue)try{t=new l().parseFromString(i,$e)}catch{}if(!t||!t.documentElement){t=j.createDocument(We,`template`,null);try{t.documentElement.innerHTML=Ge?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),We===Ue?P.call(t,xe?`html`:`body`)[0]:xe?t.documentElement:a},yt=function(e){return M.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},bt=function(e){return e=DM(e,L,` `),e=DM(e,ee,` `),e=DM(e,te,` `),e},xt=function(e){e.normalize();let t=M.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=bt(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&vM(r,e=>{Ct(e.content)&&xt(e.content)})},St=function(e){let t=b?b(e):null;return typeof t!=`string`||tt(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},Ct=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===_N.documentFragment}catch{return!1}},wt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Tt(e,n,r){e.length!==0&&vM(e,e=>{e.call(t,n,r,nt)})}let Et=function(e,t){return!!(be&&e.hasChildNodes()&&!wt(e.firstElementChild)&&IM(pN,e.textContent)&&IM(pN,e.innerHTML)||be&&e.namespaceURI===Ue&&t===`style`&&wt(e.firstElementChild)||e.nodeType===_N.processingInstruction||be&&e.nodeType===_N.comment&&IM(mN,e.data))},Dt=function(e,t){if(!fe[t]&&z(t)&&(de.tagNameCheck instanceof RegExp&&IM(de.tagNameCheck,t)||de.tagNameCheck instanceof Function&&de.tagNameCheck(t)))return!1;if(Me&&!Fe[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Ne?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return ft(e),!0},Ot=function(e,n){if(Tt(I.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(St(e))return ft(e),!0;let r=tt(b?b(e):e.nodeName);if(Tt(I.uponSanitizeElement,e,{tagName:r,allowedTags:ce}),e!==n&&g(e)===null)return!0;if(Et(e,r))return ft(e),!0;if(fe[r]||!(me.tagCheck instanceof Function&&me.tagCheck(r))&&!ce[r]){let t=Dt(e,r);return t===!1&&Tt(I.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===_N.element&&!dt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&IM(hN,e.innerHTML))return ft(e),!0;if(ye&&e.nodeType===_N.text){let n=bt(e.textContent);e.textContent!==n&&(xM(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Tt(I.afterSanitizeElements,e,null),!1},kt=function(e,t,r){if(pe[t]||be&&t===`patchsrc`||be&&t===`for`&&e!==`label`&&e!==`output`||ke&&(t===`id`||t===`name`)&&(r in n||r in rt))return!1;let i=R[t]||me.attributeCheck instanceof Function&&me.attributeCheck(t,e);if(!(ge&&IM(ne,t))&&!(he&&IM(re,t))){if(!i){if(!(z(e)&&(de.tagNameCheck instanceof RegExp&&IM(de.tagNameCheck,e)||de.tagNameCheck instanceof Function&&de.tagNameCheck(e))&&(de.attributeNameCheck instanceof RegExp&&IM(de.attributeNameCheck,t)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(t,e))||t===`is`&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&IM(de.tagNameCheck,r)||de.tagNameCheck instanceof Function&&de.tagNameCheck(r))))return!1}else if(!ze[t]&&!IM(se,DM(r,ae,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&OM(r,`data:`)===0&&Le[e])&&!(_e&&!IM(ie,DM(r,ae,``)))&&r)return!1}return!0},At=BM({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),z=function(e){return!At[wM(e)]&&IM(oe,e)},jt=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return D(r);case`TrustedScriptURL`:return O(r)}return r},Mt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),St(e)?ft(e):bM(t.removed)}catch{mt(n,e)}},Nt=function(e){Tt(I.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||St(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},r=t.length,i=tt(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=tt(o),u=c,d=o===`value`?u:kM(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Tt(I.uponSanitizeAttribute,e,n),d=n.attrValue,Ae&&(l===`id`||l===`name`)&&OM(d,je)!==0&&(mt(o,e),d=je+d),be&&IM(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){mt(o,e);continue}if(l===`attributename`&&EM(d,`href`)){mt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){mt(o,e);continue}if(!ve&&IM(gN,d)){mt(o,e);continue}if(ye&&(d=bt(d)),!kt(i,l,d)){mt(o,e);continue}d=jt(i,l,s,d),d!==u&&Mt(e,o,s,d)}}Tt(I.afterSanitizeAttributes,e,null)},Pt=function(e){let t=null,n=yt(e);for(Tt(I.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Tt(I.uponSanitizeShadowNode,t,null),Ot(t,e),Nt(t),Ct(t.content)&&Pt(t.content),(y?y(t):t.nodeType)===_N.element){let e=_(t);Ct(e)&&(Ft(e),Pt(e))}Tt(I.afterSanitizeShadowDOM,e,null)},Ft=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Pt(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===_N.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&tt(e)===`template`){let e=n.content;Ct(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Ct(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ge=!e,Ge&&(e=`<!-->`),typeof e!=`string`&&!wt(e)&&(e=UM(e),typeof e!=`string`))throw LM(`dirty is not a string, aborting`);if(!t.isSupported)return e;Se?(ce=Ce,R=we):at(n),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(ce=HM(ce)),I.uponSanitizeAttribute.length>0&&(R=HM(R)),t.removed=[];let c=Ne&&typeof e!=`string`&&wt(e);if(c){_t(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=tt(t);if(!ce[n]||fe[n])throw pt(e),LM(`root node is forbidden and cannot be sanitized in-place`)}if(St(e))throw pt(e),LM(`root node is clobbered and cannot be sanitized in-place`);try{Ft(e)}catch(t){throw pt(e),t}}else if(wt(e))i=vt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===_N.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Ft(a);else{if(!Ee&&!ye&&!xe&&e.indexOf(`<`)===-1)return x&&Oe?D(e):e;if(i=vt(e),!i)return Ee?null:Oe?S:``}i&&Te&&ft(i.firstChild);let l=c?e:i,u=yt(l);try{for(;o=u.nextNode();)Ot(o,l),Nt(o),Ct(o.content)&&Pt(o.content)}catch(n){throw c&&(pt(e),vM(t.removed,e=>{e.element&&gt(e.element)})),n}if(c)return vM(t.removed,e=>{e.element&&gt(e.element)}),ye&&xt(e),e;if(Ee){if(ye&&xt(i),De)for(s=N.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(R.shadowroot||R.shadowrootmode)&&(s=F.call(r,s,!0)),s}let d=xe?i.outerHTML:i.innerHTML;return xe&&ce[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&IM(dN,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
32
- `+d),ye&&(d=bt(d)),x&&Oe?D(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};at(e),Se=!0,Ce=ce,we=R},t.clearConfig=function(){nt=null,Se=!1,Ce=null,we=null,x=C,S=``},t.isValidAttribute=function(e,t,n){nt||at({});let r=tt(e),i=tt(t);return kt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&PM(I,e)&&xM(I[e],t)},t.removeHook=function(e,t){if(PM(I,e)){if(t!==void 0){let n=yM(I[e],t);return n===-1?void 0:SM(I[e],n,1)[0]}return bM(I[e])}},t.removeHooks=function(e){PM(I,e)&&(I[e]=[])},t.removeAllHooks=function(){I=bN()},t}var CN=SN(),wN=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)(MA),[r,i]=(0,d.useState)(1),{isPending:a,isLoading:o,isError:s,error:c,data:l,isFetching:u,isPlaceholderData:f}=(0,m.useQuery)({queryKey:[`run_changelog`,n,r],queryFn:()=>Oe({run:n,page:r}),placeholderData:m.keepPreviousData});return(0,p.jsxs)(K,{show:e,size:`lg`,onHide:()=>t(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsxs)(K.Title,{children:[`History of Run `,n.label]})}),(0,p.jsx)(K.Body,{children:(0,p.jsxs)(`div`,{children:[a?(0,p.jsx)(`div`,{children:`Loading...`}):s?(0,p.jsxs)(`div`,{children:[`Error: `,c.message]}):(0,p.jsx)(Nl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:(0,p.jsx)(`tbody`,{children:l.items.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(uk,{format:`DD-MM-YYYY`,children:e.date_created})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:CN.sanitize(e.message)}})}),(0,p.jsxs)(`td`,{children:[e.user.first_name,` `,e.user.last_name]})]},e.id))})}),(0,p.jsx)(KO,{data:l,setPage:i,isPlaceholderData:f}),u?(0,p.jsx)(`span`,{children:` Loading...`}):null]})}),(0,p.jsx)(K.Footer,{children:(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},TN=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{size:e,variant:`primary`,onClick:()=>n(!t),children:`Run history`}),t&&(0,p.jsx)(wN,{show:t,setModalShow:n})]})},EN=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)(MA);return(0,p.jsxs)(K,{show:e,size:`xl`,onHide:()=>t(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsxs)(K.Title,{children:[`All steps of run `,n.label]})}),(0,p.jsx)(K.Body,{children:(0,p.jsx)(eM,{hideLabel:!1})}),(0,p.jsx)(K.Footer,{children:(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},DN=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(U,{size:e,variant:`primary`,onClick:()=>n(!0),children:`All run steps`}),t&&(0,p.jsx)(EN,{show:t,setModalShow:n})]})},ON=()=>{let{runStep:e,run:t}=(0,d.useContext)(MA),[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)([]),[u,h]=(0,d.useState)([]),[g,_]=(0,d.useState)([]),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(!1),[S,C,w]=(0,m.useQueries)({queries:[{queryKey:[`templates`,g],queryFn:()=>Ye({reworkRecipes:g}),enabled:n&&g.length>0},{queryKey:[`run_steps`,e.id],queryFn:()=>Ae({run:t,page:1,pageSize:1e3}),enabled:n},{queryKey:[`template_steps`,`rework`,o,e.id],queryFn:()=>Je({template:o,pageSize:1e3}),enabled:o!==null}]});if((0,d.useEffect)(()=>{if(C.isSuccess&&c.length>0){let e=new Set(c),t=[];for(let n of C.data.items)e.has(n.id)&&t.push(n.recipe_version.recipe);_(t)}},[C.isSuccess,c]),!e.has_recipe)return`Reworks are only possible for steps with a recipe`;function T(e){let t=S.data.templates.find(t=>t.id===e);t!==void 0&&s(t)}function E(){let t={};a({}),c.length===0&&(t.runStep=`Please select at least one step`),a(e=>({...e,...t})),Object.keys(t).length===0&&(x(!0),f.default.create().patch(`/update/run/step/rework/`+e.id,{reworked_run_steps:c,template_steps:u,comment:v}).then(()=>{x(!1),window.location.reload()}))}return(0,p.jsxs)(p.Fragment,{children:[n&&(0,p.jsxs)(G,{method:`post`,onSubmit:()=>E(),children:[(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Template`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[g.length===0&&(0,p.jsx)(Cr,{variant:`info`,children:`— Select a rework step`}),g.length>0&&(0,p.jsxs)(G.Control,{as:`select`,name:`template`,onChange:e=>T(parseInt(e.target.value)),isInvalid:!!i.template,children:[(0,p.jsx)(`option`,{value:``,children:`— Select a template`}),S.data!==void 0&&S.data.templates.map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.label,`: `,e.name]},e.id))]}),i.template&&(0,p.jsx)(`span`,{className:`text-danger`,children:i.template})]})]}),o!==null&&(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Include template steps`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsx)(`ul`,{className:`list-group`,children:!w.isLoading&&w.data!==void 0&&w.data.steps.map(e=>(0,p.jsx)(`li`,{className:`list-group-item `,children:(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,className:`form-check-input`,id:`templateStep`+e.id,"aria-label":e.process_module.process.name,name:`templateStep`,onChange:t=>{t.target.checked?h([...u,e.id]):h(u.filter(t=>t!==e.id))},value:e.id}),(0,p.jsxs)(`label`,{htmlFor:`templateStep`+e.id,className:`from-check-label`,children:[(0,p.jsxs)(`small`,{className:`text-muted pe-2`,children:[e.number,`:`]}),e.process_module.process.name]})]})},e.id))})})]}),(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Repeat steps`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(`ul`,{className:`list-group`,children:[C.isLoading&&(0,p.jsx)(`option`,{children:`Loading run steps...`}),!C.isLoading&&C.data.items.map(t=>{if(e.sequence>=t.sequence)return(0,p.jsxs)(`li`,{className:`list-group-item d-flex justify-content-between`+(e.id===t.id?` bg-success-subtle`:``),children:[(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,className:`form-check-input`,id:`runStep`+t.id,"aria-label":t.process_module.process.name,name:`runStep`,onChange:e=>{e.target.checked?l([...c,t.id]):l(c.filter(e=>e!==t.id))},value:t.id}),(0,p.jsxs)(`label`,{htmlFor:`runStep`+t.id,className:`from-check-label`,children:[(0,p.jsxs)(`small`,{className:`text-muted pe-2`,children:[t.number,`:`]}),t.process_module.process.name]})]}),t.is_finished&&(0,p.jsx)(`div`,{children:(0,p.jsx)(`span`,{className:`badge bg-success`,children:`Finished`})})]},t.id)})]}),i.runStep&&(0,p.jsx)(`span`,{className:`text-danger`,children:i.runStep})]})]}),(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Comment`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsxs)(G.Group,{controlId:`runStep.remark`,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:6,onChange:e=>y(e.target.value),value:v,isInvalid:!!i.comment}),(0,p.jsx)(`small`,{className:`text-muted`,children:`Optional comment for the rework`})]})})]}),(0,p.jsx)(`div`,{className:`row mb-3`,children:(0,p.jsxs)(`div`,{className:`col-sm-9 offset-sm-3`,children:[(0,p.jsxs)(U,{variant:`primary`,onClick:()=>E(),disabled:b,children:[b&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Create rework`]}),`\xA0`,(0,p.jsx)(U,{variant:`warning`,onClick:()=>r(!1),children:`Cancel`})]})})]}),!n&&(0,p.jsx)(U,{variant:`primary`,className:`mt-3`,onClick:()=>r(!0),children:`Set Rework`})]})},kN={items:[],amountOfPages:0,currentPage:0,totalItems:0,hasMore:!1},AN=()=>{let{environment:e}=(0,g.useParams)(),{runStep:t,run:n}=(0,d.useContext)(MA),r=(0,m.useQueries)({queries:[{queryKey:[`monitors`,t.process_module.module.equipment],queryFn:()=>t.process_module.module.equipment?de({equipment:t.process_module.module.equipment}):kN},{queryKey:[`ecn`,t.process_module.module],queryFn:()=>ee({module:t.process_module.module})},{queryKey:[`equipmentModule`,t.process_module.module],queryFn:()=>I({id:t.process_module.module.id})},{queryKey:[`requirement`,t.id],queryFn:()=>De({run:n,step:t})}]}),[i,a,o,s]=r,[c,l]=(0,d.useState)(!0),{addReadingCallbackFn:u,removeReadingCallbackFn:f}=Wk(),[h,_]=(0,d.useState)(``),v=(0,d.useId)();(0,d.useEffect)(()=>(u(v,_),()=>{f(v)}),[]);let y=r.some(e=>e.isLoading);if(r.some(e=>e.isError))return r.forEach((e,r)=>{e.isError&&console.error(`StepDashboard query error`,{index:r,error:e.error,runStep:t,run:n})}),(0,p.jsx)(p.Fragment,{children:`Error fetching data`});if(y)return(0,p.jsx)(`div`,{children:`Loading...`});let b=o.data;return(0,p.jsx)(Jr,{fluid:!0,children:(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{className:`col-9`,children:[n.run_type===pt.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),n.run_type===pt.PRODUCTION&&(0,p.jsx)(`small`,{children:`Production run`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[n.name,` (`,n.project.name,`)`]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-lg-row gap-2 flex-wrap justify-content-end`,children:[t.has_rework&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`mx-1 badge bg-primary`,children:`Rework`}),(0,p.jsx)(Yj,{}),(0,p.jsx)(Jj,{}),t.is_skipped&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`badge bg-info`,children:`SKIPPED`})]})]}),(0,p.jsx)(dk,{run:n}),t.label&&(0,p.jsx)(Lj,{label:t.label}),(0,p.jsx)(Rj,{runStep:t}),t.is_finished&&(0,p.jsxs)(Cr,{variant:`success`,children:[`This step has been finished by `,t.finish_user?.first_name,` `,t.finish_user?.last_name]}),t.has_recipe&&(0,p.jsx)(W,{className:`rounded my-4`,children:(0,p.jsxs)(W.Body,{children:[(0,p.jsx)(W.Title,{className:`text-muted`,children:`Recipe`}),(0,p.jsxs)(W.Text,{className:`display-5`,children:[t.recipe_version.recipe.name,` (Version `,t.recipe_version.version,`)`]})]})}),s.data?.items.length==1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(NA,{requirement:s.data.items[0],step:t,editOnly:!1}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(PA,{requirement:s.data.items[0],editOnly:!1})]}),s.data?.items.length!=1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{children:`Experimental split`}),(0,p.jsx)(sA,{run:n,runStep:t})]}),(0,p.jsxs)(`p`,{className:`pt-3`,children:[`Reading from scanner: `,h]}),(0,p.jsxs)(jl,{className:`pm-3`,children:[(0,p.jsxs)(qr,{children:[(0,p.jsx)(`h3`,{children:`Checklist`}),(0,p.jsx)(Uj,{}),(0,p.jsx)(`h2`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(yk,{runStep:t})]}),(0,p.jsxs)(qr,{children:[(0,p.jsx)(`h2`,{children:`Parameters`}),(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(`input`,{type:`checkbox`,id:`showOnlyEmphasizedParameters`,checked:c,className:`form-check-input`,"data-toggle":`toggle`,onChange:()=>l(!c)}),(0,p.jsx)(`label`,{htmlFor:`showOnlyEmphasizedParameters`,className:`ms-2`,children:`Show only emphasized parameters`})]}),(0,p.jsx)(_k,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:c}),t.has_instructions&&t.instructions&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{children:`Instructions`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.instructions}})]}),(0,p.jsx)(Gj,{}),(0,p.jsx)(`h3`,{className:`pt-3`,children:`Rework`}),(0,p.jsx)(ON,{})]})]}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mb-3`,children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsxs)(`div`,{className:`d-flex gap-2 flex-wrap justify-content-end`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(DN,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(TN,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(rO,{size:void 0,moduleId:t.process_module.module.id})})]})]}),(0,p.jsx)(eM,{pageSize:n.run_type===pt.RESEARCH?5:1e3,hideLabel:!0})]}),(0,p.jsx)(qr,{className:`col-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(`h2`,{children:(0,p.jsxs)(g.Link,{to:`/${e}/operator/equipment/${t.process_module.module.equipment?.id}`,children:[t.process_module.module.equipment?.name,` (`,t.process_module.module?.name,`)`]})}),b&&(0,p.jsx)(`div`,{children:(0,p.jsx)(`h2`,{children:(0,p.jsx)(Ld,{module:b})})}),i.data?.items&&i.data.items.map(e=>(0,p.jsx)(tO,{monitor:e},e.id)),a.data?.items.map(function(e){return(0,p.jsxs)(W,{className:`my-2`,children:[(0,p.jsxs)(W.Header,{children:[`ECN: `,e.ecn]}),(0,p.jsx)(W.Body,{children:(0,p.jsx)(W.Text,{children:(0,p.jsx)(MD,{children:e.description})})}),(0,p.jsxs)(W.Footer,{children:[e.date_created&&(0,p.jsxs)(p.Fragment,{children:[`Created by `,zD(e.date_created,`DD-MM-YY H:m`),` by `,e.owner.full_name]}),e.last_update&&(0,p.jsxs)(p.Fragment,{children:[` `,`· Updated by `,zD(e.last_update,`DD-MM-YY H:m`),` by `,e.owner.full_name]})]})]},e.id)})]})})]})})},jN=()=>{let[e,t]=(0,d.useState)(!1),{modalProperties:n}=(0,d.useContext)(MA),r=()=>{t(!1),n.show=!1};return(0,d.useEffect)(()=>{t(n.show)},[n]),(0,p.jsxs)(K,{show:e,size:`xl`,onHide:r,children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:n.modalTitle})}),(0,p.jsx)(K.Body,{children:n.modalContent}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{variant:`secondary`,onClick:r,children:`Save`}),n.modalSaveButton]})]})};function MN(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(AN,{}),(0,p.jsx)(jN,{})]})}function NN({run:e,runStep:t,showOnlyEmphasizedParameters:n,reloadRunStepFn:r}){let{data:i,refetch:a}=(0,m.useQuery)({queryKey:[`checklist`,t?.id],queryFn:()=>Pe({runStep:t})}),o=(0,d.useMemo)(()=>i?.items,[i]),[s,c]=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>ke({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Re({step:t})}]}),l=(0,d.useMemo)(()=>{let e=s.data?.items??[],n=c.data?.items??[],r=e.filter(e=>e.part_level===t.part_level);return r.length!==0&&r.every(e=>n.find(t=>t.part_id==e.id)?.processed===!0)},[s.data,c.data,t.part_level]),[u,f]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mb-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`h3`,{className:`mb-2 text-start`,children:`Parts`})}),(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-move-out`,children:l?`Finish step`:`Finish all parts before moving out`}),children:(0,p.jsx)(`span`,{children:(0,p.jsx)(U,{variant:l?`success`:`light`,onClick:()=>{f(!0),Fe(t).finally(()=>{f(!1),r()})},disabled:u||!l,children:u?`Moving out...`:`Move out`})})})]}),(0,p.jsx)(nA,{run:e,runStep:t}),(0,p.jsx)(`h3`,{className:`mt-2`,children:`Parameters`}),(0,p.jsx)(_k,{runStep:t,showOnlyEmphasizedParameters:n}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsx)(`div`,{className:`col`,children:(0,p.jsx)(Gj,{runStep:t,reloadRunStep:r})}),(0,p.jsx)(`div`,{className:`col`,children:t.has_instructions&&t.instructions&&(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`h3`,{className:`mb-2 text-start`,children:`Instructions`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.instructions}})]})})]}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsxs)(`div`,{className:`col`,children:[(0,p.jsx)(`h3`,{className:`mt-2`,children:`Checklist`}),!o&&(0,p.jsx)(nc,{children:Array.from({length:1}).map((e,t)=>(0,p.jsx)(nc.Item,{children:(0,p.jsxs)(q,{as:`div`,animation:`glow`,children:[(0,p.jsx)(q,{xs:17}),` `,(0,p.jsx)(q,{xs:4}),` `,(0,p.jsx)(q,{xs:6})]})},t))}),o&&(0,p.jsxs)(p.Fragment,{children:[o.length===0&&(0,p.jsx)(Cr,{variant:`info`,children:`No checklist found`}),o.length>0&&(0,p.jsx)(nc,{children:o.map(e=>(0,p.jsx)(Vj,{checklistItem:e,refetch:a},e.id))})]})]}),(0,p.jsxs)(`div`,{className:`col`,children:[(0,p.jsx)(`h3`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(yk,{runStep:t})]})]})]})}function PN({children:e}){let[t,n]=(0,d.useState)(!1);return(0,p.jsx)(Ot,{children:(0,p.jsx)(hk.Provider,{value:{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}function FN(){return(0,p.jsx)(Jr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}function IN({control:e,name:t}){let{environment:n}=(0,g.useParams)(),[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{async function e(){try{let e=await le({environment:n,withLocations:!0});i(e.items)}catch(e){console.error(`Error fetching rooms:`,e)}finally{o(!1)}}e()},[]),a?(0,p.jsx)(`p`,{children:`Loading labs...`}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{children:`Choose a lab`}),(0,p.jsx)(G.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:(0,p.jsx)(wu,{name:t,render:({field:{onChange:e,value:t}})=>(0,p.jsxs)(G.Select,{"aria-label":`Choose a lab`,value:t?.id||``,onChange:t=>{e(r.find(e=>e.id.toString()===t.target.value)||null)},children:[(0,p.jsx)(`option`,{value:``,children:`— Choose a lab`}),r.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),control:e})})]})}var LN=Object.defineProperty,RN=Object.getOwnPropertySymbols,zN=Object.prototype.hasOwnProperty,BN=Object.prototype.propertyIsEnumerable,VN=(e,t,n)=>t in e?LN(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,HN=(e,t)=>{for(var n in t||(t={}))zN.call(t,n)&&VN(e,n,t[n]);if(RN)for(var n of RN(t))BN.call(t,n)&&VN(e,n,t[n]);return e},UN=(e,t)=>{var n={};for(var r in e)zN.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&RN)for(var r of RN(e))t.indexOf(r)<0&&BN.call(e,r)&&(n[r]=e[r]);return n},WN;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(WN||(WN={})),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||(e.QrCode={}))})(WN||(WN={})),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||(e.QrSegment={}))})(WN||(WN={}));var GN=WN,KN={L:GN.QrCode.Ecc.LOW,M:GN.QrCode.Ecc.MEDIUM,Q:GN.QrCode.Ecc.QUARTILE,H:GN.QrCode.Ecc.HIGH},qN=128,JN=`L`,YN=`#FFFFFF`,XN=`#000000`,ZN=!1,QN=1,$N=4,eP=0,tP=.1;function nP(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function rP(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function iP(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*tP),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function aP(e,t){return t==null?e?$N:eP:Math.max(Math.floor(t),0)}function oP({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=u.default.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...GN.QrSegment.makeSegments(t)),e),[]);return GN.QrCode.encodeSegments(r,KN[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:d,numCells:f,calculatedImageSettings:p}=u.default.useMemo(()=>{let e=c.getModules(),t=aP(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:iP(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:l,numCells:f,calculatedImageSettings:p}}var sP=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),cP=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=qN,level:a=JN,bgColor:o=YN,fgColor:s=XN,includeMargin:c=ZN,minVersion:l=QN,boostLevel:d,marginSize:f,imageSettings:p}=n,m=UN(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=UN(m,[`style`]),_=p?.src,v=u.default.useRef(null),y=u.default.useRef(null),b=u.default.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=u.default.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=oP({value:r,level:a,minVersion:l,boostLevel:d,includeMargin:c,marginSize:f,imageSettings:p,size:i});u.default.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=rP(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,sP?t.fill(new Path2D(nP(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),u.default.useEffect(()=>{S(!1)},[_]);let D=HN({height:i,width:i},h),O=null;return _!=null&&(O=u.default.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),u.default.createElement(u.default.Fragment,null,u.default.createElement(`canvas`,HN({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});cP.displayName=`QRCodeCanvas`;var lP=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=qN,level:a=JN,bgColor:o=YN,fgColor:s=XN,includeMargin:c=ZN,minVersion:l=QN,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=UN(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=oP({value:r,level:a,minVersion:l,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:m,size:i}),b=_,x=null;m!=null&&y!=null&&(y.excavation!=null&&(b=rP(_,y.excavation)),x=u.default.createElement(`image`,{href:m.src,height:y.h,width:y.w,x:y.x+g,y:y.y+g,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=nP(b,g);return u.default.createElement(`svg`,HN({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},h),!!f&&u.default.createElement(`title`,null,f),u.default.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),u.default.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});lP.displayName=`QRCodeSVG`;function uP({control:e,name:t,room:n}){let[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{async function e(){try{let e=await ce({room:n,pageSize:1e3});i(e.items),o(!1)}catch(e){console.error(`Error fetching locations:`,e)}}e()},[n]),a?(0,p.jsx)(`p`,{children:`Loading locations...`}):(0,p.jsxs)(G.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:[(0,p.jsx)(G.Label,{children:`Select a storage location`}),(0,p.jsx)(wu,{name:t,control:e,defaultValue:``,render:({field:{onChange:e,value:t}})=>(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(jl,{children:r.map(n=>(0,p.jsx)(qr,{xs:4,md:3,className:`mb-3`,children:(0,p.jsx)(W,{onClick:()=>e(n.id.toString()),style:{cursor:`pointer`,border:t.toString()===n.id.toString()?`2px solid #007bff`:`1px solid #ddd`,borderRadius:`8px`},className:`h-100`,children:(0,p.jsxs)(W.Body,{children:[(0,p.jsx)(W.Title,{children:n.name}),(0,p.jsxs)(`div`,{className:`text-muted small mb-2 d-flex gap-2 justify-content-between`,children:[n.code&&(0,p.jsxs)(`div`,{children:[`Code: `,n.code]}),n.zone_group&&(0,p.jsxs)(`div`,{children:[`Zone group: `,n.zone_group.name]})]}),(0,p.jsxs)(`div`,{style:{textAlign:`center`,marginTop:`10px`},children:[(0,p.jsx)(lP,{value:`/l/`+n.id.toString(),size:128}),` `]})]})})},n.id))})})})]})}var dP=({show:e,setShow:t,onChemicalCreate:n})=>{let{register:r,control:i,setValue:a,handleSubmit:o,formState:{errors:s,isSubmitting:c}}=Id({defaultValues:{}}),l=async e=>{try{let t=await f.default.post(`create/chemical`,e);t.data&&n(t.data)}finally{t(!1)}};return(0,p.jsx)(K,{show:e,size:`lg`,onHide:()=>t(!1),children:(0,p.jsxs)(G,{onSubmit:o(l),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Create new chemical`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`cas_number`,className:`col-sm-3 col-form-label text-end`,children:`CAS Number`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(G.Control,{as:`input`,id:`cas_number`,...r(`cas_number`,{required:`A cas number is required`}),isInvalid:s.cas_number!==void 0}),s.cas_number&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.cas_number.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`name`,className:`col-sm-3 col-form-label text-end`,children:`Name`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(G.Control,{as:`input`,id:`name`,...r(`name`,{required:`A name is required`}),isInvalid:s.name!==void 0}),s.name&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.name.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`description`,className:`col-sm-3 col-form-label text-end`,children:`Description`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:3,id:`description`,...r(`description`)}),s.description&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.description.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`standard_product`,className:`col-sm-3 col-form-label text-end`,children:`Standard product`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(G.Select,{id:`standard_product`,...r(`standard_product`,{required:`A standard product is required`}),isInvalid:s.standard_product!==void 0,children:[(0,p.jsx)(`option`,{value:st.NON_STANDARD_PRODUCT,children:`Non standard product`}),(0,p.jsx)(`option`,{value:st.STANDARD_PRODUCT,children:`Standard product`})]}),s.standard_product&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.standard_product.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`physical_state`,className:`col-sm-3 col-form-label text-end`,children:`Physical state`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(G.Select,{id:`physical_state`,...r(`physical_state`,{required:`A physical state is required`}),isInvalid:s.physical_state!==void 0,children:[(0,p.jsx)(`option`,{value:ct.SOLID,children:`Solid`}),(0,p.jsx)(`option`,{value:ct.LIQUID,children:`Liquid`}),(0,p.jsx)(`option`,{value:ct.GAS,children:`Gas`}),(0,p.jsx)(`option`,{value:ct.OTHER,children:`Other`})]}),s.physical_state&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.physical_state.message})]})]})]}),(0,p.jsx)(K.Footer,{children:(0,p.jsxs)(U,{variant:`primary`,disabled:c,onClick:()=>o(l)(),children:[c&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Create new chemical`]})})]})})};function fP({control:e,name:t,setValue:n,errors:r}){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(null),u=(e,t)=>{try{O({query:e}).then(e=>{let n=e.items.map(e=>({value:e.id,label:e.name+(e.cas_number?` (`+e.cas_number+`)`:``)})),r={...i};n.forEach(e=>{r[e.value]=e}),a(r),t(n)})}catch(e){console.error(`Error fetching chemicals:`,e)}},m=e=>e&&i[e]?i[e]:c||null;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Search Existing Chemicals`}),(0,p.jsxs)(jl,{children:[(0,p.jsx)(wu,{name:t,control:e,render:({field:e})=>(0,p.jsx)(qb,{isSearchable:!0,isClearable:!0,defaultOptions:!0,placeholder:`— Select a chemical, or start typing`,loadOptions:u,value:m(e.value),styles:Xb,onChange:t=>{l(null),e.onChange(t?.value)}})}),r.chemical&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:r.chemical.message}),(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`primary`,className:`mt-2`,onClick:()=>s(!0),children:`Create New Chemical`})})]})]}),(0,p.jsx)(dP,{show:o,setShow:s,onChemicalCreate:async e=>{try{let r=await f.default.post(`create/chemical`,e),i={value:r.data.id,label:r.data.name+(r.data.cas_number?` (${r.data.cas_number})`:``)};a(e=>({...e,[i.value]:i})),l(i),s(!1),n(t,r.data.id)}catch(e){console.error(`Error creating chemical:`,e)}}})]})}function pP(e){return/\/l\/\d+$/.test(e)}function mP(e){let t=e.match(/\/l\/(\d+)$/);return t?parseInt(t[1],10):null}var hP=[{value:`g`,label:`Gram`},{value:`kg`,label:`Kilogram`},{value:`lb`,label:`US pound`},{value:`mc`,label:`Microgram`},{value:`mg`,label:`Milligram`},{value:`oz`,label:`Ounce`},{value:`to`,label:`Tonnes`},{value:`ton`,label:`US ton`},{value:`"3`,label:`Cubic inch`},{value:`ccm`,label:`Cubic centimeter`},{value:`cl`,label:`Centiliter`},{value:`dm3`,label:`Cubic decimeter`},{value:`foz`,label:`Fluid Ounce Us`},{value:`ft3`,label:`Cubic foot`},{value:`gal`,label:`US gallon`},{value:`hl`,label:`Hectoliter`},{value:`kit`,label:`Kit`},{value:`l`,label:`Liter`},{value:`m3`,label:`Cubic meter`},{value:`ml`,label:`Mililiter`},{value:`mm3`,label:`Cubic milimeter`},{value:`pc`,label:`Item`},{value:`pce`,label:`Piece`},{value:`pt`,label:`Pint, US liquid`},{value:`qt`,label:`Quart, US liquid`},{value:`yd3`,label:`Cubic Yard`},{value:`µl`,label:`Microliter`}].sort((e,t)=>e.label.localeCompare(t.label));function gP(){let e=new Date;return e.setFullYear(e.getFullYear()+5),e.toISOString().split(`T`)[0]}function _P({room:e,barcode:t,resetForm:n,location:r,setLocation:i}){let{user:a}=(0,d.useContext)(v),{environment:o}=(0,g.useParams)(),{addCallbackFn:s,removeCallbackFn:c}=Wk(),[l,u]=(0,d.useState)(null),{register:m,control:h,handleSubmit:_,watch:y,setValue:b,formState:{errors:x,isSubmitting:S}}=Id({defaultValues:{expire_date:gP(),owner:{value:a?.id,label:a?.full_name}}}),C=y(`location`);(0,d.useEffect)(()=>{C&&oe({id:C}).then(e=>i(e))},[C]);let w=(0,d.useId)(),T=(0,d.useCallback)(e=>{if(pP(e)){let t=mP(e);t!==null&&(oe({id:t}).then(e=>i(e)),b(`location`,t))}e.startsWith(`reset-scan-location`)&&O()},[b]);(0,d.useEffect)(()=>(c(Gk.WILD_CARD,w),s(Gk.WILD_CARD,w,T),()=>c(Gk.WILD_CARD,w)),[b]);let D=async e=>{if(e.user=e.owner.value,(await E({qrCodeContent:t})).items.length>0){alert(`This barcode is already registered to a container`);return}let n=await f.default.post(`create/chemical/container`,e);u(n.data),await f.default.post(`create/chemical/container/external-label`,{container:n.data.id,qr_code_content:t})},O=()=>{i(null),b(`location`,0)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(G,{onSubmit:_(D),children:[!r&&(0,p.jsx)(uP,{room:e,control:h,name:`location`}),r&&(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Scanned location`}),(0,p.jsx)(qr,{children:(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`span`,{className:`h1`,children:r.name}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(lP,{value:`reset-scan-location`,size:100,onClick:O}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset location`})]})]})})]}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(fP,{control:h,errors:x,setValue:b,...m(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:h,...m(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Concentration`}),(0,p.jsxs)(zs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`input`,...m(`concentration`,{required:`A concentration is required`}),isInvalid:x.concentration!==void 0}),x.concentration&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.concentration.message})]})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Amount`}),(0,p.jsxs)(zs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`input`,...m(`amount`,{required:`An amount is required`}),isInvalid:x.amount!==void 0}),(0,p.jsx)(wu,{name:`amount_unit`,control:h,render:({field:e})=>(0,p.jsxs)(ms,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(fs.Item,{eventKey:``,children:`(no unit)`},0),hP.map(e=>(0,p.jsxs)(fs.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),x.amount&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.amount.message})]})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Expire date`}),(0,p.jsx)(G.Control,{type:`date`,...m(`expire_date`,{required:`An expire date is required`}),isInvalid:x.expire_date!==void 0}),x.expire_date&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.expire_date.message})]}),(0,p.jsxs)(U,{type:`submit`,variant:`primary`,disabled:S,children:[S&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Register container`]})]})]}),l&&(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(Cr,{variant:`success`,children:`Container registered successfully`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${o}/chemical/container/details/${l.id}/general.html`,children:`Go to container`}),(0,p.jsx)(lP,{value:`reset-form`,size:100,className:`float-end`,onClick:n})]})]})]})}function vP({control:e,errors:t}){let[n,r]=(0,d.useState)({}),i=(e,t)=>{try{D({query:e}).then(e=>{let i=e.items.map(e=>({value:e.id,label:e.name})),a={...n};i.forEach(e=>{a[e.value]=e}),r(a),t(i)})}catch(e){console.error(`Error fetching types:`,e)}},a=e=>n[e]||null;return(0,p.jsx)(wu,{name:`container_type`,control:e,render:({field:e})=>(0,p.jsx)(qb,{isSearchable:!0,defaultOptions:!0,placeholder:`— Select a container type`,loadOptions:i,value:a(e.value),onChange:t=>{e.onChange(t?.value)},styles:Xb})})}function yP({room:e,resetForm:t,location:n,setLocation:r}){let{user:i}=(0,d.useContext)(v),{environment:a}=(0,g.useParams)(),{addCallbackFn:o,removeCallbackFn:s}=Wk(),[c,l]=(0,d.useState)(null),u=new Date;u.setFullYear(u.getFullYear()+5);let{register:m,control:h,handleSubmit:_,watch:y,setValue:b,formState:{errors:x,isSubmitting:S}}=Id({defaultValues:{expire_date:u.toISOString().split(`T`)[0],owner:{value:i?.id,label:i?.full_name}}}),C=y(`location`);(0,d.useEffect)(()=>{C&&oe({id:C}).then(e=>{r(e)})},[C]);let w=(0,d.useCallback)(()=>{r(null),b(`location`,0)},[r,b]),T=(0,d.useId)(),E=(0,d.useCallback)(async e=>{if(pP(e)){let t=mP(e);t!==null&&(r(await oe({id:t})),b(`location`,t));return}e.startsWith(`reset-scan-location`)&&w()},[r,b,w]);return(0,d.useEffect)(()=>(s(Gk.WILD_CARD,T),o(Gk.WILD_CARD,T,E),()=>s(Gk.WILD_CARD,T)),[E]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(G,{onSubmit:_(async e=>{e.user=e.owner.value;let t=await f.default.post(`create/chemical/container`,e);l(t.data)}),children:[!n&&(0,p.jsx)(uP,{room:e,control:h,name:`location`}),n&&(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Scanned location`}),(0,p.jsx)(qr,{children:(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`span`,{className:`h1`,children:n.name}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(lP,{value:`reset-scan-location`,size:100,onClick:()=>w()}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset location`})]})]})})]}),n&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(fP,{control:h,errors:x,setValue:b,...m(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:h,...m(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Concentration`}),(0,p.jsxs)(zs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`input`,...m(`concentration`,{required:`An concentration is required`}),isInvalid:x.concentration!==void 0}),x.concentration&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.concentration.message})]})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Amount`}),(0,p.jsxs)(zs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`input`,...m(`amount`,{required:`An amount is required`}),isInvalid:x.amount!==void 0}),(0,p.jsx)(wu,{name:`amount_unit`,control:h,render:({field:e})=>(0,p.jsxs)(ms,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(fs.Item,{eventKey:``,children:`(no unit)`},0),hP.map(e=>(0,p.jsxs)(fs.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),x.amount&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.amount.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(G.Label,{children:`Container type`}),(0,p.jsx)(vP,{control:h,...m(`container_type`,{required:`Container type is required`}),errors:x}),x.container_type&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.container_type.message})]}),(0,p.jsxs)(G.Group,{className:`mb-3 w-50 w-25-sm`,children:[(0,p.jsx)(G.Label,{children:`Expire date`}),(0,p.jsx)(G.Control,{type:`date`,...m(`expire_date`,{required:`An expire date is required`}),isInvalid:x.expire_date!==void 0}),x.expire_date&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.expire_date.message})]}),(0,p.jsxs)(U,{type:`submit`,variant:`primary`,disabled:S,children:[S&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Register container`]})]})]}),c&&(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(Cr,{variant:`success`,children:`Container registered successfully`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${a}/chemical/container/render/single-${c.id}.pdf`,children:`Print label`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${a}/chemical/container/details/${c.id}/general.html`,children:`Go to container`})}),(0,p.jsx)(lP,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>t()})]})]})]})}function bP(){let{environment:e}=(0,g.useParams)(),{addReadingCallbackFn:t,removeReadingCallbackFn:n,addCallbackFn:r,removeCallbackFn:i}=Wk(),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)(null),[f,m]=(0,d.useState)(!1),[h,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),{control:w,watch:D,reset:O,setValue:k}=Id({defaultValues:{room:null}}),A=D(`room`),j=(0,d.useCallback)(()=>{y(null),u(null),c([]),m(!1)},[]);(0,d.useEffect)(()=>{if(j(),!A){x(null),C(null),_(!1);return}x(A),_(A.building.site.has_external_chemical_labelling)},[A,j]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`);e&&se({id:parseInt(e)}).then(e=>{x(e),_(e.building.site.has_external_chemical_labelling),k(`room`,e)})},[k]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`location`);e&&oe({id:parseInt(e)}).then(e=>{C(e),x(e.zone_group.room),_(e.zone_group.room.building.site.has_external_chemical_labelling),k(`room`,e.zone_group.room)})},[k]);let M=(0,d.useCallback)(()=>{O({room:b}),C(null),j()},[O,b,j]),N=(0,d.useId)();(0,d.useEffect)(()=>(t(N,o),()=>{n(N)}),[]);let P=(0,d.useCallback)(async e=>{if(!(!b||e.includes(`/l/`))){if(y(e),e.includes(`/cc/`)){let t=e.split(`/cc/`)[1],n=await T({id:parseInt(t)});u(n)}try{let t=await E({qrCodeContent:e});t?.items?.length>0?(c(t.items),m(!1)):(m(!0),c([]))}catch(e){console.error(`Error fetching chemical container external labels`,e),c([]),m(!1)}}},[b]);(0,d.useEffect)(()=>(i(Gk.WILD_CARD,N),b&&r(Gk.WILD_CARD,N,P),()=>i(Gk.WILD_CARD,N)),[P,b]);let F=(0,d.useId)();return(0,d.useEffect)(()=>(i(Gk.RESET_FORM,F),r(Gk.RESET_FORM,F,M),()=>i(Gk.RESET_FORM,F)),[M]),(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{style:{width:`fit-content`},children:(0,p.jsx)(IN,{control:w,name:`room`})}),(0,p.jsx)(`p`,{className:`pt-3 h3`,children:b?`Reading from scanner: ${v??`No chemical barcode scanned`}`:`Chemical scanner disabled`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(lP,{value:`reset-form`,size:100,className:`float-end`,onClick:M}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset form`})]})]}),!b&&(0,p.jsxs)(Cr,{variant:`warning`,className:`mt-3`,children:[(0,p.jsx)(Cr.Heading,{children:`No room selected`}),`Select a room before scanning chemical barcodes. Chemical intake scanning is disabled until a room is selected.`]}),b&&(0,p.jsx)(p.Fragment,{children:h?(0,p.jsxs)(Cr,{children:[`Lab `,b.name,` has external labels, each chemical material should have a material from the internal supplier/warehouse`]}):(0,p.jsxs)(Cr,{children:[`Lab `,b.name,` has no external labels, labels can be printed via the intake form`]})}),l&&(0,p.jsxs)(Cr,{variant:`info d-flex flex-column gap-3`,children:[`This is already an own chemical material, this is `,l.chemical.name,` and should be stored on`,` `,l.location.name,` in `,l.location.zone_group.room.name,(0,p.jsx)(`a`,{className:`alert-link`,href:`${e}/chemical/container/details/${l.id}/general.html`,children:`Go to container`})]}),!l&&v&&s.length>0&&(0,p.jsxs)(Nl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`Label`}),(0,p.jsx)(`th`,{children:`Container`}),(0,p.jsx)(`th`,{children:`Location`})]})}),(0,p.jsx)(`tbody`,{children:s.map(t=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:t.id}),(0,p.jsx)(`td`,{children:t.label}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${e}/chemical/container/details/${t.container.id}/general.html`,children:t.container.chemical.name})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${e}/location/details/${t.container.location.id}/general.html`,children:t.container.location.name})})]},t.id))})]}),!l&&f&&b&&v&&(0,p.jsx)(_P,{room:b,barcode:v,location:S,setLocation:C,resetForm:M}),!l&&b&&!h&&(0,p.jsx)(yP,{room:b,location:S,setLocation:C,resetForm:M})]})}function xP({badge_uuid:e}){return(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Card read: `,e]})}function SP({user_id:e}){let[t,n]=(0,d.useState)(``);return(0,d.useEffect)(()=>{let t=`https://`+TP+`/api/onelab/view/user/${e}`;(async()=>{try{let e=await fetch(t);if(!e.ok)throw Error(`Response status: ${e.status} with body: ${await e.text()}`);let r=await e.json();n(r.full_name)}catch(e){console.log(e)}})()},[]),(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Clients has detected user: `,t||`loading...`]})}function CP(){return(0,p.jsx)(`div`,{})}var wP=[`all`,`equipment`,`not_set`],TP=document.getElementById(`root`)?.dataset.goldsteinEndpoint??``,EP=`mock-token`,DP=10,OP=15;async function kP(e){let t=`https://`+TP+`/api/update/client-association`,n=prompt(`Select the new association for the client:`,e);if(n===null){alert(`Please enter a not null value`);return}let[r,i]=n.split(`:`),a=Number(i);if(!r||isNaN(a)||a===0){alert(`Please follow the correct format: $item:$id`);return}if(!wP.slice(1).includes(r)){alert(`Please select a valid $item: (equipment, not_set)`);return}let o=await fetch(t,{method:`PATCH`,body:JSON.stringify({previous_association:e,new_association:n}),headers:{"Content-type":`application/json; charset=UTF-8`}});if(!o.ok)throw Error(`Response status: ${o.status} with body: ${await o.text()}`);let s=await o.text();alert(s)}function AP(){let e=(0,d.useRef)(null),[t,n]=(0,d.useState)(new Map);async function r(e){let t=Lv(e.notifications_list,new Date,DP,OP);n(t)}function i(){let t=`
30
+ `},i)),a}function WE(e,t){return e&&`run`in e?async function(n,r){let i=UE(n,{file:r,...t});await e.run(i,r)}:function(n,r){return UE(n,{file:r,...e||t})}}function GE(e){if(e)throw e}var KE=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function qE(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function JE(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?YE(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function YE(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var XE={basename:ZE,dirname:QE,extname:$E,join:eD,sep:`/`};function ZE(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);rD(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function QE(e){if(rD(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function $E(e){rD(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function eD(...e){let t=-1,n;for(;++t<e.length;)rD(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:tD(n)}function tD(e){rD(e);let t=e.codePointAt(0)===47,n=nD(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function nD(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function rD(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var iD={cwd:aD};function aD(){return`/`}function oD(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function sD(e){if(typeof e==`string`)e=new URL(e);else if(!oD(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return cD(e)}function cD(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var lD=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],uD=class{constructor(e){let t;t=e?oD(e)?{path:e}:typeof e==`string`||mD(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:iD.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<lD.length;){let e=lD[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)lD.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?XE.basename(this.path):void 0}set basename(e){fD(e,`basename`),dD(e,`basename`),this.path=XE.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?XE.dirname(this.path):void 0}set dirname(e){pD(this.basename,`dirname`),this.path=XE.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?XE.extname(this.path):void 0}set extname(e){if(dD(e,`extname`),pD(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=XE.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){oD(e)&&(e=sD(e)),fD(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?XE.basename(this.path,this.extname):void 0}set stem(e){fD(e,`stem`),dD(e,`stem`),this.path=XE.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new $x(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function dD(e,t){if(e&&e.includes(XE.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+XE.sep+"`")}function fD(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function pD(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function mD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var hD=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),gD=l(KE(),1),_D={}.hasOwnProperty,vD=new class e extends hD{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=JE()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,gD.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(xD(`data`,this.frozen),this.namespace[e]=t,this):_D.call(this.namespace,e)&&this.namespace[e]||void 0:e?(xD(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=wD(e),n=this.parser||this.Parser;return yD(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),yD(`process`,this.parser||this.Parser),bD(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=wD(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);ED(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),yD(`processSync`,this.parser||this.Parser),bD(`processSync`,this.compiler||this.Compiler),this.process(e,r),CD(`processSync`,`process`,t),n;function r(e,r){t=!0,GE(e),n=r}}run(e,t,n){SD(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=wD(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),CD(`runSync`,`run`,n),r;function i(e,t){GE(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=wD(t),r=this.compiler||this.Compiler;return bD(`stringify`,r),SD(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(xD(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,gD.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];qE(o)&&qE(r)&&(r=(0,gD.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function yD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function bD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function xD(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function SD(e){if(!qE(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function CD(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function wD(e){return TD(e)?e:new uD(e)}function TD(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function ED(e){return typeof e==`string`||DD(e)}function DD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var OD=[],kD={allowDangerousHtml:!0},AD=/^(https?|ircs?|mailto|xmpp)$/i,jD=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function MD(e){let t=ND(e),n=PD(e);return FD(t.runSync(t.parse(n),n),e)}function ND(e){let t=e.rehypePlugins||OD,n=e.remarkPlugins||OD,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...kD}:kD;return vD().use(kT).use(n).use(WE,r).use(t)}function PD(e){let t=e.children||``,n=new uD;return typeof t==`string`?n.value=t:``+t,n}function FD(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||ID;for(let e of jD)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return PE(e,l),oS(e,{Fragment:p.Fragment,components:i,ignoreInvalidStyle:!0,jsx:p.jsx,jsxs:p.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in OS)if(Object.hasOwn(OS,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=OS[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function ID(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||AD.test(e.slice(0,t))?e:``}function LD(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;let t=new Date(e);return isNaN(t.getTime())?null:t}function RD(e,t){let n=LD(e);if(!n)return``;let r=e=>e.toString().padStart(2,`0`),i={YYYY:n.getFullYear().toString(),YY:n.getFullYear().toString().slice(-2),MMMM:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`][n.getMonth()],MMM:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][n.getMonth()],MM:r(n.getMonth()+1),DD:r(n.getDate()),HH:r(n.getHours()),mm:r(n.getMinutes()),H:n.getHours().toString(),m:n.getMinutes().toString()},a=Object.keys(i).sort((e,t)=>t.length-e.length).join(`|`);return t.replace(new RegExp(a,`g`),e=>i[e])}function zD(e,t=`DD-MM-YY HH:mm`){return RD(e,t)}function BD({ecn:e,equipment:t,ecnAttachments:n,reloadQueryFn:r,expanded:i=!0}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(e),[f,m]=(0,d.useState)(i),h=e=>{r([`ecn`,`attachment`,`status_mail`]),u({...l,...e})},g=()=>n.filter(t=>t.ecn.id===e.id);return(0,p.jsxs)(`div`,{className:`p-3 mb-4 border-bottom`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(wr,{bg:`dark`,children:`ECN`}),(0,p.jsx)(`h4`,{className:l.date_closed?`text-danger mb-0`:`mb-0`,children:l.date_closed?(0,p.jsx)(`s`,{children:l.ecn}):l.ecn})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(U,{variant:`outline-primary`,size:`sm`,onClick:()=>m(e=>!e),"aria-label":`Toggle Details`,children:f?`Hide Details`:`Show Details`}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{o((0,p.jsx)(Qb,{equipment:t,showModal:!0,onClose:e=>{c(!1),e&&(r([`ecn`,`attachment`,`status_mail`]),h(e))},ecn:l,attachments:g()})),c(!0)},"aria-label":`Edit ECN`,children:`Edit`})]})]}),f&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mb-3`,children:(0,p.jsx)(MD,{children:l.description})}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap text-muted`,children:[(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Creator`}),(0,p.jsx)(`div`,{className:`text-body`,children:l.owner.full_name})]}),(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Created`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(l.date_created,`DD MMMM YYYY`)})]}),l.date_closed&&(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Closed`}),(0,p.jsx)(`div`,{className:`text-danger`,children:RD(l.date_closed,`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Attachments`}),(0,p.jsx)(`div`,{className:`text-body`,children:l.attachments})]}),l.updated_by&&(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update By`}),(0,p.jsx)(`div`,{className:`text-body`,children:l.updated_by.full_name})]}),l.last_update&&(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(l.last_update,`DD MMMM YYYY`)})]})]})]}),s&&a]})}var VD=({equipment:e,showModal:t,onClose:n,issue:r,attachments:i})=>{let[a,o]=(0,d.useState)([]),[s,c]=(0,d.useState)([]),{user:l}=(0,d.useContext)(v),[u,m]=(0,d.useState)(i),{register:h,handleSubmit:g,reset:_,control:y}=Id({defaultValues:{issue:r?.issue||``,description:r?.description||``,issue_type:r?.issue_type||ut.DEFAULT,status:r?.status||dt.ACTIVE,forecast_up:r?.forecast_up?new Date(r?.forecast_up).toISOString().split(`T`)[0]:``,actions:r?.actions||``,owner:r?.owner||{}}});(0,d.useEffect)(()=>{r&&_({issue:r?.issue||``,description:r?.description||``,issue_type:r?.issue_type||ut.DEFAULT,status:r?.status||dt.ACTIVE,forecast_up:r?.forecast_up?new Date(r?.forecast_up).toISOString().split(`T`)[0]:``,actions:r?.actions||``,owner:r?.owner||{}})},[r,_]);let{getRootProps:b,getInputProps:x,isDragActive:S}=Hb({accept:{"application/*":[],"image/*":[]},onDrop:e=>{o(t=>[...t,...e])}});(0,d.useEffect)(()=>{t&&(async()=>{if(e?.id)try{let t=await re({equipment:e});c(t.items||[])}catch(e){console.error(`Error fetching modules:`,e)}})()},[e,t]);async function w(){await f.default.delete(`/delete/equipment/module/issue/${r?.id}`),n({...r,date_closed:new Date().toISOString(),last_update:new Date().toISOString(),updated_by:l?.full_name})}let T=e=>{o(t=>t.filter((t,n)=>n!==e))},E=e=>{u&&m(t=>t?.filter((t,n)=>n!==e))},D=(e,t)=>new Promise(async(n,r)=>{try{if(u&&i&&i!=u){let e=new Set(u.map(e=>e.id)),t=[];for(let n of i)e.has(n.id)||t.push(f.default.delete(`/delete/equipment/module/issue/attachment/${n.id}`));await Promise.all(t)}e.length>0&&t&&await Promise.all(e.map(async e=>{let n=await C(e),r={issue_id:t,filename:e.name,type:e.type,content:n};await f.default.post(`/create/equipment/module/issue/attachment`,r)})),n()}catch(e){r(e)}});return(0,d.useEffect)(()=>{t&&(async()=>{if(e?.id)try{let t=await re({equipment:e});c(t.items||[])}catch(e){console.error(`Error fetching modules:`,e)}})()},[e,t]),(0,p.jsx)(K,{show:t,size:`lg`,centered:!0,onHide:()=>n(r),children:(0,p.jsxs)(G,{onSubmit:g(async e=>{try{let t,i={module_id:e.module_id,issue:e.issue,description:e.description,owner:e?.owner.value||r?.owner,status:e.status,issue_type:e.issue_type,actions:e.actions,forecast_up:e.forecast_up};r?(await D(a,r.id),t=(await f.default.patch(`/update/equipment/module/issue/${r?.id}`,i)).data):(t=(await f.default.post(`/create/equipment/module/issue`,i)).data,D(a,t.id),t.attachments=a.length),n(t)}catch(e){console.error(`Error submitting the form:`,e)}}),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:r?`Edit Issue for ${e.name}`:`Create new Issue for ${e.name}`})}),(0,p.jsxs)(K.Body,{children:[!r&&(0,p.jsxs)(G.Group,{controlId:`module`,className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Module`}),(0,p.jsxs)(G.Select,{...h(`module_id`,{required:`Module is required`}),children:[(0,p.jsx)(`option`,{value:``,children:`— Select a module`}),s.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,p.jsxs)(G.Group,{controlId:`issue`,children:[(0,p.jsx)(G.Label,{children:`Issue`}),(0,p.jsx)(G.Control,{type:`text`,...h(`issue`,{required:`Issue content is required`}),autoFocus:!0})]}),(0,p.jsxs)(G.Group,{controlId:`description`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Description`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:3,...h(`description`,{required:`Description is required`})})]}),(0,p.jsxs)(G.Group,{controlId:`issueType`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Issue`}),(0,p.jsxs)(G.Control,{as:`select`,...h(`issue_type`,{required:`Issue type is required`}),children:[(0,p.jsx)(`option`,{value:ut.DEFAULT,children:`Default`}),(0,p.jsx)(`option`,{value:ut.PRIORITY,children:`Priority`}),(0,p.jsx)(`option`,{value:ut.ESCALATION,children:`Escalation`})]})]}),(0,p.jsxs)(G.Group,{controlId:`status`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Status`}),(0,p.jsxs)(G.Control,{as:`select`,...h(`status`,{required:`Status is required`}),children:[(0,p.jsx)(`option`,{value:dt.ACTIVE,children:`Active`}),(0,p.jsx)(`option`,{value:dt.CLOSED,children:`Closed`})]})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:y,...h(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(G.Group,{controlId:`forecastUp`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Forecast Up`}),(0,p.jsx)(G.Control,{type:`date`,...h(`forecast_up`,{required:`Forecast Up date is required`})})]}),(0,p.jsxs)(G.Group,{controlId:`actions`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Actions`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:5,...h(`actions`,{required:!1})})]}),(0,p.jsxs)(G.Group,{children:[(0,p.jsx)(G.Label,{children:`Attachments`}),(0,p.jsxs)(`div`,{...b({className:`dropzone ${S?`active`:``}`,style:{border:`2px dashed #007bff`,padding:`10px`,textAlign:`center`}}),children:[(0,p.jsx)(`input`,{...x()}),S?(0,p.jsx)(`p`,{children:`Drop the files here...`}):(0,p.jsx)(`p`,{children:`Drag & drop files here, or click to select files`})]}),a.length>0&&(0,p.jsx)(`ul`,{children:a.map((e,t)=>(0,p.jsxs)(`li`,{children:[e.name,` `,(0,p.jsx)(U,{variant:`secondary`,onClick:()=>T(t),children:`cancel`})]},`${e.name}-${e.lastModified}`))})]}),u&&u.length>0&&(0,p.jsxs)(G.Group,{controlId:`uploaded_files`,className:`mt-3`,children:[(0,p.jsx)(G.Label,{children:`Uploaded files`}),(0,p.jsx)(`ul`,{children:u.map((e,t)=>(0,p.jsxs)(`li`,{children:[e.filename,` `,(0,p.jsx)(U,{variant:`secondary`,onClick:()=>E(t),children:`delete`})]},e.id))})]})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{variant:`secondary`,onClick:()=>n(r),children:`Cancel`}),(0,p.jsx)(U,{variant:`primary`,type:`submit`,children:r?`Update Issue`:`Create Issue`}),r&&(0,p.jsx)(U,{variant:`danger`,onClick:()=>w(),children:`Close Issue`})]})]})})};function HD({issue:e,equipment:t,issueAttachments:n,reloadQueryFn:r,expanded:i=!0}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(i),f=e=>{r([`issue`,`attachment`,`status_mail`]),r([`issue`,`status_mail`])},m=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(`div`,{className:`p-3 mb-4 border-bottom`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(wr,{bg:`dark`,children:`Issue`}),(0,p.jsx)(`h4`,{className:e.date_closed?`text-danger mb-0`:`mb-0`,children:e.date_closed?(0,p.jsx)(`s`,{children:e.issue}):e.issue})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(U,{variant:`outline-primary`,size:`sm`,onClick:()=>u(e=>!e),"aria-label":`Toggle Details`,children:l?`Hide Details`:`Show Details`}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{o((0,p.jsx)(VD,{equipment:t,showModal:!0,onClose:e=>{c(!1),e&&f(e)},issue:e,attachments:m()})),c(!0)},"aria-label":`Edit Issue`,children:`Edit`})]})]}),l&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mb-2`,children:(0,p.jsx)(MD,{children:e.description})}),(0,p.jsx)(`p`,{className:`mb-3`,children:e.actions}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-4 text-muted`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Creator`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.owner.full_name})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Created`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(e.date_created,`DD MMMM YYYY`)})]}),e.date_closed&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Closed`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(e.date_closed,`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Forecast Up`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(e.forecast_up,`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Issue Type`}),(0,p.jsxs)(`div`,{className:`text-body`,children:[e.issue_type===ut.DEFAULT&&`Issue`,e.issue_type===ut.ESCALATION&&`Escalation`,e.issue_type===ut.PRIORITY&&`Priority`]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Attachments`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.attachments})]}),e.updated_by&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update By`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.updated_by.full_name})]}),e.last_update&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update`}),(0,p.jsx)(`div`,{className:`text-body`,children:RD(e.last_update,`DD MMMM YYYY`)})]})]})]}),s&&a]})}function UD({reservations:e}){if(!e||e.length<1)return(0,p.jsx)(p.Fragment,{});let t=e[0];return(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsxs)(fl,{id:`tooltip-${t.id}`,children:[(0,p.jsx)(`h5`,{children:t.title}),(0,p.jsx)(`p`,{children:e[0].active?`Currently active`:`Upcoming in: ${RD(e[0].start,`DD MMMM YYYY`)}`}),(0,p.jsx)(`p`,{children:e[1]?`Next upcoming reservation in: ${RD(e[1].start,`DD MMMM YYYY`)}`:`No next upcoming reservations`})]}),children:(0,p.jsxs)(wr,{bg:e[0].active?`info`:`dark`,children:[`Reserved by: `,e[0].user.full_name]})})}function WD({equipment:e,modules:t,issues:n,issueAttachments:r,ecnNotes:i,ecnAttachments:a,reloadQueryFn:o,showIssues:s,reservations:c}){let[l,u]=(0,d.useState)(null),[f,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)([]),[x,S]=(0,d.useState)(void 0),[C,w]=(0,d.useState)([]),[T,E]=(0,d.useState)([]),D=e=>{o([`ecn`,`attachment`,`status_mail`]),w([...C,e])},O=e=>{o([`issue`,`status_mail`]),o([`issue`,`attachment`,`status_mail`]),E([...T,e])};(0,d.useEffect)(()=>{w(i),E(n),b(t.filter(t=>t.equipment.id===e.id&&t.id!==e.main_tool_module_id)),S(t.findLast(t=>t.equipment.id===e.id&&t.id===e.main_tool_module_id))},[i,n,e,t]);let k=e=>C.filter(t=>t.module_id===e),A=e=>T.filter(t=>t.module_id===e);return(0,p.jsxs)(`div`,{className:`card mb-4`,children:[(0,p.jsxs)(`div`,{className:`card-header d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsxs)(`h4`,{className:`mb-0`,children:[e.number,` - `,e.name]}),x&&(0,p.jsx)(Ld,{module:x}),x&&(0,p.jsx)(UD,{reservations:c.filter(e=>e.modules.some(e=>e.id===x.id))})]}),(0,p.jsxs)(ms,{as:Tr,title:`Action`,id:`bg-nested-dropdown`,children:[(0,p.jsx)(fs.Item,{eventKey:`1`,onClick:()=>{g((0,p.jsx)(Qb,{equipment:e,showModal:!0,onClose:e=>{v(!1),e&&D(e)}})),v(!0)},children:`New ECN`}),s!==1&&(0,p.jsx)(fs.Item,{eventKey:`1`,onClick:()=>{u((0,p.jsx)(VD,{equipment:e,showModal:!0,onClose:e=>{m(!1),e&&O(e)}})),m(!0)},children:`New Issue`})]})]}),(0,p.jsx)(`div`,{className:`card-body`,children:(0,p.jsxs)(jl,{children:[x&&(0,p.jsx)(qr,{xs:12,md:y.length>0?6:12,children:(0,p.jsx)(W,{className:`mb-3`,children:(0,p.jsxs)(W.Body,{children:[(0,p.jsxs)(W.Title,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{children:`Main module`}),(0,p.jsx)(`div`,{className:`ms-2`})]}),(0,p.jsxs)(`div`,{className:`mt-3`,children:[k(x.id).map(t=>(0,p.jsx)(BD,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},t.id)),s!==1&&A(x.id).map(t=>(0,p.jsx)(HD,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},t.id))]})]})})}),y.length>0&&(0,p.jsx)(qr,{xs:12,md:x?6:12,children:y.map(t=>(0,p.jsx)(W,{className:`mb-3`,children:(0,p.jsxs)(W.Body,{children:[(0,p.jsx)(W.Title,{className:`d-flex align-items-center`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(`span`,{children:t.name}),(0,p.jsx)(Ld,{module:t}),(0,p.jsx)(UD,{reservations:c.filter(e=>e.modules.some(e=>e.id===t.id))})]})}),(0,p.jsxs)(`div`,{className:`mt-3`,children:[k(t.id).map(t=>(0,p.jsx)(BD,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},t.id)),s!==1&&A(t.id).map(t=>(0,p.jsx)(HD,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},t.id))]})]})},t.id))})]})}),_&&h,f&&l]})}var GD=()=>document.documentElement.getAttribute(`data-bs-theme`)===`dark`,KD={control:e=>({...e,backgroundColor:GD()?`#212529`:e.backgroundColor,borderColor:GD()?`#495057`:e.borderColor,color:GD()?`#fff`:e.color}),menu:e=>({...e,backgroundColor:GD()?`#212529`:e.backgroundColor}),option:(e,t)=>({...e,backgroundColor:GD()?t.isSelected?`#0d6efd`:t.isFocused?`#343a40`:`#212529`:e.backgroundColor,color:GD()?`#fff`:e.color}),singleValue:e=>({...e,color:GD()?`#fff`:e.color}),multiValue:e=>({...e,backgroundColor:GD()?`#343a40`:e.backgroundColor}),multiValueLabel:e=>({...e,color:GD()?`#fff`:e.color}),input:e=>({...e,color:GD()?`#fff`:e.color})},qD=(e,t)=>{let n=[];for(let r of e??[]){let e=t.get(r.id);e&&n.push(e)}return n},JD=({showModal:e,onClose:t,message:n})=>{let{register:r,handleSubmit:i,setValue:a,reset:o,control:s}=Id({defaultValues:{title:n?.title,description:n?.description,rooms:n?.rooms,type:n?.type,owner:n?.owner}}),[c,l]=(0,d.useState)([]),[u,m]=(0,d.useState)([]),[h,g]=(0,d.useState)(``),_=(0,d.useMemo)(()=>new Map(c.map(e=>[e.value.id,e])),[c]),{statusMail:v}=(0,d.useContext)(uy);(0,d.useEffect)(()=>{f.default.get(`/list/room`).then(e=>{let t=(e.data._embedded.items||[]).map(e=>({value:e,label:e.name}));l(t)}).catch(e=>{console.error(`Error fetching rooms:`,e),g(`Error fetching rooms:`+e)}),f.default.get(`/list/location/message/type`).then(e=>{let t=new Set(v.filter.messageType),r=e.data._embedded.items||[],i=[];for(let e of r)t.has(e.id.toString())&&i.push({value:e,label:e.type});m(i),a(`type`,n?.type||i[0].value)}).catch(e=>{console.error(`Error fetching message types:`,e),g(`Error fetching message types:`+e)})},[]);let y=e=>e.title?e?.owner.value===void 0&&n?.owner===void 0?`owner`:e.rooms===void 0||e.rooms.map(e=>e.id).length<=0?`room`:e.type?``:`type`:`title`;return(0,p.jsx)(K,{show:e,size:`lg`,centered:!0,onHide:()=>t(n),children:(0,p.jsxs)(G,{onSubmit:i(async e=>{let r=y(e);if(r!==``){g(`Please fill: `+r);return}try{let r={title:e.title,description:e.description,owner:e?.owner.value||n?.owner.id,type:e.type.id,rooms:e.rooms.map(e=>e.id)},i;if(i=n?await f.default.patch(`/update/location/message/${n.id}`,r):await f.default.post(`/create/location/message`,r),i){t(i?.data),o();return}console.error(`No response received`),g(`No response received`)}catch(e){console.error(`Error submitting the form:`,e),g(`Error submitting the form:`+e)}}),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Edit status mail message`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Title`}),(0,p.jsx)(G.Control,{type:`text`,placeholder:`Enter the title`,...r(`title`)})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Message`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:3,placeholder:`Give the message`,...r(`description`)})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:s,...r(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Rooms`}),(0,p.jsx)(wu,{name:`rooms`,control:s,render:({field:e})=>(0,p.jsx)(pv,{isMulti:!0,options:c,classNamePrefix:`react-select`,placeholder:`Select one or more rooms`,value:qD(e.value,_),onChange:t=>e.onChange(t.map(e=>e.value)),styles:KD})})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Type`}),(0,p.jsx)(wu,{name:`type`,control:s,render:({field:e})=>(0,p.jsx)(pv,{options:u,classNamePrefix:`react-select`,placeholder:`— Select a message type`,value:u.find(t=>t.value.id===e.value?.id)||null,onChange:t=>e.onChange(t?.value),styles:KD})})]})]}),(0,p.jsxs)(K.Footer,{children:[h!=``&&(0,p.jsx)(`span`,{className:`text-danger`,children:h}),(0,p.jsx)(U,{variant:`secondary`,onClick:()=>t(n),children:`Cancel`}),(0,p.jsx)(U,{variant:`primary`,type:`submit`,children:n?`Update Message`:`Create Message`})]})]})})};function YD({message:e}){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(e),s=e=>{o({...a,...e})};return(0,p.jsxs)(`div`,{className:`card mb-4`,children:[(0,p.jsxs)(`div`,{className:`card-header d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(wr,{bg:`dark`,children:a.type.type}),(0,p.jsx)(`h5`,{className:`mb-0`,children:a.title})]}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{n((0,p.jsx)(JD,{showModal:!0,onClose:e=>{i(!1),e&&s(e)},message:a})),i(!0)},children:`Edit`})]}),(0,p.jsx)(`div`,{className:`card-body`,children:(0,p.jsx)(MD,{children:a.description})}),(0,p.jsx)(`div`,{className:`card-footer bg-transparent`,children:(0,p.jsxs)(`small`,{className:`text-muted d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`span`,{children:[`Created: `,RD(a.date_created,`DD MMM YYYY`)]}),a.last_update&&(0,p.jsxs)(`span`,{children:[`Updated: `,RD(a.last_update,`DD MMM YYYY`)]}),a.rooms.length>0&&(0,p.jsxs)(`span`,{children:[`Rooms:`,` `,a.rooms.map((e,t)=>(0,p.jsxs)(d.default.Fragment,{children:[t>0&&`, `,e.name]},e.id))]}),(0,p.jsxs)(`span`,{children:[`Owner: `,a.owner.full_name]})]})}),r&&t]})}function XD({messageList:e,refetchFn:t}){let[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex gap-3`,children:[(0,p.jsx)(`h2`,{children:`Messages`}),(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`secondary`,onClick:()=>{r((0,p.jsx)(JD,{showModal:!0,onClose:e=>{a(!1),t()}})),a(!0)},children:`New message`})})]}),e.map((e,t)=>(0,p.jsx)(`div`,{children:(0,p.jsx)(YD,{message:e})},e.id)),i&&n]})}function ZD({issue:e,moduleName:t,issueAttachments:n,equipment:r,reloadQueryFn:i}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),l=e=>{i([`issue`,`status_mail`]),i([`issue`,`attachment`,`status_mail`])},u=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:`align-middle`,children:[(0,p.jsx)(`td`,{className:`text-nowrap`,children:t??`-`}),(0,p.jsx)(`td`,{children:e.issue}),(0,p.jsx)(`td`,{children:(0,p.jsx)(MD,{children:e.description})}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:RD(e.forecast_up,`DD MMMM YYYY`)}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:e.owner.full_name}),(0,p.jsx)(`td`,{className:`text-center`,children:(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-outline-light`,onClick:()=>{if(!r){console.error(`equipment is null in the table`);return}c(!0),o((0,p.jsx)(VD,{equipment:r,showModal:!0,onClose:e=>{c(!1),e&&l(e)},issue:e,attachments:u()}))},children:`Edit`})})]},e.id),s&&a]})}function QD({issues:e,modules:t,issueAttachments:n,reloadQueryFn:r}){return(0,p.jsx)(`div`,{className:`table-responsive`,children:(0,p.jsxs)(`table`,{className:`table table-hover table-striped table-bordered table-sm`,children:[(0,p.jsx)(`thead`,{className:`bg-primary text-white`,children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{scope:`col`,children:`Module`}),(0,p.jsx)(`th`,{scope:`col`,children:`Issue`}),(0,p.jsx)(`th`,{scope:`col`,children:`Description`}),(0,p.jsx)(`th`,{scope:`col`,children:`Forecast Up`}),(0,p.jsx)(`th`,{scope:`col`,children:`Owner`}),(0,p.jsx)(`th`,{scope:`col`,className:`text-center`,children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:e.map(e=>(0,p.jsx)(ZD,{issue:e,moduleName:t.find(t=>t.id===e.module_id)?.name,issueAttachments:n,equipment:t.find(t=>t.id===e.module_id)?.equipment,reloadQueryFn:r},e.id))})]})})}function $D({statusMail:e}){let[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(!1);return(0,p.jsx)(U,{variant:`primary`,size:`sm`,onClick:async()=>{try{if(n(!0),!e.id||e.id<=0)throw Error(`Status Mail ID is not correctly set`);let t={status_mail:e.id};await f.default.post(`/send/status-mail`,t),i(!0)}catch(e){console.error(`Error sending status mail:`,e),alert(`Error sending status mail. Please try again.`)}finally{n(!1)}},disabled:t,"aria-label":`Toggle Details`,children:t?`Sending...`:r?`Sending successful`:`Send Status Mail`})}function eO(){let{statusMail:e}=(0,d.useContext)(uy),[t,n]=(0,d.useState)([]),r=(0,m.useQueryClient)(),i=(0,m.useQueries)({queries:[{queryKey:[`equipment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>N({statusMail:e})},{queryKey:[`module`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>re({statusMail:e})},{queryKey:[`ecn`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ee({statusMail:e})},{queryKey:[`issue`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ne({statusMail:e})},{queryKey:[`messages`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ae({statusMail:e})},{queryKey:[`ecn`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>F({statusMail:e})},{queryKey:[`issue`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>L({statusMail:e})},{queryKey:[`reservation`,`active`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ie({which:`active`})},{queryKey:[`reservation`,`upcoming`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ie({which:`upcoming`})}]}),a=t=>{let n=t;n.push(JSON.stringify(e.filter)),r.refetchQueries({queryKey:n})},[o,s,c,l,u,f,h,g,_]=i,v=i.some(e=>e.isLoading),y=i.some(e=>e.isError),b=i.every(e=>e.isSuccess);return(0,d.useEffect)(()=>{b&&n(o.data.items)},[b]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[`Status mail `,e.name]}),(0,p.jsx)(`div`,{children:(0,p.jsx)($D,{statusMail:e})})]}),(0,p.jsx)(`p`,{children:e.subject}),v&&(0,p.jsx)(Cr,{variant:`info`,children:`Loading status mail`}),y&&(0,p.jsx)(Cr,{variant:`danger`,children:`Error loading status mail`}),b&&e.show_issues_with_priority&&(()=>{let e=l.data.items.filter(e=>e.issue_type===2);return e.length===0?(0,p.jsx)(p.Fragment,{}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{children:`Issues with priority`}),(0,p.jsx)(QD,{issues:e,modules:s.data.items,issueAttachments:h.data.items,reloadQueryFn:a})]})})(),b&&u.data&&(0,p.jsx)(XD,{messageList:u.data.items,refetchFn:u.refetch}),b&&(()=>{if(!t.length)return(0,p.jsx)(`p`,{children:`No equipment available.`});let n=[...t].sort((t,n)=>e.classification===ft.ROOM?t.room.name.localeCompare(n.room.name):t.area&&n.area&&e.classification===ft.AREA?t.area.title.localeCompare(n.area.title):t.area&&n.area&&e.classification===ft.AREA_PER_FACILITY?t.area.facility.title.localeCompare(n.area.facility.title)||t.area.title.localeCompare(n.area.title):0),r,i=null,o=``;return n.map(t=>{let n=[];return e.classification===ft.ROOM?t.room.name!==o&&(n.push((0,p.jsxs)(`h2`,{children:[`Room: `,t.room.name]},`room-${t.room.name}`)),o=t.room.name):e.classification===ft.AREA?t.area&&t.area!==i&&(n.push((0,p.jsxs)(`h2`,{children:[`Area: `,t.area.title]},`area-${t.area.id}`)),i=t.area):e.classification===ft.AREA_PER_FACILITY&&(t.area&&t.area.facility!==r&&(n.push((0,p.jsxs)(`h2`,{children:[`Facility: `,t.area.facility.title]},`facility-${t.area.facility.id}`)),r=t.area.facility),t.area&&t.area!==i&&(n.push((0,p.jsxs)(`h4`,{children:[`Area: `,t.area.title]},`area-${t.area.id}`)),i=t.area)),n.push((0,p.jsx)(WD,{equipment:t,modules:s.data.items,issues:l.data.items,issueAttachments:h.data.items,ecnNotes:c.data.items,ecnAttachments:f.data.items,reloadQueryFn:a,showIssues:e.show_issues,reservations:e.show_reservations?g.data.items.concat(_.data.items):[]},t.id)),n})})()]})}function tO({monitor:e}){let{environment:t}=(0,g.useParams)(),[n]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,e],queryFn:()=>ue({monitorId:e.id})}]});return n.isLoading?(0,p.jsx)(`div`,{children:`Loading requirements...`}):n.data?.items.map(n=>{let r=`bg-secondary-subtle`;if(n.latest_result)for(let e=0;e<n.latest_result.values.length;e++){if(n.latest_result.values[e].value_is_valid===!1){r=`bg-danger-subtle`;break}if(n.latest_result.values[e].value_is_valid===!0){r=`bg-success-subtle`;break}}return(0,p.jsx)(W,{className:`mb-2 me-2`,children:(0,p.jsxs)(W.Body,{className:r,children:[(0,p.jsx)(W.Title,{children:(0,p.jsx)(g.Link,{to:`/${t}/operator/monitor/`+e.id,children:e.name})}),(0,p.jsxs)(W.Text,{children:[n.title,n.latest_result&&(0,p.jsxs)(p.Fragment,{children:[`Latest measurement: `,zD(n.latest_result.date_created,`DD-MM-YY HH:mm`)]})]})]})},n.id)})}function nO({show:e,onClose:t}){return(0,p.jsx)(Hl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Bl,{onClose:t,show:e,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Bl.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Assist logged`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Bl.Body,{children:`Assist was logged successfully`})]})})}var rO=({moduleId:e,size:t})=>{let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(``);function c(){f.default.create().post(`create/equipment/module/changelog`,{module:e,changelog:o}).finally(()=>{r(!1),a(!0),s(``)})}let l=e=>{s(e.target.value)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{variant:`primary`,size:t,onClick:()=>r(!0),children:`Log assist`}),(0,p.jsxs)(K,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Log assist`})}),(0,p.jsx)(K.Body,{children:(0,p.jsx)(G,{children:(0,p.jsxs)(G.Group,{className:`mb-3`,controlId:`modal.ControlTextarea1`,children:[(0,p.jsx)(G.Label,{children:`Describe the assist`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:3,value:o,onChange:e=>l(e)})]})})}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,variant:`primary`,onClick:()=>c(),children:`Log assist`}),(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{r(!1)},children:`Close`})]})]}),(0,p.jsx)(nO,{show:i,onClose:()=>a(!1)})]})},iO=(0,d.createContext)({equipment:{},reloadEquipment:()=>{}});function aO({issue:e,equipment:t,issueAttachments:n,reloadQueryFn:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(e),u=e=>{r([`issue`,t.name]),r([`issue`,`attachment`,t.name]),l({...c,...e})},f=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(W,{className:`my-2`,children:[(0,p.jsxs)(W.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(W.Title,{children:[(0,p.jsx)(wr,{bg:`dark`,children:`Issue`}),` `,c.issue]}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(VD,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},issue:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(W.Text,{children:(0,p.jsx)(MD,{children:c.description})})]}),(0,p.jsxs)(nc,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Created:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:zD(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Owner:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.owner.full_name})]}),c.updated_by&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Updated:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.updated_by.full_name}),(0,p.jsxs)(`span`,{className:`ms-1`,children:[`(`,zD(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},c.module_id),o&&i]})}function oO({ecn:e,equipment:t,ecnAttachments:n,reloadQueryFn:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(e),u=e=>{r([`ecn`,t.name]),r([`ecn`,`attachment`,t.name]),l({...c,...e})},f=()=>n.filter(t=>t.ecn.id===e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(W,{className:`my-2`,children:[(0,p.jsxs)(W.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(W.Title,{children:[(0,p.jsx)(wr,{bg:`dark`,children:`ECN`}),` `,e.ecn]}),(0,p.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(Qb,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},ecn:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(W.Text,{children:(0,p.jsx)(MD,{children:e.description})})]}),(0,p.jsxs)(nc,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Created:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:zD(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Owner:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.owner.full_name})]}),c.updated_by&&(0,p.jsxs)(nc.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Updated:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.updated_by.full_name}),(0,p.jsxs)(`span`,{className:`ms-1`,children:[`(`,zD(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},e.module_id),o&&i]})}var sO=e=>{if(e<60)return`${e} min`;let t=Math.floor(e/60),n=e%60;return`${t}h ${n>0?`${n}min`:``}`.trim()};function cO(){let{id:e}=(0,g.useParams)(),[t,n]=(0,d.useState)([]),r=(0,m.useQueries)({queries:[{queryKey:[`service`,`equipment`,e],queryFn:()=>qe({equipmentId:Number(e)})}]}),[i]=r,a=r.some(e=>e.isLoading),o=r.some(e=>e.isError),s=r.every(e=>e.isSuccess);return(0,d.useEffect)(()=>{s&&n(i.data.items)},[s,i.data]),a?(0,p.jsx)(`div`,{children:`Loading...`}):o?(0,p.jsx)(`div`,{children:`Error loading services.`}):i.data.items.length===0?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsx)(Cr,{variant:`info`,children:`No services found`})]}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsxs)(Nl,{striped:!0,bordered:!0,hover:!0,responsive:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Id`}),(0,p.jsx)(`th`,{children:`Name`}),(0,p.jsx)(`th`,{children:`Type`}),(0,p.jsx)(`th`,{children:`Team`}),(0,p.jsx)(`th`,{children:`Department`}),(0,p.jsx)(`th`,{children:`Duration`}),(0,p.jsx)(`th`,{children:`Report2`})]})}),(0,p.jsx)(`tbody`,{children:t.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.id}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${window.location.pathname.split(`/`)[1]}/service/details/${e.id}/general.html`,children:e.name})}),(0,p.jsx)(`td`,{children:e.type?.name||`N/A`}),(0,p.jsx)(`td`,{children:e.team?.name||`N/A`}),(0,p.jsx)(`td`,{children:e.department?.name||`N/A`}),(0,p.jsx)(`td`,{children:sO(e.minutes_needed_for_service)}),(0,p.jsx)(`td`,{children:e.latest_event_report_id&&(0,p.jsx)(`a`,{className:`btn btn-primary btn-sm`,href:`/${window.location.pathname.split(`/`)[1]}/service/event/report/${e.latest_event_report_id}/results`,children:`View Report`})})]},e.id))})]})]})}function lO(){let{environment:e}=(0,g.useParams)(),{equipment:t}=(0,d.useContext)(iO),n=(0,m.useQueryClient)(),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(!1),[f,h,_,v,y,b,x]=(0,m.useQueries)({queries:[{queryKey:[`runs`,t.name,e],queryFn:()=>je({firstUnfinishedStepEquipment:t,environment:e})},{queryKey:[`monitors`,t.name],queryFn:()=>de({equipment:t})},{queryKey:[`ecn`,t.name],queryFn:()=>ee({equipment:t})},{queryKey:[`issue`,t.name],queryFn:()=>ne({equipment:t})},{queryKey:[`module`,t.name],queryFn:()=>re({equipment:t})},{queryKey:[`ecn`,`attachment`,t.name],queryFn:()=>F({equipment:t})},{queryKey:[`issue`,`attachment`,t.name],queryFn:()=>L({equipment:t})}]}),S=e=>{n.invalidateQueries({queryKey:e})},C=e=>e?_.data?.items.filter(t=>t.module_id===e):[],w=e=>e?v.data?.items.filter(t=>t.module_id===e):[],T=()=>{c((0,p.jsx)(Qb,{equipment:t,showModal:!0,onClose:()=>{u(!1),setTimeout(()=>{S([`ecn`,t.name]),S([`ecn`,`attachment`,t.name])},100)}})),u(!0)},E=()=>{i((0,p.jsx)(VD,{equipment:t,showModal:!0,onClose:()=>{o(!1),setTimeout(()=>{S([`issue`,t.name]),S([`issue`,`attachment`,t.name])},100)}})),o(!0)};return(0,p.jsxs)(Jr,{fluid:!0,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-left`,children:h.data?.items&&h.data.items.map(e=>(0,p.jsx)(tO,{monitor:e},e.id))}),(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{md:8,children:[(0,p.jsx)(`h2`,{children:`Runs`}),f.isLoading&&(0,p.jsx)(`div`,{children:`Loading...`}),` `,f.isError&&(0,p.jsx)(`div`,{children:`Error...`}),f.isFetched&&f.data&&f.data?.items.length===0&&(0,p.jsx)(Cr,{variant:`info`,children:`No runs found`}),f.isFetched&&f.data&&f.data?.items.length>0&&(0,p.jsxs)(Nl,{striped:!0,bordered:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Run`}),(0,p.jsx)(`th`,{children:`Priority`}),(0,p.jsx)(`th`,{children:`Hold Code`}),(0,p.jsx)(`th`,{children:`Batch Card`}),(0,p.jsx)(`th`,{children:`Project`})]})}),(0,p.jsx)(`tbody`,{children:f.data?.items.map(t=>(0,p.jsxs)(`tr`,{children:[(0,p.jsxs)(`td`,{children:[t.first_unfinished_step&&(0,p.jsx)(g.Link,{to:`/${e}/operator/run/step/${t.first_unfinished_step.id}`,children:t.name}),t.first_unfinished_step===void 0&&t.last_finished_step&&(0,p.jsx)(g.Link,{to:`/${e}/operator/run/step/${t.last_finished_step.id}`,children:t.name})]}),(0,p.jsxs)(`td`,{children:[t.priority&&(0,p.jsx)(`span`,{className:`badge`,style:{backgroundColor:t.priority.priority.back_color,color:t.priority.priority.front_color},children:t.priority.priority.code}),!t.priority&&(0,p.jsx)(`span`,{className:`badge bg-info`,children:`NORMAL`})]}),(0,p.jsx)(`td`,{children:t.hold_code&&(0,p.jsx)(`span`,{className:`badge handle`,style:{backgroundColor:t.hold_code.hold_code.back_color,color:t.hold_code.hold_code.front_color},children:t.hold_code.hold_code.code})}),(0,p.jsx)(`td`,{children:t.batch_card&&t.batch_card.content&&(0,p.jsx)(`span`,{className:`text-danger`,children:t.batch_card.content})}),(0,p.jsx)(`td`,{children:t.project.name})]},t.id))})]}),(0,p.jsx)(cO,{})]}),(0,p.jsxs)(qr,{md:4,children:[(0,p.jsx)(`h2`,{children:`Assistance`}),y.data?.items.map(e=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`h3`,{children:e.id===t.main_tool_module_id?`Main tool`:e.name}),(0,p.jsx)(`div`,{children:(0,p.jsx)(Ld,{module:e,refetchFn:()=>S([`module`,t.name])})})]}),(0,p.jsxs)(`div`,{className:`pb-lg-5`,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between`,children:(0,p.jsxs)(`div`,{className:`d-flex gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`primary`,size:`sm`,onClick:E,children:`New Issue`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`primary`,size:`sm`,onClick:T,children:`New ECN`})}),(0,p.jsx)(`div`,{children:e.id===t.main_tool_module_id&&(0,p.jsx)(rO,{size:`sm`,moduleId:e.id})})]})}),C(e.id)?.map(e=>(0,p.jsx)(oO,{ecn:e,equipment:t,ecnAttachments:b.data?.items??[],reloadQueryFn:S},e.id)),w(e.id)?.map(e=>(0,p.jsx)(aO,{issue:e,equipment:t,issueAttachments:x.data?.items??[],reloadQueryFn:S},e.id))]})]},e.id))]})]}),l&&s,a&&r]})}var uO=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&k({id:parseInt(n)}).then(t)},[n,e]);function r(){k({id:parseInt(n)}).then(t)}return{equipment:e,setEquipment:t,reloadEquipment:r}};function dO({children:e}){let{equipment:t,reloadEquipment:n}=uO();return t===null?(0,p.jsx)(Ot,{children:(0,p.jsx)(Ct,{message:`Loading equipment...`})}):(0,p.jsx)(Ot,{children:(0,p.jsx)(iO.Provider,{value:{equipment:t,reloadEquipment:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}function fO(){let{equipment:e}=(0,d.useContext)(iO),t=(0,m.useQueries)({queries:[{queryKey:[`activeReservationQuery`,e],queryFn:()=>ie({equipment:e,which:`active`})},{queryKey:[`upcomingReservationQuery`,e],queryFn:()=>ie({equipment:e,which:`upcoming`})},{queryKey:[`modules`,e],queryFn:()=>re({equipment:e})}]}),[n,r,i]=t,a=t.some(e=>e.isLoading),o=t.every(e=>e.isSuccess);return a?(0,p.jsx)(`div`,{children:`Loading...`}):o&&(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between mb-3`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[e.name,` Operator Dashboard`]}),(0,p.jsxs)(`div`,{children:[n.data?.items.map(e=>(0,p.jsxs)(`div`,{className:`mx-2 p-2 rounded border-danger`,style:{backgroundColor:e.color},children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-o text-white pe-2`,"aria-hidden":`true`}),`Active reservation`,(0,p.jsx)(`br`,{}),`Until `,zD(e.end,`DD-MM-YY HH:mm`),` by `,e.user.full_name]},e.id)),r.data?.items.map(e=>(0,p.jsxs)(`div`,{className:`mx-2 p-2 rounded border-success border-2`,style:{backgroundColor:e.color},children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-o text-white pe-2`,"aria-hidden":`true`}),`Next reservation`,(0,p.jsx)(`br`,{}),zD(e.start,`DD-MM-YY HH:mm`),(0,p.jsx)(`br`,{}),e.user.full_name]},e.id))]})]})}function pO(){return(0,p.jsxs)(dO,{children:[(0,p.jsx)(fO,{}),(0,p.jsx)(g.Outlet,{})]})}function mO({children:e}){let{id:t}=(0,g.useParams)(),{data:n,isFetching:r,isLoading:i}=(0,m.useQuery)({queryKey:[`statusMail`,t],queryFn:()=>j({id:parseInt(t)}),enabled:!!t});return i||r?(0,p.jsx)(Ot,{children:(0,p.jsx)(Ct,{message:`Loading status mail...`})}):(0,p.jsx)(Ot,{children:(0,p.jsx)(uy.Provider,{value:{statusMail:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}var hO,gO;function _O(e){let[t,n]=(0,d.useState)(!0),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),s=()=>{n(!1),o(!0)};return(0,d.useEffect)(()=>{if(!document){let t=Error(`[ScriptLoadingError] document not defined when attempting to load ${e}`);i(t);return}let t=document.querySelector(`script[src="${e}"]`);if(t?.dataset.loaded){s();return}let n=t||document.createElement(`script`);t||(n.src=e),n.addEventListener(`load`,()=>{n.dataset.loaded=`1`,s()}),n.addEventListener(`error`,t=>{console.error(`Failed to load script:`,e,t);let n=Error(`[ScriptLoadingError] Failed to load script: ${e}`);i(n)}),t||document.head.append(n)},[]),{isLoading:t,error:r,isSuccess:a}}var vO=e=>e&&e.charts,yO=(e,t)=>{let{controls:n,toolbarItems:r,getChartEditor:i}=e;return t&&t.charts&&t.visualization&&t.visualization.ChartWrapper&&t.visualization.Dashboard&&(!n||t.visualization.ChartWrapper)&&(!i||t.visualization.ChartEditor)&&(!r||t.visualization.drawToolbar)},bO=e=>window.google;function xO(e){let{chartVersion:t=`current`,chartPackages:n=[`corechart`,`controls`],chartLanguage:r=`en`,mapsApiKey:i}=e,[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),{isLoading:f,error:p,isSuccess:m}=_O(e.chartLoaderScriptUrl||`https://www.gstatic.com/charts/loader.js`);return(0,d.useEffect)(()=>{if(!m)return;let a=bO();if(!vO(a)){c(Error(`[ScriptInitializationError] Script loaded but Google not attached to window.`));return}if(yO(e,a)){o(a);return}a.charts.load(t,{packages:n,language:r,mapsApiKey:i}),a.charts.setOnLoadCallback(()=>{if(!yO(e,a)){let e=Error(`[GoogleChartsInitializationError] Google Charts not ready after load callback.`);console.error(e),u(e);return}o(a)})},[m]),{error:p||s||l,isLoading:f,google:a}}var SO={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:`https://www.gstatic.com/charts/loader.js`},CO=e=>{let{isReady:t,chartControls:n,filter:r}=e;return!t||!n||!n?.length?null:d.default.createElement(d.default.Fragment,null,n.filter(e=>{let{controlProp:t,control:n}=e;return!r||r({control:n,controlProp:t})}).map(e=>{let{control:t}=e;return d.default.createElement(`div`,{key:t.getContainerId(),id:t.getContainerId()})}))},wO=0,TO=()=>(wO+=1,`reactgooglegraph-${wO}`),EO=class{};hO=EO,Dt(EO,`initializeControls`,e=>{for(let t=0;t<e.length;t+=1){let{controlType:n,options:r,controlWrapperParams:i}=e[t].controlProp;i&&`state`in i&&e[t].control.setState(i.state),e[t].control.setOptions(r),e[t].control.setControlType(n)}}),Dt(EO,`listenToControlEvents`,(e,t)=>{let{google:n}=t;return e.flatMap(e=>{let{control:r,controlProp:i}=e,{controlEvents:a=[]}=i;return a.map(e=>{let{callback:i,eventName:a}=e;return n.visualization.events.addListener(r,a,function(){for(var e=arguments.length,a=Array(e),o=0;o<e;o++)a[o]=arguments[o];i({chartWrapper:null,controlWrapper:r,props:t,google:n,eventArgs:a})})})})}),Dt(EO,`createControlId`,e=>{let t;return t=e===void 0?`googlechart-control-${TO()}`:e,t}),Dt(EO,`createChartControls`,e=>{let{controls:t,google:n}=e;return t?t.map((e,t)=>{let{controlID:r,controlType:i,options:a,controlWrapperParams:o}=e,s=hO.createControlId(r);return{controlProp:e,control:new n.visualization.ControlWrapper({containerId:s,controlType:i,options:a,...o})}}):null}),Dt(EO,`addControls`,e=>{let{chartWrapper:t,chartDashboard:n}=e,r=hO.createChartControls(e);return!r||!n||!t?null:(n.bind(r.map(e=>{let{control:t}=e;return t}),t),hO.initializeControls(r),r)});var DO=e=>{let[t,n]=d.useState(null);return[d.useMemo(()=>!t||!e?null:e.map((e,n)=>{let r=t[n];return r?{controlProp:e,control:r}:void 0}).flatMap(e=>e?[e]:[]),[t,e]),n]},OO=(e,t)=>{d.useEffect(()=>{let n=EO.listenToControlEvents(e??[],t);return()=>{n.forEach(e=>{t.google.visualization.events.removeListener(e)})}},[e,t])},kO=e=>{let[t,n]=DO(e.controls);return OO(t??[],e),{addControls:e=>{let t=EO.addControls(e);n(t?.map(e=>e.control)??null)},renderControl:n=>{let{chartWrapper:r,chartDashboard:i}=e;return d.createElement(CO,{...e,isReady:!!(r&&i),chartControls:t,filter:n})}}},AO=e=>{let t=d.useRef(null);return{chartId:(()=>{let{graphID:n,graph_id:r}=e,i=n||r,a;return a=i||t.current||TO(),t.current=a,t.current})()}},jO=[`#3366CC`,`#DC3912`,`#FF9900`,`#109618`,`#990099`,`#3B3EAC`,`#0099C6`,`#DD4477`,`#66AA00`,`#B82E2E`,`#316395`,`#994499`,`#22AA99`,`#AAAA11`,`#6633CC`,`#E67300`,`#8B0707`,`#329262`,`#5574A6`,`#3B3EAC`],MO=async function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return new Promise((r,i)=>{let a=`${n.headers?`headers=${n.headers}`:`headers=0`}`,o=`${n.query?`&tq=${encodeURIComponent(n.query)}`:``}`,s=`${t}/gviz/tq?${`${a}${`${n.gid?`&gid=${n.gid}`:``}`}${`${n.sheet?`&sheet=${n.sheet}`:``}`}${o}${`${n.access_token?`&access_token=${n.access_token}`:``}`}`}`;new e.visualization.Query(s).send(e=>{e.isError()?i(`Error in query: ${e.getMessage()} ${e.getDetailedMessage()}`):r(e.getDataTable())})})},NO=`#CCCCCC`,PO=class{};gO=PO,Dt(PO,`grayOutHiddenColumnsLabel`,(e,t)=>{let{googleChartWrapper:n,options:r}=e;if(!n){console.error(`googleChartWrapper is not defined`);return}let i=n.getDataTable();if(!i)return;let a=i.getNumberOfColumns();if(!(t.length>0))return;let o=Array.from({length:a-1}).map((e,n)=>{let a=gO.getColumnId(i,n+1);return t.includes(a)?NO:r&&r.colors?r.colors[n]:jO[n]});n.setOptions({...r,colors:o}),n.draw()}),Dt(PO,`listenToLegendToggle`,(e,t)=>{let[n,r]=t,{google:i,googleChartWrapper:a}=e;if(!a){console.error(`googleChartWrapper is not defined`);return}return i.visualization.events.addListener(a,`select`,()=>{let e=a.getChart().getSelection(),t=a.getDataTable();if(e.length===0||e[0].row!==null||!t)return;let i=e[0].column,o=gO.getColumnId(t,i);n?.includes(o)?r(e=>[...e.filter(e=>e!==o)]):r(e=>[...e,o])})}),Dt(PO,`draw`,async e=>{let{data:t,diffdata:n,rows:r,columns:i,options:a,chartType:o,formatters:s,spreadSheetUrl:c,spreadSheetQueryParameters:l,googleChartDashboard:u,googleChartWrapper:d,google:f,hiddenColumns:p,legendToggle:m,legend_toggle:h}=e;if(!d){console.error(`draw was called with googleChartWrapper = null`);return}let g,_=null;if(n){let e=f.visualization.arrayToDataTable(n.old),t=f.visualization.arrayToDataTable(n.new);_=f.visualization[o].prototype.computeDiff(e,t)}g=t?t instanceof f.visualization.DataTable?t:Array.isArray(t)?f.visualization.arrayToDataTable(t):new f.visualization.DataTable(t):r&&i?f.visualization.arrayToDataTable([i,...r]):c?await MO(f,c,l):f.visualization.arrayToDataTable([]);let v=g.getNumberOfColumns(),y=Array(v).fill(0).map((e,t)=>{let n=gO.getColumnId(g,t);return p.includes(n)?{label:g.getColumnLabel(t),type:g.getColumnType(t),calc:()=>null}:t}),b=d.getChart();d.getChartType()===`Timeline`&&b&&b.clearChart(),d.setChartType(o),d.setOptions(a||{});let x=new f.visualization.DataView(g);x.setColumns(y),d.setDataTable(x),d.draw(),u&&u.draw(g),_&&(d.setDataTable(_),d.draw()),s&&(gO.applyFormatters({dataTable:g,formatters:s,google:f}),d.setDataTable(g),d.draw()),(m===!0||h===!0)&&gO.grayOutHiddenColumnsLabel(e,p)}),Dt(PO,`getColumnId`,(e,t)=>e.getColumnId(t)||e.getColumnLabel(t)),Dt(PO,`applyFormatters`,e=>{let{dataTable:t,formatters:n,google:r}=e;for(let e of n)switch(e.type){case`ArrowFormat`:new r.visualization.ArrowFormat(e.options).format(t,e.column);return;case`BarFormat`:new r.visualization.BarFormat(e.options).format(t,e.column);return;case`ColorFormat`:{let n=new r.visualization.ColorFormat(e.options),{ranges:i}=e;if(i)for(let e of i)n.addRange(...e);n.format(t,e.column);return}case`DateFormat`:new r.visualization.DateFormat(e.options).format(t,e.column);return;case`NumberFormat`:new r.visualization.NumberFormat(e.options).format(t,e.column);return;case`PatternFormat`:new r.visualization.PatternFormat(e.options).format(t,e.column);return;default:console.warn(`Unknown formatter type: ${e.type}`);return}});var FO=e=>{let{google:t,googleChartWrapper:n,googleChartDashboard:r}=e,[i,a]=d.useState([]);d.useEffect(()=>{n&&PO.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t})},[i,e.data,e.rows,e.columns,e.options,e.chartLoaderScriptUrl,e.chartType,e.formatters,e.spreadSheetUrl,e.spreadSheetQueryParameters,e.legendToggle,e.legend_toggle]);let o=()=>{let{googleChartWrapper:t}=e;t&&t.draw()},s=n=>{let s=[],{legendToggle:c,legend_toggle:l}=e;if(PO.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t}),window.addEventListener(`resize`,o),l||c){let t=PO.listenToLegendToggle(e,[i,a]);t&&s.push(t)}return s},c=(e,n)=>{window.removeEventListener(`resize`,o),n.forEach(e=>{t.visualization.events.removeListener(e)}),e.getChartType()===`Timeline`&&e.getChart()&&e.getChart().clearChart()};d.useEffect(()=>{if(!n)return;let e=s(n);return()=>{c(n,e)}},[n,s,c])},IO=e=>{let{chartEvents:t,google:n,googleChartWrapper:r}=e;if(t){if(!r){console.warn(`listenToEvents was called before chart wrapper ready.`);return}return t.map(t=>{let{eventName:i,callback:a}=t;return n.visualization.events.addListener(r,i,function(){for(var t=arguments.length,i=Array(t),o=0;o<t;o++)i[o]=arguments[o];a({chartWrapper:r,props:e,google:n,eventArgs:i})})})}},LO=e=>{(0,d.useEffect)(()=>{if(!e.googleChartWrapper)return;let t=IO(e);return()=>{t?.forEach(t=>{e.google.visualization.events.removeListener(t)})}},[e])},RO=e=>{let[t,n]=d.useState(null),[r,i]=d.useState(null),{addControls:a,renderControl:o}=kO({...e,chartDashboard:r,chartWrapper:t});LO({...e,googleChartWrapper:t});let{chartId:s}=AO(e),c=d.useRef(null),l=d.useRef(null);d.useEffect(()=>{let{options:t,google:r,chartType:o,chartWrapperParams:u,toolbarItems:d,getChartEditor:f,getChartWrapper:p,onLoad:m}=e,h={chartType:o,options:t,containerId:s,...u},g=new r.visualization.ChartWrapper(h);g.setOptions(t||{}),p?.(g,r);let _=new r.visualization.Dashboard(c.current);d&&r.visualization.drawToolbar(l.current,d);let v=null;f&&(v=new r.visualization.ChartEditor,f({chartEditor:v,chartWrapper:g,google:r})),a({...e,chartDashboard:_,chartWrapper:g}),n(g),i(_),m?.(r,{google:r,chartWrapper:g,chartEditor:v,chartDashboard:_})},[]),FO({...e,googleChartWrapper:t,googleChartDashboard:r});let u=()=>{let{width:t,height:n,options:r,style:i,className:a,rootProps:o,google:c}=e,l={height:n||r&&r.height,width:t||r&&r.width,...i};return d.createElement(`div`,{id:s,style:l,className:a,...o})},f=()=>e.toolbarItems?d.createElement(`div`,{ref:l}):null,{width:p,height:m,options:h,style:g}=e,_={height:m||h&&h.height,width:p||h&&h.width,...g};return e.render?d.createElement(`div`,{ref:c,style:_},d.createElement(`div`,{ref:l,id:`toolbar`}),e.render({renderChart:u,renderControl:o,renderToolbar:f})):d.createElement(`div`,{ref:c,style:_},o(e=>{let{controlProp:t}=e;return t.controlPosition!==`bottom`}),u(),o(e=>{let{controlProp:t}=e;return t.controlPosition===`bottom`}),f())},zO=d.createContext(SO),BO=e=>{let{children:t,value:n}=e;return d.createElement(zO.Provider,{value:n},t)},VO=e=>{let{google:t,isLoading:n,error:r}=xO(e);return n?e.loader??null:r?e.errorElement??null:t?d.default.createElement(RO,{google:t,...e}):null},HO=e=>{let t={...SO,...e};return d.default.createElement(BO,{value:t},d.default.createElement(VO,t))},UO;(function(e){e.annotation=`annotation`,e.annotationText=`annotationText`,e.certainty=`certainty`,e.emphasis=`emphasis`,e.interval=`interval`,e.scope=`scope`,e.style=`style`,e.tooltip=`tooltip`,e.domain=`domain`})(UO||(UO={}));function WO({target:e,results:t}){let n={title:e.logging_parameter.name,curveType:`function`,series:{0:{pointSize:10},1:{},2:{},3:{}},legend:{position:`bottom`}},r=[[{type:`date`,label:`Date`},`Value`]],i=1;return e.target&&(r[0].push(`Target`),n.series[i]={color:`#38e22c`,lineWidth:2,pointShape:{type:`square`}},i++),e.min_value&&(r[0].push(`Min`),n.series[i]={color:`#e2431e`,lineWidth:2,pointShape:{type:`triangle`},pointSize:10},i++),e.max_value&&(r[0].push(`Max`),n.series[i]={color:`#e2431e`,lineWidth:2,pointShape:{type:`triangle`,rotation:180},pointSize:10}),t.forEach(t=>{for(let n of t.values){if(n.logging_parameter.id!==e.logging_parameter.id||n.float_value===0)continue;let i=new Date(t.date_created);r.push([i,n.float_value]),e.target&&r[r.length-1].push(e.target),e.min_value&&r[r.length-1].push(e.min_value),e.max_value&&r[r.length-1].push(e.max_value)}}),r.length===1?(0,p.jsx)(`div`,{className:`text-center`,children:`No data available`}):(0,p.jsx)(HO,{chartType:`ScatterChart`,width:`100%`,height:`400px`,data:r,options:n})}var GO=({data:e,setPage:t,setPageSize:n,pageSize:r,isPlaceholderData:i})=>{if(e===void 0||i)return(0,p.jsx)(p.Fragment,{});let a=[];for(let n=1;n<=e.amountOfPages;n++)a.push((0,p.jsx)(Dl.Item,{active:n===e.currentPage,onClick:()=>t(e=>n),children:n},n));return(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`div`,{className:`d-flex gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{size:`sm`,onClick:()=>t(e=>Math.max(e-1,0)),disabled:e.currentPage===1,children:`Previous Page`})}),(0,p.jsx)(Dl,{size:`sm`,children:a.map((e,t)=>(0,p.jsx)(`div`,{children:e},t))}),(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{size:`sm`,onClick:()=>{!i&&e.hasMore&&t(e=>e+1)},disabled:i||!e.hasMore,children:`Next Page`})})]}),n===void 0?null:(0,p.jsx)(`div`,{children:(0,p.jsxs)(G.Select,{onChange:e=>{n(t=>parseInt(e.target.value))},value:r,size:`sm`,children:[(0,p.jsx)(`option`,{value:10,children:`10`}),(0,p.jsx)(`option`,{value:25,children:`25`}),(0,p.jsx)(`option`,{value:50,children:`50`}),(0,p.jsx)(`option`,{value:100,children:`100`})]})})]})};function KO({show:e,onClose:t}){return(0,p.jsx)(Hl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Bl,{onClose:t,show:e,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Bl.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Bl.Body,{children:`Measurement results were saved successfully`})]})})}var qO=new Date().toISOString().split(`T`)[0],JO=({requirement:e,targets:t,refetchResults:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),{control:l,register:u,handleSubmit:m,reset:h,watch:g,formState:{errors:_,isValid:v}}=Id({defaultValues:{date:qO}}),{fields:y,append:b,remove:x}=Fd({control:l,name:`results`,rules:{required:!0}});(0,d.useEffect)(()=>{x(),t.forEach(e=>{b({id:e.id,label:e.logging_parameter.name,logging_parameter_id:e.logging_parameter.id,value:``})})},[t]),(0,d.useEffect)(()=>{c(v)},[g(),v]);async function S(t){await f.default.post(`create/monitor/requirement/result`,{requirement:e.id,date:t.date,values:t.results}),o(!0),i(!1),n(),h()}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{variant:`primary`,onClick:()=>i(!0),children:`Add manual result`}),(0,p.jsx)(K,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(G,{onSubmit:m(e=>S(e)),validated:s,children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Add manual result`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Date`}),(0,p.jsx)(G.Control,{type:`date`,placeholder:`Date`,required:!0,...u(`date`,{required:`This field is required`})},`date`),_.date&&(0,p.jsx)(G.Control.Feedback,{children:_.date.message})]}),y.map((e,t)=>(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:e.label}),(0,p.jsxs)(zs,{hasValidation:!0,children:[(0,p.jsx)(G.Control,{type:`number`,step:.01,placeholder:e.label,required:!0,...u(`results.${t}.value`,{required:`This field is required`})},e.id),_?.results?.[t]?.value&&(0,p.jsx)(G.Control.Feedback,{children:_.results[t].value.message})]})]},e.id))]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{h(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(KO,{show:a,onClose:()=>o(!1)})]})};function YO({show:e,onClose:t}){return(0,p.jsx)(Hl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Bl,{onClose:t,show:e,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Bl.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Bl.Body,{children:`Measurement results were saved successfully`})]})})}var XO=({requirement:e,result:t,refetchMonitorStepParameterValues:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)([]),{control:m,register:h,handleSubmit:g,reset:_,watch:v,formState:{errors:y,isValid:b}}=Id({defaultValues:{}});(0,d.useEffect)(()=>{async function n(){let[n,r,i]=await Promise.all([pe({result:t}),ge({requirement:e}),te({module:e.step.process_module.module})]);r.items=r.items.filter(e=>!n.items.map(e=>e.step_parameter.id).includes(e.id)),r.items=r.items.filter(e=>i.items.map(e=>e.parameter.id).includes(e.parameter.id)),u(r.items)}r&&n()},[r]),(0,d.useEffect)(()=>{c(b)},[v(),b]);async function x(e){await f.default.post(`create/monitor/requirement/result/step-parameter-value`,{result:t.id,step_parameter:e.module_step_parameter_id,value:e.value}),o(!0),i(!1),n(),_()}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{variant:`primary`,size:`sm`,onClick:()=>i(!0),children:`+`}),(0,p.jsx)(K,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(G,{onSubmit:g(e=>x(e)),validated:s,children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Add process parameter`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Date`}),(0,p.jsx)(G.Control,{type:`text`,value:t.date_created,readOnly:!0})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Module Step Parameter`}),(0,p.jsxs)(G.Select,{...h(`module_step_parameter_id`,{required:!0}),children:[(0,p.jsx)(`option`,{value:``,children:`— Select a parameter`}),l.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.parameter.name},e.id))]}),(0,p.jsx)(G.Text,{className:`text-muted`,children:`Only parameters are shown here which are active on the Equipment Module and in the monitor step. In case parameters are missing you should replace the process in the monitor with the same process from the process library to reload the parameters`})]}),(0,p.jsxs)(zs,{hasValidation:!0,children:[(0,p.jsx)(G.Control,{type:`number`,step:.01,required:!0,...h(`value`,{required:`This field is required`})}),y?.value&&(0,p.jsx)(G.Control.Feedback,{children:y.value.message})]})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{_(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(YO,{show:a,onClose:()=>o(!1)})]})};function ZO({show:e,onClose:t}){return(0,p.jsx)(Hl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Bl,{onClose:t,show:e,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Bl.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Bl.Body,{children:`Measurement results were saved successfully`})]})})}var QO=({monitorResultStepParameterValue:e,refetchMonitorStepParameterValues:t})=>{let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(!1),{control:c,register:l,handleSubmit:u,reset:m,watch:h,formState:{errors:g,isValid:_}}=Id({defaultValues:{value:e.value.toString()}});(0,d.useEffect)(()=>{s(_)},[h(),_]);async function v(n){await f.default.patch(`update/monitor/requirement/result/step-parameter-value/`+e.id,{value:n.value}),a(!0),r(!1),t(),m()}async function y(){await f.default.delete(`delete/monitor/requirement/result/step-parameter-value/`+e.id,{}),a(!0),r(!1),t(),m()}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{role:`button`,tabIndex:0,onClick:()=>r(!0),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},children:e.value}),(0,p.jsx)(K,{show:n,size:`lg`,onHide:()=>r(!1),children:(0,p.jsxs)(G,{onSubmit:u(e=>v(e)),validated:o,children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Add process parameter`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Date`}),(0,p.jsx)(G.Control,{type:`text`,value:e.date_created,readOnly:!0})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Module Step Parameter`}),(0,p.jsx)(G.Control,{type:`text`,value:e.step_parameter.parameter.name,readOnly:!0})]}),(0,p.jsxs)(zs,{hasValidation:!0,children:[(0,p.jsx)(G.Control,{type:`number`,step:.01,required:!0,...l(`value`,{required:`This field is required`})}),g?.value&&(0,p.jsx)(G.Control.Feedback,{children:g.value.message})]})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,type:`submit`,variant:`primary`,children:`Update value`}),(0,p.jsx)(U,{className:`float-end`,variant:`danger`,onClick:()=>y(),children:`Delete value`}),(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{m(),r(!1)},children:`Close`})]})]})}),(0,p.jsx)(ZO,{show:i,onClose:()=>a(!1)})]})};function $O({requirement:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(1),[a,o]=(0,d.useState)(15),[s,c,l,u]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`files`,e.step,11],queryFn:()=>he({step:e.step,pageSize:11,order:`date-created`,direction:`desc`})},{queryKey:[`requirement`,`target`,e],queryFn:()=>me({requirement:e})},{queryKey:[`requirement`,`results`,e,r,a],queryFn:()=>fe({requirement:e,pageSize:a,order:`date-created`,direction:`desc`,page:r}),placeholderData:m.keepPreviousData},{queryKey:[`requirement`,`monitor_step_parameters`,e,r,a],queryFn:()=>pe({requirement:e,pageSize:a,order:`date-created`,direction:`desc`,page:r}),placeholderData:m.keepPreviousData}]}),h=(0,d.useMemo)(()=>u.data?Array.from(new Map(u.data.items.map(e=>[e.step_parameter.id,e.step_parameter])).values()):[],[u.data]),g=s.data?.items??[],{getRootProps:_,getInputProps:v,isDragActive:y,isDragAccept:b,isDragReject:x}=Hb({onDrop:(0,d.useCallback)(t=>{t.forEach(t=>{let r=new FileReader;r.onload=async()=>{let i=r.result;try{await f.default.create().post(`update/monitor/requirement/upload-file/`+e.id,{content:i,filename:t.name,type:t.type})}catch(e){n(`Upload failed due to: `+e.response.data.detail)}await s.refetch(),await l.refetch()},r.readAsDataURL(t)})},[e.id,s,l])}),S=(0,d.useMemo)(()=>({...y?{borderColor:`#83afee`}:{},...b?{borderColor:`#00e676`}:{},...x?{borderColor:`#ff1744`}:{}}),[b,x,y]);return c.isLoading||c.isFetching?(0,p.jsx)(Cr,{variant:`info`,children:`Loading targets...`}):l.isLoading||l.isFetching?(0,p.jsx)(Cr,{variant:`info`,children:`Loading results...`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`h1`,{className:`display-5`,children:[`Requirement: `,e.title]}),(0,p.jsx)(`p`,{className:`lead`,children:e.definition}),(0,p.jsx)(jl,{className:`my-3`,children:(0,p.jsxs)(qr,{children:[(0,p.jsx)(`h2`,{children:`Charts`}),(0,p.jsx)(`div`,{className:`d-flex`,children:c.data?.items.map(e=>(0,p.jsx)(WO,{target:e,results:l.data.items},e.id))})]})}),(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{md:8,children:[e.method&&e.method!==`-`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{children:`Method`}),(0,p.jsx)(`p`,{children:e.method})]}),c.data?.items.length===0&&(0,p.jsx)(Cr,{variant:`danger`,children:`No targets found`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`h2`,{children:`Results`}),(0,p.jsx)(`div`,{children:(0,p.jsx)(JO,{requirement:e,targets:c.data.items,refetchResults:l.refetch})})]}),(0,p.jsxs)(Nl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:[(0,p.jsxs)(`thead`,{children:[(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`Date`}),c.data?.items.map(e=>(0,p.jsx)(`th`,{children:e.logging_parameter.name},e.id)),h.map(e=>(0,p.jsx)(`th`,{children:e.parameter.name},e.id)),(0,p.jsx)(`th`,{children:`+`})]}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2}),c.data?.items.map(e=>(0,p.jsxs)(`td`,{children:[e.min_value,e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`≤`}),!e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`<`}),e.target??`X`,e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`≥`}),!e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`>`}),e.max_value]},e.id)),h.map(e=>(0,p.jsx)(`th`,{className:`table-secondary`},e.id)),(0,p.jsx)(`th`,{})]})]}),(0,p.jsx)(`tbody`,{children:l.data?.items.map(t=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t.id})}),(0,p.jsx)(`td`,{children:zD(t.date_created,`DD-MM-YY HH:mm`)}),c.data?.items.map(e=>{let n=[];for(let r of t.values)r.logging_parameter.id===e.logging_parameter.id&&n.push((0,p.jsx)(`span`,{className:r.value_is_valid?`text-success`:`text-danger`,children:r.float_value},`${r.logging_parameter.id}-${r.float_value}`));return(0,p.jsx)(`td`,{children:n},e.id)}),h.map(e=>{let n=[];for(let r of u.data?.items??[])r.step_parameter.id!==e.id||r.result.id!==t.id||n.push((0,p.jsx)(QO,{monitorResultStepParameterValue:r,refetchMonitorStepParameterValues:u.refetch},r.id));return(0,p.jsx)(`td`,{className:`table-secondary`,children:n},e.id)}),(0,p.jsx)(`td`,{children:(0,p.jsx)(XO,{result:t,requirement:e,refetchMonitorStepParameterValues:u.refetch})})]},t.id))})]}),(0,p.jsx)(GO,{data:l.data,setPage:i,setPageSize:o,pageSize:a,isPlaceholderData:l.isPlaceholderData})]}),(0,p.jsxs)(qr,{md:4,children:[(0,p.jsx)(`h2`,{children:`Upload new results`}),(0,p.jsx)(`p`,{children:`Drop your results file here`}),(0,p.jsxs)(`div`,{..._({style:S,className:`dropzone`}),children:[(0,p.jsx)(`input`,{...v()}),y?(0,p.jsx)(`p`,{children:`Drop file(s) here ...`}):(0,p.jsx)(`p`,{children:`Drag and drop file(s) here, or click to select files`}),(0,p.jsx)(`p`,{children:t})]}),g.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{className:`mt-2`,children:`Uploaded files`}),(0,p.jsxs)(`p`,{children:[`Last `,11,` uploaded files`]}),(0,p.jsx)(`ul`,{className:`list-group`,children:g.map((e,t)=>(0,p.jsxs)(`li`,{className:`list-group-item`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`span`,{children:[t+1,` `,(0,p.jsx)(`a`,{href:e.url,children:e.name}),e.has_monitor_step_loggings&&(0,p.jsx)(wr,{className:`ms-1 bg-primary`,children:`Logging`})]}),(0,p.jsxs)(`span`,{children:[Math.round(e.size/1024),`kiB`]})]}),(0,p.jsx)(`small`,{className:`text-muted`,children:zD(e.date_created,`DD-MM-YY HH:mm`)})]},e.url))})]})]})]})]})}function ek(){let{id:e}=(0,g.useParams)(),[t,n]=(0,m.useQueries)({queries:[{queryKey:[`monitor`,e],queryFn:()=>R({id:parseInt(e)})},{queryKey:[`requirements`,e],queryFn:()=>ue({monitorId:parseInt(e)})}]});return t.isLoading?(0,p.jsx)(`div`,{children:`Loading...`}):(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[`SPC Test `,t.data?.name]}),n.data?.items.map((e,t)=>(0,p.jsx)(`div`,{className:`border border-1 p-3 my-3`,children:(0,p.jsx)($O,{requirement:e})},t))]})}function tk(){return(0,p.jsx)(Jr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}var nk=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&R({id:parseInt(n)}).then(t)},[n,e]);function r(){R({id:parseInt(n)}).then(t)}return{monitor:e,setMonitor:t,reloadMonitor:r}},rk=(0,d.createContext)({monitor:{},reloadMonitor:()=>{}});function ik({children:e}){let{monitor:t,reloadMonitor:n}=nk();return t===null?(0,p.jsx)(Ot,{children:(0,p.jsx)(Ct,{message:`Loading monitor...`})}):(0,p.jsx)(Ot,{children:(0,p.jsx)(rk.Provider,{value:{monitor:t,reloadMonitor:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}var ak=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||n!==e.id.toString())&&we({id:parseInt(n)}).then(t)},[n,e]);function r(){we({id:parseInt(n)}).then(t)}return{run:e,reloadRun:r}},ok=(0,d.createContext)({run:{},reloadRun:()=>{}});function sk({children:e}){let{run:t,reloadRun:n}=ak();return t===null?(0,p.jsx)(Ct,{message:`Loading run...`}):(0,p.jsx)(Ot,{children:(0,p.jsx)(ok.Provider,{value:{run:t,reloadRun:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading rest of run...`}),children:e})})})}function ck({text:e}){if(!e)return null;let t=e.split(/\r\n|\n|\r/);return(0,p.jsx)(p.Fragment,{children:t.map((e,n)=>(0,p.jsxs)(d.default.Fragment,{children:[e,n<t.length-1&&(0,p.jsx)(`br`,{})]},n))})}var lk=({children:e,format:t=`d-M-Y`})=>(0,p.jsx)(p.Fragment,{children:RD(e,t)}),uk=({run:e})=>{let[t,n]=(0,d.useState)(e.batch_card),[r,i]=(0,d.useState)(!1),{register:a,handleSubmit:o,formState:s,resetField:c}=Id({defaultValues:{content:t?.content}}),{isSubmitting:l,errors:u}=s,m=async t=>{await f.default.create().patch(`update/run/batch-card/`+e.id,{content:t.content}),i(!1);let r=await f.default.get(`view/run/`+e.id);n(r.data.batch_card)},h=async()=>{await f.default.create().delete(`delete/run/batch-card/`+e.id),i(!1),n(void 0),c(`content`)};return r?(0,p.jsxs)(G,{onSubmit:o(m),className:`mb-3`,children:[(0,p.jsxs)(zs,{hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:6,...a(`content`,{required:!0}),isInvalid:u.content!==void 0}),u.content&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:`This field is required`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-md-row gap-2 justify-content-between mt-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-2`,children:[(0,p.jsxs)(U,{variant:`primary`,type:`submit`,disabled:l,className:`text-nowrap`,children:[l&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Save batch card`]}),(0,p.jsx)(U,{variant:`secondary`,onClick:()=>i(!1),children:`Cancel`})]}),t&&(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`outline-danger`,className:`text-nowrap`,onClick:h,children:`Delete batch card`})})]})]}):t?t&&(0,p.jsxs)(W,{className:`rounded my-4 shadow-sm border-0`,children:[(0,p.jsxs)(W.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-start justify-content-between gap-3`,children:[(0,p.jsx)(W.Title,{className:`text-danger mb-0`,children:`Batch card`}),(0,p.jsx)(U,{variant:`outline-primary`,size:`sm`,className:`text-nowrap`,onClick:()=>i(!0),children:`Update batch card`})]}),(0,p.jsx)(W.Text,{className:`mt-3 mb-2 fs-5 text-body`,children:t&&(0,p.jsx)(ck,{text:t.content})})]}),(0,p.jsx)(W.Footer,{className:`bg-transparent border-0 pt-0 pb-3`,children:(0,p.jsxs)(`div`,{className:`text-muted small`,children:[`Created `,(0,p.jsx)(lk,{format:`DD-MM-YY`,children:t.date_created}),` by`,` `,t.user.first_name,` `,t.user.last_name,t.last_update&&(0,p.jsxs)(`span`,{children:[` (`,`Updated `,(0,p.jsx)(lk,{format:`DD-MM-YY H:m`,children:t.last_update}),`)`]})]})})]}):(0,p.jsx)(U,{variant:`outline-primary`,className:`mb-4`,onClick:()=>i(!0),children:`Create Batch Card`})};function dk(){let{run:e}=(0,d.useContext)(ok);return(0,p.jsxs)(p.Fragment,{children:[e.run_type===pt.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),e.run_type===pt.PRODUCTION&&(0,p.jsx)(`small`,{children:`Production run`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:(0,p.jsxs)(`h1`,{className:`display-4`,children:[e.name,` (`,e.project.name,`)`]})}),(0,p.jsx)(uk,{run:e})]})}function fk(e){let{run:t,reloadRun:n}=(0,d.useContext)(ok),{environment:r}=(0,g.useParams)(),i=window.location.pathname,a=[{title:`Information`,link:`/${r}/operator/run/details/${t.id}/information`},{title:`Steps`,link:`/${r}/operator/run/details/${t.id}/steps`},{title:`Layout`,link:`/${r}/operator/run/details/${t.id}/layout`}];return(0,p.jsx)($c,{variant:`tabs`,className:e.className,defaultActiveKey:`/home`,activeKey:i,children:a.map(e=>(0,p.jsx)($c.Item,{children:(0,p.jsx)(g.Link,{to:e.link,className:`nav-link `+(e.link===i?`active`:``),children:e.title})},e.link))})}function pk(){return(0,p.jsx)(sk,{children:(0,p.jsxs)(Jr,{fluid:!0,children:[(0,p.jsx)(dk,{}),(0,p.jsx)(fk,{className:`mb-4`}),(0,p.jsx)(g.Outlet,{})]})})}var mk=(0,d.createContext)({showOnlyEmphasizedParameters:!1,setShowOnlyEmphasizedParameters:()=>{}}),hk=({parameter:e,value:t,refetchFn:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(t.value),s=async r=>{let a={value:r};try{t.id===void 0?(a.parameter=e.id,await f.default.post(`/create/run/step/parameter/value`,a)):await f.default.patch(`/update/run/step/parameter/value/${t.id}`,a)}catch(e){console.error(`Failed to update parameter value with error: `,e)}n(),i(!1)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{role:`button`,tabIndex:0,style:{cursor:`pointer`,borderBottom:`1px dashed #999`,display:r?`none`:``},className:t.value==``||t.value==null?`text-muted`:``,onClick:()=>{i(!r)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i(!r))},children:t.value!==``&&t.value!==null?t.value:`edit`}),(0,p.jsxs)(`div`,{style:{display:r?``:`none`},className:`btn-group`,children:[(0,p.jsx)(`input`,{type:`text`,"aria-label":`Parameter value`,value:a??``,className:`form-control`,onChange:e=>o(e.target.value)}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Save`,onClick:()=>{s(a)},className:`btn btn-success btn-sm`,children:(0,p.jsx)(`i`,{className:`fa fa-check`})}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Cancel`,onClick:()=>{i(!1)},className:`btn btn-danger btn-sm`,children:(0,p.jsx)(`i`,{className:`fa fa-times`})})]})]})},gk=({runStep:e,showOnlyEmphasizedParameters:t,editableParameters:n=!0,refetchFn:r})=>{let{data:i,isLoading:a}=(0,m.useQuery)({queryKey:[`runStepParameters`,e.id],queryFn:()=>Le({runStep:e})}),o=(0,m.useQueryClient)(),s=()=>{o.refetchQueries({queryKey:[`runStepParameters`,e.id]}),r&&r()},c=i?.items??[],l=t?c.filter(e=>e.emphasize):c;return a?(0,p.jsxs)(Nl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Pos`}),(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:Array.from({length:2}).map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:3})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:7})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:4})})})]},t))})]}):c.length===0?(0,p.jsx)(Cr,{variant:`info`,children:`No parameters found`}):(0,p.jsxs)(Nl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Pos`}),(0,p.jsx)(`th`,{children:`Parameter`}),c[0].values.map((e,t)=>(0,p.jsx)(`th`,{children:`Value`},t)),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:l.length>0?l.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:e.sequence})}),(0,p.jsx)(`td`,{children:e.parameter.name}),e.values.map((t,r)=>(0,p.jsx)(`td`,{children:n?(0,p.jsx)(hk,{parameter:e,refetchFn:s,value:t}):(0,p.jsx)(`span`,{children:t.value})},t.id??`${e.id}-${r}`)),(0,p.jsx)(`td`,{children:e.unit?.abbr??``})]},e.id)):(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:3+c[0].values.length,children:`No emphasized parameters found.`})})})]})},_k=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};function vk({runStep:e,refetchFn:t}){let[n,r]=(0,d.useState)([]),[i,a]=(0,d.useState)(``),{data:o,isLoading:s}=(0,m.useQuery)({queryKey:[`files`,e.id],queryFn:()=>Ie({step:e})}),c=(0,m.useQueryClient)(),l=()=>{c.refetchQueries({queryKey:[`files`,e.id]}),t&&t()},u=o?.items??[],h=async e=>{if(confirm(`Are you sure you want to delete ${e.name}? You can not undo this action`))try{await f.default.delete(`delete/run/step/file/${e.id}`),l()}catch(e){console.error(e)}},{getRootProps:g,getInputProps:_,isDragActive:v,isDragAccept:y,isDragReject:b}=Hb({onDrop:e=>{r(t=>[...t,...e]),a(`${e.length} file(s) selected`)}}),x=(0,d.useMemo)(()=>({...v?{borderColor:`#83afee`}:{},...y?{borderColor:`#00e676`}:{},...b?{borderColor:`#ff1744`}:{}}),[y,b,v]),S=()=>{n.forEach(t=>{let n=new FileReader;n.onload=async()=>{let i=n.result;try{await f.default.create().post(`update/run/step/upload-file/`+e.id,{content:i,filename:t.name,type:t.type})}catch(e){a(`Upload failed due to: `+e.response.data.detail)}try{l(),a(`Files uploaded succesfully`),r([])}catch(e){a(`Error refetching file data`),console.error(e)}},n.readAsDataURL(t)})};return s?(0,p.jsx)(`div`,{children:`Loading...`}):(0,p.jsxs)(`div`,{children:[u&&u.length>0&&(0,p.jsxs)(Nl,{hover:!0,striped:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`No`}),(0,p.jsx)(`th`,{children:`File`}),(0,p.jsx)(`th`,{children:`Size`}),(0,p.jsx)(`th`,{children:`Date`})]})}),(0,p.jsx)(`tbody`,{children:u.map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t+1})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(`a`,{href:`${e.url}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(wr,{className:`ms-1 bg-primary`,children:`Logging`})]}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":`Delete file`,className:`fa fa-trash-o remove-file handle`,style:{cursor:`pointer`},onClick:()=>h(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),h(e))}}),` `,_k(e.size)]}),(0,p.jsx)(`td`,{children:zD(e.date_created,`DD-MM-YY HH:mm`)})]},e.url))})]}),(0,p.jsxs)(`div`,{...g({style:x,className:`dropzone bg-secondary-subtle border rounded dz-clickable`}),children:[(0,p.jsx)(`input`,{..._()}),v?(0,p.jsx)(`p`,{children:`Drop files here...`}):(0,p.jsx)(`p`,{children:`Drag and drop files here or click to select`})]}),n.length>0&&(0,p.jsx)(nc,{className:`mt-3`,children:n.map(e=>(0,p.jsx)(nc.Item,{children:e.name},e.name))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(U,{className:`mt-3`,onClick:S,disabled:n.length===0,children:`Upload Selected Files`}),(0,p.jsx)(`p`,{className:`mt-2 text-muted`,children:i})]})]})}var yk=({runStepPart:e,setRunStepPart:t,editable:n=!0})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(e.comment),{register:s,handleSubmit:c,formState:l,resetField:u}=Id({defaultValues:{comment:a}}),{isSubmitting:m,errors:h}=l;return n?r?(0,p.jsxs)(G,{onSubmit:c(async n=>{await f.default.create().patch(`update/run/step/part/`+e.id,{comment:n.comment}).then(n=>{t({...e,comment:n.data.comment}),o(n.data.comment),i(!1)})}),children:[(0,p.jsx)(G.Group,{className:`mb-3`,controlId:`formBasicEmail`,children:(0,p.jsx)(G.Control,{as:`textarea`,...s(`comment`)})}),(0,p.jsx)(U,{size:`sm`,type:`submit`,disabled:m,children:`Save`}),(0,p.jsx)(U,{variant:`warning`,size:`sm`,className:`ms-2`,onClick:()=>i(!1),children:`Cancel`})]}):a===null?(0,p.jsx)(U,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Add comment`}):(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`div`,{className:`text-break`,children:a}),(0,p.jsx)(U,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Edit`})]}):(0,p.jsx)(`div`,{children:a})},bk=({runStepPart:e,setRunStepPartAction:t,createRunStepPart:n})=>(0,p.jsxs)(fs,{align:`end`,children:[(0,p.jsx)(fs.Toggle,{size:`sm`,variant:`outline-secondary`,children:`Actions`}),(0,p.jsxs)(fs.Menu,{children:[e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(fs.Item,{onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n)),(0,p.jsx)(fs.Item,{onClick:()=>n(),children:`Init`})]})]}),xk={[He.START]:`btn-start`,[He.FINISH]:`btn-success`,[He.FAIL]:`btn-failed`,[He.REWORK]:`btn-rework`,[He.SET_REPAIR]:`btn-repair`,[He.CLEAR_REPAIR]:`btn-secondary`,[He.SET_TESTING]:`btn-test`,[He.CLEAR_TESTING]:`btn-secondary`},Sk=({runStepPart:e,setRunStepPartAction:t})=>e.available_actions.length===0?null:(0,p.jsx)(p.Fragment,{children:e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm me-2 ${xk[n]}`,onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n))}),Ck=(e,t)=>{let{status:n,processed:r,failed:i,started:a,available_actions:o}=t.updated_run_step_part_state;return{...e,status:n,processed:r,failed:i,started:a,available_actions:o}},wk=(e,t)=>e&&(Array.isArray(e.pages)?{...e,pages:e.pages.map(e=>!e||!Array.isArray(e.items)?e:{...e,items:t(e.items)})}:Array.isArray(e.items)?{...e,items:t(e.items)}:e),Tk=e=>e?Array.isArray(e.pages)?e.pages.flatMap(e=>Array.isArray(e?.items)?e.items:[]):Array.isArray(e.items)?e.items:[]:[],Ek=(e,t)=>{let{runStepPart:n,latestAction:r}=t;return wk(e,e=>e.map(e=>e.id===n.id?Ck(e,r):e))},Dk=(e,t)=>wk(e,e=>e.map(e=>t.get(e.id)??e)),Ok=e=>Array.isArray(e)?e:Array.isArray(e.items)?e.items:[],kk=(e,t)=>{let n=Ok(t);if(n.length===0)return e;let r=new Map(n.map(e=>[e.updated_run_step_part_state.run_step_part_id,e])),i=new Map(n.map(e=>[e.updated_run_step_part_state.run_part_id,e]));return wk(e,e=>e.map(e=>{let t=r.get(e.id)??i.get(e.part_id);return t?Ck(e,t):e}))},Ak=(e,t,n,r)=>{if(e.id===n.id||e.part_id!==n.part_id)return!1;let i=r.get(e.step_id);return i?i.run_id===t.run_id&&i.part_level===0&&i.sequence>t.sequence:!1},jk=(e,t,n,r={},i=new Map)=>{if(!e)return e;let a=e=>e.id===n.id?n:r.updateSubsequent&&Ak(e,t,n,i)?{...e,tray_id:n.tray_id,tray_row:n.tray_row,tray_column:n.tray_column}:e;if(Array.isArray(e.pages)){let t=e.pages;if(t.some(e=>Array.isArray(e?.items)&&e.items.some(e=>e.id===n.id)))return wk(e,e=>e.map(a));if(t.length>0){let r=t.length-1;return{...e,pages:t.map((e,t)=>{if(!e||!Array.isArray(e.items))return e;let i=e.items.map(a);return{...e,items:t===r?[...i,n]:i}})}}return e}if(Array.isArray(e.items)){let t=e.items,r=t.some(e=>e.id===n.id);return{...e,items:r?t.map(a):[...t.map(a),n]}}return e},Mk=e=>{let t=new Map;return e.getQueriesData({queryKey:[`runSteps`]}).forEach(([,e])=>{Tk(e).forEach(e=>{t.set(e.id,e)})}),t},Nk=async(e,t)=>{if(t.length===0)return;let n=Array.from(new Set(t.map(e=>e.part_id))).map(e=>({id:e}));if(n.length===0)return;let r=await Re({runPart:n}),i=new Map(r.items.map(e=>[e.id,e]));i.size!==0&&e.setQueriesData({queryKey:[`runStepParts`]},e=>Dk(e,i))},Pk=async(e,t)=>{let n=Array.from(new Set(t.map(e=>e.step_id)));if(n.length===0)return;let r=await Promise.all(n.map(e=>Te({id:e}))),i=new Map(r.map(e=>[e.id,e]));e.setQueriesData({queryKey:[`runSteps`]},e=>wk(e,e=>e.map(e=>i.get(e.id)??e)))},Fk=(e,t)=>{e.setQueriesData({queryKey:[`runStepParts`]},e=>Ek(e,t)),Nk(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step part cache from run part.`,e)}),Pk(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step cache from run step part.`,e)})},Ik=(e,t)=>{Fk(e,t)},Lk=(e,t,n)=>{if(`latestActions`in n){e.setQueriesData({predicate:e=>Array.isArray(e.queryKey)&&e.queryKey[0]===`runStepParts`&&(e.queryKey.length===1||e.queryKey[1]===t.id)},e=>kk(e,n.latestActions)),Nk(e,Ok(n.latestActions).map(e=>({id:e.updated_run_step_part_state.run_step_part_id,part_id:e.updated_run_step_part_state.run_part_id}))).catch(e=>{console.error(`Failed to refresh run step part cache from run parts.`,e)}),Pk(e,[{step_id:t.id}]).catch(e=>{console.error(`Failed to refresh run step cache from run step.`,e)});return}Fk(e,n)},Rk=(e,t,n,r={})=>{let i=r.updateSubsequent?Mk(e):new Map;e.setQueriesData({queryKey:[`runStepParts`]},e=>jk(e,t,n,r,i))};function zk(e){return!0}var Bk=e=>!!e.closest(`button, a, input, textarea, select, option, label`),Vk=({runPart:e,partIsSelected:t,setPartAsSelected:n,runStepParts:r,canInit:i,runStep:a,dropdown:o})=>{let[s,c]=(0,d.useState)(),l=(0,m.useQueryClient)();(0,d.useEffect)(()=>{let t=r.find(t=>t.part_id===e.id);c(t)},[r,e.id]);let u=t=>{if(!n)return;let r=t.target;if(Bk(r))return;let i=s?s.part_id:e.id;i!==void 0&&n(i)},h=()=>{i||f.default.post(`/create/run/step/part`,{run_part_id:e.id,run_step_id:a.id}).then(e=>{let t={...e.data};c(t),Rk(l,a,t)})},g=async({runStepPart:e,runStepPartAction:t})=>{let n=await Be({runStepPart:e,runStepPartAction:t});c(e=>{if(!e)return e;let{status:t,processed:r,failed:i,started:a,available_actions:o}=n.updated_run_step_part_state;return{...e,status:t,processed:r,failed:i,started:a,available_actions:o}}),Lk(l,a,{runStepPart:e,latestAction:n})};return s?(0,p.jsxs)(`tr`,{onClick:u,style:n?{cursor:`pointer`}:void 0,children:[(0,p.jsx)(`td`,{children:n&&zk(a)&&(0,p.jsx)(`input`,{type:`checkbox`,id:`part-select-${s.part_id}`,name:`tomato`,"aria-label":`Select part`,className:`form-check-input`,checked:t,onChange:()=>n?.(s.part_id)})}),(0,p.jsx)(`td`,{children:e.scanner_label}),(0,p.jsx)(`td`,{children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-1`,children:[(0,p.jsx)(`span`,{className:`badge ${s.status.class??``}`.trim(),children:s.status.key}),(0,p.jsx)(`small`,{className:`text-muted`,children:s.status.text})]})}),zk(a)&&(0,p.jsx)(`td`,{children:o?(0,p.jsx)(bk,{runStepPart:s,setRunStepPartAction:g,createRunStepPart:h}):(0,p.jsx)(Sk,{runStepPart:s,setRunStepPartAction:g})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(yk,{runStepPart:s,setRunStepPart:c})})]}):null},Hk=(0,d.createContext)(null),Uk=()=>{let e=(0,d.useContext)(Hk);if(e===null)throw Error(`useScannerContext must be used within a ScannerProvider`);return e},Wk=function(e){return e[e.WILD_CARD=0]=`WILD_CARD`,e[e.PERFORM_RUN_ACTION=1]=`PERFORM_RUN_ACTION`,e[e.RESET_FORM=2]=`RESET_FORM`,e}({});function Gk(e){return e.startsWith(`_qr`)?1:e.toUpperCase().includes(`RESET-FORM`)?2:0}function Kk({parts:e}){let[t,n]=(0,d.useState)(new Map),r=(0,d.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(e,!(t.get(e)??!1)),n})},[]),{lastlyReadedKeys:i,addCallbackFn:a,removeCallbackFn:o}=Uk(),s=(0,d.useId)(),c=(0,d.useRef)(new Set),l=(0,d.useCallback)(t=>{if(Gk(t)!=Wk.WILD_CARD)return;let n=t.replace(/_/g,`-`).toUpperCase();if(!n)return;if(e.length==0){if(c.current.size>=15){let e=c.current.values().next().value;e!==void 0&&c.current.delete(e)}c.current.add(n);return}let i=e.find(e=>n.includes(e.scanner_label.toUpperCase()));i&&r(i.id)},[e,r]);return(0,d.useEffect)(()=>(o(Wk.WILD_CARD,s),l(i),a(Wk.WILD_CARD,s,l),()=>{o(Wk.WILD_CARD,s)}),[e]),(0,d.useEffect)(()=>{let r=new Map;for(let n of e){let e=n.id;r.set(e,t.get(e)??!1)}r.size!==t.size&&n(()=>r),e.length>0&&(c.current.forEach(e=>{l(e)}),c.current.clear())},[e,t,r]),{selectedParts:t,setPartAsSelected:r,setPartsSelection:(0,d.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return e.forEach(e=>{r.set(e,t)}),r})},[]),selectAllParts:(0,d.useCallback)(()=>{n(e=>new Map([...e.keys()].map(e=>[e,!0])))},[]),selectNoneParts:(0,d.useCallback)(()=>{n(e=>new Map([...e.keys()].map(e=>[e,!1])))},[]),hasSelectedParts:Array.from(t.values()).some(e=>e)}}var qk=null;function Jk(e){if(!qk){console.warn(`notification() called before NotificationProvider is mounted`);return}qk(e)}function Yk({children:e}){let[t,n]=(0,d.useState)([]),r=(0,d.useRef)(0),i=(0,d.useCallback)(e=>{let t=++r.current;n(n=>[...n,{...e,id:t}])},[]);(0,d.useEffect)(()=>(qk=i,()=>{qk=null}),[i]);let a=(0,d.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,p.jsxs)(p.Fragment,{children:[e,(0,p.jsx)(Hl,{containerPosition:`fixed`,position:`top-end`,children:t.map(({id:e,notificationHeader:t,notificationBody:n,notificationType:r})=>(0,p.jsxs)(Bl,{show:!0,delay:3e3+(r==`danger`?150:0),autohide:!0,bg:r,onClose:()=>a(e),className:`m-5`,children:[(0,p.jsx)(Bl.Header,{children:(0,p.jsx)(`span`,{className:`me-auto`,children:t})}),(0,p.jsx)(Bl.Body,{children:n})]},e))})]})}var Xk=e=>`step_id`in e&&`part_id`in e;function Zk({runStep:e,parts:t,selectedParts:n,getRunPart:r,getRunStepPart:i,actionsFromScanner:a=!0}){let o=(0,m.useQueryClient)(),{addCallbackFn:s,removeCallbackFn:c}=Uk(),l=(0,d.useId)(),u=(0,d.useCallback)(()=>{if(t.length===0)return[];if(Xk(t[0]))return t.filter(e=>{let t=r?r(e):e.part_id;return n.get(t)});let e=[];for(let r of t){if(!n.get(r.id))continue;let t=i?i(r):void 0;t&&e.push(t)}return e},[t,n,r,i]),f=(0,d.useCallback)(async t=>{let n=u();if(n.length===0)return;let r=n.filter(e=>e.available_actions.some(({id:e})=>e===t));if(r.length===0)return;if(r.length===1){let e=r[0],n=await Be({runStepPart:e,runStepPartAction:t});Ik(o,{runStepPart:e,latestAction:n});return}let i=await Ve({runStepPartActions:r.map(e=>({runStepPart:e,runStepPartAction:t}))});Lk(o,e,{latestActions:i})},[u,o,e]),p=(0,d.useCallback)(e=>{if(!e||!Qk(e))return;let t=We(e.split(`/`)[1]);if(!t){Jk({notificationHeader:`Part scanner`,notificationBody:`Non valid action found in the scanned text`,notificationType:`danger`});return}Jk({notificationHeader:`Part scanner`,notificationBody:`Performing action ${Ue(t)} on selected parts`,notificationType:`success`}),f(t)},[f]);return(0,d.useEffect)(()=>{if(a)return c(Wk.PERFORM_RUN_ACTION,l),s(Wk.PERFORM_RUN_ACTION,l,p),()=>{c(Wk.PERFORM_RUN_ACTION,l)}},[a,p,s,c,l]),{performActionToSelectedParts:f,getAvailableActionsForSelection:(0,d.useCallback)(()=>{let e=new Map;for(let t of u())for(let{id:n,name:r}of t.available_actions)e.has(n)||e.set(n,r);return Array.from(e.entries()).map(([e,t])=>({id:e,name:t}))},[u])}}function Qk(e){return RegExp(`^_qr/.+`).test(e)}var $k=({onSelectAll:e,onSelectNone:t,hasSelectedParts:n,actionsDropdown:r,traySelections:i,onToggleTray:a})=>{let o=(i??[]).length>0;return(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`div`,{className:`btn-group btn-group-sm`,role:`group`,"aria-label":`Part selection controls`,children:[(0,p.jsx)(`button`,{type:`button`,className:`part-check-all btn btn-outline-secondary`,onClick:e,children:`All`}),(0,p.jsx)(`button`,{type:`button`,className:`part-check-none btn btn-outline-secondary`,onClick:t,children:`None`})]}),o&&(0,p.jsx)(`div`,{className:`btn-group btn-group-sm`,role:`group`,"aria-label":`Tray selection controls`,children:i?.map(e=>{let t=e.allSelected;return(0,p.jsx)(`button`,{type:`button`,className:`btn ${t?`btn-secondary`:`btn-outline-secondary`}`,"aria-pressed":t,onClick:()=>a?.(e.partIds,!t),children:e.label},e.id)})}),n&&r]})},eA=({availableActions:e,onActionSelected:t})=>{let[n,r]=(0,d.useState)(null);if(e.length===0)return null;let i=async e=>{if(n===null){r(e);try{await t(e)}finally{r(null)}}};return(0,p.jsx)(p.Fragment,{children:e.map(({id:e,name:t})=>(0,p.jsxs)(`button`,{type:`button`,className:`btn btn-sm ${xk[e]}`,onClick:()=>void i(e),disabled:n!==null,children:[n===e&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),t]},e))})},tA=({run:e,runStep:t})=>{let n=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>ke({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Re({step:t})}]}),[r,i]=n,a=n.some(e=>e.isLoading),o=n.some(e=>e.isError),s=(0,d.useMemo)(()=>r.data?.items??[],[r.data]),c=(0,d.useMemo)(()=>i.data?.items??[],[i.data]),l=(0,d.useMemo)(()=>s.filter(e=>e.part_level===t.part_level),[s,t.part_level]),[u,f]=(0,d.useState)(!1),{selectedParts:h,selectAllParts:g}=Kk({parts:l});iA({runStepParts:c,runParts:l});let _=(0,d.useMemo)(()=>l.filter(e=>h.get(e.id)&&(u||!nA(c,e))),[l,c,h,u]);return o?(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run parts.`}):(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(Nl,{size:`sm`,striped:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2,children:`Part`}),(0,p.jsx)(`th`,{children:`Status`}),(0,p.jsx)(`th`,{children:`Actions`}),(0,p.jsx)(`th`,{children:`Comment`})]})}),(0,p.jsxs)(`tbody`,{children:[a&&Array.from({length:1}).map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`div`,animation:`glow`,children:(0,p.jsx)(q,{xs:7})})})]},`placeholder-${t}`)),!a&&_.map((e,n)=>(0,p.jsx)(Vk,{runStep:t,runPart:e,runStepParts:c,canInit:!1,partIsSelected:h.get(e.id)??!1,dropdown:!1},`${e.parsed_label}${n}`))]})]}),(0,p.jsx)(rA,{runStepParts:c,selectedPartsLength:_.length,totalParts:l.length,onSelectAll:g,toggleShowCompletedParts:()=>{f(!u)}})]})},nA=(e,t)=>{let n=e.find(e=>e.part_id==t.id);return n!=null&&n.processed},rA=({runStepParts:e,selectedPartsLength:t,totalParts:n,onSelectAll:r,toggleShowCompletedParts:i})=>{let a=(0,d.useMemo)(()=>{let t=0;return e.forEach(e=>e.processed?t++:null),t},[e]);return(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-sm-row flex-wrap gap-2 mt-2`,children:[(0,p.jsxs)(`span`,{className:`badge rounded-pill bg-warning-subtle text-warning-emphasis border border-warning-subtle px-3 py-2 fw-semibold`,role:`button`,tabIndex:0,title:`Show all the parts`,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},style:{cursor:`pointer`},children:[`This step has `,(0,d.useMemo)(()=>n-t,[n,t]),` more parts`]}),(0,p.jsxs)(`span`,{className:`badge rounded-pill bg-info-subtle text-info-emphasis border border-info-subtle px-3 py-2 fw-semibold`,children:[`This step has `,t,` scanned parts`]}),(0,p.jsxs)(`span`,{role:`button`,tabIndex:0,title:`Show all the parts`,style:{cursor:`pointer`},onClick:i,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},className:`badge rounded-pill bg-success-subtle text-success-emphasis border border-success-subtle px-3 py-2 fw-semibold`,children:[`This step has `,a,` finished parts`]})]})};function iA({runStepParts:e,runParts:t}){let{addCallbackFn:n,removeCallbackFn:r}=Uk(),i=(0,d.useId)(),a=(0,d.useCallback)(n=>{let r=n.replace(/_/g,`-`).toUpperCase();if(!r)return;let i=t.find(e=>r.includes(e.scanner_label.toUpperCase()));if(i){if(nA(e,i)){Jk({notificationHeader:`Run parts table`,notificationBody:`Part ${i.parsed_label??i.scanner_label} is already completed`,notificationType:`danger`});return}Jk({notificationHeader:`Part scanner`,notificationBody:`Found part: ${i.scanner_label}`,notificationType:`success`})}},[t,e]);(0,d.useEffect)(()=>(r(Wk.WILD_CARD,i),n(Wk.WILD_CARD,i,a),()=>{r(Wk.WILD_CARD,i)}),[t,e])}var aA=!1,oA=({run:e,runStep:t})=>{let n=(0,m.useQueryClient)(),r=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>ke({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Re({step:t})}]}),[i,a]=r,o=r.some(e=>e.isLoading),s=r.some(e=>e.isError),c=(0,d.useMemo)(()=>i.data?.items??[],[i.data]),l=(0,d.useMemo)(()=>a.data?.items??[],[a.data]),{selectedParts:u,setPartAsSelected:f,setPartsSelection:h,selectAllParts:g,selectNoneParts:_,hasSelectedParts:v}=Kk({parts:c});iA({runStepParts:l,runParts:c}),(0,d.useEffect)(()=>{let e=[];for(let[t,n]of u.entries())n&&e.push(t);n.setQueryData([`runPartSelection`,t.id],e)},[n,t.id,u]);let{performActionToSelectedParts:y,getAvailableActionsForSelection:b}=Zk({runStep:t,parts:c,selectedParts:u,getRunPart:void 0,getRunStepPart:e=>l.find(t=>t.part_id===e.id)}),x=(0,d.useMemo)(()=>b(),[b]),S=(0,d.useMemo)(()=>{let t=new Map,n=new Map(c.map(e=>[e.id,e]));if(l.forEach(e=>{let r=n.get(e.part_id)?.tray;if(!r)return;let i=t.get(r.id)??{id:r.id,label:r.name??r.label??`Tray ${r.id}`,partIds:[]};i.partIds.push(e.part_id),t.set(r.id,i)}),t.size===0)return[];let r=[...e.run_trays??[]].sort((e,t)=>e.sequence-t.sequence);return(r.length>0?(()=>{let e=[];for(let n of r){let r=t.get(n.id);r&&e.push({...r,label:n.name??n.label??r.label})}return e})():Array.from(t.values()).sort((e,t)=>e.label.localeCompare(t.label))).map(e=>({...e,allSelected:e.partIds.every(e=>u.get(e))}))},[e.run_trays,u,c,l]),C=(0,d.useMemo)(()=>(0,p.jsx)(eA,{availableActions:x,onActionSelected:y}),[x,y]);if(o)return(0,p.jsx)(Ct,{message:`Loading run parts`});if(s)return(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run parts.`});if(c.length===0)return(0,p.jsx)(Cr,{variant:`warning`,children:`No parts found for this run step.`});if(l.length===0)return(0,p.jsx)(Cr,{variant:`warning`,children:`No step parts found for this run step.`});let w=zk(t),T=()=>(0,p.jsx)(p.Fragment,{children:w&&(0,p.jsx)($k,{onSelectAll:g,onSelectNone:_,hasSelectedParts:v,traySelections:S,onToggleTray:(e,t)=>h(e,t),actionsDropdown:C})});return(0,p.jsxs)(d.Fragment,{children:[T(),c&&c.length>0&&(0,p.jsxs)(p.Fragment,{children:[!w&&(0,p.jsxs)(Cr,{variant:`warning`,className:`py-2 mb-2`,children:[(0,p.jsx)(`strong`,{children:`Step locked.`}),` Finish the previous step before processing these parts.`]}),(0,p.jsxs)(Nl,{size:`sm`,striped:!0,hover:!0,className:w?void 0:`text-muted`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2,children:`Part`}),(0,p.jsx)(`th`,{children:`Status`}),w&&(0,p.jsx)(`th`,{children:`Actions`}),(0,p.jsx)(`th`,{children:`Comment`})]})}),(0,p.jsx)(`tbody`,{children:c.map((n,r)=>{let i=u.get(n.id)??!1;return(0,p.jsx)(Vk,{runStep:t,runPart:n,runStepParts:l,canInit:e.run_type===pt.PRODUCTION,partIsSelected:i,setPartAsSelected:w?f:void 0,dropdown:aA},`key-${r}-${n.id}`)})})]})]}),l.length>=25&&T()]})};function sA({run:e,step:t,refetchFn:n=()=>null}){let{run:r}=(0,d.useContext)(ok),{showOnlyEmphasizedParameters:i}=(0,d.useContext)(mk),a=e??r;return a?(0,p.jsx)(W,{className:`p-4 my-3`,children:(0,p.jsx)(W.Body,{children:(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Experimental split`}),(0,p.jsx)(oA,{run:a,runStep:t}),t.has_remark&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{children:`Remark`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.remark}})]})]}),(0,p.jsxs)(qr,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(gk,{runStep:t,showOnlyEmphasizedParameters:i,refetchFn:()=>{n([JSON.stringify(t),`parameters`])}}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(vk,{runStep:t,refetchFn:()=>{n([`runSteps`])}})]})]})})}):null}var cA=(e,t)=>e==null&&t==null?0:e==null?1:t==null?-1:e-t,lA=(e,t)=>cA(e.left,t.left)||e.id-t.id,uA=e=>e.parent?.id??e.root_id??e.id,dA=(e,t)=>{let n=e[0],r=t[0];return cA(n?.parent?.left,r?.parent?.left)||cA(n?.parent?.id,r?.parent?.id)||lA(n,r)},fA=({parts:e,slotCount:t,getSlotIndex:n})=>{let r=Array.from({length:t},()=>[]),i=new Map;e.forEach(e=>{let t=uA(e),n=i.get(t)??[];n.push(e),i.set(t,n)});for(let e of i.values()){let i=[...e].sort(lA),a=n(i[0]),o=a!==null&&a>=0&&a<t?a:r.reduce((e,t,n)=>e===-1||t.length<r[e].length?n:e,-1);o!==-1&&r[o].push(i)}return r.map(e=>e.sort(dA).flat())},pA=({parts:e,getOverrideSlotIndex:t,getDirectSlotIndex:n,slotCount:r})=>{let i=new Map,a=[...new Set(e.map(e=>e.part_level))].sort((e,t)=>e-t),o=[...e].sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:cA(e.left,t.left)||e.id-t.id);return a.forEach(e=>{let a=o.filter(t=>t.part_level===e),s=new Set,c=[];a.forEach(e=>{let a=t?.(e);if(a!=null&&a>=0&&(r===void 0||a<r)){i.set(e.id,a),s.add(a);return}let o=e.parent?.id?i.get(e.parent.id):void 0;if(o!==void 0){i.set(e.id,o),s.add(o);return}let l=n(e);if(l!==null&&l>=0&&(r===void 0||l<r)&&!s.has(l)){i.set(e.id,l),s.add(l);return}c.push(e)}),c.forEach(e=>{let t=0;for(;s.has(t);)t+=1;r!==void 0&&t>=r||(i.set(e.id,t),s.add(t))})}),i},mA=({runPart:e,stepPart:t,statusClass:n,withTrayCell:r=!1,allowCreate:i=!1,isSelected:a=!1,runStep:o})=>{let s=(0,m.useQueryClient)(),c=t?.id!==void 0,[l,u]=(0,d.useState)(!1),h=(0,d.useRef)(null),g=(0,d.useRef)(null),_=(0,d.useRef)(null),v=()=>{_.current&&(clearTimeout(_.current),_.current=null),!l&&(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{u(!0)},500))},y=()=>{g.current&&(clearTimeout(g.current),g.current=null),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>u(!1),150)};(0,d.useEffect)(()=>()=>{g.current&&clearTimeout(g.current),_.current&&clearTimeout(_.current)},[]);let b=()=>{!e||!o||f.default.post(`/create/run/step/part`,{run_part_id:e.id,run_step_id:o.id}).then(e=>{let t={...e.data};Rk(s,o,t)})},x=async({runStepPart:e,runStepPartAction:t})=>{let n=await Be({runStepPart:e,runStepPartAction:t});o&&Lk(s,o,{runStepPart:e,latestAction:n})},S=!c||!e?null:i&&!c?(0,p.jsxs)(U,{size:`sm`,variant:`outline-secondary`,className:`tray-grid__badge tray-grid__badge--init`,onClick:b,children:[`Init `,e.scanner_label]}):(0,p.jsx)(`span`,{className:`tray-grid__badge ${n??`step-part-inactive`}${a?` step-part-selected`:``}`,children:e.scanner_label});return r?(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`div`,{ref:h,role:`button`,tabIndex:0,onMouseEnter:v,onMouseLeave:y,onClick:()=>l?y():v(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l?y():v())},className:`tray-grid__cell${e?``:` tray-grid__cell--empty`}`,children:S}),t&&(0,p.jsx)(hl,{target:h.current,show:l,placement:`top`,children:({placement:e,arrowProps:n,show:r,popper:i,hasDoneInitialMeasure:a,...o})=>(0,p.jsx)(`div`,{...o,onMouseEnter:v,onMouseLeave:y,style:{position:`absolute`,backgroundColor:`rgba(33, 37, 41, 0.95)`,padding:`12px 16px`,border:`1px solid rgba(255, 255, 255, 0.2)`,borderRadius:6,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.2)`,display:`flex`,alignItems:`center`,gap:4,whiteSpace:`nowrap`,...o.style},children:(0,p.jsx)(Sk,{runStepPart:t,setRunStepPartAction:x})})})]}):S},hA=(e,t)=>t.get(e.id)?.status.class??`step-part-inactive`,gA=({runPart:e,context:t})=>{let{step:n,stepPartsById:r,allowCreate:i,selectedPartIds:a}=t;return(0,p.jsx)(mA,{runPart:e,statusClass:hA(e,r),allowCreate:i,stepPart:r.get(e.id),isSelected:a.includes(e.id),runStep:n})},_A=({runParts:e,context:t})=>(0,p.jsx)(`div`,{className:`tray-grid__cell${e.length?``:` tray-grid__cell--empty`}${e.length>1?` tray-grid__cell--multi`:``}`,children:e.map(e=>(0,p.jsx)(gA,{runPart:e,context:t},e.id))}),vA=({runPart:e,context:t})=>{let{step:n,stepPartsById:r,allowCreate:i,selectedPartIds:a}=t;return(0,p.jsx)(mA,{runPart:e,statusClass:e?hA(e,r):void 0,withTrayCell:!0,allowCreate:i,stepPart:e?r.get(e.id):void 0,isSelected:e?a.includes(e.id):!1,runStep:n})},yA=12,bA=({leveledParts:e,allNonTrayParts:t,isSplitLevel:n,context:r})=>{let i=pA({parts:t,getDirectSlotIndex:e=>e.left>=1?e.left-1:null}),a=n?e.reduce((e,t)=>Math.max(e,(i.get(t.id)??-1)+1),0):Math.max(e.length,e.reduce((e,t)=>Math.max(e,t.left??0),0)),o=Math.max(1,Math.ceil(a/yA)),s=yA,c={"--tray-columns":s,"--tray-rows":o},l=n?fA({parts:e,slotCount:o*s,getSlotIndex:e=>i.get(e.id)??null}):Array.from({length:o*s},()=>[]);if(!n){let t=[];e.forEach(e=>{let n=e.left,r=n>=1&&n<=l.length?n-1:null;if(r!==null&&!l[r].length){l[r].push(e);return}t.push(e)}),t.forEach(e=>{let t=l.findIndex(e=>e.length===0);t!==-1&&l[t].push(e)})}return(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":`ltr`,style:c,children:l.map((e,t)=>n?(0,p.jsx)(_A,{runParts:e,context:r},`slot-no-tray-${t}`):(0,p.jsx)(vA,{runPart:e[0]??null,context:r},`slot-no-tray-${t}`))})},xA=({label:e,trayStepParts:t,runStep:n,children:r})=>{let i=(0,m.useQueryClient)(),a=(0,d.useRef)(null),o=(0,d.useRef)(null),[s,c]=(0,d.useState)(!1),l=()=>{o.current&&(clearTimeout(o.current),o.current=null),c(!0)},u=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>c(!1),150)},f=(()=>{let e=new Map;for(let n of t)for(let{id:t,name:r}of n.available_actions)e.has(t)||e.set(t,r);return Array.from(e.entries()).map(([e,t])=>({id:e,name:t}))})(),h=async e=>{let r=t.filter(t=>t.available_actions.some(({id:t})=>t===e));if(r.length===0)return;let a=await Ve({runStepPartActions:r.map(t=>({runStepPart:t,runStepPartAction:e}))});Lk(i,n,{latestActions:a})};return(0,p.jsxs)(`div`,{ref:a,className:`tray-grid-wrapper`,onMouseEnter:l,onMouseLeave:u,children:[(0,p.jsx)(`div`,{className:`tray-grid__label`,children:e}),r,f.length>0&&(0,p.jsx)(hl,{target:a.current,show:s,placement:`top`,children:({placement:e,arrowProps:t,show:n,popper:r,hasDoneInitialMeasure:i,...a})=>(0,p.jsx)(`div`,{...a,onMouseEnter:l,onMouseLeave:u,style:{position:`absolute`,backgroundColor:`rgba(33, 37, 41, 0.95)`,padding:`12px 16px`,border:`1px solid rgba(255, 255, 255, 0.2)`,borderRadius:6,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.2)`,display:`flex`,alignItems:`center`,gap:4,whiteSpace:`nowrap`,...a.style},children:(0,p.jsx)(eA,{availableActions:f,onActionSelected:h})})})]})},SA=(e,t,n)=>!t||!n||t<1||n<1||t>e.rows||n>e.columns?null:e.orientation===`ttb`?(n-1)*e.rows+(t-1):(t-1)*e.columns+(n-1),CA=(e,t)=>e.map(e=>t.get(e.id)).filter(e=>e!==void 0),wA=e=>e?.tray_id!=null&&!e?.failed?1:e?.tray_id==null?3:2,TA=({tray:e,trayParts:t,trayAllParts:n,stepParts:r,isSplitLevel:i,context:a})=>{let{step:o,stepPartsById:s}=a,c=e.tray_type,l=e.name??e.label??``,u=CA(t,s),d=new Map;if(r.forEach(e=>{e.step_id===o.id&&d.set(e.part_id,e)}),!c?.rows||!c?.columns)return(0,p.jsx)(xA,{label:l,trayStepParts:u,runStep:o,children:(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-2`,children:t.map(e=>(0,p.jsx)(gA,{runPart:e,context:a},e.id))})});let f=c.rows*c.columns,m=new Set((c.forbidden_slots??[]).map(e=>SA(c,e.y,e.x)).filter(e=>e!==null)),h=c.orientation===`ttb`?`ttb`:`ltr`,g={"--tray-columns":c.columns,"--tray-rows":c.rows},_=pA({parts:n,slotCount:f,getOverrideSlotIndex:e=>{let t=d.get(e.id);return!t||t.tray_row==null&&t.tray_column==null?null:SA(c,t.tray_row??e.tray_row,t.tray_column??e.tray_column)},getDirectSlotIndex:e=>SA(c,e.tray_row,e.tray_column)}),v=i?fA({parts:t,slotCount:f,getSlotIndex:e=>_.get(e.id)??null}):Array.from({length:f},()=>[]);return i||t.forEach(e=>{let t=d.get(e.id),n=SA(c,t?.tray_row??e.tray_row,t?.tray_column??e.tray_column);if(n===null)return;let r=wA(t),i=v[n][0],a=i?wA(d.get(i.id)):null;a!==null&&a<r||(v[n]=[e])}),(0,p.jsx)(xA,{label:l,trayStepParts:u,runStep:o,children:(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":h,style:g,children:v.map((t,n)=>m.has(n)?(0,p.jsx)(`div`,{"aria-hidden":`true`},`slot-${e.id}-${n}`):i?(0,p.jsx)(_A,{runParts:t,context:a},`slot-${e.id}-${n}`):(0,p.jsx)(vA,{runPart:t[0]??null,context:a},`slot-${e.id}-${n}`))})})},EA=(e,t)=>!t||!t.tray_id?e.tray?.id??0:t.tray_id,DA=(e,t)=>{let n=new Map(t.map(e=>[e.part_id,e]));return e.reduce((e,t)=>{if(!t.tray)return e;let r=EA(t,n.get(t.id)),i=e.get(r)??[];return i.push(t),e.set(r,i),e},new Map)},OA=({step:e,parts:t,stepParts:n,run:r})=>{let i=(0,d.useMemo)(()=>t.filter(t=>t.part_level===e.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),[t]),a=(0,d.useMemo)(()=>{let t=new Map;for(let r of n)r.step_id===e.id&&t.set(r.part_id,r);return t},[n,e]),o=(0,d.useMemo)(()=>[...r.run_trays??[]].sort((e,t)=>e.sequence-t.sequence),[r]),s=(0,d.useMemo)(()=>DA(i,n),[i,n]),c=(0,d.useMemo)(()=>t.filter(e=>!e.tray),[t]),l=(0,d.useMemo)(()=>DA(t,n),[t,n]),u=r.run_type===pt.PRODUCTION,f=e.part_level>0,{data:h=[]}=(0,m.useQuery)({queryKey:[`runPartSelection`,e.id],queryFn:async()=>[],initialData:[],enabled:!1}),g={step:e,stepPartsById:a,allowCreate:u,selectedPartIds:h};return o.length===0||i[0]?.part_level>0?(0,p.jsx)(bA,{leveledParts:i,allNonTrayParts:c,isSplitLevel:f,context:g}):(0,p.jsx)(`div`,{className:`tray-grid-group`,children:o.map(e=>(0,p.jsx)(TA,{tray:e,trayParts:s.get(e.id)??[],trayAllParts:l.get(e.id)??[],stepParts:n,isSplitLevel:f,context:g},`tray-${e.id}`))})};function kA({run:e,step:t,parts:n,monitoredBy:r,refetchFn:i}){let{environment:a}=(0,g.useParams)(),[o,s]=(0,d.useState)(!1),c=()=>{s(!o)},[l,u]=(0,d.useState)(t.process_module.module);(0,d.useEffect)(()=>{u(t.process_module.module)},[t.process_module.module]);let[f]=(0,m.useQueries)({queries:[{queryKey:[`runStepParts`,t.id],queryFn:()=>Re({step:t}),placeholderData:m.keepPreviousData}]}),h=(0,d.useMemo)(()=>f.data?.items??[],[f.data?.items]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":o?`Collapse details`:`Expand details`,className:`fa ms-2 `+(o?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())}})}),(0,p.jsx)(`td`,{className:l.latest_module_status&&l.latest_module_status.status.is_down_status?`table-danger`:``,children:f.isLoading?(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(OA,{step:t,parts:n,stepParts:h,run:e})}),(0,p.jsxs)(`td`,{children:[r&&(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-${r.id}`,children:`Monitored by step: ${r.step.number}`}),children:(0,p.jsx)(`i`,{className:`fa fa-search me-2`})}),t.amount_of_files>0&&(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip`}),` `,t.amount_of_files]}),t.has_remark&&(0,p.jsx)(`i`,{className:`fa fa-comment-o text-warning me-3`}),t.is_finished&&(0,p.jsx)(`i`,{className:`fa fa-check text-success me-3`})]}),(0,p.jsxs)(`td`,{className:t.has_step_group?`ps-4`:``,children:[t.number,` - `,(0,p.jsx)(g.Link,{to:`/${a}/operator/run/step/${t.id}`,children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.name}})}),` `]}),(0,p.jsxs)(`td`,{children:[l.equipment&&(0,p.jsx)(g.Link,{to:`/${a}/operator/equipment/${l.equipment.id}`,className:`me-2`,children:l.equipment.name}),(0,p.jsx)(Ld,{module:l,refetchFn:()=>{i([`runSteps`])}})]})]}),o&&(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:n.length+6,children:(0,p.jsx)(sA,{step:t,refetchFn:i})})})]})}var AA=({requirement:e,result:t,show:n,setShow:r,refetchFn:i,part:a,stepPart:o})=>{let[s,c]=(0,d.useState)({}),[l,u]=(0,d.useState)(!1),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),v=(0,d.useMemo)(()=>new Map(t?.values.map(e=>[e.logging_parameter.id,e])??[]),[t?.values]);(0,d.useEffect)(()=>{if(Object.keys(s).length>0)return;let n={};for(let r of e.targets){let e=``;t!==void 0&&(e=v.get(r.logging_parameter.id)?.string_value??``),n[r.logging_parameter.id]=e}c(n)},[e,v]),(0,d.useEffect)(()=>{_(!1),h(null),u(!1)},[n]);let y=async()=>{try{h(null),_(!1),u(!0),await f.default.delete(`/delete/run/measurement/result/${t?.id??0}`),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},b=async()=>{try{h(null),_(!1),u(!0),await Promise.all(Object.entries(s).map(([e,t])=>{let n=Number.parseInt(e),r={value:t},i=v.get(n)?.id;return f.default.patch(`/update/run/measurement/result/value/${i??0}`,r)})),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},x=async()=>{let t={measurement:e.measurement.id,values:Object.entries(s).flatMap(e=>({logging_parameter:Number.parseInt(e[0]),value:e[1]}))};o&&(t.step_part=o?.id??0,t.part=a?.id??0,t.step=e.step.id??0);try{h(null),_(!1),u(!0),await f.default.post(`/create/run/measurement/result`,t),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}};return(0,p.jsxs)(K,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:t?(0,p.jsx)(p.Fragment,{children:`Update results`}):(0,p.jsx)(p.Fragment,{children:`Create result`})})}),(0,p.jsxs)(G,{onSubmit:e=>{e.preventDefault(),t?b():x()},children:[(0,p.jsxs)(K.Body,{children:[m&&(0,p.jsx)(Cr,{variant:`danger`,children:m}),g&&(0,p.jsx)(Cr,{variant:`success`,children:`Results have been updated successfully`}),e.targets.map(e=>(t?.values.find(t=>t.logging_parameter.id===e.logging_parameter.id)?.string_value,(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:e.logging_parameter.name}),(0,p.jsx)(G.Control,{type:`number`,step:`any`,placeholder:`Thickness`,value:s[e.logging_parameter.id]??``,onChange:t=>c(n=>({...n,[e.logging_parameter.id]:t.target.value}))})]},e.id)))]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{variant:`warning`,onClick:()=>r(!1),children:`Close`}),l?(0,p.jsxs)(U,{type:`submit`,variant:`info`,disabled:l,children:[(0,p.jsx)(Ml,{animation:`border`,size:`sm`,className:`me-2`}),` Updating results...`]}):t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{variant:`danger`,disabled:l,onClick:y,children:`Delete result`}),(0,p.jsx)(U,{type:`submit`,variant:`info`,disabled:l,children:`Update result`})]}):(0,p.jsx)(U,{type:`submit`,variant:`info`,disabled:l,children:`Create result`})]})]})]})},jA=(0,d.createContext)({runStep:{},setRunStep:e=>{},reloadRunStep:()=>{},run:{},modalProperties:{},setModalProperties:e=>{}});function MA({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a,editOnly:o=!1}){let{run:s}=(0,d.useContext)(jA),[c,l]=(0,d.useState)(r??[]),[u,f]=(0,d.useState)(n??[]),[h,g]=(0,d.useState)(i??[]),_=(0,m.useQueryClient)(),v=(0,m.useQueries)({queries:[{queryKey:[`runParts`,`${s?.id??`unknown`}`],queryFn:async()=>await ke({run:s}),enabled:!r||r.length===0,retry:1},{queryKey:[`runStepParts`,`${t?.run_id??`unknown`}`,`${t?.id??`unknown`}`],queryFn:async()=>await Re({step:e.requirement_for_step??e.step}),enabled:!n||n.length===0,retry:1},{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Ne({measurement:e.measurement}),enabled:!i||i.length===0,retry:1}]}),y=()=>{_.refetchQueries({queryKey:[`requirement`,`measurementResults`,e.measurement.id]})},[b,x,S]=v;(0,d.useEffect)(()=>{r&&r.length>0?l(r):b?.data&&l(b.data.items)},[r,b?.data]),(0,d.useEffect)(()=>{n&&n.length>0?f(n):x?.data&&f(x.data.items)},[n,x?.data]),(0,d.useEffect)(()=>{i&&i.length>0?g(i):S?.data&&g(S.data.items)},[i,S?.data]);let[C,w]=(0,d.useState)(null),T=r&&r.length>0?r:c,E=((n&&n.length>0?n:u)??[]).filter(e=>(T??[]).find(n=>n.id===e.part_id&&n.part_level===t.part_level)!==void 0),D=!r||r.length===0,O=!n||n.length===0,k=!i||i.length===0,A=D&&b?.isLoading||O&&x?.isLoading||k&&S?.isLoading,j=D&&b?.isError||O&&x?.isError||k&&S?.isError;if(A&&E.length===0)return(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(Ml,{animation:`border`,size:`sm`}),` `,(0,p.jsx)(`span`,{children:`Loading data…`})]});if(j&&E.length===0)return(0,p.jsxs)(Cr,{variant:`danger`,className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsx)(`div`,{children:`Failed to load required data. Please try again.`}),(0,p.jsxs)(`div`,{children:[D&&b?.isError&&(0,p.jsx)(U,{size:`sm`,variant:`outline-light`,onClick:()=>b.refetch(),children:`Retry parts`}),` `,O&&x?.isError&&(0,p.jsx)(U,{size:`sm`,variant:`outline-light`,onClick:()=>x.refetch(),children:`Retry step parts`}),` `,k&&S?.isError&&(0,p.jsx)(U,{size:`sm`,variant:`outline-light`,onClick:()=>S.refetch(),children:`Retry results`})]})]});let M=t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return``;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id===t.logging_parameter.id);return r?(r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n))?`table-danger`:`table-success`:``};return(0,p.jsx)(p.Fragment,{children:E.length>0?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Nl,{size:`sm`,striped:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{style:{width:`26%`},children:`Part`}),(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`}),!o&&(0,p.jsx)(`th`,{style:{width:`1%`}})]})}),(0,p.jsx)(`tbody`,{children:E.map(t=>{let n=h.find(e=>e.values.some(e=>e.step_part_id===t.id)),r=(n?.values??[]).filter(e=>e.step_part_id===t.id),i=e.targets.length;return e.targets.map((e,a)=>{let s=r.find(t=>t.logging_parameter.id===e.logging_parameter.id)??null;return(0,p.jsxs)(`tr`,{className:s?M(s):``,children:[a===0&&(0,p.jsxs)(`td`,{rowSpan:i,children:[T.find(e=>e.id===t.part_id)?.short_label??t.part_id,` `,(0,p.jsxs)(`small`,{className:`text-muted`,children:[`(`,t.id,`)`]})]}),(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{children:s?s.string_value:(0,p.jsx)(`span`,{className:`text-muted`,children:`not set`})}),(0,p.jsx)(`td`,{children:e.logging_parameter.unit?.abbr??``}),!o&&a===0&&(0,p.jsx)(`td`,{rowSpan:i,className:`align-middle text-nowrap`,children:(0,p.jsxs)(U,{size:`sm`,variant:n?`outline-primary`:`outline-success`,onClick:()=>w(String(t.id)),children:[(0,p.jsx)(`i`,{className:`fa fa-edit`}),` `,n?`Edit values`:`Add values`]})})]},`${t.id}:${e.logging_parameter.id}`)})})})]}),!o&&E.map(t=>{let n=h.find(e=>e.values.some(e=>e.step_part_id===t.id));return(0,p.jsx)(AA,{requirement:e,...n?{result:n}:{part:T.find(e=>e.id===t.part_id),stepPart:t},show:C===String(t.id),setShow:e=>{e||w(null)},refetchFn:a??y},`modal:${t.id}`)})]}):(0,p.jsx)(Cr,{variant:`secondary`,className:`mb-0`,children:`No selected parts`})})}function NA({requirement:e,measurementResults:t,refetchFn:n,editOnly:r=!1}){let[i,a]=(0,d.useState)(t??[]),o=(0,m.useQueryClient)(),s=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Ne({measurement:e.measurement}),enabled:!t||t.length===0,retry:1}]}),c=()=>{o.refetchQueries({queryKey:[`requirement`,`measurementResults`,e.measurement.id]})},[l]=s;(0,d.useEffect)(()=>{t&&t.length>0?a(t.filter(e=>e.values.some(e=>!e.step_part_id))):l?.data&&a(l.data.items.filter(e=>e.values.some(e=>!e.step_part_id)))},[t,l?.data]);let[u,f]=(0,d.useState)(null),[h,g]=(0,d.useState)(!1),_=s.some(e=>e.isLoading);if(s.some(e=>e.isError))return s.forEach((e,t)=>{e.isError&&console.error(`StepDashboard query error`,{index:t,error:e.error})}),(0,p.jsx)(p.Fragment,{children:`Error fetching data`});if(_)return(0,p.jsx)(`div`,{children:`Loading...`});let v=t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return``;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id===t.logging_parameter.id);return r&&(r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n))?`table-danger text-light`:``};return(0,p.jsxs)(`div`,{className:`d-flex flex-column gap-4`,children:[i.map(t=>(0,p.jsxs)(`div`,{className:`border rounded p-3 shadow-sm`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:[(0,p.jsxs)(`h6`,{className:`mb-0`,children:[`Result `,(0,p.jsxs)(`small`,{className:`text-muted`,children:[`#`,t.id]})]}),!r&&(0,p.jsxs)(U,{size:`sm`,variant:`outline-primary`,onClick:()=>f(t.id),children:[(0,p.jsx)(`i`,{className:`fa fa-edit`}),` Update value`]})]}),(0,p.jsxs)(`table`,{className:`table table-striped table-sm mb-0`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:t.values.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{className:e?v(e):``,children:e.string_value}),(0,p.jsx)(`td`,{children:e.logging_parameter.unit?.abbr??``})]},`value:${e.id}`))})]}),(0,p.jsx)(AA,{requirement:e,result:t,show:u===t.id,setShow:e=>{e||f(null)},refetchFn:n??c})]},t.id)),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(U,{size:`sm`,onClick:()=>g(!h),children:[(0,p.jsx)(`i`,{className:`fa fa-plus`}),` Add results`]})}),(0,p.jsx)(AA,{requirement:e,show:h,setShow:e=>{e||g(!1)},refetchFn:n??c})]})}function PA({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}){let{environment:o}=(0,g.useParams)();return(0,p.jsx)(W,{className:`p-4 my-3`,children:(0,p.jsx)(W.Body,{children:(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{md:`7`,children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(MA,{requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(NA,{requirement:e,measurementResults:i,refetchFn:a})]}),(0,p.jsxs)(qr,{md:`5`,children:[(0,p.jsx)(`h4`,{children:`Monitored Step`}),(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${e.requirement_for_step?.id??e.step.id}`,children:(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-search`}),` `,e.requirement_for_step?.name??e.step.name]})}),(0,p.jsx)(`h4`,{children:`Definition`}),(0,p.jsx)(`span`,{children:e.definition}),(0,p.jsx)(`h4`,{children:`Targets`}),(0,p.jsxs)(Nl,{size:`sm`,striped:!1,bordered:!1,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`parameter`}),(0,p.jsx)(`th`,{children:`min value`}),(0,p.jsx)(`th`,{children:`max value`}),(0,p.jsx)(`th`,{children:`inclusive`})]})}),(0,p.jsx)(`tbody`,{children:e.targets.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{children:e.min_value}),(0,p.jsx)(`td`,{children:e.max_value}),(0,p.jsx)(`td`,{children:e.inclusive?`yes`:`no`})]},e.id))})]}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(vk,{runStep:t,refetchFn:()=>{a([`requirements`])}})]})]})})})}var FA=({requirement:e,step:t,measurementResults:n,parts:r,stepParts:i})=>{let a=r.filter(e=>e.part_level===t.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),o=a.reduce((e,t)=>{let n=t.root_id??t.id;return e[n]||(e[n]=[]),e[n].push(t),e},{}),s=new Map(i.map(e=>[e.part_id,e])),c=new Map;for(let e of n)for(let t of e.values)t.step_part_id!==void 0&&t.step_part_id!==null&&!c.has(t.step_part_id)&&c.set(t.step_part_id,e);let l=new Map(e.targets.map(e=>[e.logging_parameter.id,e])),u=e=>{let t=s.get(e.id);if(!t)return`badge-inactive`;let n=c.get(t.id);if(!n)return``;for(let e of n.values){let t=parseFloat(e.string_value),n=l.get(e.logging_parameter.id);if(n){if(n.inclusive){if(!(n.min_value<=t&&n.max_value>=t))return`badge-failed`}else if(!(n.min_value<t&&n.max_value>t))return`badge-failed`}}return`badge-processed`},d=e=>(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-${e.id}`,children:`Level: ${e.part_level}${e.parent?`, Parent: ${e.parent.short_label}`:``}`}),children:(0,p.jsx)(`span`,{className:`badge badge-level-${e.part_level} ${u(e)} me-1`,children:e.short_label},e.id)},e.id);return(0,p.jsxs)(`div`,{children:[a[0].parent?Object.entries(o).map(([e,t])=>(0,p.jsxs)(`div`,{className:`mb-2`,children:[(0,p.jsxs)(`label`,{className:`text-muted me-1`,children:[t[0].parent?.short_label,`:`]}),` `,t.map(e=>d(e))]},e)):a.map(e=>d(e)),(0,p.jsx)(`span`,{children:`(measurements)`})]})};function IA({requirement:e,step:t,parts:n,refetchFn:r}){let{environment:i}=(0,g.useParams)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(t.process_module.module);(0,d.useEffect)(()=>{c(t.process_module.module)},[t.process_module.module]);let l=()=>{o(!a)},u=(0,m.useQueryClient)(),f=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Ne({measurement:e.measurement})},{queryKey:[`runStepParts`,e.requirement_for_step?.id??e.step.id],queryFn:()=>Re({step:e.requirement_for_step??e.step}),placeholderData:m.keepPreviousData}]}),h=e=>{e[0]===`requirement`&&u.refetchQueries({queryKey:e}),r(e)},[_,v]=f,y=f.some(e=>e.isLoading),b=(0,d.useMemo)(()=>v.data?.items??[],[v.data?.items]),x=(0,d.useMemo)(()=>_.data?.items??[],[_.data?.items]),S=(0,d.useMemo)(()=>new Map(e.targets.map(e=>[e.logging_parameter.id,e])),[e.targets]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:(e=>{if(e.length==0)return y?``:`table-info`;let t=!1;for(let n of e)if(n.values.some(e=>{if(!(e&&!isNaN(parseFloat(e.string_value))))return!1;let t=parseFloat(e.string_value),n=S.get(e.logging_parameter.id);return n?n.inclusive?!(n.min_value<=t&&n.max_value>=t):!(n.min_value<t&&n.max_value>t):!1})){t=!0;break}return t?`table-danger`:``})(x),children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":a?`Collapse details`:`Expand details`,className:`fa ms-2 `+(a?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:l,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l())}})}),(0,p.jsx)(`td`,{children:y?(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(FA,{requirement:e,step:t,measurementResults:x,parts:n,stepParts:b})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(wr,{bg:`info`,children:`requirement`}),t.amount_of_files>0&&(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip`}),` `,t.amount_of_files]}),t.has_remark&&(0,p.jsx)(`i`,{className:`fa fa-comment-o text-warning`})]}),(0,p.jsx)(`td`,{className:t.has_step_group?`ps-4`:``,children:(0,p.jsxs)(`div`,{children:[`(`,t.number,`)`,` `,(0,p.jsx)(g.Link,{to:`/${i}/operator/run/step/${t.id}`,children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.name}})}),` `]})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(g.Link,{to:`/${i}/operator/equipment/${s.equipment.id}`,className:`me-2`,children:s.equipment.name}),(0,p.jsx)(Ld,{module:s,refetchFn:()=>{r([`runSteps`])}})]})]}),a&&(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:n.length+5,children:y?`Loading...`:(0,p.jsx)(PA,{requirement:e,step:t,stepParts:b,parts:n,measurementResults:x,refetchFn:h})})})]})}var LA=e=>(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:5,style:{margin:0},className:`bg-info`,children:(0,p.jsx)(`span`,{children:e.step_group?.label})})});function RA(){let{run:e}=(0,d.useContext)(ok),{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n}=(0,d.useContext)(mk),[r,i]=(0,d.useState)(1),[a]=(0,d.useState)(25),[o,s]=(0,d.useState)(new Map),c=(0,m.useQueryClient)(),l=(0,m.useQueries)({queries:[{queryKey:[`runSteps`,JSON.stringify(e),r],queryFn:()=>Ae({run:e,page:r,pageSize:a}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>ke({run:e})},{queryKey:[`requirements`,JSON.stringify(e)],queryFn:()=>De({run:e})}]}),u=t=>{let n=[...t,JSON.stringify(e)];t[0]===`runSteps`&&n.push(r),c.refetchQueries({queryKey:n})},[f,h,g]=l,_=l.some(e=>e.isLoading),v=l.some(e=>e.isError);v&&l.forEach((t,n)=>{t.isError&&console.error(`RunStepsElement query error`,{index:n,error:t.error,run:e})});let y=(0,d.useMemo)(()=>f.data?.items??[],[f.data?.items]),b=(0,d.useMemo)(()=>h.data?.items??[],[h.data?.items]),x=(0,d.useMemo)(()=>g.data?.items??[],[g.data?.items]);if((0,d.useEffect)(()=>{s(e=>{let t=new Map(e);return y.forEach(e=>{let n=e.label?.id;n!==void 0&&!t.has(n)&&t.set(n,!0)}),t})},[y]),_)return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center`,children:(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`2rem`,height:`1rem`,borderRadius:`0.5rem`}})}),(0,p.jsx)(q,{animation:`glow`,as:`span`,className:`ms-2`,children:(0,p.jsx)(q,{style:{width:`15rem`}})})]})}),(0,p.jsxs)(Nl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Parts`}),(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Process`}),(0,p.jsx)(`th`,{children:`Equipment`})]})}),(0,p.jsx)(`tbody`,{children:[1,2].map(e=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:5,className:`bg-info`,children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`0.75rem`}})})}),(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`10rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`12rem`}})})})]})]},e))})]})]});if(v)return(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run steps.`});let S=new Set,C=y.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||S.has(String(e.step_group.id))?!1:(S.add(String(e.step_group.id)),!0)),w={};for(let e of x)e.requirement_for_step!=null&&(w[String(e.requirement_for_step.id)]=e);let T=e=>{let t=e.label,n=t?.id;if(!e.is_own_label||!t||n===void 0)return null;let r=e=>{s(t=>{let n=new Map(t);return n.set(e,!n.get(e)),n})};return(0,p.jsx)(`tr`,{style:{cursor:`pointer`},onClick:()=>r(n),children:(0,p.jsx)(`td`,{colSpan:5,style:{margin:0},className:`bg-secondary`,children:(0,p.jsxs)(`span`,{className:`label-toggle`,children:[(0,p.jsx)(`i`,{className:`fa `+(o.get(e.label?.id??-1)?`fa-caret-down`:`fa-caret-right`)}),` `,t.label]})})})};return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center`,children:(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(`input`,{type:`checkbox`,id:`showOnlyEmphasizedParameters`,checked:t,className:`form-check-input`,"data-toggle":`toggle`,onChange:()=>n(!t)}),(0,p.jsx)(`label`,{htmlFor:`showOnlyEmphasizedParameters`,className:`ms-2`,children:`Show only emphasized parameters`})]})}),(0,p.jsxs)(Nl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Parts`}),(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Process`}),(0,p.jsx)(`th`,{children:`Equipment`})]})}),(0,p.jsx)(`tbody`,{children:y.map(t=>{let n=`step-${t.id}`;return(0,p.jsxs)(d.default.Fragment,{children:[t.has_label&&T(t),(!t.has_label||o.get(t.label?.id??-1))&&(0,p.jsxs)(p.Fragment,{children:[t.has_step_group&&C.includes(t)&&LA(t),t.has_requirement?(0,p.jsx)(IA,{requirement:x.find(e=>e.step.id===t.id),step:t,parts:b,refetchFn:u}):(0,p.jsx)(kA,{run:e,step:t,parts:b,monitoredBy:w[t.id],refetchFn:u})]})]},n)})})]}),(0,p.jsx)(GO,{data:f.data,setPage:i,isPlaceholderData:f.isPlaceholderData})]})}var zA=[],BA=new Set,VA=(e,t,n)=>{let r=e[t]??[];if(r.length===n.length&&r.every((e,t)=>e===n[t])||n.length===0&&!(t in e))return e;let i={...e};return n.length>0?i[t]=n:delete i[t],i},HA=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n};function UA(){let[e,t]=(0,d.useState)([]),[n,r]=(0,d.useState)({}),[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)({}),c=(0,d.useMemo)(()=>{let e={};for(let[t,r]of Object.entries(n))e[Number(t)]=new Set(r);return e},[n]);return{selectedRuns:e,partIdsByRunId:n,amountPerPartByRunId:i,descriptionsByRunId:o,selectRun:(0,d.useCallback)(e=>{t(t=>t.some(t=>t.id===e.id)?t:[...t,e])},[]),deselectRun:(0,d.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e)),r(t=>VA(t,e,[])),a(t=>HA(t,e)),s(t=>HA(t,e))},[]),getSelectedPartIds:(0,d.useCallback)(e=>n[e]??zA,[n]),isPartSelected:(0,d.useCallback)((e,t)=>(c[e]??BA).has(t),[c]),setRunPartIds:(0,d.useCallback)((e,t)=>{r(n=>VA(n,e,t))},[]),togglePart:(0,d.useCallback)((e,t)=>{r(n=>{let r=n[e]??[];return VA(n,e,r.includes(t)?r.filter(e=>e!==t):[...r,t])})},[]),setPartsSelected:(0,d.useCallback)((e,t,n)=>{r(r=>{let i=r[e]??[],a;if(n){let e=new Set(i);t.forEach(t=>e.add(t)),a=[...e]}else{let e=new Set(t);a=i.filter(t=>!e.has(t))}return VA(r,e,a)})},[]),getPartAmount:(0,d.useCallback)((e,t)=>i[e]?.[t]??1,[i]),setPartAmount:(0,d.useCallback)((e,t,n)=>{let r=Number.isFinite(n)?Math.max(1,n):1;a(n=>(n[e]?.[t]??1)===r?n:{...n,[e]:{...n[e]??{},[t]:r}})},[]),setDescription:(0,d.useCallback)((e,t)=>{s(n=>{if((n[e]??``)===t||!t&&!(e in n))return n;let r={...n};return t?r[e]=t:delete r[e],r})},[])}}function WA(e,t){return t.selectedRuns.map(n=>{let r=t.partIdsByRunId[n.id]??[],i=t.amountPerPartByRunId[n.id]??{},a=r.length>0?Object.fromEntries(r.map(e=>[e,i[e]??1])):null;return{run_id:e,parent_run_id:n.id,part_ids:r,amount_per_part:a,description:t.descriptionsByRunId[n.id]||null}})}var GA=(e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left,KA=e=>{let t=new Map;for(let n of e){let e=t.get(n.part_level)??[];e.push(n),t.set(n.part_level,e)}return Array.from(t.entries()).toSorted(([e],[t])=>e-t).map(([e,t])=>({level:e,parts:t.toSorted(GA)}))},qA=e=>e.parsed_label||e.scanner_label||e.label||e.short_label;function JA({runId:e,part:t,selection:n}){let r=n.isPartSelected(e,t.id),i=qA(t),a=`part-amount-${e}-${t.id}`,o=`part-selected-${e}-${t.id}`;return(0,p.jsxs)(`div`,{className:`list-group-item d-flex align-items-center gap-3 flex-wrap${r?` border-primary border-top`:``}`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(G.Label,{htmlFor:a,className:`small text-secondary mb-0`,children:`Split`}),(0,p.jsx)(G.Control,{id:a,type:`number`,size:`sm`,min:1,step:`any`,inputMode:`decimal`,value:n.getPartAmount(e,t.id),onChange:r=>n.setPartAmount(e,t.id,Number(r.target.value)),"aria-label":`Experimental split amount for ${i}`,style:{maxWidth:`7rem`}})]}),(0,p.jsx)(`label`,{htmlFor:o,className:`flex-grow-1 mb-0`,style:{cursor:`pointer`},children:i}),(0,p.jsx)(G.Check,{id:o,type:`checkbox`,checked:r,onChange:()=>n.togglePart(e,t.id),"aria-label":`Select ${i}`,className:`ms-sm-auto`})]})}function YA({runId:e,part:t,selection:n}){let r=n.isPartSelected(e,t.id);return(0,p.jsx)(wr,{as:`button`,type:`button`,bg:r?`primary`:`dark`,onClick:()=>n.togglePart(e,t.id),"aria-pressed":r,title:t.label,className:`border-0 fs-6 fw-normal px-3 py-2${r?` step-part-selected`:``}`,style:{cursor:`pointer`},children:qA(t)})}function XA({runId:e,group:t,selection:n,experimentalEdit:r}){let i=t.parts.length>0&&t.parts.every(t=>n.isPartSelected(e,t.id));return(0,p.jsxs)(`fieldset`,{className:`mb-4 border-0 p-0`,children:[(0,p.jsxs)(`legend`,{className:`d-flex align-items-center gap-2 fs-6 fw-semibold mb-2`,children:[(0,p.jsxs)(`span`,{children:[`Level `,t.level]}),(0,p.jsx)(wr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:t.parts.length}),(0,p.jsx)(U,{variant:`link`,size:`sm`,className:`p-0 ms-1`,onClick:()=>{n.setPartsSelected(e,t.parts.map(e=>e.id),!i)},children:i?`Deselect all`:`Select all`})]}),r?(0,p.jsx)(`div`,{className:`list-group`,children:t.parts.map(t=>(0,p.jsx)(JA,{runId:e,part:t,selection:n},t.id))}):(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-2`,children:t.parts.map(t=>(0,p.jsx)(YA,{runId:e,part:t,selection:n},t.id))})]})}function ZA({run:e,selection:t,partGroups:n,isLoadingParts:r,experimentalEdit:i,onToggleExperimentalEdit:a}){let o=t.getSelectedPartIds(e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`h3`,{children:`Description`}),(0,p.jsx)(G.Control,{as:`textarea`,rows:3,value:t.descriptionsByRunId[e.id]??``,onChange:n=>t.setDescription(e.id,n.target.value),placeholder:`Enter a description for ${e.label}`})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between mb-3`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`mb-1`,children:`Select parts`}),(0,p.jsx)(U,{variant:i?`outline-primary`:`primary`,size:`sm`,onClick:a,"aria-pressed":i,children:i?`Done editing split`:`Edit experimental split`}),i&&(0,p.jsx)(`p`,{className:`text-secondary small mb-0 mt-1`,children:`Amounts must be 1 or higher.`}),(0,p.jsxs)(`p`,{className:`text-secondary mb-0`,children:[e.label,` — `,e.name]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[o.length>0&&(0,p.jsxs)(`span`,{className:`text-secondary small`,children:[o.length,` selected`]}),(0,p.jsx)(U,{variant:`link`,size:`sm`,className:`p-0`,onClick:()=>t.setRunPartIds(e.id,[]),children:`Clear`})]})]}),r&&(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2 text-secondary`,children:[(0,p.jsx)(Ml,{animation:`border`,size:`sm`,role:`status`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{children:`Loading parts…`})]}),!r&&n.length===0&&(0,p.jsx)(`p`,{className:`text-secondary mb-0`,children:`This run has no parts to select.`}),!r&&n.map(n=>(0,p.jsx)(XA,{runId:e.id,group:n,selection:t,experimentalEdit:i},n.level))]})}function QA({selectedRuns:e,onDeselect:t}){return(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between mb-2`,children:[(0,p.jsx)(`h3`,{className:`mb-0`,children:`Selected runs`}),e.length>0&&(0,p.jsx)(wr,{bg:`primary`,pill:!0,className:`fw-normal`,children:e.length})]}),e.length===0&&(0,p.jsx)(`p`,{className:`text-secondary mb-0`,children:`Select one or more parent runs to configure their parts.`}),e.length>0&&(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:e.map(e=>(0,p.jsxs)(`div`,{className:`d-flex flex-column gap-2 bg-body-secondary rounded p-2`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`fw-semibold`,children:[e.label,` — `,e.name]}),(0,p.jsx)(`div`,{className:`text-secondary small`,children:`Included in creation`})]}),(0,p.jsx)(`div`,{className:`d-flex align-items-center gap-2`,children:(0,p.jsx)(U,{variant:`outline-danger`,size:`sm`,onClick:()=>t(e.id),children:`Deselect`})})]},e.id))})]})}var $A=e=>KA(e.items??[]),ej=e=>({value:e.id,label:`${e.label} — ${e.name}`,run:e}),tj=Xb;function nj({selection:e,run:t}){let{environment:n}=(0,g.useParams)(),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),{selectedRuns:s}=e,{data:c,isFetching:l}=(0,m.useQuery)({queryKey:[n],queryFn:()=>je({environment:n,availableAsParentForRun:t})}),u=(0,m.useQueries)({queries:s.map(e=>({queryKey:[e.id],queryFn:()=>ke({run:e}),select:$A}))}),f=(0,d.useMemo)(()=>c?.items??[],[c]),h=(0,d.useMemo)(()=>f.map(ej),[f]),_=r===null?0:Math.max(0,s.findIndex(e=>e.id===r)),v=s[_]??null,y=u[_],b=async e=>{let t=e.toLowerCase(),n=[];for(let e of f)(!t||e.label.toLowerCase().includes(t)||e.name.toLowerCase().includes(t))&&n.push(ej(e));return n},x=t=>{e.selectRun(t),i(t.id)};return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`h3`,{children:`Select parent runs`}),(0,p.jsx)(qb,{isSearchable:!0,isClearable:!0,defaultOptions:h,placeholder:`— Select a run, or start typing`,loadOptions:b,isLoading:l,value:null,styles:tj,onChange:e=>{e&&x(e.run)}})]}),(0,p.jsx)(QA,{selectedRuns:s,onDeselect:e.deselectRun}),s.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)($c,{variant:`tabs`,activeKey:v===null?void 0:`run-${v.id}`,onSelect:e=>{e?.startsWith(`run-`)&&i(Number(e.replace(`run-`,``)))},className:`mb-3`,children:s.map(e=>(0,p.jsx)($c.Item,{children:(0,p.jsx)($c.Link,{eventKey:`run-${e.id}`,children:e.label})},e.id))}),(0,p.jsx)(`div`,{className:`ms-2 ps-2`,children:v&&(0,p.jsx)(ZA,{run:v,selection:e,partGroups:y?.data??[],isLoadingParts:y?.isFetching??!1,experimentalEdit:a,onToggleExperimentalEdit:()=>o(e=>!e)},v.id)})]})]})}function rj({title:e,children:t}){return(0,p.jsxs)(`fieldset`,{children:[(0,p.jsx)(`legend`,{className:`fs-5 mb-0`,children:e}),t]})}var ij=e=>{if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null};function aj({controlId:e,label:t,options:n,isLoading:r,value:i,onChange:a,showError:o,disabled:s,helpText:c}){let l=t.toLowerCase(),u=`${l}s`;return(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:e,children:[(0,p.jsxs)(G.Label,{column:!0,sm:3,children:[t,` `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsxs)(G.Select,{value:i??``,onChange:e=>a(ij(e.target.value)),required:!0,disabled:s,isInvalid:o,children:[(0,p.jsx)(`option`,{value:``,children:r?`Loading ${u}...`:`— Select a ${l}`}),n.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),o&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:r?`${t}s are still loading.`:`— Select a ${l}.`}),(0,p.jsx)(G.Text,{muted:!0,children:c})]})]})}function oj({title:e,isEmpty:t,children:n}){return t?``:(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`text-secondary mb-2`,children:[e,` `,(0,p.jsx)(`span`,{className:`text-body-tertiary`,children:`(selected previously)`})]}),(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:n})]})}function sj({selectedRuns:e,selectedSubstrates:t,partIdsByRunId:n}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(oj,{title:`Parent runs & parts`,isEmpty:e.length===0,children:e.map(e=>{let t=n[e.id]?.length??0;return(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between gap-3 bg-body-secondary border-0 rounded p-2`,children:[(0,p.jsxs)(`div`,{className:`fw-semibold`,children:[e.label,` — `,e.name]}),t>0?(0,p.jsxs)(wr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:[t,` `,t===1?`part`:`parts`]}):(0,p.jsx)(`span`,{className:`text-secondary fst-italic small`,children:`No parts selected`})]},e.id)})}),(0,p.jsx)(oj,{title:`Substrates`,isEmpty:t.length===0,children:t.map(({substrate:e,amount:t})=>(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between gap-3 bg-body-secondary rounded p-2`,children:[(0,p.jsxs)(`div`,{className:`fw-semibold`,children:[e.label,` — `,e.short_label]}),(0,p.jsxs)(wr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:[`Amount: `,t]})]},e.id))})]})}function cj({isSubmitting:e,errorMessage:t,selectedRuns:n,selectedSubstrates:r,partIdsByRunId:i,onBack:a,onSubmit:o}){let{environment:s}=(0,g.useParams)(),[c,l]=(0,d.useState)(``),[u,f]=(0,d.useState)(``),[h,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(pt.RESEARCH),[w,T]=(0,d.useState)(1),[E,D]=(0,d.useState)(``),[O,k]=(0,d.useState)(!1),{data:A,isError:j,isLoading:M}=(0,m.useQuery)({queryKey:[`organisation-groups`,s],queryFn:()=>_e({environment:s})}),{data:N,isError:P,isLoading:F}=(0,m.useQuery)({queryKey:[`organisation-teams`,s,ht.Run],queryFn:()=>ye({environment:s,purpose:ht.Run})}),{data:I,isError:L,isLoading:ee}=(0,m.useQuery)({queryKey:[`organisation-projects`,s,mt.Run],queryFn:()=>ve({environment:s,purpose:mt.Run})}),te=c.trim(),ne=u.trim(),re=M||F||ee,ie=j||P||L,ae=A?.items??[],oe=N?.items??[],se=I?.items??[],ce=h!==null&&ae.some(e=>e.id===h),le=v!==null&&oe.some(e=>e.id===v),R=b!==null&&se.some(e=>e.id===b),ue=te===``,de=ne===``,fe=O&&ue,pe=O&&de,me=!ue&&!de&&ce&&le&&R&&!re&&!ie&&!e;return(0,p.jsxs)(G,{noValidate:!0,onSubmit:e=>{e.preventDefault(),k(!0),me&&o({name:te,motivation:ne,groupId:h,teamId:v,projectId:b,parts:Number.isFinite(w)?Math.max(1,w):1,location:E,runType:S})},className:`form-horizontal`,children:[(0,p.jsxs)(rj,{title:`Details`,children:[(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-name`,children:[(0,p.jsxs)(G.Label,{column:!0,sm:3,children:[`Run name `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsx)(G.Control,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Give a run name`,required:!0,disabled:e,isInvalid:fe}),fe&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:`Run name is required.`}),(0,p.jsx)(G.Text,{muted:!0,children:`Give a short and descriptive name for the run`})]})]}),(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-location`,children:[(0,p.jsx)(G.Label,{column:!0,sm:3,children:`Sample location`}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsx)(G.Control,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`Location of the samples`,disabled:e}),(0,p.jsx)(G.Text,{muted:!0,children:`Give here the location where the run samples are stored`})]})]}),(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-motivation`,children:[(0,p.jsxs)(G.Label,{column:!0,sm:3,children:[`Motivation `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:3,value:u,onChange:e=>f(e.target.value),placeholder:`Why is this run being created?`,required:!0,disabled:e,isInvalid:pe}),pe&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:`Motivation is required.`}),(0,p.jsx)(G.Text,{muted:!0,children:`Explain here the motivation for this run`})]})]})]}),(0,p.jsxs)(rj,{title:`Organisation`,children:[O&&ie&&(0,p.jsx)(Cr,{variant:`warning`,children:`Could not load organisation values.`}),(0,p.jsx)(aj,{controlId:`create-run-group`,label:`Group`,options:ae,isLoading:M,value:h,onChange:_,showError:O&&!ce,disabled:e,helpText:`Select the group to which this run belongs`}),(0,p.jsx)(aj,{controlId:`create-run-team`,label:`Team`,options:oe,isLoading:F,value:v,onChange:y,showError:O&&!le,disabled:e,helpText:`Select the team to which this run belongs`}),(0,p.jsx)(aj,{controlId:`create-run-project`,label:`Project`,options:se,isLoading:ee,value:b,onChange:x,showError:O&&!R,disabled:e,helpText:`Select the project to which this run belongs`})]}),(0,p.jsx)(rj,{title:`Parts`,children:(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-parts`,children:[(0,p.jsx)(G.Label,{column:!0,sm:3,children:`Experimental split`}),(0,p.jsxs)(qr,{sm:9,children:[(0,p.jsx)(G.Control,{type:`number`,min:1,step:1,value:w,onChange:e=>T(Number(e.target.value)),disabled:e}),(0,p.jsx)(G.Text,{muted:!0,children:`Select here the amount of parts (experimental split) this run has, give only the main amount of parts, individual parts can be split later`})]})]})}),(0,p.jsx)(rj,{title:`Type`,children:(0,p.jsxs)(G.Group,{as:jl,className:`mb-3`,controlId:`create-run-type`,children:[(0,p.jsx)(G.Label,{column:!0,sm:3,children:`Run type`}),(0,p.jsx)(qr,{sm:9,children:(0,p.jsxs)(G.Select,{value:S,onChange:e=>C(e.target.value),disabled:e,children:[(0,p.jsx)(`option`,{value:pt.RESEARCH,children:`Research`}),(0,p.jsx)(`option`,{value:pt.PRODUCTION,children:`Production`})]})})]})}),(0,p.jsx)(jl,{className:`my-3`,children:(0,p.jsx)(qr,{sm:9,className:`offset-sm-3`,children:(0,p.jsx)(sj,{selectedRuns:n,selectedSubstrates:r,partIdsByRunId:i})})}),t&&(0,p.jsx)(Cr,{variant:`danger`,className:`mb-4`,children:t}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-end mt-4 gap-3`,children:[(0,p.jsx)(U,{variant:`outline-secondary`,type:`button`,onClick:a,disabled:e,children:`Back`}),(0,p.jsx)(U,{variant:`primary`,type:`submit`,disabled:e,children:e?`Creating...`:`Create Run`})]})]})}var lj=e=>{if(e instanceof Error&&e.message!==``)return e.message;if(typeof e==`object`&&e&&`response`in e&&typeof e.response==`object`&&e.response!==null){let t=e.response;if(typeof t.data?.message==`string`)return t.data.message;if(typeof t.data?.detail==`string`)return t.data.detail}return`Could not create the run.`},uj=e=>({value:e.id,label:`${e.label} — ${e.short_label}`,substrate:e}),dj=async e=>(await Xe({query:e||void 0})).items.map(uj),fj=Xb;function pj({selectedSubstrates:e,setSelectedSubstrates:t}){let n=e=>{t(t=>t.some(t=>t.substrate.id===e.id)?t:[...t,{substrate:e,amount:1}])},r=(e,n)=>{let r=Number.isFinite(n)?Math.max(0,n):0;t(t=>t.map(t=>t.substrate.id===e?{...t,amount:r}:t))},i=e=>{t(t=>t.filter(t=>t.substrate.id!==e))};return(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`h3`,{children:`Select substrate`}),(0,p.jsx)(qb,{isSearchable:!0,isClearable:!0,defaultOptions:!0,placeholder:`— Select a substrate, or start typing`,loadOptions:dj,value:null,styles:fj,onChange:e=>{e&&n(e.substrate)}}),e.length>0&&(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2 mt-3`,children:e.map(({substrate:e,amount:t})=>(0,p.jsxs)(`div`,{className:`d-flex flex-column gap-2 bg-body-secondary rounded p-2`,children:[(0,p.jsxs)(`div`,{className:`fw-semibold`,children:[e.label,` — `,e.short_label]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(U,{variant:`outline-danger`,size:`sm`,onClick:()=>i(e.id),"aria-label":`Deselect ${e.label}`,children:`Deselect`}),(0,p.jsx)(G.Control,{type:`number`,min:0,step:1,value:t,className:`flex-grow-1`,onChange:t=>r(e.id,Number(t.target.value)),"aria-label":`Amount for ${e.label}`})]})]},e.id))})]})}function mj(){let{environment:e}=(0,g.useParams)(),t=(0,g.useNavigate)(),n=(0,m.useQueryClient)(),[r,i]=(0,d.useState)(`parts`),[a,o]=(0,d.useState)([]),s=UA(),c=(0,m.useMutation)({mutationFn:async({runValues:e,parentRuns:t,substrates:n})=>{let r=await be({name:e.name,motivation:e.motivation,group_id:e.groupId,team_id:e.teamId,project_id:e.projectId,parts:e.parts,location:e.location||null,run_type:e.runType}),i=WA(r.id,t).map(e=>xe(e)),a=n.map(({substrate:e,amount:t})=>Se({run_id:r.id,substrate_id:e.id,amount:t}));return await Promise.all([...i,...a]),r},onSuccess:(r,i)=>{n.invalidateQueries({queryKey:[e]}),n.invalidateQueries({queryKey:[r.id]}),i.parentRuns.selectedRuns.forEach(e=>{n.invalidateQueries({queryKey:[e.id]})}),t(`/${e}/run/${r.id}/information.html`)}});return(0,p.jsxs)(`div`,{children:[r!==`details`&&(0,p.jsxs)($c,{variant:`tabs`,activeKey:r,onSelect:e=>{(e===`parts`||e===`substrate`)&&i(e)},className:`mb-4`,children:[(0,p.jsx)($c.Item,{children:(0,p.jsx)($c.Link,{eventKey:`parts`,children:`Parent run and parts`})}),(0,p.jsx)($c.Item,{children:(0,p.jsx)($c.Link,{eventKey:`substrate`,children:`Select Substrate`})})]}),(0,p.jsxs)(`div`,{className:`m-3`,children:[r===`parts`&&(0,p.jsx)(nj,{selection:s}),r===`substrate`&&(0,p.jsx)(pj,{selectedSubstrates:a,setSelectedSubstrates:o}),r===`details`&&(0,p.jsx)(cj,{isSubmitting:c.isPending,errorMessage:c.isError?lj(c.error):void 0,selectedRuns:s.selectedRuns,selectedSubstrates:a,partIdsByRunId:s.partIdsByRunId,onBack:()=>i(`parts`),onSubmit:e=>{c.mutate({runValues:e,parentRuns:s,substrates:a})}}),r!==`details`&&(0,p.jsx)(`div`,{className:`d-flex justify-content-end mt-4`,children:(0,p.jsx)(U,{variant:`primary`,disabled:c.isPending,onClick:()=>{i(`details`)},children:`Continue`})})]})]})}function hj(){let{environment:e}=(0,g.useParams)(),{run:t,reloadRun:n}=(0,d.useContext)(ok),r=(0,m.useQueryClient)(),i=UA(),a=(0,m.useMutation)({mutationFn:async e=>Promise.all(WA(t.id,e).map(e=>xe(e))),onSuccess:(i,a)=>{n(),r.invalidateQueries({queryKey:[e]}),r.invalidateQueries({queryKey:[t.id]}),a.selectedRuns.forEach(e=>{r.invalidateQueries({queryKey:[e.id]})})}});return(0,p.jsx)(`div`,{children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(nj,{selection:i,run:t}),(0,p.jsx)(`div`,{className:`d-flex justify-content-end mt-4`,children:(0,p.jsx)(U,{variant:`primary`,disabled:i.selectedRuns.length===0||a.isPending,onClick:()=>{i.selectedRuns.length>0&&a.mutate(i)},children:a.isPending?`Adding...`:`Add Parent Runs`})}),a.isSuccess&&a.data.length>0&&(0,p.jsxs)(Cr,{variant:`success`,className:`mt-3`,children:[`Parent runs added to `,t.label??`#${t.id}`,`.`]})]})})}function gj(){let{run:e}=(0,d.useContext)(ok),{environment:t}=(0,g.useParams)(),n=e.run_type===pt.RESEARCH,r=e.run_type===pt.PRODUCTION,i=n?`Research`:r?`Production`:String(e.run_type);return(0,p.jsxs)(`div`,{className:`row g-4 mt-1`,children:[(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-tag text-primary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Name`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.name??`—`}),`c`]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa ${n?`fa-flask text-info`:`fa-industry text-primary`} mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Run Type`}),(0,p.jsx)(`span`,{className:`badge ${n?`bg-info`:`bg-primary`}`,children:i})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-plus-o text-muted mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Created`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.date_created?new Date(e.date_created).toLocaleDateString():`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-certificate mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Status`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.status??`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-user-circle-o text-warning mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Responsible`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.responsible?.full_name??`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-play-circle-o text-success mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Start Date`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.start_date?new Date(e.start_date).toLocaleDateString():`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-briefcase text-secondary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Project`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.project?.name??`No project`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-tasks text-primary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Steps`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.amount_of_steps??`—`})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-clock-o text-muted mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Last Update`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.last_update?new Date(e.last_update).toLocaleDateString():`—`})]})]})}),e.priority&&(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-flag text-danger mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Priority`}),(0,p.jsx)(`span`,{className:`badge bg-danger`,children:e.priority.priority.code}),e.priority.description&&(0,p.jsx)(`div`,{className:`text-muted small mt-1`,children:e.priority.description})]})]})}),e.hold_code&&(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-ban text-danger mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Hold Code`}),(0,p.jsx)(`span`,{className:`badge bg-danger`,children:e.hold_code.hold_code.code}),e.hold_code.description&&(0,p.jsx)(`div`,{className:`text-muted small mt-1`,children:e.hold_code.description})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-users text-secondary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Team`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:(0,p.jsx)(g.Link,{to:`${bt()}${t}/organisation/team/details/${e.team.id}/responsible-users.html`,children:e.team?.name??`—`})})]})]})}),(0,p.jsx)(`div`,{className:`col-sm-4`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`i`,{className:`fa fa-object-group text-secondary mt-1`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-muted small`,children:`Group`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:(0,p.jsx)(g.Link,{to:`${bt()}${t}/organisation/group/details/${e.group.id}/responsible-users.html`,children:e.group?.name??`—`})})]})]})})]})}var _j=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};function vj(){let{run:e}=(0,d.useContext)(ok),[t,n]=(0,d.useState)([]),[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(!1),s=(0,m.useQueryClient)(),{environment:c}=(0,g.useParams)(),{data:l,isLoading:u}=(0,m.useQuery)({queryKey:[`run-files`,e.id],queryFn:()=>Ee({run:e}),enabled:!!e?.id}),f=l?.items??[],h=()=>{s.refetchQueries({queryKey:[`run-files`,e.id]})},{getRootProps:_,getInputProps:v,isDragActive:y,isDragAccept:b,isDragReject:x}=Hb({onDrop:e=>{n(t=>[...t,...e]),i(`${e.length} file(s) selected`)}}),S=(0,d.useMemo)(()=>({...y?{borderColor:`#83afee`}:{},...b?{borderColor:`#00e676`}:{},...x?{borderColor:`#ff1744`}:{}}),[b,x,y]),C=()=>{if(t.length===0)return;o(!0),i(`Uploading...`);let r=0,a=t.length,s=0;t.forEach(t=>{let c=new FileReader;c.onload=async()=>{let l=c.result;try{await Me({filename:t.name,type:t.type,content:l,run:e})}catch(e){s+=1,console.error(e)}finally{r+=1,r===a&&(o(!1),n([]),i(s===0?`Files uploaded successfully`:`Upload finished with ${s} error(s)`),h())}},c.readAsDataURL(t)})},w=async e=>{if(confirm(`Are you sure you want to delete ${e.name}? You can not undo this action`))try{await Ce({file:e}),h()}catch(e){console.error(e)}};return(0,p.jsxs)(`div`,{className:`mt-5`,children:[(0,p.jsxs)(`h3`,{className:`h5 mb-3`,children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip text-secondary me-2`,"aria-hidden":`true`}),`Files`]}),u?(0,p.jsxs)(Nl,{hover:!0,striped:!0,responsive:!0,className:`align-middle`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{style:{width:`3rem`},children:`No`}),(0,p.jsx)(`th`,{children:`File`}),(0,p.jsx)(`th`,{children:`Size`}),(0,p.jsx)(`th`,{children:`Date`}),(0,p.jsx)(`th`,{style:{width:`8rem`},className:`text-end`,children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:8})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:6})})}),(0,p.jsx)(`td`,{className:`text-end`,children:(0,p.jsx)(q,{as:`span`,animation:`glow`,children:(0,p.jsx)(q,{xs:10})})})]})})]}):f.length>0?(0,p.jsxs)(Nl,{hover:!0,striped:!0,responsive:!0,className:`align-middle`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{style:{width:`3rem`},children:`No`}),(0,p.jsx)(`th`,{children:`File`}),(0,p.jsx)(`th`,{children:`Size`}),(0,p.jsx)(`th`,{children:`Date`}),(0,p.jsx)(`th`,{style:{width:`8rem`},className:`text-end`,children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:f.map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t+1})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(g.Link,{to:`${bt()}/${c}/file/download/${e.id}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(wr,{className:`ms-2 bg-primary`,children:`Logging`})]}),(0,p.jsx)(`td`,{children:_j(e.size)}),(0,p.jsx)(`td`,{children:zD(e.date_created,`DD-MM-YY HH:mm`)}),(0,p.jsxs)(`td`,{className:`text-end`,children:[(0,p.jsx)(U,{size:`sm`,variant:`outline-primary`,className:`me-2`,onClick:()=>{window.location.href=`${bt()}/${c}/file/download/${e.id}`},"aria-label":`Download ${e.name}`,title:`Download`,children:(0,p.jsx)(`i`,{className:`fa fa-download`,"aria-hidden":`true`})}),(0,p.jsx)(U,{size:`sm`,variant:`outline-danger`,onClick:()=>w(e),"aria-label":`Delete ${e.name}`,title:`Delete`,children:(0,p.jsx)(`i`,{className:`fa fa-trash-o`,"aria-hidden":`true`})})]})]},e.id))})]}):(0,p.jsx)(`div`,{className:`text-muted fst-italic mb-3`,children:`No files uploaded yet`}),(0,p.jsxs)(`div`,{..._({style:S,className:`dropzone bg-secondary-subtle border rounded dz-clickable`}),children:[(0,p.jsx)(`input`,{...v()}),y?(0,p.jsx)(`p`,{children:`Drop files here...`}):(0,p.jsx)(`p`,{children:`Drag and drop files here or click to select`})]}),t.length>0&&(0,p.jsx)(nc,{className:`mt-3`,children:t.map(e=>(0,p.jsxs)(nc.Item,{className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsx)(`span`,{children:e.name}),(0,p.jsx)(`small`,{className:`text-muted`,children:_j(e.size)})]},`${e.name}-${e.lastModified}`))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(U,{className:`mt-3`,onClick:C,disabled:t.length===0||a,children:a?`Uploading...`:`Upload Selected Files`}),r&&(0,p.jsx)(`p`,{className:`mt-2 text-muted small`,children:r})]})]})}function yj(){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run information`}),(0,p.jsx)(gj,{}),(0,p.jsx)(vj,{})]})}var bj=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t.id))},xj=e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`};function Sj({step:e,tray:t,parts:n,stepParts:r}){let i=(0,m.useQueryClient)(),a=t.tray_type,o=t.label?`${t.name} - ${t.label}`:t.name,s=(0,d.useMemo)(()=>new Map(n.map(e=>[e.id,e])),[n]),c=(0,d.useMemo)(()=>new Map(r.map(e=>[e.id,e])),[r]),l=async(t,n,o,l)=>{t.preventDefault();let u=Number(t.dataTransfer.getData(`text/plain`)),d=c.get(u);if(!d){console.error(`Unable to update run step part tray: stepPart not found`);return}if(a&&(a.forbidden_slots??[]).some(e=>e.x===l&&e.y===o))return;let f=s.get(d.part_id);if((d.tray_id??f?.tray?.id)===n.id&&(d.tray_column??f?.tray_column)===l&&(d.tray_row??f?.tray_row)===o)return;if(r.find(t=>{if(t.id===d.id||t.step_id!==e.id||t.has_failed_in_previouse_state||t.failed)return!1;let r=s.get(t.part_id);return(t.tray_id??r?.tray?.id)===n.id&&(t.tray_row??r?.tray_row)===o&&(t.tray_column??r?.tray_column)===l})){Jk({notificationHeader:`Tray part change`,notificationBody:`This position is occupied by a part that has not failed in this or a previous step.`,notificationType:`danger`});return}let p={...d,tray_id:n.id,tray_row:o,tray_column:l};Rk(i,e,p);try{let t=await ze(d,n,o,l,!0);Rk(i,e,t.data,{updateSubsequent:!0}),Jk({notificationHeader:`Tray part change`,notificationBody:`Part moved successfully`,notificationType:`success`})}catch(t){Rk(i,e,d),Jk({notificationHeader:`Tray part change`,notificationBody:Tj(t),notificationType:`danger`})}};if(!a?.rows||!a?.columns)return(0,p.jsx)(`section`,{className:`tray-visual my-2`,"aria-label":t.name,children:`TODO HANDLE CASE WHERE TRAY TYPE IS WRONG`});let u=a.rows*a.columns,f={"--tray-rows":a.rows,"--tray-columns":a.columns},h=new Set((a.forbidden_slots??[]).map(e=>Cj(a,e.y,e.x)).filter(e=>e!==null)),g=Array.from({length:u},()=>null);return r.forEach(e=>{let t=s.get(e.part_id);if(!t)return;let n=Cj(a,e.tray_row??t.tray_row,e.tray_column??t.tray_column);if(n===null){console.log(e);return}if(e.has_failed_in_previouse_state)return;let r=Ej(e),i=g[n],o=i?Ej(i):null;o!==null&&o<r||(g[n]=e)}),(0,p.jsxs)(`section`,{className:`tray-visual my-2`,style:f,"aria-label":t.name,children:[(0,p.jsx)(`h4`,{className:`h6 mb-2`,children:o}),(0,p.jsx)(`div`,{className:`tray-visual__frame`,children:(0,p.jsx)(`div`,{className:`tray-visual__grid`,"data-orientation":a.orientation===`ttb`?`ttb`:`ltr`,children:g.map((e,n)=>{let r=n+1,{row:i,column:o}=wj(a,n),c=e?s.get(e.part_id):null,u=Dj(e),d=Oj(e);return h.has(n)?(0,p.jsx)(`div`,{className:`tray-visual__pocket`,"aria-hidden":`true`},`${t.id}-${r}`):(0,p.jsx)(`div`,{className:`tray-visual__pocket`,children:(0,p.jsx)(`div`,{className:`tray-visual__slot`,"data-tray-id":t.id,"data-tray-row":i,"data-tray-column":o,"data-pocket-number":r,onDragOver:xj,onDrop:e=>l(e,t,i,o),children:c&&e?(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-tray-slot-part-${e.id}`,children:d}),children:(0,p.jsx)(`span`,{className:`tray-visual__part badge ${u} badge-level-${c.part_level}`,"data-part-id":c.id,"data-step-part-id":e.id,draggable:!0,onDragStart:t=>bj(t,e),children:c.scanner_label})},e.id):(0,p.jsx)(`span`,{className:`tray-visual__index`,children:r})})},`${t.id}-${r}`)})})})]})}var Cj=(e,t,n)=>!t||!n||t<1||n<1||t>e.rows||n>e.columns?null:e.orientation===`ttb`?(n-1)*e.rows+(t-1):(t-1)*e.columns+(n-1),wj=(e,t)=>e.orientation===`ttb`?{row:t%e.rows+1,column:Math.floor(t/e.rows)+1}:{row:Math.floor(t/e.columns)+1,column:t%e.columns+1},Tj=e=>{if(typeof e==`object`&&e&&`response`in e){let t=e.response;if(typeof t?.data?.detail==`string`&&t.data.detail!==``)return t.data.detail;if(typeof t?.data?.message==`string`&&t.data.message!==``)return t.data.message}return e instanceof Error&&e.message!==``?e.message:`Could not move part.`},Ej=e=>e.tray_id!=null&&!e.failed?1:e.tray_id==null?3:2,Dj=e=>e?.failed?`bg-danger`:e?.tray_id?`bg-primary`:`bg-grey`,Oj=e=>e?.failed?`Part failed`:e==null?`In default postion`:e.tray_id==null?`In default position`:`Not in default postion`,kj=({step:e,parts:t,stepParts:n,run:r})=>{let i=(0,d.useMemo)(()=>[...r.run_trays??[]].sort((e,t)=>e.sequence-t.sequence),[r]),a=(0,d.useMemo)(()=>n.filter(t=>t.step_id===e.id),[n,e.id]),o=(0,d.useMemo)(()=>t.filter(t=>t.part_level===e.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),[t]),s=(0,d.useMemo)(()=>DA(o,a),[o,a]);return i.length===0||o[0]?.part_level>0?(0,p.jsx)(OA,{step:e,parts:t,stepParts:n,run:r}):(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-4`,children:i.map(t=>(0,p.jsx)(Sj,{step:e,tray:t,parts:s.get(t.id)??[],stepParts:a},t.id))})};function Aj({step:e,parts:t,run:n}){let{environment:r}=(0,g.useParams)(),[i]=(0,m.useQueries)({queries:[{queryKey:[`runStepParts`,e.id],queryFn:()=>Re({step:e}),placeholderData:m.keepPreviousData}]}),a=(0,d.useMemo)(()=>i.data?.items??[],[i.data?.items]),o=(0,d.useMemo)(()=>t.filter(t=>t.part_level===e.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),[t]);return(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsxs)(g.Link,{to:`/${r}/operator/run/step/${e.id}`,children:[` `,(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.name}})]})}),(0,p.jsx)(`td`,{children:i.isLoading?(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(kj,{step:e,parts:o,stepParts:a,run:n})})]})}var jj=e=>(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:2,style:{margin:0},className:`bg-info`,children:(0,p.jsx)(`span`,{children:e.step_group?.label})})});function Mj(){let{run:e}=(0,d.useContext)(ok),[t,n]=(0,d.useState)(1),[r]=(0,d.useState)(25),[i,a]=(0,d.useState)(new Map),o=(0,m.useQueries)({queries:[{queryKey:[`runSteps`,JSON.stringify(e),t],queryFn:()=>Ae({run:e,page:t,pageSize:r}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>ke({run:e})}]}),[s,c]=o,l=o.some(e=>e.isLoading),u=o.some(e=>e.isError),f=(0,d.useMemo)(()=>s.data?.items??[],[s.data?.items]),h=(0,d.useMemo)(()=>c.data?.items??[],[c.data?.items]);(0,d.useEffect)(()=>{a(e=>{let t=new Map(e);return f.forEach(e=>{let n=e.label?.id;n!==void 0&&!t.has(n)&&t.set(n,!0)}),t})},[f]),(0,d.useEffect)(()=>{u&&o.forEach((t,n)=>{t.isError&&console.error(`RunLayoutElement query error`,{index:n,error:t.error,run:e})})},[u,o,e]);let g=new Set,_=f.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||g.has(String(e.step_group.id))?!1:(g.add(String(e.step_group.id)),!0)),v=e=>{a(t=>{let n=new Map(t);return n.set(e,!n.get(e)),n})},y=e=>{let t=e.label,n=t?.id;return!e.is_own_label||!t||n===void 0?null:(0,p.jsx)(`tr`,{style:{cursor:`pointer`},onClick:()=>v(n),children:(0,p.jsx)(`td`,{colSpan:2,style:{margin:0},className:`bg-secondary`,children:(0,p.jsxs)(`span`,{className:`label-toggle`,children:[(0,p.jsx)(`i`,{className:`fa `+(i.get(e.label?.id??-1)?`fa-caret-down`:`fa-caret-right`)}),` `,t.label]})})})};return l?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run layout edit`}),(0,p.jsxs)(Nl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Step`}),(0,p.jsx)(`th`,{children:`Parts`})]})}),(0,p.jsx)(`tbody`,{children:[1,2].map(e=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:2,className:`bg-info`,children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`span`,children:(0,p.jsx)(q,{style:{width:`4rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(q,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(q,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))})})]})]},e))})]})]}):u?(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run layout.`}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run layout edit`}),(0,p.jsxs)(Nl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Step`}),(0,p.jsx)(`th`,{children:`Parts`})]})}),(0,p.jsx)(`tbody`,{children:f.map(t=>(0,p.jsxs)(d.default.Fragment,{children:[t.has_label&&y(t),(!t.has_label||!!i.get(t.label?.id??-1))&&(0,p.jsxs)(p.Fragment,{children:[t.has_step_group&&_.includes(t)&&jj(t),(0,p.jsx)(Aj,{step:t,parts:h,run:e},`step-${t.id}`)]})]},`step-${t.id}`))})]}),(0,p.jsx)(GO,{data:s.data,setPage:n,isPlaceholderData:s.isPlaceholderData})]})}var Nj=()=>{let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(null),{id:i}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||i!==e.id.toString())&&Te({id:parseInt(i)}).then(e=>(we({id:e.run_id}).then(r),e)).then(t)},[i,e]);function a(){Te({id:parseInt(i)}).then(e=>(we({id:e.run_id}).then(r),e)).then(t)}return{run:n,runStep:e,setRunStep:t,reloadRunStep:a}};function Pj({children:e}){let{runStep:t,setRunStep:n,run:r,reloadRunStep:i}=Nj(),[a,o]=(0,d.useState)({});if(t===null||r===null){let e=`Loading run...`;return t===null&&r===null?e=`Loading run and run step...`:r===null&&(e=`Loading run step...`),(0,p.jsx)(Ot,{children:(0,p.jsx)(Ct,{message:e})})}return(0,p.jsx)(Ot,{children:(0,p.jsx)(jA.Provider,{value:{runStep:t,setRunStep:n,reloadRunStep:i,run:r,modalProperties:a,setModalProperties:o},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}function Fj(){return(0,p.jsx)(Pj,{children:(0,p.jsx)(Jr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})})}var Ij=({label:e})=>(0,p.jsx)(`div`,{className:`p-2 h4 mb-1 bg-info text-white`,children:e.label}),Lj=({runStep:e})=>{let{environment:t}=(0,g.useParams)();return(0,p.jsxs)(`h2`,{children:[` `,e.number,` -`,e.process_module.process.name,` on`,` `,(0,p.jsxs)(g.Link,{to:`/${t}/operator/equipment/${e.process_module.module.equipment?.id}`,children:[e.process_module.module.equipment?.name,` (`,e.process_module.module.name,`)`]})]})},Rj=({checklistItem:e,show:t,setModalShow:n,mutation:r})=>(0,p.jsxs)(K,{show:t,size:`lg`,onHide:()=>n(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Checklist item`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsx)(`h2`,{children:e.task}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.description}})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{className:`float-end`,variant:`primary`,onClick:()=>{r.mutate()},children:`Done`}),(0,p.jsx)(U,{variant:`secondary`,onClick:()=>n(!1),children:`Close`})]})]});function zj({checklistItem:e,onOpenModal:t,onMarkDone:n}){return e.can_finish?e.description===``?(0,p.jsx)(U,{className:`float-end`,size:`sm`,variant:`success`,onClick:n,children:`Done checklist step`}):(0,p.jsx)(U,{className:`float-end`,variant:`primary`,onClick:t,children:`Execute checklist step`}):null}var Bj=({checklistItem:e,refetch:t})=>{let[n,r]=(0,d.useState)(!1),i=(0,m.useMutation)({mutationFn:async()=>(await f.default.create().patch(`update/run/step/checklist/done/`+e.id,{})).data,onSuccess:e=>{r(!1),t()}});return(0,p.jsxs)(nc.Item,{disabled:e.is_executed,className:`d-flex justify-content-between align-items-start`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[e.task,e.is_executed&&(0,p.jsxs)(`small`,{children:[`Executed on `,(0,p.jsx)(lk,{format:`DD-MM-YYYY`,children:e.date_executed})]})]}),(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(zj,{checklistItem:e,onOpenModal:()=>r(!0),onMarkDone:()=>i.mutate()})}),(0,p.jsx)(Rj,{checklistItem:e,show:n,setModalShow:r,mutation:i})]})},Vj={movingOut:`Moving out...`,skipping:`Skipping...`,unskipping:`Unskipping...`,operationFinished:`Operation finished`,operationSkipped:`Operation skipped`,operationUnskipped:`Operation unskipped`};function Hj({run:e,runStep:t,reloadRunStep:n}){let r=(0,g.useNavigate)(),{environment:i}=(0,g.useParams)(),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),{run:l,runStep:u,reloadRunStep:h}=(0,d.useContext)(jA);(0,d.useEffect)(()=>{if(a){let e=setTimeout(()=>{o(null)},3e3);return()=>clearTimeout(e)}},[a]);let _=e??l,v=t??u,y=n??h??(()=>null),{data:b,error:x,isLoading:S,refetch:C}=(0,m.useQuery)({queryKey:[`checklist`,v?.id],queryFn:()=>Pe({runStep:v}),enabled:!!v}),w=(0,d.useCallback)(async e=>{o(Vj.movingOut),c(!0);try{let t=await Fe(e);o(Vj.operationFinished),t.data.next_step_id===null?y():r(`/${i}/operator/run/step/${t.data.next_step_id}`)}finally{c(!1)}},[i,r,y]),T=(0,d.useCallback)(async e=>{o(Vj.skipping),c(!0);try{await f.default.create().patch(`update/run/step/skip/${e.id}`,{}),o(Vj.operationSkipped),y()}finally{c(!1)}},[y]),E=(0,d.useCallback)(async e=>{o(Vj.unskipping),c(!0);try{await f.default.create().patch(`update/run/step/un-skip/${e.id}`,{}),o(Vj.operationUnskipped),y()}finally{c(!1)}},[y]),{checklistItems:D,canFinishOperation:O}=(0,d.useMemo)(()=>{let e=b?.items??[],t=e.findIndex(e=>!e.is_executed);return{checklistItems:e.map((e,n)=>({...e,can_finish:n===t})),canFinishOperation:!!(v&&!v.is_finished&&t===-1)}},[b,v]);return!v||!_?(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext in RunStepChecklist`}):S?(0,p.jsx)(Ct,{message:`Loading...`}):x?(0,p.jsx)(Cr,{variant:`danger`,children:`Failed to load checklist.`}):(0,p.jsxs)(p.Fragment,{children:[D.length===0&&(0,p.jsx)(Cr,{variant:`info`,children:`No checklist found`}),D.length>0&&(0,p.jsx)(nc,{children:D.map(e=>(0,p.jsx)(Bj,{checklistItem:e,refetch:C},e.id))}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mt-3`,children:[(0,p.jsxs)(`div`,{className:`d-flex gap-2 align-items-center`,children:[O&&(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`success`,onClick:()=>w(v),disabled:s,children:a===Vj.operationFinished||a===Vj.movingOut?a:`Move out`})}),_.access.edit&&!v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`primary`,onClick:()=>T(v),disabled:s,children:a===Vj.operationSkipped||a===Vj.skipping?a:`Skip operation`})}),_.access.edit&&v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`warning`,onClick:()=>E(v),disabled:s,children:a===Vj.operationUnskipped||a===Vj.unskipping?a:`Unskip operation`})})]}),(0,p.jsx)(`div`,{className:`d-flex gap-2`,children:v.next_step_id&&(0,p.jsx)(`div`,{children:(0,p.jsx)(g.Link,{to:`/${i}/operator/run/step/${v.next_step_id}`,className:`btn btn-secondary`,children:`Next step`})})})]})]})}var Uj=()=>void 0;function Wj({runStep:e,reloadRunStep:t,title:n=`Remark`,titleClassName:r=`mb-2 text-start`}){let{runStep:i,setRunStep:a}=(0,d.useContext)(jA),o=e??i,s=t?()=>t():e?Uj:a??Uj,[c,l]=(0,d.useState)(!1),u=o?!o.is_finished:!1,m=!!o?.remark?.trim(),{register:h,handleSubmit:g,formState:_,reset:v}=Id({defaultValues:{remark:o?.remark_unparsed??``}}),{isSubmitting:y}=_;(0,d.useEffect)(()=>{v({remark:o?.remark_unparsed??``})},[v,o?.remark_unparsed]);let b=(0,d.useCallback)(async e=>{if(!o)return;await f.default.patch(`update/run/step/`+o.id,{remark:e.remark});let t=await f.default.get(`view/run/step/`+o.id);s({...o,remark:t.data.remark,remark_unparsed:t.data.remark_unparsed}),l(!1)},[o,s]);return o?!c||!u?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:r,children:n}),!m&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-muted`,children:`No remark.`}),u&&(0,p.jsx)(U,{variant:`primary`,className:`ms-auto`,size:`sm`,onClick:()=>l(!0),children:`Add remark`})]}),m&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-success`,dangerouslySetInnerHTML:{__html:o.remark}}),` `,u&&(0,p.jsx)(U,{variant:`primary`,className:`mt-3`,onClick:()=>l(!0),children:`Edit remark`})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{className:r,children:n}),(0,p.jsxs)(G,{onSubmit:g(b),children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:6,...h(`remark`)}),(0,p.jsx)(`p`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:`If a non-conformity happens, note it here`})}),(0,p.jsxs)(U,{variant:`primary`,type:`submit`,disabled:y,children:[y&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Save remark`]}),(0,p.jsx)(U,{variant:`secondary`,className:`ms-2`,onClick:()=>l(!1),children:`Cancel`})]})]}):(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext for StepRemark`})}var Gj=(e,t)=>{f.default.get(`list/run/hold-code`).then(e=>{let{data:t}=e;return t._embedded.items}).then(e=>{t(e.map(e=>({value:e.id,label:e.code})))})},Kj=({run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})=>{let[a,o]=d.default.useState(!1),{register:s,control:c,setValue:l,handleSubmit:u,formState:m}=Id({defaultValues:{holdCode:r?{value:r.hold_code.id,label:r.hold_code.code}:{},description:r?r.description:``}}),{errors:h,isSubmitting:g}=m;return(0,p.jsx)(K,{show:t,size:`lg`,onHide:()=>n(!1),children:(0,p.jsxs)(G,{onSubmit:u(async t=>{try{let n=await f.default.patch(`update/run/hold-code/`+e.id,{holdcode:a?null:t.holdCode.value,description:t.description});n.data.hold_code?i(n.data):i(void 0),o(!1)}finally{n(!1)}}),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:a?`Reset hold code`:`Update hold code`})}),(0,p.jsxs)(K.Body,{children:[!a&&(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Hold code`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(wu,{name:`holdCode`,control:c,rules:{validate:{required:e=>e.value!==void 0||a||`A hold code is required`}},render:({field:e})=>(0,p.jsx)(qb,{isSearchable:!1,defaultOptions:!0,placeholder:`— Select a hold code`,loadOptions:Gj,value:e.value,onChange:t=>{e.onChange(t)}})}),h.holdCode&&(0,p.jsx)(`span`,{className:`text-danger`,children:h.holdCode.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`holdCodeDescription`,className:`col-sm-3 col-form-label text-end`,children:`Message`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:3,id:`holdCodeDescription`,...s(`description`,{required:`A message is required`}),isInvalid:h.description!==void 0}),h.description&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:h.description.message})]})]})]}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsxs)(U,{type:`submit`,variant:a?`success`:`primary`,disabled:g,children:[g&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),a?`Release lot`:`Update Hold code`]}),r&&(0,p.jsx)(U,{variant:`outline-danger`,onClick:()=>{l(`description`,a?r.description:``),o(!a)},children:a?`Update hold Code`:`Reset hold code`})]})]})})},qj=()=>{let{run:e}=(0,d.useContext)(jA),[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(e.hold_code),a=()=>{n(!0)};return(0,p.jsxs)(p.Fragment,{children:[r&&(0,p.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`Edit hold code`,className:`badge handle`,style:{backgroundColor:r.hold_code.back_color,color:r.hold_code.front_color,fontSize:`1.5rem`,cursor:`pointer`},onClick:()=>a(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},children:r.hold_code.code}),!r&&(0,p.jsx)(wr,{bg:`secondary`,className:`handle`,onClick:()=>a(),style:{fontSize:`1.5rem`,cursor:`pointer`},children:`No hold code`}),(0,p.jsx)(Kj,{run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})]})},Jj=()=>{let{run:e}=(0,d.useContext)(jA),[t,n]=(0,d.useState)(e.priority);return(0,p.jsxs)(d.default.Fragment,{children:[t&&(0,p.jsx)(`span`,{className:`badge`,style:{backgroundColor:t.priority.back_color,color:t.priority.front_color,fontSize:`1.5rem`},children:t.priority.code}),!t&&(0,p.jsx)(`span`,{className:`badge bg-info`,style:{fontSize:`1.5rem`},children:`NORMAL`})]})},Yj=({run:e,runStep:t,showOnlyEmphasizedParameters:n})=>(0,p.jsx)(`div`,{className:`border rounded px-3 py-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsx)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:(0,p.jsx)(oA,{run:e,runStep:t})}),(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[n&&(0,p.jsx)(`h4`,{children:`Emphasized parameters`}),!n&&(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(gk,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:n})]})]})}),Xj=({run:e,monitoredBy:t,runStep:n,runParts:r,runStepParts:i,hideLabel:a,firstInGroup:o})=>{let{environment:s}=(0,g.useParams)(),[c,l]=(0,d.useState)(!1),{runStep:u}=(0,d.useContext)(jA);return(0,p.jsxs)(p.Fragment,{children:[!a&&n.has_label&&n.is_own_label&&(0,p.jsx)(`div`,{className:`bg-info text-white rounded px-3 py-1`,children:n.label?.label}),n.step_group&&o&&(0,p.jsx)(`div`,{className:`bg-secondary text-white rounded px-3 py-1`,children:n.step_group?.label}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 border rounded px-3 py-2 ${n.has_step_group?`ms-4`:``}`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2 flex-shrink-0`,children:[n.id!==u.id&&(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":c?`Collapse details`:`Expand details`,className:`fa `+(c?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:()=>{l(!c)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l(!c))}}),n.id===u.id&&(0,p.jsx)(`i`,{className:`fa fa-chevron-right text-success`,style:{cursor:`pointer`},title:`This step is currently running`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 flex-grow-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(OA,{step:n,parts:r,stepParts:i,run:e})}),(0,p.jsxs)(`div`,{className:`flex-shrink-0 text-nowrap`,children:[n.number,` `,n.is_skipped&&(0,p.jsx)(wr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(g.Link,{to:`/${s}/operator/run/step/${n.id}`,dangerouslySetInnerHTML:{__html:n.name}}),` `,t&&(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-${t.id}`,children:`Monitored by step: ${t.step.number}`}),children:(0,p.jsx)(`i`,{className:`fa fa-search me-2`})})]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-3 flex-shrink-0 ms-auto`,children:[(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.finish_user?n.finish_user.initials:``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.has_rework?(0,p.jsx)(`span`,{className:`badge bg-primary`,children:`Rework`}):``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.is_finished?(0,p.jsx)(lk,{format:`DD-MM-YYYY`,children:n.finish_date}):``})]})]}),c&&(0,p.jsx)(Yj,{run:e,runStep:n,showOnlyEmphasizedParameters:!1})]})};function Zj({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i}){let a=n.filter(t=>t.step_id===(e.requirement_for_step?.id??e.step.id)),{environment:o}=(0,g.useParams)();return(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(`div`,{className:`border rounded px-3 py-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[(0,p.jsx)(`h4`,{children:`Measurement results`}),(0,p.jsx)(MA,{requirement:e,step:t,stepParts:a,parts:r,measurementResults:i,editOnly:!0})]}),(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[(0,p.jsx)(`h4`,{children:`Monitored Step`}),(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${e.requirement_for_step?.id??e.step.id}`,children:(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-search`}),` `,e.requirement_for_step?.name??e.step.name]})}),(0,p.jsx)(`h4`,{children:`Definition`}),(0,p.jsx)(`span`,{children:e.definition}),(0,p.jsx)(`h4`,{children:`Targets`}),(0,p.jsxs)(Nl,{size:`sm`,striped:!1,bordered:!1,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`min value`}),(0,p.jsx)(`th`,{children:`max value`}),(0,p.jsx)(`th`,{children:`inclusive`})]})}),(0,p.jsx)(`tbody`,{children:e.targets.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.min_value}),(0,p.jsx)(`td`,{children:e.max_value}),(0,p.jsx)(`td`,{children:e.inclusive?`yes`:`no`})]},e.id))})]})]})]})})})}function Qj({requirement:e,runParts:t,runStepParts:n,hideLabel:r,firstInGroup:i}){let a=e.step,{environment:o}=(0,g.useParams)(),{runStep:s}=(0,d.useContext)(jA),[c,l]=(0,d.useState)(!1),[u]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Ne({measurement:e.measurement})}]});return(0,p.jsxs)(p.Fragment,{children:[!r&&a.has_label&&a.is_own_label&&(0,p.jsx)(`div`,{className:`bg-info text-white rounded px-3 py-1`,children:a.label?.label}),a.step_group&&i&&(0,p.jsx)(`div`,{className:`bg-secondary text-white rounded px-3 py-1`,children:a.step_group?.label}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 border rounded px-3 py-2 ${(()=>{if(!u.data)return``;let t=new Map;for(let e of u.data.items)for(let n of e.values)n.step_part_id!==void 0&&n.step_part_id!==null&&t.set(n.step_part_id,n);let r=!1;for(let i of n){let n=t.get(i.id);if(!(n&&!isNaN(parseFloat(n.string_value))))return a.id===s.id?`bg-success-subtle`:``;let o=parseFloat(n.string_value);if(e.targets.some(e=>e.inclusive?!(e.min_value<=o&&e.max_value>=o):!(e.min_value<o&&e.max_value>o))){r=!0;break}}return r?`bg-danger-subtle`:a.id===s.id?`bg-success-subtle`:``})()} ${a.has_step_group?`ms-4`:``}`,children:[(0,p.jsx)(`div`,{className:`d-flex align-items-center gap-2 flex-shrink-0`,children:a.id!==s.id&&(0,p.jsx)(`i`,{role:`button`,tabIndex:0,"aria-label":c?`Collapse details`:`Expand details`,className:`fa `+(c?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:()=>{l(!c)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l(!c))}})}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 flex-grow-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(FA,{requirement:e,step:a,parts:t,stepParts:n,measurementResults:u.data?.items??[]})}),(0,p.jsxs)(`div`,{className:`flex-shrink-0 text-nowrap`,children:[a.number,` `,a.is_skipped&&(0,p.jsx)(wr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(wr,{bg:`info`,children:`requirement`}),` `,(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${a.id}`,dangerouslySetInnerHTML:{__html:a.name}}),` `]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-3 flex-shrink-0 ms-auto`,children:[(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.finish_user?a.finish_user.initials:``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.has_rework?(0,p.jsx)(`span`,{className:`badge bg-primary`,children:`Rework`}):``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.is_finished?(0,p.jsx)(lk,{format:`DD-MM-YYYY`,children:a.finish_date}):``})]})]}),c&&(0,p.jsx)(Zj,{requirement:e,step:a,stepParts:n,parts:t,measurementResults:u.data?.items??[]})]})}var $j=({pageSize:e=25,hideLabel:t=!1})=>{let{runStep:n,run:r}=(0,d.useContext)(jA),[i,a]=(0,d.useState)(1);(0,d.useEffect)(()=>{n?.sequence&&a(Math.max(1,Math.ceil(n.sequence/e)))},[n?.sequence,e]);let o=r?.id??null,{data:s,error:c,isError:l,isLoading:u}=(0,m.useQuery)({queryKey:[`runParts`,`${o}`],queryFn:()=>ke({run:r}),enabled:!!o}),{data:f,error:h,isError:g,isLoading:_}=(0,m.useQuery)({queryKey:[`runStepParts`,`${o}`],queryFn:()=>Re({run:r}),enabled:!!o}),{data:v,error:y,isError:b,isFetching:x,isLoading:S,isPlaceholderData:C}=(0,m.useQuery)({queryKey:[`runSteps`,o,i,e],queryFn:()=>Ae({run:r,page:i,pageSize:e}),enabled:!!o,placeholderData:m.keepPreviousData}),{data:w,error:T,isError:E,isLoading:D}=(0,m.useQuery)({queryKey:[`requirements`,o],queryFn:()=>De({run:r}),enabled:!!o,placeholderData:m.keepPreviousData}),O=u||_||S||D,k=l||g||b||E,A=c||h||y||T,j=s?.items??[],M=f?.items??[],N=v?.items??[],P=w?.items??[],F=new Set,I=N.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||F.has(String(e.step_group.id))?!1:(F.add(String(e.step_group.id)),!0)),L={};for(let e of P)e.requirement_for_step!=null&&(L[String(e.requirement_for_step.id)]=e);return d.default.useEffect(()=>{k&&console.error(`RunStepSimpleList query error`,{runId:o,errors:[c,h,y,T]})},[k,o,c,h,y,T]),(0,p.jsxs)(`div`,{children:[O?(0,p.jsx)(`div`,{children:`Loading...`}):k?(0,p.jsxs)(`div`,{children:[`Error: `,String(A?.message??A)]}):(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:N.map((e,n)=>(0,p.jsx)(d.default.Fragment,{children:e.has_requirement?(0,p.jsx)(Qj,{requirement:P.find(t=>t.step.id===e.id),runParts:j,runStepParts:M,firstInGroup:I.includes(e)},e.id??e.sequence??n):(0,p.jsx)(Xj,{run:r,monitoredBy:L[e.id],runParts:j,runStepParts:M,hideLabel:t,firstInGroup:I.includes(e),runStep:e},e.id??e.sequence??n)},n))}),(0,p.jsx)(GO,{data:v,setPage:a,isPlaceholderData:C}),x?(0,p.jsx)(`span`,{children:` Loading...`}):null]})};function eM(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tM(e){if(Array.isArray(e))return e}function nM(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function rM(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
31
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function iM(e,t){return tM(e)||nM(e,t)||aM(e,t)||rM()}function aM(e,t){if(e){if(typeof e==`string`)return eM(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?eM(e,t):void 0}}var oM=Object.entries,sM=Object.setPrototypeOf,cM=Object.isFrozen,lM=Object.getPrototypeOf,uM=Object.getOwnPropertyDescriptor,dM=Object.freeze,fM=Object.seal,pM=Object.create,mM=typeof Reflect<`u`&&Reflect,hM=mM.apply,gM=mM.construct;dM||(dM=function(e){return e}),fM||(fM=function(e){return e}),hM||(hM=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)}),gM||(gM=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)});var _M=LM(Array.prototype.forEach),vM=LM(Array.prototype.lastIndexOf),yM=LM(Array.prototype.pop),bM=LM(Array.prototype.push),xM=LM(Array.prototype.splice),SM=Array.isArray,CM=LM(String.prototype.toLowerCase),wM=LM(String.prototype.toString),TM=LM(String.prototype.match),EM=LM(String.prototype.replace),DM=LM(String.prototype.indexOf),OM=LM(String.prototype.trim),kM=LM(Number.prototype.toString),AM=LM(Boolean.prototype.toString),jM=typeof BigInt>`u`?null:LM(BigInt.prototype.toString),MM=typeof Symbol>`u`?null:LM(Symbol.prototype.toString),NM=LM(Object.prototype.hasOwnProperty),PM=LM(Object.prototype.toString),FM=LM(RegExp.prototype.test),IM=RM(TypeError);function LM(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return hM(e,t,r)}}function RM(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return gM(e,n)}}function zM(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:CM;if(sM&&sM(e,null),!SM(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(cM(t)||(t[r]=e),i=e)}e[i]=!0}return e}function BM(e){for(let t=0;t<e.length;t++)NM(e,t)||(e[t]=null);return e}function VM(e){let t=pM(null);for(let r of oM(e)){var n=iM(r,2);let i=n[0],a=n[1];NM(e,i)&&(SM(a)?t[i]=BM(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=VM(a):t[i]=a)}return t}function HM(e){switch(typeof e){case`string`:return e;case`number`:return kM(e);case`boolean`:return AM(e);case`bigint`:return jM?jM(e):`0`;case`symbol`:return MM?MM(e):`Symbol()`;case`undefined`:return PM(e);case`function`:case`object`:{if(e===null)return PM(e);let t=e,n=UM(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:PM(e)}return PM(e)}default:return PM(e)}}function UM(e,t){for(;e!==null;){let n=uM(e,t);if(n){if(n.get)return LM(n.get);if(typeof n.value==`function`)return LM(n.value)}e=lM(e)}function n(){return null}return n}function WM(e){try{return FM(e,``),!0}catch{return!1}}var GM=dM(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),KM=dM(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),qM=dM([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),JM=dM([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),YM=dM(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),XM=dM([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),ZM=dM([`#text`]),QM=dM(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),$M=dM(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),eN=dM(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),tN=dM([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),nN=fM(/{{[\w\W]*|^[\w\W]*}}/g),rN=fM(/<%[\w\W]*|^[\w\W]*%>/g),iN=fM(/\${[\w\W]*/g),aN=fM(/^data-[\-\w.\u00B7-\uFFFF]+$/),oN=fM(/^aria-[\-\w]+$/),sN=fM(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cN=fM(/^(?:\w+script|data):/i),lN=fM(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),uN=fM(/^html$/i),dN=fM(/^[a-z][.\w]*(-[.\w]+)+$/i),fN=fM(/<[/\w!]/g),pN=fM(/<[/\w]/g),mN=fM(/<\/no(script|embed|frames)/i),hN=fM(/\/>/i),gN={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_N=function(){return typeof window>`u`?null:window},vN=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},yN=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},bN=function(e,t,n,r){return NM(e,t)&&SM(e[t])?zM(r.base?VM(r.base):{},e[t],r.transform):n};function xN(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_N(),t=e=>xN(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==gN.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=UM(d,`cloneNode`),p=UM(d,`remove`),m=UM(d,`nextSibling`),h=UM(d,`childNodes`),g=UM(d,`parentNode`),_=UM(d,`shadowRoot`),v=UM(d,`attributes`),y=o&&o.prototype?UM(o.prototype,`nodeType`):null,b=o&&o.prototype?UM(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,w=!1,T=0,E=function(){if(T>0)throw IM(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},D=function(e){E(),T++;try{return x.createHTML(e)}finally{T--}},O=function(e){E(),T++;try{return x.createScriptURL(e)}finally{T--}},k=function(){return w||(C=vN(u,i),w=!0),C},A=n,j=A.implementation,M=A.createNodeIterator,N=A.createDocumentFragment,P=A.getElementsByTagName,F=r.importNode,I=yN();t.isSupported=typeof oM==`function`&&typeof g==`function`&&j&&j.createHTMLDocument!==void 0;let L=nN,ee=rN,te=iN,ne=aN,re=oN,ie=cN,ae=lN,oe=dN,se=sN,ce=null,le=zM({},[...GM,...KM,...qM,...YM,...ZM]),R=null,ue=zM({},[...QM,...$M,...eN,...tN]),de=Object.seal(pM(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),fe=null,pe=null,me=Object.seal(pM(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),he=!0,ge=!0,_e=!1,ve=!0,ye=!1,be=!0,xe=!1,Se=!1,Ce=null,we=null,Te=!1,Ee=!1,De=!1,Oe=!1,ke=!0,Ae=!1,je=`user-content-`,Me=!0,Ne=!1,Pe={},Fe=null,Ie=zM({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Le=null,Re=zM({},[`audio`,`video`,`img`,`source`,`image`,`track`]),ze=null,Be=zM({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ve=`http://www.w3.org/1998/Math/MathML`,He=`http://www.w3.org/2000/svg`,Ue=`http://www.w3.org/1999/xhtml`,We=Ue,Ge=!1,Ke=null,qe=zM({},[Ve,He,Ue],wM),Je=dM([`mi`,`mo`,`mn`,`ms`,`mtext`]),Ye=zM({},Je),Xe=dM([`annotation-xml`]),Ze=zM({},Xe),Qe=zM({},[`title`,`style`,`font`,`a`,`script`]),$e=null,et=[`application/xhtml+xml`,`text/html`],tt=null,nt=null,rt=n.createElement(`form`),it=function(e){return e instanceof RegExp||e instanceof Function},at=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(nt&&nt===e)return;(!e||typeof e!=`object`)&&(e={}),e=VM(e),$e=et.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,tt=$e===`application/xhtml+xml`?wM:CM,ce=bN(e,`ALLOWED_TAGS`,le,{transform:tt}),R=bN(e,`ALLOWED_ATTR`,ue,{transform:tt}),Ke=bN(e,`ALLOWED_NAMESPACES`,qe,{transform:wM}),ze=bN(e,`ADD_URI_SAFE_ATTR`,Be,{transform:tt,base:Be}),Le=bN(e,`ADD_DATA_URI_TAGS`,Re,{transform:tt,base:Re}),Fe=bN(e,`FORBID_CONTENTS`,Ie,{transform:tt}),fe=bN(e,`FORBID_TAGS`,VM({}),{transform:tt}),pe=bN(e,`FORBID_ATTR`,VM({}),{transform:tt}),Pe=NM(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?VM(e.USE_PROFILES):e.USE_PROFILES:!1,he=e.ALLOW_ARIA_ATTR!==!1,ge=e.ALLOW_DATA_ATTR!==!1,_e=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ve=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ye=e.SAFE_FOR_TEMPLATES||!1,be=e.SAFE_FOR_XML!==!1,xe=e.WHOLE_DOCUMENT||!1,Ee=e.RETURN_DOM||!1,De=e.RETURN_DOM_FRAGMENT||!1,Oe=e.RETURN_TRUSTED_TYPE||!1,Te=e.FORCE_BODY||!1,ke=e.SANITIZE_DOM!==!1,Ae=e.SANITIZE_NAMED_PROPS||!1,Me=e.KEEP_CONTENT!==!1,Ne=e.IN_PLACE||!1,se=WM(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:sN,We=typeof e.NAMESPACE==`string`?e.NAMESPACE:Ue,Ye=NM(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?VM(e.MATHML_TEXT_INTEGRATION_POINTS):zM({},Je),Ze=NM(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?VM(e.HTML_INTEGRATION_POINTS):zM({},Xe);let t=NM(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?VM(e.CUSTOM_ELEMENT_HANDLING):pM(null);if(de=pM(null),NM(t,`tagNameCheck`)&&it(t.tagNameCheck)&&(de.tagNameCheck=t.tagNameCheck),NM(t,`attributeNameCheck`)&&it(t.attributeNameCheck)&&(de.attributeNameCheck=t.attributeNameCheck),NM(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(de.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),fM(de),ye&&(ge=!1),De&&(Ee=!0),Pe&&(ce=zM({},ZM),R=pM(null),Pe.html===!0&&(zM(ce,GM),zM(R,QM)),Pe.svg===!0&&(zM(ce,KM),zM(R,$M),zM(R,tN)),Pe.svgFilters===!0&&(zM(ce,qM),zM(R,$M),zM(R,tN)),Pe.mathMl===!0&&(zM(ce,YM),zM(R,eN),zM(R,tN))),me.tagCheck=null,me.attributeCheck=null,NM(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?me.tagCheck=e.ADD_TAGS:SM(e.ADD_TAGS)&&(ce===le&&(ce=VM(ce)),zM(ce,e.ADD_TAGS,tt))),NM(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?me.attributeCheck=e.ADD_ATTR:SM(e.ADD_ATTR)&&(R===ue&&(R=VM(R)),zM(R,e.ADD_ATTR,tt))),NM(e,`ADD_URI_SAFE_ATTR`)&&SM(e.ADD_URI_SAFE_ATTR)&&zM(ze,e.ADD_URI_SAFE_ATTR,tt),NM(e,`FORBID_CONTENTS`)&&SM(e.FORBID_CONTENTS)&&(Fe===Ie&&(Fe=VM(Fe)),zM(Fe,e.FORBID_CONTENTS,tt)),NM(e,`ADD_FORBID_CONTENTS`)&&SM(e.ADD_FORBID_CONTENTS)&&(Fe===Ie&&(Fe=VM(Fe)),zM(Fe,e.ADD_FORBID_CONTENTS,tt)),Me&&(ce[`#text`]=!0),xe&&zM(ce,[`html`,`head`,`body`]),ce.table&&(zM(ce,[`tbody`]),delete fe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw IM(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw IM(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=D(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=k()),x&&typeof S==`string`&&(S=D(``)));dM&&dM(e),nt=e},ot=zM({},[...KM,...qM,...JM]),st=zM({},[...YM,...XM]),ct=function(e,t,n){return t.namespaceURI===Ue?e===`svg`:t.namespaceURI===Ve?e===`svg`&&(n===`annotation-xml`||Ye[n]):!!ot[e]},lt=function(e,t,n){return t.namespaceURI===Ue?e===`math`:t.namespaceURI===He?e===`math`&&Ze[n]:!!st[e]},ut=function(e,t,n){return t.namespaceURI===He&&!Ze[n]||t.namespaceURI===Ve&&!Ye[n]?!1:!st[e]&&(Qe[e]||!ot[e])},dt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:We,tagName:`template`});let n=CM(e.tagName),r=CM(t.tagName);return Ke[e.namespaceURI]?e.namespaceURI===He?ct(n,t,r):e.namespaceURI===Ve?lt(n,t,r):e.namespaceURI===Ue?ut(n,t,r):!!($e===`application/xhtml+xml`&&Ke[e.namespaceURI]):!1},ft=function(e){bM(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw IM(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},pt=function(e){gt(e);let t=h(e);if(t){let e=[];_M(t,t=>{bM(e,t)}),_M(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},mt=function(e,n){try{bM(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{bM(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Ee||De)try{ft(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ht=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||R[tt(i)]))try{e.removeAttribute(i)}catch{}}},gt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===gN.element&&ht(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},_t=function(e){if(!be)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===gN.processingInstruction||n===gN.comment&&FM(pN,e.data)){try{p(e)}catch{}continue}if(n===gN.element){let t=e,n=tt(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},vt=function(e){let t=null,r=null;if(Te)e=`<remove></remove>`+e;else{let t=TM(e,/^[\r\n\t ]+/);r=t&&t[0]}$e===`application/xhtml+xml`&&We===Ue&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?D(e):e;if(We===Ue)try{t=new l().parseFromString(i,$e)}catch{}if(!t||!t.documentElement){t=j.createDocument(We,`template`,null);try{t.documentElement.innerHTML=Ge?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),We===Ue?P.call(t,xe?`html`:`body`)[0]:xe?t.documentElement:a},yt=function(e){return M.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},bt=function(e){return e=EM(e,L,` `),e=EM(e,ee,` `),e=EM(e,te,` `),e},xt=function(e){e.normalize();let t=M.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=bt(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&_M(r,e=>{Ct(e.content)&&xt(e.content)})},St=function(e){let t=b?b(e):null;return typeof t!=`string`||tt(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},Ct=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===gN.documentFragment}catch{return!1}},wt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Tt(e,n,r){e.length!==0&&_M(e,e=>{e.call(t,n,r,nt)})}let Et=function(e,t){return!!(be&&e.hasChildNodes()&&!wt(e.firstElementChild)&&FM(fN,e.textContent)&&FM(fN,e.innerHTML)||be&&e.namespaceURI===Ue&&t===`style`&&wt(e.firstElementChild)||e.nodeType===gN.processingInstruction||be&&e.nodeType===gN.comment&&FM(pN,e.data))},Dt=function(e,t){if(!fe[t]&&z(t)&&(de.tagNameCheck instanceof RegExp&&FM(de.tagNameCheck,t)||de.tagNameCheck instanceof Function&&de.tagNameCheck(t)))return!1;if(Me&&!Fe[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Ne?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return ft(e),!0},Ot=function(e,n){if(Tt(I.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(St(e))return ft(e),!0;let r=tt(b?b(e):e.nodeName);if(Tt(I.uponSanitizeElement,e,{tagName:r,allowedTags:ce}),e!==n&&g(e)===null)return!0;if(Et(e,r))return ft(e),!0;if(fe[r]||!(me.tagCheck instanceof Function&&me.tagCheck(r))&&!ce[r]){let t=Dt(e,r);return t===!1&&Tt(I.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===gN.element&&!dt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&FM(mN,e.innerHTML))return ft(e),!0;if(ye&&e.nodeType===gN.text){let n=bt(e.textContent);e.textContent!==n&&(bM(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Tt(I.afterSanitizeElements,e,null),!1},kt=function(e,t,r){if(pe[t]||be&&t===`patchsrc`||be&&t===`for`&&e!==`label`&&e!==`output`||ke&&(t===`id`||t===`name`)&&(r in n||r in rt))return!1;let i=R[t]||me.attributeCheck instanceof Function&&me.attributeCheck(t,e);if(!(ge&&FM(ne,t))&&!(he&&FM(re,t))){if(!i){if(!(z(e)&&(de.tagNameCheck instanceof RegExp&&FM(de.tagNameCheck,e)||de.tagNameCheck instanceof Function&&de.tagNameCheck(e))&&(de.attributeNameCheck instanceof RegExp&&FM(de.attributeNameCheck,t)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(t,e))||t===`is`&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&FM(de.tagNameCheck,r)||de.tagNameCheck instanceof Function&&de.tagNameCheck(r))))return!1}else if(!ze[t]&&!FM(se,EM(r,ae,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&DM(r,`data:`)===0&&Le[e])&&!(_e&&!FM(ie,EM(r,ae,``)))&&r)return!1}return!0},At=zM({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),z=function(e){return!At[CM(e)]&&FM(oe,e)},jt=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return D(r);case`TrustedScriptURL`:return O(r)}return r},Mt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),St(e)?ft(e):yM(t.removed)}catch{mt(n,e)}},Nt=function(e){Tt(I.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||St(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},r=t.length,i=tt(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=tt(o),u=c,d=o===`value`?u:OM(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Tt(I.uponSanitizeAttribute,e,n),d=n.attrValue,Ae&&(l===`id`||l===`name`)&&DM(d,je)!==0&&(mt(o,e),d=je+d),be&&FM(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){mt(o,e);continue}if(l===`attributename`&&TM(d,`href`)){mt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){mt(o,e);continue}if(!ve&&FM(hN,d)){mt(o,e);continue}if(ye&&(d=bt(d)),!kt(i,l,d)){mt(o,e);continue}d=jt(i,l,s,d),d!==u&&Mt(e,o,s,d)}}Tt(I.afterSanitizeAttributes,e,null)},Pt=function(e){let t=null,n=yt(e);for(Tt(I.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Tt(I.uponSanitizeShadowNode,t,null),Ot(t,e),Nt(t),Ct(t.content)&&Pt(t.content),(y?y(t):t.nodeType)===gN.element){let e=_(t);Ct(e)&&(Ft(e),Pt(e))}Tt(I.afterSanitizeShadowDOM,e,null)},Ft=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Pt(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===gN.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&tt(e)===`template`){let e=n.content;Ct(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Ct(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ge=!e,Ge&&(e=`<!-->`),typeof e!=`string`&&!wt(e)&&(e=HM(e),typeof e!=`string`))throw IM(`dirty is not a string, aborting`);if(!t.isSupported)return e;Se?(ce=Ce,R=we):at(n),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(ce=VM(ce)),I.uponSanitizeAttribute.length>0&&(R=VM(R)),t.removed=[];let c=Ne&&typeof e!=`string`&&wt(e);if(c){_t(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=tt(t);if(!ce[n]||fe[n])throw pt(e),IM(`root node is forbidden and cannot be sanitized in-place`)}if(St(e))throw pt(e),IM(`root node is clobbered and cannot be sanitized in-place`);try{Ft(e)}catch(t){throw pt(e),t}}else if(wt(e))i=vt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===gN.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Ft(a);else{if(!Ee&&!ye&&!xe&&e.indexOf(`<`)===-1)return x&&Oe?D(e):e;if(i=vt(e),!i)return Ee?null:Oe?S:``}i&&Te&&ft(i.firstChild);let l=c?e:i,u=yt(l);try{for(;o=u.nextNode();)Ot(o,l),Nt(o),Ct(o.content)&&Pt(o.content)}catch(n){throw c&&(pt(e),_M(t.removed,e=>{e.element&&gt(e.element)})),n}if(c)return _M(t.removed,e=>{e.element&&gt(e.element)}),ye&&xt(e),e;if(Ee){if(ye&&xt(i),De)for(s=N.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(R.shadowroot||R.shadowrootmode)&&(s=F.call(r,s,!0)),s}let d=xe?i.outerHTML:i.innerHTML;return xe&&ce[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&FM(uN,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
32
+ `+d),ye&&(d=bt(d)),x&&Oe?D(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};at(e),Se=!0,Ce=ce,we=R},t.clearConfig=function(){nt=null,Se=!1,Ce=null,we=null,x=C,S=``},t.isValidAttribute=function(e,t,n){nt||at({});let r=tt(e),i=tt(t);return kt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&NM(I,e)&&bM(I[e],t)},t.removeHook=function(e,t){if(NM(I,e)){if(t!==void 0){let n=vM(I[e],t);return n===-1?void 0:xM(I[e],n,1)[0]}return yM(I[e])}},t.removeHooks=function(e){NM(I,e)&&(I[e]=[])},t.removeAllHooks=function(){I=yN()},t}var SN=xN(),CN=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)(jA),[r,i]=(0,d.useState)(1),{isPending:a,isLoading:o,isError:s,error:c,data:l,isFetching:u,isPlaceholderData:f}=(0,m.useQuery)({queryKey:[`run_changelog`,n,r],queryFn:()=>Oe({run:n,page:r}),placeholderData:m.keepPreviousData});return(0,p.jsxs)(K,{show:e,size:`lg`,onHide:()=>t(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsxs)(K.Title,{children:[`History of Run `,n.label]})}),(0,p.jsx)(K.Body,{children:(0,p.jsxs)(`div`,{children:[a?(0,p.jsx)(`div`,{children:`Loading...`}):s?(0,p.jsxs)(`div`,{children:[`Error: `,c.message]}):(0,p.jsx)(Nl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:(0,p.jsx)(`tbody`,{children:l.items.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(lk,{format:`DD-MM-YYYY`,children:e.date_created})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:SN.sanitize(e.message)}})}),(0,p.jsxs)(`td`,{children:[e.user.first_name,` `,e.user.last_name]})]},e.id))})}),(0,p.jsx)(GO,{data:l,setPage:i,isPlaceholderData:f}),u?(0,p.jsx)(`span`,{children:` Loading...`}):null]})}),(0,p.jsx)(K.Footer,{children:(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},wN=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{size:e,variant:`primary`,onClick:()=>n(!t),children:`Run history`}),t&&(0,p.jsx)(CN,{show:t,setModalShow:n})]})},TN=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)(jA);return(0,p.jsxs)(K,{show:e,size:`xl`,onHide:()=>t(!1),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsxs)(K.Title,{children:[`All steps of run `,n.label]})}),(0,p.jsx)(K.Body,{children:(0,p.jsx)($j,{hideLabel:!1})}),(0,p.jsx)(K.Footer,{children:(0,p.jsx)(U,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},EN=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(U,{size:e,variant:`primary`,onClick:()=>n(!0),children:`All run steps`}),t&&(0,p.jsx)(TN,{show:t,setModalShow:n})]})},DN=()=>{let{runStep:e,run:t}=(0,d.useContext)(jA),[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)([]),[u,h]=(0,d.useState)([]),[g,_]=(0,d.useState)([]),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(!1),[S,C,w]=(0,m.useQueries)({queries:[{queryKey:[`templates`,g],queryFn:()=>Ye({reworkRecipes:g}),enabled:n&&g.length>0},{queryKey:[`run_steps`,e.id],queryFn:()=>Ae({run:t,page:1,pageSize:1e3}),enabled:n},{queryKey:[`template_steps`,`rework`,o,e.id],queryFn:()=>Je({template:o,pageSize:1e3}),enabled:o!==null}]});if((0,d.useEffect)(()=>{if(C.isSuccess&&c.length>0){let e=new Set(c),t=[];for(let n of C.data.items)e.has(n.id)&&t.push(n.recipe_version.recipe);_(t)}},[C.isSuccess,c]),!e.has_recipe)return`Reworks are only possible for steps with a recipe`;function T(e){let t=S.data.templates.find(t=>t.id===e);t!==void 0&&s(t)}function E(){let t={};a({}),c.length===0&&(t.runStep=`Please select at least one step`),a(e=>({...e,...t})),Object.keys(t).length===0&&(x(!0),f.default.create().patch(`/update/run/step/rework/`+e.id,{reworked_run_steps:c,template_steps:u,comment:v}).then(()=>{x(!1),window.location.reload()}))}return(0,p.jsxs)(p.Fragment,{children:[n&&(0,p.jsxs)(G,{method:`post`,onSubmit:()=>E(),children:[(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Template`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[g.length===0&&(0,p.jsx)(Cr,{variant:`info`,children:`— Select a rework step`}),g.length>0&&(0,p.jsxs)(G.Control,{as:`select`,name:`template`,onChange:e=>T(parseInt(e.target.value)),isInvalid:!!i.template,children:[(0,p.jsx)(`option`,{value:``,children:`— Select a template`}),S.data!==void 0&&S.data.templates.map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.label,`: `,e.name]},e.id))]}),i.template&&(0,p.jsx)(`span`,{className:`text-danger`,children:i.template})]})]}),o!==null&&(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Include template steps`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsx)(`ul`,{className:`list-group`,children:!w.isLoading&&w.data!==void 0&&w.data.steps.map(e=>(0,p.jsx)(`li`,{className:`list-group-item `,children:(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,className:`form-check-input`,id:`templateStep`+e.id,"aria-label":e.process_module.process.name,name:`templateStep`,onChange:t=>{t.target.checked?h([...u,e.id]):h(u.filter(t=>t!==e.id))},value:e.id}),(0,p.jsxs)(`label`,{htmlFor:`templateStep`+e.id,className:`from-check-label`,children:[(0,p.jsxs)(`small`,{className:`text-muted pe-2`,children:[e.number,`:`]}),e.process_module.process.name]})]})},e.id))})})]}),(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Repeat steps`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(`ul`,{className:`list-group`,children:[C.isLoading&&(0,p.jsx)(`option`,{children:`Loading run steps...`}),!C.isLoading&&C.data.items.map(t=>{if(e.sequence>=t.sequence)return(0,p.jsxs)(`li`,{className:`list-group-item d-flex justify-content-between`+(e.id===t.id?` bg-success-subtle`:``),children:[(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,className:`form-check-input`,id:`runStep`+t.id,"aria-label":t.process_module.process.name,name:`runStep`,onChange:e=>{e.target.checked?l([...c,t.id]):l(c.filter(e=>e!==t.id))},value:t.id}),(0,p.jsxs)(`label`,{htmlFor:`runStep`+t.id,className:`from-check-label`,children:[(0,p.jsxs)(`small`,{className:`text-muted pe-2`,children:[t.number,`:`]}),t.process_module.process.name]})]}),t.is_finished&&(0,p.jsx)(`div`,{children:(0,p.jsx)(`span`,{className:`badge bg-success`,children:`Finished`})})]},t.id)})]}),i.runStep&&(0,p.jsx)(`span`,{className:`text-danger`,children:i.runStep})]})]}),(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(G.Label,{className:`col-sm-3 col-form-label text-end`,children:`Comment`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsxs)(G.Group,{controlId:`runStep.remark`,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:6,onChange:e=>y(e.target.value),value:v,isInvalid:!!i.comment}),(0,p.jsx)(`small`,{className:`text-muted`,children:`Optional comment for the rework`})]})})]}),(0,p.jsx)(`div`,{className:`row mb-3`,children:(0,p.jsxs)(`div`,{className:`col-sm-9 offset-sm-3`,children:[(0,p.jsxs)(U,{variant:`primary`,onClick:()=>E(),disabled:b,children:[b&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Create rework`]}),`\xA0`,(0,p.jsx)(U,{variant:`warning`,onClick:()=>r(!1),children:`Cancel`})]})})]}),!n&&(0,p.jsx)(U,{variant:`primary`,className:`mt-3`,onClick:()=>r(!0),children:`Set Rework`})]})},ON={items:[],amountOfPages:0,currentPage:0,totalItems:0,hasMore:!1},kN=()=>{let{environment:e}=(0,g.useParams)(),{runStep:t,run:n}=(0,d.useContext)(jA),r=(0,m.useQueries)({queries:[{queryKey:[`monitors`,t.process_module.module.equipment],queryFn:()=>t.process_module.module.equipment?de({equipment:t.process_module.module.equipment}):ON},{queryKey:[`ecn`,t.process_module.module],queryFn:()=>ee({module:t.process_module.module})},{queryKey:[`equipmentModule`,t.process_module.module],queryFn:()=>I({id:t.process_module.module.id})},{queryKey:[`requirement`,t.id],queryFn:()=>De({run:n,step:t})}]}),[i,a,o,s]=r,[c,l]=(0,d.useState)(!0),{addReadingCallbackFn:u,removeReadingCallbackFn:f}=Uk(),[h,_]=(0,d.useState)(``),v=(0,d.useId)();(0,d.useEffect)(()=>(u(v,_),()=>{f(v)}),[]);let y=r.some(e=>e.isLoading);if(r.some(e=>e.isError))return r.forEach((e,r)=>{e.isError&&console.error(`StepDashboard query error`,{index:r,error:e.error,runStep:t,run:n})}),(0,p.jsx)(p.Fragment,{children:`Error fetching data`});if(y)return(0,p.jsx)(`div`,{children:`Loading...`});let b=o.data;return(0,p.jsx)(Jr,{fluid:!0,children:(0,p.jsxs)(jl,{children:[(0,p.jsxs)(qr,{className:`col-9`,children:[n.run_type===pt.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),n.run_type===pt.PRODUCTION&&(0,p.jsx)(`small`,{children:`Production run`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[n.name,` (`,n.project.name,`)`]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-lg-row gap-2 flex-wrap justify-content-end`,children:[t.has_rework&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`mx-1 badge bg-primary`,children:`Rework`}),(0,p.jsx)(Jj,{}),(0,p.jsx)(qj,{}),t.is_skipped&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`badge bg-info`,children:`SKIPPED`})]})]}),(0,p.jsx)(uk,{run:n}),t.label&&(0,p.jsx)(Ij,{label:t.label}),(0,p.jsx)(Lj,{runStep:t}),t.is_finished&&(0,p.jsxs)(Cr,{variant:`success`,children:[`This step has been finished by `,t.finish_user?.first_name,` `,t.finish_user?.last_name]}),t.has_recipe&&(0,p.jsx)(W,{className:`rounded my-4`,children:(0,p.jsxs)(W.Body,{children:[(0,p.jsx)(W.Title,{className:`text-muted`,children:`Recipe`}),(0,p.jsxs)(W.Text,{className:`display-5`,children:[t.recipe_version.recipe.name,` (Version `,t.recipe_version.version,`)`]})]})}),s.data?.items.length==1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(MA,{requirement:s.data.items[0],step:t,editOnly:!1}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(NA,{requirement:s.data.items[0],editOnly:!1})]}),s.data?.items.length!=1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{children:`Experimental split`}),(0,p.jsx)(oA,{run:n,runStep:t})]}),(0,p.jsxs)(`p`,{className:`pt-3`,children:[`Reading from scanner: `,h]}),(0,p.jsxs)(jl,{className:`pm-3`,children:[(0,p.jsxs)(qr,{children:[(0,p.jsx)(`h3`,{children:`Checklist`}),(0,p.jsx)(Hj,{}),(0,p.jsx)(`h2`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(vk,{runStep:t})]}),(0,p.jsxs)(qr,{children:[(0,p.jsx)(`h2`,{children:`Parameters`}),(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(`input`,{type:`checkbox`,id:`showOnlyEmphasizedParameters`,checked:c,className:`form-check-input`,"data-toggle":`toggle`,onChange:()=>l(!c)}),(0,p.jsx)(`label`,{htmlFor:`showOnlyEmphasizedParameters`,className:`ms-2`,children:`Show only emphasized parameters`})]}),(0,p.jsx)(gk,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:c}),t.has_instructions&&t.instructions&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{children:`Instructions`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.instructions}})]}),(0,p.jsx)(Wj,{}),(0,p.jsx)(`h3`,{className:`pt-3`,children:`Rework`}),(0,p.jsx)(DN,{})]})]}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mb-3`,children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsxs)(`div`,{className:`d-flex gap-2 flex-wrap justify-content-end`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(EN,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(wN,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(rO,{size:void 0,moduleId:t.process_module.module.id})})]})]}),(0,p.jsx)($j,{pageSize:n.run_type===pt.RESEARCH?5:1e3,hideLabel:!0})]}),(0,p.jsx)(qr,{className:`col-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(`h2`,{children:(0,p.jsxs)(g.Link,{to:`/${e}/operator/equipment/${t.process_module.module.equipment?.id}`,children:[t.process_module.module.equipment?.name,` (`,t.process_module.module?.name,`)`]})}),b&&(0,p.jsx)(`div`,{children:(0,p.jsx)(`h2`,{children:(0,p.jsx)(Ld,{module:b})})}),i.data?.items&&i.data.items.map(e=>(0,p.jsx)(tO,{monitor:e},e.id)),a.data?.items.map(function(e){return(0,p.jsxs)(W,{className:`my-2`,children:[(0,p.jsxs)(W.Header,{children:[`ECN: `,e.ecn]}),(0,p.jsx)(W.Body,{children:(0,p.jsx)(W.Text,{children:(0,p.jsx)(MD,{children:e.description})})}),(0,p.jsxs)(W.Footer,{children:[e.date_created&&(0,p.jsxs)(p.Fragment,{children:[`Created by `,zD(e.date_created,`DD-MM-YY H:m`),` by `,e.owner.full_name]}),e.last_update&&(0,p.jsxs)(p.Fragment,{children:[` `,`· Updated by `,zD(e.last_update,`DD-MM-YY H:m`),` by `,e.owner.full_name]})]})]},e.id)})]})})]})})},AN=()=>{let[e,t]=(0,d.useState)(!1),{modalProperties:n}=(0,d.useContext)(jA),r=()=>{t(!1),n.show=!1};return(0,d.useEffect)(()=>{t(n.show)},[n]),(0,p.jsxs)(K,{show:e,size:`xl`,onHide:r,children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:n.modalTitle})}),(0,p.jsx)(K.Body,{children:n.modalContent}),(0,p.jsxs)(K.Footer,{children:[(0,p.jsx)(U,{variant:`secondary`,onClick:r,children:`Save`}),n.modalSaveButton]})]})};function jN(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(kN,{}),(0,p.jsx)(AN,{})]})}function MN({run:e,runStep:t,showOnlyEmphasizedParameters:n,reloadRunStepFn:r}){let{data:i,refetch:a}=(0,m.useQuery)({queryKey:[`checklist`,t?.id],queryFn:()=>Pe({runStep:t})}),o=(0,d.useMemo)(()=>i?.items,[i]),[s,c]=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>ke({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Re({step:t})}]}),l=(0,d.useMemo)(()=>{let e=s.data?.items??[],n=c.data?.items??[],r=e.filter(e=>e.part_level===t.part_level);return r.length!==0&&r.every(e=>n.find(t=>t.part_id==e.id)?.processed===!0)},[s.data,c.data,t.part_level]),[u,f]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mb-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`h3`,{className:`mb-2 text-start`,children:`Parts`})}),(0,p.jsx)(vl,{placement:`top`,overlay:(0,p.jsx)(fl,{id:`tooltip-move-out`,children:l?`Finish step`:`Finish all parts before moving out`}),children:(0,p.jsx)(`span`,{children:(0,p.jsx)(U,{variant:l?`success`:`light`,onClick:()=>{f(!0),Fe(t).finally(()=>{f(!1),r()})},disabled:u||!l,children:u?`Moving out...`:`Move out`})})})]}),(0,p.jsx)(tA,{run:e,runStep:t}),(0,p.jsx)(`h3`,{className:`mt-2`,children:`Parameters`}),(0,p.jsx)(gk,{runStep:t,showOnlyEmphasizedParameters:n}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsx)(`div`,{className:`col`,children:(0,p.jsx)(Wj,{runStep:t,reloadRunStep:r})}),(0,p.jsx)(`div`,{className:`col`,children:t.has_instructions&&t.instructions&&(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`h3`,{className:`mb-2 text-start`,children:`Instructions`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.instructions}})]})})]}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsxs)(`div`,{className:`col`,children:[(0,p.jsx)(`h3`,{className:`mt-2`,children:`Checklist`}),!o&&(0,p.jsx)(nc,{children:Array.from({length:1}).map((e,t)=>(0,p.jsx)(nc.Item,{children:(0,p.jsxs)(q,{as:`div`,animation:`glow`,children:[(0,p.jsx)(q,{xs:17}),` `,(0,p.jsx)(q,{xs:4}),` `,(0,p.jsx)(q,{xs:6})]})},t))}),o&&(0,p.jsxs)(p.Fragment,{children:[o.length===0&&(0,p.jsx)(Cr,{variant:`info`,children:`No checklist found`}),o.length>0&&(0,p.jsx)(nc,{children:o.map(e=>(0,p.jsx)(Bj,{checklistItem:e,refetch:a},e.id))})]})]}),(0,p.jsxs)(`div`,{className:`col`,children:[(0,p.jsx)(`h3`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(vk,{runStep:t})]})]})]})}function NN({children:e}){let[t,n]=(0,d.useState)(!1);return(0,p.jsx)(Ot,{children:(0,p.jsx)(mk.Provider,{value:{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Ct,{message:`Loading...`}),children:e})})})}function PN(){return(0,p.jsx)(Jr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}function FN({control:e,name:t}){let{environment:n}=(0,g.useParams)(),[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{async function e(){try{let e=await le({environment:n,withLocations:!0});i(e.items)}catch(e){console.error(`Error fetching rooms:`,e)}finally{o(!1)}}e()},[]),a?(0,p.jsx)(`p`,{children:`Loading labs...`}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{children:`Choose a lab`}),(0,p.jsx)(G.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:(0,p.jsx)(wu,{name:t,render:({field:{onChange:e,value:t}})=>(0,p.jsxs)(G.Select,{"aria-label":`Choose a lab`,value:t?.id||``,onChange:t=>{e(r.find(e=>e.id.toString()===t.target.value)||null)},children:[(0,p.jsx)(`option`,{value:``,children:`— Choose a lab`}),r.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),control:e})})]})}var IN=Object.defineProperty,LN=Object.getOwnPropertySymbols,RN=Object.prototype.hasOwnProperty,zN=Object.prototype.propertyIsEnumerable,BN=(e,t,n)=>t in e?IN(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,VN=(e,t)=>{for(var n in t||(t={}))RN.call(t,n)&&BN(e,n,t[n]);if(LN)for(var n of LN(t))zN.call(t,n)&&BN(e,n,t[n]);return e},HN=(e,t)=>{var n={};for(var r in e)RN.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&LN)for(var r of LN(e))t.indexOf(r)<0&&zN.call(e,r)&&(n[r]=e[r]);return n},UN;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(UN||(UN={})),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||(e.QrCode={}))})(UN||(UN={})),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||(e.QrSegment={}))})(UN||(UN={}));var WN=UN,GN={L:WN.QrCode.Ecc.LOW,M:WN.QrCode.Ecc.MEDIUM,Q:WN.QrCode.Ecc.QUARTILE,H:WN.QrCode.Ecc.HIGH},KN=128,qN=`L`,JN=`#FFFFFF`,YN=`#000000`,XN=!1,ZN=1,QN=4,$N=0,eP=.1;function tP(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function nP(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function rP(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*eP),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function iP(e,t){return t==null?e?QN:$N:Math.max(Math.floor(t),0)}function aP({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=u.default.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...WN.QrSegment.makeSegments(t)),e),[]);return WN.QrCode.encodeSegments(r,GN[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:d,numCells:f,calculatedImageSettings:p}=u.default.useMemo(()=>{let e=c.getModules(),t=iP(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:rP(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:l,numCells:f,calculatedImageSettings:p}}var oP=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),sP=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=KN,level:a=qN,bgColor:o=JN,fgColor:s=YN,includeMargin:c=XN,minVersion:l=ZN,boostLevel:d,marginSize:f,imageSettings:p}=n,m=HN(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=HN(m,[`style`]),_=p?.src,v=u.default.useRef(null),y=u.default.useRef(null),b=u.default.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=u.default.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=aP({value:r,level:a,minVersion:l,boostLevel:d,includeMargin:c,marginSize:f,imageSettings:p,size:i});u.default.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=nP(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,oP?t.fill(new Path2D(tP(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),u.default.useEffect(()=>{S(!1)},[_]);let D=VN({height:i,width:i},h),O=null;return _!=null&&(O=u.default.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),u.default.createElement(u.default.Fragment,null,u.default.createElement(`canvas`,VN({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});sP.displayName=`QRCodeCanvas`;var cP=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=KN,level:a=qN,bgColor:o=JN,fgColor:s=YN,includeMargin:c=XN,minVersion:l=ZN,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=HN(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=aP({value:r,level:a,minVersion:l,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:m,size:i}),b=_,x=null;m!=null&&y!=null&&(y.excavation!=null&&(b=nP(_,y.excavation)),x=u.default.createElement(`image`,{href:m.src,height:y.h,width:y.w,x:y.x+g,y:y.y+g,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=tP(b,g);return u.default.createElement(`svg`,VN({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},h),!!f&&u.default.createElement(`title`,null,f),u.default.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),u.default.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});cP.displayName=`QRCodeSVG`;function lP({control:e,name:t,room:n}){let[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{async function e(){try{let e=await ce({room:n,pageSize:1e3});i(e.items),o(!1)}catch(e){console.error(`Error fetching locations:`,e)}}e()},[n]),a?(0,p.jsx)(`p`,{children:`Loading locations...`}):(0,p.jsxs)(G.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:[(0,p.jsx)(G.Label,{children:`Select a storage location`}),(0,p.jsx)(wu,{name:t,control:e,defaultValue:``,render:({field:{onChange:e,value:t}})=>(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(jl,{children:r.map(n=>(0,p.jsx)(qr,{xs:4,md:3,className:`mb-3`,children:(0,p.jsx)(W,{onClick:()=>e(n.id.toString()),style:{cursor:`pointer`,border:t.toString()===n.id.toString()?`2px solid #007bff`:`1px solid #ddd`,borderRadius:`8px`},className:`h-100`,children:(0,p.jsxs)(W.Body,{children:[(0,p.jsx)(W.Title,{children:n.name}),(0,p.jsxs)(`div`,{className:`text-muted small mb-2 d-flex gap-2 justify-content-between`,children:[n.code&&(0,p.jsxs)(`div`,{children:[`Code: `,n.code]}),n.zone_group&&(0,p.jsxs)(`div`,{children:[`Zone group: `,n.zone_group.name]})]}),(0,p.jsxs)(`div`,{style:{textAlign:`center`,marginTop:`10px`},children:[(0,p.jsx)(cP,{value:`/l/`+n.id.toString(),size:128}),` `]})]})})},n.id))})})})]})}var uP=({show:e,setShow:t,onChemicalCreate:n})=>{let{register:r,control:i,setValue:a,handleSubmit:o,formState:{errors:s,isSubmitting:c}}=Id({defaultValues:{}}),l=async e=>{try{let t=await f.default.post(`create/chemical`,e);t.data&&n(t.data)}finally{t(!1)}};return(0,p.jsx)(K,{show:e,size:`lg`,onHide:()=>t(!1),children:(0,p.jsxs)(G,{onSubmit:o(l),children:[(0,p.jsx)(K.Header,{closeButton:!0,children:(0,p.jsx)(K.Title,{children:`Create new chemical`})}),(0,p.jsxs)(K.Body,{children:[(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`cas_number`,className:`col-sm-3 col-form-label text-end`,children:`CAS Number`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(G.Control,{as:`input`,id:`cas_number`,...r(`cas_number`,{required:`A cas number is required`}),isInvalid:s.cas_number!==void 0}),s.cas_number&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.cas_number.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`name`,className:`col-sm-3 col-form-label text-end`,children:`Name`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(G.Control,{as:`input`,id:`name`,...r(`name`,{required:`A name is required`}),isInvalid:s.name!==void 0}),s.name&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.name.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`description`,className:`col-sm-3 col-form-label text-end`,children:`Description`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(G.Control,{as:`textarea`,rows:3,id:`description`,...r(`description`)}),s.description&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.description.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`standard_product`,className:`col-sm-3 col-form-label text-end`,children:`Standard product`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(G.Select,{id:`standard_product`,...r(`standard_product`,{required:`A standard product is required`}),isInvalid:s.standard_product!==void 0,children:[(0,p.jsx)(`option`,{value:st.NON_STANDARD_PRODUCT,children:`Non standard product`}),(0,p.jsx)(`option`,{value:st.STANDARD_PRODUCT,children:`Standard product`})]}),s.standard_product&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.standard_product.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{htmlFor:`physical_state`,className:`col-sm-3 col-form-label text-end`,children:`Physical state`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(G.Select,{id:`physical_state`,...r(`physical_state`,{required:`A physical state is required`}),isInvalid:s.physical_state!==void 0,children:[(0,p.jsx)(`option`,{value:ct.SOLID,children:`Solid`}),(0,p.jsx)(`option`,{value:ct.LIQUID,children:`Liquid`}),(0,p.jsx)(`option`,{value:ct.GAS,children:`Gas`}),(0,p.jsx)(`option`,{value:ct.OTHER,children:`Other`})]}),s.physical_state&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:s.physical_state.message})]})]})]}),(0,p.jsx)(K.Footer,{children:(0,p.jsxs)(U,{variant:`primary`,disabled:c,onClick:()=>o(l)(),children:[c&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Create new chemical`]})})]})})};function dP({control:e,name:t,setValue:n,errors:r}){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(null),u=(e,t)=>{try{O({query:e}).then(e=>{let n=e.items.map(e=>({value:e.id,label:e.name+(e.cas_number?` (`+e.cas_number+`)`:``)})),r={...i};n.forEach(e=>{r[e.value]=e}),a(r),t(n)})}catch(e){console.error(`Error fetching chemicals:`,e)}},m=e=>e&&i[e]?i[e]:c||null;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Search Existing Chemicals`}),(0,p.jsxs)(jl,{children:[(0,p.jsx)(wu,{name:t,control:e,render:({field:e})=>(0,p.jsx)(qb,{isSearchable:!0,isClearable:!0,defaultOptions:!0,placeholder:`— Select a chemical, or start typing`,loadOptions:u,value:m(e.value),styles:Xb,onChange:t=>{l(null),e.onChange(t?.value)}})}),r.chemical&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:r.chemical.message}),(0,p.jsx)(`div`,{children:(0,p.jsx)(U,{variant:`primary`,className:`mt-2`,onClick:()=>s(!0),children:`Create New Chemical`})})]})]}),(0,p.jsx)(uP,{show:o,setShow:s,onChemicalCreate:async e=>{try{let r=await f.default.post(`create/chemical`,e),i={value:r.data.id,label:r.data.name+(r.data.cas_number?` (${r.data.cas_number})`:``)};a(e=>({...e,[i.value]:i})),l(i),s(!1),n(t,r.data.id)}catch(e){console.error(`Error creating chemical:`,e)}}})]})}function fP(e){return/\/l\/\d+$/.test(e)}function pP(e){let t=e.match(/\/l\/(\d+)$/);return t?parseInt(t[1],10):null}var mP=[{value:`g`,label:`Gram`},{value:`kg`,label:`Kilogram`},{value:`lb`,label:`US pound`},{value:`mc`,label:`Microgram`},{value:`mg`,label:`Milligram`},{value:`oz`,label:`Ounce`},{value:`to`,label:`Tonnes`},{value:`ton`,label:`US ton`},{value:`"3`,label:`Cubic inch`},{value:`ccm`,label:`Cubic centimeter`},{value:`cl`,label:`Centiliter`},{value:`dm3`,label:`Cubic decimeter`},{value:`foz`,label:`Fluid Ounce Us`},{value:`ft3`,label:`Cubic foot`},{value:`gal`,label:`US gallon`},{value:`hl`,label:`Hectoliter`},{value:`kit`,label:`Kit`},{value:`l`,label:`Liter`},{value:`m3`,label:`Cubic meter`},{value:`ml`,label:`Mililiter`},{value:`mm3`,label:`Cubic milimeter`},{value:`pc`,label:`Item`},{value:`pce`,label:`Piece`},{value:`pt`,label:`Pint, US liquid`},{value:`qt`,label:`Quart, US liquid`},{value:`yd3`,label:`Cubic Yard`},{value:`µl`,label:`Microliter`}].sort((e,t)=>e.label.localeCompare(t.label));function hP(){let e=new Date;return e.setFullYear(e.getFullYear()+5),e.toISOString().split(`T`)[0]}function gP({room:e,barcode:t,resetForm:n,location:r,setLocation:i}){let{user:a}=(0,d.useContext)(v),{environment:o}=(0,g.useParams)(),{addCallbackFn:s,removeCallbackFn:c}=Uk(),[l,u]=(0,d.useState)(null),{register:m,control:h,handleSubmit:_,watch:y,setValue:b,formState:{errors:x,isSubmitting:S}}=Id({defaultValues:{expire_date:hP(),owner:{value:a?.id,label:a?.full_name}}}),C=y(`location`);(0,d.useEffect)(()=>{C&&oe({id:C}).then(e=>i(e))},[C]);let w=(0,d.useId)(),T=(0,d.useCallback)(e=>{if(fP(e)){let t=pP(e);t!==null&&(oe({id:t}).then(e=>i(e)),b(`location`,t))}e.startsWith(`reset-scan-location`)&&O()},[b]);(0,d.useEffect)(()=>(c(Wk.WILD_CARD,w),s(Wk.WILD_CARD,w,T),()=>c(Wk.WILD_CARD,w)),[b]);let D=async e=>{if(e.user=e.owner.value,(await E({qrCodeContent:t})).items.length>0){alert(`This barcode is already registered to a container`);return}let n=await f.default.post(`create/chemical/container`,e);u(n.data),await f.default.post(`create/chemical/container/external-label`,{container:n.data.id,qr_code_content:t})},O=()=>{i(null),b(`location`,0)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(G,{onSubmit:_(D),children:[!r&&(0,p.jsx)(lP,{room:e,control:h,name:`location`}),r&&(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Scanned location`}),(0,p.jsx)(qr,{children:(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`span`,{className:`h1`,children:r.name}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(cP,{value:`reset-scan-location`,size:100,onClick:O}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset location`})]})]})})]}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(dP,{control:h,errors:x,setValue:b,...m(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:h,...m(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Concentration`}),(0,p.jsxs)(zs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`input`,...m(`concentration`,{required:`A concentration is required`}),isInvalid:x.concentration!==void 0}),x.concentration&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.concentration.message})]})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Amount`}),(0,p.jsxs)(zs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`input`,...m(`amount`,{required:`An amount is required`}),isInvalid:x.amount!==void 0}),(0,p.jsx)(wu,{name:`amount_unit`,control:h,render:({field:e})=>(0,p.jsxs)(ms,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(fs.Item,{eventKey:``,children:`(no unit)`},0),mP.map(e=>(0,p.jsxs)(fs.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),x.amount&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.amount.message})]})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Expire date`}),(0,p.jsx)(G.Control,{type:`date`,...m(`expire_date`,{required:`An expire date is required`}),isInvalid:x.expire_date!==void 0}),x.expire_date&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.expire_date.message})]}),(0,p.jsxs)(U,{type:`submit`,variant:`primary`,disabled:S,children:[S&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Register container`]})]})]}),l&&(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(Cr,{variant:`success`,children:`Container registered successfully`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${o}/chemical/container/details/${l.id}/general.html`,children:`Go to container`}),(0,p.jsx)(cP,{value:`reset-form`,size:100,className:`float-end`,onClick:n})]})]})]})}function _P({control:e,errors:t}){let[n,r]=(0,d.useState)({}),i=(e,t)=>{try{D({query:e}).then(e=>{let i=e.items.map(e=>({value:e.id,label:e.name})),a={...n};i.forEach(e=>{a[e.value]=e}),r(a),t(i)})}catch(e){console.error(`Error fetching types:`,e)}},a=e=>n[e]||null;return(0,p.jsx)(wu,{name:`container_type`,control:e,render:({field:e})=>(0,p.jsx)(qb,{isSearchable:!0,defaultOptions:!0,placeholder:`— Select a container type`,loadOptions:i,value:a(e.value),onChange:t=>{e.onChange(t?.value)},styles:Xb})})}function vP({room:e,resetForm:t,location:n,setLocation:r}){let{user:i}=(0,d.useContext)(v),{environment:a}=(0,g.useParams)(),{addCallbackFn:o,removeCallbackFn:s}=Uk(),[c,l]=(0,d.useState)(null),u=new Date;u.setFullYear(u.getFullYear()+5);let{register:m,control:h,handleSubmit:_,watch:y,setValue:b,formState:{errors:x,isSubmitting:S}}=Id({defaultValues:{expire_date:u.toISOString().split(`T`)[0],owner:{value:i?.id,label:i?.full_name}}}),C=y(`location`);(0,d.useEffect)(()=>{C&&oe({id:C}).then(e=>{r(e)})},[C]);let w=(0,d.useCallback)(()=>{r(null),b(`location`,0)},[r,b]),T=(0,d.useId)(),E=(0,d.useCallback)(async e=>{if(fP(e)){let t=pP(e);t!==null&&(r(await oe({id:t})),b(`location`,t));return}e.startsWith(`reset-scan-location`)&&w()},[r,b,w]);return(0,d.useEffect)(()=>(s(Wk.WILD_CARD,T),o(Wk.WILD_CARD,T,E),()=>s(Wk.WILD_CARD,T)),[E]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(G,{onSubmit:_(async e=>{e.user=e.owner.value;let t=await f.default.post(`create/chemical/container`,e);l(t.data)}),children:[!n&&(0,p.jsx)(lP,{room:e,control:h,name:`location`}),n&&(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Scanned location`}),(0,p.jsx)(qr,{children:(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`span`,{className:`h1`,children:n.name}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(cP,{value:`reset-scan-location`,size:100,onClick:()=>w()}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset location`})]})]})})]}),n&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(dP,{control:h,errors:x,setValue:b,...m(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:h,...m(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Concentration`}),(0,p.jsxs)(zs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`input`,...m(`concentration`,{required:`An concentration is required`}),isInvalid:x.concentration!==void 0}),x.concentration&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.concentration.message})]})]}),(0,p.jsxs)(G.Group,{className:`mb-3`,children:[(0,p.jsx)(G.Label,{children:`Amount`}),(0,p.jsxs)(zs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(G.Control,{as:`input`,...m(`amount`,{required:`An amount is required`}),isInvalid:x.amount!==void 0}),(0,p.jsx)(wu,{name:`amount_unit`,control:h,render:({field:e})=>(0,p.jsxs)(ms,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(fs.Item,{eventKey:``,children:`(no unit)`},0),mP.map(e=>(0,p.jsxs)(fs.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),x.amount&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.amount.message})]})]}),(0,p.jsxs)(zs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(G.Label,{children:`Container type`}),(0,p.jsx)(_P,{control:h,...m(`container_type`,{required:`Container type is required`}),errors:x}),x.container_type&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.container_type.message})]}),(0,p.jsxs)(G.Group,{className:`mb-3 w-50 w-25-sm`,children:[(0,p.jsx)(G.Label,{children:`Expire date`}),(0,p.jsx)(G.Control,{type:`date`,...m(`expire_date`,{required:`An expire date is required`}),isInvalid:x.expire_date!==void 0}),x.expire_date&&(0,p.jsx)(G.Control.Feedback,{type:`invalid`,children:x.expire_date.message})]}),(0,p.jsxs)(U,{type:`submit`,variant:`primary`,disabled:S,children:[S&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Register container`]})]})]}),c&&(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(Cr,{variant:`success`,children:`Container registered successfully`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${a}/chemical/container/render/single-${c.id}.pdf`,children:`Print label`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${a}/chemical/container/details/${c.id}/general.html`,children:`Go to container`})}),(0,p.jsx)(cP,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>t()})]})]})]})}function yP(){let{environment:e}=(0,g.useParams)(),{addReadingCallbackFn:t,removeReadingCallbackFn:n,addCallbackFn:r,removeCallbackFn:i}=Uk(),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)(null),[f,m]=(0,d.useState)(!1),[h,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),{control:w,watch:D,reset:O,setValue:k}=Id({defaultValues:{room:null}}),A=D(`room`),j=(0,d.useCallback)(()=>{y(null),u(null),c([]),m(!1)},[]);(0,d.useEffect)(()=>{if(j(),!A){x(null),C(null),_(!1);return}x(A),_(A.building.site.has_external_chemical_labelling)},[A,j]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`);e&&se({id:parseInt(e)}).then(e=>{x(e),_(e.building.site.has_external_chemical_labelling),k(`room`,e)})},[k]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`location`);e&&oe({id:parseInt(e)}).then(e=>{C(e),x(e.zone_group.room),_(e.zone_group.room.building.site.has_external_chemical_labelling),k(`room`,e.zone_group.room)})},[k]);let M=(0,d.useCallback)(()=>{O({room:b}),C(null),j()},[O,b,j]),N=(0,d.useId)();(0,d.useEffect)(()=>(t(N,o),()=>{n(N)}),[]);let P=(0,d.useCallback)(async e=>{if(!(!b||e.includes(`/l/`))){if(y(e),e.includes(`/cc/`)){let t=e.split(`/cc/`)[1],n=await T({id:parseInt(t)});u(n)}try{let t=await E({qrCodeContent:e});t?.items?.length>0?(c(t.items),m(!1)):(m(!0),c([]))}catch(e){console.error(`Error fetching chemical container external labels`,e),c([]),m(!1)}}},[b]);(0,d.useEffect)(()=>(i(Wk.WILD_CARD,N),b&&r(Wk.WILD_CARD,N,P),()=>i(Wk.WILD_CARD,N)),[P,b]);let F=(0,d.useId)();return(0,d.useEffect)(()=>(i(Wk.RESET_FORM,F),r(Wk.RESET_FORM,F,M),()=>i(Wk.RESET_FORM,F)),[M]),(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{style:{width:`fit-content`},children:(0,p.jsx)(FN,{control:w,name:`room`})}),(0,p.jsx)(`p`,{className:`pt-3 h3`,children:b?`Reading from scanner: ${v??`No chemical barcode scanned`}`:`Chemical scanner disabled`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(cP,{value:`reset-form`,size:100,className:`float-end`,onClick:M}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset form`})]})]}),!b&&(0,p.jsxs)(Cr,{variant:`warning`,className:`mt-3`,children:[(0,p.jsx)(Cr.Heading,{children:`No room selected`}),`Select a room before scanning chemical barcodes. Chemical intake scanning is disabled until a room is selected.`]}),b&&(0,p.jsx)(p.Fragment,{children:h?(0,p.jsxs)(Cr,{children:[`Lab `,b.name,` has external labels, each chemical material should have a material from the internal supplier/warehouse`]}):(0,p.jsxs)(Cr,{children:[`Lab `,b.name,` has no external labels, labels can be printed via the intake form`]})}),l&&(0,p.jsxs)(Cr,{variant:`info d-flex flex-column gap-3`,children:[`This is already an own chemical material, this is `,l.chemical.name,` and should be stored on`,` `,l.location.name,` in `,l.location.zone_group.room.name,(0,p.jsx)(`a`,{className:`alert-link`,href:`${e}/chemical/container/details/${l.id}/general.html`,children:`Go to container`})]}),!l&&v&&s.length>0&&(0,p.jsxs)(Nl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`Label`}),(0,p.jsx)(`th`,{children:`Container`}),(0,p.jsx)(`th`,{children:`Location`})]})}),(0,p.jsx)(`tbody`,{children:s.map(t=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:t.id}),(0,p.jsx)(`td`,{children:t.label}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${e}/chemical/container/details/${t.container.id}/general.html`,children:t.container.chemical.name})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${e}/location/details/${t.container.location.id}/general.html`,children:t.container.location.name})})]},t.id))})]}),!l&&f&&b&&v&&(0,p.jsx)(gP,{room:b,barcode:v,location:S,setLocation:C,resetForm:M}),!l&&b&&!h&&(0,p.jsx)(vP,{room:b,location:S,setLocation:C,resetForm:M})]})}function bP({badge_uuid:e}){return(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Card read: `,e]})}function xP({user_id:e}){let[t,n]=(0,d.useState)(``);return(0,d.useEffect)(()=>{let t=`https://`+wP+`/api/onelab/view/user/${e}`;(async()=>{try{let e=await fetch(t);if(!e.ok)throw Error(`Response status: ${e.status} with body: ${await e.text()}`);let r=await e.json();n(r.full_name)}catch(e){console.log(e)}})()},[]),(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Clients has detected user: `,t||`loading...`]})}function SP(){return(0,p.jsx)(`div`,{})}var CP=[`all`,`equipment`,`not_set`],wP=document.getElementById(`root`)?.dataset.goldsteinEndpoint??``,TP=`mock-token`,EP=10,DP=15;async function OP(e){let t=`https://`+wP+`/api/update/client-association`,n=prompt(`Select the new association for the client:`,e);if(n===null){alert(`Please enter a not null value`);return}let[r,i]=n.split(`:`),a=Number(i);if(!r||isNaN(a)||a===0){alert(`Please follow the correct format: $item:$id`);return}if(!CP.slice(1).includes(r)){alert(`Please select a valid $item: (equipment, not_set)`);return}let o=await fetch(t,{method:`PATCH`,body:JSON.stringify({previous_association:e,new_association:n}),headers:{"Content-type":`application/json; charset=UTF-8`}});if(!o.ok)throw Error(`Response status: ${o.status} with body: ${await o.text()}`);let s=await o.text();alert(s)}function kP(){let e=(0,d.useRef)(null),[t,n]=(0,d.useState)(new Map);async function r(e){let t=Lv(e.notifications_list,new Date,EP,DP);n(t)}function i(){let t=`
33
33
  SELECT * FROM notifications
34
34
  ${s===`all`?``:`WHERE association_item = "${s}"`}
35
- `.trim(),n={listening_association:`${s}:*`,sql_statement:t},r={package_type:jv.UPDATE_LISTENING_DATA,payload:JSON.stringify(n)};Nv(e.current,r),r={package_type:jv.GET_DATA,payload:``},Nv(e.current,r)}let a=()=>{setTimeout(()=>{(e.current===null||e.current.readyState===WebSocket.CLOSED||e.current.readyState===WebSocket.CLOSING)&&o()},1e3)},o=()=>{Fv(`wss://`+TP+`/ws`,EP).then(t=>{e.current!==null&&e.current.close(),t.onmessage=e=>{Pv(e,r)},t.onclose=()=>{console.log(`WebSocket closed`),a()},t.onerror=e=>{console.error(`WebSocket error`,e),a()},e.current=t,console.log(`WebSocket connected`),i(),Nv(t,{package_type:jv.GET_DATA,payload:``})}).catch(e=>{console.error(`WebSocket connection failed`,e),a()})};(0,d.useEffect)(()=>(o(),()=>{e.current&&(e.current.close(),console.log(`Web socket disconnected`))}),[]);let[s,c]=(0,d.useState)(wP[0]);return(0,d.useEffect)(()=>{i()},[s]),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h1`,{children:`Goldstein Clients`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`typeFilter`,children:`Filter by type:`}),(0,p.jsx)(`select`,{className:`form-control`,id:`typeFilter`,value:s,onChange:e=>c(e.target.value),children:wP.map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))})]}),(0,p.jsxs)(Nl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Client`}),(0,p.jsx)(`th`,{children:`Status`}),(0,p.jsx)(`th`,{children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:Array.from(t.entries()).map(([e,t])=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e}),(0,p.jsxs)(`td`,{children:[t.status===Iv.CLIENT_CONNECTED&&(0,p.jsx)(CP,{}),t.status===Iv.CARD_READED&&(0,p.jsx)(xP,{badge_uuid:t.message.badgeUUID}),t.status===Iv.USER_AUTHENTICATED&&(0,p.jsx)(SP,{user_id:t.message.userID})]}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>kP(e),children:`Edit association`})})]},e))})]})]})}var jP=e=>typeof e==`string`?e:``;function MP({result:e,status:t,onAutoSave:n,onDirty:r}){let{control:i,formState:a}=Du(),o=e.criterion_version,s=String(e.id),c=o.criterion.background_color&&o.criterion.has_background_color?{backgroundColor:o.criterion.background_color}:void 0,l=a.errors[s]?.message,u=o.required,d=e=>u?Array.isArray(e)?e.length>0||`This field is required.`:typeof e==`boolean`||e!=null&&e!==``||`This field is required.`:!0,f=l?`is-invalid`:t?.state===`saved`?`is-valid`:t?.state===`dirty`?`border-warning`:``,m=l?`border border-danger rounded p-2`:t?.state===`saved`?`border border-success rounded p-2`:t?.state===`dirty`?`border border-warning rounded p-2`:``,h=o.criterion.values??{};return(0,p.jsxs)(`div`,{className:`form-group mb-3 rounded ${o.highlighted?`border border-warning`:``}`,style:c,children:[(0,p.jsxs)(`label`,{htmlFor:`result-${e.id}`,className:`form-label`,children:[o.criterion.criterion,o.required&&(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsx)(wu,{name:s,control:i,rules:{validate:d},render:({field:t})=>{switch(o.criterion.input_type){case`integer`:case`float`:return(0,p.jsx)(`input`,{id:`result-${e.id}`,"aria-label":o.criterion.criterion,type:`number`,step:o.criterion.input_type===`float`?`0.01`:`1`,className:`form-control ${f}`,value:jP(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`date`:return(0,p.jsx)(`input`,{id:`result-${e.id}`,"aria-label":o.criterion.criterion,type:`date`,className:`form-control ${f}`,value:jP(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`text`:return(0,p.jsx)(`textarea`,{id:`result-${e.id}`,"aria-label":o.criterion.criterion,className:`form-control ${f}`,rows:3,value:jP(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`string`:return(0,p.jsx)(`input`,{id:`result-${e.id}`,"aria-label":o.criterion.criterion,type:`text`,className:`form-control ${f}`,value:jP(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`select`:return(0,p.jsxs)(`select`,{id:`result-${e.id}`,className:`form-select ${f}`,value:jP(t.value),onChange:i=>{t.onChange(i.target.value),r(e.id),n(e)},children:[(0,p.jsx)(`option`,{value:``,children:`-- select --`}),Object.entries(h).map(([e,t])=>(0,p.jsx)(`option`,{value:e,children:t},e))]});case`radio`:{let i=String(t.value??``);return(0,p.jsx)(`div`,{className:`form-check ${m}`,children:Object.entries(h).map(([a,o])=>(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`radio`,id:`result-${e.id}_${a}`,"aria-label":String(o),name:`result-${e.id}`,value:a,checked:i===a,onChange:i=>{t.onChange(i.target.value),r(e.id),n(e)},className:`form-check-input ${f}`}),(0,p.jsx)(`label`,{htmlFor:`result-${e.id}_${a}`,className:`form-check-label`,children:o})]},a))})}case`checkbox`:{let i=Array.isArray(t.value)?t.value:[],a=(a,o)=>{let s=o?[...i,a]:i.filter(e=>e!==a);t.onChange(s),r(e.id),n(e)};return(0,p.jsx)(`div`,{className:`form-check ${m}`,children:Object.entries(h).map(([t,n])=>(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,id:`result-${e.id}_${t}`,"aria-label":String(n),name:`result-${e.id}`,value:t,checked:i.includes(t),onChange:e=>a(t,e.target.checked),className:`form-check-input ${f}`}),(0,p.jsx)(`label`,{htmlFor:`result-${e.id}_${t}`,className:`form-check-label`,children:n})]},t))})}case`bool`:return(0,p.jsx)(`div`,{className:`form-check form-switch ${m}`,children:(0,p.jsx)(`input`,{type:`checkbox`,id:`result-${e.id}`,"aria-label":o.criterion.criterion,checked:!!t.value,onChange:i=>{t.onChange(i.target.checked),r(e.id),n(e)},className:`form-check-input ${f}`})});case`action`:return(0,p.jsxs)(`div`,{className:`d-flex align-items-center ${m}`,children:[(0,p.jsx)(`span`,{className:`me-2`,children:`Done `}),(0,p.jsxs)(`div`,{role:`group`,"aria-label":`${e.id}-action`,className:`btn-group btn-group-sm`,children:[(0,p.jsx)(`button`,{type:`button`,className:`btn ${t.value?`btn-primary`:`btn-outline-secondary`}`,onClick:()=>{t.onChange(!0),r(e.id),n(e)},"aria-pressed":!!t.value,children:`Yes`}),(0,p.jsx)(`button`,{type:`button`,className:`btn ${t.value?`btn-outline-secondary`:`btn-primary`}`,onClick:()=>{t.onChange(!1),r(e.id),n(e)},"aria-pressed":!t.value,children:`No`})]})]});default:return(0,p.jsx)(p.Fragment,{})}}}),o.criterion.help_block&&(0,p.jsx)(`small`,{className:`form-text text-muted`,children:o.criterion.help_block}),l&&(0,p.jsx)(`div`,{className:`invalid-feedback`,children:l})]})}function NP({categoryId:e,label:t,results:n}){let r=(0,d.useRef)({}),i=(0,d.useRef)({}),a=String(e),[o,s]=(0,d.useState)({categoryId:a,statuses:{}}),c=o.categoryId===a?o.statuses:{},l=(0,d.useCallback)(e=>{let t={},n=e=>e===null?null:String(e);return e.forEach(e=>{let r=e.criterion_version;if(r.criterion.input_type===`checkbox`){let n=e.value||r.default_value||``;t[String(e.id)]=n?n.toString().split(`, `):[]}else if(r.criterion.input_type===`bool`||r.criterion.input_type===`action`){let n=e.value??r.default_value??`false`;t[String(e.id)]=n===`true`}else{let i=e.value??r.default_value??``;t[String(e.id)]=n(i)??``}}),t},[]),u=Id({defaultValues:(0,d.useMemo)(()=>l(n),[l,n]),mode:`onBlur`}),{control:m,getValues:h,reset:g,trigger:_}=u;(0,d.useEffect)(()=>{let e=r.current[a];if(e)g(e);else{let e=l(n);r.current[a]=e,g(e)}},[l,a,g,n]);let v=Su({control:m});(0,d.useEffect)(()=>{if(!v)return;let e=Object.entries(v);r.current[a]=e.reduce((e,[t,n])=>(e[t]=n??null,e),{})},[v,a]);let y=(0,d.useCallback)(async e=>{let t=String(e.id);if(!await _(t))return;let n=h(t),r=(i.current[e.id]??0)+1;i.current[e.id]=r,s(t=>({categoryId:a,statuses:{...t.categoryId===a?t.statuses:{},[e.id]:{state:`saving`}}}));let o=n??``;Array.isArray(n)?o=n.join(`, `):typeof n==`boolean`&&(o=n?`true`:`false`);try{await f.default.patch(`/update/service/event/report/result/${e.id}`,{value:o}),i.current[e.id]===r&&s(t=>({categoryId:a,statuses:{...t.categoryId===a?t.statuses:{},[e.id]:{state:`saved`,savedAt:Date.now()}}}))}catch(t){console.error(`Failed to save:`,t),i.current[e.id]===r&&s(t=>({categoryId:a,statuses:{...t.categoryId===a?t.statuses:{},[e.id]:{state:`error`,message:`Save failed. Try again.`}}}))}},[a,h,_]),b=(0,d.useCallback)(e=>{s(t=>({categoryId:a,statuses:{...t.categoryId===a?t.statuses:{},[e]:{state:`dirty`}}}))},[a]),x=(0,d.useMemo)(()=>Object.values(c).some(e=>e.state===`dirty`||e.state===`saving`||e.state===`error`),[c]);return(0,d.useEffect)(()=>{let e=e=>{x&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[x]),(0,p.jsxs)(Ou,{...u,children:[(0,p.jsx)(`legend`,{children:t}),n.map(e=>(0,p.jsx)(MP,{result:e,status:c[e.id],onAutoSave:y,onDirty:b},e.id))]})}function PP(){let{id:e}=(0,g.useParams)(),t=(0,g.useLocation)(),n=(0,g.useNavigate)(),[r,i]=(0,d.useState)(),[a,o]=(0,d.useState)({}),[s,c]=(0,d.useState)({}),[l,u]=(0,d.useState)(0),[f,m]=(0,d.useState)(null);(0,d.useEffect)(()=>{e&&(Ge({id:Number(e)}).then(e=>{let t=e.reduce((e,t)=>{let n=t.criterion_version.type.category,r=String(n.id);return e[r]||(e[r]=[]),e[r].push(t),e},{}),n={},r={};e.forEach(e=>{let t=e.criterion_version.type.category,i=String(t.id);n[i]=t.category,r[i]=typeof t.sequence==`number`?t.sequence:2**53-1}),i(t),o(n),c(r)}),Ke({id:Number(e)}).then(e=>m(e)).catch(()=>m(null)))},[e]);let h=(0,d.useMemo)(()=>r?Object.keys(r).sort((e,t)=>{let n=s[e]??2**53-1,r=s[t]??2**53-1;return n===r?Number(e)-Number(t):n-r}):[],[r,s]),_=h.length;return(0,d.useEffect)(()=>{if(!_)return;let e=new URLSearchParams(t.search).get(`category`);if(e){let t=h.indexOf(e);if(t!==-1){u(t);return}}u(0)},[_,t.search,h]),(0,d.useEffect)(()=>{if(!_)return;let e=h[l],r=new URLSearchParams(t.search);e&&r.get(`category`)!==e&&(r.set(`category`,e),n({pathname:t.pathname,search:r.toString()},{replace:!1}))},[l,_,h,t.pathname,t.search,n]),r?_===0?(0,p.jsx)(`div`,{children:`No categories found`}):(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-center align-items-center gap-3 mb-3`,children:[(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-outline-primary`,onClick:()=>{u(e=>Math.max(e-1,0))},disabled:l===0,children:`Previous`}),(0,p.jsxs)(`div`,{className:`text-center`,children:[`Category `,l+1,` of `,_]}),(0,p.jsx)(`button`,{type:`button`,className:`btn btn-outline-primary btn-sm`,onClick:()=>{u(e=>Math.min(e+1,_-1))},disabled:l===_-1,children:`Next`})]}),(0,p.jsx)(NP,{categoryId:h[l],label:a[h[l]],results:r[h[l]]})]}):(0,p.jsx)(`div`,{children:`Loading…`})}var FP={active:`text-bg-warning`,approved:`text-bg-success`,canceled:`text-bg-secondary`,cancelled:`text-bg-secondary`,completed:`text-bg-success`,done:`text-bg-success`,error:`text-bg-danger`,expired:`text-bg-secondary`,failed:`text-bg-danger`,pending:`text-bg-warning`,processing:`text-bg-warning`,queued:`text-bg-warning`,rejected:`text-bg-danger`,running:`text-bg-warning`,skipped:`text-bg-secondary`,started:`text-bg-warning`,success:`text-bg-success`,uploaded:`text-bg-success`};function IP(e){let t=e.trim().toLowerCase();return t in FP?FP[t]:/(fail|error|reject|invalid|deny)/.test(t)?`text-bg-danger`:/(complete|done|success|approve|upload|finish|ready|ok)/.test(t)?`text-bg-success`:/(run|process|progress|pending|queue|start|wait|active)/.test(t)?`text-bg-warning`:/(cancel|skip|expire|close|stop)/.test(t)?`text-bg-secondary`:`text-bg-info`}function LP(e){return e instanceof Map?Array.from(e.entries()):Array.isArray(e)?e.flatMap(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&typeof e[1]==`string`?[[e[0],e[1]]]:[]):typeof e==`object`&&e?Object.entries(e).flatMap(([e,t])=>typeof t==`string`?[[e,t]]:[]):[]}var RP={approve:{action:`approve`,buttonClassName:`btn-success`,label:`Approve`,successMessage:`Upload approved.`},fail:{action:`fail`,buttonClassName:`btn-outline-warning`,label:`Mark as failed`,successMessage:`Upload marked as failed.`},finish:{action:`finish`,buttonClassName:`btn-primary`,label:`Mark as finished`,successMessage:`Upload marked as finished.`},reject:{action:`reject`,buttonClassName:`btn-outline-danger`,label:`Reject`,successMessage:`Upload rejected.`}},zP={awaiting_approval:[`approve`,`reject`,`fail`],started:[`reject`,`fail`],syncing:[`fail`],uploading:[`finish`,`reject`,`fail`]};function BP(e){return(zP[e]??[]).map(e=>RP[e])}function VP(e){if(typeof e==`object`&&e&&`response`in e){let t=e.response;if(typeof t?.data?.message==`string`)return t.data.message}return e instanceof Error&&e.message!==``?e.message:`Could not process upload action.`}function HP({event:e,contentEntries:t,irisEndpoint:n,onEventUpdated:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),u=(0,d.useMemo)(()=>e?BP(e.state):[],[e]),f=(0,d.useCallback)(async t=>{if(e){a(t),s(``),l(``);try{let i={fileUploadEventUid:e.uid,irisServerUrl:n},a;a=t===`approve`?await at(i):t===`fail`?await rt(i):t===`finish`?await it(i):await ot(i);let o=u.find(e=>e.action===t);r(a),l(o?.successMessage??`Action completed.`)}catch(e){s(VP(e))}finally{a(null)}}},[u,e,n,r]);return(0,p.jsxs)(`div`,{className:`border rounded h-100`,children:[(0,p.jsxs)(`div`,{className:`border-bottom px-3 py-2`,children:[(0,p.jsx)(`div`,{className:`fw-semibold`,children:`Event details`}),(0,p.jsx)(`div`,{className:`small text-secondary`,children:`Inspect the current state and attached payload files`})]}),!e&&(0,p.jsx)(`div`,{className:`p-4 text-secondary`,children:`Choose an event to inspect its details.`}),e&&(0,p.jsxs)(`div`,{className:`p-3 p-lg-4`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-md-row justify-content-between gap-3 mb-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Event id`}),(0,p.jsx)(`code`,{className:`text-break`,children:e.uid})]}),(0,p.jsx)(`div`,{className:`d-flex align-items-start`,children:(0,p.jsx)(`span`,{className:`badge ${IP(e.state)}`,children:e.state})})]}),(0,p.jsxs)(`div`,{className:`row g-3 mb-4`,children:[(0,p.jsx)(`div`,{className:`col-md-6`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Context`}),(0,p.jsx)(`div`,{className:`fw-semibold text-break`,children:e.context})]})}),(0,p.jsx)(`div`,{className:`col-md-6`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Started`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:zD(e.start)})]})}),(0,p.jsx)(`div`,{className:`col-md-4`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Completed state`}),(0,p.jsx)(`div`,{className:`fw-semibold text-break`,children:e.completedState||`-`})]})}),(0,p.jsx)(`div`,{className:`col-md-4`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`TTL`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.TTL})]})}),(0,p.jsx)(`div`,{className:`col-md-4`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Auto approve`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.autoApprove?`Enabled`:`Disabled`})]})})]}),(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-2 gap-2`,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`h6 mb-0`,children:`Actions`}),(0,p.jsx)(`div`,{className:`small text-secondary`,children:`State transition actions available for this event`})]})}),u.length===0&&(0,p.jsx)(`div`,{className:`rounded border p-3 text-secondary`,children:`No manual actions are available for this state.`}),u.length>0&&(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-2`,children:u.map(e=>(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm ${e.buttonClassName}`,disabled:i!==null,onClick:()=>f(e.action),children:i===e.action?`Processing...`:e.label},e.action))}),o!==``&&(0,p.jsx)(`div`,{className:`alert alert-danger py-2 mt-3 mb-0`,children:o}),c!==``&&(0,p.jsx)(`div`,{className:`alert alert-success py-2 mt-3 mb-0`,children:c})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-2 gap-2`,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`h6 mb-0`,children:`Attached files`}),(0,p.jsxs)(`div`,{className:`small text-secondary`,children:[t.length,` file entries available`]})]})}),t.length===0&&(0,p.jsx)(`div`,{className:`rounded border p-3 text-secondary`,children:`This event does not include attached files.`}),t.length>0&&(0,p.jsx)(`div`,{className:`vstack gap-3`,children:t.map(([e,t])=>(0,p.jsxs)(`div`,{className:`rounded border overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 border-bottom d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`code`,{className:`text-break`,children:e}),(0,p.jsx)(`span`,{className:`badge border`,children:`attached`})]}),(0,p.jsx)(`pre`,{className:`m-0 p-3 bg-body-tertiary`,style:{maxHeight:220,overflow:`auto`},children:(0,p.jsx)(`code`,{children:t})})]},e))})]})]})]})}function UP({activeContext:e,events:t,selectedEventUid:n,onSelectEvent:r}){return(0,p.jsxs)(`div`,{className:`border rounded overflow-hidden h-100`,children:[(0,p.jsxs)(`div`,{className:`border-bottom px-3 py-2`,children:[(0,p.jsx)(`div`,{className:`fw-semibold`,children:`Incoming upload events`}),(0,p.jsx)(`div`,{className:`small text-secondary`,children:`Latest messages for the selected context`})]}),(0,p.jsxs)(`div`,{className:`list-group list-group-flush`,children:[t.map(e=>{let t=n===e.uid;return(0,p.jsxs)(`button`,{type:`button`,className:`list-group-item list-group-item-action text-start ${t?`active`:``}`,onClick:()=>r(e.uid),children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-start gap-2 mb-2`,children:[(0,p.jsx)(`code`,{className:t?`text-white`:``,children:e.uid}),(0,p.jsx)(`span`,{className:`badge ${IP(e.state)}`,children:e.state})]}),(0,p.jsxs)(`div`,{className:`small ${t?`text-white-50`:`text-secondary`}`,children:[(0,p.jsxs)(`div`,{children:[`Context: `,e.context]}),(0,p.jsxs)(`div`,{children:[`Started: `,zD(e.start)]})]})]},e.uid)}),e!==``&&t.length===0&&(0,p.jsx)(`div`,{className:`list-group-item text-secondary`,children:`Listening for new events...`}),e===``&&(0,p.jsx)(`div`,{className:`list-group-item text-secondary`,children:`Select a context to start the live stream.`})]})]})}function WP({irisEndpoint:e,context:t,onMessage:n,onError:r}){let i=(0,d.useRef)(null),a=(0,d.useRef)(null),o=(0,d.useRef)(!0),s=(0,d.useRef)(0),[c,l]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{if(!t)return;o.current=!0;let c=()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},u=()=>{c();let d=tt({context:t,irisServerUrl:e.endsWith(`/`)?e:`${e}/`,onOpen:()=>{s.current=0,l(!0)},onEvent:e=>{n(e)},onError:e=>{if(l(!1),r(e),d.close(),!o.current)return;let t=Math.min(1e3*2**s.current,3e4);s.current+=1,a.current=window.setTimeout(()=>{u()},t)}});i.current=d,d.start()};return u(),()=>{o.current=!1,c(),i.current?.close(),i.current=null,l(!1)}},[e,t,n,r]),{isConnected:c,close:()=>{o.current=!1,a.current!==null&&(window.clearTimeout(a.current),a.current=null),i.current?.close(),i.current=null,l(!1)}}}function GP(){let[e,t]=(0,d.useState)(``),[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)([]),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),u=xt();(0,d.useEffect)(()=>{n&&nt({irisServerUrl:u,context:n}).then(e=>{a(e)})},[n]);let f=(0,d.useCallback)(e=>{n!==``&&e.context===n&&(l(``),a(t=>[e,...t.filter(t=>t.uid!==e.uid)]),s(e.uid))},[n]),{isConnected:m}=WP({irisEndpoint:u,context:n,onMessage:f,onError:(0,d.useCallback)(e=>{if(n===``){l(``);return}if(e===null){l(``);return}l(`Error trying to connect to the server, reconnecting....`)},[n])}),h=(0,d.useCallback)(t=>{t.preventDefault(),r(e),a([]),s(``),l(``)},[e]),g=(0,d.useMemo)(()=>i.length===0?null:i.find(e=>e.uid===o)??i[0],[i,o]),_=(0,d.useMemo)(()=>g?LP(g.content):[],[g]);return(0,p.jsx)(`div`,{className:`w-100`,children:(0,p.jsx)(`div`,{className:`card shadow-sm border-0`,children:(0,p.jsxs)(`div`,{className:`card-body p-3 p-lg-4`,children:[(0,p.jsxs)(`form`,{onSubmit:h,className:`row g-2 align-items-end mb-4`,children:[(0,p.jsxs)(`div`,{className:`col-lg-8`,children:[(0,p.jsx)(`label`,{className:`form-label fw-semibold`,htmlFor:`iris-context-input`,children:`Context`}),(0,p.jsx)(`input`,{id:`iris-context-input`,className:`form-control`,type:`text`,value:e,placeholder:`lab-a`,onChange:e=>t(e.target.value)})]}),(0,p.jsx)(`div`,{className:`col-lg-4 col-xl-2`,children:(0,p.jsx)(`button`,{className:`btn btn-primary w-100`,type:`submit`,disabled:e.trim()===``,children:`Load context`})})]}),c!==``&&(0,p.jsx)(`div`,{className:`alert alert-danger py-2 mb-4`,children:c}),!m&&(0,p.jsx)(`div`,{className:`alert alert-warning py-2 mb-4`,children:`Could not connect to the server`}),m&&(0,p.jsxs)(`div`,{className:`row g-3`,children:[(0,p.jsx)(`div`,{className:`col-xl-5`,children:(0,p.jsx)(UP,{activeContext:n,events:i,selectedEventUid:g?.uid||``,onSelectEvent:s})}),(0,p.jsx)(`div`,{className:`col-xl-7`,children:(0,p.jsx)(HP,{event:g,contentEntries:_,irisEndpoint:u,onEventUpdated:f},g?.uid||``)})]},`${n}${i.length>0?i[0].uid:``}`)]})})})}function KP(e){switch(e){case`Shift`:return!0;case`Alt`:return!0;case`Control`:return!0;case`Meta`:return!0}return!1}function qP(e){switch(e){case`Enter`:return!0;default:return!1}}function JP(e,t){let n=``,r=()=>{n=``,t&&t(n)};return i=>{if(i.target instanceof HTMLInputElement||i.target instanceof HTMLTextAreaElement)return;let a=i.key;if(!KP(a)){if(a===`Escape`){r();return}if(qP(a)){e(n),r();return}n+=a,t&&t(n)}}}var YP=({children:e})=>{let[t,n]=(0,d.useState)(``),r=(0,d.useRef)(new Map),i=(0,d.useRef)(new Map),a=e=>{(0,d.startTransition)(()=>{i.current.forEach(t=>t(e))})},o=e=>{n(e);let t=Kk(e);(0,d.startTransition)(()=>{r.current.get(t)?.forEach(t=>t(e))})};return(0,d.useEffect)(()=>{let e=JP(o,a);return document.addEventListener(`keyup`,e),()=>{document.removeEventListener(`keyup`,e)}},[o,a]),(0,p.jsx)(Uk.Provider,{value:{lastlyReadedKeys:t,addCallbackFn:(e,t,n)=>{r.current.has(e)||r.current.set(e,new Map),r.current.get(e).set(t,n)},removeCallbackFn:(e,t)=>{r.current.get(e)?.delete(t)},addReadingCallbackFn:(e,t)=>{i.current.set(e,t)},removeReadingCallbackFn:e=>{i.current.delete(e)}},children:e})};function XP({runsList:e,onFail:t=e=>null}){let[n,r]=(0,d.useState)(null),{lastlyReadedKeys:i}=Wk();return(0,d.useEffect)(()=>{let n=i.replace(/_/g,`-`).toUpperCase(),a=e.find(e=>n.includes(e.label));if(!a){t(`Run not found`);return}Yk({notificationHeader:`Run scanner`,notificationBody:`Run ${a.label} found`,notificationType:`success`}),r(a)},[i]),{selectedRun:n}}exports.AuthContext=v,exports.AuthProvider=kt,exports.BatchCardElement=dk,exports.ChemicalHeaderElement=FN,exports.ChemicalIntakeElement=bP,exports.DateFormat=uk,exports.EditRunParents=gj,exports.EmphasizedParametersContext=hk,exports.EmphasizedParametersProvider=PN,exports.EquipmentContext=iO,exports.EquipmentDashboard=lO,exports.EquipmentHeaderElement=pO,exports.EquipmentProvider=dO,exports.GoldsteinClientsDashboard=AP,exports.GoldsteinEquipmentDashboard=ly,exports.InputModal=jN,exports.IrisOperatorDashboard=GP,exports.ModuleStatusElement=Ld,exports.MonitorCard=tO,exports.MonitorContext=ik,exports.MonitorHeaderElement=nk,exports.MonitorPage=tk,exports.MonitorProvider=ak,exports.NewRunWizard=hj,exports.NotificationProvider=Xk,exports.PaginationLinks=KO,exports.ReportResults=PP,exports.RunContext=sk,exports.RunHeaderElement=mk,exports.RunInformationElement=bj,exports.RunLayoutElement=Nj,exports.RunProvider=ck,exports.RunStepChecklist=Uj,exports.RunStepContext=MA,exports.RunStepExecuteElement=MN,exports.RunStepExecuteMinimal=NN,exports.RunStepHeaderElement=Ij,exports.RunStepProvider=Fj,exports.RunStepsElement=zA,exports.ScannerContext=Uk,exports.ScannerProvider=YP,exports.SetupUpdateEquipment=Dv,exports.StatusMailComponent=eO,exports.StatusMailContext=uy,exports.StatusMailProvider=mO,exports.StepDetails=cA,exports.initSolodbComponents=vt,exports.notification=Yk,exports.useAuth=St,exports.useScannerContext=Wk,exports.useSelectRunWithScanner=XP;
35
+ `.trim(),n={listening_association:`${s}:*`,sql_statement:t},r={package_type:jv.UPDATE_LISTENING_DATA,payload:JSON.stringify(n)};Nv(e.current,r),r={package_type:jv.GET_DATA,payload:``},Nv(e.current,r)}let a=()=>{setTimeout(()=>{(e.current===null||e.current.readyState===WebSocket.CLOSED||e.current.readyState===WebSocket.CLOSING)&&o()},1e3)},o=()=>{Fv(`wss://`+wP+`/ws`,TP).then(t=>{e.current!==null&&e.current.close(),t.onmessage=e=>{Pv(e,r)},t.onclose=()=>{console.log(`WebSocket closed`),a()},t.onerror=e=>{console.error(`WebSocket error`,e),a()},e.current=t,console.log(`WebSocket connected`),i(),Nv(t,{package_type:jv.GET_DATA,payload:``})}).catch(e=>{console.error(`WebSocket connection failed`,e),a()})};(0,d.useEffect)(()=>(o(),()=>{e.current&&(e.current.close(),console.log(`Web socket disconnected`))}),[]);let[s,c]=(0,d.useState)(CP[0]);return(0,d.useEffect)(()=>{i()},[s]),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h1`,{children:`Goldstein Clients`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`typeFilter`,children:`Filter by type:`}),(0,p.jsx)(`select`,{className:`form-control`,id:`typeFilter`,value:s,onChange:e=>c(e.target.value),children:CP.map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))})]}),(0,p.jsxs)(Nl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Client`}),(0,p.jsx)(`th`,{children:`Status`}),(0,p.jsx)(`th`,{children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:Array.from(t.entries()).map(([e,t])=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e}),(0,p.jsxs)(`td`,{children:[t.status===Iv.CLIENT_CONNECTED&&(0,p.jsx)(SP,{}),t.status===Iv.CARD_READED&&(0,p.jsx)(bP,{badge_uuid:t.message.badgeUUID}),t.status===Iv.USER_AUTHENTICATED&&(0,p.jsx)(xP,{user_id:t.message.userID})]}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>OP(e),children:`Edit association`})})]},e))})]})]})}var AP=e=>typeof e==`string`?e:``;function jP({result:e,status:t,onAutoSave:n,onDirty:r}){let{control:i,formState:a}=Du(),o=e.criterion_version,s=String(e.id),c=o.criterion.background_color&&o.criterion.has_background_color?{backgroundColor:o.criterion.background_color}:void 0,l=a.errors[s]?.message,u=o.required,d=e=>u?Array.isArray(e)?e.length>0||`This field is required.`:typeof e==`boolean`||e!=null&&e!==``||`This field is required.`:!0,f=l?`is-invalid`:t?.state===`saved`?`is-valid`:t?.state===`dirty`?`border-warning`:``,m=l?`border border-danger rounded p-2`:t?.state===`saved`?`border border-success rounded p-2`:t?.state===`dirty`?`border border-warning rounded p-2`:``,h=o.criterion.values??{};return(0,p.jsxs)(`div`,{className:`form-group mb-3 rounded ${o.highlighted?`border border-warning`:``}`,style:c,children:[(0,p.jsxs)(`label`,{htmlFor:`result-${e.id}`,className:`form-label`,children:[o.criterion.criterion,o.required&&(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsx)(wu,{name:s,control:i,rules:{validate:d},render:({field:t})=>{switch(o.criterion.input_type){case`integer`:case`float`:return(0,p.jsx)(`input`,{id:`result-${e.id}`,"aria-label":o.criterion.criterion,type:`number`,step:o.criterion.input_type===`float`?`0.01`:`1`,className:`form-control ${f}`,value:AP(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`date`:return(0,p.jsx)(`input`,{id:`result-${e.id}`,"aria-label":o.criterion.criterion,type:`date`,className:`form-control ${f}`,value:AP(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`text`:return(0,p.jsx)(`textarea`,{id:`result-${e.id}`,"aria-label":o.criterion.criterion,className:`form-control ${f}`,rows:3,value:AP(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`string`:return(0,p.jsx)(`input`,{id:`result-${e.id}`,"aria-label":o.criterion.criterion,type:`text`,className:`form-control ${f}`,value:AP(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`select`:return(0,p.jsxs)(`select`,{id:`result-${e.id}`,className:`form-select ${f}`,value:AP(t.value),onChange:i=>{t.onChange(i.target.value),r(e.id),n(e)},children:[(0,p.jsx)(`option`,{value:``,children:`-- select --`}),Object.entries(h).map(([e,t])=>(0,p.jsx)(`option`,{value:e,children:t},e))]});case`radio`:{let i=String(t.value??``);return(0,p.jsx)(`div`,{className:`form-check ${m}`,children:Object.entries(h).map(([a,o])=>(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`radio`,id:`result-${e.id}_${a}`,"aria-label":String(o),name:`result-${e.id}`,value:a,checked:i===a,onChange:i=>{t.onChange(i.target.value),r(e.id),n(e)},className:`form-check-input ${f}`}),(0,p.jsx)(`label`,{htmlFor:`result-${e.id}_${a}`,className:`form-check-label`,children:o})]},a))})}case`checkbox`:{let i=Array.isArray(t.value)?t.value:[],a=(a,o)=>{let s=o?[...i,a]:i.filter(e=>e!==a);t.onChange(s),r(e.id),n(e)};return(0,p.jsx)(`div`,{className:`form-check ${m}`,children:Object.entries(h).map(([t,n])=>(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,id:`result-${e.id}_${t}`,"aria-label":String(n),name:`result-${e.id}`,value:t,checked:i.includes(t),onChange:e=>a(t,e.target.checked),className:`form-check-input ${f}`}),(0,p.jsx)(`label`,{htmlFor:`result-${e.id}_${t}`,className:`form-check-label`,children:n})]},t))})}case`bool`:return(0,p.jsx)(`div`,{className:`form-check form-switch ${m}`,children:(0,p.jsx)(`input`,{type:`checkbox`,id:`result-${e.id}`,"aria-label":o.criterion.criterion,checked:!!t.value,onChange:i=>{t.onChange(i.target.checked),r(e.id),n(e)},className:`form-check-input ${f}`})});case`action`:return(0,p.jsxs)(`div`,{className:`d-flex align-items-center ${m}`,children:[(0,p.jsx)(`span`,{className:`me-2`,children:`Done `}),(0,p.jsxs)(`div`,{role:`group`,"aria-label":`${e.id}-action`,className:`btn-group btn-group-sm`,children:[(0,p.jsx)(`button`,{type:`button`,className:`btn ${t.value?`btn-primary`:`btn-outline-secondary`}`,onClick:()=>{t.onChange(!0),r(e.id),n(e)},"aria-pressed":!!t.value,children:`Yes`}),(0,p.jsx)(`button`,{type:`button`,className:`btn ${t.value?`btn-outline-secondary`:`btn-primary`}`,onClick:()=>{t.onChange(!1),r(e.id),n(e)},"aria-pressed":!t.value,children:`No`})]})]});default:return(0,p.jsx)(p.Fragment,{})}}}),o.criterion.help_block&&(0,p.jsx)(`small`,{className:`form-text text-muted`,children:o.criterion.help_block}),l&&(0,p.jsx)(`div`,{className:`invalid-feedback`,children:l})]})}function MP({categoryId:e,label:t,results:n}){let r=(0,d.useRef)({}),i=(0,d.useRef)({}),a=String(e),[o,s]=(0,d.useState)({categoryId:a,statuses:{}}),c=o.categoryId===a?o.statuses:{},l=(0,d.useCallback)(e=>{let t={},n=e=>e===null?null:String(e);return e.forEach(e=>{let r=e.criterion_version;if(r.criterion.input_type===`checkbox`){let n=e.value||r.default_value||``;t[String(e.id)]=n?n.toString().split(`, `):[]}else if(r.criterion.input_type===`bool`||r.criterion.input_type===`action`){let n=e.value??r.default_value??`false`;t[String(e.id)]=n===`true`}else{let i=e.value??r.default_value??``;t[String(e.id)]=n(i)??``}}),t},[]),u=Id({defaultValues:(0,d.useMemo)(()=>l(n),[l,n]),mode:`onBlur`}),{control:m,getValues:h,reset:g,trigger:_}=u;(0,d.useEffect)(()=>{let e=r.current[a];if(e)g(e);else{let e=l(n);r.current[a]=e,g(e)}},[l,a,g,n]);let v=Su({control:m});(0,d.useEffect)(()=>{if(!v)return;let e=Object.entries(v);r.current[a]=e.reduce((e,[t,n])=>(e[t]=n??null,e),{})},[v,a]);let y=(0,d.useCallback)(async e=>{let t=String(e.id);if(!await _(t))return;let n=h(t),r=(i.current[e.id]??0)+1;i.current[e.id]=r,s(t=>({categoryId:a,statuses:{...t.categoryId===a?t.statuses:{},[e.id]:{state:`saving`}}}));let o=n??``;Array.isArray(n)?o=n.join(`, `):typeof n==`boolean`&&(o=n?`true`:`false`);try{await f.default.patch(`/update/service/event/report/result/${e.id}`,{value:o}),i.current[e.id]===r&&s(t=>({categoryId:a,statuses:{...t.categoryId===a?t.statuses:{},[e.id]:{state:`saved`,savedAt:Date.now()}}}))}catch(t){console.error(`Failed to save:`,t),i.current[e.id]===r&&s(t=>({categoryId:a,statuses:{...t.categoryId===a?t.statuses:{},[e.id]:{state:`error`,message:`Save failed. Try again.`}}}))}},[a,h,_]),b=(0,d.useCallback)(e=>{s(t=>({categoryId:a,statuses:{...t.categoryId===a?t.statuses:{},[e]:{state:`dirty`}}}))},[a]),x=(0,d.useMemo)(()=>Object.values(c).some(e=>e.state===`dirty`||e.state===`saving`||e.state===`error`),[c]);return(0,d.useEffect)(()=>{let e=e=>{x&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[x]),(0,p.jsxs)(Ou,{...u,children:[(0,p.jsx)(`legend`,{children:t}),n.map(e=>(0,p.jsx)(jP,{result:e,status:c[e.id],onAutoSave:y,onDirty:b},e.id))]})}function NP(){let{id:e}=(0,g.useParams)(),t=(0,g.useLocation)(),n=(0,g.useNavigate)(),[r,i]=(0,d.useState)(),[a,o]=(0,d.useState)({}),[s,c]=(0,d.useState)({}),[l,u]=(0,d.useState)(0),[f,m]=(0,d.useState)(null);(0,d.useEffect)(()=>{e&&(Ge({id:Number(e)}).then(e=>{let t=e.reduce((e,t)=>{let n=t.criterion_version.type.category,r=String(n.id);return e[r]||(e[r]=[]),e[r].push(t),e},{}),n={},r={};e.forEach(e=>{let t=e.criterion_version.type.category,i=String(t.id);n[i]=t.category,r[i]=typeof t.sequence==`number`?t.sequence:2**53-1}),i(t),o(n),c(r)}),Ke({id:Number(e)}).then(e=>m(e)).catch(()=>m(null)))},[e]);let h=(0,d.useMemo)(()=>r?Object.keys(r).sort((e,t)=>{let n=s[e]??2**53-1,r=s[t]??2**53-1;return n===r?Number(e)-Number(t):n-r}):[],[r,s]),_=h.length;return(0,d.useEffect)(()=>{if(!_)return;let e=new URLSearchParams(t.search).get(`category`);if(e){let t=h.indexOf(e);if(t!==-1){u(t);return}}u(0)},[_,t.search,h]),(0,d.useEffect)(()=>{if(!_)return;let e=h[l],r=new URLSearchParams(t.search);e&&r.get(`category`)!==e&&(r.set(`category`,e),n({pathname:t.pathname,search:r.toString()},{replace:!1}))},[l,_,h,t.pathname,t.search,n]),r?_===0?(0,p.jsx)(`div`,{children:`No categories found`}):(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-center align-items-center gap-3 mb-3`,children:[(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-outline-primary`,onClick:()=>{u(e=>Math.max(e-1,0))},disabled:l===0,children:`Previous`}),(0,p.jsxs)(`div`,{className:`text-center`,children:[`Category `,l+1,` of `,_]}),(0,p.jsx)(`button`,{type:`button`,className:`btn btn-outline-primary btn-sm`,onClick:()=>{u(e=>Math.min(e+1,_-1))},disabled:l===_-1,children:`Next`})]}),(0,p.jsx)(MP,{categoryId:h[l],label:a[h[l]],results:r[h[l]]})]}):(0,p.jsx)(`div`,{children:`Loading…`})}var PP={active:`text-bg-warning`,approved:`text-bg-success`,canceled:`text-bg-secondary`,cancelled:`text-bg-secondary`,completed:`text-bg-success`,done:`text-bg-success`,error:`text-bg-danger`,expired:`text-bg-secondary`,failed:`text-bg-danger`,pending:`text-bg-warning`,processing:`text-bg-warning`,queued:`text-bg-warning`,rejected:`text-bg-danger`,running:`text-bg-warning`,skipped:`text-bg-secondary`,started:`text-bg-warning`,success:`text-bg-success`,uploaded:`text-bg-success`};function FP(e){let t=e.trim().toLowerCase();return t in PP?PP[t]:/(fail|error|reject|invalid|deny)/.test(t)?`text-bg-danger`:/(complete|done|success|approve|upload|finish|ready|ok)/.test(t)?`text-bg-success`:/(run|process|progress|pending|queue|start|wait|active)/.test(t)?`text-bg-warning`:/(cancel|skip|expire|close|stop)/.test(t)?`text-bg-secondary`:`text-bg-info`}function IP(e){return e instanceof Map?Array.from(e.entries()):Array.isArray(e)?e.flatMap(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&typeof e[1]==`string`?[[e[0],e[1]]]:[]):typeof e==`object`&&e?Object.entries(e).flatMap(([e,t])=>typeof t==`string`?[[e,t]]:[]):[]}var LP={approve:{action:`approve`,buttonClassName:`btn-success`,label:`Approve`,successMessage:`Upload approved.`},fail:{action:`fail`,buttonClassName:`btn-outline-warning`,label:`Mark as failed`,successMessage:`Upload marked as failed.`},finish:{action:`finish`,buttonClassName:`btn-primary`,label:`Mark as finished`,successMessage:`Upload marked as finished.`},reject:{action:`reject`,buttonClassName:`btn-outline-danger`,label:`Reject`,successMessage:`Upload rejected.`}},RP={awaiting_approval:[`approve`,`reject`,`fail`],started:[`reject`,`fail`],syncing:[`fail`],uploading:[`finish`,`reject`,`fail`]};function zP(e){return(RP[e]??[]).map(e=>LP[e])}function BP(e){if(typeof e==`object`&&e&&`response`in e){let t=e.response;if(typeof t?.data?.message==`string`)return t.data.message}return e instanceof Error&&e.message!==``?e.message:`Could not process upload action.`}function VP({event:e,contentEntries:t,irisEndpoint:n,onEventUpdated:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),u=(0,d.useMemo)(()=>e?zP(e.state):[],[e]),f=(0,d.useCallback)(async t=>{if(e){a(t),s(``),l(``);try{let i={fileUploadEventUid:e.uid,irisServerUrl:n},a;a=t===`approve`?await at(i):t===`fail`?await rt(i):t===`finish`?await it(i):await ot(i);let o=u.find(e=>e.action===t);r(a),l(o?.successMessage??`Action completed.`)}catch(e){s(BP(e))}finally{a(null)}}},[u,e,n,r]);return(0,p.jsxs)(`div`,{className:`border rounded h-100`,children:[(0,p.jsxs)(`div`,{className:`border-bottom px-3 py-2`,children:[(0,p.jsx)(`div`,{className:`fw-semibold`,children:`Event details`}),(0,p.jsx)(`div`,{className:`small text-secondary`,children:`Inspect the current state and attached payload files`})]}),!e&&(0,p.jsx)(`div`,{className:`p-4 text-secondary`,children:`Choose an event to inspect its details.`}),e&&(0,p.jsxs)(`div`,{className:`p-3 p-lg-4`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-md-row justify-content-between gap-3 mb-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Event id`}),(0,p.jsx)(`code`,{className:`text-break`,children:e.uid})]}),(0,p.jsx)(`div`,{className:`d-flex align-items-start`,children:(0,p.jsx)(`span`,{className:`badge ${FP(e.state)}`,children:e.state})})]}),(0,p.jsxs)(`div`,{className:`row g-3 mb-4`,children:[(0,p.jsx)(`div`,{className:`col-md-6`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Context`}),(0,p.jsx)(`div`,{className:`fw-semibold text-break`,children:e.context})]})}),(0,p.jsx)(`div`,{className:`col-md-6`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Started`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:zD(e.start)})]})}),(0,p.jsx)(`div`,{className:`col-md-4`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Completed state`}),(0,p.jsx)(`div`,{className:`fw-semibold text-break`,children:e.completedState||`-`})]})}),(0,p.jsx)(`div`,{className:`col-md-4`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`TTL`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.TTL})]})}),(0,p.jsx)(`div`,{className:`col-md-4`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Auto approve`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.autoApprove?`Enabled`:`Disabled`})]})})]}),(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-2 gap-2`,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`h6 mb-0`,children:`Actions`}),(0,p.jsx)(`div`,{className:`small text-secondary`,children:`State transition actions available for this event`})]})}),u.length===0&&(0,p.jsx)(`div`,{className:`rounded border p-3 text-secondary`,children:`No manual actions are available for this state.`}),u.length>0&&(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-2`,children:u.map(e=>(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm ${e.buttonClassName}`,disabled:i!==null,onClick:()=>f(e.action),children:i===e.action?`Processing...`:e.label},e.action))}),o!==``&&(0,p.jsx)(`div`,{className:`alert alert-danger py-2 mt-3 mb-0`,children:o}),c!==``&&(0,p.jsx)(`div`,{className:`alert alert-success py-2 mt-3 mb-0`,children:c})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-2 gap-2`,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`h6 mb-0`,children:`Attached files`}),(0,p.jsxs)(`div`,{className:`small text-secondary`,children:[t.length,` file entries available`]})]})}),t.length===0&&(0,p.jsx)(`div`,{className:`rounded border p-3 text-secondary`,children:`This event does not include attached files.`}),t.length>0&&(0,p.jsx)(`div`,{className:`vstack gap-3`,children:t.map(([e,t])=>(0,p.jsxs)(`div`,{className:`rounded border overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 border-bottom d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`code`,{className:`text-break`,children:e}),(0,p.jsx)(`span`,{className:`badge border`,children:`attached`})]}),(0,p.jsx)(`pre`,{className:`m-0 p-3 bg-body-tertiary`,style:{maxHeight:220,overflow:`auto`},children:(0,p.jsx)(`code`,{children:t})})]},e))})]})]})]})}function HP({activeContext:e,events:t,selectedEventUid:n,onSelectEvent:r}){return(0,p.jsxs)(`div`,{className:`border rounded overflow-hidden h-100`,children:[(0,p.jsxs)(`div`,{className:`border-bottom px-3 py-2`,children:[(0,p.jsx)(`div`,{className:`fw-semibold`,children:`Incoming upload events`}),(0,p.jsx)(`div`,{className:`small text-secondary`,children:`Latest messages for the selected context`})]}),(0,p.jsxs)(`div`,{className:`list-group list-group-flush`,children:[t.map(e=>{let t=n===e.uid;return(0,p.jsxs)(`button`,{type:`button`,className:`list-group-item list-group-item-action text-start ${t?`active`:``}`,onClick:()=>r(e.uid),children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-start gap-2 mb-2`,children:[(0,p.jsx)(`code`,{className:t?`text-white`:``,children:e.uid}),(0,p.jsx)(`span`,{className:`badge ${FP(e.state)}`,children:e.state})]}),(0,p.jsxs)(`div`,{className:`small ${t?`text-white-50`:`text-secondary`}`,children:[(0,p.jsxs)(`div`,{children:[`Context: `,e.context]}),(0,p.jsxs)(`div`,{children:[`Started: `,zD(e.start)]})]})]},e.uid)}),e!==``&&t.length===0&&(0,p.jsx)(`div`,{className:`list-group-item text-secondary`,children:`Listening for new events...`}),e===``&&(0,p.jsx)(`div`,{className:`list-group-item text-secondary`,children:`Select a context to start the live stream.`})]})]})}function UP({irisEndpoint:e,context:t,onMessage:n,onError:r}){let i=(0,d.useRef)(null),a=(0,d.useRef)(null),o=(0,d.useRef)(!0),s=(0,d.useRef)(0),[c,l]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{if(!t)return;o.current=!0;let c=()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},u=()=>{c();let d=tt({context:t,irisServerUrl:e.endsWith(`/`)?e:`${e}/`,onOpen:()=>{s.current=0,l(!0)},onEvent:e=>{n(e)},onError:e=>{if(l(!1),r(e),d.close(),!o.current)return;let t=Math.min(1e3*2**s.current,3e4);s.current+=1,a.current=window.setTimeout(()=>{u()},t)}});i.current=d,d.start()};return u(),()=>{o.current=!1,c(),i.current?.close(),i.current=null,l(!1)}},[e,t,n,r]),{isConnected:c,close:()=>{o.current=!1,a.current!==null&&(window.clearTimeout(a.current),a.current=null),i.current?.close(),i.current=null,l(!1)}}}function WP(){let[e,t]=(0,d.useState)(``),[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)([]),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),u=xt();(0,d.useEffect)(()=>{n&&nt({irisServerUrl:u,context:n}).then(e=>{a(e)})},[n]);let f=(0,d.useCallback)(e=>{n!==``&&e.context===n&&(l(``),a(t=>[e,...t.filter(t=>t.uid!==e.uid)]),s(e.uid))},[n]),{isConnected:m}=UP({irisEndpoint:u,context:n,onMessage:f,onError:(0,d.useCallback)(e=>{if(n===``){l(``);return}if(e===null){l(``);return}l(`Error trying to connect to the server, reconnecting....`)},[n])}),h=(0,d.useCallback)(t=>{t.preventDefault(),r(e),a([]),s(``),l(``)},[e]),g=(0,d.useMemo)(()=>i.length===0?null:i.find(e=>e.uid===o)??i[0],[i,o]),_=(0,d.useMemo)(()=>g?IP(g.content):[],[g]);return(0,p.jsx)(`div`,{className:`w-100`,children:(0,p.jsx)(`div`,{className:`card shadow-sm border-0`,children:(0,p.jsxs)(`div`,{className:`card-body p-3 p-lg-4`,children:[(0,p.jsxs)(`form`,{onSubmit:h,className:`row g-2 align-items-end mb-4`,children:[(0,p.jsxs)(`div`,{className:`col-lg-8`,children:[(0,p.jsx)(`label`,{className:`form-label fw-semibold`,htmlFor:`iris-context-input`,children:`Context`}),(0,p.jsx)(`input`,{id:`iris-context-input`,className:`form-control`,type:`text`,value:e,placeholder:`lab-a`,onChange:e=>t(e.target.value)})]}),(0,p.jsx)(`div`,{className:`col-lg-4 col-xl-2`,children:(0,p.jsx)(`button`,{className:`btn btn-primary w-100`,type:`submit`,disabled:e.trim()===``,children:`Load context`})})]}),c!==``&&(0,p.jsx)(`div`,{className:`alert alert-danger py-2 mb-4`,children:c}),!m&&(0,p.jsx)(`div`,{className:`alert alert-warning py-2 mb-4`,children:`Could not connect to the server`}),m&&(0,p.jsxs)(`div`,{className:`row g-3`,children:[(0,p.jsx)(`div`,{className:`col-xl-5`,children:(0,p.jsx)(HP,{activeContext:n,events:i,selectedEventUid:g?.uid||``,onSelectEvent:s})}),(0,p.jsx)(`div`,{className:`col-xl-7`,children:(0,p.jsx)(VP,{event:g,contentEntries:_,irisEndpoint:u,onEventUpdated:f},g?.uid||``)})]},`${n}${i.length>0?i[0].uid:``}`)]})})})}function GP(e){switch(e){case`Shift`:return!0;case`Alt`:return!0;case`Control`:return!0;case`Meta`:return!0}return!1}function KP(e){switch(e){case`Enter`:return!0;default:return!1}}function qP(e,t){let n=``,r=()=>{n=``,t&&t(n)};return i=>{if(i.target instanceof HTMLInputElement||i.target instanceof HTMLTextAreaElement)return;let a=i.key;if(!GP(a)){if(a===`Escape`){r();return}if(KP(a)){e(n),r();return}n+=a,t&&t(n)}}}var JP=({children:e})=>{let[t,n]=(0,d.useState)(``),r=(0,d.useRef)(new Map),i=(0,d.useRef)(new Map),a=e=>{(0,d.startTransition)(()=>{i.current.forEach(t=>t(e))})},o=e=>{n(e);let t=Gk(e);(0,d.startTransition)(()=>{r.current.get(t)?.forEach(t=>t(e))})};return(0,d.useEffect)(()=>{let e=qP(o,a);return document.addEventListener(`keyup`,e),()=>{document.removeEventListener(`keyup`,e)}},[o,a]),(0,p.jsx)(Hk.Provider,{value:{lastlyReadedKeys:t,addCallbackFn:(e,t,n)=>{r.current.has(e)||r.current.set(e,new Map),r.current.get(e).set(t,n)},removeCallbackFn:(e,t)=>{r.current.get(e)?.delete(t)},addReadingCallbackFn:(e,t)=>{i.current.set(e,t)},removeReadingCallbackFn:e=>{i.current.delete(e)}},children:e})};function YP({runsList:e,onFail:t=e=>null}){let[n,r]=(0,d.useState)(null),{lastlyReadedKeys:i}=Uk();return(0,d.useEffect)(()=>{let n=i.replace(/_/g,`-`).toUpperCase(),a=e.find(e=>n.includes(e.label));if(!a){t(`Run not found`);return}Jk({notificationHeader:`Run scanner`,notificationBody:`Run ${a.label} found`,notificationType:`success`}),r(a)},[i]),{selectedRun:n}}exports.AuthContext=v,exports.AuthProvider=kt,exports.BatchCardElement=uk,exports.ChemicalHeaderElement=PN,exports.ChemicalIntakeElement=yP,exports.DateFormat=lk,exports.EditRunParents=hj,exports.EmphasizedParametersContext=mk,exports.EmphasizedParametersProvider=NN,exports.EquipmentContext=iO,exports.EquipmentDashboard=lO,exports.EquipmentHeaderElement=pO,exports.EquipmentProvider=dO,exports.GoldsteinClientsDashboard=kP,exports.GoldsteinEquipmentDashboard=ly,exports.InputModal=AN,exports.IrisOperatorDashboard=WP,exports.ModuleStatusElement=Ld,exports.MonitorCard=tO,exports.MonitorContext=rk,exports.MonitorHeaderElement=tk,exports.MonitorPage=ek,exports.MonitorProvider=ik,exports.NewRunWizard=mj,exports.NotificationProvider=Yk,exports.PaginationLinks=GO,exports.ReportResults=NP,exports.RunContext=ok,exports.RunHeaderElement=pk,exports.RunInformationElement=yj,exports.RunLayoutElement=Mj,exports.RunProvider=sk,exports.RunStepChecklist=Hj,exports.RunStepContext=jA,exports.RunStepExecuteElement=jN,exports.RunStepExecuteMinimal=MN,exports.RunStepHeaderElement=Fj,exports.RunStepProvider=Pj,exports.RunStepsElement=RA,exports.ScannerContext=Hk,exports.ScannerProvider=JP,exports.SetupUpdateEquipment=Dv,exports.StatusMailComponent=eO,exports.StatusMailContext=uy,exports.StatusMailProvider=mO,exports.StepDetails=sA,exports.initSolodbComponents=vt,exports.notification=Jk,exports.useAuth=St,exports.useScannerContext=Uk,exports.useSelectRunWithScanner=YP;
36
36
  //# sourceMappingURL=index.cjs.map