@jield/solodb-react-components 1.2.2 → 1.2.3
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/README.md +10 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +182 -174
- package/dist/index.js.map +1 -1
- package/dist/modules/run/components/wizard/createRunForm/createRunForm.d.ts +2 -3
- package/dist/modules/run/components/wizard/createRunForm/formSection.d.ts +1 -1
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require("react"),d=l(u,1);u=l(u);let f=require("axios");f=l(f,1);let p=require("react/jsx-runtime"),m=require("@tanstack/react-query"),h=require("react-dom");h=l(h);let g=require("react-router-dom"),_=require("@tanstack/react-table");var v=(0,d.createContext)({user:null,setUser:()=>{},isLoadingUser:!0});function y(e){let t={...e};return t.facet=Object.fromEntries(Object.entries(e.facet).filter(([e,t])=>t.values.length>0)),e.filter.general.length<=0&&(t.filter={}),t}async function b({service:e,environment:t,formResult:n}){let r=new URLSearchParams;if(e!==void 0&&r.append(`service`,e),t!==void 0&&r.append(`environment`,t),n!==void 0){let e=JSON.stringify(y(n));r.append(`formResult`,btoa(e))}let i=`view/filter?`+r.toString(),{data:a}=await f.default.get(i);return{filter:a._embedded.items[0],facet:a._embedded.items[1]}}async function x(){let{data:e}=await f.default.get(`me`);return e}async function S({query:e,selection:t}){let n=new URLSearchParams;e&&n.append(`query`,e),t&&n.append(`selection`,t.toString());let r=`list/user?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}function C(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(e)},r.onerror=n,r.readAsDataURL(e)})}var w=(e,t)=>{f.default.defaults.headers.common.Authorization=`Bearer `+e,f.default.defaults.headers.common.Accept=`application/json`,f.default.defaults.headers.common[`Content-Type`]=`application/json`,f.default.defaults.baseURL=t};async function T({id:e}){let{data:t}=await f.default.get(`view/chemical/container/`+e);return t}async function E({qrCodeContent:e}){let t=new URLSearchParams;t.append(`qr_code_content`,e);let n=`list/chemical/container/external-label?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function D({query:e}){let t=new URLSearchParams;e&&t.append(`query`,e);let n=`list/chemical/container/type?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function O({query:e}){let t=new URLSearchParams;e&&t.append(`query`,e);let n=`list/chemical?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function k({id:e}){let{data:t}=await f.default.get(`view/equipment/`+e);return t}async function A({id:e}){let{data:t}=await f.default.get(`view/setup/`+e);return t}async function j({id:e}){let{data:t}=await f.default.get(`view/status-mail/`+e);return t}function M(e){let t={...e};return t.facet=Object.fromEntries(Object.entries(e.facet).filter(([e,t])=>t.values.length>0)),e.filter.general.length<=0&&(t.filter={}),t}async function ee({environment:e,run:t,room:n,statusMail:r,hasWorkstationComponents:i=!1,page:a=1,pageSize:o=25,query:s,filter:c,order:l,direction:u}){let d=new URLSearchParams;e!==void 0&&d.append(`environment`,e),t!==void 0&&d.append(`run`,t.id.toString()),n!==void 0&&d.append(`room`,n.id.toString()),i&&d.append(`has_workstation_components`,`true`),s!==void 0&&d.append(`query`,s),l!==void 0&&d.append(`order`,l),u!==void 0&&d.append(`direction`,u),r!==void 0&&(d.append(`status_mail`,r.id.toString()),d.append(`page_size`,`200`)),c!==void 0&&(c=M(c),d.append(`filter`,btoa(JSON.stringify(c)))),d.append(`page`,a.toString()),d.append(`page_size`,o.toString());let p=`list/equipment?`+d.toString(),{data:m}=await f.default.get(p);return{items:m._embedded.items,amountOfPages:m.page_count,currentPage:m.page,totalItems:m.total_items,hasMore:m.page<m.page_count}}async function te(){let e=`list/equipment/status?`+new URLSearchParams().toString(),{data:t}=await f.default.get(e);return{items:t._embedded.items,amountOfPages:t.page_count,currentPage:t.page,totalItems:t.total_items,hasMore:t.page<t.page_count}}async function N({equipment:e,module:t,statusMail:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&(r.append(`status_mail`,n.id.toString()),r.append(`page_size`,`1000`));let i=`list/equipment/module/ecn/attachment?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function ne({id:e}){if(isNaN(e))return null;let{data:t}=await f.default.get(`view/equipment/module/`+e);return t}async function re({equipment:e,module:t,statusMail:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&(r.append(`status_mail`,n.id.toString()),r.append(`page_size`,`1000`));let i=`list/equipment/module/issue/attachment?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function ie({equipment:e,module:t,statusMail:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&(r.append(`status_mail`,n.id.toString()),r.append(`page_size`,`1000`));let i=`list/equipment/module/ecn?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function ae({module:e,pageSize:t,order:n,direction:r}){let i=new URLSearchParams;e!==void 0&&i.append(`module`,e.id.toString()),t!==void 0&&i.append(`page_size`,t.toString()),n&&i.append(`order`,n),r&&i.append(`direction`,r);let a=`list/equipment/module/parameter?`+i.toString(),{data:o}=await f.default.get(a);return{items:o._embedded.items,amountOfPages:o.page_count,currentPage:o.page,totalItems:o.total_items,hasMore:o.page<o.page_count}}async function P({equipment:e,module:t,statusMail:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&(r.append(`status_mail`,n.id.toString()),r.append(`page_size`,`1000`));let i=`list/equipment/module/issue?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function oe({equipment:e,statusMail:t,run:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&(r.append(`status_mail`,t.id.toString()),r.append(`page_size`,`10000`)),n!==void 0&&r.append(`run`,n.id.toString());let i=`list/equipment/module?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function se({equipment:e,module:t,which:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&r.append(`which`,n);let i=`list/equipment/reservation?`+r.toString(),{data:a}=await f.default.get(i);if(n==`active`)for(let e=0;e<a._embedded.items.length;e++)a._embedded.items[e].active=!0;return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function ce({statusMail:e}){let t=new URLSearchParams;e!==void 0&&(t.append(`status_mail`,e.id.toString()),t.append(`page_size`,`1000`));let n=`list/location/message?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function le({id:e}){let{data:t}=await f.default.get(`view/location/`+e);return t}async function ue({id:e}){let{data:t}=await f.default.get(`view/room/`+e);return t}async function de({environment:e,room:t,pageSize:n=25}){let r=new URLSearchParams;e&&r.append(`environment`,e),t&&r.append(`room`,t.id.toString()),r.append(`page_size`,n.toString());let i=`list/location?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function fe({environment:e,withLocations:t}){let n=new URLSearchParams;e&&n.append(`environment`,e),t&&n.append(`which`,`with_locations`);let r=`list/room?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function pe({id:e}){let{data:t}=await f.default.get(`view/monitor/`+e);return t}async function me({equipmentId:e,monitorId:t}){let n=new URLSearchParams;e!==void 0&&n.append(`equipment`,e.toString()),t&&n.append(`monitor`,t.toString());let r=`list/monitor/requirement?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function he({equipment:e}){let t=new URLSearchParams;e!=null&&t.append(`equipment`,e.id.toString()),t.append(`ad_hoc`,`true`);let n=`list/monitor?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function ge({requirement:e,order:t,direction:n,pageSize:r,page:i}){let a=new URLSearchParams;e&&a.append(`requirement`,e.id.toString()),t&&a.append(`order`,t),n&&a.append(`direction`,n),r&&a.append(`page_size`,r.toString()),i&&a.append(`page`,i.toString());let o=`list/monitor/measurement/result?`+a.toString(),{data:s}=await f.default.get(o);return{items:s._embedded.items,amountOfPages:s.page_count,currentPage:s.page,totalItems:s.total_items,hasMore:s.page<s.page_count}}async function _e({requirement:e,result:t,order:n,direction:r,pageSize:i,page:a}){let o=new URLSearchParams;e&&o.append(`requirement`,e.id.toString()),t&&o.append(`result`,t.id.toString()),n&&o.append(`order`,n),r&&o.append(`direction`,r),i&&o.append(`page_size`,i.toString()),a&&o.append(`page`,a.toString());let s=`list/monitor/measurement/result/step-parameter-value?`+o.toString(),{data:c}=await f.default.get(s);return{items:c._embedded.items,amountOfPages:c.page_count,currentPage:c.page,totalItems:c.total_items,hasMore:c.page<c.page_count}}async function ve({requirement:e}){let t=new URLSearchParams;e&&t.append(`requirement`,e.id.toString());let n=`list/monitor/requirement/target?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function ye({step:e,pageSize:t,order:n,direction:r}){let i=new URLSearchParams;e!==void 0&&i.append(`step`,e.id.toString()),t!==void 0&&i.append(`page_size`,t.toString()),n&&i.append(`order`,n),r&&i.append(`direction`,r);let a=`list/monitor/step/file?`+i.toString(),{data:o}=await f.default.get(a);return{items:o._embedded.items,amountOfPages:o.page_count,currentPage:o.page,totalItems:o.total_items,hasMore:o.page<o.page_count}}async function be({step:e,requirement:t,pageSize:n,order:r,direction:i}){let a=new URLSearchParams;e!==void 0&&a.append(`step`,e.id.toString()),t!==void 0&&a.append(`requirement`,t.id.toString()),n!==void 0&&a.append(`page_size`,n.toString()),r&&a.append(`order`,r),i&&a.append(`direction`,i);let o=`list/monitor/step/parameter?`+a.toString(),{data:s}=await f.default.get(o);return{items:s._embedded.items,amountOfPages:s.page_count,currentPage:s.page,totalItems:s.total_items,hasMore:s.page<s.page_count}}async function xe({environment:e,query:t,order:n,direction:r,page:i,page_size:a}={}){let o=new URLSearchParams;e!==void 0&&o.append(`environment`,e),t!==void 0&&o.append(`query`,t),n!==void 0&&o.append(`order`,n),r!==void 0&&o.append(`direction`,r),i!==void 0&&o.append(`page`,i.toString()),a!==void 0&&o.append(`page_size`,a.toString());let s=`list/organisation/group?`+o.toString(),{data:c}=await f.default.get(s);return{items:c._embedded.items,amountOfPages:c.page_count,currentPage:c.page,totalItems:c.total_items,hasMore:c.page<c.page_count}}async function Se({environment:e,query:t,order:n,direction:r,page:i,page_size:a,purpose:o}={}){let s=new URLSearchParams;e!==void 0&&s.append(`environment`,e),t!==void 0&&s.append(`query`,t),n!==void 0&&s.append(`order`,n),r!==void 0&&s.append(`direction`,r),i!==void 0&&s.append(`page`,i.toString()),a!==void 0&&s.append(`page_size`,a.toString()),o!==void 0&&s.append(`purpose`,o.toString());let c=`list/organisation/project?`+s.toString(),{data:l}=await f.default.get(c);return{items:l._embedded.items,amountOfPages:l.page_count,currentPage:l.page,totalItems:l.total_items,hasMore:l.page<l.page_count}}async function Ce({environment:e,query:t,order:n,direction:r,page:i,page_size:a,purpose:o}={}){let s=new URLSearchParams;e!==void 0&&s.append(`environment`,e),t!==void 0&&s.append(`query`,t),n!==void 0&&s.append(`order`,n),r!==void 0&&s.append(`direction`,r),i!==void 0&&s.append(`page`,i.toString()),a!==void 0&&s.append(`page_size`,a.toString()),o!==void 0&&s.append(`purpose`,o.toString());let c=`list/organisation/team?`+s.toString(),{data:l}=await f.default.get(c);return{items:l._embedded.items,amountOfPages:l.page_count,currentPage:l.page,totalItems:l.total_items,hasMore:l.page<l.page_count}}async function we({name:e,motivation:t,group_id:n,team_id:r,project_id:i,experimental_split:a,location:o,conclusion:s,run_type:c}){return(await f.default.post(`create/run`,{name:e,motivation:t,group_id:n,team_id:r,project_id:i,...a===void 0?{}:{experimental_split:a},...o===void 0?{}:{location:o},...s===void 0?{}:{conclusion:s},...c===void 0?{}:{run_type:c}})).data}async function Te({run_id:e,parent_run_id:t,part_ids:n,amount_per_part:r,description:i}){return(await f.default.post(`create/run/parent`,{run_id:e,parent_run_id:t,...n===void 0?{}:{part_ids:n},...r===void 0?{}:{amount_per_part:r},...i===void 0?{}:{description:i}})).data}async function Ee({run_id:e,substrate_id:t,amount:n}){return(await f.default.post(`create/run/substrate`,{run_id:e,substrate_id:t,amount:n})).data}async function De({file:e}){let t=`delete/run/file/`+e.id;await f.default.delete(t)}async function Oe({id:e}){let t=`view/run/`+e,{data:n}=await f.default.get(t);return n}async function ke({id:e}){let t=`view/run/step/`+e,{data:n}=await f.default.get(t);return n}async function Ae({run:e,query:t,order:n,direction:r,pageSize:i,page:a}){let o=new URLSearchParams;o.append(`run`,e.id.toString()),t!==void 0&&o.append(`query`,t),n!==void 0&&o.append(`order`,n),r!==void 0&&o.append(`direction`,r),i!==void 0&&o.append(`page_size`,i.toString()),a!==void 0&&o.append(`page`,a.toString());let s=`list/run/file?`+o.toString(),{data:c}=await f.default.get(s);return{items:c._embedded.items,amountOfPages:c.page_count,currentPage:c.page,totalItems:c.total_items,hasMore:c.page<c.page_count}}async function je({step:e,run:t}){let n=new URLSearchParams;e!==void 0&&n.append(`step`,String(e.id)),t!==void 0&&n.append(`run`,String(t.id));let r=`list/run/requirement?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function Me({run:e,page:t}){let n=new URLSearchParams;e!==void 0&&n.append(`run`,e.id.toString()),n.append(`page`,t.toString());let r=`list/run/changelog?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function Ne({run:e,level:t}){let n=new URLSearchParams;n.append(`run`,e.id.toString()),n.append(`page_size`,`10000`),t!==void 0&&n.append(`level`,`${t}`);let r=`list/run/parts?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function Pe({run:e,page:t=1,pageSize:n=25}){let r=new URLSearchParams;e!==void 0&&r.append(`run`,e.id.toString()),r.append(`page`,t.toString()),r.append(`page_size`,n.toString());let i=`list/run/step?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function Fe({environment:e,firstUnfinishedStepEquipment:t,availableAsParentForRun:n}){let r=new URLSearchParams;t!==void 0&&(r.append(`operator`,`1`),r.append(`first_unfinished_step_equipment_id`,t.id.toString())),e!==void 0&&r.append(`environment`,e),n!=null&&r.append(`available_as_parent_for_run`,n.id.toString());let i=`list/run?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function Ie({filename:e,type:t,content:n,run:r,step:i}){let{data:a}=await f.default.post(`create/file/upload-file`,{filename:e,type:t,content:n,...r===void 0?{}:{run:r.id},...i===void 0?{}:{step:i.id}});return a}async function Le({measurement:e}){let t=new URLSearchParams;t.append(`measurement`,String(e.id));let n=`/list/run/measurement/result?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function Re({runStep:e}){let t=new URLSearchParams;e!==void 0&&t.append(`step`,e.id.toString());let n=`list/run/step/checklist?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function ze(e){if(!e)throw Error(`Run step is undefined when trying to finish step`);return await f.default.create().patch(`update/run/step/finish/`+e.id,{})}async function Be({step:e,pageSize:t}){let n=new URLSearchParams;e!==void 0&&n.append(`step`,e.id.toString()),t!==void 0&&n.append(`page_size`,t.toString()),n.append(`order`,`date-created`),n.append(`direction`,`DESC`);let r=`list/run/step/file?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function Ve({runStep:e}){let t=new URLSearchParams;e!==void 0&&t.append(`step`,e.id.toString());let n=`list/run/step/parameter?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function He({step:e,run:t,runPart:n,page_size:r,page:i}){let a=new URLSearchParams;if(e!==void 0&&a.append(`step`,e.id.toString()),t!==void 0&&a.append(`run`,t.id.toString()),n!==void 0)for(let e of n)a.append(`part[]`,e.id.toString());i!==void 0&&a.append(`page`,i.toString()),r===void 0?a.append(`page_size`,`1000`):a.append(`page_size`,r.toString());let o=`list/run/step/part?`+a.toString(),{data:s}=await f.default.get(o);return{items:s._embedded.items,amountOfPages:s.page_count,currentPage:s.page,totalItems:s.total_items,hasMore:s.page<s.page_count}}async function Ue(e,t,n,r,i){if(!e||!t||!r||!n)throw Error(`Invalid values when trying to update run step part tray`);let a={tray_id:t.id,tray_row:n,tray_column:r};return i!=null&&(a.update_subsequent=i),await f.default.create().patch(`update/run/step/part/${e.id}/tray`,a)}async function We({runStepPart:e,runStepPartAction:t}){let{data:n}=await f.default.post(`create/run/step/part/action`,{run_step_part_id:e.id,type:t});return n}async function F({runStepPartActions:e}){let{data:t}=await f.default.post(`create/run/step/part/action`,{items:e.map(({runStepPart:e,runStepPartAction:t,comment:n})=>({run_step_part_id:e.id,type:t,...n===void 0?{}:{comment:n}}))});return t}var Ge=function(e){return e[e.START=1]=`START`,e[e.FINISH=2]=`FINISH`,e[e.FAIL=3]=`FAIL`,e[e.REWORK=4]=`REWORK`,e[e.SET_REPAIR=5]=`SET_REPAIR`,e[e.CLEAR_REPAIR=6]=`CLEAR_REPAIR`,e[e.SET_TESTING=7]=`SET_TESTING`,e[e.CLEAR_TESTING=8]=`CLEAR_TESTING`,e}({});function Ke(e){return new Map([[Ge.START,`start_processing`],[Ge.FINISH,`finish_processing`],[Ge.FAIL,`fail_processing`],[Ge.REWORK,`rework`],[Ge.SET_REPAIR,`repair`],[Ge.CLEAR_REPAIR,`clear_repairing`],[Ge.SET_TESTING,`test`],[Ge.CLEAR_TESTING,`clear_testing`]]).get(e)??null}function qe(e){return new Map([[`start_processing`,Ge.START],[`finish_processing`,Ge.FINISH],[`fail_processing`,Ge.FAIL],[`rework`,Ge.REWORK],[`repair`,Ge.SET_REPAIR],[`clear_repairing`,Ge.CLEAR_REPAIR],[`test`,Ge.SET_TESTING],[`clear_testing`,Ge.CLEAR_TESTING]]).get(e)??null}async function Je({id:e}){let t=new URLSearchParams;e!==void 0&&t.append(`report`,e.toString());let n=`list/service/event/report/results?`+t.toString(),{data:r}=await f.default.get(n);return r._embedded.items}async function Ye({id:e}){let{data:t}=await f.default.get(`view/service/event/report/`+e);return t}async function Xe({equipmentId:e}){let t=new URLSearchParams;e!==void 0&&t.append(`equipment`,e.toString());let n=`list/service?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function Ze({template:e,pageSize:t}){let n=new URLSearchParams;e!==void 0&&n.append(`template`,e.id.toString()),t!==void 0&&n.append(`page_size`,t.toString());let r=`list/template/step?`+n.toString(),{data:i}=await f.default.get(r);return{steps:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items}}async function Qe({reworkRecipes:e}){let t=new URLSearchParams;e!==void 0&&e.map(e=>e.id).forEach(e=>{t.append(`rework_recipe_id[]`,e.toString())});let n=`list/template?`+t.toString(),{data:r}=await f.default.get(n);return{templates:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items}}async function $e({query:e,order:t,direction:n,pageSize:r=25,page:i=1}){let a=new URLSearchParams;e!==void 0&&a.append(`query`,e),t!==void 0&&a.append(`order`,t),n!==void 0&&a.append(`direction`,n),a.append(`page_size`,r.toString()),a.append(`page`,i.toString());let o=`list/substrate?`+a.toString(),{data:s}=await f.default.get(o);return{items:s._embedded.items,amountOfPages:s.page_count,currentPage:s.page,totalItems:s.total_items,hasMore:s.page<s.page_count}}function et(e){return e?f.default.create({baseURL:e}):f.default}function tt(e,t){return t?new URL(e,t).toString():e}function nt({path:e,irisServerUrl:t,onEvent:n,onOpen:r,onError:i}){let a=new AbortController,o=f.default.defaults.headers.common.Authorization;return{start:async()=>{try{let i=await fetch(tt(e,t),{method:`GET`,headers:{Accept:`text/event-stream`,...typeof o==`string`?{Authorization:o}:{}},signal:a.signal});if(!i.ok)throw Error(`HTTP ${i.status}`);r&&r(new Event(`open`));let s=i.body?.getReader();if(!s)throw Error(`ReadableStream not supported`);let c=new TextDecoder,l=``;for(;;){let{value:e,done:t}=await s.read();if(t)break;l+=c.decode(e,{stream:!0});let r=l.split(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require("react"),d=l(u,1);u=l(u);let f=require("axios");f=l(f,1);let p=require("react/jsx-runtime"),m=require("@tanstack/react-query"),h=require("react-dom");h=l(h);let g=require("react-router-dom"),_=require("@tanstack/react-table");var v=(0,d.createContext)({user:null,setUser:()=>{},isLoadingUser:!0});function y(e){let t={...e};return t.facet=Object.fromEntries(Object.entries(e.facet).filter(([e,t])=>t.values.length>0)),e.filter.general.length<=0&&(t.filter={}),t}async function b({service:e,environment:t,formResult:n}){let r=new URLSearchParams;if(e!==void 0&&r.append(`service`,e),t!==void 0&&r.append(`environment`,t),n!==void 0){let e=JSON.stringify(y(n));r.append(`formResult`,btoa(e))}let i=`view/filter?`+r.toString(),{data:a}=await f.default.get(i);return{filter:a._embedded.items[0],facet:a._embedded.items[1]}}async function x(){let{data:e}=await f.default.get(`me`);return e}async function S({query:e,selection:t}){let n=new URLSearchParams;e&&n.append(`query`,e),t&&n.append(`selection`,t.toString());let r=`list/user?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}function C(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(e)},r.onerror=n,r.readAsDataURL(e)})}var w=(e,t)=>{f.default.defaults.headers.common.Authorization=`Bearer `+e,f.default.defaults.headers.common.Accept=`application/json`,f.default.defaults.headers.common[`Content-Type`]=`application/json`,f.default.defaults.baseURL=t};async function T({id:e}){let{data:t}=await f.default.get(`view/chemical/container/`+e);return t}async function E({qrCodeContent:e}){let t=new URLSearchParams;t.append(`qr_code_content`,e);let n=`list/chemical/container/external-label?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function D({query:e}){let t=new URLSearchParams;e&&t.append(`query`,e);let n=`list/chemical/container/type?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function O({query:e}){let t=new URLSearchParams;e&&t.append(`query`,e);let n=`list/chemical?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function k({id:e}){let{data:t}=await f.default.get(`view/equipment/`+e);return t}async function A({id:e}){let{data:t}=await f.default.get(`view/setup/`+e);return t}async function j({id:e}){let{data:t}=await f.default.get(`view/status-mail/`+e);return t}function M(e){let t={...e};return t.facet=Object.fromEntries(Object.entries(e.facet).filter(([e,t])=>t.values.length>0)),e.filter.general.length<=0&&(t.filter={}),t}async function ee({environment:e,run:t,room:n,statusMail:r,hasWorkstationComponents:i=!1,page:a=1,pageSize:o=25,query:s,filter:c,order:l,direction:u}){let d=new URLSearchParams;e!==void 0&&d.append(`environment`,e),t!==void 0&&d.append(`run`,t.id.toString()),n!==void 0&&d.append(`room`,n.id.toString()),i&&d.append(`has_workstation_components`,`true`),s!==void 0&&d.append(`query`,s),l!==void 0&&d.append(`order`,l),u!==void 0&&d.append(`direction`,u),r!==void 0&&(d.append(`status_mail`,r.id.toString()),d.append(`page_size`,`200`)),c!==void 0&&(c=M(c),d.append(`filter`,btoa(JSON.stringify(c)))),d.append(`page`,a.toString()),d.append(`page_size`,o.toString());let p=`list/equipment?`+d.toString(),{data:m}=await f.default.get(p);return{items:m._embedded.items,amountOfPages:m.page_count,currentPage:m.page,totalItems:m.total_items,hasMore:m.page<m.page_count}}async function te(){let e=`list/equipment/status?`+new URLSearchParams().toString(),{data:t}=await f.default.get(e);return{items:t._embedded.items,amountOfPages:t.page_count,currentPage:t.page,totalItems:t.total_items,hasMore:t.page<t.page_count}}async function N({equipment:e,module:t,statusMail:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&(r.append(`status_mail`,n.id.toString()),r.append(`page_size`,`1000`));let i=`list/equipment/module/ecn/attachment?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function ne({id:e}){if(isNaN(e))return null;let{data:t}=await f.default.get(`view/equipment/module/`+e);return t}async function re({equipment:e,module:t,statusMail:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&(r.append(`status_mail`,n.id.toString()),r.append(`page_size`,`1000`));let i=`list/equipment/module/issue/attachment?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function ie({equipment:e,module:t,statusMail:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&(r.append(`status_mail`,n.id.toString()),r.append(`page_size`,`1000`));let i=`list/equipment/module/ecn?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function ae({module:e,pageSize:t,order:n,direction:r}){let i=new URLSearchParams;e!==void 0&&i.append(`module`,e.id.toString()),t!==void 0&&i.append(`page_size`,t.toString()),n&&i.append(`order`,n),r&&i.append(`direction`,r);let a=`list/equipment/module/parameter?`+i.toString(),{data:o}=await f.default.get(a);return{items:o._embedded.items,amountOfPages:o.page_count,currentPage:o.page,totalItems:o.total_items,hasMore:o.page<o.page_count}}async function P({equipment:e,module:t,statusMail:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&(r.append(`status_mail`,n.id.toString()),r.append(`page_size`,`1000`));let i=`list/equipment/module/issue?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function oe({equipment:e,statusMail:t,run:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&(r.append(`status_mail`,t.id.toString()),r.append(`page_size`,`10000`)),n!==void 0&&r.append(`run`,n.id.toString());let i=`list/equipment/module?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function se({equipment:e,module:t,which:n}){let r=new URLSearchParams;e!==void 0&&r.append(`equipment`,e.id.toString()),t!==void 0&&r.append(`module`,t.id.toString()),n!==void 0&&r.append(`which`,n);let i=`list/equipment/reservation?`+r.toString(),{data:a}=await f.default.get(i);if(n==`active`)for(let e=0;e<a._embedded.items.length;e++)a._embedded.items[e].active=!0;return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function ce({statusMail:e}){let t=new URLSearchParams;e!==void 0&&(t.append(`status_mail`,e.id.toString()),t.append(`page_size`,`1000`));let n=`list/location/message?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function le({id:e}){let{data:t}=await f.default.get(`view/location/`+e);return t}async function ue({id:e}){let{data:t}=await f.default.get(`view/room/`+e);return t}async function de({environment:e,room:t,pageSize:n=25}){let r=new URLSearchParams;e&&r.append(`environment`,e),t&&r.append(`room`,t.id.toString()),r.append(`page_size`,n.toString());let i=`list/location?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function fe({environment:e,withLocations:t}){let n=new URLSearchParams;e&&n.append(`environment`,e),t&&n.append(`which`,`with_locations`);let r=`list/room?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function pe({id:e}){let{data:t}=await f.default.get(`view/monitor/`+e);return t}async function me({equipmentId:e,monitorId:t}){let n=new URLSearchParams;e!==void 0&&n.append(`equipment`,e.toString()),t&&n.append(`monitor`,t.toString());let r=`list/monitor/requirement?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function he({equipment:e}){let t=new URLSearchParams;e!=null&&t.append(`equipment`,e.id.toString()),t.append(`ad_hoc`,`true`);let n=`list/monitor?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function ge({requirement:e,order:t,direction:n,pageSize:r,page:i}){let a=new URLSearchParams;e&&a.append(`requirement`,e.id.toString()),t&&a.append(`order`,t),n&&a.append(`direction`,n),r&&a.append(`page_size`,r.toString()),i&&a.append(`page`,i.toString());let o=`list/monitor/measurement/result?`+a.toString(),{data:s}=await f.default.get(o);return{items:s._embedded.items,amountOfPages:s.page_count,currentPage:s.page,totalItems:s.total_items,hasMore:s.page<s.page_count}}async function _e({requirement:e,result:t,order:n,direction:r,pageSize:i,page:a}){let o=new URLSearchParams;e&&o.append(`requirement`,e.id.toString()),t&&o.append(`result`,t.id.toString()),n&&o.append(`order`,n),r&&o.append(`direction`,r),i&&o.append(`page_size`,i.toString()),a&&o.append(`page`,a.toString());let s=`list/monitor/measurement/result/step-parameter-value?`+o.toString(),{data:c}=await f.default.get(s);return{items:c._embedded.items,amountOfPages:c.page_count,currentPage:c.page,totalItems:c.total_items,hasMore:c.page<c.page_count}}async function ve({requirement:e}){let t=new URLSearchParams;e&&t.append(`requirement`,e.id.toString());let n=`list/monitor/requirement/target?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function ye({step:e,pageSize:t,order:n,direction:r}){let i=new URLSearchParams;e!==void 0&&i.append(`step`,e.id.toString()),t!==void 0&&i.append(`page_size`,t.toString()),n&&i.append(`order`,n),r&&i.append(`direction`,r);let a=`list/monitor/step/file?`+i.toString(),{data:o}=await f.default.get(a);return{items:o._embedded.items,amountOfPages:o.page_count,currentPage:o.page,totalItems:o.total_items,hasMore:o.page<o.page_count}}async function be({step:e,requirement:t,pageSize:n,order:r,direction:i}){let a=new URLSearchParams;e!==void 0&&a.append(`step`,e.id.toString()),t!==void 0&&a.append(`requirement`,t.id.toString()),n!==void 0&&a.append(`page_size`,n.toString()),r&&a.append(`order`,r),i&&a.append(`direction`,i);let o=`list/monitor/step/parameter?`+a.toString(),{data:s}=await f.default.get(o);return{items:s._embedded.items,amountOfPages:s.page_count,currentPage:s.page,totalItems:s.total_items,hasMore:s.page<s.page_count}}async function xe({environment:e,query:t,order:n,direction:r,page:i,page_size:a}={}){let o=new URLSearchParams;e!==void 0&&o.append(`environment`,e),t!==void 0&&o.append(`query`,t),n!==void 0&&o.append(`order`,n),r!==void 0&&o.append(`direction`,r),i!==void 0&&o.append(`page`,i.toString()),a!==void 0&&o.append(`page_size`,a.toString());let s=`list/organisation/group?`+o.toString(),{data:c}=await f.default.get(s);return{items:c._embedded.items,amountOfPages:c.page_count,currentPage:c.page,totalItems:c.total_items,hasMore:c.page<c.page_count}}async function Se({environment:e,query:t,order:n,direction:r,page:i,page_size:a,purpose:o}={}){let s=new URLSearchParams;e!==void 0&&s.append(`environment`,e),t!==void 0&&s.append(`query`,t),n!==void 0&&s.append(`order`,n),r!==void 0&&s.append(`direction`,r),i!==void 0&&s.append(`page`,i.toString()),a!==void 0&&s.append(`page_size`,a.toString()),o!==void 0&&s.append(`purpose`,o.toString());let c=`list/organisation/project?`+s.toString(),{data:l}=await f.default.get(c);return{items:l._embedded.items,amountOfPages:l.page_count,currentPage:l.page,totalItems:l.total_items,hasMore:l.page<l.page_count}}async function Ce({environment:e,query:t,order:n,direction:r,page:i,page_size:a,purpose:o}={}){let s=new URLSearchParams;e!==void 0&&s.append(`environment`,e),t!==void 0&&s.append(`query`,t),n!==void 0&&s.append(`order`,n),r!==void 0&&s.append(`direction`,r),i!==void 0&&s.append(`page`,i.toString()),a!==void 0&&s.append(`page_size`,a.toString()),o!==void 0&&s.append(`purpose`,o.toString());let c=`list/organisation/team?`+s.toString(),{data:l}=await f.default.get(c);return{items:l._embedded.items,amountOfPages:l.page_count,currentPage:l.page,totalItems:l.total_items,hasMore:l.page<l.page_count}}async function we({name:e,motivation:t,group_id:n,team_id:r,project_id:i,parts:a,location:o,run_type:s}){return(await f.default.post(`create/run`,{name:e,motivation:t,group_id:n,team_id:r,project_id:i,...a===void 0?{}:{parts:a},...o===void 0?{}:{location:o},...s===void 0?{}:{run_type:s}})).data}async function Te({run_id:e,parent_run_id:t,part_ids:n,amount_per_part:r,description:i}){return(await f.default.post(`create/run/parent`,{run_id:e,parent_run_id:t,...n===void 0?{}:{part_ids:n},...r===void 0?{}:{amount_per_part:r},...i===void 0?{}:{description:i}})).data}async function Ee({run_id:e,substrate_id:t,amount:n}){return(await f.default.post(`create/run/substrate`,{run_id:e,substrate_id:t,amount:n})).data}async function De({file:e}){let t=`delete/run/file/`+e.id;await f.default.delete(t)}async function Oe({id:e}){let t=`view/run/`+e,{data:n}=await f.default.get(t);return n}async function ke({id:e}){let t=`view/run/step/`+e,{data:n}=await f.default.get(t);return n}async function Ae({run:e,query:t,order:n,direction:r,pageSize:i,page:a}){let o=new URLSearchParams;o.append(`run`,e.id.toString()),t!==void 0&&o.append(`query`,t),n!==void 0&&o.append(`order`,n),r!==void 0&&o.append(`direction`,r),i!==void 0&&o.append(`page_size`,i.toString()),a!==void 0&&o.append(`page`,a.toString());let s=`list/run/file?`+o.toString(),{data:c}=await f.default.get(s);return{items:c._embedded.items,amountOfPages:c.page_count,currentPage:c.page,totalItems:c.total_items,hasMore:c.page<c.page_count}}async function je({step:e,run:t}){let n=new URLSearchParams;e!==void 0&&n.append(`step`,String(e.id)),t!==void 0&&n.append(`run`,String(t.id));let r=`list/run/requirement?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function Me({run:e,page:t}){let n=new URLSearchParams;e!==void 0&&n.append(`run`,e.id.toString()),n.append(`page`,t.toString());let r=`list/run/changelog?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function Ne({run:e,level:t}){let n=new URLSearchParams;n.append(`run`,e.id.toString()),n.append(`page_size`,`10000`),t!==void 0&&n.append(`level`,`${t}`);let r=`list/run/parts?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function Pe({run:e,page:t=1,pageSize:n=25}){let r=new URLSearchParams;e!==void 0&&r.append(`run`,e.id.toString()),r.append(`page`,t.toString()),r.append(`page_size`,n.toString());let i=`list/run/step?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function Fe({environment:e,firstUnfinishedStepEquipment:t,availableAsParentForRun:n}){let r=new URLSearchParams;t!==void 0&&(r.append(`operator`,`1`),r.append(`first_unfinished_step_equipment_id`,t.id.toString())),e!==void 0&&r.append(`environment`,e),n!=null&&r.append(`available_as_parent_for_run`,n.id.toString());let i=`list/run?`+r.toString(),{data:a}=await f.default.get(i);return{items:a._embedded.items,amountOfPages:a.page_count,currentPage:a.page,totalItems:a.total_items,hasMore:a.page<a.page_count}}async function Ie({filename:e,type:t,content:n,run:r,step:i}){let{data:a}=await f.default.post(`create/file/upload-file`,{filename:e,type:t,content:n,...r===void 0?{}:{run:r.id},...i===void 0?{}:{step:i.id}});return a}async function Le({measurement:e}){let t=new URLSearchParams;t.append(`measurement`,String(e.id));let n=`/list/run/measurement/result?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function Re({runStep:e}){let t=new URLSearchParams;e!==void 0&&t.append(`step`,e.id.toString());let n=`list/run/step/checklist?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function ze(e){if(!e)throw Error(`Run step is undefined when trying to finish step`);return await f.default.create().patch(`update/run/step/finish/`+e.id,{})}async function Be({step:e,pageSize:t}){let n=new URLSearchParams;e!==void 0&&n.append(`step`,e.id.toString()),t!==void 0&&n.append(`page_size`,t.toString()),n.append(`order`,`date-created`),n.append(`direction`,`DESC`);let r=`list/run/step/file?`+n.toString(),{data:i}=await f.default.get(r);return{items:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items,hasMore:i.page<i.page_count}}async function Ve({runStep:e}){let t=new URLSearchParams;e!==void 0&&t.append(`step`,e.id.toString());let n=`list/run/step/parameter?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function He({step:e,run:t,runPart:n,page_size:r,page:i}){let a=new URLSearchParams;if(e!==void 0&&a.append(`step`,e.id.toString()),t!==void 0&&a.append(`run`,t.id.toString()),n!==void 0)for(let e of n)a.append(`part[]`,e.id.toString());i!==void 0&&a.append(`page`,i.toString()),r===void 0?a.append(`page_size`,`1000`):a.append(`page_size`,r.toString());let o=`list/run/step/part?`+a.toString(),{data:s}=await f.default.get(o);return{items:s._embedded.items,amountOfPages:s.page_count,currentPage:s.page,totalItems:s.total_items,hasMore:s.page<s.page_count}}async function Ue(e,t,n,r,i){if(!e||!t||!r||!n)throw Error(`Invalid values when trying to update run step part tray`);let a={tray_id:t.id,tray_row:n,tray_column:r};return i!=null&&(a.update_subsequent=i),await f.default.create().patch(`update/run/step/part/${e.id}/tray`,a)}async function We({runStepPart:e,runStepPartAction:t}){let{data:n}=await f.default.post(`create/run/step/part/action`,{run_step_part_id:e.id,type:t});return n}async function F({runStepPartActions:e}){let{data:t}=await f.default.post(`create/run/step/part/action`,{items:e.map(({runStepPart:e,runStepPartAction:t,comment:n})=>({run_step_part_id:e.id,type:t,...n===void 0?{}:{comment:n}}))});return t}var Ge=function(e){return e[e.START=1]=`START`,e[e.FINISH=2]=`FINISH`,e[e.FAIL=3]=`FAIL`,e[e.REWORK=4]=`REWORK`,e[e.SET_REPAIR=5]=`SET_REPAIR`,e[e.CLEAR_REPAIR=6]=`CLEAR_REPAIR`,e[e.SET_TESTING=7]=`SET_TESTING`,e[e.CLEAR_TESTING=8]=`CLEAR_TESTING`,e}({});function Ke(e){return new Map([[Ge.START,`start_processing`],[Ge.FINISH,`finish_processing`],[Ge.FAIL,`fail_processing`],[Ge.REWORK,`rework`],[Ge.SET_REPAIR,`repair`],[Ge.CLEAR_REPAIR,`clear_repairing`],[Ge.SET_TESTING,`test`],[Ge.CLEAR_TESTING,`clear_testing`]]).get(e)??null}function qe(e){return new Map([[`start_processing`,Ge.START],[`finish_processing`,Ge.FINISH],[`fail_processing`,Ge.FAIL],[`rework`,Ge.REWORK],[`repair`,Ge.SET_REPAIR],[`clear_repairing`,Ge.CLEAR_REPAIR],[`test`,Ge.SET_TESTING],[`clear_testing`,Ge.CLEAR_TESTING]]).get(e)??null}async function Je({id:e}){let t=new URLSearchParams;e!==void 0&&t.append(`report`,e.toString());let n=`list/service/event/report/results?`+t.toString(),{data:r}=await f.default.get(n);return r._embedded.items}async function Ye({id:e}){let{data:t}=await f.default.get(`view/service/event/report/`+e);return t}async function Xe({equipmentId:e}){let t=new URLSearchParams;e!==void 0&&t.append(`equipment`,e.toString());let n=`list/service?`+t.toString(),{data:r}=await f.default.get(n);return{items:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items,hasMore:r.page<r.page_count}}async function Ze({template:e,pageSize:t}){let n=new URLSearchParams;e!==void 0&&n.append(`template`,e.id.toString()),t!==void 0&&n.append(`page_size`,t.toString());let r=`list/template/step?`+n.toString(),{data:i}=await f.default.get(r);return{steps:i._embedded.items,amountOfPages:i.page_count,currentPage:i.page,totalItems:i.total_items}}async function Qe({reworkRecipes:e}){let t=new URLSearchParams;e!==void 0&&e.map(e=>e.id).forEach(e=>{t.append(`rework_recipe_id[]`,e.toString())});let n=`list/template?`+t.toString(),{data:r}=await f.default.get(n);return{templates:r._embedded.items,amountOfPages:r.page_count,currentPage:r.page,totalItems:r.total_items}}async function $e({query:e,order:t,direction:n,pageSize:r=25,page:i=1}){let a=new URLSearchParams;e!==void 0&&a.append(`query`,e),t!==void 0&&a.append(`order`,t),n!==void 0&&a.append(`direction`,n),a.append(`page_size`,r.toString()),a.append(`page`,i.toString());let o=`list/substrate?`+a.toString(),{data:s}=await f.default.get(o);return{items:s._embedded.items,amountOfPages:s.page_count,currentPage:s.page,totalItems:s.total_items,hasMore:s.page<s.page_count}}function et(e){return e?f.default.create({baseURL:e}):f.default}function tt(e,t){return t?new URL(e,t).toString():e}function nt({path:e,irisServerUrl:t,onEvent:n,onOpen:r,onError:i}){let a=new AbortController,o=f.default.defaults.headers.common.Authorization;return{start:async()=>{try{let i=await fetch(tt(e,t),{method:`GET`,headers:{Accept:`text/event-stream`,...typeof o==`string`?{Authorization:o}:{}},signal:a.signal});if(!i.ok)throw Error(`HTTP ${i.status}`);r&&r(new Event(`open`));let s=i.body?.getReader();if(!s)throw Error(`ReadableStream not supported`);let c=new TextDecoder,l=``;for(;;){let{value:e,done:t}=await s.read();if(t)break;l+=c.decode(e,{stream:!0});let r=l.split(`
|
|
2
2
|
|
|
3
3
|
`);l=r.pop()||``;for(let e of r){let t=rt(e);if(t.data&&n)try{n(JSON.parse(t.data))}catch{n(t.data)}}}}catch{i&&i(new Event(`error`))}},close:()=>a.abort()}}function rt(e){let t=e.split(`
|
|
4
4
|
`),n={};for(let e of t)e.startsWith(`data:`)?n.data=(n.data||``)+e.slice(5).trim():e.startsWith(`event:`)?n.type=e.slice(6).trim():e.startsWith(`id:`)&&(n.id=e.slice(3).trim());return n}function it({context:e,...t}){return nt({...t,path:`/v1/${encodeURIComponent(e)}/stream/events`})}async function at({context:e,irisServerUrl:t}){let n=et(t),r=`/v1/${encodeURIComponent(e)}/list/events`;return(await n.get(r)).data}async function ot({fileUploadEventUid:e,irisServerUrl:t}){let n=et(t),r=`/v1/event/${encodeURIComponent(e)}/fail`;return(await n.post(r,{})).data}async function st({fileUploadEventUid:e,irisServerUrl:t}){let n=et(t),r=`/v1/event/${encodeURIComponent(e)}/finish`;return(await n.post(r,{})).data}async function ct({fileUploadEventUid:e,irisServerUrl:t}){let n=et(t),r=`/v1/event/${encodeURIComponent(e)}/approve`;return(await n.post(r,{})).data}async function lt({fileUploadEventUid:e,irisServerUrl:t}){let n=et(t),r=`/v1/event/${encodeURIComponent(e)}/reject`;return(await n.post(r,{})).data}var ut=function(e){return e[e.STANDARD_PRODUCT=1]=`STANDARD_PRODUCT`,e[e.NON_STANDARD_PRODUCT=2]=`NON_STANDARD_PRODUCT`,e}({}),dt=function(e){return e[e.SOLID=1]=`SOLID`,e[e.LIQUID=2]=`LIQUID`,e[e.GAS=3]=`GAS`,e[e.OTHER=4]=`OTHER`,e}({}),ft=function(e){return e[e.Equipment=1]=`Equipment`,e[e.Accessory=2]=`Accessory`,e[e.Storage=3]=`Storage`,e}({}),pt=function(e){return e[e.DEFAULT=1]=`DEFAULT`,e[e.PRIORITY=2]=`PRIORITY`,e[e.ESCALATION=3]=`ESCALATION`,e}({}),mt=function(e){return e[e.ACTIVE=1]=`ACTIVE`,e[e.CLOSED=2]=`CLOSED`,e}({}),ht=function(e){return e[e.AREA=1]=`AREA`,e[e.AREA_PER_FACILITY=2]=`AREA_PER_FACILITY`,e[e.ROOM=3]=`ROOM`,e}({}),gt=function(e){return e[e.RESEARCH=1]=`RESEARCH`,e[e.PRODUCTION=2]=`PRODUCTION`,e}({}),_t=function(e){return e[e.Run=1]=`Run`,e[e.Equipment=2]=`Equipment`,e[e.Sensors=3]=`Sensors`,e[e.Substrate=4]=`Substrate`,e[e.Chemicals=5]=`Chemicals`,e}({}),vt=function(e){return e[e.Run=1]=`Run`,e[e.Service=2]=`Service`,e[e.Quota=3]=`Quota`,e}({}),yt={serverUri:``,irisServerUri:``};function bt(e){if(!e)return``;let t=/^[a-zA-Z]+:\/\//.test(e)?e:`https://${e}`,n=new URL(t);return n.pathname=`/`,n.search=``,n.hash=``,n.toString()}function xt(e){e.serverUri!==void 0&&(yt.serverUri=bt(e.serverUri)),e.irisServerUri!==void 0&&(yt.irisServerUri=bt(e.irisServerUri))}function St(){return yt.serverUri+`api`}function Ct(){return yt.serverUri}function wt(){return yt.irisServerUri}var Tt=()=>{let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(!0),i=(0,d.useRef)(!1);return(0,d.useEffect)(()=>{let e=document.getElementById(`root`)?.dataset.jwt??``;if(w(e,St()),!e){r(!1);return}i.current||(i.current=!0,x().then(t).finally(()=>r(!1)))},[]),{user:e,setUser:t,isLoadingUser:n}},Et=({message:e})=>(0,p.jsxs)(`div`,{className:`d-flex flex-column justify-content-center align-items-center`,style:{height:`100vh`},children:[(0,p.jsx)(`div`,{className:`spinner-border`,role:`status`,"aria-label":`Loading`}),(0,p.jsx)(`p`,{className:`mt-3 mb-0`,children:e||`Loading...`})]});function Dt(e){"@babel/helpers - typeof";return Dt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Dt(e)}function Ot(e,t){if(Dt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Dt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function kt(e){var t=Ot(e,`string`);return Dt(t)==`symbol`?t:t+``}function At(e,t,n){return(t=kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var jt=class extends d.default.Component{constructor(e){super(e),At(this,`handleReset`,()=>{this.setState({hasError:!1,error:void 0})}),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught an error`,e,t)}render(){return this.state.hasError?this.props.fallback?(0,p.jsx)(p.Fragment,{children:this.props.fallback}):(0,p.jsxs)(`div`,{style:{padding:16},children:[(0,p.jsx)(`h3`,{children:`Ssomething went wrong.`}),this.state.error&&(0,p.jsx)(`pre`,{style:{color:`#c00`,whiteSpace:`pre-wrap`},children:this.state.error.message}),(0,p.jsx)(`button`,{type:`button`,onClick:this.handleReset,children:`Try again`})]}):this.props.children}},Mt=({children:e})=>{let{user:t,setUser:n,isLoadingUser:r}=Tt();return r?(0,p.jsx)(jt,{children:(0,p.jsx)(Et,{message:`Loading user...`})}):(0,p.jsx)(jt,{children:(0,p.jsx)(v.Provider,{value:{user:t,setUser:n,isLoadingUser:r},children:e})})},Nt=o(((e,t)=>{(function(){"use strict";var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}));function I(){return I=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(null,arguments)}function Pt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ft=l(o(((e,t)=>{t.exports=function(e,t,n,r,i,a,o,s){if(process.env.NODE_ENV!==`production`&&t===void 0)throw Error(`invariant requires an error message argument`);if(!e){var c;if(t===void 0)c=Error(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var l=[n,r,i,a,o,s],u=0;c=Error(t.replace(/%s/g,function(){return l[u++]})),c.name=`Invariant Violation`}throw c.framesToPop=1,c}}}))());function It(e){return`default`+e.charAt(0).toUpperCase()+e.substr(1)}function Lt(e){var t=Rt(e,`string`);return typeof t==`symbol`?t:String(t)}function Rt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function zt(e,t,n){var r=(0,u.useRef)(e!==void 0),i=(0,u.useState)(t),a=i[0],o=i[1],s=e!==void 0,c=r.current;return r.current=s,!s&&c&&a!==t&&o(t),[s?e:a,(0,u.useCallback)(function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];n&&n.apply(void 0,[e].concat(r)),o(e)},[n])]}function Bt(e,t){return Object.keys(t).reduce(function(n,r){var i,a=n,o=a[It(r)],s=a[r],c=Pt(a,[It(r),r].map(Lt)),l=t[r],u=zt(s,o,e[l]),d=u[0],f=u[1];return I({},c,(i={},i[r]=d,i[l]=f,i))},e)}function Vt(e,t){return Vt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Vt(e,t)}function Ht(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Vt(e,t)}function Ut(){var e=this.constructor.getDerivedStateFromProps(this.props,this.state);e!=null&&this.setState(e)}function Wt(e){function t(t){return this.constructor.getDerivedStateFromProps(e,t)??null}this.setState(t.bind(this))}function Gt(e,t){try{var n=this.props,r=this.state;this.props=e,this.state=t,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,r)}finally{this.props=n,this.state=r}}Ut.__suppressDeprecationWarning=!0,Wt.__suppressDeprecationWarning=!0,Gt.__suppressDeprecationWarning=!0;var L=l(Nt()),Kt=u.createContext({prefixes:{},breakpoints:[`xxl`,`xl`,`lg`,`md`,`sm`,`xs`],minBreakpoint:`xs`}),{Consumer:qt,Provider:Jt}=Kt;function R(e,t){let{prefixes:n}=(0,u.useContext)(Kt);return e||n[t]||t}function Yt(){let{breakpoints:e}=(0,u.useContext)(Kt);return e}function Xt(){let{minBreakpoint:e}=(0,u.useContext)(Kt);return e}function Zt(){let{dir:e}=(0,u.useContext)(Kt);return e===`rtl`}function Qt(e){return e&&e.ownerDocument||document}function $t(e){var t=Qt(e);return t&&t.defaultView||window}function en(e,t){return $t(e).getComputedStyle(e,t)}var tn=/([A-Z])/g;function nn(e){return e.replace(tn,`-$1`).toLowerCase()}var rn=/^ms-/;function an(e){return nn(e).replace(rn,`-ms-`)}var on=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i;function sn(e){return!!(e&&on.test(e))}function cn(e,t){var n=``,r=``;if(typeof t==`string`)return e.style.getPropertyValue(an(t))||en(e).getPropertyValue(an(t));Object.keys(t).forEach(function(i){var a=t[i];!a&&a!==0?e.style.removeProperty(an(i)):sn(i)?r+=i+`(`+a+`) `:n+=an(i)+`: `+a+`;`}),r&&(n+=`transform: `+r+`;`),e.style.cssText+=`;`+n}var ln=o((e=>{var t=typeof Symbol==`function`&&Symbol.for,n=t?Symbol.for(`react.element`):60103,r=t?Symbol.for(`react.portal`):60106,i=t?Symbol.for(`react.fragment`):60107,a=t?Symbol.for(`react.strict_mode`):60108,o=t?Symbol.for(`react.profiler`):60114,s=t?Symbol.for(`react.provider`):60109,c=t?Symbol.for(`react.context`):60110,l=t?Symbol.for(`react.async_mode`):60111,u=t?Symbol.for(`react.concurrent_mode`):60111,d=t?Symbol.for(`react.forward_ref`):60112,f=t?Symbol.for(`react.suspense`):60113,p=t?Symbol.for(`react.suspense_list`):60120,m=t?Symbol.for(`react.memo`):60115,h=t?Symbol.for(`react.lazy`):60116,g=t?Symbol.for(`react.block`):60121,_=t?Symbol.for(`react.fundamental`):60117,v=t?Symbol.for(`react.responder`):60118,y=t?Symbol.for(`react.scope`):60119;function b(e){if(typeof e==`object`&&e){var t=e.$$typeof;switch(t){case n:switch(e=e.type,e){case l:case u:case i:case o:case a:case f:return e;default:switch(e=e&&e.$$typeof,e){case c:case d:case h:case m:case s:return e;default:return t}}case r:return t}}}function x(e){return b(e)===u}e.AsyncMode=l,e.ConcurrentMode=u,e.ContextConsumer=c,e.ContextProvider=s,e.Element=n,e.ForwardRef=d,e.Fragment=i,e.Lazy=h,e.Memo=m,e.Portal=r,e.Profiler=o,e.StrictMode=a,e.Suspense=f,e.isAsyncMode=function(e){return x(e)||b(e)===l},e.isConcurrentMode=x,e.isContextConsumer=function(e){return b(e)===c},e.isContextProvider=function(e){return b(e)===s},e.isElement=function(e){return typeof e==`object`&&!!e&&e.$$typeof===n},e.isForwardRef=function(e){return b(e)===d},e.isFragment=function(e){return b(e)===i},e.isLazy=function(e){return b(e)===h},e.isMemo=function(e){return b(e)===m},e.isPortal=function(e){return b(e)===r},e.isProfiler=function(e){return b(e)===o},e.isStrictMode=function(e){return b(e)===a},e.isSuspense=function(e){return b(e)===f},e.isValidElementType=function(e){return typeof e==`string`||typeof e==`function`||e===i||e===u||e===o||e===a||e===f||e===p||typeof e==`object`&&!!e&&(e.$$typeof===h||e.$$typeof===m||e.$$typeof===s||e.$$typeof===c||e.$$typeof===d||e.$$typeof===_||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)},e.typeOf=b})),un=o((e=>{process.env.NODE_ENV!==`production`&&(function(){"use strict";var t=typeof Symbol==`function`&&Symbol.for,n=t?Symbol.for(`react.element`):60103,r=t?Symbol.for(`react.portal`):60106,i=t?Symbol.for(`react.fragment`):60107,a=t?Symbol.for(`react.strict_mode`):60108,o=t?Symbol.for(`react.profiler`):60114,s=t?Symbol.for(`react.provider`):60109,c=t?Symbol.for(`react.context`):60110,l=t?Symbol.for(`react.async_mode`):60111,u=t?Symbol.for(`react.concurrent_mode`):60111,d=t?Symbol.for(`react.forward_ref`):60112,f=t?Symbol.for(`react.suspense`):60113,p=t?Symbol.for(`react.suspense_list`):60120,m=t?Symbol.for(`react.memo`):60115,h=t?Symbol.for(`react.lazy`):60116,g=t?Symbol.for(`react.block`):60121,_=t?Symbol.for(`react.fundamental`):60117,v=t?Symbol.for(`react.responder`):60118,y=t?Symbol.for(`react.scope`):60119;function b(e){return typeof e==`string`||typeof e==`function`||e===i||e===u||e===o||e===a||e===f||e===p||typeof e==`object`&&!!e&&(e.$$typeof===h||e.$$typeof===m||e.$$typeof===s||e.$$typeof===c||e.$$typeof===d||e.$$typeof===_||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)}function x(e){if(typeof e==`object`&&e){var t=e.$$typeof;switch(t){case n:var p=e.type;switch(p){case l:case u:case i:case o:case a:case f:return p;default:var g=p&&p.$$typeof;switch(g){case c:case d:case h:case m:case s:return g;default:return t}}case r:return t}}}var S=l,C=u,w=c,T=s,E=n,D=d,O=i,k=h,A=m,j=r,M=o,ee=a,te=f,N=!1;function ne(e){return N||(N=!0,console.warn(`The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.`)),re(e)||x(e)===l}function re(e){return x(e)===u}function ie(e){return x(e)===c}function ae(e){return x(e)===s}function P(e){return typeof e==`object`&&!!e&&e.$$typeof===n}function oe(e){return x(e)===d}function se(e){return x(e)===i}function ce(e){return x(e)===h}function le(e){return x(e)===m}function ue(e){return x(e)===r}function de(e){return x(e)===o}function fe(e){return x(e)===a}function pe(e){return x(e)===f}e.AsyncMode=S,e.ConcurrentMode=C,e.ContextConsumer=w,e.ContextProvider=T,e.Element=E,e.ForwardRef=D,e.Fragment=O,e.Lazy=k,e.Memo=A,e.Portal=j,e.Profiler=M,e.StrictMode=ee,e.Suspense=te,e.isAsyncMode=ne,e.isConcurrentMode=re,e.isContextConsumer=ie,e.isContextProvider=ae,e.isElement=P,e.isForwardRef=oe,e.isFragment=se,e.isLazy=ce,e.isMemo=le,e.isPortal=ue,e.isProfiler=de,e.isStrictMode=fe,e.isSuspense=pe,e.isValidElementType=b,e.typeOf=x})()})),dn=o(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=ln():t.exports=un()})),fn=o(((e,t)=>{var n=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function a(e){if(e==null)throw TypeError(`Object.assign cannot be called with null or undefined`);return Object(e)}function o(){try{if(!Object.assign)return!1;var e=new String(`abc`);if(e[5]=`de`,Object.getOwnPropertyNames(e)[0]===`5`)return!1;for(var t={},n=0;n<10;n++)t[`_`+String.fromCharCode(n)]=n;if(Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(``)!==`0123456789`)return!1;var r={};return`abcdefghijklmnopqrst`.split(``).forEach(function(e){r[e]=e}),Object.keys(Object.assign({},r)).join(``)===`abcdefghijklmnopqrst`}catch{return!1}}t.exports=o()?Object.assign:function(e,t){for(var o,s=a(e),c,l=1;l<arguments.length;l++){for(var u in o=Object(arguments[l]),o)r.call(o,u)&&(s[u]=o[u]);if(n){c=n(o);for(var d=0;d<c.length;d++)i.call(o,c[d])&&(s[c[d]]=o[c[d]])}}return s}})),pn=o(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),mn=o(((e,t)=>{t.exports=Function.call.bind(Object.prototype.hasOwnProperty)})),hn=o(((e,t)=>{var n=function(){};if(process.env.NODE_ENV!==`production`){var r=pn(),i={},a=mn();n=function(e){var t=`Warning: `+e;typeof console<`u`&&console.error(t);try{throw Error(t)}catch{}}}function o(e,t,o,s,c){if(process.env.NODE_ENV!==`production`){for(var l in e)if(a(e,l)){var u;try{if(typeof e[l]!=`function`){var d=Error((s||`React class`)+`: `+o+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw d.name=`Invariant Violation`,d}u=e[l](t,l,s,o,null,r)}catch(e){u=e}if(u&&!(u instanceof Error)&&n((s||`React class`)+`: type specification of `+o+" `"+l+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof u+`. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).`),u instanceof Error&&!(u.message in i)){i[u.message]=!0;var f=c?c():``;n(`Failed `+o+` type: `+u.message+(f??``))}}}}o.resetWarningCache=function(){process.env.NODE_ENV!==`production`&&(i={})},t.exports=o})),gn=o(((e,t)=>{var n=dn(),r=fn(),i=pn(),a=mn(),o=hn(),s=function(){};process.env.NODE_ENV!==`production`&&(s=function(e){var t=`Warning: `+e;typeof console<`u`&&console.error(t);try{throw Error(t)}catch{}});function c(){return null}t.exports=function(e,t){var l=typeof Symbol==`function`&&Symbol.iterator,u=`@@iterator`;function d(e){var t=e&&(l&&e[l]||e[u]);if(typeof t==`function`)return t}var f=`<<anonymous>>`,p={array:_(`array`),bigint:_(`bigint`),bool:_(`boolean`),func:_(`function`),number:_(`number`),object:_(`object`),string:_(`string`),symbol:_(`symbol`),any:v(),arrayOf:y,element:b(),elementType:x(),instanceOf:S,node:E(),objectOf:w,oneOf:C,oneOfType:T,shape:O,exact:k};function m(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}function h(e,t){this.message=e,this.data=t&&typeof t==`object`?t:{},this.stack=``}h.prototype=Error.prototype;function g(e){if(process.env.NODE_ENV!==`production`)var n={},r=0;function a(a,o,c,l,u,d,p){if(l=l||f,d=d||c,p!==i){if(t){var m=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw m.name=`Invariant Violation`,m}else if(process.env.NODE_ENV!==`production`&&typeof console<`u`){var g=l+`:`+c;!n[g]&&r<3&&(s("You are manually calling a React.PropTypes validation function for the `"+d+"` prop on `"+l+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),n[g]=!0,r++)}}return o[c]==null?a?o[c]===null?new h(`The `+u+" `"+d+"` is marked as required "+("in `"+l+"`, but its value is `null`.")):new h(`The `+u+" `"+d+"` is marked as required in "+("`"+l+"`, but its value is `undefined`.")):null:e(o,c,l,u,d)}var o=a.bind(null,!1);return o.isRequired=a.bind(null,!0),o}function _(e){function t(t,n,r,i,a,o){var s=t[n];if(M(s)!==e){var c=ee(s);return new h(`Invalid `+i+" `"+a+"` of type "+("`"+c+"` supplied to `"+r+"`, expected ")+("`"+e+"`."),{expectedType:e})}return null}return g(t)}function v(){return g(c)}function y(e){function t(t,n,r,a,o){if(typeof e!=`function`)return new h("Property `"+o+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var s=t[n];if(!Array.isArray(s)){var c=M(s);return new h(`Invalid `+a+" `"+o+"` of type "+("`"+c+"` supplied to `"+r+"`, expected an array."))}for(var l=0;l<s.length;l++){var u=e(s,l,r,a,o+`[`+l+`]`,i);if(u instanceof Error)return u}return null}return g(t)}function b(){function t(t,n,r,i,a){var o=t[n];if(!e(o)){var s=M(o);return new h(`Invalid `+i+" `"+a+"` of type "+("`"+s+"` supplied to `"+r+"`, expected a single ReactElement."))}return null}return g(t)}function x(){function e(e,t,r,i,a){var o=e[t];if(!n.isValidElementType(o)){var s=M(o);return new h(`Invalid `+i+" `"+a+"` of type "+("`"+s+"` supplied to `"+r+"`, expected a single ReactElement type."))}return null}return g(e)}function S(e){function t(t,n,r,i,a){if(!(t[n]instanceof e)){var o=e.name||f,s=N(t[n]);return new h(`Invalid `+i+" `"+a+"` of type "+("`"+s+"` supplied to `"+r+"`, expected ")+("instance of `"+o+"`."))}return null}return g(t)}function C(e){if(!Array.isArray(e))return process.env.NODE_ENV!==`production`&&(arguments.length>1?s(`Invalid arguments supplied to oneOf, expected an array, got `+arguments.length+` arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).`):s(`Invalid argument supplied to oneOf, expected an array.`)),c;function t(t,n,r,i,a){for(var o=t[n],s=0;s<e.length;s++)if(m(o,e[s]))return null;var c=JSON.stringify(e,function(e,t){return ee(t)===`symbol`?String(t):t});return new h(`Invalid `+i+" `"+a+"` of value `"+String(o)+"` "+("supplied to `"+r+"`, expected one of "+c+`.`))}return g(t)}function w(e){function t(t,n,r,o,s){if(typeof e!=`function`)return new h("Property `"+s+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var c=t[n],l=M(c);if(l!==`object`)return new h(`Invalid `+o+" `"+s+"` of type "+("`"+l+"` supplied to `"+r+"`, expected an object."));for(var u in c)if(a(c,u)){var d=e(c,u,r,o,s+`.`+u,i);if(d instanceof Error)return d}return null}return g(t)}function T(e){if(!Array.isArray(e))return process.env.NODE_ENV!==`production`&&s(`Invalid argument supplied to oneOfType, expected an instance of array.`),c;for(var t=0;t<e.length;t++){var n=e[t];if(typeof n!=`function`)return s(`Invalid argument supplied to oneOfType. Expected an array of check functions, but received `+te(n)+` at index `+t+`.`),c}function r(t,n,r,o,s){for(var c=[],l=0;l<e.length;l++){var u=e[l],d=u(t,n,r,o,s,i);if(d==null)return null;d.data&&a(d.data,`expectedType`)&&c.push(d.data.expectedType)}var f=c.length>0?`, expected one of type [`+c.join(`, `)+`]`:``;return new h(`Invalid `+o+" `"+s+"` supplied to "+("`"+r+"`"+f+`.`))}return g(r)}function E(){function e(e,t,n,r,i){return A(e[t])?null:new h(`Invalid `+r+" `"+i+"` supplied to "+("`"+n+"`, expected a ReactNode."))}return g(e)}function D(e,t,n,r,i){return new h((e||`React class`)+`: `+t+" type `"+n+`.`+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+i+"`.")}function O(e){function t(t,n,r,a,o){var s=t[n],c=M(s);if(c!==`object`)return new h(`Invalid `+a+" `"+o+"` of type `"+c+"` "+("supplied to `"+r+"`, expected `object`."));for(var l in e){var u=e[l];if(typeof u!=`function`)return D(r,a,o,l,ee(u));var d=u(s,l,r,a,o+`.`+l,i);if(d)return d}return null}return g(t)}function k(e){function t(t,n,o,s,c){var l=t[n],u=M(l);if(u!==`object`)return new h(`Invalid `+s+" `"+c+"` of type `"+u+"` "+("supplied to `"+o+"`, expected `object`."));for(var d in r({},t[n],e)){var f=e[d];if(a(e,d)&&typeof f!=`function`)return D(o,s,c,d,ee(f));if(!f)return new h(`Invalid `+s+" `"+c+"` key `"+d+"` supplied to `"+o+`\`.
|
|
@@ -33,7 +33,7 @@ Arguments: `+Array.prototype.slice.call(r).join(``)+`
|
|
|
33
33
|
`},i)),a}function YN(e,t){return e&&`run`in e?async function(n,r){let i=JN(n,{file:r,...t});await e.run(i,r)}:function(n,r){return JN(n,{file:r,...e||t})}}function XN(e){if(e)throw e}var ZN=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 QN(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 $N(){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?eP(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 eP(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 tP={basename:nP,dirname:rP,extname:iP,join:aP,sep:`/`};function nP(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);cP(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 rP(e){if(cP(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 iP(e){cP(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 aP(...e){let t=-1,n;for(;++t<e.length;)cP(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:oP(n)}function oP(e){cP(e);let t=e.codePointAt(0)===47,n=sP(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function sP(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 cP(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var lP={cwd:uP};function uP(){return`/`}function dP(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function fP(e){if(typeof e==`string`)e=new URL(e);else if(!dP(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 pP(e)}function pP(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 mP=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],hP=class{constructor(e){let t;t=e?dP(e)?{path:e}:typeof e==`string`||yP(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:lP.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<mP.length;){let e=mP[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)mP.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?tP.basename(this.path):void 0}set basename(e){_P(e,`basename`),gP(e,`basename`),this.path=tP.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?tP.dirname(this.path):void 0}set dirname(e){vP(this.basename,`dirname`),this.path=tP.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?tP.extname(this.path):void 0}set extname(e){if(gP(e,`extname`),vP(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=tP.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){dP(e)&&(e=fP(e)),_P(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?tP.basename(this.path,this.extname):void 0}set stem(e){_P(e,`stem`),gP(e,`stem`),this.path=tP.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 ik(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 gP(e,t){if(e&&e.includes(tP.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+tP.sep+"`")}function _P(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function vP(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function yP(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var bP=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),xP=l(ZN(),1),SP={}.hasOwnProperty,CP=new class e extends bP{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=$N()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,xP.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(EP(`data`,this.frozen),this.namespace[e]=t,this):SP.call(this.namespace,e)&&this.namespace[e]||void 0:e?(EP(`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=kP(e),n=this.parser||this.Parser;return wP(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),wP(`process`,this.parser||this.Parser),TP(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=kP(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);jP(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(),wP(`processSync`,this.parser||this.Parser),TP(`processSync`,this.compiler||this.Compiler),this.process(e,r),OP(`processSync`,`process`,t),n;function r(e,r){t=!0,XN(e),n=r}}run(e,t,n){DP(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=kP(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),OP(`runSync`,`run`,n),r;function i(e,t){XN(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=kP(t),r=this.compiler||this.Compiler;return TP(`stringify`,r),DP(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(EP(`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,xP.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];QN(o)&&QN(r)&&(r=(0,xP.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function wP(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function TP(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function EP(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 DP(e){if(!QN(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function OP(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function kP(e){return AP(e)?e:new hP(e)}function AP(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function jP(e){return typeof e==`string`||MP(e)}function MP(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var NP=[],PP={allowDangerousHtml:!0},FP=/^(https?|ircs?|mailto|xmpp)$/i,IP=[{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 LP(e){let t=RP(e),n=zP(e);return BP(t.runSync(t.parse(n),n),e)}function RP(e){let t=e.rehypePlugins||NP,n=e.remarkPlugins||NP,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...PP}:PP;return CP().use(PM).use(n).use(YN,r).use(t)}function zP(e){let t=e.children||``,n=new hP;return typeof t==`string`?n.value=t:``+t,n}function BP(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||VP;for(let e of IP)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return zN(e,l),dk(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 Nk)if(Object.hasOwn(Nk,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Nk[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 VP(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||FP.test(e.slice(0,t))?e:``}function HP({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)(Dr,{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)(B,{variant:`outline-primary`,size:`sm`,onClick:()=>m(e=>!e),"aria-label":`Toggle Details`,children:f?`Hide Details`:`Show Details`}),(0,p.jsx)(B,{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)(LP,{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:J(l.date_created).format(`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:J(l.date_closed).format(`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:J(l.last_update).format(`DD MMMM YYYY`)})]})]})]}),s&&a]})}var UP=({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||pt.DEFAULT,status:r?.status||mt.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||pt.DEFAULT,status:r?.status||mt.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}=Ub({accept:{"application/*":[],"image/*":[]},onDrop:e=>{o(t=>[...t,...e])}});(0,d.useEffect)(()=>{t&&(async()=>{if(e?.id)try{c((await oe({equipment:e})).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)for(let e=0;e<i.length;e++){let t=i[e].id,n=!1;for(let e=0;e<u.length;e++)if(t==u[e].id){n=!0;break}n||await f.default.delete(`/delete/equipment/module/issue/attachment/${i[e].id}`)}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{c((await oe({equipment:e})).items||[])}catch(e){console.error(`Error fetching modules:`,e)}})()},[e,t]),(0,p.jsx)(U,{show:t,size:`lg`,centered:!0,onHide:()=>n(r),children:(0,p.jsxs)(H,{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)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:r?`Edit Issue for ${e.name}`:`Create new Issue for ${e.name}`})}),(0,p.jsxs)(U.Body,{children:[!r&&(0,p.jsxs)(H.Group,{controlId:`module`,className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module`}),(0,p.jsxs)(H.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)(H.Group,{controlId:`issue`,children:[(0,p.jsx)(H.Label,{children:`Issue`}),(0,p.jsx)(H.Control,{type:`text`,...h(`issue`,{required:`Issue content is required`}),autoFocus:!0})]}),(0,p.jsxs)(H.Group,{controlId:`description`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Description`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,...h(`description`,{required:`Description is required`})})]}),(0,p.jsxs)(H.Group,{controlId:`issueType`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Issue`}),(0,p.jsxs)(H.Control,{as:`select`,...h(`issue_type`,{required:`Issue type is required`}),children:[(0,p.jsx)(`option`,{value:pt.DEFAULT,children:`Default`}),(0,p.jsx)(`option`,{value:pt.PRIORITY,children:`Priority`}),(0,p.jsx)(`option`,{value:pt.ESCALATION,children:`Escalation`})]})]}),(0,p.jsxs)(H.Group,{controlId:`status`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Status`}),(0,p.jsxs)(H.Control,{as:`select`,...h(`status`,{required:`Status is required`}),children:[(0,p.jsx)(`option`,{value:mt.ACTIVE,children:`Active`}),(0,p.jsx)(`option`,{value:mt.CLOSED,children:`Closed`})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:y,...h(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{controlId:`forecastUp`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Forecast Up`}),(0,p.jsx)(H.Control,{type:`date`,...h(`forecast_up`,{required:`Forecast Up date is required`})})]}),(0,p.jsxs)(H.Group,{controlId:`actions`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Actions`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:5,...h(`actions`,{required:!1})})]}),(0,p.jsxs)(H.Group,{children:[(0,p.jsx)(H.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)(B,{variant:`secondary`,onClick:()=>T(t),children:`cancel`})]},`${e.name}-${e.lastModified}`))})]}),u&&u.length>0&&(0,p.jsxs)(H.Group,{controlId:`uploaded_files`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Uploaded files`}),(0,p.jsx)(`ul`,{children:u.map((e,t)=>(0,p.jsxs)(`li`,{children:[e.filename,` `,(0,p.jsx)(B,{variant:`secondary`,onClick:()=>E(t),children:`delete`})]},e.id))})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{variant:`secondary`,onClick:()=>n(r),children:`Cancel`}),(0,p.jsx)(B,{variant:`primary`,type:`submit`,children:r?`Update Issue`:`Create Issue`}),r&&(0,p.jsx)(B,{variant:`danger`,onClick:()=>w(),children:`Close Issue`})]})]})})},WP=l(o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):n.moment=r()})(e,(function(){"use strict";var e;function n(){return e.apply(null,arguments)}function r(t){e=t}function i(e){return e instanceof Array||Object.prototype.toString.call(e)===`[object Array]`}function a(e){return e!=null&&Object.prototype.toString.call(e)===`[object Object]`}function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(e).length===0;for(var t in e)if(o(e,t))return!1;return!0}function c(e){return e===void 0}function l(e){return typeof e==`number`||Object.prototype.toString.call(e)===`[object Number]`}function u(e){return e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`}function d(e,t){var n=[],r,i=e.length;for(r=0;r<i;++r)n.push(t(e[r],r));return n}function f(e,t){for(var n in t)o(t,n)&&(e[n]=t[n]);return o(t,`toString`)&&(e.toString=t.toString),o(t,`valueOf`)&&(e.valueOf=t.valueOf),e}function p(e,t,n,r){return cr(e,t,n,r,!0).utc()}function m(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function h(e){return e._pf??(e._pf=m()),e._pf}var g=Array.prototype.some?Array.prototype.some:function(e){var t=Object(this),n=t.length>>>0,r;for(r=0;r<n;r++)if(r in t&&e.call(this,t[r],r,t))return!0;return!1};function _(e){var t=null,n=!1,r=e._d&&!isNaN(e._d.getTime());if(r&&(t=h(e),n=g.call(t.parsedDateParts,function(e){return e!=null}),r=t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&n),e._strict&&(r=r&&t.charsLeftOver===0&&t.unusedTokens.length===0&&t.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(e))e._isValid=r;else return r;return e._isValid}function v(e){var t=p(NaN);return e==null?h(t).userInvalidated=!0:f(h(t),e),t}var y=n.momentProperties=[],b=!1;function x(e,t){var n,r,i,a=y.length;if(c(t._isAMomentObject)||(e._isAMomentObject=t._isAMomentObject),c(t._i)||(e._i=t._i),c(t._f)||(e._f=t._f),c(t._l)||(e._l=t._l),c(t._strict)||(e._strict=t._strict),c(t._tzm)||(e._tzm=t._tzm),c(t._isUTC)||(e._isUTC=t._isUTC),c(t._offset)||(e._offset=t._offset),c(t._pf)||(e._pf=h(t)),c(t._locale)||(e._locale=t._locale),a>0)for(n=0;n<a;n++)r=y[n],i=t[r],c(i)||(e[r]=i);return e}function S(e){x(this,e),this._d=new Date(e._d==null?NaN:e._d.getTime()),this.isValid()||(this._d=new Date(NaN)),b===!1&&(b=!0,n.updateOffset(this),b=!1)}function C(e){return e instanceof S||e!=null&&e._isAMomentObject!=null}function w(e){n.suppressDeprecationWarnings===!1&&typeof console<`u`&&console.warn&&console.warn(`Deprecation warning: `+e)}function T(e,t){var r=!0;return f(function(){if(n.deprecationHandler!=null&&n.deprecationHandler(null,e),r){var i=[],a,s,c,l=arguments.length;for(s=0;s<l;s++){if(a=``,typeof arguments[s]==`object`){for(c in a+=`
|
|
34
34
|
[`+s+`] `,arguments[0])o(arguments[0],c)&&(a+=c+`: `+arguments[0][c]+`, `);a=a.slice(0,-2)}else a=arguments[s];i.push(a)}w(e+`
|
|
35
35
|
Arguments: `+Array.prototype.slice.call(i).join(``)+`
|
|
36
|
-
`+Error().stack),r=!1}return t.apply(this,arguments)},t)}var E={};function D(e,t){n.deprecationHandler!=null&&n.deprecationHandler(e,t),E[e]||(w(t),E[e]=!0)}n.suppressDeprecationWarnings=!1,n.deprecationHandler=null;function O(e){return typeof Function<`u`&&e instanceof Function||Object.prototype.toString.call(e)===`[object Function]`}function k(e){var t,n;for(n in e)o(e,n)&&(t=e[n],O(t)?this[n]=t:this[`_`+n]=t);this._config=e,this._dayOfMonthOrdinalParseLenient=RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+`|\\d{1,2}`)}function A(e,t){var n=f({},e),r;for(r in t)o(t,r)&&(a(e[r])&&a(t[r])?(n[r]={},f(n[r],e[r]),f(n[r],t[r])):t[r]==null?delete n[r]:n[r]=t[r]);for(r in e)o(e,r)&&!o(t,r)&&a(e[r])&&(n[r]=f({},n[r]));return n}function j(e){e!=null&&this.set(e)}var M=Object.keys?Object.keys:function(e){var t,n=[];for(t in e)o(e,t)&&n.push(t);return n},ee={sameDay:`[Today at] LT`,nextDay:`[Tomorrow at] LT`,nextWeek:`dddd [at] LT`,lastDay:`[Yesterday at] LT`,lastWeek:`[Last] dddd [at] LT`,sameElse:`L`};function te(e,t,n){var r=this._calendar[e]||this._calendar.sameElse;return O(r)?r.call(t,n):r}function N(e,t,n){var r=``+Math.abs(e),i=t-r.length;return(e>=0?n?`+`:``:`-`)+(10**Math.max(0,i)).toString().substr(1)+r}var ne=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,re=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ie={},ae={};function P(e,t,n,r){var i=r;typeof r==`string`&&(i=function(){return this[r]()}),e&&(ae[e]=i),t&&(ae[t[0]]=function(){return N(i.apply(this,arguments),t[1],t[2])}),n&&(ae[n]=function(){return this.localeData().ordinal(i.apply(this,arguments),e)})}function oe(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,``):e.replace(/\\/g,``)}function se(e){var t=e.match(ne),n,r;for(n=0,r=t.length;n<r;n++)ae[t[n]]?t[n]=ae[t[n]]:t[n]=oe(t[n]);return function(n){var i=``,a;for(a=0;a<r;a++)i+=O(t[a])?t[a].call(n,e):t[a];return i}}function ce(e,t){return e.isValid()?(t=le(t,e.localeData()),ie[t]=ie[t]||se(t),ie[t](e)):e.localeData().invalidDate()}function le(e,t){var n=5;function r(e){return t.longDateFormat(e)||e}for(re.lastIndex=0;n>=0&&re.test(e);)e=e.replace(re,r),re.lastIndex=0,--n;return e}var ue={LTS:`h:mm:ss A`,LT:`h:mm A`,L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`};function de(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toUpperCase()];return t||!n?t:(this._longDateFormat[e]=n.match(ne).map(function(e){return e===`MMMM`||e===`MM`||e===`DD`||e===`dddd`?e.slice(1):e}).join(``),this._longDateFormat[e])}var fe=`Invalid date`;function pe(){return this._invalidDate}var me=`%d`,he=/\d{1,2}/;function ge(e){return this._ordinal.replace(`%d`,e)}var _e={future:`in %s`,past:`%s ago`,s:`a few seconds`,ss:`%d seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,w:`a week`,ww:`%d weeks`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function ve(e,t,n,r){var i=this._relativeTime[n];return O(i)?i(e,t,n,r):i.replace(/%d/i,e)}function ye(e,t){var n=this._relativeTime[e>0?`future`:`past`];return O(n)?n(t):n.replace(/%s/i,t)}var be={D:`date`,dates:`date`,date:`date`,d:`day`,days:`day`,day:`day`,e:`weekday`,weekdays:`weekday`,weekday:`weekday`,E:`isoWeekday`,isoweekdays:`isoWeekday`,isoweekday:`isoWeekday`,DDD:`dayOfYear`,dayofyears:`dayOfYear`,dayofyear:`dayOfYear`,h:`hour`,hours:`hour`,hour:`hour`,ms:`millisecond`,milliseconds:`millisecond`,millisecond:`millisecond`,m:`minute`,minutes:`minute`,minute:`minute`,M:`month`,months:`month`,month:`month`,Q:`quarter`,quarters:`quarter`,quarter:`quarter`,s:`second`,seconds:`second`,second:`second`,gg:`weekYear`,weekyears:`weekYear`,weekyear:`weekYear`,GG:`isoWeekYear`,isoweekyears:`isoWeekYear`,isoweekyear:`isoWeekYear`,w:`week`,weeks:`week`,week:`week`,W:`isoWeek`,isoweeks:`isoWeek`,isoweek:`isoWeek`,y:`year`,years:`year`,year:`year`};function xe(e){return typeof e==`string`?be[e]||be[e.toLowerCase()]:void 0}function Se(e){var t={},n,r;for(r in e)o(e,r)&&(n=xe(r),n&&(t[n]=e[r]));return t}var Ce={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function we(e){var t=[],n;for(n in e)o(e,n)&&t.push({unit:n,priority:Ce[n]});return t.sort(function(e,t){return e.priority-t.priority}),t}var Te=/\d/,Ee=/\d\d/,De=/\d{3}/,Oe=/\d{4}/,ke=/[+-]?\d{6}/,Ae=/\d\d?/,je=/\d\d\d\d?/,Me=/\d\d\d\d\d\d?/,Ne=/\d{1,3}/,Pe=/\d{1,4}/,Fe=/[+-]?\d{1,6}/,Ie=/\d+/,Le=/[+-]?\d+/,Re=/Z|[+-]\d\d:?\d\d/gi,ze=/Z|[+-]\d\d(?::?\d\d)?/gi,Be=/[+-]?\d+(\.\d{1,3})?/,Ve=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,He=/^[1-9]\d?/,Ue=/^([1-9]\d|\d)/,We={};function F(e,t,n){We[e]=O(t)?t:function(e,r){return e&&n?n:t}}function Ge(e,t){return o(We,e)?We[e](t._strict,t._locale):new RegExp(Ke(e))}function Ke(e){return qe(e.replace(`\\`,``).replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,n,r,i){return t||n||r||i}))}function qe(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,`\\$&`)}function Je(e){return e<0?Math.ceil(e)||0:Math.floor(e)}function Ye(e){var t=+e,n=0;return t!==0&&isFinite(t)&&(n=Je(t)),n}var Xe={};function Ze(e,t){var n,r=t,i;for(typeof e==`string`&&(e=[e]),l(t)&&(r=function(e,n){n[t]=Ye(e)}),i=e.length,n=0;n<i;n++)Xe[e[n]]=r}function Qe(e,t){Ze(e,function(e,n,r,i){r._w=r._w||{},t(e,r._w,r,i)})}function $e(e,t,n){t!=null&&o(Xe,e)&&Xe[e](t,n._a,n,e)}function et(e){return e%4==0&&e%100!=0||e%400==0}var tt=0,nt=1,rt=2,it=3,at=4,ot=5,st=6,ct=7,lt=8;P(`Y`,0,0,function(){var e=this.year();return e<=9999?N(e,4):`+`+e}),P(0,[`YY`,2],0,function(){return this.year()%100}),P(0,[`YYYY`,4],0,`year`),P(0,[`YYYYY`,5],0,`year`),P(0,[`YYYYYY`,6,!0],0,`year`),F(`Y`,Le),F(`YY`,Ae,Ee),F(`YYYY`,Pe,Oe),F(`YYYYY`,Fe,ke),F(`YYYYYY`,Fe,ke),Ze([`YYYYY`,`YYYYYY`],tt),Ze(`YYYY`,function(e,t){t[tt]=e.length===2?n.parseTwoDigitYear(e):Ye(e)}),Ze(`YY`,function(e,t){t[tt]=n.parseTwoDigitYear(e)}),Ze(`Y`,function(e,t){t[tt]=parseInt(e,10)});function ut(e){return et(e)?366:365}n.parseTwoDigitYear=function(e){return Ye(e)+(Ye(e)>68?1900:2e3)};var dt=pt(`FullYear`,!0);function ft(){return et(this.year())}function pt(e,t){return function(r){return r==null?mt(this,e):(ht(this,e,r),n.updateOffset(this,t),this)}}function mt(e,t){if(!e.isValid())return NaN;var n=e._d,r=e._isUTC;switch(t){case`Milliseconds`:return r?n.getUTCMilliseconds():n.getMilliseconds();case`Seconds`:return r?n.getUTCSeconds():n.getSeconds();case`Minutes`:return r?n.getUTCMinutes():n.getMinutes();case`Hours`:return r?n.getUTCHours():n.getHours();case`Date`:return r?n.getUTCDate():n.getDate();case`Day`:return r?n.getUTCDay():n.getDay();case`Month`:return r?n.getUTCMonth():n.getMonth();case`FullYear`:return r?n.getUTCFullYear():n.getFullYear();default:return NaN}}function ht(e,t,n){var r,i,a,o,s;if(!(!e.isValid()||isNaN(n))){switch(r=e._d,i=e._isUTC,t){case`Milliseconds`:i?r.setUTCMilliseconds(n):r.setMilliseconds(n);return;case`Seconds`:i?r.setUTCSeconds(n):r.setSeconds(n);return;case`Minutes`:i?r.setUTCMinutes(n):r.setMinutes(n);return;case`Hours`:i?r.setUTCHours(n):r.setHours(n);return;case`Date`:i?r.setUTCDate(n):r.setDate(n);return;case`FullYear`:break;default:return}a=n,o=e.month(),s=e.date(),s=s===29&&o===1&&!et(a)?28:s,i?r.setUTCFullYear(a,o,s):r.setFullYear(a,o,s)}}function gt(e){return e=xe(e),O(this[e])?this[e]():this}function _t(e,t){if(typeof e==`object`){e=Se(e);var n=we(e),r,i=n.length;for(r=0;r<i;r++)this[n[r].unit](e[n[r].unit])}else if(e=xe(e),O(this[e]))return this[e](t);return this}function vt(e,t){return(e%t+t)%t}var yt=Array.prototype.indexOf?Array.prototype.indexOf:function(e){var t;for(t=0;t<this.length;++t)if(this[t]===e)return t;return-1};function bt(e,t){if(isNaN(e)||isNaN(t))return NaN;var n=vt(t,12);return e+=(t-n)/12,n===1?et(e)?29:28:31-n%7%2}P(`M`,[`MM`,2],`Mo`,function(){return this.month()+1}),P(`MMM`,0,0,function(e){return this.localeData().monthsShort(this,e)}),P(`MMMM`,0,0,function(e){return this.localeData().months(this,e)}),F(`M`,Ae,He),F(`MM`,Ae,Ee),F(`MMM`,function(e,t){return t.monthsShortRegex(e)}),F(`MMMM`,function(e,t){return t.monthsRegex(e)}),Ze([`M`,`MM`],function(e,t){t[nt]=Ye(e)-1}),Ze([`MMM`,`MMMM`],function(e,t,n,r){var i=n._locale.monthsParse(e,r,n._strict);i==null?h(n).invalidMonth=e:t[nt]=i});var xt=`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),St=`Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec`.split(`_`),Ct=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,wt=Ve,Tt=Ve;function Et(e,t){return e?i(this._months)?this._months[e.month()]:this._months[(this._months.isFormat||Ct).test(t)?`format`:`standalone`][e.month()]:i(this._months)?this._months:this._months.standalone}function Dt(e,t){return e?i(this._monthsShort)?this._monthsShort[e.month()]:this._monthsShort[Ct.test(t)?`format`:`standalone`][e.month()]:i(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Ot(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],r=0;r<12;++r)a=p([2e3,r]),this._shortMonthsParse[r]=this.monthsShort(a,``).toLocaleLowerCase(),this._longMonthsParse[r]=this.months(a,``).toLocaleLowerCase();return n?t===`MMM`?(i=yt.call(this._shortMonthsParse,o),i===-1?null:i):(i=yt.call(this._longMonthsParse,o),i===-1?null:i):t===`MMM`?(i=yt.call(this._shortMonthsParse,o),i===-1?(i=yt.call(this._longMonthsParse,o),i===-1?null:i):i):(i=yt.call(this._longMonthsParse,o),i===-1?(i=yt.call(this._shortMonthsParse,o),i===-1?null:i):i)}function kt(e,t,n){var r,i,a;if(this._monthsParseExact)return Ot.call(this,e,t,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),r=0;r<12;r++)if(i=p([2e3,r]),n&&!this._longMonthsParse[r]&&(this._longMonthsParse[r]=RegExp(`^`+this.months(i,``).replace(`.`,``)+`$`,`i`),this._shortMonthsParse[r]=RegExp(`^`+this.monthsShort(i,``).replace(`.`,``)+`$`,`i`)),!n&&!this._monthsParse[r]&&(a=`^`+this.months(i,``)+`|^`+this.monthsShort(i,``),this._monthsParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`MMMM`&&this._longMonthsParse[r].test(e)||n&&t===`MMM`&&this._shortMonthsParse[r].test(e)||!n&&this._monthsParse[r].test(e))return r}function At(e,t){if(!e.isValid())return e;if(typeof t==`string`){if(/^\d+$/.test(t))t=Ye(t);else if(t=e.localeData().monthsParse(t),!l(t))return e}var n=t,r=e.date();return r=r<29?r:Math.min(r,bt(e.year(),n)),e._isUTC?e._d.setUTCMonth(n,r):e._d.setMonth(n,r),e}function jt(e){return e==null?mt(this,`Month`):(At(this,e),n.updateOffset(this,!0),this)}function Mt(){return bt(this.year(),this.month())}function Nt(e){return this._monthsParseExact?(o(this,`_monthsRegex`)||Pt.call(this),e?this._monthsShortStrictRegex:this._monthsShortRegex):(o(this,`_monthsShortRegex`)||(this._monthsShortRegex=wt),this._monthsShortStrictRegex&&e?this._monthsShortStrictRegex:this._monthsShortRegex)}function I(e){return this._monthsParseExact?(o(this,`_monthsRegex`)||Pt.call(this),e?this._monthsStrictRegex:this._monthsRegex):(o(this,`_monthsRegex`)||(this._monthsRegex=Tt),this._monthsStrictRegex&&e?this._monthsStrictRegex:this._monthsRegex)}function Pt(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i,a,o,s;for(i=0;i<12;i++)a=p([2e3,i]),o=qe(this.monthsShort(a,``)),s=qe(this.months(a,``)),t.push(o),n.push(s),r.push(s),r.push(o);t.sort(e),n.sort(e),r.sort(e),this._monthsRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._monthsShortStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function Ft(e,t,n,r,i,a,o){var s;return e<100&&e>=0?(s=new Date(e+400,t,n,r,i,a,o),isFinite(s.getFullYear())&&s.setFullYear(e)):s=new Date(e,t,n,r,i,a,o),s}function It(e){var t,n;return e<100&&e>=0?(n=Array.prototype.slice.call(arguments),n[0]=e+400,t=new Date(Date.UTC.apply(null,n)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e)):t=new Date(Date.UTC.apply(null,arguments)),t}function Lt(e,t,n){var r=7+t-n;return-((7+It(e,0,r).getUTCDay()-t)%7)+r-1}function Rt(e,t,n,r,i){var a=(7+n-r)%7,o=Lt(e,r,i),s=1+7*(t-1)+a+o,c,l;return s<=0?(c=e-1,l=ut(c)+s):s>ut(e)?(c=e+1,l=s-ut(e)):(c=e,l=s),{year:c,dayOfYear:l}}function zt(e,t,n){var r=Lt(e.year(),t,n),i=Math.floor((e.dayOfYear()-r-1)/7)+1,a,o;return i<1?(o=e.year()-1,a=i+Bt(o,t,n)):i>Bt(e.year(),t,n)?(a=i-Bt(e.year(),t,n),o=e.year()+1):(o=e.year(),a=i),{week:a,year:o}}function Bt(e,t,n){var r=Lt(e,t,n),i=Lt(e+1,t,n);return(ut(e)-r+i)/7}P(`w`,[`ww`,2],`wo`,`week`),P(`W`,[`WW`,2],`Wo`,`isoWeek`),F(`w`,Ae,He),F(`ww`,Ae,Ee),F(`W`,Ae,He),F(`WW`,Ae,Ee),Qe([`w`,`ww`,`W`,`WW`],function(e,t,n,r){t[r.substr(0,1)]=Ye(e)});function Vt(e){return zt(e,this._week.dow,this._week.doy).week}var Ht={dow:0,doy:6};function Ut(){return this._week.dow}function Wt(){return this._week.doy}function Gt(e){var t=this.localeData().week(this);return e==null?t:this.add((e-t)*7,`d`)}function L(e){var t=zt(this,1,4).week;return e==null?t:this.add((e-t)*7,`d`)}P(`d`,0,`do`,`day`),P(`dd`,0,0,function(e){return this.localeData().weekdaysMin(this,e)}),P(`ddd`,0,0,function(e){return this.localeData().weekdaysShort(this,e)}),P(`dddd`,0,0,function(e){return this.localeData().weekdays(this,e)}),P(`e`,0,0,`weekday`),P(`E`,0,0,`isoWeekday`),F(`d`,Ae),F(`e`,Ae),F(`E`,Ae),F(`dd`,function(e,t){return t.weekdaysMinRegex(e)}),F(`ddd`,function(e,t){return t.weekdaysShortRegex(e)}),F(`dddd`,function(e,t){return t.weekdaysRegex(e)}),Qe([`dd`,`ddd`,`dddd`],function(e,t,n,r){var i=n._locale.weekdaysParse(e,r,n._strict);i==null?h(n).invalidWeekday=e:t.d=i}),Qe([`d`,`e`,`E`],function(e,t,n,r){t[r]=Ye(e)});function Kt(e,t){return typeof e==`string`?isNaN(e)?(e=t.weekdaysParse(e),typeof e==`number`?e:null):parseInt(e,10):e}function qt(e,t){return typeof e==`string`?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}function Jt(e,t){return e.slice(t,7).concat(e.slice(0,t))}var R=`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),Yt=`Sun_Mon_Tue_Wed_Thu_Fri_Sat`.split(`_`),Xt=`Su_Mo_Tu_We_Th_Fr_Sa`.split(`_`),Zt=Ve,Qt=Ve,$t=Ve;function en(e,t){var n=i(this._weekdays)?this._weekdays:this._weekdays[e&&e!==!0&&this._weekdays.isFormat.test(t)?`format`:`standalone`];return e===!0?Jt(n,this._week.dow):e?n[e.day()]:n}function tn(e){return e===!0?Jt(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort}function nn(e){return e===!0?Jt(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin}function rn(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],r=0;r<7;++r)a=p([2e3,1]).day(r),this._minWeekdaysParse[r]=this.weekdaysMin(a,``).toLocaleLowerCase(),this._shortWeekdaysParse[r]=this.weekdaysShort(a,``).toLocaleLowerCase(),this._weekdaysParse[r]=this.weekdays(a,``).toLocaleLowerCase();return n?t===`dddd`?(i=yt.call(this._weekdaysParse,o),i===-1?null:i):t===`ddd`?(i=yt.call(this._shortWeekdaysParse,o),i===-1?null:i):(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i):t===`dddd`?(i=yt.call(this._weekdaysParse,o),i!==-1||(i=yt.call(this._shortWeekdaysParse,o),i!==-1)?i:(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i)):t===`ddd`?(i=yt.call(this._shortWeekdaysParse,o),i!==-1||(i=yt.call(this._weekdaysParse,o),i!==-1)?i:(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i)):(i=yt.call(this._minWeekdaysParse,o),i!==-1||(i=yt.call(this._weekdaysParse,o),i!==-1)?i:(i=yt.call(this._shortWeekdaysParse,o),i===-1?null:i))}function an(e,t,n){var r,i,a;if(this._weekdaysParseExact)return rn.call(this,e,t,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),r=0;r<7;r++)if(i=p([2e3,1]).day(r),n&&!this._fullWeekdaysParse[r]&&(this._fullWeekdaysParse[r]=RegExp(`^`+this.weekdays(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._shortWeekdaysParse[r]=RegExp(`^`+this.weekdaysShort(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._minWeekdaysParse[r]=RegExp(`^`+this.weekdaysMin(i,``).replace(`.`,`\\.?`)+`$`,`i`)),this._weekdaysParse[r]||(a=`^`+this.weekdays(i,``)+`|^`+this.weekdaysShort(i,``)+`|^`+this.weekdaysMin(i,``),this._weekdaysParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`dddd`&&this._fullWeekdaysParse[r].test(e)||n&&t===`ddd`&&this._shortWeekdaysParse[r].test(e)||n&&t===`dd`&&this._minWeekdaysParse[r].test(e)||!n&&this._weekdaysParse[r].test(e))return r}function on(e){if(!this.isValid())return e==null?NaN:this;var t=mt(this,`Day`);return e==null?t:(e=Kt(e,this.localeData()),this.add(e-t,`d`))}function sn(e){if(!this.isValid())return e==null?NaN:this;var t=(this.day()+7-this.localeData()._week.dow)%7;return e==null?t:this.add(e-t,`d`)}function cn(e){if(!this.isValid())return e==null?NaN:this;if(e!=null){var t=qt(e,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function ln(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||fn.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(o(this,`_weekdaysRegex`)||(this._weekdaysRegex=Zt),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)}function un(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||fn.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(o(this,`_weekdaysShortRegex`)||(this._weekdaysShortRegex=Qt),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function dn(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||fn.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(o(this,`_weekdaysMinRegex`)||(this._weekdaysMinRegex=$t),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function fn(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i=[],a,o,s,c,l;for(a=0;a<7;a++)o=p([2e3,1]).day(a),s=qe(this.weekdaysMin(o,``)),c=qe(this.weekdaysShort(o,``)),l=qe(this.weekdays(o,``)),t.push(s),n.push(c),r.push(l),i.push(s),i.push(c),i.push(l);t.sort(e),n.sort(e),r.sort(e),i.sort(e),this._weekdaysRegex=RegExp(`^(`+i.join(`|`)+`)`,`i`),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._weekdaysShortStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._weekdaysMinStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function pn(){return this.hours()%12||12}function mn(){return this.hours()||24}P(`H`,[`HH`,2],0,`hour`),P(`h`,[`hh`,2],0,pn),P(`k`,[`kk`,2],0,mn),P(`hmm`,0,0,function(){return``+pn.apply(this)+N(this.minutes(),2)}),P(`hmmss`,0,0,function(){return``+pn.apply(this)+N(this.minutes(),2)+N(this.seconds(),2)}),P(`Hmm`,0,0,function(){return``+this.hours()+N(this.minutes(),2)}),P(`Hmmss`,0,0,function(){return``+this.hours()+N(this.minutes(),2)+N(this.seconds(),2)});function hn(e,t){P(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}hn(`a`,!0),hn(`A`,!1);function gn(e,t){return t._meridiemParse}F(`a`,gn),F(`A`,gn),F(`H`,Ae,Ue),F(`h`,Ae,He),F(`k`,Ae,He),F(`HH`,Ae,Ee),F(`hh`,Ae,Ee),F(`kk`,Ae,Ee),F(`hmm`,je),F(`hmmss`,Me),F(`Hmm`,je),F(`Hmmss`,Me),Ze([`H`,`HH`],it),Ze([`k`,`kk`],function(e,t,n){var r=Ye(e);t[it]=r===24?0:r}),Ze([`a`,`A`],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),Ze([`h`,`hh`],function(e,t,n){t[it]=Ye(e),h(n).bigHour=!0}),Ze(`hmm`,function(e,t,n){var r=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r)),h(n).bigHour=!0}),Ze(`hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r,2)),t[ot]=Ye(e.substr(i)),h(n).bigHour=!0}),Ze(`Hmm`,function(e,t,n){var r=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r))}),Ze(`Hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r,2)),t[ot]=Ye(e.substr(i))});function _n(e){return(e+``).toLowerCase().charAt(0)===`p`}var vn=/[ap]\.?m?\.?/i,yn=pt(`Hours`,!0);function z(e,t,n){return e>11?n?`pm`:`PM`:n?`am`:`AM`}var bn={calendar:ee,longDateFormat:ue,invalidDate:fe,ordinal:me,dayOfMonthOrdinalParse:he,relativeTime:_e,months:xt,monthsShort:St,week:Ht,weekdays:R,weekdaysMin:Xt,weekdaysShort:Yt,meridiemParse:vn},xn={},Sn={},Cn;function wn(e,t){var n,r=Math.min(e.length,t.length);for(n=0;n<r;n+=1)if(e[n]!==t[n])return n;return r}function Tn(e){return e&&e.toLowerCase().replace(`_`,`-`)}function En(e){for(var t=0,n,r,i,a;t<e.length;){for(a=Tn(e[t]).split(`-`),n=a.length,r=Tn(e[t+1]),r=r?r.split(`-`):null;n>0;){if(i=On(a.slice(0,n).join(`-`)),i)return i;if(r&&r.length>=n&&wn(a,r)>=n-1)break;n--}t++}return Cn}function Dn(e){return!!(e&&e.match(`^[^/\\\\]*$`))}function On(e){var n=null,r;if(xn[e]===void 0&&t!==void 0&&t&&t.exports&&Dn(e))try{n=Cn._abbr,r=require,r(`./locale/`+e),kn(n)}catch{xn[e]=null}return xn[e]}function kn(e,t){var n;return e&&(n=c(t)?Mn(e):An(e,t),n?Cn=n:typeof console<`u`&&console.warn&&console.warn(`Locale `+e+` not found. Did you forget to load it?`)),Cn._abbr}function An(e,t){if(t!==null){var n,r=bn;if(t.abbr=e,xn[e]!=null)D(`defineLocaleOverride`,`use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.`),r=xn[e]._config;else if(t.parentLocale!=null)if(xn[t.parentLocale]!=null)r=xn[t.parentLocale]._config;else if(n=On(t.parentLocale),n!=null)r=n._config;else return Sn[t.parentLocale]||(Sn[t.parentLocale]=[]),Sn[t.parentLocale].push({name:e,config:t}),null;return xn[e]=new j(A(r,t)),Sn[e]&&Sn[e].forEach(function(e){An(e.name,e.config)}),kn(e),xn[e]}else return delete xn[e],null}function jn(e,t){if(t!=null){var n,r,i=bn;xn[e]!=null&&xn[e].parentLocale!=null?xn[e].set(A(xn[e]._config,t)):(r=On(e),r!=null&&(i=r._config),t=A(i,t),r??(t.abbr=e),n=new j(t),n.parentLocale=xn[e],xn[e]=n),kn(e)}else xn[e]!=null&&(xn[e].parentLocale==null?xn[e]!=null&&delete xn[e]:(xn[e]=xn[e].parentLocale,e===kn()&&kn(e)));return xn[e]}function Mn(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return Cn;if(!i(e)){if(t=On(e),t)return t;e=[e]}return En(e)}function Nn(){return M(xn)}function Pn(e){var t,n=e._a;return n&&h(e).overflow===-2&&(t=n[nt]<0||n[nt]>11?nt:n[rt]<1||n[rt]>bt(n[tt],n[nt])?rt:n[it]<0||n[it]>24||n[it]===24&&(n[at]!==0||n[ot]!==0||n[st]!==0)?it:n[at]<0||n[at]>59?at:n[ot]<0||n[ot]>59?ot:n[st]<0||n[st]>999?st:-1,h(e)._overflowDayOfYear&&(t<tt||t>rt)&&(t=rt),h(e)._overflowWeeks&&t===-1&&(t=ct),h(e)._overflowWeekday&&t===-1&&(t=lt),h(e).overflow=t),e}var Fn=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,In=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ln=/Z|[+-]\d\d(?::?\d\d)?/,Rn=[[`YYYYYY-MM-DD`,/[+-]\d{6}-\d\d-\d\d/],[`YYYY-MM-DD`,/\d{4}-\d\d-\d\d/],[`GGGG-[W]WW-E`,/\d{4}-W\d\d-\d/],[`GGGG-[W]WW`,/\d{4}-W\d\d/,!1],[`YYYY-DDD`,/\d{4}-\d{3}/],[`YYYY-MM`,/\d{4}-\d\d/,!1],[`YYYYYYMMDD`,/[+-]\d{10}/],[`YYYYMMDD`,/\d{8}/],[`GGGG[W]WWE`,/\d{4}W\d{3}/],[`GGGG[W]WW`,/\d{4}W\d{2}/,!1],[`YYYYDDD`,/\d{7}/],[`YYYYMM`,/\d{6}/,!1],[`YYYY`,/\d{4}/,!1]],zn=[[`HH:mm:ss.SSSS`,/\d\d:\d\d:\d\d\.\d+/],[`HH:mm:ss,SSSS`,/\d\d:\d\d:\d\d,\d+/],[`HH:mm:ss`,/\d\d:\d\d:\d\d/],[`HH:mm`,/\d\d:\d\d/],[`HHmmss.SSSS`,/\d\d\d\d\d\d\.\d+/],[`HHmmss,SSSS`,/\d\d\d\d\d\d,\d+/],[`HHmmss`,/\d\d\d\d\d\d/],[`HHmm`,/\d\d\d\d/],[`HH`,/\d\d/]],Bn=/^\/?Date\((-?\d+)/i,Vn=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,Hn={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Un(e){var t,n,r=e._i,i=Fn.exec(r)||In.exec(r),a,o,s,c,l=Rn.length,u=zn.length;if(i){for(h(e).iso=!0,t=0,n=l;t<n;t++)if(Rn[t][1].exec(i[1])){o=Rn[t][0],a=Rn[t][2]!==!1;break}if(o==null){e._isValid=!1;return}if(i[3]){for(t=0,n=u;t<n;t++)if(zn[t][1].exec(i[3])){s=(i[2]||` `)+zn[t][0];break}if(s==null){e._isValid=!1;return}}if(!a&&s!=null){e._isValid=!1;return}if(i[4])if(Ln.exec(i[4]))c=`Z`;else{e._isValid=!1;return}e._f=o+(s||``)+(c||``),tr(e)}else e._isValid=!1}function Wn(e,t,n,r,i,a){var o=[Gn(e),St.indexOf(t),parseInt(n,10),parseInt(r,10),parseInt(i,10)];return a&&o.push(parseInt(a,10)),o}function Gn(e){var t=parseInt(e,10);return t<=49?2e3+t:t<=999?1900+t:t}function Kn(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).replace(/^\s\s*/,``).replace(/\s\s*$/,``)}function qn(e,t,n){return e&&Yt.indexOf(e)!==new Date(t[0],t[1],t[2]).getDay()?(h(n).weekdayMismatch=!0,n._isValid=!1,!1):!0}function Jn(e,t,n){if(e)return Hn[e];if(t)return 0;var r=parseInt(n,10),i=r%100;return(r-i)/100*60+i}function Yn(e){var t=Vn.exec(Kn(e._i)),n;if(t){if(n=Wn(t[4],t[3],t[2],t[5],t[6],t[7]),!qn(t[1],n,e))return;e._a=n,e._tzm=Jn(t[8],t[9],t[10]),e._d=It.apply(null,e._a),e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),h(e).rfc2822=!0}else e._isValid=!1}function Xn(e){var t=Bn.exec(e._i);if(t!==null){e._d=new Date(+t[1]);return}if(Un(e),e._isValid===!1)delete e._isValid;else return;if(Yn(e),e._isValid===!1)delete e._isValid;else return;e._strict?e._isValid=!1:n.createFromInputFallback(e)}n.createFromInputFallback=T(`value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.`,function(e){e._d=new Date(e._i+(e._useUTC?` UTC`:``))});function Zn(e,t,n){return e??t??n}function Qn(e){var t=new Date(n.now());return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function $n(e){var t,n,r=[],i,a,o;if(!e._d){for(i=Qn(e),e._w&&e._a[rt]==null&&e._a[nt]==null&&er(e),e._dayOfYear!=null&&(o=Zn(e._a[tt],i[tt]),(e._dayOfYear>ut(o)||e._dayOfYear===0)&&(h(e)._overflowDayOfYear=!0),n=It(o,0,e._dayOfYear),e._a[nt]=n.getUTCMonth(),e._a[rt]=n.getUTCDate()),t=0;t<3&&e._a[t]==null;++t)e._a[t]=r[t]=i[t];for(;t<7;t++)e._a[t]=r[t]=e._a[t]==null?+(t===2):e._a[t];e._a[it]===24&&e._a[at]===0&&e._a[ot]===0&&e._a[st]===0&&(e._nextDay=!0,e._a[it]=0),e._d=(e._useUTC?It:Ft).apply(null,r),a=e._useUTC?e._d.getUTCDay():e._d.getDay(),e._tzm!=null&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[it]=24),e._w&&e._w.d!==void 0&&e._w.d!==a&&(h(e).weekdayMismatch=!0)}}function er(e){var t=e._w,n,r,i,a,o,s,c,l;t.GG!=null||t.W!=null||t.E!=null?(a=1,o=4,n=Zn(t.GG,e._a[tt],zt(lr(),1,4).year),r=Zn(t.W,1),i=Zn(t.E,1),(i<1||i>7)&&(c=!0)):(a=e._locale._week.dow,o=e._locale._week.doy,l=zt(lr(),a,o),n=Zn(t.gg,e._a[tt],l.year),r=Zn(t.w,l.week),t.d==null?t.e==null?i=a:(i=t.e+a,(t.e<0||t.e>6)&&(c=!0)):(i=t.d,(i<0||i>6)&&(c=!0))),r<1||r>Bt(n,a,o)?h(e)._overflowWeeks=!0:c==null?(s=Rt(n,r,i,a,o),e._a[tt]=s.year,e._dayOfYear=s.dayOfYear):h(e)._overflowWeekday=!0}n.ISO_8601=function(){},n.RFC_2822=function(){};function tr(e){if(e._f===n.ISO_8601){Un(e);return}if(e._f===n.RFC_2822){Yn(e);return}e._a=[],h(e).empty=!0;var t=``+e._i,r,i,a,o,s,c=t.length,l=0,u,d;for(a=le(e._f,e._locale).match(ne)||[],d=a.length,r=0;r<d;r++)o=a[r],i=(t.match(Ge(o,e))||[])[0],i&&(s=t.substr(0,t.indexOf(i)),s.length>0&&h(e).unusedInput.push(s),t=t.slice(t.indexOf(i)+i.length),l+=i.length),ae[o]?(i?h(e).empty=!1:h(e).unusedTokens.push(o),$e(o,i,e)):e._strict&&!i&&h(e).unusedTokens.push(o);h(e).charsLeftOver=c-l,t.length>0&&h(e).unusedInput.push(t),e._a[it]<=12&&h(e).bigHour===!0&&e._a[it]>0&&(h(e).bigHour=void 0),h(e).parsedDateParts=e._a.slice(0),h(e).meridiem=e._meridiem,e._a[it]=nr(e._locale,e._a[it],e._meridiem),u=h(e).era,u!==null&&(e._a[tt]=e._locale.erasConvertYear(u,e._a[tt])),$n(e),Pn(e)}function nr(e,t,n){var r;return n==null?t:e.meridiemHour==null?e.isPM==null?t:(r=e.isPM(n),r&&t<12&&(t+=12),!r&&t===12&&(t=0),t):e.meridiemHour(t,n)}function rr(e){var t,n,r,i,a,o,s=!1,c=e._f.length;if(c===0){h(e).invalidFormat=!0,e._d=new Date(NaN);return}for(i=0;i<c;i++)a=0,o=!1,t=x({},e),e._useUTC!=null&&(t._useUTC=e._useUTC),t._f=e._f[i],tr(t),_(t)&&(o=!0),a+=h(t).charsLeftOver,a+=h(t).unusedTokens.length*10,h(t).score=a,s?a<r&&(r=a,n=t):(r==null||a<r||o)&&(r=a,n=t,o&&(s=!0));f(e,n||t)}function ir(e){if(!e._d){var t=Se(e._i),n=t.day===void 0?t.date:t.day;e._a=d([t.year,t.month,n,t.hour,t.minute,t.second,t.millisecond],function(e){return e&&parseInt(e,10)}),$n(e)}}function ar(e){var t=new S(Pn(or(e)));return t._nextDay&&(t.add(1,`d`),t._nextDay=void 0),t}function or(e){var t=e._i,n=e._f;return e._locale=e._locale||Mn(e._l),t===null||n===void 0&&t===``?v({nullInput:!0}):(typeof t==`string`&&(e._i=t=e._locale.preparse(t)),C(t)?new S(Pn(t)):(u(t)?e._d=t:i(n)?rr(e):n?tr(e):sr(e),_(e)||(e._d=null),e))}function sr(e){var t=e._i;c(t)?e._d=new Date(n.now()):u(t)?e._d=new Date(t.valueOf()):typeof t==`string`?Xn(e):i(t)?(e._a=d(t.slice(0),function(e){return parseInt(e,10)}),$n(e)):a(t)?ir(e):l(t)?e._d=new Date(t):n.createFromInputFallback(e)}function cr(e,t,n,r,o){var c={};return(t===!0||t===!1)&&(r=t,t=void 0),(n===!0||n===!1)&&(r=n,n=void 0),(a(e)&&s(e)||i(e)&&e.length===0)&&(e=void 0),c._isAMomentObject=!0,c._useUTC=c._isUTC=o,c._l=n,c._i=e,c._f=t,c._strict=r,ar(c)}function lr(e,t,n,r){return cr(e,t,n,r,!1)}var ur=T(`moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/`,function(){var e=lr.apply(null,arguments);return this.isValid()&&e.isValid()?e<this?this:e:v()}),dr=T(`moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/`,function(){var e=lr.apply(null,arguments);return this.isValid()&&e.isValid()?e>this?this:e:v()});function fr(e,t){var n,r;if(t.length===1&&i(t[0])&&(t=t[0]),!t.length)return lr();for(n=t[0],r=1;r<t.length;++r)(!t[r].isValid()||t[r][e](n))&&(n=t[r]);return n}function pr(){return fr(`isBefore`,[].slice.call(arguments,0))}function mr(){return fr(`isAfter`,[].slice.call(arguments,0))}var hr=function(){return Date.now?Date.now():+new Date},gr=[`year`,`quarter`,`month`,`week`,`day`,`hour`,`minute`,`second`,`millisecond`];function _r(e){var t,n=!1,r,i=gr.length;for(t in e)if(o(e,t)&&!(yt.call(gr,t)!==-1&&(e[t]==null||!isNaN(e[t]))))return!1;for(r=0;r<i;++r)if(e[gr[r]]){if(n)return!1;parseFloat(e[gr[r]])!==Ye(e[gr[r]])&&(n=!0)}return!0}function vr(){return this._isValid}function yr(){return Vr(NaN)}function br(e){var t=Se(e),n=t.year||0,r=t.quarter||0,i=t.month||0,a=t.week||t.isoWeek||0,o=t.day||0,s=t.hour||0,c=t.minute||0,l=t.second||0,u=t.millisecond||0;this._isValid=_r(t),this._milliseconds=+u+l*1e3+c*6e4+s*1e3*60*60,this._days=+o+a*7,this._months=+i+r*3+n*12,this._data={},this._locale=Mn(),this._bubble()}function xr(e){return e instanceof br}function Sr(e){return e<0?Math.round(-1*e)*-1:Math.round(e)}function Cr(e,t,n){var r=Math.min(e.length,t.length),i=Math.abs(e.length-t.length),a=0,o;for(o=0;o<r;o++)(n&&e[o]!==t[o]||!n&&Ye(e[o])!==Ye(t[o]))&&a++;return a+i}function wr(e,t){P(e,0,0,function(){var e=this.utcOffset(),n=`+`;return e<0&&(e=-e,n=`-`),n+N(~~(e/60),2)+t+N(~~e%60,2)})}wr(`Z`,`:`),wr(`ZZ`,``),F(`Z`,ze),F(`ZZ`,ze),Ze([`Z`,`ZZ`],function(e,t,n){n._useUTC=!0,n._tzm=Er(ze,e)});var Tr=/([\+\-]|\d\d)/gi;function Er(e,t){var n=(t||``).match(e),r,i,a;return n===null?null:(r=n[n.length-1]||[],i=(r+``).match(Tr)||[`-`,0,0],a=+(i[1]*60)+Ye(i[2]),a===0?0:i[0]===`+`?a:-a)}function Dr(e,t){var r,i;return t._isUTC?(r=t.clone(),i=(C(e)||u(e)?e.valueOf():lr(e).valueOf())-r.valueOf(),r._d.setTime(r._d.valueOf()+i),n.updateOffset(r,!1),r):lr(e).local()}function B(e){return-Math.round(e._d.getTimezoneOffset())}n.updateOffset=function(){};function Or(e,t,r){var i=this._offset||0,a;if(!this.isValid())return e==null?NaN:this;if(e!=null){if(typeof e==`string`){if(e=Er(ze,e),e===null)return this}else Math.abs(e)<16&&!r&&(e*=60);return!this._isUTC&&t&&(a=B(this)),this._offset=e,this._isUTC=!0,a!=null&&this.add(a,`m`),i!==e&&(!t||this._changeInProgress?Kr(this,Vr(e-i,`m`),1,!1):this._changeInProgress||(this._changeInProgress=!0,n.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?i:B(this)}function kr(e,t){return e==null?-this.utcOffset():(typeof e!=`string`&&(e=-e),this.utcOffset(e,t),this)}function Ar(e){return this.utcOffset(0,e)}function jr(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e&&this.subtract(B(this),`m`)),this}function Mr(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i==`string`){var e=Er(Re,this._i);e==null?this.utcOffset(0,!0):this.utcOffset(e)}return this}function Nr(e){return this.isValid()?(e=e?lr(e).utcOffset():0,(this.utcOffset()-e)%60==0):!1}function Pr(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Fr(){if(!c(this._isDSTShifted))return this._isDSTShifted;var e={},t;return x(e,this),e=or(e),e._a?(t=e._isUTC?p(e._a):lr(e._a),this._isDSTShifted=this.isValid()&&Cr(e._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function Ir(){return this.isValid()?!this._isUTC:!1}function Lr(){return this.isValid()?this._isUTC:!1}function Rr(){return this.isValid()?this._isUTC&&this._offset===0:!1}var zr=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,Br=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Vr(e,t){var n=e,r=null,i,a,s;return xr(e)?n={ms:e._milliseconds,d:e._days,M:e._months}:l(e)||!isNaN(+e)?(n={},t?n[t]=+e:n.milliseconds=+e):(r=zr.exec(e))?(i=r[1]===`-`?-1:1,n={y:0,d:Ye(r[rt])*i,h:Ye(r[it])*i,m:Ye(r[at])*i,s:Ye(r[ot])*i,ms:Ye(Sr(r[st]*1e3))*i}):(r=Br.exec(e))?(i=r[1]===`-`?-1:1,n={y:Hr(r[2],i),M:Hr(r[3],i),w:Hr(r[4],i),d:Hr(r[5],i),h:Hr(r[6],i),m:Hr(r[7],i),s:Hr(r[8],i)}):n==null?n={}:typeof n==`object`&&(`from`in n||`to`in n)&&(s=Wr(lr(n.from),lr(n.to)),n={},n.ms=s.milliseconds,n.M=s.months),a=new br(n),xr(e)&&o(e,`_locale`)&&(a._locale=e._locale),xr(e)&&o(e,`_isValid`)&&(a._isValid=e._isValid),a}Vr.fn=br.prototype,Vr.invalid=yr;function Hr(e,t){var n=e&&parseFloat(e.replace(`,`,`.`));return(isNaN(n)?0:n)*t}function Ur(e,t){var n={};return n.months=t.month()-e.month()+(t.year()-e.year())*12,e.clone().add(n.months,`M`).isAfter(t)&&--n.months,n.milliseconds=t-+e.clone().add(n.months,`M`),n}function Wr(e,t){var n;return e.isValid()&&t.isValid()?(t=Dr(t,e),e.isBefore(t)?n=Ur(e,t):(n=Ur(t,e),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function Gr(e,t){return function(n,r){var i,a;return r!==null&&!isNaN(+r)&&(D(t,`moment().`+t+`(period, number) is deprecated. Please use moment().`+t+`(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.`),a=n,n=r,r=a),i=Vr(n,r),Kr(this,i,e),this}}function Kr(e,t,r,i){var a=t._milliseconds,o=Sr(t._days),s=Sr(t._months);e.isValid()&&(i=i??!0,s&&At(e,mt(e,`Month`)+s*r),o&&ht(e,`Date`,mt(e,`Date`)+o*r),a&&e._d.setTime(e._d.valueOf()+a*r),i&&n.updateOffset(e,o||s))}var qr=Gr(1,`add`),Jr=Gr(-1,`subtract`);function Yr(e){return typeof e==`string`||e instanceof String}function Xr(e){return C(e)||u(e)||Yr(e)||l(e)||Qr(e)||Zr(e)||e==null}function Zr(e){var t=a(e)&&!s(e),n=!1,r=[`years`,`year`,`y`,`months`,`month`,`M`,`days`,`day`,`d`,`dates`,`date`,`D`,`hours`,`hour`,`h`,`minutes`,`minute`,`m`,`seconds`,`second`,`s`,`milliseconds`,`millisecond`,`ms`],i,c,l=r.length;for(i=0;i<l;i+=1)c=r[i],n=n||o(e,c);return t&&n}function Qr(e){var t=i(e),n=!1;return t&&(n=e.filter(function(t){return!l(t)&&Yr(e)}).length===0),t&&n}function $r(e){var t=a(e)&&!s(e),n=!1,r=[`sameDay`,`nextDay`,`lastDay`,`nextWeek`,`lastWeek`,`sameElse`],i,c;for(i=0;i<r.length;i+=1)c=r[i],n=n||o(e,c);return t&&n}function ei(e,t){var n=e.diff(t,`days`,!0);return n<-6?`sameElse`:n<-1?`lastWeek`:n<0?`lastDay`:n<1?`sameDay`:n<2?`nextDay`:n<7?`nextWeek`:`sameElse`}function ti(e,t){arguments.length===1&&(arguments[0]?Xr(arguments[0])?(e=arguments[0],t=void 0):$r(arguments[0])&&(t=arguments[0],e=void 0):(e=void 0,t=void 0));var r=e||lr(),i=Dr(r,this).startOf(`day`),a=n.calendarFormat(this,i)||`sameElse`,o=t&&(O(t[a])?t[a].call(this,r):t[a]);return this.format(o||this.localeData().calendar(a,this,lr(r)))}function ni(){return new S(this)}function ri(e,t){var n=C(e)?e:lr(e);return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()>n.valueOf():n.valueOf()<this.clone().startOf(t).valueOf()):!1}function ii(e,t){var n=C(e)?e:lr(e);return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()<n.valueOf():this.clone().endOf(t).valueOf()<n.valueOf()):!1}function ai(e,t,n,r){var i=C(e)?e:lr(e),a=C(t)?t:lr(t);return this.isValid()&&i.isValid()&&a.isValid()?(r=r||`()`,(r[0]===`(`?this.isAfter(i,n):!this.isBefore(i,n))&&(r[1]===`)`?this.isBefore(a,n):!this.isAfter(a,n))):!1}function oi(e,t){var n=C(e)?e:lr(e),r;return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()===n.valueOf():(r=n.valueOf(),this.clone().startOf(t).valueOf()<=r&&r<=this.clone().endOf(t).valueOf())):!1}function si(e,t){return this.isSame(e,t)||this.isAfter(e,t)}function ci(e,t){return this.isSame(e,t)||this.isBefore(e,t)}function li(e,t,n){var r,i,a;if(!this.isValid()||(r=Dr(e,this),!r.isValid()))return NaN;switch(i=(r.utcOffset()-this.utcOffset())*6e4,t=xe(t),t){case`year`:a=ui(this,r)/12;break;case`month`:a=ui(this,r);break;case`quarter`:a=ui(this,r)/3;break;case`second`:a=(this-r)/1e3;break;case`minute`:a=(this-r)/6e4;break;case`hour`:a=(this-r)/36e5;break;case`day`:a=(this-r-i)/864e5;break;case`week`:a=(this-r-i)/6048e5;break;default:a=this-r}return n?a:Je(a)}function ui(e,t){if(e.date()<t.date())return-ui(t,e);var n=(t.year()-e.year())*12+(t.month()-e.month()),r=e.clone().add(n,`months`),i,a;return t-r<0?(i=e.clone().add(n-1,`months`),a=(t-r)/(r-i)):(i=e.clone().add(n+1,`months`),a=(t-r)/(i-r)),-(n+a)||0}n.defaultFormat=`YYYY-MM-DDTHH:mm:ssZ`,n.defaultFormatUtc=`YYYY-MM-DDTHH:mm:ss[Z]`;function di(){return this.clone().locale(`en`).format(`ddd MMM DD YYYY HH:mm:ss [GMT]ZZ`)}function fi(e){if(!this.isValid())return null;var t=e!==!0,n=t?this.clone().utc():this;return n.year()<0||n.year()>9999?ce(n,t?`YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYYYY-MM-DD[T]HH:mm:ss.SSSZ`):O(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace(`Z`,ce(n,`Z`)):ce(n,t?`YYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYY-MM-DD[T]HH:mm:ss.SSSZ`)}function pi(){if(!this.isValid())return`moment.invalid(/* `+this._i+` */)`;var e=`moment`,t=``,n,r,i,a;return this.isLocal()||(e=this.utcOffset()===0?`moment.utc`:`moment.parseZone`,t=`Z`),n=`[`+e+`("]`,r=0<=this.year()&&this.year()<=9999?`YYYY`:`YYYYYY`,i=`-MM-DD[T]HH:mm:ss.SSS`,a=t+`[")]`,this.format(n+r+i+a)}function mi(e){e||(e=this.isUtc()?n.defaultFormatUtc:n.defaultFormat);var t=ce(this,e);return this.localeData().postformat(t)}function hi(e,t){return this.isValid()&&(C(e)&&e.isValid()||lr(e).isValid())?Vr({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function gi(e){return this.from(lr(),e)}function _i(e,t){return this.isValid()&&(C(e)&&e.isValid()||lr(e).isValid())?Vr({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function vi(e){return this.to(lr(),e)}function yi(e){var t;return e===void 0?this._locale._abbr:(t=Mn(e),t!=null&&(this._locale=t),this)}var bi=T(`moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.`,function(e){return e===void 0?this.localeData():this.locale(e)});function xi(){return this._locale}var Si=1e3,Ci=60*Si,wi=60*Ci,Ti=146097*24*wi;function Ei(e,t){return(e%t+t)%t}function Di(e,t,n){return e<100&&e>=0?new Date(e+400,t,n)-Ti:new Date(e,t,n).valueOf()}function Oi(e,t,n){return e<100&&e>=0?Date.UTC(e+400,t,n)-Ti:Date.UTC(e,t,n)}function ki(e){var t,r;if(e=xe(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Oi:Di,e){case`year`:t=r(this.year(),0,1);break;case`quarter`:t=r(this.year(),this.month()-this.month()%3,1);break;case`month`:t=r(this.year(),this.month(),1);break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday());break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case`day`:case`date`:t=r(this.year(),this.month(),this.date());break;case`hour`:t=this._d.valueOf(),t-=Ei(t+(this._isUTC?0:this.utcOffset()*Ci),wi);break;case`minute`:t=this._d.valueOf(),t-=Ei(t,Ci);break;case`second`:t=this._d.valueOf(),t-=Ei(t,Si);break}return this._d.setTime(t),n.updateOffset(this,!0),this}function Ai(e){var t,r;if(e=xe(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Oi:Di,e){case`year`:t=r(this.year()+1,0,1)-1;break;case`quarter`:t=r(this.year(),this.month()-this.month()%3+3,1)-1;break;case`month`:t=r(this.year(),this.month()+1,1)-1;break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case`day`:case`date`:t=r(this.year(),this.month(),this.date()+1)-1;break;case`hour`:t=this._d.valueOf(),t+=wi-Ei(t+(this._isUTC?0:this.utcOffset()*Ci),wi)-1;break;case`minute`:t=this._d.valueOf(),t+=Ci-Ei(t,Ci)-1;break;case`second`:t=this._d.valueOf(),t+=Si-Ei(t,Si)-1;break}return this._d.setTime(t),n.updateOffset(this,!0),this}function ji(){return this._d.valueOf()-(this._offset||0)*6e4}function Mi(){return Math.floor(this.valueOf()/1e3)}function Ni(){return new Date(this.valueOf())}function Pi(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]}function Fi(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}}function Ii(){return this.isValid()?this.toISOString():null}function Li(){return _(this)}function Ri(){return f({},h(this))}function zi(){return h(this).overflow}function Bi(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}P(`N`,0,0,`eraAbbr`),P(`NN`,0,0,`eraAbbr`),P(`NNN`,0,0,`eraAbbr`),P(`NNNN`,0,0,`eraName`),P(`NNNNN`,0,0,`eraNarrow`),P(`y`,[`y`,1],`yo`,`eraYear`),P(`y`,[`yy`,2],0,`eraYear`),P(`y`,[`yyy`,3],0,`eraYear`),P(`y`,[`yyyy`,4],0,`eraYear`),F(`N`,Zi),F(`NN`,Zi),F(`NNN`,Zi),F(`NNNN`,Qi),F(`NNNNN`,$i),Ze([`N`,`NN`,`NNN`,`NNNN`,`NNNNN`],function(e,t,n,r){var i=n._locale.erasParse(e,r,n._strict);i?h(n).era=i:h(n).invalidEra=e}),F(`y`,Ie),F(`yy`,Ie),F(`yyy`,Ie),F(`yyyy`,Ie),F(`yo`,ea),Ze([`y`,`yy`,`yyy`,`yyyy`],tt),Ze([`yo`],function(e,t,n,r){var i;n._locale._eraYearOrdinalRegex&&(i=e.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?t[tt]=n._locale.eraYearOrdinalParse(e,i):t[tt]=parseInt(e,10)});function Vi(e,t){var r,i,a,o=this._eras||Mn(`en`)._eras;for(r=0,i=o.length;r<i;++r){switch(typeof o[r].since){case`string`:a=n(o[r].since).startOf(`day`),o[r].since=a.valueOf();break}switch(typeof o[r].until){case`undefined`:o[r].until=1/0;break;case`string`:a=n(o[r].until).startOf(`day`).valueOf(),o[r].until=a.valueOf();break}}return o}function Hi(e,t,n){var r,i,a=this.eras(),o,s,c;for(e=e.toUpperCase(),r=0,i=a.length;r<i;++r)if(o=a[r].name.toUpperCase(),s=a[r].abbr.toUpperCase(),c=a[r].narrow.toUpperCase(),n)switch(t){case`N`:case`NN`:case`NNN`:if(s===e)return a[r];break;case`NNNN`:if(o===e)return a[r];break;case`NNNNN`:if(c===e)return a[r];break}else if([o,s,c].indexOf(e)>=0)return a[r]}function Ui(e,t){var r=e.since<=e.until?1:-1;return t===void 0?n(e.since).year():n(e.since).year()+(t-e.offset)*r}function Wi(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].name;return``}function Gi(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].narrow;return``}function Ki(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].abbr;return``}function qi(){var e,t,r,i,a=this.localeData().eras();for(e=0,t=a.length;e<t;++e)if(r=a[e].since<=a[e].until?1:-1,i=this.clone().startOf(`day`).valueOf(),a[e].since<=i&&i<=a[e].until||a[e].until<=i&&i<=a[e].since)return(this.year()-n(a[e].since).year())*r+a[e].offset;return this.year()}function Ji(e){return o(this,`_erasNameRegex`)||ta.call(this),e?this._erasNameRegex:this._erasRegex}function Yi(e){return o(this,`_erasAbbrRegex`)||ta.call(this),e?this._erasAbbrRegex:this._erasRegex}function Xi(e){return o(this,`_erasNarrowRegex`)||ta.call(this),e?this._erasNarrowRegex:this._erasRegex}function Zi(e,t){return t.erasAbbrRegex(e)}function Qi(e,t){return t.erasNameRegex(e)}function $i(e,t){return t.erasNarrowRegex(e)}function ea(e,t){return t._eraYearOrdinalRegex||Ie}function ta(){var e=[],t=[],n=[],r=[],i,a,o,s,c,l=this.eras();for(i=0,a=l.length;i<a;++i)o=qe(l[i].name),s=qe(l[i].abbr),c=qe(l[i].narrow),t.push(o),e.push(s),n.push(c),r.push(o),r.push(s),r.push(c);this._erasRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._erasNameRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`),this._erasAbbrRegex=RegExp(`^(`+e.join(`|`)+`)`,`i`),this._erasNarrowRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`)}P(0,[`gg`,2],0,function(){return this.weekYear()%100}),P(0,[`GG`,2],0,function(){return this.isoWeekYear()%100});function na(e,t){P(0,[e,e.length],0,t)}na(`gggg`,`weekYear`),na(`ggggg`,`weekYear`),na(`GGGG`,`isoWeekYear`),na(`GGGGG`,`isoWeekYear`),F(`G`,Le),F(`g`,Le),F(`GG`,Ae,Ee),F(`gg`,Ae,Ee),F(`GGGG`,Pe,Oe),F(`gggg`,Pe,Oe),F(`GGGGG`,Fe,ke),F(`ggggg`,Fe,ke),Qe([`gggg`,`ggggg`,`GGGG`,`GGGGG`],function(e,t,n,r){t[r.substr(0,2)]=Ye(e)}),Qe([`gg`,`GG`],function(e,t,r,i){t[i]=n.parseTwoDigitYear(e)});function ra(e){return la.call(this,e,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function ia(e){return la.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)}function aa(){return Bt(this.year(),1,4)}function oa(){return Bt(this.isoWeekYear(),1,4)}function sa(){var e=this.localeData()._week;return Bt(this.year(),e.dow,e.doy)}function ca(){var e=this.localeData()._week;return Bt(this.weekYear(),e.dow,e.doy)}function la(e,t,n,r,i){var a;return e==null?zt(this,r,i).year:(a=Bt(e,r,i),t>a&&(t=a),ua.call(this,e,t,n,r,i))}function ua(e,t,n,r,i){var a=Rt(e,t,n,r,i),o=It(a.year,0,a.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}P(`Q`,0,`Qo`,`quarter`),F(`Q`,Te),Ze(`Q`,function(e,t){t[nt]=(Ye(e)-1)*3});function da(e){return e==null?Math.ceil((this.month()+1)/3):this.month((e-1)*3+this.month()%3)}P(`D`,[`DD`,2],`Do`,`date`),F(`D`,Ae,He),F(`DD`,Ae,Ee),F(`Do`,function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Ze([`D`,`DD`],rt),Ze(`Do`,function(e,t){t[rt]=Ye(e.match(Ae)[0])});var fa=pt(`Date`,!0);P(`DDD`,[`DDDD`,3],`DDDo`,`dayOfYear`),F(`DDD`,Ne),F(`DDDD`,De),Ze([`DDD`,`DDDD`],function(e,t,n){n._dayOfYear=Ye(e)});function pa(e){var t=Math.round((this.clone().startOf(`day`)-this.clone().startOf(`year`))/864e5)+1;return e==null?t:this.add(e-t,`d`)}P(`m`,[`mm`,2],0,`minute`),F(`m`,Ae,Ue),F(`mm`,Ae,Ee),Ze([`m`,`mm`],at);var ma=pt(`Minutes`,!1);P(`s`,[`ss`,2],0,`second`),F(`s`,Ae,Ue),F(`ss`,Ae,Ee),Ze([`s`,`ss`],ot);var ha=pt(`Seconds`,!1);P(`S`,0,0,function(){return~~(this.millisecond()/100)}),P(0,[`SS`,2],0,function(){return~~(this.millisecond()/10)}),P(0,[`SSS`,3],0,`millisecond`),P(0,[`SSSS`,4],0,function(){return this.millisecond()*10}),P(0,[`SSSSS`,5],0,function(){return this.millisecond()*100}),P(0,[`SSSSSS`,6],0,function(){return this.millisecond()*1e3}),P(0,[`SSSSSSS`,7],0,function(){return this.millisecond()*1e4}),P(0,[`SSSSSSSS`,8],0,function(){return this.millisecond()*1e5}),P(0,[`SSSSSSSSS`,9],0,function(){return this.millisecond()*1e6}),F(`S`,Ne,Te),F(`SS`,Ne,Ee),F(`SSS`,Ne,De);var ga,_a;for(ga=`SSSS`;ga.length<=9;ga+=`S`)F(ga,Ie);function va(e,t){t[st]=Ye((`0.`+e)*1e3)}for(ga=`S`;ga.length<=9;ga+=`S`)Ze(ga,va);_a=pt(`Milliseconds`,!1),P(`z`,0,0,`zoneAbbr`),P(`zz`,0,0,`zoneName`);function ya(){return this._isUTC?`UTC`:``}function ba(){return this._isUTC?`Coordinated Universal Time`:``}var V=S.prototype;V.add=qr,V.calendar=ti,V.clone=ni,V.diff=li,V.endOf=Ai,V.format=mi,V.from=hi,V.fromNow=gi,V.to=_i,V.toNow=vi,V.get=gt,V.invalidAt=zi,V.isAfter=ri,V.isBefore=ii,V.isBetween=ai,V.isSame=oi,V.isSameOrAfter=si,V.isSameOrBefore=ci,V.isValid=Li,V.lang=bi,V.locale=yi,V.localeData=xi,V.max=dr,V.min=ur,V.parsingFlags=Ri,V.set=_t,V.startOf=ki,V.subtract=Jr,V.toArray=Pi,V.toObject=Fi,V.toDate=Ni,V.toISOString=fi,V.inspect=pi,typeof Symbol<`u`&&Symbol.for!=null&&(V[Symbol.for(`nodejs.util.inspect.custom`)]=function(){return`Moment<`+this.format()+`>`}),V.toJSON=Ii,V.toString=di,V.unix=Mi,V.valueOf=ji,V.creationData=Bi,V.eraName=Wi,V.eraNarrow=Gi,V.eraAbbr=Ki,V.eraYear=qi,V.year=dt,V.isLeapYear=ft,V.weekYear=ra,V.isoWeekYear=ia,V.quarter=V.quarters=da,V.month=jt,V.daysInMonth=Mt,V.week=V.weeks=Gt,V.isoWeek=V.isoWeeks=L,V.weeksInYear=sa,V.weeksInWeekYear=ca,V.isoWeeksInYear=aa,V.isoWeeksInISOWeekYear=oa,V.date=fa,V.day=V.days=on,V.weekday=sn,V.isoWeekday=cn,V.dayOfYear=pa,V.hour=V.hours=yn,V.minute=V.minutes=ma,V.second=V.seconds=ha,V.millisecond=V.milliseconds=_a,V.utcOffset=Or,V.utc=Ar,V.local=jr,V.parseZone=Mr,V.hasAlignedHourOffset=Nr,V.isDST=Pr,V.isLocal=Ir,V.isUtcOffset=Lr,V.isUtc=Rr,V.isUTC=Rr,V.zoneAbbr=ya,V.zoneName=ba,V.dates=T(`dates accessor is deprecated. Use date instead.`,fa),V.months=T(`months accessor is deprecated. Use month instead`,jt),V.years=T(`years accessor is deprecated. Use year instead`,dt),V.zone=T(`moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/`,kr),V.isDSTShifted=T(`isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information`,Fr);function xa(e){return lr(e*1e3)}function Sa(){return lr.apply(null,arguments).parseZone()}function Ca(e){return e}var wa=j.prototype;wa.calendar=te,wa.longDateFormat=de,wa.invalidDate=pe,wa.ordinal=ge,wa.preparse=Ca,wa.postformat=Ca,wa.relativeTime=ve,wa.pastFuture=ye,wa.set=k,wa.eras=Vi,wa.erasParse=Hi,wa.erasConvertYear=Ui,wa.erasAbbrRegex=Yi,wa.erasNameRegex=Ji,wa.erasNarrowRegex=Xi,wa.months=Et,wa.monthsShort=Dt,wa.monthsParse=kt,wa.monthsRegex=I,wa.monthsShortRegex=Nt,wa.week=Vt,wa.firstDayOfYear=Wt,wa.firstDayOfWeek=Ut,wa.weekdays=en,wa.weekdaysMin=nn,wa.weekdaysShort=tn,wa.weekdaysParse=an,wa.weekdaysRegex=ln,wa.weekdaysShortRegex=un,wa.weekdaysMinRegex=dn,wa.isPM=_n,wa.meridiem=z;function Ta(e,t,n,r){var i=Mn(),a=p().set(r,t);return i[n](a,e)}function Ea(e,t,n){if(l(e)&&(t=e,e=void 0),e=e||``,t!=null)return Ta(e,t,n,`month`);var r,i=[];for(r=0;r<12;r++)i[r]=Ta(e,r,n,`month`);return i}function Da(e,t,n,r){typeof e==`boolean`?(l(t)&&(n=t,t=void 0),t=t||``):(t=e,n=t,e=!1,l(t)&&(n=t,t=void 0),t=t||``);var i=Mn(),a=e?i._week.dow:0,o,s=[];if(n!=null)return Ta(t,(n+a)%7,r,`day`);for(o=0;o<7;o++)s[o]=Ta(t,(o+a)%7,r,`day`);return s}function Oa(e,t){return Ea(e,t,`months`)}function ka(e,t){return Ea(e,t,`monthsShort`)}function Aa(e,t,n){return Da(e,t,n,`weekdays`)}function ja(e,t,n){return Da(e,t,n,`weekdaysShort`)}function Ma(e,t,n){return Da(e,t,n,`weekdaysMin`)}kn(`en`,{eras:[{since:`0001-01-01`,until:1/0,offset:1,name:`Anno Domini`,narrow:`AD`,abbr:`AD`},{since:`0000-12-31`,until:-1/0,offset:1,name:`Before Christ`,narrow:`BC`,abbr:`BC`}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10;return e+(Ye(e%100/10)===1?`th`:t===1?`st`:t===2?`nd`:t===3?`rd`:`th`)}}),n.lang=T(`moment.lang is deprecated. Use moment.locale instead.`,kn),n.langData=T(`moment.langData is deprecated. Use moment.localeData instead.`,Mn);var Na=Math.abs;function Pa(){var e=this._data;return this._milliseconds=Na(this._milliseconds),this._days=Na(this._days),this._months=Na(this._months),e.milliseconds=Na(e.milliseconds),e.seconds=Na(e.seconds),e.minutes=Na(e.minutes),e.hours=Na(e.hours),e.months=Na(e.months),e.years=Na(e.years),this}function Fa(e,t,n,r){var i=Vr(t,n);return e._milliseconds+=r*i._milliseconds,e._days+=r*i._days,e._months+=r*i._months,e._bubble()}function Ia(e,t){return Fa(this,e,t,1)}function La(e,t){return Fa(this,e,t,-1)}function Ra(e){return e<0?Math.floor(e):Math.ceil(e)}function za(){var e=this._milliseconds,t=this._days,n=this._months,r=this._data,i,a,o,s,c;return e>=0&&t>=0&&n>=0||e<=0&&t<=0&&n<=0||(e+=Ra(Va(n)+t)*864e5,t=0,n=0),r.milliseconds=e%1e3,i=Je(e/1e3),r.seconds=i%60,a=Je(i/60),r.minutes=a%60,o=Je(a/60),r.hours=o%24,t+=Je(o/24),c=Je(Ba(t)),n+=c,t-=Ra(Va(c)),s=Je(n/12),n%=12,r.days=t,r.months=n,r.years=s,this}function Ba(e){return e*4800/146097}function Va(e){return e*146097/4800}function Ha(e){if(!this.isValid())return NaN;var t,n,r=this._milliseconds;if(e=xe(e),e===`month`||e===`quarter`||e===`year`)switch(t=this._days+r/864e5,n=this._months+Ba(t),e){case`month`:return n;case`quarter`:return n/3;case`year`:return n/12}else switch(t=this._days+Math.round(Va(this._months)),e){case`week`:return t/7+r/6048e5;case`day`:return t+r/864e5;case`hour`:return t*24+r/36e5;case`minute`:return t*1440+r/6e4;case`second`:return t*86400+r/1e3;case`millisecond`:return Math.floor(t*864e5)+r;default:throw Error(`Unknown unit `+e)}}function Ua(e){return function(){return this.as(e)}}var Wa=Ua(`ms`),Ga=Ua(`s`),Ka=Ua(`m`),qa=Ua(`h`),Ja=Ua(`d`),Ya=Ua(`w`),Xa=Ua(`M`),Za=Ua(`Q`),Qa=Ua(`y`),$a=Wa;function eo(){return Vr(this)}function to(e){return e=xe(e),this.isValid()?this[e+`s`]():NaN}function no(e){return function(){return this.isValid()?this._data[e]:NaN}}var ro=no(`milliseconds`),io=no(`seconds`),ao=no(`minutes`),oo=no(`hours`),so=no(`days`),co=no(`months`),lo=no(`years`);function uo(){return Je(this.days()/7)}var fo=Math.round,po={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function mo(e,t,n,r,i){return i.relativeTime(t||1,!!n,e,r)}function ho(e,t,n,r){var i=Vr(e).abs(),a=fo(i.as(`s`)),o=fo(i.as(`m`)),s=fo(i.as(`h`)),c=fo(i.as(`d`)),l=fo(i.as(`M`)),u=fo(i.as(`w`)),d=fo(i.as(`y`)),f=a<=n.ss&&[`s`,a]||a<n.s&&[`ss`,a]||o<=1&&[`m`]||o<n.m&&[`mm`,o]||s<=1&&[`h`]||s<n.h&&[`hh`,s]||c<=1&&[`d`]||c<n.d&&[`dd`,c];return n.w!=null&&(f=f||u<=1&&[`w`]||u<n.w&&[`ww`,u]),f=f||l<=1&&[`M`]||l<n.M&&[`MM`,l]||d<=1&&[`y`]||[`yy`,d],f[2]=t,f[3]=+e>0,f[4]=r,mo.apply(null,f)}function go(e){return e===void 0?fo:typeof e==`function`?(fo=e,!0):!1}function _o(e,t){return po[e]===void 0?!1:t===void 0?po[e]:(po[e]=t,e===`s`&&(po.ss=t-1),!0)}function vo(e,t){if(!this.isValid())return this.localeData().invalidDate();var n=!1,r=po,i,a;return typeof e==`object`&&(t=e,e=!1),typeof e==`boolean`&&(n=e),typeof t==`object`&&(r=Object.assign({},po,t),t.s!=null&&t.ss==null&&(r.ss=t.s-1)),i=this.localeData(),a=ho(this,!n,r,i),n&&(a=i.pastFuture(+this,a)),i.postformat(a)}var yo=Math.abs;function bo(e){return(e>0)-(e<0)||+e}function xo(){if(!this.isValid())return this.localeData().invalidDate();var e=yo(this._milliseconds)/1e3,t=yo(this._days),n=yo(this._months),r,i,a,o,s=this.asSeconds(),c,l,u,d;return s?(r=Je(e/60),i=Je(r/60),e%=60,r%=60,a=Je(n/12),n%=12,o=e?e.toFixed(3).replace(/\.?0+$/,``):``,c=s<0?`-`:``,l=bo(this._months)===bo(s)?``:`-`,u=bo(this._days)===bo(s)?``:`-`,d=bo(this._milliseconds)===bo(s)?``:`-`,c+`P`+(a?l+a+`Y`:``)+(n?l+n+`M`:``)+(t?u+t+`D`:``)+(i||r||e?`T`:``)+(i?d+i+`H`:``)+(r?d+r+`M`:``)+(e?d+o+`S`:``)):`P0D`}var So=br.prototype;return So.isValid=vr,So.abs=Pa,So.add=Ia,So.subtract=La,So.as=Ha,So.asMilliseconds=Wa,So.asSeconds=Ga,So.asMinutes=Ka,So.asHours=qa,So.asDays=Ja,So.asWeeks=Ya,So.asMonths=Xa,So.asQuarters=Za,So.asYears=Qa,So.valueOf=$a,So._bubble=za,So.clone=eo,So.get=to,So.milliseconds=ro,So.seconds=io,So.minutes=ao,So.hours=oo,So.days=so,So.weeks=uo,So.months=co,So.years=lo,So.humanize=vo,So.toISOString=xo,So.toString=xo,So.toJSON=xo,So.locale=yi,So.localeData=xi,So.toIsoString=T(`toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)`,xo),So.lang=bi,P(`X`,0,0,`unix`),P(`x`,0,0,`valueOf`),F(`x`,Le),F(`X`,Be),Ze(`X`,function(e,t,n){n._d=new Date(parseFloat(e)*1e3)}),Ze(`x`,function(e,t,n){n._d=new Date(Ye(e))}),n.version=`2.30.1`,r(lr),n.fn=V,n.min=pr,n.max=mr,n.now=hr,n.utc=p,n.unix=xa,n.months=Oa,n.isDate=u,n.locale=kn,n.invalid=v,n.duration=Vr,n.isMoment=C,n.weekdays=Aa,n.parseZone=Sa,n.localeData=Mn,n.isDuration=xr,n.monthsShort=ka,n.weekdaysMin=Ma,n.defineLocale=An,n.updateLocale=jn,n.locales=Nn,n.weekdaysShort=ja,n.normalizeUnits=xe,n.relativeTimeRounding=go,n.relativeTimeThreshold=_o,n.calendarFormat=ei,n.prototype=V,n.HTML5_FMT={DATETIME_LOCAL:`YYYY-MM-DDTHH:mm`,DATETIME_LOCAL_SECONDS:`YYYY-MM-DDTHH:mm:ss`,DATETIME_LOCAL_MS:`YYYY-MM-DDTHH:mm:ss.SSS`,DATE:`YYYY-MM-DD`,TIME:`HH:mm`,TIME_SECONDS:`HH:mm:ss`,TIME_MS:`HH:mm:ss.SSS`,WEEK:`GGGG-[W]WW`,MONTH:`YYYY-MM`},n}))}))(),1);function GP({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)(Dr,{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)(B,{variant:`outline-primary`,size:`sm`,onClick:()=>u(e=>!e),"aria-label":`Toggle Details`,children:l?`Hide Details`:`Show Details`}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{o((0,p.jsx)(UP,{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)(LP,{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:(0,WP.default)(e.date_created).format(`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:(0,WP.default)(e.date_closed).format(`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:(0,WP.default)(e.forecast_up).format(`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===pt.DEFAULT&&`Issue`,e.issue_type===pt.ESCALATION&&`Escalation`,e.issue_type===pt.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:(0,WP.default)(e.last_update).format(`DD MMMM YYYY`)})]})]})]}),s&&a]})}function KP({reservations:e}){if(!e||e.length<1)return(0,p.jsx)(p.Fragment,{});let t=e[0];return(0,p.jsx)(xl,{placement:`top`,overlay:(0,p.jsxs)(hl,{id:`tooltip-${t.id}`,children:[(0,p.jsx)(`h5`,{children:t.title}),(0,p.jsx)(`p`,{children:e[0].active?`Currently active`:`Upcoming in: ${J(e[0].start).format(`DD MMMM YYYY`)}`}),(0,p.jsx)(`p`,{children:e[1]?`Next upcoming reservation in: ${J(e[1].start).format(`DD MMMM YYYY`)}`:`No next upcoming reservations`})]}),children:(0,p.jsxs)(Dr,{bg:e[0].active?`info`:`dark`,children:[`Reserved by: `,e[0].user.full_name]})})}function qP({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)(KP,{reservations:c.filter(e=>e.modules.some(e=>e.id===x.id))})]}),(0,p.jsxs)(_s,{as:Or,title:`Action`,id:`bg-nested-dropdown`,children:[(0,p.jsx)(hs.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)(hs.Item,{eventKey:`1`,onClick:()=>{u((0,p.jsx)(UP,{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)(Pl,{children:[x&&(0,p.jsx)(Zr,{xs:12,md:y.length>0?6:12,children:(0,p.jsx)(Hr,{className:`mb-3`,children:(0,p.jsxs)(Hr.Body,{children:[(0,p.jsxs)(Hr.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)(HP,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},t.id)),s!==1&&A(x.id).map(t=>(0,p.jsx)(GP,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},t.id))]})]})})}),y.length>0&&(0,p.jsx)(Zr,{xs:12,md:x?6:12,children:y.map(t=>(0,p.jsx)(Hr,{className:`mb-3`,children:(0,p.jsxs)(Hr.Body,{children:[(0,p.jsx)(Hr.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)(KP,{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)(HP,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},t.id)),s!==1&&A(t.id).map(t=>(0,p.jsx)(GP,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},t.id))]})]})},t.id))})]})}),_&&h,f&&l]})}var JP=({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)(``),_=()=>document.documentElement.getAttribute(`data-bs-theme`)===`dark`,v={control:e=>({...e,backgroundColor:_()?`#212529`:e.backgroundColor,borderColor:_()?`#495057`:e.borderColor,color:_()?`#fff`:e.color}),menu:e=>({...e,backgroundColor:_()?`#212529`:e.backgroundColor}),option:(e,t)=>({...e,backgroundColor:_()?t.isSelected?`#0d6efd`:t.isFocused?`#343a40`:`#212529`:e.backgroundColor,color:_()?`#fff`:e.color}),singleValue:e=>({...e,color:_()?`#fff`:e.color}),multiValue:e=>({...e,backgroundColor:_()?`#343a40`:e.backgroundColor}),multiValueLabel:e=>({...e,color:_()?`#fff`:e.color}),input:e=>({...e,color:_()?`#fff`:e.color})},{statusMail:y}=(0,d.useContext)(dy);(0,d.useEffect)(()=>{f.default.get(`/list/room`).then(e=>{l((e.data._embedded.items||[]).map(e=>({value:e,label:e.name})))}).catch(e=>{console.error(`Error fetching rooms:`,e),g(`Error fetching rooms:`+e)}),f.default.get(`/list/location/message/type`).then(e=>{let t=y.filter.messageType,r=(e.data._embedded.items||[]).filter(e=>t.includes(e.id.toString())).map(e=>({value:e,label:e.type}));m(r),a(`type`,n?.type||r[0].value)}).catch(e=>{console.error(`Error fetching message types:`,e),g(`Error fetching message types:`+e)})},[]);let b=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)(U,{show:e,size:`lg`,centered:!0,onHide:()=>t(n),children:(0,p.jsxs)(H,{onSubmit:i(async e=>{let r=b(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)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Edit status mail message`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Title`}),(0,p.jsx)(H.Control,{type:`text`,placeholder:`Enter the title`,...r(`title`)})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Message`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,placeholder:`Give the message`,...r(`description`)})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:s,...r(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Rooms`}),(0,p.jsx)(Eu,{name:`rooms`,control:s,render:({field:e})=>(0,p.jsx)(_v,{isMulti:!0,options:c,classNamePrefix:`react-select`,placeholder:`Select one or more rooms`,value:c.filter(t=>e.value?.some(e=>e.id===t.value.id)),onChange:t=>e.onChange(t.map(e=>e.value)),styles:v})})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Type`}),(0,p.jsx)(Eu,{name:`type`,control:s,render:({field:e})=>(0,p.jsx)(_v,{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:v})})]})]}),(0,p.jsxs)(U.Footer,{children:[h!=``&&(0,p.jsx)(`span`,{className:`text-danger`,children:h}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>t(n),children:`Cancel`}),(0,p.jsx)(B,{variant:`primary`,type:`submit`,children:n?`Update Message`:`Create Message`})]})]})})};function YP({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)(Dr,{bg:`dark`,children:a.type.type}),(0,p.jsx)(`h5`,{className:`mb-0`,children:a.title})]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{n((0,p.jsx)(JP,{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)(LP,{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: `,J(a.date_created).format(`DD MMM YYYY`)]}),a.last_update&&(0,p.jsxs)(`span`,{children:[`Updated: `,J(a.last_update).format(`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 XP({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)(B,{variant:`secondary`,onClick:()=>{r((0,p.jsx)(JP,{showModal:!0,onClose:e=>{a(!1),t()}})),a(!0)},children:`New message`})})]}),e.map((e,t)=>(0,p.jsx)(`div`,{children:(0,p.jsx)(YP,{message:e})},e.id)),i&&n]})}function ZP({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)(LP,{children:e.description})}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:J(e.forecast_up).format(`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)(UP,{equipment:r,showModal:!0,onClose:e=>{c(!1),e&&l(e)},issue:e,attachments:u()}))},children:`Edit`})})]},e.id),s&&a]})}function QP({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)(ZP,{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 $P({statusMail:e}){let[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(!1);return(0,p.jsx)(B,{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 eF(){let{statusMail:e}=(0,d.useContext)(dy),[t,n]=(0,d.useState)([]),r=(0,m.useQueryClient)(),i=(0,m.useQueries)({queries:[{queryKey:[`equipment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ee({statusMail:e})},{queryKey:[`module`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>oe({statusMail:e})},{queryKey:[`ecn`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ie({statusMail:e})},{queryKey:[`issue`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>P({statusMail:e})},{queryKey:[`messages`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ce({statusMail:e})},{queryKey:[`ecn`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>N({statusMail:e})},{queryKey:[`issue`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>re({statusMail:e})},{queryKey:[`reservation`,`active`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>se({which:`active`})},{queryKey:[`reservation`,`upcoming`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>se({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)($P,{statusMail:e})})]}),(0,p.jsx)(`p`,{children:e.subject}),v&&(0,p.jsx)(Er,{variant:`info`,children:`Loading status mail`}),y&&(0,p.jsx)(Er,{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)(QP,{issues:e,modules:s.data.items,issueAttachments:h.data.items,reloadQueryFn:a})]})})(),b&&u.data&&(0,p.jsx)(XP,{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===ht.ROOM?t.room.name.localeCompare(n.room.name):t.area&&n.area&&e.classification===ht.AREA?t.area.title.localeCompare(n.area.title):t.area&&n.area&&e.classification===ht.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===ht.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===ht.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===ht.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)(qP,{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 tF(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 nF(e,t){let n=tF(e);if(!n)return``;let r=e=>e.toString().padStart(2,`0`),i={YYYY:n.getFullYear().toString(),YY:n.getFullYear().toString().slice(-2),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=t;return Object.keys(i).sort((e,t)=>t.length-e.length).forEach(e=>{a=a.replace(new RegExp(e,`g`),i[e])}),a}function rF(e,t=`DD-MM-YY HH:mm`){return nF(e,t)}function iF({monitor:e}){let{environment:t}=(0,g.useParams)(),[n]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,e],queryFn:()=>me({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)(Hr,{className:`mb-2 me-2`,children:(0,p.jsxs)(Hr.Body,{className:r,children:[(0,p.jsx)(Hr.Title,{children:(0,p.jsx)(g.Link,{to:`/${t}/operator/monitor/`+e.id,children:e.name})}),(0,p.jsxs)(Hr.Text,{children:[n.title,n.latest_result&&(0,p.jsxs)(p.Fragment,{children:[`Latest measurement: `,rF(n.latest_result.date_created,`DD-MM-YY HH:mm`)]})]})]})},n.id)})}var aF=({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)};function u(){return(0,p.jsx)(Gl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Ul,{onClose:()=>a(!1),show:i,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Ul.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Assist logged`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Ul.Body,{children:`Assist was logged successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,size:t,onClick:()=>r(!0),children:`Log assist`}),(0,p.jsxs)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Log assist`})}),(0,p.jsx)(U.Body,{children:(0,p.jsx)(H,{children:(0,p.jsxs)(H.Group,{className:`mb-3`,controlId:`modal.ControlTextarea1`,children:[(0,p.jsx)(H.Label,{children:`Describe the assist`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,value:o,onChange:e=>l(e)})]})})}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:()=>c(),children:`Log assist`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{r(!1)},children:`Close`})]})]}),(0,p.jsx)(u,{})]})},oF=(0,d.createContext)({equipment:{},reloadEquipment:()=>{}});function sF({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)(Hr,{className:`my-2`,children:[(0,p.jsxs)(Hr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(Hr.Title,{children:[(0,p.jsx)(Dr,{bg:`dark`,children:`Issue`}),` `,c.issue]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(UP,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},issue:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(Hr.Text,{children:(0,p.jsx)(LP,{children:c.description})})]}),(0,p.jsxs)(ac,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(ac.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:rF(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(ac.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)(ac.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:[`(`,rF(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},c.module_id),o&&i]})}function cF({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)(Hr,{className:`my-2`,children:[(0,p.jsxs)(Hr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(Hr.Title,{children:[(0,p.jsx)(Dr,{bg:`dark`,children:`ECN`}),` `,e.ecn]}),(0,p.jsx)(B,{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)(Hr.Text,{children:(0,p.jsx)(LP,{children:e.description})})]}),(0,p.jsxs)(ac,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(ac.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:rF(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(ac.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)(ac.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:[`(`,rF(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},e.module_id),o&&i]})}function lF(){let{id:e}=(0,g.useParams)(),[t,n]=(0,d.useState)([]),r=(0,m.useQueries)({queries:[{queryKey:[`service`,`equipment`,e],queryFn:()=>Xe({equipmentId:Number(e)})}]}),[i]=r,a=r.some(e=>e.isLoading),o=r.some(e=>e.isError),s=r.every(e=>e.isSuccess);if((0,d.useEffect)(()=>{s&&n(i.data.items)},[s,i.data]),a)return(0,p.jsx)(`div`,{children:`Loading...`});if(o)return(0,p.jsx)(`div`,{children:`Error loading services.`});let c=e=>{if(e<60)return`${e} min`;let t=Math.floor(e/60),n=e%60;return`${t}h ${n>0?`${n}min`:``}`.trim()};return i.data.items.length===0?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsx)(Er,{variant:`info`,children:`No services found`})]}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsxs)(Il,{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:c(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 uF(){let{environment:e}=(0,g.useParams)(),{equipment:t}=(0,d.useContext)(oF),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:()=>Fe({firstUnfinishedStepEquipment:t,environment:e})},{queryKey:[`monitors`,t.name],queryFn:()=>he({equipment:t})},{queryKey:[`ecn`,t.name],queryFn:()=>ie({equipment:t})},{queryKey:[`issue`,t.name],queryFn:()=>P({equipment:t})},{queryKey:[`module`,t.name],queryFn:()=>oe({equipment:t})},{queryKey:[`ecn`,`attachment`,t.name],queryFn:()=>N({equipment:t})},{queryKey:[`issue`,`attachment`,t.name],queryFn:()=>re({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)(UP,{equipment:t,showModal:!0,onClose:()=>{o(!1),setTimeout(()=>{S([`issue`,t.name]),S([`issue`,`attachment`,t.name])},100)}})),o(!0)};return(0,p.jsxs)(Qr,{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)(iF,{monitor:e},e.id))}),(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{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)(Er,{variant:`info`,children:`No runs found`}),f.isFetched&&f.data&&f.data?.items.length>0&&(0,p.jsxs)(Il,{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)(lF,{})]}),(0,p.jsxs)(Zr,{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)(B,{variant:`primary`,size:`sm`,onClick:E,children:`New Issue`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:T,children:`New ECN`})}),(0,p.jsx)(`div`,{children:e.id===t.main_tool_module_id&&(0,p.jsx)(aF,{size:`sm`,moduleId:e.id})})]})}),C(e.id)?.map(e=>(0,p.jsx)(cF,{ecn:e,equipment:t,ecnAttachments:b.data?.items??[],reloadQueryFn:S},e.id)),w(e.id)?.map(e=>(0,p.jsx)(sF,{issue:e,equipment:t,issueAttachments:x.data?.items??[],reloadQueryFn:S},e.id))]})]},e.id))]})]}),l&&s,a&&r]})}var dF=()=>{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 fF({children:e}){let{equipment:t,reloadEquipment:n}=dF();return t===null?(0,p.jsx)(jt,{children:(0,p.jsx)(Et,{message:`Loading equipment...`})}):(0,p.jsx)(jt,{children:(0,p.jsx)(oF.Provider,{value:{equipment:t,reloadEquipment:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}function pF(){let{equipment:e}=(0,d.useContext)(oF),t=(0,m.useQueries)({queries:[{queryKey:[`activeReservationQuery`,e],queryFn:()=>se({equipment:e,which:`active`})},{queryKey:[`upcomingReservationQuery`,e],queryFn:()=>se({equipment:e,which:`upcoming`})},{queryKey:[`modules`,e],queryFn:()=>oe({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 `,rF(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`,{}),rF(e.start,`DD-MM-YY HH:mm`),(0,p.jsx)(`br`,{}),e.user.full_name]},e.id))]})]})}function mF(){return(0,p.jsxs)(fF,{children:[(0,p.jsx)(pF,{}),(0,p.jsx)(g.Outlet,{})]})}function hF({children:e}){let{id:t}=(0,g.useParams)(),n=(0,m.useQuery)({queryKey:[`statusMail`,t],queryFn:()=>j({id:parseInt(t)}),enabled:!!t});return n.isLoading||n.isFetching?(0,p.jsx)(jt,{children:(0,p.jsx)(Et,{message:`Loading status mail...`})}):(0,p.jsx)(jt,{children:(0,p.jsx)(dy.Provider,{value:{statusMail:n.data},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}var gF=()=>St(),_F,vF;function yF(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){i(Error(`[ScriptLoadingError] document not defined when attempting to load ${e}`));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),i(Error(`[ScriptLoadingError] Failed to load script: ${e}`))}),t||document.head.append(n)},[]),{isLoading:t,error:r,isSuccess:a}}var bF=e=>e&&e.charts,xF=(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)},SF=e=>window.google;function CF(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}=yF(e.chartLoaderScriptUrl||`https://www.gstatic.com/charts/loader.js`);return(0,d.useEffect)(()=>{if(!m)return;let a=SF();if(!bF(a)){c(Error(`[ScriptInitializationError] Script loaded but Google not attached to window.`));return}if(xF(e,a)){o(a);return}a.charts.load(t,{packages:n,language:r,mapsApiKey:i}),a.charts.setOnLoadCallback(()=>{if(!xF(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 wF={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:`https://www.gstatic.com/charts/loader.js`},TF=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}):!0}).map(e=>{let{control:t}=e;return d.default.createElement(`div`,{key:t.getContainerId(),id:t.getContainerId()})}))},EF=0,DF=()=>(EF+=1,`reactgooglegraph-${EF}`),OF=class{};_F=OF,At(OF,`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)}}),At(OF,`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})})})})}),At(OF,`createControlId`,e=>{let t;return t=e===void 0?`googlechart-control-${DF()}`:e,t}),At(OF,`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=_F.createControlId(r);return{controlProp:e,control:new n.visualization.ControlWrapper({containerId:s,controlType:i,options:a,...o})}}):null}),At(OF,`addControls`,e=>{let{chartWrapper:t,chartDashboard:n}=e,r=_F.createChartControls(e);return!r||!n||!t?null:(n.bind(r.map(e=>{let{control:t}=e;return t}),t),_F.initializeControls(r),r)});var kF=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]},AF=(e,t)=>{d.useEffect(()=>{let n=OF.listenToControlEvents(e??[],t);return()=>{n.forEach(e=>{t.google.visualization.events.removeListener(e)})}},[e,t])},jF=e=>{let[t,n]=kF(e.controls);return AF(t??[],e),{addControls:e=>{n(OF.addControls(e)?.map(e=>e.control)??null)},renderControl:n=>{let{chartWrapper:r,chartDashboard:i}=e;return d.createElement(TF,{...e,isReady:!!(r&&i),chartControls:t,filter:n})}}},MF=e=>{let t=d.useRef(null);return{chartId:(()=>{let{graphID:n,graph_id:r}=e,i=n||r,a;return a=i||t.current||DF(),t.current=a,t.current})()}},NF=[`#3366CC`,`#DC3912`,`#FF9900`,`#109618`,`#990099`,`#3B3EAC`,`#0099C6`,`#DD4477`,`#66AA00`,`#B82E2E`,`#316395`,`#994499`,`#22AA99`,`#AAAA11`,`#6633CC`,`#E67300`,`#8B0707`,`#329262`,`#5574A6`,`#3B3EAC`],PF=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())})})},FF=`#CCCCCC`,IF=class{};vF=IF,At(IF,`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=vF.getColumnId(i,n+1);return t.includes(a)?FF:r&&r.colors?r.colors[n]:NF[n]});n.setOptions({...r,colors:o}),n.draw()}),At(IF,`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=vF.getColumnId(t,i);n?.includes(o)?r(e=>[...e.filter(e=>e!==o)]):r(e=>[...e,o])})}),At(IF,`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 PF(f,c,l):f.visualization.arrayToDataTable([]);let v=g.getNumberOfColumns(),y=Array(v).fill(0).map((e,t)=>{let n=vF.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&&(vF.applyFormatters({dataTable:g,formatters:s,google:f}),d.setDataTable(g),d.draw()),(m===!0||h===!0)&&vF.grayOutHiddenColumnsLabel(e,p)}),At(IF,`getColumnId`,(e,t)=>e.getColumnId(t)||e.getColumnLabel(t)),At(IF,`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 LF=e=>{let{google:t,googleChartWrapper:n,googleChartDashboard:r}=e,[i,a]=d.useState([]);d.useEffect(()=>{n&&IF.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(IF.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t}),window.addEventListener(`resize`,o),l||c){let t=IF.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])},RF=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})})})}},zF=e=>{(0,d.useEffect)(()=>{if(!e.googleChartWrapper)return;let t=RF(e);return()=>{t?.forEach(t=>{e.google.visualization.events.removeListener(t)})}},[e])},BF=e=>{let[t,n]=d.useState(null),[r,i]=d.useState(null),{addControls:a,renderControl:o}=jF({...e,chartDashboard:r,chartWrapper:t});zF({...e,googleChartWrapper:t});let{chartId:s}=MF(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:_})},[]),LF({...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())},VF=d.createContext(wF),HF=e=>{let{children:t,value:n}=e;return d.createElement(VF.Provider,{value:n},t)},UF=e=>{let{google:t,isLoading:n,error:r}=CF(e);return n?e.loader??null:r?e.errorElement??null:t?d.default.createElement(BF,{google:t,...e}):null},WF=e=>{let t={...wF,...e};return d.default.createElement(HF,{value:t},d.default.createElement(UF,t))},GF;(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`})(GF||(GF={}));function KF({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=>{t.values.filter(t=>t.logging_parameter.id===e.logging_parameter.id).filter(e=>e.float_value!==0).forEach(n=>{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)(WF,{chartType:`ScatterChart`,width:`100%`,height:`400px`,data:r,options:n})}var qF=({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)(Al.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)(B,{size:`sm`,onClick:()=>t(e=>Math.max(e-1,0)),disabled:e.currentPage===1,children:`Previous Page`})}),(0,p.jsx)(Al,{size:`sm`,children:a.map((e,t)=>(0,p.jsx)(`div`,{children:e},t))}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{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)(H.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`})]})})]})},JF=new Date().toISOString().split(`T`)[0],YF=({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:JF}}),{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()}function C(){return(0,p.jsx)(Gl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Ul,{onClose:()=>o(!1),show:a,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Ul.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Ul.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,onClick:()=>i(!0),children:`Add manual result`}),(0,p.jsx)(U,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(H,{onSubmit:m(e=>S(e)),validated:s,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add manual result`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`date`,placeholder:`Date`,required:!0,...u(`date`,{required:`This field is required`})},`date`),_.date&&(0,p.jsx)(H.Control.Feedback,{children:_.date.message})]}),y.map((e,t)=>(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:e.label}),(0,p.jsxs)(Hs,{hasValidation:!0,children:[(0,p.jsx)(H.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)(H.Control.Feedback,{children:_.results[t].value.message})]})]},e.id))]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{h(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(C,{})]})},XF=({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=await _e({result:t}),r=await be({requirement:e}),i=await ae({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(),_()}function S(){return(0,p.jsx)(Gl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Ul,{onClose:()=>o(!1),show:a,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Ul.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Ul.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:()=>i(!0),children:`+`}),(0,p.jsx)(U,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(H,{onSubmit:g(e=>x(e)),validated:s,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add process parameter`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`text`,value:t.date_created,readOnly:!0})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module Step Parameter`}),(0,p.jsxs)(H.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)(H.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)(Hs,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,required:!0,...h(`value`,{required:`This field is required`})}),y?.value&&(0,p.jsx)(H.Control.Feedback,{children:y.value.message})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{_(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(S,{})]})},ZF=({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()}function b(){return(0,p.jsx)(Gl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Ul,{onClose:()=>a(!1),show:i,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Ul.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Ul.Body,{children:`Measurement results were saved successfully`})]})})}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)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:(0,p.jsxs)(H,{onSubmit:u(e=>v(e)),validated:o,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add process parameter`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`text`,value:e.date_created,readOnly:!0})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module Step Parameter`}),(0,p.jsx)(H.Control,{type:`text`,value:e.step_parameter.parameter.name,readOnly:!0})]}),(0,p.jsxs)(Hs,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,required:!0,...l(`value`,{required:`This field is required`})}),g?.value&&(0,p.jsx)(H.Control.Feedback,{children:g.value.message})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Update value`}),(0,p.jsx)(B,{className:`float-end`,variant:`danger`,onClick:()=>y(),children:`Delete value`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{m(),r(!1)},children:`Close`})]})]})}),(0,p.jsx)(b,{})]})};function QF({requirement:e}){let[t,n]=(0,d.useState)([]),[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(1),[s,c]=(0,d.useState)(15),[l,u]=(0,d.useState)([]),[h,g,_,v]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`files`,e.step,11],queryFn:()=>ye({step:e.step,pageSize:11,order:`date-created`,direction:`desc`})},{queryKey:[`requirement`,`target`,e],queryFn:()=>ve({requirement:e})},{queryKey:[`requirement`,`results`,e,a,s],queryFn:()=>ge({requirement:e,pageSize:s,order:`date-created`,direction:`desc`,page:a}),placeholderData:m.keepPreviousData},{queryKey:[`requirement`,`monitor_step_parameters`,e,a,s],queryFn:()=>_e({requirement:e,pageSize:s,order:`date-created`,direction:`desc`,page:a}),placeholderData:m.keepPreviousData}]});(0,d.useEffect)(()=>{n([]),!h.isLoading&&h.data.items.forEach(e=>{n(t=>[...t,e])})},[h.isLoading]),(0,d.useEffect)(()=>{v.data&&u(Array.from(new Map(v.data.items.map(e=>[e.step_parameter.id,e.step_parameter])).values()))},[v.isLoading,v.data]);let{getRootProps:y,getInputProps:b,isDragActive:x,isDragAccept:S,isDragReject:C}=Ub({onDrop:(0,d.useCallback)(t=>{t.forEach(t=>{let n=new FileReader;n.onload=async()=>{let r=n.result;try{await f.default.create().post(`update/monitor/requirement/upload-file/`+e.id,{content:r,filename:t.name,type:t.type})}catch(e){i(`Upload failed due to: `+e.response.data.detail)}await h.refetch(),await _.refetch()},n.readAsDataURL(t)})},[e.id,h,_])}),w=(0,d.useMemo)(()=>({...x?{borderColor:`#83afee`}:{},...S?{borderColor:`#00e676`}:{},...C?{borderColor:`#ff1744`}:{}}),[S,C,x]);return g.isLoading||g.isFetching?(0,p.jsx)(Er,{variant:`info`,children:`Loading targets...`}):_.isLoading||_.isFetching?(0,p.jsx)(Er,{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)(Pl,{className:`my-3`,children:(0,p.jsxs)(Zr,{children:[(0,p.jsx)(`h2`,{children:`Charts`}),(0,p.jsx)(`div`,{className:`d-flex`,children:g.data?.items.map(e=>(0,p.jsx)(KF,{target:e,results:_.data.items},e.id))})]})}),(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{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})]}),g.data?.items.length===0&&(0,p.jsx)(Er,{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)(YF,{requirement:e,targets:g.data.items,refetchResults:_.refetch})})]}),(0,p.jsxs)(Il,{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`}),g.data?.items.map(e=>(0,p.jsx)(`th`,{children:e.logging_parameter.name},e.id)),l.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}),g.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)),l.map(e=>(0,p.jsx)(`th`,{className:`table-secondary`},e.id)),(0,p.jsx)(`th`,{})]})]}),(0,p.jsx)(`tbody`,{children:_.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:rF(t.date_created,`DD-MM-YY HH:mm`)}),g.data?.items.map(e=>(0,p.jsx)(`td`,{children:t.values.filter(t=>t.logging_parameter.id===e.logging_parameter.id).map(e=>(0,p.jsx)(`span`,{className:e.value_is_valid?`text-success`:`text-danger`,children:e.float_value},`${e.logging_parameter.id}-${e.float_value}`))},e.id)),l.map(e=>(0,p.jsx)(`td`,{className:`table-secondary`,children:v.data?.items.filter(n=>n.step_parameter.id===e.id&&n.result.id===t.id).map(e=>(0,p.jsx)(ZF,{monitorResultStepParameterValue:e,refetchMonitorStepParameterValues:v.refetch},e.id))},e.id)),(0,p.jsx)(`td`,{children:(0,p.jsx)(XF,{result:t,requirement:e,refetchMonitorStepParameterValues:v.refetch})})]},t.id))})]}),(0,p.jsx)(qF,{data:_.data,setPage:o,setPageSize:c,pageSize:s,isPlaceholderData:_.isPlaceholderData})]}),(0,p.jsxs)(Zr,{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`,{...y({style:w,className:`dropzone`}),children:[(0,p.jsx)(`input`,{...b()}),x?(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:r})]}),t.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:t.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:gF()+e.url,children:e.name}),e.has_monitor_step_loggings&&(0,p.jsx)(Dr,{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:rF(e.date_created,`DD-MM-YY HH:mm`)})]},e.url))})]})]})]})]})}function $F(){let{id:e}=(0,g.useParams)(),[t,n]=(0,m.useQueries)({queries:[{queryKey:[`monitor`,e],queryFn:()=>pe({id:parseInt(e)})},{queryKey:[`requirements`,e],queryFn:()=>me({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)(QF,{requirement:e})},t))]})}function eI(){return(0,p.jsx)(Qr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}var tI=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&pe({id:parseInt(n)}).then(t)},[n,e]);function r(){pe({id:parseInt(n)}).then(t)}return{monitor:e,setMonitor:t,reloadMonitor:r}},nI=(0,d.createContext)({monitor:{},reloadMonitor:()=>{}});function rI({children:e}){let{monitor:t,reloadMonitor:n}=tI();return t===null?(0,p.jsx)(jt,{children:(0,p.jsx)(Et,{message:`Loading monitor...`})}):(0,p.jsx)(jt,{children:(0,p.jsx)(nI.Provider,{value:{monitor:t,reloadMonitor:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}var iI=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||n!==e.id.toString())&&Oe({id:parseInt(n)}).then(t)},[n,e]);function r(){Oe({id:parseInt(n)}).then(t)}return{run:e,reloadRun:r}},aI=(0,d.createContext)({run:{},reloadRun:()=>{}});function oI({children:e}){let{run:t,reloadRun:n}=iI();return t===null?(0,p.jsx)(Et,{message:`Loading run...`}):(0,p.jsx)(jt,{children:(0,p.jsx)(aI.Provider,{value:{run:t,reloadRun:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading rest of run...`}),children:e})})})}function sI({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 cI=({children:e,format:t=`d-M-Y`})=>(0,p.jsx)(p.Fragment,{children:J(Date.parse(e)).format(t)}),lI=({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),n((await f.default.get(`view/run/`+e.id)).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)(H,{onSubmit:o(m),className:`mb-3`,children:[(0,p.jsxs)(Hs,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:6,...a(`content`,{required:!0}),isInvalid:u.content!==void 0}),u.content&&(0,p.jsx)(H.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)(B,{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)(B,{variant:`secondary`,onClick:()=>i(!1),children:`Cancel`})]}),t&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`outline-danger`,className:`text-nowrap`,onClick:h,children:`Delete batch card`})})]})]}):t?t&&(0,p.jsxs)(Hr,{className:`rounded my-4 shadow-sm border-0`,children:[(0,p.jsxs)(Hr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-start justify-content-between gap-3`,children:[(0,p.jsx)(Hr.Title,{className:`text-danger mb-0`,children:`Batch card`}),(0,p.jsx)(B,{variant:`outline-primary`,size:`sm`,className:`text-nowrap`,onClick:()=>i(!0),children:`Update batch card`})]}),(0,p.jsx)(Hr.Text,{className:`mt-3 mb-2 fs-5 text-body`,children:t&&(0,p.jsx)(sI,{text:t.content})})]}),(0,p.jsx)(Hr.Footer,{className:`bg-transparent border-0 pt-0 pb-3`,children:(0,p.jsxs)(`div`,{className:`text-muted small`,children:[`Created `,(0,p.jsx)(cI,{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)(cI,{format:`DD-MM-YY H:m`,children:t.last_update}),`)`]})]})})]}):(0,p.jsx)(B,{variant:`outline-primary`,className:`mb-4`,onClick:()=>i(!0),children:`Create Batch Card`})};function uI(){let{run:e}=(0,d.useContext)(aI);return(0,p.jsxs)(p.Fragment,{children:[e.run_type===gt.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),e.run_type===gt.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)(lI,{run:e})]})}function dI(e){let{run:t,reloadRun:n}=(0,d.useContext)(aI),{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)(nl,{variant:`tabs`,className:e.className,defaultActiveKey:`/home`,activeKey:i,children:a.map(e=>(0,p.jsx)(nl.Item,{children:(0,p.jsx)(g.Link,{to:e.link,className:`nav-link `+(e.link===i?`active`:``),children:e.title})},e.link))})}function fI(){return(0,p.jsx)(oI,{children:(0,p.jsxs)(Qr,{fluid:!0,children:[(0,p.jsx)(uI,{}),(0,p.jsx)(dI,{className:`mb-4`}),(0,p.jsx)(g.Outlet,{})]})})}var pI=(0,d.createContext)({showOnlyEmphasizedParameters:!1,setShowOnlyEmphasizedParameters:()=>{}}),mI=({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`})})]})]})},hI=({runStep:e,showOnlyEmphasizedParameters:t,editableParameters:n=!0,refetchFn:r})=>{let{data:i,isLoading:a}=(0,m.useQuery)({queryKey:[`runStepParameters`,e.id],queryFn:()=>Ve({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)(Il,{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)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:3})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:7})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:4})})})]},t))})]}):c.length===0?(0,p.jsx)(Er,{variant:`info`,children:`No parameters found`}):(0,p.jsxs)(Il,{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)(mI,{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.`})})})]})},gI=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 _I({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:()=>Be({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}=Ub({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)(Il,{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:`${gF()}${e.url}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(Dr,{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))}}),` `,gI(e.size)]}),(0,p.jsx)(`td`,{children:rF(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)(ac,{className:`mt-3`,children:n.map(e=>(0,p.jsx)(ac.Item,{children:e.name},e.name))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(B,{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 vI=({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)(H,{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)(H.Group,{className:`mb-3`,controlId:`formBasicEmail`,children:(0,p.jsx)(H.Control,{as:`textarea`,...s(`comment`)})}),(0,p.jsx)(B,{size:`sm`,type:`submit`,disabled:m,children:`Save`}),(0,p.jsx)(B,{variant:`warning`,size:`sm`,className:`ms-2`,onClick:()=>i(!1),children:`Cancel`})]}):a===null?(0,p.jsx)(B,{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)(B,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Edit`})]}):(0,p.jsx)(`div`,{children:a})},yI=({runStepPart:e,setRunStepPartAction:t,createRunStepPart:n})=>(0,p.jsxs)(hs,{align:`end`,children:[(0,p.jsx)(hs.Toggle,{size:`sm`,variant:`outline-secondary`,children:`Actions`}),(0,p.jsxs)(hs.Menu,{children:[e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(hs.Item,{onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n)),(0,p.jsx)(hs.Item,{onClick:()=>n(),children:`Init`})]})]}),bI={[Ge.START]:`btn-start`,[Ge.FINISH]:`btn-success`,[Ge.FAIL]:`btn-failed`,[Ge.REWORK]:`btn-rework`,[Ge.SET_REPAIR]:`btn-repair`,[Ge.CLEAR_REPAIR]:`btn-secondary`,[Ge.SET_TESTING]:`btn-test`,[Ge.CLEAR_TESTING]:`btn-secondary`},xI=({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 ${bI[n]}`,onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n))}),SI=(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}},CI=(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),wI=e=>e?Array.isArray(e.pages)?e.pages.flatMap(e=>Array.isArray(e?.items)?e.items:[]):Array.isArray(e.items)?e.items:[]:[],TI=(e,t)=>{let{runStepPart:n,latestAction:r}=t;return CI(e,e=>e.map(e=>e.id===n.id?SI(e,r):e))},EI=(e,t)=>CI(e,e=>e.map(e=>t.get(e.id)??e)),DI=e=>Array.isArray(e)?e:Array.isArray(e.items)?e.items:[],OI=(e,t)=>{let n=DI(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 CI(e,e=>e.map(e=>{let t=r.get(e.id)??i.get(e.part_id);return t?SI(e,t):e}))},kI=(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},AI=(e,t,n,r={},i=new Map)=>{if(!e)return e;let a=e=>e.id===n.id?n:r.updateSubsequent&&kI(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 CI(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},jI=e=>{let t=new Map;return e.getQueriesData({queryKey:[`runSteps`]}).forEach(([,e])=>{wI(e).forEach(e=>{t.set(e.id,e)})}),t},MI=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 He({runPart:n}),i=new Map(r.items.map(e=>[e.id,e]));i.size!==0&&e.setQueriesData({queryKey:[`runStepParts`]},e=>EI(e,i))},NI=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=>ke({id:e}))),i=new Map(r.map(e=>[e.id,e]));e.setQueriesData({queryKey:[`runSteps`]},e=>CI(e,e=>e.map(e=>i.get(e.id)??e)))},PI=(e,t)=>{e.setQueriesData({queryKey:[`runStepParts`]},e=>TI(e,t)),MI(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step part cache from run part.`,e)}),NI(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step cache from run step part.`,e)})},FI=(e,t)=>{PI(e,t)},II=(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=>OI(e,n.latestActions)),MI(e,DI(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)}),NI(e,[{step_id:t.id}]).catch(e=>{console.error(`Failed to refresh run step cache from run step.`,e)});return}PI(e,n)},LI=(e,t,n,r={})=>{let i=r.updateSubsequent?jI(e):new Map;e.setQueriesData({queryKey:[`runStepParts`]},e=>AI(e,t,n,r,i))};function RI(e){return!0}var zI=e=>!!e.closest(`button, a, input, textarea, select, option, label`),BI=({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)(()=>{c(r.find(t=>t.part_id===e.id))},[r,e.id]);let u=t=>{if(!n)return;let r=t.target;if(zI(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),LI(l,a,t)})},g=async({runStepPart:e,runStepPartAction:t})=>{let n=await We({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}}),II(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&&RI(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})]})}),RI(a)&&(0,p.jsx)(`td`,{children:o?(0,p.jsx)(yI,{runStepPart:s,setRunStepPartAction:g,createRunStepPart:h}):(0,p.jsx)(xI,{runStepPart:s,setRunStepPartAction:g})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(vI,{runStepPart:s,setRunStepPart:c})})]}):null},VI=(0,d.createContext)(null),HI=()=>{let e=(0,d.useContext)(VI);if(e===null)throw Error(`useScannerContext must be used within a ScannerProvider`);return e},UI=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 WI(e){return e.startsWith(`_qr`)?1:e.toUpperCase().includes(`RESET-FORM`)?2:0}function GI({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}=HI(),s=(0,d.useId)(),c=(0,d.useRef)(new Set),l=(0,d.useCallback)(t=>{if(WI(t)!=UI.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(UI.WILD_CARD,s),l(i),a(UI.WILD_CARD,s,l),()=>{o(UI.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 KI=null;function qI(e){if(!KI){console.warn(`notification() called before NotificationProvider is mounted`);return}KI(e)}function JI({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)(()=>(KI=i,()=>{KI=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)(Gl,{containerPosition:`fixed`,position:`top-end`,children:t.map(({id:e,notificationHeader:t,notificationBody:n,notificationType:r})=>(0,p.jsxs)(Ul,{show:!0,delay:3e3+(r==`danger`?150:0),autohide:!0,bg:r,onClose:()=>a(e),className:`m-5`,children:[(0,p.jsx)(Ul.Header,{children:(0,p.jsx)(`span`,{className:`me-auto`,children:t})}),(0,p.jsx)(Ul.Body,{children:n})]},e))})]})}var YI=e=>`step_id`in e&&`part_id`in e;function XI({runStep:e,parts:t,selectedParts:n,getRunPart:r,getRunStepPart:i,actionsFromScanner:a=!0}){let o=(0,m.useQueryClient)(),{addCallbackFn:s,removeCallbackFn:c}=HI(),l=(0,d.useId)(),u=(0,d.useCallback)(()=>t.length===0?[]:YI(t[0])?t.filter(e=>{let t=r?r(e):e.part_id;return n.get(t)}):t.filter(e=>n.get(e.id)).map(e=>i?i(e):void 0).filter(e=>e!==void 0),[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){if(r.length===1){let e=r[0];FI(o,{runStepPart:e,latestAction:await We({runStepPart:e,runStepPartAction:t})});return}II(o,e,{latestActions:await F({runStepPartActions:r.map(e=>({runStepPart:e,runStepPartAction:t}))})})}},[u,o,e]),p=(0,d.useCallback)(e=>{if(!e||!ZI(e))return;let t=qe(e.split(`/`)[1]);if(!t){qI({notificationHeader:`Part scanner`,notificationBody:`Non valid action found in the scanned text`,notificationType:`danger`});return}qI({notificationHeader:`Part scanner`,notificationBody:`Performing action ${Ke(t)} on selected parts`,notificationType:`success`}),f(t)},[f]);return(0,d.useEffect)(()=>{if(a)return c(UI.PERFORM_RUN_ACTION,l),s(UI.PERFORM_RUN_ACTION,l,p),()=>{c(UI.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 ZI(e){return RegExp(`^_qr/.+`).test(e)}var QI=({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]})},$I=({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 ${bI[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))})},eL=({run:e,runStep:t})=>{let n=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Ne({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>He({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}=GI({parts:l});rL({runStepParts:c,runParts:l});let _=(0,d.useMemo)(()=>l.filter(e=>h.get(e.id)&&(u||!tL(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)(Il,{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)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:7})})})]},`placeholder-${t}`)),!a&&_.map((e,n)=>(0,p.jsx)(BI,{runStep:t,runPart:e,runStepParts:c,canInit:!1,partIsSelected:h.get(e.id)??!1,dropdown:!1},`${e.parsed_label}${n}`))]})]}),(0,p.jsx)(nL,{runStepParts:c,selectedPartsLength:_.length,totalParts:l.length,onSelectAll:g,toggleShowCompletedParts:()=>{f(!u)}})]})},tL=(e,t)=>{let n=e.find(e=>e.part_id==t.id);return n==null?!1:n.processed},nL=({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 rL({runStepParts:e,runParts:t}){let{addCallbackFn:n,removeCallbackFn:r}=HI(),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(tL(e,i)){qI({notificationHeader:`Run parts table`,notificationBody:`Part ${i.parsed_label??i.scanner_label} is already completed`,notificationType:`danger`});return}qI({notificationHeader:`Part scanner`,notificationBody:`Found part: ${i.scanner_label}`,notificationType:`success`})}},[t,e]);(0,d.useEffect)(()=>(r(UI.WILD_CARD,i),n(UI.WILD_CARD,i,a),()=>{r(UI.WILD_CARD,i)}),[t,e])}var iL=!1,aL=({run:e,runStep:t})=>{let n=(0,m.useQueryClient)(),r=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Ne({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>He({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}=GI({parts:c});rL({runStepParts:l,runParts:c}),(0,d.useEffect)(()=>{let e=Array.from(u.entries()).filter(([,e])=>e).map(([e])=>e);n.setQueryData([`runPartSelection`,t.id],e)},[n,t.id,u]);let{performActionToSelectedParts:y,getAvailableActionsForSelection:b}=XI({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;if(l.forEach(e=>{let n=c.find(t=>t.id===e.part_id)?.tray;if(!n)return;let r=t.get(n.id)??{id:n.id,label:n.name??n.label??`Tray ${n.id}`,partIds:[]};r.partIds.push(e.part_id),t.set(n.id,r)}),t.size===0)return[];let n=[...e.run_trays??[]].sort((e,t)=>e.sequence-t.sequence);return(n.length>0?n.filter(e=>t.has(e.id)).map(e=>{let n=t.get(e.id);return{...n,label:e.name??e.label??n.label}}):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,l]);if(o)return(0,p.jsx)(Et,{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)(Er,{variant:`warning`,children:`No parts found for this run step.`});if(l.length===0)return(0,p.jsx)(Er,{variant:`warning`,children:`No step parts found for this run step.`});let C=RI(t),w=()=>(0,p.jsx)(p.Fragment,{children:C&&(0,p.jsx)(QI,{onSelectAll:g,onSelectNone:_,hasSelectedParts:v,traySelections:S,onToggleTray:(e,t)=>h(e,t),actionsDropdown:(0,p.jsx)($I,{availableActions:x,onActionSelected:y})})});return(0,p.jsxs)(d.Fragment,{children:[w(),c&&c.length>0&&(0,p.jsxs)(p.Fragment,{children:[!C&&(0,p.jsxs)(Er,{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)(Il,{size:`sm`,striped:!0,hover:!0,className:C?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`}),C&&(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)(BI,{runStep:t,runPart:n,runStepParts:l,canInit:e.run_type===gt.PRODUCTION,partIsSelected:i,setPartAsSelected:C?f:void 0,dropdown:iL},`key-${r}-${n.id}`)})})]})]}),l.length>=25&&w()]})};function oL({run:e,step:t,refetchFn:n=()=>null}){let{run:r}=(0,d.useContext)(aI),{showOnlyEmphasizedParameters:i}=(0,d.useContext)(pI),a=e??r;return a?(0,p.jsx)(Hr,{className:`p-4 my-3`,children:(0,p.jsx)(Hr.Body,{children:(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Experimental split`}),(0,p.jsx)(aL,{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)(Zr,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(hI,{runStep:t,showOnlyEmphasizedParameters:i,refetchFn:()=>{n([JSON.stringify(t),`parameters`])}}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(_I,{runStep:t,refetchFn:()=>{n([`runSteps`])}})]})]})})}):null}var sL=(e,t)=>e==null&&t==null?0:e==null?1:t==null?-1:e-t,cL=(e,t)=>sL(e.left,t.left)||e.id-t.id,lL=e=>e.parent?.id??e.root_id??e.id,uL=(e,t)=>{let n=e[0],r=t[0];return sL(n?.parent?.left,r?.parent?.left)||sL(n?.parent?.id,r?.parent?.id)||cL(n,r)},dL=({parts:e,slotCount:t,getSlotIndex:n})=>{let r=Array.from({length:t},()=>[]),i=new Map;return e.forEach(e=>{let t=lL(e),n=i.get(t)??[];n.push(e),i.set(t,n)}),Array.from(i.values()).map(e=>[...e].sort(cL)).forEach(e=>{let i=n(e[0]),a=i!==null&&i>=0&&i<t?i:r.reduce((e,t,n)=>e===-1||t.length<r[e].length?n:e,-1);a!==-1&&r[a].push(e)}),r.map(e=>e.sort(uL).flat())},fL=({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:sL(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},pL=({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=>{LI(s,o,{...e.data})})},x=async({runStepPart:e,runStepPartAction:t})=>{let n=await We({runStepPart:e,runStepPartAction:t});o&&II(s,o,{runStepPart:e,latestAction:n})},S=!c||!e?null:i&&!c?(0,p.jsxs)(B,{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)(vl,{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)(xI,{runStepPart:t,setRunStepPartAction:x})})})]}):S},mL=(e,t)=>t.get(e.id)?.status.class??`step-part-inactive`,hL=({runPart:e,context:t})=>{let{step:n,stepPartsById:r,allowCreate:i,selectedPartIds:a}=t;return(0,p.jsx)(pL,{runPart:e,statusClass:mL(e,r),allowCreate:i,stepPart:r.get(e.id),isSelected:a.includes(e.id),runStep:n})},gL=({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)(hL,{runPart:e,context:t},e.id))}),_L=({runPart:e,context:t})=>{let{step:n,stepPartsById:r,allowCreate:i,selectedPartIds:a}=t;return(0,p.jsx)(pL,{runPart:e,statusClass:e?mL(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})},vL=12,yL=({leveledParts:e,allNonTrayParts:t,isSplitLevel:n,context:r})=>{let i=fL({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/vL)),s=vL,c={"--tray-columns":s,"--tray-rows":o},l=n?dL({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)(gL,{runParts:e,context:r},`slot-no-tray-${t}`):(0,p.jsx)(_L,{runPart:e[0]??null,context:r},`slot-no-tray-${t}`))})},bL=({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));r.length!==0&&II(i,n,{latestActions:await F({runStepPartActions:r.map(t=>({runStepPart:t,runStepPartAction:e}))})})};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)(vl,{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)($I,{availableActions:f,onActionSelected:h})})})]})},xL=(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),SL=(e,t)=>e.map(e=>t.get(e.id)).filter(e=>e!==void 0),CL=e=>e?.tray_id!=null&&!e?.failed?1:e?.tray_id==null?3:2,wL=({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=SL(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)(bL,{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)(hL,{runPart:e,context:a},e.id))})});let f=c.rows*c.columns,m=c.orientation===`ttb`?`ttb`:`ltr`,h={"--tray-columns":c.columns,"--tray-rows":c.rows},g=fL({parts:n,slotCount:f,getOverrideSlotIndex:e=>{let t=d.get(e.id);return!t||t.tray_row==null&&t.tray_column==null?null:xL(c,t.tray_row??e.tray_row,t.tray_column??e.tray_column)},getDirectSlotIndex:e=>xL(c,e.tray_row,e.tray_column)}),_=i?dL({parts:t,slotCount:f,getSlotIndex:e=>g.get(e.id)??null}):Array.from({length:f},()=>[]);return i||t.forEach(e=>{let t=d.get(e.id),n=xL(c,t?.tray_row??e.tray_row,t?.tray_column??e.tray_column);if(n===null)return;let r=CL(t),i=_[n][0],a=i?CL(d.get(i.id)):null;a!==null&&a<r||(_[n]=[e])}),(0,p.jsx)(bL,{label:l,trayStepParts:u,runStep:o,children:(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":m,style:h,children:_.map((t,n)=>i?(0,p.jsx)(gL,{runParts:t,context:a},`slot-${e.id}-${n}`):(0,p.jsx)(_L,{runPart:t[0]??null,context:a},`slot-${e.id}-${n}`))})})},TL=(e,t)=>!t||!t.tray_id?e.tray?.id??0:t.tray_id,EL=(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=TL(t,n.get(t.id)),i=e.get(r)??[];return i.push(t),e.set(r,i),e},new Map)},DL=({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)(()=>new Map(n.filter(t=>t.step_id===e.id).map(e=>[e.part_id,e])),[n,e]),o=(0,d.useMemo)(()=>[...r.run_trays??[]].sort((e,t)=>e.sequence-t.sequence),[r]),s=(0,d.useMemo)(()=>EL(i,n),[i,n]),c=(0,d.useMemo)(()=>t.filter(e=>!e.tray),[t]),l=(0,d.useMemo)(()=>EL(t,n),[t,n]),u=r.run_type===gt.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)(yL,{leveledParts:i,allNonTrayParts:c,isSplitLevel:f,context:g}):(0,p.jsx)(`div`,{className:`tray-grid-group`,children:o.map(e=>(0,p.jsx)(wL,{tray:e,trayParts:s.get(e.id)??[],trayAllParts:l.get(e.id)??[],stepParts:n,isSplitLevel:f,context:g},`tray-${e.id}`))})};function OL({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:()=>He({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)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(DL,{step:t,parts:n,stepParts:h,run:e})}),(0,p.jsxs)(`td`,{children:[r&&(0,p.jsx)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{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)(oL,{step:t,refetchFn:i})})})]})}var kL=({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);(0,d.useEffect)(()=>{if(Object.keys(s).length>0)return;let n={};for(let r of e.targets){let e=``;t!==void 0&&(e=t.values.find(e=>e.logging_parameter.id==r.logging_parameter.id)?.string_value??``),n[r.logging_parameter.id]=e}c(n)},[e]),(0,d.useEffect)(()=>{_(!1),h(null),u(!1)},[n]);let v=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)}},y=async()=>{try{h(null),_(!1),u(!0);let n=Object.entries(s).map(async([e,n])=>{let r=Number.parseInt(e),i={value:n},a=t?.values.find(e=>e.logging_parameter.id===r)?.id;await f.default.patch(`/update/run/measurement/result/value/${a??0}`,i)});await Promise.all(n),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},b=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)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:t?(0,p.jsx)(p.Fragment,{children:`Update results`}):(0,p.jsx)(p.Fragment,{children:`Create result`})})}),(0,p.jsxs)(H,{onSubmit:e=>{e.preventDefault(),t?y():b()},children:[(0,p.jsxs)(U.Body,{children:[m&&(0,p.jsx)(Er,{variant:`danger`,children:m}),g&&(0,p.jsx)(Er,{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)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:e.logging_parameter.name}),(0,p.jsx)(H.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)(U.Footer,{children:[(0,p.jsx)(B,{variant:`warning`,onClick:()=>r(!1),children:`Close`}),l?(0,p.jsxs)(B,{type:`submit`,variant:`info`,disabled:l,children:[(0,p.jsx)(Fl,{animation:`border`,size:`sm`,className:`me-2`}),` Updating results...`]}):t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`danger`,disabled:l,onClick:v,children:`Delete result`}),(0,p.jsx)(B,{type:`submit`,variant:`info`,disabled:l,children:`Update result`})]}):(0,p.jsx)(B,{type:`submit`,variant:`info`,disabled:l,children:`Create result`})]})]})]})},AL=(0,d.createContext)({runStep:{},setRunStep:e=>{},reloadRunStep:()=>{},run:{},modalProperties:{},setModalProperties:e=>{}});function jL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a,editOnly:o=!1}){let{run:s}=(0,d.useContext)(AL),[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 Ne({run:s}),enabled:!r||r.length===0,retry:1},{queryKey:[`runStepParts`,`${t?.run_id??`unknown`}`,`${t?.id??`unknown`}`],queryFn:async()=>await He({step:e.requirement_for_step??e.step}),enabled:!n||n.length===0,retry:1},{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Le({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)(Fl,{animation:`border`,size:`sm`}),` `,(0,p.jsx)(`span`,{children:`Loading data…`})]});if(j&&E.length===0)return(0,p.jsxs)(Er,{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)(B,{size:`sm`,variant:`outline-light`,onClick:()=>b.refetch(),children:`Retry parts`}),` `,O&&x?.isError&&(0,p.jsx)(B,{size:`sm`,variant:`outline-light`,onClick:()=>x.refetch(),children:`Retry step parts`}),` `,k&&S?.isError&&(0,p.jsx)(B,{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)(Il,{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)(B,{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)(kL,{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)(Er,{variant:`secondary`,className:`mb-0`,children:`No selected parts`})})}function ML({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 Le({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.filter(e=>e.isError).forEach((e,t)=>{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)(B,{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)(kL,{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)(B,{size:`sm`,onClick:()=>g(!h),children:[(0,p.jsx)(`i`,{className:`fa fa-plus`}),` Add results`]})}),(0,p.jsx)(kL,{requirement:e,show:h,setShow:e=>{e||g(!1)},refetchFn:n??c})]})}function NL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}){let{environment:o}=(0,g.useParams)();return(0,p.jsx)(Hr,{className:`p-4 my-3`,children:(0,p.jsx)(Hr.Body,{children:(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{md:`7`,children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(jL,{requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(ML,{requirement:e,measurementResults:i,refetchFn:a})]}),(0,p.jsxs)(Zr,{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)(Il,{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)(_I,{runStep:t,refetchFn:()=>{a([`requirements`])}})]})]})})})}var PL=({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=t=>{let r=i.find(e=>e.part_id===t.id);if(!r)return`badge-inactive`;let a=n.find(e=>e.values.some(e=>e.step_part_id===r.id));if(!a)return``;for(let t of a.values){let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id==t.logging_parameter.id);if(r){if(r.inclusive){if(!(r.min_value<=n&&r.max_value>=n))return`badge-failed`}else if(!(r.min_value<n&&r.max_value>n))return`badge-failed`}}return`badge-processed`},c=e=>(0,p.jsx)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{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} ${s(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=>c(e))]},e)):a.map(e=>c(e)),(0,p.jsx)(`span`,{children:`(measurements)`})]})};function FL({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:()=>Le({measurement:e.measurement})},{queryKey:[`runStepParts`,e.requirement_for_step?.id??e.step.id],queryFn:()=>He({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]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:(t=>{if(t.length==0)return y?``:`table-info`;let n=!1;for(let r of t)if(r.values.some(t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return!1;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):!1})){n=!0;break}return n?`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)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(PL,{requirement:e,step:t,measurementResults:x,parts:n,stepParts:b})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(Dr,{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)(NL,{requirement:e,step:t,stepParts:b,parts:n,measurementResults:x,refetchFn:h})})})]})}function IL(){let{run:e}=(0,d.useContext)(aI),{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n}=(0,d.useContext)(pI),[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:()=>Pe({run:e,page:r,pageSize:a}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>Ne({run:e})},{queryKey:[`requirements`,JSON.stringify(e)],queryFn:()=>je({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.filter(e=>e.isError).forEach((t,n)=>{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)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`2rem`,height:`1rem`,borderRadius:`0.5rem`}})}),(0,p.jsx)(W,{animation:`glow`,as:`span`,className:`ms-2`,children:(0,p.jsx)(W,{style:{width:`15rem`}})})]})}),(0,p.jsxs)(Il,{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)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`0.75rem`}})})}),(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`10rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{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=>(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})})}),E=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)(Il,{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&&E(t),(!t.has_label||o.get(t.label?.id??-1))&&(0,p.jsxs)(p.Fragment,{children:[t.has_step_group&&C.includes(t)&&T(t),t.has_requirement?(0,p.jsx)(FL,{requirement:x.find(e=>e.step.id===t.id),step:t,parts:b,refetchFn:u}):(0,p.jsx)(OL,{run:e,step:t,parts:b,monitoredBy:w[t.id],refetchFn:u})]})]},n)})})]}),(0,p.jsx)(qF,{data:f.data,setPage:i,isPlaceholderData:f.isPlaceholderData})]})}var LL=[],RL=new Set,zL=(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},BL=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n};function VL(){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=>zL(t,e,[])),a(t=>BL(t,e)),s(t=>BL(t,e))},[]),getSelectedPartIds:(0,d.useCallback)(e=>n[e]??LL,[n]),isPartSelected:(0,d.useCallback)((e,t)=>(c[e]??RL).has(t),[c]),setRunPartIds:(0,d.useCallback)((e,t)=>{r(n=>zL(n,e,t))},[]),togglePart:(0,d.useCallback)((e,t)=>{r(n=>{let r=n[e]??[];return zL(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 zL(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 HL(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 UL=(e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left,WL=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(UL)}))},GL=e=>e.parsed_label||e.scanner_label||e.label||e.short_label;function KL({runId:e,part:t,selection:n}){let r=n.isPartSelected(e,t.id),i=GL(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)(H.Label,{htmlFor:a,className:`small text-secondary mb-0`,children:`Split`}),(0,p.jsx)(H.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)(H.Check,{id:o,type:`checkbox`,checked:r,onChange:()=>n.togglePart(e,t.id),"aria-label":`Select ${i}`,className:`ms-sm-auto`})]})}function qL({runId:e,part:t,selection:n}){let r=n.isPartSelected(e,t.id);return(0,p.jsx)(Dr,{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:GL(t)})}function JL({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)(Dr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:t.parts.length}),(0,p.jsx)(B,{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)(KL,{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)(qL,{runId:e,part:t,selection:n},t.id))})]})}function YL({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)(H.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)(B,{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)(B,{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)(Fl,{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)(JL,{runId:e.id,group:n,selection:t,experimentalEdit:i},n.level))]})}function XL({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)(Dr,{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)(B,{variant:`outline-danger`,size:`sm`,onClick:()=>t(e.id),children:`Deselect`})})]},e.id))})]})}var ZL=e=>WL(e.items??[]),QL=e=>({value:e.id,label:`${e.label} — ${e.name}`,run:e}),$L=Xb;function eR({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:()=>Fe({environment:n,availableAsParentForRun:t})}),u=(0,m.useQueries)({queries:s.map(e=>({queryKey:[e.id],queryFn:()=>Ne({run:e}),select:ZL}))}),f=(0,d.useMemo)(()=>c?.items??[],[c]),h=(0,d.useMemo)(()=>f.map(QL),[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();return f.filter(e=>!t||e.label.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)).map(QL)},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)(Jb,{isSearchable:!0,isClearable:!0,defaultOptions:h,placeholder:`— Select a run, or start typing`,loadOptions:b,isLoading:l,value:null,styles:$L,onChange:e=>{e&&x(e.run)}})]}),(0,p.jsx)(XL,{selectedRuns:s,onDeselect:e.deselectRun}),s.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(nl,{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)(nl.Item,{children:(0,p.jsx)(nl.Link,{eventKey:`run-${e.id}`,children:e.label})},e.id))}),(0,p.jsx)(`div`,{className:`ms-2 ps-2`,children:v&&(0,p.jsx)(YL,{run:v,selection:e,partGroups:y?.data??[],isLoadingParts:y?.isFetching??!1,experimentalEdit:a,onToggleExperimentalEdit:()=>o(e=>!e)},v.id)})]})]})}function tR({title:e,isFirst:t=!1,children:n}){return(0,p.jsxs)(Pl,{className:`g-3 py-4${t?``:` border-top`}`,children:[(0,p.jsx)(Zr,{xs:12,md:3,children:(0,p.jsx)(`h3`,{className:`fs-5 mb-0`,children:e})}),(0,p.jsx)(Zr,{xs:12,md:9,children:(0,p.jsx)(`div`,{className:`d-flex flex-column gap-3`,children:n})})]})}var nR=e=>{if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null};function rR({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)(H.Group,{controlId:e,children:[(0,p.jsxs)(H.Label,{children:[t,` `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(H.Select,{value:i??``,onChange:e=>a(nR(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)(H.Control.Feedback,{type:`invalid`,children:r?`${t}s are still loading.`:`Select a ${l}.`}),(0,p.jsx)(H.Text,{muted:!0,children:c})]})}function iR({title:e,isEmpty:t,emptyText:n,children:r}){return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`text-secondary small text-uppercase fw-semibold mb-2`,children:[e,` `,(0,p.jsx)(`span`,{className:`text-body-tertiary`,children:`(selected previously)`})]}),t?(0,p.jsx)(`p`,{className:`text-secondary fst-italic mb-0`,children:n}):(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:r})]})}function aR({selectedRuns:e,selectedSubstrates:t,partIdsByRunId:n}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(iR,{title:`Parent runs & parts`,isEmpty:e.length===0,emptyText:`No parent runs selected.`,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)(Dr,{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)(iR,{title:`Substrates`,isEmpty:t.length===0,emptyText:`No substrates selected.`,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)(Dr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:[`Amount: `,t]})]},e.id))})]})}function oR({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)(`research`),[w,T]=(0,d.useState)(1),[E,D]=(0,d.useState)(``),[O,k]=(0,d.useState)(``),[A,j]=(0,d.useState)(!1),M=(0,m.useQuery)({queryKey:[`organisation-groups`,s],queryFn:()=>xe({environment:s})}),ee=(0,m.useQuery)({queryKey:[`organisation-teams`,s,vt.Run],queryFn:()=>Ce({environment:s,purpose:vt.Run})}),te=(0,m.useQuery)({queryKey:[`organisation-projects`,s,_t.Run],queryFn:()=>Se({environment:s,purpose:_t.Run})}),N=c.trim(),ne=u.trim(),re=M.isLoading||ee.isLoading||te.isLoading,ie=M.isError||ee.isError||te.isError,ae=M.data?.items??[],P=ee.data?.items??[],oe=te.data?.items??[],se=h!==null&&ae.some(e=>e.id===h),ce=v!==null&&P.some(e=>e.id===v),le=b!==null&&oe.some(e=>e.id===b),ue=N===``,de=ne===``,fe=A&&ue,pe=A&&de,me=!ue&&!de&&se&&ce&&le&&!re&&!ie&&!e;return(0,p.jsxs)(H,{noValidate:!0,onSubmit:e=>{e.preventDefault(),j(!0),me&&o({name:N,motivation:ne,groupId:h,teamId:v,projectId:b,parts:Number.isFinite(w)?Math.max(1,w):1,location:E,conclusion:O,runType:S})},children:[(0,p.jsxs)(tR,{title:`Details`,isFirst:!0,children:[(0,p.jsxs)(H.Group,{controlId:`create-run-name`,children:[(0,p.jsxs)(H.Label,{children:[`Run name `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsx)(H.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)(H.Control.Feedback,{type:`invalid`,children:`Run name is required.`}),(0,p.jsx)(H.Text,{muted:!0,children:`Give a short and descriptive name for the run`})]}),(0,p.jsxs)(H.Group,{controlId:`create-run-location`,children:[(0,p.jsx)(H.Label,{children:`Sample location`}),(0,p.jsx)(H.Control,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`Location of the samples`,disabled:e}),(0,p.jsx)(H.Text,{muted:!0,children:`Give here the location where the run samples are stored`})]}),(0,p.jsxs)(H.Group,{controlId:`create-run-motivation`,children:[(0,p.jsxs)(H.Label,{children:[`Motivation `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsx)(H.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)(H.Control.Feedback,{type:`invalid`,children:`Motivation is required.`}),(0,p.jsx)(H.Text,{muted:!0,children:`Explain here the motivation for this run`})]}),(0,p.jsxs)(H.Group,{controlId:`create-run-conclusion`,children:[(0,p.jsx)(H.Label,{children:`Conclusion`}),(0,p.jsx)(H.Control,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`Optional`,disabled:e}),(0,p.jsx)(H.Text,{muted:!0,children:`Explain the conclusion of this run`})]})]}),(0,p.jsxs)(tR,{title:`Organisation`,children:[A&&ie&&(0,p.jsx)(Er,{variant:`warning`,children:`Could not load organisation values.`}),(0,p.jsx)(rR,{controlId:`create-run-group`,label:`Group`,options:ae,isLoading:M.isLoading,value:h,onChange:_,showError:A&&!se,disabled:e,helpText:`Select the group to which this run belongs`}),(0,p.jsx)(rR,{controlId:`create-run-team`,label:`Team`,options:P,isLoading:ee.isLoading,value:v,onChange:y,showError:A&&!ce,disabled:e,helpText:`Select the team to which this run belongs`}),(0,p.jsx)(rR,{controlId:`create-run-project`,label:`Project`,options:oe,isLoading:te.isLoading,value:b,onChange:x,showError:A&&!le,disabled:e,helpText:`Select the project to which this run belongs`})]}),(0,p.jsx)(tR,{title:`Parts`,children:(0,p.jsxs)(H.Group,{controlId:`create-run-parts`,children:[(0,p.jsx)(H.Label,{children:`Experimental split`}),(0,p.jsx)(H.Control,{type:`number`,min:1,step:1,value:w,onChange:e=>T(Number(e.target.value)),disabled:e}),(0,p.jsx)(H.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)(tR,{title:`Type`,children:(0,p.jsxs)(H.Group,{controlId:`create-run-type`,children:[(0,p.jsx)(H.Label,{children:`Run type`}),(0,p.jsxs)(H.Select,{value:S,onChange:e=>C(e.target.value),disabled:e,children:[(0,p.jsx)(`option`,{value:`research`,children:`Research`}),(0,p.jsx)(`option`,{value:`production`,children:`Production`})]})]})}),(0,p.jsx)(tR,{title:`Overview`,children:(0,p.jsx)(aR,{selectedRuns:n,selectedSubstrates:r,partIdsByRunId:i})}),t&&(0,p.jsx)(Er,{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)(B,{variant:`outline-secondary`,type:`button`,onClick:a,disabled:e,children:`Back`}),(0,p.jsx)(B,{variant:`primary`,type:`submit`,disabled:e,children:e?`Creating...`:`Create Run`})]})]})}var sR=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.`},cR=e=>({value:e.id,label:`${e.label} — ${e.short_label}`,substrate:e}),lR=async e=>(await $e({query:e||void 0})).items.map(cR),uR=Xb;function dR({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)(Jb,{isSearchable:!0,isClearable:!0,defaultOptions:!0,placeholder:`— Select a substrate, or start typing`,loadOptions:lR,value:null,styles:uR,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)(B,{variant:`outline-danger`,size:`sm`,onClick:()=>i(e.id),"aria-label":`Deselect ${e.label}`,children:`Deselect`}),(0,p.jsx)(H.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 fR(){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=VL(),c=(0,m.useMutation)({mutationFn:async({runValues:e,parentRuns:t,substrates:n})=>{let r=await we({name:e.name,motivation:e.motivation,group_id:e.groupId,team_id:e.teamId,project_id:e.projectId,experimental_split:e.parts,location:e.location||null,conclusion:e.conclusion||null,run_type:e.runType}),i=HL(r.id,t).map(e=>Te(e)),a=n.map(({substrate:e,amount:t})=>Ee({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)(nl,{variant:`tabs`,activeKey:r,onSelect:e=>{(e===`parts`||e===`substrate`)&&i(e)},className:`mb-4`,children:[(0,p.jsx)(nl.Item,{children:(0,p.jsx)(nl.Link,{eventKey:`parts`,children:`Parent run and parts`})}),(0,p.jsx)(nl.Item,{children:(0,p.jsx)(nl.Link,{eventKey:`substrate`,children:`Select Substrate`})})]}),(0,p.jsxs)(`div`,{className:`m-3`,children:[r===`parts`&&(0,p.jsx)(eR,{selection:s}),r===`substrate`&&(0,p.jsx)(dR,{selectedSubstrates:a,setSelectedSubstrates:o}),r===`details`&&(0,p.jsx)(oR,{isSubmitting:c.isPending,errorMessage:c.isError?sR(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)(B,{variant:`primary`,disabled:c.isPending,onClick:()=>{i(`details`)},children:`Continue`})})]})]})}function pR(){let{environment:e}=(0,g.useParams)(),{run:t,reloadRun:n}=(0,d.useContext)(aI),r=(0,m.useQueryClient)(),i=VL(),a=(0,m.useMutation)({mutationFn:async e=>{let n=[];for(let r of HL(t.id,e))n.push(await Te(r));return n},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)(eR,{selection:i,run:t}),(0,p.jsx)(`div`,{className:`d-flex justify-content-end mt-4`,children:(0,p.jsx)(B,{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)(Er,{variant:`success`,className:`mt-3`,children:[`Parent runs added to `,t.label??`#${t.id}`,`.`]})]})})}function mR(){let{run:e}=(0,d.useContext)(aI),{environment:t}=(0,g.useParams)(),n=e.run_type===gt.RESEARCH,r=e.run_type===gt.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:`${Ct()}${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:`${Ct()}${t}/organisation/group/details/${e.group.id}/responsible-users.html`,children:e.group?.name??`—`})})]})]})})]})}var hR=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 gR(){let{run:e}=(0,d.useContext)(aI),[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:()=>Ae({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}=Ub({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 Ie({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 De({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)(Il,{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)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:8})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:6})})}),(0,p.jsx)(`td`,{className:`text-end`,children:(0,p.jsx)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:10})})})]})})]}):f.length>0?(0,p.jsxs)(Il,{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:`${Ct()}/${c}/file/download/${e.id}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(Dr,{className:`ms-2 bg-primary`,children:`Logging`})]}),(0,p.jsx)(`td`,{children:hR(e.size)}),(0,p.jsx)(`td`,{children:rF(e.date_created,`DD-MM-YY HH:mm`)}),(0,p.jsxs)(`td`,{className:`text-end`,children:[(0,p.jsx)(B,{size:`sm`,variant:`outline-primary`,className:`me-2`,onClick:()=>{window.location.href=`${Ct()}/${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)(B,{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)(ac,{className:`mt-3`,children:t.map(e=>(0,p.jsxs)(ac.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:hR(e.size)})]},`${e.name}-${e.lastModified}`))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(B,{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 _R(){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run information`}),(0,p.jsx)(mR,{}),(0,p.jsx)(gR,{})]})}function vR({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=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t.id))},u=e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},f=async(t,n,a,o)=>{t.preventDefault();let s=Number(t.dataTransfer.getData(`text/plain`)),l=c.get(s);if(!l){console.error(`Unable to update run step part tray: stepPart not found`);return}if(!(l.tray_id===n.id&&l.tray_column===o&&l.tray_row===a)){if(r.find(t=>t.id!==l.id&&t.step_id===e.id&&t.tray_id===n.id&&t.tray_row===a&&t.tray_column===o&&!(t.has_failed_in_previouse_state||t.failed))){qI({notificationHeader:`Tray part change`,notificationBody:`Two PartTrays can not be in the same tray position`,notificationType:`danger`});return}LI(i,e,{...l,tray_id:n.id,tray_row:a,tray_column:o});try{LI(i,e,(await Ue(l,n,a,o,!0)).data,{updateSubsequent:!0}),qI({notificationHeader:`Tray part change`,notificationBody:`Part moved successfully`,notificationType:`success`})}catch(t){LI(i,e,l),qI({notificationHeader:`Tray part change`,notificationBody:xR(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 h=a.rows*a.columns,g={"--tray-rows":a.rows,"--tray-columns":a.columns},_=Array.from({length:h},()=>null);return r.forEach(e=>{let t=s.get(e.part_id);if(!t)return;let n=yR(a,e.tray_row??t.tray_row,e.tray_column??t.tray_column);if(n===null||e.has_failed_in_previouse_state)return;let r=SR(e),i=_[n],o=i?SR(i):null;o!==null&&o<r||(_[n]=e)}),(0,p.jsxs)(`section`,{className:`tray-visual my-2`,style:g,"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:_.map((e,n)=>{let r=n+1,{row:i,column:o}=bR(a,n),c=e?s.get(e.part_id):null,d=CR(e),m=wR(e);return(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:u,onDrop:e=>f(e,t,i,o),children:c&&e?(0,p.jsx)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{id:`tooltip-tray-slot-part-${e.id}`,children:m}),children:(0,p.jsx)(`span`,{className:`tray-visual__part badge ${d} badge-level-${c.part_level}`,"data-part-id":c.id,"data-step-part-id":e.id,draggable:!0,onDragStart:t=>l(t,e),children:c.scanner_label})},e.id):(0,p.jsx)(`span`,{className:`tray-visual__index`,children:r})})},`${t.id}-${r}`)})})})]})}var yR=(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),bR=(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},xR=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.`},SR=e=>e.tray_id!=null&&!e.failed?1:e.tray_id==null?3:2,CR=e=>e?.failed?`bg-danger`:e?.tray_id?`bg-primary`:`bg-grey`,wR=e=>e?.failed?`Part failed`:e==null?`In default postion`:e.tray_id==null?`In default position`:`Not in default postion`,TR=({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)(()=>EL(o,a),[o,a]);return i.length===0||o[0]?.part_level>0?(0,p.jsx)(DL,{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)(vR,{step:e,tray:t,parts:s.get(t.id)??[],stepParts:a},t.id))})};function ER({step:e,parts:t,run:n}){let{environment:r}=(0,g.useParams)(),[i]=(0,m.useQueries)({queries:[{queryKey:[`runStepParts`,e.id],queryFn:()=>He({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)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(TR,{step:e,parts:o,stepParts:a,run:n})})]})}function DR(){let{run:e}=(0,d.useContext)(aI),[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:()=>Pe({run:e,page:t,pageSize:r}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>Ne({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.filter(e=>e.isError).forEach((t,n)=>{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]})})})},b=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})})});return l?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run layout edit`}),(0,p.jsxs)(Il,{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)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`4rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{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)(Il,{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)&&b(t),(0,p.jsx)(ER,{step:t,parts:h,run:e},`step-${t.id}`)]})]},`step-${t.id}`))})]}),(0,p.jsx)(qF,{data:s.data,setPage:n,isPlaceholderData:s.isPlaceholderData})]})}var OR=()=>{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())&&ke({id:parseInt(i)}).then(e=>(Oe({id:e.run_id}).then(r),e)).then(t)},[i,e]);function a(){ke({id:parseInt(i)}).then(e=>(Oe({id:e.run_id}).then(r),e)).then(t)}return{run:n,runStep:e,setRunStep:t,reloadRunStep:a}};function kR({children:e}){let{runStep:t,setRunStep:n,run:r,reloadRunStep:i}=OR(),[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)(jt,{children:(0,p.jsx)(Et,{message:e})})}return(0,p.jsx)(jt,{children:(0,p.jsx)(AL.Provider,{value:{runStep:t,setRunStep:n,reloadRunStep:i,run:r,modalProperties:a,setModalProperties:o},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}function AR(){return(0,p.jsx)(kR,{children:(0,p.jsx)(Qr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})})}var jR=({label:e})=>(0,p.jsx)(`div`,{className:`p-2 h4 mb-1 bg-info text-white`,children:e.label}),MR=({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,`)`]})]})},NR=({checklistItem:e,show:t,setModalShow:n,mutation:r})=>(0,p.jsxs)(U,{show:t,size:`lg`,onHide:()=>n(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Checklist item`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsx)(`h2`,{children:e.task}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.description}})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:()=>{r.mutate()},children:`Done`}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>n(!1),children:`Close`})]})]});function PR({checklistItem:e,onOpenModal:t,onMarkDone:n}){return e.can_finish?e.description===``?(0,p.jsx)(B,{className:`float-end`,size:`sm`,variant:`success`,onClick:n,children:`Done checklist step`}):(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:t,children:`Execute checklist step`}):null}var FR=({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)(ac.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)(cI,{format:`DD-MM-YYYY`,children:e.date_executed})]})]}),(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(PR,{checklistItem:e,onOpenModal:()=>r(!0),onMarkDone:()=>i.mutate()})}),(0,p.jsx)(NR,{checklistItem:e,show:n,setModalShow:r,mutation:i})]})},IR={movingOut:`Moving out...`,skipping:`Skipping...`,unskipping:`Unskipping...`,operationFinished:`Operation finished`,operationSkipped:`Operation skipped`,operationUnskipped:`Operation unskipped`};function LR({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)(AL);(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:()=>Re({runStep:v}),enabled:!!v}),w=(0,d.useCallback)(async e=>{o(IR.movingOut),c(!0);try{let t=await ze(e);o(IR.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(IR.skipping),c(!0);try{await f.default.create().patch(`update/run/step/skip/${e.id}`,{}),o(IR.operationSkipped),y()}finally{c(!1)}},[y]),E=(0,d.useCallback)(async e=>{o(IR.unskipping),c(!0);try{await f.default.create().patch(`update/run/step/un-skip/${e.id}`,{}),o(IR.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)(Et,{message:`Loading...`}):x?(0,p.jsx)(Er,{variant:`danger`,children:`Failed to load checklist.`}):(0,p.jsxs)(p.Fragment,{children:[D.length===0&&(0,p.jsx)(Er,{variant:`info`,children:`No checklist found`}),D.length>0&&(0,p.jsx)(ac,{children:D.map(e=>(0,p.jsx)(FR,{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)(B,{variant:`success`,onClick:()=>w(v),disabled:s,children:a===IR.operationFinished||a===IR.movingOut?a:`Move out`})}),_.access.edit&&!v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,onClick:()=>T(v),disabled:s,children:a===IR.operationSkipped||a===IR.skipping?a:`Skip operation`})}),_.access.edit&&v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`warning`,onClick:()=>E(v),disabled:s,children:a===IR.operationUnskipped||a===IR.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 RR=()=>void 0;function zR({runStep:e,reloadRunStep:t,title:n=`Remark`,titleClassName:r=`mb-2 text-start`}){let{runStep:i,setRunStep:a}=(0,d.useContext)(AL),o=e??i,s=t?()=>t():e?RR:a??RR,[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)(B,{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)(B,{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)(H,{onSubmit:g(b),children:[(0,p.jsx)(H.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)(B,{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)(B,{variant:`secondary`,className:`ms-2`,onClick:()=>l(!1),children:`Cancel`})]})]}):(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext for StepRemark`})}var BR=({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,_=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)}},v=(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})))})};return(0,p.jsx)(U,{show:t,size:`lg`,onHide:()=>n(!1),children:(0,p.jsxs)(H,{onSubmit:u(_),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:a?`Reset hold code`:`Update hold code`})}),(0,p.jsxs)(U.Body,{children:[!a&&(0,p.jsxs)(Hs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(H.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)(Eu,{name:`holdCode`,control:c,rules:{validate:{required:e=>e.value!==void 0||a||`A hold code is required`}},render:({field:e})=>(0,p.jsx)(Jb,{isSearchable:!1,defaultOptions:!0,placeholder:`Select a hold code`,loadOptions:v,value:e.value,onChange:t=>{e.onChange(t)}})}),h.holdCode&&(0,p.jsx)(`span`,{className:`text-danger`,children:h.holdCode.message})]})]}),(0,p.jsxs)(Hs,{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)(H.Control,{as:`textarea`,rows:3,id:`holdCodeDescription`,...s(`description`,{required:`A message is required`}),isInvalid:h.description!==void 0}),h.description&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:h.description.message})]})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsxs)(B,{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)(B,{variant:`outline-danger`,onClick:()=>{l(`description`,a?r.description:``),o(!a)},children:a?`Update hold Code`:`Reset hold code`})]})]})})},VR=()=>{let{run:e}=(0,d.useContext)(AL),[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)(Dr,{bg:`secondary`,className:`handle`,onClick:()=>a(),style:{fontSize:`1.5rem`,cursor:`pointer`},children:`No hold code`}),(0,p.jsx)(BR,{run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})]})},HR=()=>{let{run:e}=(0,d.useContext)(AL),[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`})]})},UR=({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)(aL,{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)(hI,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:n})]})]})}),WR=({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)(AL);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)(DL,{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)(Dr,{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)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{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)(cI,{format:`DD-MM-YYYY`,children:n.finish_date}):``})]})]}),c&&(0,p.jsx)(UR,{run:e,runStep:n,showOnlyEmphasizedParameters:!1})]})};function GR({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)(jL,{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)(Il,{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 KR({requirement:e,runParts:t,runStepParts:n,hideLabel:r,firstInGroup:i}){let a=e.step,{environment:o}=(0,g.useParams)(),{runStep:s}=(0,d.useContext)(AL),[c,l]=(0,d.useState)(!1),[u]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Le({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=!1;for(let r of n){let n=u.data?.items.find(e=>e.values.some(e=>e.step_part_id===r.id))?.values.find(e=>e.step_part_id===r.id);if(!(n&&!isNaN(parseFloat(n.string_value))))return a.id===s.id?`bg-success-subtle`:``;let i=parseFloat(n.string_value);if(e.targets.some(e=>e.inclusive?!(e.min_value<=i&&e.max_value>=i):!(e.min_value<i&&e.max_value>i))){t=!0;break}}return t?`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)(PL,{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)(Dr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(Dr,{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)(cI,{format:`DD-MM-YYYY`,children:a.finish_date}):``})]})]}),c&&(0,p.jsx)(GR,{requirement:e,step:a,stepParts:n,parts:t,measurementResults:u.data?.items??[]})]})}var qR=({pageSize:e=25,hideLabel:t=!1})=>{let{runStep:n,run:r}=(0,d.useContext)(AL),[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,s=(0,m.useQuery)({queryKey:[`runParts`,`${o}`],queryFn:()=>Ne({run:r}),enabled:!!o}),c=(0,m.useQuery)({queryKey:[`runStepParts`,`${o}`],queryFn:()=>He({run:r}),enabled:!!o}),l=(0,m.useQuery)({queryKey:[`runSteps`,o,i,e],queryFn:()=>Pe({run:r,page:i,pageSize:e}),enabled:!!o,placeholderData:m.keepPreviousData}),u=(0,m.useQuery)({queryKey:[`requirements`,o],queryFn:()=>je({run:r}),enabled:!!o,placeholderData:m.keepPreviousData}),f=s.isLoading||c.isLoading||l.isLoading||u.isLoading,h=s.isError||c.isError||l.isError||u.isError,g=s.error||c.error||l.error||u.error,_=s.data?.items??[],v=c.data?.items??[],y=l.data?.items??[],b=u.data?.items??[],x=new Set,S=y.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||x.has(String(e.step_group.id))?!1:(x.add(String(e.step_group.id)),!0)),C={};for(let e of b)e.requirement_for_step!=null&&(C[String(e.requirement_for_step.id)]=e);return d.default.useEffect(()=>{h&&console.error(`RunStepSimpleList query error`,{runId:o,errors:[s.error,c.error,l.error,u.error]})},[h,o,s.error,c.error,l.error,u.error]),(0,p.jsxs)(`div`,{children:[f?(0,p.jsx)(`div`,{children:`Loading...`}):h?(0,p.jsxs)(`div`,{children:[`Error: `,String(g?.message??g)]}):(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:y.map((e,n)=>(0,p.jsx)(d.default.Fragment,{children:e.has_requirement?(0,p.jsx)(KR,{requirement:b.find(t=>t.step.id===e.id),runParts:_,runStepParts:v,firstInGroup:S.includes(e)},e.id??e.sequence??n):(0,p.jsx)(WR,{run:r,monitoredBy:C[e.id],runParts:_,runStepParts:v,hideLabel:t,firstInGroup:S.includes(e),runStep:e},e.id??e.sequence??n)},n))}),(0,p.jsx)(qF,{data:l.data,setPage:a,isPlaceholderData:l.isPlaceholderData}),l.isFetching?(0,p.jsx)(`span`,{children:` Loading...`}):null]})},JR=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)(AL),[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:()=>Me({run:n,page:r}),placeholderData:m.keepPreviousData});return(0,p.jsxs)(U,{show:e,size:`lg`,onHide:()=>t(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsxs)(U.Title,{children:[`History of Run `,n.label]})}),(0,p.jsx)(U.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)(Il,{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)(cI,{format:`DD-MM-YYYY`,children:e.date_created})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.message}})}),(0,p.jsxs)(`td`,{children:[e.user.first_name,` `,e.user.last_name]})]},e.id))})}),(0,p.jsx)(qF,{data:l,setPage:i,isPlaceholderData:f}),u?(0,p.jsx)(`span`,{children:` Loading...`}):null]})}),(0,p.jsx)(U.Footer,{children:(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},YR=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{size:e,variant:`primary`,onClick:()=>n(!t),children:`Run history`}),t&&(0,p.jsx)(JR,{show:t,setModalShow:n})]})},XR=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)(AL);return(0,p.jsxs)(U,{show:e,size:`xl`,onHide:()=>t(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsxs)(U.Title,{children:[`All steps of run `,n.label]})}),(0,p.jsx)(U.Body,{children:(0,p.jsx)(qR,{hideLabel:!1})}),(0,p.jsx)(U.Footer,{children:(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},ZR=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(B,{size:e,variant:`primary`,onClick:()=>n(!0),children:`All run steps`}),t&&(0,p.jsx)(XR,{show:t,setModalShow:n})]})},QR=()=>{let{runStep:e,run:t}=(0,d.useContext)(AL),[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:()=>Qe({reworkRecipes:g}),enabled:n&&g.length>0},{queryKey:[`run_steps`,e.id],queryFn:()=>Pe({run:t,page:1,pageSize:1e3}),enabled:n},{queryKey:[`template_steps`,`rework`,o,e.id],queryFn:()=>Ze({template:o,pageSize:1e3}),enabled:o!==null}]});if((0,d.useEffect)(()=>{C.isSuccess&&c.length>0&&_([...C.data.items.filter(e=>c.includes(e.id)).map(e=>e.recipe_version.recipe)])},[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)(H,{method:`post`,onSubmit:()=>E(),children:[(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.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)(Er,{variant:`info`,children:`Please select a rework step`}),g.length>0&&(0,p.jsxs)(H.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)(H.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)(H.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)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Comment`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsxs)(H.Group,{controlId:`runStep.remark`,children:[(0,p.jsx)(H.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)(B,{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)(B,{variant:`warning`,onClick:()=>r(!1),children:`Cancel`})]})})]}),!n&&(0,p.jsx)(B,{variant:`primary`,className:`mt-3`,onClick:()=>r(!0),children:`Set Rework`})]})},$R={items:[],amountOfPages:0,currentPage:0,totalItems:0,hasMore:!1},ez=()=>{let{environment:e}=(0,g.useParams)(),{runStep:t,run:n}=(0,d.useContext)(AL),r=(0,m.useQueries)({queries:[{queryKey:[`monitors`,t.process_module.module.equipment],queryFn:()=>t.process_module.module.equipment?he({equipment:t.process_module.module.equipment}):$R},{queryKey:[`ecn`,t.process_module.module],queryFn:()=>ie({module:t.process_module.module})},{queryKey:[`equipmentModule`,t.process_module.module],queryFn:()=>ne({id:t.process_module.module.id})},{queryKey:[`requirement`,t.id],queryFn:()=>je({run:n,step:t})}]}),[i,a,o,s]=r,[c,l]=(0,d.useState)(!0),{addReadingCallbackFn:u,removeReadingCallbackFn:f}=HI(),[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.filter(e=>e.isError).forEach((e,r)=>{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)(Qr,{fluid:!0,children:(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{className:`col-9`,children:[n.run_type===gt.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),n.run_type===gt.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)(HR,{}),(0,p.jsx)(VR,{}),t.is_skipped&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`badge bg-info`,children:`SKIPPED`})]})]}),(0,p.jsx)(lI,{run:n}),t.label&&(0,p.jsx)(jR,{label:t.label}),(0,p.jsx)(MR,{runStep:t}),t.is_finished&&(0,p.jsxs)(Er,{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)(Hr,{className:`rounded my-4`,children:(0,p.jsxs)(Hr.Body,{children:[(0,p.jsx)(Hr.Title,{className:`text-muted`,children:`Recipe`}),(0,p.jsxs)(Hr.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)(jL,{requirement:s.data.items[0],step:t,editOnly:!1}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(ML,{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)(aL,{run:n,runStep:t})]}),(0,p.jsxs)(`p`,{className:`pt-3`,children:[`Reading from scanner: `,h]}),(0,p.jsxs)(Pl,{className:`pm-3`,children:[(0,p.jsxs)(Zr,{children:[(0,p.jsx)(`h3`,{children:`Checklist`}),(0,p.jsx)(LR,{}),(0,p.jsx)(`h2`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(_I,{runStep:t})]}),(0,p.jsxs)(Zr,{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)(hI,{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)(zR,{}),(0,p.jsx)(`h3`,{className:`pt-3`,children:`Rework`}),(0,p.jsx)(QR,{})]})]}),(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)(ZR,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(YR,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(aF,{size:void 0,moduleId:t.process_module.module.id})})]})]}),(0,p.jsx)(qR,{pageSize:n.run_type===gt.RESEARCH?5:1e3,hideLabel:!0})]}),(0,p.jsx)(Zr,{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)(iF,{monitor:e},e.id)),a.data?.items.map(function(e){return(0,p.jsxs)(Hr,{className:`my-2`,children:[(0,p.jsxs)(Hr.Header,{children:[`ECN: `,e.ecn]}),(0,p.jsx)(Hr.Body,{children:(0,p.jsx)(Hr.Text,{children:(0,p.jsx)(LP,{children:e.description})})}),(0,p.jsxs)(Hr.Footer,{children:[e.date_created&&(0,p.jsxs)(p.Fragment,{children:[`Created by `,rF(e.date_created,`DD-MM-YY H:m`),` by `,e.owner.full_name]}),e.last_update&&(0,p.jsxs)(p.Fragment,{children:[` `,`· Updated by `,rF(e.last_update,`DD-MM-YY H:m`),` by `,e.owner.full_name]})]})]},e.id)})]})})]})})},tz=()=>{let[e,t]=(0,d.useState)(!1),{modalProperties:n}=(0,d.useContext)(AL),r=()=>{t(!1),n.show=!1};return(0,d.useEffect)(()=>{t(n.show)},[n]),(0,p.jsxs)(U,{show:e,size:`xl`,onHide:r,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:n.modalTitle})}),(0,p.jsx)(U.Body,{children:n.modalContent}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{variant:`secondary`,onClick:r,children:`Save`}),n.modalSaveButton]})]})};function nz(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ez,{}),(0,p.jsx)(tz,{})]})}function rz({run:e,runStep:t,showOnlyEmphasizedParameters:n,reloadRunStepFn:r}){let{data:i,refetch:a}=(0,m.useQuery)({queryKey:[`checklist`,t?.id],queryFn:()=>Re({runStep:t})}),o=(0,d.useMemo)(()=>i?.items,[i]),[s,c]=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Ne({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>He({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?!1: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)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{id:`tooltip-move-out`,children:l?`Finish step`:`Finish all parts before moving out`}),children:(0,p.jsx)(`span`,{children:(0,p.jsx)(B,{variant:l?`success`:`light`,onClick:()=>{f(!0),ze(t).finally(()=>{f(!1),r()})},disabled:u||!l,children:u?`Moving out...`:`Move out`})})})]}),(0,p.jsx)(eL,{run:e,runStep:t}),(0,p.jsx)(`h3`,{className:`mt-2`,children:`Parameters`}),(0,p.jsx)(hI,{runStep:t,showOnlyEmphasizedParameters:n}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsx)(`div`,{className:`col`,children:(0,p.jsx)(zR,{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)(ac,{children:Array.from({length:1}).map((e,t)=>(0,p.jsx)(ac.Item,{children:(0,p.jsxs)(W,{as:`div`,animation:`glow`,children:[(0,p.jsx)(W,{xs:17}),` `,(0,p.jsx)(W,{xs:4}),` `,(0,p.jsx)(W,{xs:6})]})},t))}),o&&(0,p.jsxs)(p.Fragment,{children:[o.length===0&&(0,p.jsx)(Er,{variant:`info`,children:`No checklist found`}),o.length>0&&(0,p.jsx)(ac,{children:o.map(e=>(0,p.jsx)(FR,{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)(_I,{runStep:t})]})]})]})}function iz({children:e}){let[t,n]=(0,d.useState)(!1);return(0,p.jsx)(jt,{children:(0,p.jsx)(pI.Provider,{value:{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}function az(){return(0,p.jsx)(Qr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}function oz({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{i((await fe({environment:n,withLocations:!0})).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)(H.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:(0,p.jsx)(Eu,{name:t,render:({field:{onChange:e,value:t}})=>(0,p.jsxs)(H.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 sz=Object.defineProperty,cz=Object.getOwnPropertySymbols,lz=Object.prototype.hasOwnProperty,uz=Object.prototype.propertyIsEnumerable,dz=(e,t,n)=>t in e?sz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fz=(e,t)=>{for(var n in t||(t={}))lz.call(t,n)&&dz(e,n,t[n]);if(cz)for(var n of cz(t))uz.call(t,n)&&dz(e,n,t[n]);return e},pz=(e,t)=>{var n={};for(var r in e)lz.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&cz)for(var r of cz(e))t.indexOf(r)<0&&uz.call(e,r)&&(n[r]=e[r]);return n},mz;(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})(mz||(mz={})),(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={}))})(mz||(mz={})),(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={}))})(mz||(mz={}));var hz=mz,gz={L:hz.QrCode.Ecc.LOW,M:hz.QrCode.Ecc.MEDIUM,Q:hz.QrCode.Ecc.QUARTILE,H:hz.QrCode.Ecc.HIGH},_z=128,vz=`L`,yz=`#FFFFFF`,bz=`#000000`,xz=!1,Sz=1,Cz=4,wz=0,Tz=.1;function Ez(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 Dz(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 Oz(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*Tz),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 kz(e,t){return t==null?e?Cz:wz:Math.max(Math.floor(t),0)}function Az({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(...hz.QrSegment.makeSegments(t)),e),[]);return hz.QrCode.encodeSegments(r,gz[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=kz(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:Oz(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:l,numCells:f,calculatedImageSettings:p}}var jz=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Mz=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=_z,level:a=vz,bgColor:o=yz,fgColor:s=bz,includeMargin:c=xz,minVersion:l=Sz,boostLevel:d,marginSize:f,imageSettings:p}=n,m=pz(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=pz(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}=Az({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=Dz(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,jz?t.fill(new Path2D(Ez(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=fz({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`,fz({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});Mz.displayName=`QRCodeCanvas`;var Nz=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=_z,level:a=vz,bgColor:o=yz,fgColor:s=bz,includeMargin:c=xz,minVersion:l=Sz,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=pz(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=Az({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=Dz(_,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=Ez(b,g);return u.default.createElement(`svg`,fz({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)});Nz.displayName=`QRCodeSVG`;function Pz({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{i((await de({room:n,pageSize:1e3})).items),o(!1)}catch(e){console.error(`Error fetching locations:`,e)}}e()},[n]),a?(0,p.jsx)(`p`,{children:`Loading locations...`}):(0,p.jsxs)(H.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:[(0,p.jsx)(H.Label,{children:`Select a storage location`}),(0,p.jsx)(Eu,{name:t,control:e,defaultValue:``,render:({field:{onChange:e,value:t}})=>(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(Pl,{children:r.map(n=>(0,p.jsx)(Zr,{xs:4,md:3,className:`mb-3`,children:(0,p.jsx)(Hr,{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)(Hr.Body,{children:[(0,p.jsx)(Hr.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)(Nz,{value:`/l/`+n.id.toString(),size:128}),` `]})]})})},n.id))})})})]})}var Fz=({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)(U,{show:e,size:`lg`,onHide:()=>t(!1),children:(0,p.jsxs)(H,{onSubmit:o(l),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Create new chemical`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(Hs,{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)(H.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)(H.Control.Feedback,{type:`invalid`,children:s.cas_number.message})]})]}),(0,p.jsxs)(Hs,{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)(H.Control,{as:`input`,id:`name`,...r(`name`,{required:`A name is required`}),isInvalid:s.name!==void 0}),s.name&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.name.message})]})]}),(0,p.jsxs)(Hs,{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)(H.Control,{as:`textarea`,rows:3,id:`description`,...r(`description`)}),s.description&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.description.message})]})]}),(0,p.jsxs)(Hs,{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)(H.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:ut.NON_STANDARD_PRODUCT,children:`Non standard product`}),(0,p.jsx)(`option`,{value:ut.STANDARD_PRODUCT,children:`Standard product`})]}),s.standard_product&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.standard_product.message})]})]}),(0,p.jsxs)(Hs,{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)(H.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:dt.SOLID,children:`Solid`}),(0,p.jsx)(`option`,{value:dt.LIQUID,children:`Liquid`}),(0,p.jsx)(`option`,{value:dt.GAS,children:`Gas`}),(0,p.jsx)(`option`,{value:dt.OTHER,children:`Other`})]}),s.physical_state&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.physical_state.message})]})]})]}),(0,p.jsx)(U.Footer,{children:(0,p.jsxs)(B,{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 Iz({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)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Search Existing Chemicals`}),(0,p.jsxs)(Pl,{children:[(0,p.jsx)(Eu,{name:t,control:e,render:({field:e})=>(0,p.jsx)(Jb,{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)(H.Control.Feedback,{type:`invalid`,children:r.chemical.message}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,className:`mt-2`,onClick:()=>s(!0),children:`Create New Chemical`})})]})]}),(0,p.jsx)(Fz,{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 Lz(e){return/\/l\/\d+$/.test(e)}function Rz(e){let t=e.match(/\/l\/(\d+)$/);return t?parseInt(t[1],10):null}var zz=[{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 Bz(){let e=new Date;return e.setFullYear(e.getFullYear()+5),e.toISOString().split(`T`)[0]}function Vz({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}=HI(),[l,u]=(0,d.useState)(null),{register:m,control:h,handleSubmit:_,watch:y,setValue:b,formState:{errors:x,isSubmitting:S}}=Id({defaultValues:{expire_date:Bz(),owner:{value:a?.id,label:a?.full_name}}}),C=y(`location`);(0,d.useEffect)(()=>{C&&le({id:C}).then(e=>i(e))},[C]);let w=(0,d.useId)(),T=(0,d.useCallback)(e=>{if(Lz(e)){let t=Rz(e);t!==null&&(le({id:t}).then(e=>i(e)),b(`location`,t))}e.startsWith(`reset-scan-location`)&&O()},[b]);(0,d.useEffect)(()=>(c(UI.WILD_CARD,w),s(UI.WILD_CARD,w,T),()=>c(UI.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)(H,{onSubmit:_(D),children:[!r&&(0,p.jsx)(Pz,{room:e,control:h,name:`location`}),r&&(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Scanned location`}),(0,p.jsx)(Zr,{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)(Nz,{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)(Iz,{control:h,errors:x,setValue:b,...m(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:h,...m(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Concentration`}),(0,p.jsxs)(Hs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...m(`concentration`,{required:`A concentration is required`}),isInvalid:x.concentration!==void 0}),x.concentration&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.concentration.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Amount`}),(0,p.jsxs)(Hs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...m(`amount`,{required:`An amount is required`}),isInvalid:x.amount!==void 0}),(0,p.jsx)(Eu,{name:`amount_unit`,control:h,render:({field:e})=>(0,p.jsxs)(_s,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(hs.Item,{eventKey:``,children:`(no unit)`},0),zz.map(e=>(0,p.jsxs)(hs.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),x.amount&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.amount.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Expire date`}),(0,p.jsx)(H.Control,{type:`date`,...m(`expire_date`,{required:`An expire date is required`}),isInvalid:x.expire_date!==void 0}),x.expire_date&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.expire_date.message})]}),(0,p.jsxs)(B,{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)(Er,{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)(Nz,{value:`reset-form`,size:100,className:`float-end`,onClick:n})]})]})]})}function Hz({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)(Eu,{name:`container_type`,control:e,render:({field:e})=>(0,p.jsx)(Jb,{isSearchable:!0,defaultOptions:!0,placeholder:`— Select a container type`,loadOptions:i,value:a(e.value),onChange:t=>{e.onChange(t?.value)},styles:Xb})})}function Uz({room:e,resetForm:t,location:n,setLocation:r}){let{user:i}=(0,d.useContext)(v),{environment:a}=(0,g.useParams)(),{addCallbackFn:o,removeCallbackFn:s}=HI(),[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&&le({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(Lz(e)){let t=Rz(e);t!==null&&(r(await le({id:t})),b(`location`,t));return}e.startsWith(`reset-scan-location`)&&w()},[r,b,w]);return(0,d.useEffect)(()=>(s(UI.WILD_CARD,T),o(UI.WILD_CARD,T,E),()=>s(UI.WILD_CARD,T)),[E]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(H,{onSubmit:_(async e=>{e.user=e.owner.value,l((await f.default.post(`create/chemical/container`,e)).data)}),children:[!n&&(0,p.jsx)(Pz,{room:e,control:h,name:`location`}),n&&(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Scanned location`}),(0,p.jsx)(Zr,{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)(Nz,{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)(Iz,{control:h,errors:x,setValue:b,...m(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:h,...m(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Concentration`}),(0,p.jsxs)(Hs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...m(`concentration`,{required:`An concentration is required`}),isInvalid:x.concentration!==void 0}),x.concentration&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.concentration.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Amount`}),(0,p.jsxs)(Hs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...m(`amount`,{required:`An amount is required`}),isInvalid:x.amount!==void 0}),(0,p.jsx)(Eu,{name:`amount_unit`,control:h,render:({field:e})=>(0,p.jsxs)(_s,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(hs.Item,{eventKey:``,children:`(no unit)`},0),zz.map(e=>(0,p.jsxs)(hs.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),x.amount&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.amount.message})]})]}),(0,p.jsxs)(Hs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(H.Label,{children:`Container type`}),(0,p.jsx)(Hz,{control:h,...m(`container_type`,{required:`Container type is required`}),errors:x}),x.container_type&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.container_type.message})]}),(0,p.jsxs)(H.Group,{className:`mb-3 w-50 w-25-sm`,children:[(0,p.jsx)(H.Label,{children:`Expire date`}),(0,p.jsx)(H.Control,{type:`date`,...m(`expire_date`,{required:`An expire date is required`}),isInvalid:x.expire_date!==void 0}),x.expire_date&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.expire_date.message})]}),(0,p.jsxs)(B,{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)(Er,{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)(Nz,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>t()})]})]})]})}function Wz(){let{environment:e}=(0,g.useParams)(),{addReadingCallbackFn:t,removeReadingCallbackFn:n,addCallbackFn:r,removeCallbackFn:i}=HI(),[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`);(0,d.useEffect)(()=>{A&&(x(A),_(A.building.site.has_external_chemical_labelling))},[A]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`);e&&ue({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&&le({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 j=(0,d.useCallback)(()=>{O({room:b}),y(null),C(null),u(null),c([]),m(!1)},[O,b]),M=(0,d.useId)();(0,d.useEffect)(()=>(t(M,o),()=>{n(M)}),[]);let ee=(0,d.useCallback)(async e=>{if(!e.includes(`/l/`)){if(y(e),e.includes(`/cc/`)){let t=e.split(`/cc/`)[1];u(await T({id:parseInt(t)}))}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)}}},[]);(0,d.useEffect)(()=>(i(UI.WILD_CARD,M),r(UI.WILD_CARD,M,ee),()=>i(UI.WILD_CARD,M)),[ee]);let te=(0,d.useId)();return(0,d.useEffect)(()=>(i(UI.RESET_FORM,te),r(UI.RESET_FORM,te,j),()=>i(UI.RESET_FORM,te)),[j]),(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)(oz,{control:w,name:`room`})}),(0,p.jsxs)(`p`,{className:`pt-3`,children:[`Reading from scanner: `,a]})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(Nz,{value:`reset-form`,size:100,className:`float-end`,onClick:j}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset form`})]})]}),b&&(0,p.jsx)(p.Fragment,{children:h?(0,p.jsxs)(Er,{children:[`Lab `,b.name,` has external labels, each chemical material should have a material from the internal supplier/warehouse`]}):(0,p.jsxs)(Er,{children:[`Lab `,b.name,` has no external labels, labels can be printed via the intake form`]})}),l&&(0,p.jsxs)(Er,{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&&(0,p.jsxs)(Il,{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)(Vz,{room:b,barcode:v,location:S,setLocation:C,resetForm:j}),!l&&b&&!h&&(0,p.jsx)(Uz,{room:b,location:S,setLocation:C,resetForm:j})]})}function Gz({badge_uuid:e}){return(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Card read: `,e]})}function Kz({user_id:e}){let[t,n]=(0,d.useState)(``);return(0,d.useEffect)(()=>{let t=`https://`+Yz+`/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()}`);n((await e.json()).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 qz(){return(0,p.jsx)(`div`,{})}var Jz=[`all`,`equipment`,`not_set`],Yz=document.getElementById(`root`)?.dataset.goldsteinEndpoint??``,Xz=`mock-token`,Zz=10,Qz=15;async function $z(e){let t=`https://`+Yz+`/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(!Jz.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 eB(){let e=(0,d.useRef)(null),[t,n]=(0,d.useState)(new Map);async function r(e){n(Rv(e.notifications_list,new Date,Zz,Qz))}function i(){let t=`
|
|
36
|
+
`+Error().stack),r=!1}return t.apply(this,arguments)},t)}var E={};function D(e,t){n.deprecationHandler!=null&&n.deprecationHandler(e,t),E[e]||(w(t),E[e]=!0)}n.suppressDeprecationWarnings=!1,n.deprecationHandler=null;function O(e){return typeof Function<`u`&&e instanceof Function||Object.prototype.toString.call(e)===`[object Function]`}function k(e){var t,n;for(n in e)o(e,n)&&(t=e[n],O(t)?this[n]=t:this[`_`+n]=t);this._config=e,this._dayOfMonthOrdinalParseLenient=RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+`|\\d{1,2}`)}function A(e,t){var n=f({},e),r;for(r in t)o(t,r)&&(a(e[r])&&a(t[r])?(n[r]={},f(n[r],e[r]),f(n[r],t[r])):t[r]==null?delete n[r]:n[r]=t[r]);for(r in e)o(e,r)&&!o(t,r)&&a(e[r])&&(n[r]=f({},n[r]));return n}function j(e){e!=null&&this.set(e)}var M=Object.keys?Object.keys:function(e){var t,n=[];for(t in e)o(e,t)&&n.push(t);return n},ee={sameDay:`[Today at] LT`,nextDay:`[Tomorrow at] LT`,nextWeek:`dddd [at] LT`,lastDay:`[Yesterday at] LT`,lastWeek:`[Last] dddd [at] LT`,sameElse:`L`};function te(e,t,n){var r=this._calendar[e]||this._calendar.sameElse;return O(r)?r.call(t,n):r}function N(e,t,n){var r=``+Math.abs(e),i=t-r.length;return(e>=0?n?`+`:``:`-`)+(10**Math.max(0,i)).toString().substr(1)+r}var ne=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,re=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ie={},ae={};function P(e,t,n,r){var i=r;typeof r==`string`&&(i=function(){return this[r]()}),e&&(ae[e]=i),t&&(ae[t[0]]=function(){return N(i.apply(this,arguments),t[1],t[2])}),n&&(ae[n]=function(){return this.localeData().ordinal(i.apply(this,arguments),e)})}function oe(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,``):e.replace(/\\/g,``)}function se(e){var t=e.match(ne),n,r;for(n=0,r=t.length;n<r;n++)ae[t[n]]?t[n]=ae[t[n]]:t[n]=oe(t[n]);return function(n){var i=``,a;for(a=0;a<r;a++)i+=O(t[a])?t[a].call(n,e):t[a];return i}}function ce(e,t){return e.isValid()?(t=le(t,e.localeData()),ie[t]=ie[t]||se(t),ie[t](e)):e.localeData().invalidDate()}function le(e,t){var n=5;function r(e){return t.longDateFormat(e)||e}for(re.lastIndex=0;n>=0&&re.test(e);)e=e.replace(re,r),re.lastIndex=0,--n;return e}var ue={LTS:`h:mm:ss A`,LT:`h:mm A`,L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`};function de(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toUpperCase()];return t||!n?t:(this._longDateFormat[e]=n.match(ne).map(function(e){return e===`MMMM`||e===`MM`||e===`DD`||e===`dddd`?e.slice(1):e}).join(``),this._longDateFormat[e])}var fe=`Invalid date`;function pe(){return this._invalidDate}var me=`%d`,he=/\d{1,2}/;function ge(e){return this._ordinal.replace(`%d`,e)}var _e={future:`in %s`,past:`%s ago`,s:`a few seconds`,ss:`%d seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,w:`a week`,ww:`%d weeks`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function ve(e,t,n,r){var i=this._relativeTime[n];return O(i)?i(e,t,n,r):i.replace(/%d/i,e)}function ye(e,t){var n=this._relativeTime[e>0?`future`:`past`];return O(n)?n(t):n.replace(/%s/i,t)}var be={D:`date`,dates:`date`,date:`date`,d:`day`,days:`day`,day:`day`,e:`weekday`,weekdays:`weekday`,weekday:`weekday`,E:`isoWeekday`,isoweekdays:`isoWeekday`,isoweekday:`isoWeekday`,DDD:`dayOfYear`,dayofyears:`dayOfYear`,dayofyear:`dayOfYear`,h:`hour`,hours:`hour`,hour:`hour`,ms:`millisecond`,milliseconds:`millisecond`,millisecond:`millisecond`,m:`minute`,minutes:`minute`,minute:`minute`,M:`month`,months:`month`,month:`month`,Q:`quarter`,quarters:`quarter`,quarter:`quarter`,s:`second`,seconds:`second`,second:`second`,gg:`weekYear`,weekyears:`weekYear`,weekyear:`weekYear`,GG:`isoWeekYear`,isoweekyears:`isoWeekYear`,isoweekyear:`isoWeekYear`,w:`week`,weeks:`week`,week:`week`,W:`isoWeek`,isoweeks:`isoWeek`,isoweek:`isoWeek`,y:`year`,years:`year`,year:`year`};function xe(e){return typeof e==`string`?be[e]||be[e.toLowerCase()]:void 0}function Se(e){var t={},n,r;for(r in e)o(e,r)&&(n=xe(r),n&&(t[n]=e[r]));return t}var Ce={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function we(e){var t=[],n;for(n in e)o(e,n)&&t.push({unit:n,priority:Ce[n]});return t.sort(function(e,t){return e.priority-t.priority}),t}var Te=/\d/,Ee=/\d\d/,De=/\d{3}/,Oe=/\d{4}/,ke=/[+-]?\d{6}/,Ae=/\d\d?/,je=/\d\d\d\d?/,Me=/\d\d\d\d\d\d?/,Ne=/\d{1,3}/,Pe=/\d{1,4}/,Fe=/[+-]?\d{1,6}/,Ie=/\d+/,Le=/[+-]?\d+/,Re=/Z|[+-]\d\d:?\d\d/gi,ze=/Z|[+-]\d\d(?::?\d\d)?/gi,Be=/[+-]?\d+(\.\d{1,3})?/,Ve=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,He=/^[1-9]\d?/,Ue=/^([1-9]\d|\d)/,We={};function F(e,t,n){We[e]=O(t)?t:function(e,r){return e&&n?n:t}}function Ge(e,t){return o(We,e)?We[e](t._strict,t._locale):new RegExp(Ke(e))}function Ke(e){return qe(e.replace(`\\`,``).replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,n,r,i){return t||n||r||i}))}function qe(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,`\\$&`)}function Je(e){return e<0?Math.ceil(e)||0:Math.floor(e)}function Ye(e){var t=+e,n=0;return t!==0&&isFinite(t)&&(n=Je(t)),n}var Xe={};function Ze(e,t){var n,r=t,i;for(typeof e==`string`&&(e=[e]),l(t)&&(r=function(e,n){n[t]=Ye(e)}),i=e.length,n=0;n<i;n++)Xe[e[n]]=r}function Qe(e,t){Ze(e,function(e,n,r,i){r._w=r._w||{},t(e,r._w,r,i)})}function $e(e,t,n){t!=null&&o(Xe,e)&&Xe[e](t,n._a,n,e)}function et(e){return e%4==0&&e%100!=0||e%400==0}var tt=0,nt=1,rt=2,it=3,at=4,ot=5,st=6,ct=7,lt=8;P(`Y`,0,0,function(){var e=this.year();return e<=9999?N(e,4):`+`+e}),P(0,[`YY`,2],0,function(){return this.year()%100}),P(0,[`YYYY`,4],0,`year`),P(0,[`YYYYY`,5],0,`year`),P(0,[`YYYYYY`,6,!0],0,`year`),F(`Y`,Le),F(`YY`,Ae,Ee),F(`YYYY`,Pe,Oe),F(`YYYYY`,Fe,ke),F(`YYYYYY`,Fe,ke),Ze([`YYYYY`,`YYYYYY`],tt),Ze(`YYYY`,function(e,t){t[tt]=e.length===2?n.parseTwoDigitYear(e):Ye(e)}),Ze(`YY`,function(e,t){t[tt]=n.parseTwoDigitYear(e)}),Ze(`Y`,function(e,t){t[tt]=parseInt(e,10)});function ut(e){return et(e)?366:365}n.parseTwoDigitYear=function(e){return Ye(e)+(Ye(e)>68?1900:2e3)};var dt=pt(`FullYear`,!0);function ft(){return et(this.year())}function pt(e,t){return function(r){return r==null?mt(this,e):(ht(this,e,r),n.updateOffset(this,t),this)}}function mt(e,t){if(!e.isValid())return NaN;var n=e._d,r=e._isUTC;switch(t){case`Milliseconds`:return r?n.getUTCMilliseconds():n.getMilliseconds();case`Seconds`:return r?n.getUTCSeconds():n.getSeconds();case`Minutes`:return r?n.getUTCMinutes():n.getMinutes();case`Hours`:return r?n.getUTCHours():n.getHours();case`Date`:return r?n.getUTCDate():n.getDate();case`Day`:return r?n.getUTCDay():n.getDay();case`Month`:return r?n.getUTCMonth():n.getMonth();case`FullYear`:return r?n.getUTCFullYear():n.getFullYear();default:return NaN}}function ht(e,t,n){var r,i,a,o,s;if(!(!e.isValid()||isNaN(n))){switch(r=e._d,i=e._isUTC,t){case`Milliseconds`:i?r.setUTCMilliseconds(n):r.setMilliseconds(n);return;case`Seconds`:i?r.setUTCSeconds(n):r.setSeconds(n);return;case`Minutes`:i?r.setUTCMinutes(n):r.setMinutes(n);return;case`Hours`:i?r.setUTCHours(n):r.setHours(n);return;case`Date`:i?r.setUTCDate(n):r.setDate(n);return;case`FullYear`:break;default:return}a=n,o=e.month(),s=e.date(),s=s===29&&o===1&&!et(a)?28:s,i?r.setUTCFullYear(a,o,s):r.setFullYear(a,o,s)}}function gt(e){return e=xe(e),O(this[e])?this[e]():this}function _t(e,t){if(typeof e==`object`){e=Se(e);var n=we(e),r,i=n.length;for(r=0;r<i;r++)this[n[r].unit](e[n[r].unit])}else if(e=xe(e),O(this[e]))return this[e](t);return this}function vt(e,t){return(e%t+t)%t}var yt=Array.prototype.indexOf?Array.prototype.indexOf:function(e){var t;for(t=0;t<this.length;++t)if(this[t]===e)return t;return-1};function bt(e,t){if(isNaN(e)||isNaN(t))return NaN;var n=vt(t,12);return e+=(t-n)/12,n===1?et(e)?29:28:31-n%7%2}P(`M`,[`MM`,2],`Mo`,function(){return this.month()+1}),P(`MMM`,0,0,function(e){return this.localeData().monthsShort(this,e)}),P(`MMMM`,0,0,function(e){return this.localeData().months(this,e)}),F(`M`,Ae,He),F(`MM`,Ae,Ee),F(`MMM`,function(e,t){return t.monthsShortRegex(e)}),F(`MMMM`,function(e,t){return t.monthsRegex(e)}),Ze([`M`,`MM`],function(e,t){t[nt]=Ye(e)-1}),Ze([`MMM`,`MMMM`],function(e,t,n,r){var i=n._locale.monthsParse(e,r,n._strict);i==null?h(n).invalidMonth=e:t[nt]=i});var xt=`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),St=`Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec`.split(`_`),Ct=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,wt=Ve,Tt=Ve;function Et(e,t){return e?i(this._months)?this._months[e.month()]:this._months[(this._months.isFormat||Ct).test(t)?`format`:`standalone`][e.month()]:i(this._months)?this._months:this._months.standalone}function Dt(e,t){return e?i(this._monthsShort)?this._monthsShort[e.month()]:this._monthsShort[Ct.test(t)?`format`:`standalone`][e.month()]:i(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Ot(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],r=0;r<12;++r)a=p([2e3,r]),this._shortMonthsParse[r]=this.monthsShort(a,``).toLocaleLowerCase(),this._longMonthsParse[r]=this.months(a,``).toLocaleLowerCase();return n?t===`MMM`?(i=yt.call(this._shortMonthsParse,o),i===-1?null:i):(i=yt.call(this._longMonthsParse,o),i===-1?null:i):t===`MMM`?(i=yt.call(this._shortMonthsParse,o),i===-1?(i=yt.call(this._longMonthsParse,o),i===-1?null:i):i):(i=yt.call(this._longMonthsParse,o),i===-1?(i=yt.call(this._shortMonthsParse,o),i===-1?null:i):i)}function kt(e,t,n){var r,i,a;if(this._monthsParseExact)return Ot.call(this,e,t,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),r=0;r<12;r++)if(i=p([2e3,r]),n&&!this._longMonthsParse[r]&&(this._longMonthsParse[r]=RegExp(`^`+this.months(i,``).replace(`.`,``)+`$`,`i`),this._shortMonthsParse[r]=RegExp(`^`+this.monthsShort(i,``).replace(`.`,``)+`$`,`i`)),!n&&!this._monthsParse[r]&&(a=`^`+this.months(i,``)+`|^`+this.monthsShort(i,``),this._monthsParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`MMMM`&&this._longMonthsParse[r].test(e)||n&&t===`MMM`&&this._shortMonthsParse[r].test(e)||!n&&this._monthsParse[r].test(e))return r}function At(e,t){if(!e.isValid())return e;if(typeof t==`string`){if(/^\d+$/.test(t))t=Ye(t);else if(t=e.localeData().monthsParse(t),!l(t))return e}var n=t,r=e.date();return r=r<29?r:Math.min(r,bt(e.year(),n)),e._isUTC?e._d.setUTCMonth(n,r):e._d.setMonth(n,r),e}function jt(e){return e==null?mt(this,`Month`):(At(this,e),n.updateOffset(this,!0),this)}function Mt(){return bt(this.year(),this.month())}function Nt(e){return this._monthsParseExact?(o(this,`_monthsRegex`)||Pt.call(this),e?this._monthsShortStrictRegex:this._monthsShortRegex):(o(this,`_monthsShortRegex`)||(this._monthsShortRegex=wt),this._monthsShortStrictRegex&&e?this._monthsShortStrictRegex:this._monthsShortRegex)}function I(e){return this._monthsParseExact?(o(this,`_monthsRegex`)||Pt.call(this),e?this._monthsStrictRegex:this._monthsRegex):(o(this,`_monthsRegex`)||(this._monthsRegex=Tt),this._monthsStrictRegex&&e?this._monthsStrictRegex:this._monthsRegex)}function Pt(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i,a,o,s;for(i=0;i<12;i++)a=p([2e3,i]),o=qe(this.monthsShort(a,``)),s=qe(this.months(a,``)),t.push(o),n.push(s),r.push(s),r.push(o);t.sort(e),n.sort(e),r.sort(e),this._monthsRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._monthsShortStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function Ft(e,t,n,r,i,a,o){var s;return e<100&&e>=0?(s=new Date(e+400,t,n,r,i,a,o),isFinite(s.getFullYear())&&s.setFullYear(e)):s=new Date(e,t,n,r,i,a,o),s}function It(e){var t,n;return e<100&&e>=0?(n=Array.prototype.slice.call(arguments),n[0]=e+400,t=new Date(Date.UTC.apply(null,n)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e)):t=new Date(Date.UTC.apply(null,arguments)),t}function Lt(e,t,n){var r=7+t-n;return-((7+It(e,0,r).getUTCDay()-t)%7)+r-1}function Rt(e,t,n,r,i){var a=(7+n-r)%7,o=Lt(e,r,i),s=1+7*(t-1)+a+o,c,l;return s<=0?(c=e-1,l=ut(c)+s):s>ut(e)?(c=e+1,l=s-ut(e)):(c=e,l=s),{year:c,dayOfYear:l}}function zt(e,t,n){var r=Lt(e.year(),t,n),i=Math.floor((e.dayOfYear()-r-1)/7)+1,a,o;return i<1?(o=e.year()-1,a=i+Bt(o,t,n)):i>Bt(e.year(),t,n)?(a=i-Bt(e.year(),t,n),o=e.year()+1):(o=e.year(),a=i),{week:a,year:o}}function Bt(e,t,n){var r=Lt(e,t,n),i=Lt(e+1,t,n);return(ut(e)-r+i)/7}P(`w`,[`ww`,2],`wo`,`week`),P(`W`,[`WW`,2],`Wo`,`isoWeek`),F(`w`,Ae,He),F(`ww`,Ae,Ee),F(`W`,Ae,He),F(`WW`,Ae,Ee),Qe([`w`,`ww`,`W`,`WW`],function(e,t,n,r){t[r.substr(0,1)]=Ye(e)});function Vt(e){return zt(e,this._week.dow,this._week.doy).week}var Ht={dow:0,doy:6};function Ut(){return this._week.dow}function Wt(){return this._week.doy}function Gt(e){var t=this.localeData().week(this);return e==null?t:this.add((e-t)*7,`d`)}function L(e){var t=zt(this,1,4).week;return e==null?t:this.add((e-t)*7,`d`)}P(`d`,0,`do`,`day`),P(`dd`,0,0,function(e){return this.localeData().weekdaysMin(this,e)}),P(`ddd`,0,0,function(e){return this.localeData().weekdaysShort(this,e)}),P(`dddd`,0,0,function(e){return this.localeData().weekdays(this,e)}),P(`e`,0,0,`weekday`),P(`E`,0,0,`isoWeekday`),F(`d`,Ae),F(`e`,Ae),F(`E`,Ae),F(`dd`,function(e,t){return t.weekdaysMinRegex(e)}),F(`ddd`,function(e,t){return t.weekdaysShortRegex(e)}),F(`dddd`,function(e,t){return t.weekdaysRegex(e)}),Qe([`dd`,`ddd`,`dddd`],function(e,t,n,r){var i=n._locale.weekdaysParse(e,r,n._strict);i==null?h(n).invalidWeekday=e:t.d=i}),Qe([`d`,`e`,`E`],function(e,t,n,r){t[r]=Ye(e)});function Kt(e,t){return typeof e==`string`?isNaN(e)?(e=t.weekdaysParse(e),typeof e==`number`?e:null):parseInt(e,10):e}function qt(e,t){return typeof e==`string`?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}function Jt(e,t){return e.slice(t,7).concat(e.slice(0,t))}var R=`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),Yt=`Sun_Mon_Tue_Wed_Thu_Fri_Sat`.split(`_`),Xt=`Su_Mo_Tu_We_Th_Fr_Sa`.split(`_`),Zt=Ve,Qt=Ve,$t=Ve;function en(e,t){var n=i(this._weekdays)?this._weekdays:this._weekdays[e&&e!==!0&&this._weekdays.isFormat.test(t)?`format`:`standalone`];return e===!0?Jt(n,this._week.dow):e?n[e.day()]:n}function tn(e){return e===!0?Jt(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort}function nn(e){return e===!0?Jt(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin}function rn(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],r=0;r<7;++r)a=p([2e3,1]).day(r),this._minWeekdaysParse[r]=this.weekdaysMin(a,``).toLocaleLowerCase(),this._shortWeekdaysParse[r]=this.weekdaysShort(a,``).toLocaleLowerCase(),this._weekdaysParse[r]=this.weekdays(a,``).toLocaleLowerCase();return n?t===`dddd`?(i=yt.call(this._weekdaysParse,o),i===-1?null:i):t===`ddd`?(i=yt.call(this._shortWeekdaysParse,o),i===-1?null:i):(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i):t===`dddd`?(i=yt.call(this._weekdaysParse,o),i!==-1||(i=yt.call(this._shortWeekdaysParse,o),i!==-1)?i:(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i)):t===`ddd`?(i=yt.call(this._shortWeekdaysParse,o),i!==-1||(i=yt.call(this._weekdaysParse,o),i!==-1)?i:(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i)):(i=yt.call(this._minWeekdaysParse,o),i!==-1||(i=yt.call(this._weekdaysParse,o),i!==-1)?i:(i=yt.call(this._shortWeekdaysParse,o),i===-1?null:i))}function an(e,t,n){var r,i,a;if(this._weekdaysParseExact)return rn.call(this,e,t,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),r=0;r<7;r++)if(i=p([2e3,1]).day(r),n&&!this._fullWeekdaysParse[r]&&(this._fullWeekdaysParse[r]=RegExp(`^`+this.weekdays(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._shortWeekdaysParse[r]=RegExp(`^`+this.weekdaysShort(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._minWeekdaysParse[r]=RegExp(`^`+this.weekdaysMin(i,``).replace(`.`,`\\.?`)+`$`,`i`)),this._weekdaysParse[r]||(a=`^`+this.weekdays(i,``)+`|^`+this.weekdaysShort(i,``)+`|^`+this.weekdaysMin(i,``),this._weekdaysParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`dddd`&&this._fullWeekdaysParse[r].test(e)||n&&t===`ddd`&&this._shortWeekdaysParse[r].test(e)||n&&t===`dd`&&this._minWeekdaysParse[r].test(e)||!n&&this._weekdaysParse[r].test(e))return r}function on(e){if(!this.isValid())return e==null?NaN:this;var t=mt(this,`Day`);return e==null?t:(e=Kt(e,this.localeData()),this.add(e-t,`d`))}function sn(e){if(!this.isValid())return e==null?NaN:this;var t=(this.day()+7-this.localeData()._week.dow)%7;return e==null?t:this.add(e-t,`d`)}function cn(e){if(!this.isValid())return e==null?NaN:this;if(e!=null){var t=qt(e,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function ln(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||fn.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(o(this,`_weekdaysRegex`)||(this._weekdaysRegex=Zt),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)}function un(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||fn.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(o(this,`_weekdaysShortRegex`)||(this._weekdaysShortRegex=Qt),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function dn(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||fn.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(o(this,`_weekdaysMinRegex`)||(this._weekdaysMinRegex=$t),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function fn(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i=[],a,o,s,c,l;for(a=0;a<7;a++)o=p([2e3,1]).day(a),s=qe(this.weekdaysMin(o,``)),c=qe(this.weekdaysShort(o,``)),l=qe(this.weekdays(o,``)),t.push(s),n.push(c),r.push(l),i.push(s),i.push(c),i.push(l);t.sort(e),n.sort(e),r.sort(e),i.sort(e),this._weekdaysRegex=RegExp(`^(`+i.join(`|`)+`)`,`i`),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._weekdaysShortStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._weekdaysMinStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function pn(){return this.hours()%12||12}function mn(){return this.hours()||24}P(`H`,[`HH`,2],0,`hour`),P(`h`,[`hh`,2],0,pn),P(`k`,[`kk`,2],0,mn),P(`hmm`,0,0,function(){return``+pn.apply(this)+N(this.minutes(),2)}),P(`hmmss`,0,0,function(){return``+pn.apply(this)+N(this.minutes(),2)+N(this.seconds(),2)}),P(`Hmm`,0,0,function(){return``+this.hours()+N(this.minutes(),2)}),P(`Hmmss`,0,0,function(){return``+this.hours()+N(this.minutes(),2)+N(this.seconds(),2)});function hn(e,t){P(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}hn(`a`,!0),hn(`A`,!1);function gn(e,t){return t._meridiemParse}F(`a`,gn),F(`A`,gn),F(`H`,Ae,Ue),F(`h`,Ae,He),F(`k`,Ae,He),F(`HH`,Ae,Ee),F(`hh`,Ae,Ee),F(`kk`,Ae,Ee),F(`hmm`,je),F(`hmmss`,Me),F(`Hmm`,je),F(`Hmmss`,Me),Ze([`H`,`HH`],it),Ze([`k`,`kk`],function(e,t,n){var r=Ye(e);t[it]=r===24?0:r}),Ze([`a`,`A`],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),Ze([`h`,`hh`],function(e,t,n){t[it]=Ye(e),h(n).bigHour=!0}),Ze(`hmm`,function(e,t,n){var r=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r)),h(n).bigHour=!0}),Ze(`hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r,2)),t[ot]=Ye(e.substr(i)),h(n).bigHour=!0}),Ze(`Hmm`,function(e,t,n){var r=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r))}),Ze(`Hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r,2)),t[ot]=Ye(e.substr(i))});function _n(e){return(e+``).toLowerCase().charAt(0)===`p`}var vn=/[ap]\.?m?\.?/i,yn=pt(`Hours`,!0);function z(e,t,n){return e>11?n?`pm`:`PM`:n?`am`:`AM`}var bn={calendar:ee,longDateFormat:ue,invalidDate:fe,ordinal:me,dayOfMonthOrdinalParse:he,relativeTime:_e,months:xt,monthsShort:St,week:Ht,weekdays:R,weekdaysMin:Xt,weekdaysShort:Yt,meridiemParse:vn},xn={},Sn={},Cn;function wn(e,t){var n,r=Math.min(e.length,t.length);for(n=0;n<r;n+=1)if(e[n]!==t[n])return n;return r}function Tn(e){return e&&e.toLowerCase().replace(`_`,`-`)}function En(e){for(var t=0,n,r,i,a;t<e.length;){for(a=Tn(e[t]).split(`-`),n=a.length,r=Tn(e[t+1]),r=r?r.split(`-`):null;n>0;){if(i=On(a.slice(0,n).join(`-`)),i)return i;if(r&&r.length>=n&&wn(a,r)>=n-1)break;n--}t++}return Cn}function Dn(e){return!!(e&&e.match(`^[^/\\\\]*$`))}function On(e){var n=null,r;if(xn[e]===void 0&&t!==void 0&&t&&t.exports&&Dn(e))try{n=Cn._abbr,r=require,r(`./locale/`+e),kn(n)}catch{xn[e]=null}return xn[e]}function kn(e,t){var n;return e&&(n=c(t)?Mn(e):An(e,t),n?Cn=n:typeof console<`u`&&console.warn&&console.warn(`Locale `+e+` not found. Did you forget to load it?`)),Cn._abbr}function An(e,t){if(t!==null){var n,r=bn;if(t.abbr=e,xn[e]!=null)D(`defineLocaleOverride`,`use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.`),r=xn[e]._config;else if(t.parentLocale!=null)if(xn[t.parentLocale]!=null)r=xn[t.parentLocale]._config;else if(n=On(t.parentLocale),n!=null)r=n._config;else return Sn[t.parentLocale]||(Sn[t.parentLocale]=[]),Sn[t.parentLocale].push({name:e,config:t}),null;return xn[e]=new j(A(r,t)),Sn[e]&&Sn[e].forEach(function(e){An(e.name,e.config)}),kn(e),xn[e]}else return delete xn[e],null}function jn(e,t){if(t!=null){var n,r,i=bn;xn[e]!=null&&xn[e].parentLocale!=null?xn[e].set(A(xn[e]._config,t)):(r=On(e),r!=null&&(i=r._config),t=A(i,t),r??(t.abbr=e),n=new j(t),n.parentLocale=xn[e],xn[e]=n),kn(e)}else xn[e]!=null&&(xn[e].parentLocale==null?xn[e]!=null&&delete xn[e]:(xn[e]=xn[e].parentLocale,e===kn()&&kn(e)));return xn[e]}function Mn(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return Cn;if(!i(e)){if(t=On(e),t)return t;e=[e]}return En(e)}function Nn(){return M(xn)}function Pn(e){var t,n=e._a;return n&&h(e).overflow===-2&&(t=n[nt]<0||n[nt]>11?nt:n[rt]<1||n[rt]>bt(n[tt],n[nt])?rt:n[it]<0||n[it]>24||n[it]===24&&(n[at]!==0||n[ot]!==0||n[st]!==0)?it:n[at]<0||n[at]>59?at:n[ot]<0||n[ot]>59?ot:n[st]<0||n[st]>999?st:-1,h(e)._overflowDayOfYear&&(t<tt||t>rt)&&(t=rt),h(e)._overflowWeeks&&t===-1&&(t=ct),h(e)._overflowWeekday&&t===-1&&(t=lt),h(e).overflow=t),e}var Fn=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,In=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ln=/Z|[+-]\d\d(?::?\d\d)?/,Rn=[[`YYYYYY-MM-DD`,/[+-]\d{6}-\d\d-\d\d/],[`YYYY-MM-DD`,/\d{4}-\d\d-\d\d/],[`GGGG-[W]WW-E`,/\d{4}-W\d\d-\d/],[`GGGG-[W]WW`,/\d{4}-W\d\d/,!1],[`YYYY-DDD`,/\d{4}-\d{3}/],[`YYYY-MM`,/\d{4}-\d\d/,!1],[`YYYYYYMMDD`,/[+-]\d{10}/],[`YYYYMMDD`,/\d{8}/],[`GGGG[W]WWE`,/\d{4}W\d{3}/],[`GGGG[W]WW`,/\d{4}W\d{2}/,!1],[`YYYYDDD`,/\d{7}/],[`YYYYMM`,/\d{6}/,!1],[`YYYY`,/\d{4}/,!1]],zn=[[`HH:mm:ss.SSSS`,/\d\d:\d\d:\d\d\.\d+/],[`HH:mm:ss,SSSS`,/\d\d:\d\d:\d\d,\d+/],[`HH:mm:ss`,/\d\d:\d\d:\d\d/],[`HH:mm`,/\d\d:\d\d/],[`HHmmss.SSSS`,/\d\d\d\d\d\d\.\d+/],[`HHmmss,SSSS`,/\d\d\d\d\d\d,\d+/],[`HHmmss`,/\d\d\d\d\d\d/],[`HHmm`,/\d\d\d\d/],[`HH`,/\d\d/]],Bn=/^\/?Date\((-?\d+)/i,Vn=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,Hn={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Un(e){var t,n,r=e._i,i=Fn.exec(r)||In.exec(r),a,o,s,c,l=Rn.length,u=zn.length;if(i){for(h(e).iso=!0,t=0,n=l;t<n;t++)if(Rn[t][1].exec(i[1])){o=Rn[t][0],a=Rn[t][2]!==!1;break}if(o==null){e._isValid=!1;return}if(i[3]){for(t=0,n=u;t<n;t++)if(zn[t][1].exec(i[3])){s=(i[2]||` `)+zn[t][0];break}if(s==null){e._isValid=!1;return}}if(!a&&s!=null){e._isValid=!1;return}if(i[4])if(Ln.exec(i[4]))c=`Z`;else{e._isValid=!1;return}e._f=o+(s||``)+(c||``),tr(e)}else e._isValid=!1}function Wn(e,t,n,r,i,a){var o=[Gn(e),St.indexOf(t),parseInt(n,10),parseInt(r,10),parseInt(i,10)];return a&&o.push(parseInt(a,10)),o}function Gn(e){var t=parseInt(e,10);return t<=49?2e3+t:t<=999?1900+t:t}function Kn(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).replace(/^\s\s*/,``).replace(/\s\s*$/,``)}function qn(e,t,n){return e&&Yt.indexOf(e)!==new Date(t[0],t[1],t[2]).getDay()?(h(n).weekdayMismatch=!0,n._isValid=!1,!1):!0}function Jn(e,t,n){if(e)return Hn[e];if(t)return 0;var r=parseInt(n,10),i=r%100;return(r-i)/100*60+i}function Yn(e){var t=Vn.exec(Kn(e._i)),n;if(t){if(n=Wn(t[4],t[3],t[2],t[5],t[6],t[7]),!qn(t[1],n,e))return;e._a=n,e._tzm=Jn(t[8],t[9],t[10]),e._d=It.apply(null,e._a),e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),h(e).rfc2822=!0}else e._isValid=!1}function Xn(e){var t=Bn.exec(e._i);if(t!==null){e._d=new Date(+t[1]);return}if(Un(e),e._isValid===!1)delete e._isValid;else return;if(Yn(e),e._isValid===!1)delete e._isValid;else return;e._strict?e._isValid=!1:n.createFromInputFallback(e)}n.createFromInputFallback=T(`value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.`,function(e){e._d=new Date(e._i+(e._useUTC?` UTC`:``))});function Zn(e,t,n){return e??t??n}function Qn(e){var t=new Date(n.now());return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function $n(e){var t,n,r=[],i,a,o;if(!e._d){for(i=Qn(e),e._w&&e._a[rt]==null&&e._a[nt]==null&&er(e),e._dayOfYear!=null&&(o=Zn(e._a[tt],i[tt]),(e._dayOfYear>ut(o)||e._dayOfYear===0)&&(h(e)._overflowDayOfYear=!0),n=It(o,0,e._dayOfYear),e._a[nt]=n.getUTCMonth(),e._a[rt]=n.getUTCDate()),t=0;t<3&&e._a[t]==null;++t)e._a[t]=r[t]=i[t];for(;t<7;t++)e._a[t]=r[t]=e._a[t]==null?+(t===2):e._a[t];e._a[it]===24&&e._a[at]===0&&e._a[ot]===0&&e._a[st]===0&&(e._nextDay=!0,e._a[it]=0),e._d=(e._useUTC?It:Ft).apply(null,r),a=e._useUTC?e._d.getUTCDay():e._d.getDay(),e._tzm!=null&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[it]=24),e._w&&e._w.d!==void 0&&e._w.d!==a&&(h(e).weekdayMismatch=!0)}}function er(e){var t=e._w,n,r,i,a,o,s,c,l;t.GG!=null||t.W!=null||t.E!=null?(a=1,o=4,n=Zn(t.GG,e._a[tt],zt(lr(),1,4).year),r=Zn(t.W,1),i=Zn(t.E,1),(i<1||i>7)&&(c=!0)):(a=e._locale._week.dow,o=e._locale._week.doy,l=zt(lr(),a,o),n=Zn(t.gg,e._a[tt],l.year),r=Zn(t.w,l.week),t.d==null?t.e==null?i=a:(i=t.e+a,(t.e<0||t.e>6)&&(c=!0)):(i=t.d,(i<0||i>6)&&(c=!0))),r<1||r>Bt(n,a,o)?h(e)._overflowWeeks=!0:c==null?(s=Rt(n,r,i,a,o),e._a[tt]=s.year,e._dayOfYear=s.dayOfYear):h(e)._overflowWeekday=!0}n.ISO_8601=function(){},n.RFC_2822=function(){};function tr(e){if(e._f===n.ISO_8601){Un(e);return}if(e._f===n.RFC_2822){Yn(e);return}e._a=[],h(e).empty=!0;var t=``+e._i,r,i,a,o,s,c=t.length,l=0,u,d;for(a=le(e._f,e._locale).match(ne)||[],d=a.length,r=0;r<d;r++)o=a[r],i=(t.match(Ge(o,e))||[])[0],i&&(s=t.substr(0,t.indexOf(i)),s.length>0&&h(e).unusedInput.push(s),t=t.slice(t.indexOf(i)+i.length),l+=i.length),ae[o]?(i?h(e).empty=!1:h(e).unusedTokens.push(o),$e(o,i,e)):e._strict&&!i&&h(e).unusedTokens.push(o);h(e).charsLeftOver=c-l,t.length>0&&h(e).unusedInput.push(t),e._a[it]<=12&&h(e).bigHour===!0&&e._a[it]>0&&(h(e).bigHour=void 0),h(e).parsedDateParts=e._a.slice(0),h(e).meridiem=e._meridiem,e._a[it]=nr(e._locale,e._a[it],e._meridiem),u=h(e).era,u!==null&&(e._a[tt]=e._locale.erasConvertYear(u,e._a[tt])),$n(e),Pn(e)}function nr(e,t,n){var r;return n==null?t:e.meridiemHour==null?e.isPM==null?t:(r=e.isPM(n),r&&t<12&&(t+=12),!r&&t===12&&(t=0),t):e.meridiemHour(t,n)}function rr(e){var t,n,r,i,a,o,s=!1,c=e._f.length;if(c===0){h(e).invalidFormat=!0,e._d=new Date(NaN);return}for(i=0;i<c;i++)a=0,o=!1,t=x({},e),e._useUTC!=null&&(t._useUTC=e._useUTC),t._f=e._f[i],tr(t),_(t)&&(o=!0),a+=h(t).charsLeftOver,a+=h(t).unusedTokens.length*10,h(t).score=a,s?a<r&&(r=a,n=t):(r==null||a<r||o)&&(r=a,n=t,o&&(s=!0));f(e,n||t)}function ir(e){if(!e._d){var t=Se(e._i),n=t.day===void 0?t.date:t.day;e._a=d([t.year,t.month,n,t.hour,t.minute,t.second,t.millisecond],function(e){return e&&parseInt(e,10)}),$n(e)}}function ar(e){var t=new S(Pn(or(e)));return t._nextDay&&(t.add(1,`d`),t._nextDay=void 0),t}function or(e){var t=e._i,n=e._f;return e._locale=e._locale||Mn(e._l),t===null||n===void 0&&t===``?v({nullInput:!0}):(typeof t==`string`&&(e._i=t=e._locale.preparse(t)),C(t)?new S(Pn(t)):(u(t)?e._d=t:i(n)?rr(e):n?tr(e):sr(e),_(e)||(e._d=null),e))}function sr(e){var t=e._i;c(t)?e._d=new Date(n.now()):u(t)?e._d=new Date(t.valueOf()):typeof t==`string`?Xn(e):i(t)?(e._a=d(t.slice(0),function(e){return parseInt(e,10)}),$n(e)):a(t)?ir(e):l(t)?e._d=new Date(t):n.createFromInputFallback(e)}function cr(e,t,n,r,o){var c={};return(t===!0||t===!1)&&(r=t,t=void 0),(n===!0||n===!1)&&(r=n,n=void 0),(a(e)&&s(e)||i(e)&&e.length===0)&&(e=void 0),c._isAMomentObject=!0,c._useUTC=c._isUTC=o,c._l=n,c._i=e,c._f=t,c._strict=r,ar(c)}function lr(e,t,n,r){return cr(e,t,n,r,!1)}var ur=T(`moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/`,function(){var e=lr.apply(null,arguments);return this.isValid()&&e.isValid()?e<this?this:e:v()}),dr=T(`moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/`,function(){var e=lr.apply(null,arguments);return this.isValid()&&e.isValid()?e>this?this:e:v()});function fr(e,t){var n,r;if(t.length===1&&i(t[0])&&(t=t[0]),!t.length)return lr();for(n=t[0],r=1;r<t.length;++r)(!t[r].isValid()||t[r][e](n))&&(n=t[r]);return n}function pr(){return fr(`isBefore`,[].slice.call(arguments,0))}function mr(){return fr(`isAfter`,[].slice.call(arguments,0))}var hr=function(){return Date.now?Date.now():+new Date},gr=[`year`,`quarter`,`month`,`week`,`day`,`hour`,`minute`,`second`,`millisecond`];function _r(e){var t,n=!1,r,i=gr.length;for(t in e)if(o(e,t)&&!(yt.call(gr,t)!==-1&&(e[t]==null||!isNaN(e[t]))))return!1;for(r=0;r<i;++r)if(e[gr[r]]){if(n)return!1;parseFloat(e[gr[r]])!==Ye(e[gr[r]])&&(n=!0)}return!0}function vr(){return this._isValid}function yr(){return Vr(NaN)}function br(e){var t=Se(e),n=t.year||0,r=t.quarter||0,i=t.month||0,a=t.week||t.isoWeek||0,o=t.day||0,s=t.hour||0,c=t.minute||0,l=t.second||0,u=t.millisecond||0;this._isValid=_r(t),this._milliseconds=+u+l*1e3+c*6e4+s*1e3*60*60,this._days=+o+a*7,this._months=+i+r*3+n*12,this._data={},this._locale=Mn(),this._bubble()}function xr(e){return e instanceof br}function Sr(e){return e<0?Math.round(-1*e)*-1:Math.round(e)}function Cr(e,t,n){var r=Math.min(e.length,t.length),i=Math.abs(e.length-t.length),a=0,o;for(o=0;o<r;o++)(n&&e[o]!==t[o]||!n&&Ye(e[o])!==Ye(t[o]))&&a++;return a+i}function wr(e,t){P(e,0,0,function(){var e=this.utcOffset(),n=`+`;return e<0&&(e=-e,n=`-`),n+N(~~(e/60),2)+t+N(~~e%60,2)})}wr(`Z`,`:`),wr(`ZZ`,``),F(`Z`,ze),F(`ZZ`,ze),Ze([`Z`,`ZZ`],function(e,t,n){n._useUTC=!0,n._tzm=Er(ze,e)});var Tr=/([\+\-]|\d\d)/gi;function Er(e,t){var n=(t||``).match(e),r,i,a;return n===null?null:(r=n[n.length-1]||[],i=(r+``).match(Tr)||[`-`,0,0],a=+(i[1]*60)+Ye(i[2]),a===0?0:i[0]===`+`?a:-a)}function Dr(e,t){var r,i;return t._isUTC?(r=t.clone(),i=(C(e)||u(e)?e.valueOf():lr(e).valueOf())-r.valueOf(),r._d.setTime(r._d.valueOf()+i),n.updateOffset(r,!1),r):lr(e).local()}function B(e){return-Math.round(e._d.getTimezoneOffset())}n.updateOffset=function(){};function Or(e,t,r){var i=this._offset||0,a;if(!this.isValid())return e==null?NaN:this;if(e!=null){if(typeof e==`string`){if(e=Er(ze,e),e===null)return this}else Math.abs(e)<16&&!r&&(e*=60);return!this._isUTC&&t&&(a=B(this)),this._offset=e,this._isUTC=!0,a!=null&&this.add(a,`m`),i!==e&&(!t||this._changeInProgress?Kr(this,Vr(e-i,`m`),1,!1):this._changeInProgress||(this._changeInProgress=!0,n.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?i:B(this)}function kr(e,t){return e==null?-this.utcOffset():(typeof e!=`string`&&(e=-e),this.utcOffset(e,t),this)}function Ar(e){return this.utcOffset(0,e)}function jr(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e&&this.subtract(B(this),`m`)),this}function Mr(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i==`string`){var e=Er(Re,this._i);e==null?this.utcOffset(0,!0):this.utcOffset(e)}return this}function Nr(e){return this.isValid()?(e=e?lr(e).utcOffset():0,(this.utcOffset()-e)%60==0):!1}function Pr(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Fr(){if(!c(this._isDSTShifted))return this._isDSTShifted;var e={},t;return x(e,this),e=or(e),e._a?(t=e._isUTC?p(e._a):lr(e._a),this._isDSTShifted=this.isValid()&&Cr(e._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function Ir(){return this.isValid()?!this._isUTC:!1}function Lr(){return this.isValid()?this._isUTC:!1}function Rr(){return this.isValid()?this._isUTC&&this._offset===0:!1}var zr=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,Br=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Vr(e,t){var n=e,r=null,i,a,s;return xr(e)?n={ms:e._milliseconds,d:e._days,M:e._months}:l(e)||!isNaN(+e)?(n={},t?n[t]=+e:n.milliseconds=+e):(r=zr.exec(e))?(i=r[1]===`-`?-1:1,n={y:0,d:Ye(r[rt])*i,h:Ye(r[it])*i,m:Ye(r[at])*i,s:Ye(r[ot])*i,ms:Ye(Sr(r[st]*1e3))*i}):(r=Br.exec(e))?(i=r[1]===`-`?-1:1,n={y:Hr(r[2],i),M:Hr(r[3],i),w:Hr(r[4],i),d:Hr(r[5],i),h:Hr(r[6],i),m:Hr(r[7],i),s:Hr(r[8],i)}):n==null?n={}:typeof n==`object`&&(`from`in n||`to`in n)&&(s=Wr(lr(n.from),lr(n.to)),n={},n.ms=s.milliseconds,n.M=s.months),a=new br(n),xr(e)&&o(e,`_locale`)&&(a._locale=e._locale),xr(e)&&o(e,`_isValid`)&&(a._isValid=e._isValid),a}Vr.fn=br.prototype,Vr.invalid=yr;function Hr(e,t){var n=e&&parseFloat(e.replace(`,`,`.`));return(isNaN(n)?0:n)*t}function Ur(e,t){var n={};return n.months=t.month()-e.month()+(t.year()-e.year())*12,e.clone().add(n.months,`M`).isAfter(t)&&--n.months,n.milliseconds=t-+e.clone().add(n.months,`M`),n}function Wr(e,t){var n;return e.isValid()&&t.isValid()?(t=Dr(t,e),e.isBefore(t)?n=Ur(e,t):(n=Ur(t,e),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function Gr(e,t){return function(n,r){var i,a;return r!==null&&!isNaN(+r)&&(D(t,`moment().`+t+`(period, number) is deprecated. Please use moment().`+t+`(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.`),a=n,n=r,r=a),i=Vr(n,r),Kr(this,i,e),this}}function Kr(e,t,r,i){var a=t._milliseconds,o=Sr(t._days),s=Sr(t._months);e.isValid()&&(i=i??!0,s&&At(e,mt(e,`Month`)+s*r),o&&ht(e,`Date`,mt(e,`Date`)+o*r),a&&e._d.setTime(e._d.valueOf()+a*r),i&&n.updateOffset(e,o||s))}var qr=Gr(1,`add`),Jr=Gr(-1,`subtract`);function Yr(e){return typeof e==`string`||e instanceof String}function Xr(e){return C(e)||u(e)||Yr(e)||l(e)||Qr(e)||Zr(e)||e==null}function Zr(e){var t=a(e)&&!s(e),n=!1,r=[`years`,`year`,`y`,`months`,`month`,`M`,`days`,`day`,`d`,`dates`,`date`,`D`,`hours`,`hour`,`h`,`minutes`,`minute`,`m`,`seconds`,`second`,`s`,`milliseconds`,`millisecond`,`ms`],i,c,l=r.length;for(i=0;i<l;i+=1)c=r[i],n=n||o(e,c);return t&&n}function Qr(e){var t=i(e),n=!1;return t&&(n=e.filter(function(t){return!l(t)&&Yr(e)}).length===0),t&&n}function $r(e){var t=a(e)&&!s(e),n=!1,r=[`sameDay`,`nextDay`,`lastDay`,`nextWeek`,`lastWeek`,`sameElse`],i,c;for(i=0;i<r.length;i+=1)c=r[i],n=n||o(e,c);return t&&n}function ei(e,t){var n=e.diff(t,`days`,!0);return n<-6?`sameElse`:n<-1?`lastWeek`:n<0?`lastDay`:n<1?`sameDay`:n<2?`nextDay`:n<7?`nextWeek`:`sameElse`}function ti(e,t){arguments.length===1&&(arguments[0]?Xr(arguments[0])?(e=arguments[0],t=void 0):$r(arguments[0])&&(t=arguments[0],e=void 0):(e=void 0,t=void 0));var r=e||lr(),i=Dr(r,this).startOf(`day`),a=n.calendarFormat(this,i)||`sameElse`,o=t&&(O(t[a])?t[a].call(this,r):t[a]);return this.format(o||this.localeData().calendar(a,this,lr(r)))}function ni(){return new S(this)}function ri(e,t){var n=C(e)?e:lr(e);return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()>n.valueOf():n.valueOf()<this.clone().startOf(t).valueOf()):!1}function ii(e,t){var n=C(e)?e:lr(e);return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()<n.valueOf():this.clone().endOf(t).valueOf()<n.valueOf()):!1}function ai(e,t,n,r){var i=C(e)?e:lr(e),a=C(t)?t:lr(t);return this.isValid()&&i.isValid()&&a.isValid()?(r=r||`()`,(r[0]===`(`?this.isAfter(i,n):!this.isBefore(i,n))&&(r[1]===`)`?this.isBefore(a,n):!this.isAfter(a,n))):!1}function oi(e,t){var n=C(e)?e:lr(e),r;return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()===n.valueOf():(r=n.valueOf(),this.clone().startOf(t).valueOf()<=r&&r<=this.clone().endOf(t).valueOf())):!1}function si(e,t){return this.isSame(e,t)||this.isAfter(e,t)}function ci(e,t){return this.isSame(e,t)||this.isBefore(e,t)}function li(e,t,n){var r,i,a;if(!this.isValid()||(r=Dr(e,this),!r.isValid()))return NaN;switch(i=(r.utcOffset()-this.utcOffset())*6e4,t=xe(t),t){case`year`:a=ui(this,r)/12;break;case`month`:a=ui(this,r);break;case`quarter`:a=ui(this,r)/3;break;case`second`:a=(this-r)/1e3;break;case`minute`:a=(this-r)/6e4;break;case`hour`:a=(this-r)/36e5;break;case`day`:a=(this-r-i)/864e5;break;case`week`:a=(this-r-i)/6048e5;break;default:a=this-r}return n?a:Je(a)}function ui(e,t){if(e.date()<t.date())return-ui(t,e);var n=(t.year()-e.year())*12+(t.month()-e.month()),r=e.clone().add(n,`months`),i,a;return t-r<0?(i=e.clone().add(n-1,`months`),a=(t-r)/(r-i)):(i=e.clone().add(n+1,`months`),a=(t-r)/(i-r)),-(n+a)||0}n.defaultFormat=`YYYY-MM-DDTHH:mm:ssZ`,n.defaultFormatUtc=`YYYY-MM-DDTHH:mm:ss[Z]`;function di(){return this.clone().locale(`en`).format(`ddd MMM DD YYYY HH:mm:ss [GMT]ZZ`)}function fi(e){if(!this.isValid())return null;var t=e!==!0,n=t?this.clone().utc():this;return n.year()<0||n.year()>9999?ce(n,t?`YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYYYY-MM-DD[T]HH:mm:ss.SSSZ`):O(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace(`Z`,ce(n,`Z`)):ce(n,t?`YYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYY-MM-DD[T]HH:mm:ss.SSSZ`)}function pi(){if(!this.isValid())return`moment.invalid(/* `+this._i+` */)`;var e=`moment`,t=``,n,r,i,a;return this.isLocal()||(e=this.utcOffset()===0?`moment.utc`:`moment.parseZone`,t=`Z`),n=`[`+e+`("]`,r=0<=this.year()&&this.year()<=9999?`YYYY`:`YYYYYY`,i=`-MM-DD[T]HH:mm:ss.SSS`,a=t+`[")]`,this.format(n+r+i+a)}function mi(e){e||(e=this.isUtc()?n.defaultFormatUtc:n.defaultFormat);var t=ce(this,e);return this.localeData().postformat(t)}function hi(e,t){return this.isValid()&&(C(e)&&e.isValid()||lr(e).isValid())?Vr({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function gi(e){return this.from(lr(),e)}function _i(e,t){return this.isValid()&&(C(e)&&e.isValid()||lr(e).isValid())?Vr({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function vi(e){return this.to(lr(),e)}function yi(e){var t;return e===void 0?this._locale._abbr:(t=Mn(e),t!=null&&(this._locale=t),this)}var bi=T(`moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.`,function(e){return e===void 0?this.localeData():this.locale(e)});function xi(){return this._locale}var Si=1e3,Ci=60*Si,wi=60*Ci,Ti=146097*24*wi;function Ei(e,t){return(e%t+t)%t}function Di(e,t,n){return e<100&&e>=0?new Date(e+400,t,n)-Ti:new Date(e,t,n).valueOf()}function Oi(e,t,n){return e<100&&e>=0?Date.UTC(e+400,t,n)-Ti:Date.UTC(e,t,n)}function ki(e){var t,r;if(e=xe(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Oi:Di,e){case`year`:t=r(this.year(),0,1);break;case`quarter`:t=r(this.year(),this.month()-this.month()%3,1);break;case`month`:t=r(this.year(),this.month(),1);break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday());break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case`day`:case`date`:t=r(this.year(),this.month(),this.date());break;case`hour`:t=this._d.valueOf(),t-=Ei(t+(this._isUTC?0:this.utcOffset()*Ci),wi);break;case`minute`:t=this._d.valueOf(),t-=Ei(t,Ci);break;case`second`:t=this._d.valueOf(),t-=Ei(t,Si);break}return this._d.setTime(t),n.updateOffset(this,!0),this}function Ai(e){var t,r;if(e=xe(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Oi:Di,e){case`year`:t=r(this.year()+1,0,1)-1;break;case`quarter`:t=r(this.year(),this.month()-this.month()%3+3,1)-1;break;case`month`:t=r(this.year(),this.month()+1,1)-1;break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case`day`:case`date`:t=r(this.year(),this.month(),this.date()+1)-1;break;case`hour`:t=this._d.valueOf(),t+=wi-Ei(t+(this._isUTC?0:this.utcOffset()*Ci),wi)-1;break;case`minute`:t=this._d.valueOf(),t+=Ci-Ei(t,Ci)-1;break;case`second`:t=this._d.valueOf(),t+=Si-Ei(t,Si)-1;break}return this._d.setTime(t),n.updateOffset(this,!0),this}function ji(){return this._d.valueOf()-(this._offset||0)*6e4}function Mi(){return Math.floor(this.valueOf()/1e3)}function Ni(){return new Date(this.valueOf())}function Pi(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]}function Fi(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}}function Ii(){return this.isValid()?this.toISOString():null}function Li(){return _(this)}function Ri(){return f({},h(this))}function zi(){return h(this).overflow}function Bi(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}P(`N`,0,0,`eraAbbr`),P(`NN`,0,0,`eraAbbr`),P(`NNN`,0,0,`eraAbbr`),P(`NNNN`,0,0,`eraName`),P(`NNNNN`,0,0,`eraNarrow`),P(`y`,[`y`,1],`yo`,`eraYear`),P(`y`,[`yy`,2],0,`eraYear`),P(`y`,[`yyy`,3],0,`eraYear`),P(`y`,[`yyyy`,4],0,`eraYear`),F(`N`,Zi),F(`NN`,Zi),F(`NNN`,Zi),F(`NNNN`,Qi),F(`NNNNN`,$i),Ze([`N`,`NN`,`NNN`,`NNNN`,`NNNNN`],function(e,t,n,r){var i=n._locale.erasParse(e,r,n._strict);i?h(n).era=i:h(n).invalidEra=e}),F(`y`,Ie),F(`yy`,Ie),F(`yyy`,Ie),F(`yyyy`,Ie),F(`yo`,ea),Ze([`y`,`yy`,`yyy`,`yyyy`],tt),Ze([`yo`],function(e,t,n,r){var i;n._locale._eraYearOrdinalRegex&&(i=e.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?t[tt]=n._locale.eraYearOrdinalParse(e,i):t[tt]=parseInt(e,10)});function Vi(e,t){var r,i,a,o=this._eras||Mn(`en`)._eras;for(r=0,i=o.length;r<i;++r){switch(typeof o[r].since){case`string`:a=n(o[r].since).startOf(`day`),o[r].since=a.valueOf();break}switch(typeof o[r].until){case`undefined`:o[r].until=1/0;break;case`string`:a=n(o[r].until).startOf(`day`).valueOf(),o[r].until=a.valueOf();break}}return o}function Hi(e,t,n){var r,i,a=this.eras(),o,s,c;for(e=e.toUpperCase(),r=0,i=a.length;r<i;++r)if(o=a[r].name.toUpperCase(),s=a[r].abbr.toUpperCase(),c=a[r].narrow.toUpperCase(),n)switch(t){case`N`:case`NN`:case`NNN`:if(s===e)return a[r];break;case`NNNN`:if(o===e)return a[r];break;case`NNNNN`:if(c===e)return a[r];break}else if([o,s,c].indexOf(e)>=0)return a[r]}function Ui(e,t){var r=e.since<=e.until?1:-1;return t===void 0?n(e.since).year():n(e.since).year()+(t-e.offset)*r}function Wi(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].name;return``}function Gi(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].narrow;return``}function Ki(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].abbr;return``}function qi(){var e,t,r,i,a=this.localeData().eras();for(e=0,t=a.length;e<t;++e)if(r=a[e].since<=a[e].until?1:-1,i=this.clone().startOf(`day`).valueOf(),a[e].since<=i&&i<=a[e].until||a[e].until<=i&&i<=a[e].since)return(this.year()-n(a[e].since).year())*r+a[e].offset;return this.year()}function Ji(e){return o(this,`_erasNameRegex`)||ta.call(this),e?this._erasNameRegex:this._erasRegex}function Yi(e){return o(this,`_erasAbbrRegex`)||ta.call(this),e?this._erasAbbrRegex:this._erasRegex}function Xi(e){return o(this,`_erasNarrowRegex`)||ta.call(this),e?this._erasNarrowRegex:this._erasRegex}function Zi(e,t){return t.erasAbbrRegex(e)}function Qi(e,t){return t.erasNameRegex(e)}function $i(e,t){return t.erasNarrowRegex(e)}function ea(e,t){return t._eraYearOrdinalRegex||Ie}function ta(){var e=[],t=[],n=[],r=[],i,a,o,s,c,l=this.eras();for(i=0,a=l.length;i<a;++i)o=qe(l[i].name),s=qe(l[i].abbr),c=qe(l[i].narrow),t.push(o),e.push(s),n.push(c),r.push(o),r.push(s),r.push(c);this._erasRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._erasNameRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`),this._erasAbbrRegex=RegExp(`^(`+e.join(`|`)+`)`,`i`),this._erasNarrowRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`)}P(0,[`gg`,2],0,function(){return this.weekYear()%100}),P(0,[`GG`,2],0,function(){return this.isoWeekYear()%100});function na(e,t){P(0,[e,e.length],0,t)}na(`gggg`,`weekYear`),na(`ggggg`,`weekYear`),na(`GGGG`,`isoWeekYear`),na(`GGGGG`,`isoWeekYear`),F(`G`,Le),F(`g`,Le),F(`GG`,Ae,Ee),F(`gg`,Ae,Ee),F(`GGGG`,Pe,Oe),F(`gggg`,Pe,Oe),F(`GGGGG`,Fe,ke),F(`ggggg`,Fe,ke),Qe([`gggg`,`ggggg`,`GGGG`,`GGGGG`],function(e,t,n,r){t[r.substr(0,2)]=Ye(e)}),Qe([`gg`,`GG`],function(e,t,r,i){t[i]=n.parseTwoDigitYear(e)});function ra(e){return la.call(this,e,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function ia(e){return la.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)}function aa(){return Bt(this.year(),1,4)}function oa(){return Bt(this.isoWeekYear(),1,4)}function sa(){var e=this.localeData()._week;return Bt(this.year(),e.dow,e.doy)}function ca(){var e=this.localeData()._week;return Bt(this.weekYear(),e.dow,e.doy)}function la(e,t,n,r,i){var a;return e==null?zt(this,r,i).year:(a=Bt(e,r,i),t>a&&(t=a),ua.call(this,e,t,n,r,i))}function ua(e,t,n,r,i){var a=Rt(e,t,n,r,i),o=It(a.year,0,a.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}P(`Q`,0,`Qo`,`quarter`),F(`Q`,Te),Ze(`Q`,function(e,t){t[nt]=(Ye(e)-1)*3});function da(e){return e==null?Math.ceil((this.month()+1)/3):this.month((e-1)*3+this.month()%3)}P(`D`,[`DD`,2],`Do`,`date`),F(`D`,Ae,He),F(`DD`,Ae,Ee),F(`Do`,function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Ze([`D`,`DD`],rt),Ze(`Do`,function(e,t){t[rt]=Ye(e.match(Ae)[0])});var fa=pt(`Date`,!0);P(`DDD`,[`DDDD`,3],`DDDo`,`dayOfYear`),F(`DDD`,Ne),F(`DDDD`,De),Ze([`DDD`,`DDDD`],function(e,t,n){n._dayOfYear=Ye(e)});function pa(e){var t=Math.round((this.clone().startOf(`day`)-this.clone().startOf(`year`))/864e5)+1;return e==null?t:this.add(e-t,`d`)}P(`m`,[`mm`,2],0,`minute`),F(`m`,Ae,Ue),F(`mm`,Ae,Ee),Ze([`m`,`mm`],at);var ma=pt(`Minutes`,!1);P(`s`,[`ss`,2],0,`second`),F(`s`,Ae,Ue),F(`ss`,Ae,Ee),Ze([`s`,`ss`],ot);var ha=pt(`Seconds`,!1);P(`S`,0,0,function(){return~~(this.millisecond()/100)}),P(0,[`SS`,2],0,function(){return~~(this.millisecond()/10)}),P(0,[`SSS`,3],0,`millisecond`),P(0,[`SSSS`,4],0,function(){return this.millisecond()*10}),P(0,[`SSSSS`,5],0,function(){return this.millisecond()*100}),P(0,[`SSSSSS`,6],0,function(){return this.millisecond()*1e3}),P(0,[`SSSSSSS`,7],0,function(){return this.millisecond()*1e4}),P(0,[`SSSSSSSS`,8],0,function(){return this.millisecond()*1e5}),P(0,[`SSSSSSSSS`,9],0,function(){return this.millisecond()*1e6}),F(`S`,Ne,Te),F(`SS`,Ne,Ee),F(`SSS`,Ne,De);var ga,_a;for(ga=`SSSS`;ga.length<=9;ga+=`S`)F(ga,Ie);function va(e,t){t[st]=Ye((`0.`+e)*1e3)}for(ga=`S`;ga.length<=9;ga+=`S`)Ze(ga,va);_a=pt(`Milliseconds`,!1),P(`z`,0,0,`zoneAbbr`),P(`zz`,0,0,`zoneName`);function ya(){return this._isUTC?`UTC`:``}function ba(){return this._isUTC?`Coordinated Universal Time`:``}var V=S.prototype;V.add=qr,V.calendar=ti,V.clone=ni,V.diff=li,V.endOf=Ai,V.format=mi,V.from=hi,V.fromNow=gi,V.to=_i,V.toNow=vi,V.get=gt,V.invalidAt=zi,V.isAfter=ri,V.isBefore=ii,V.isBetween=ai,V.isSame=oi,V.isSameOrAfter=si,V.isSameOrBefore=ci,V.isValid=Li,V.lang=bi,V.locale=yi,V.localeData=xi,V.max=dr,V.min=ur,V.parsingFlags=Ri,V.set=_t,V.startOf=ki,V.subtract=Jr,V.toArray=Pi,V.toObject=Fi,V.toDate=Ni,V.toISOString=fi,V.inspect=pi,typeof Symbol<`u`&&Symbol.for!=null&&(V[Symbol.for(`nodejs.util.inspect.custom`)]=function(){return`Moment<`+this.format()+`>`}),V.toJSON=Ii,V.toString=di,V.unix=Mi,V.valueOf=ji,V.creationData=Bi,V.eraName=Wi,V.eraNarrow=Gi,V.eraAbbr=Ki,V.eraYear=qi,V.year=dt,V.isLeapYear=ft,V.weekYear=ra,V.isoWeekYear=ia,V.quarter=V.quarters=da,V.month=jt,V.daysInMonth=Mt,V.week=V.weeks=Gt,V.isoWeek=V.isoWeeks=L,V.weeksInYear=sa,V.weeksInWeekYear=ca,V.isoWeeksInYear=aa,V.isoWeeksInISOWeekYear=oa,V.date=fa,V.day=V.days=on,V.weekday=sn,V.isoWeekday=cn,V.dayOfYear=pa,V.hour=V.hours=yn,V.minute=V.minutes=ma,V.second=V.seconds=ha,V.millisecond=V.milliseconds=_a,V.utcOffset=Or,V.utc=Ar,V.local=jr,V.parseZone=Mr,V.hasAlignedHourOffset=Nr,V.isDST=Pr,V.isLocal=Ir,V.isUtcOffset=Lr,V.isUtc=Rr,V.isUTC=Rr,V.zoneAbbr=ya,V.zoneName=ba,V.dates=T(`dates accessor is deprecated. Use date instead.`,fa),V.months=T(`months accessor is deprecated. Use month instead`,jt),V.years=T(`years accessor is deprecated. Use year instead`,dt),V.zone=T(`moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/`,kr),V.isDSTShifted=T(`isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information`,Fr);function xa(e){return lr(e*1e3)}function Sa(){return lr.apply(null,arguments).parseZone()}function Ca(e){return e}var wa=j.prototype;wa.calendar=te,wa.longDateFormat=de,wa.invalidDate=pe,wa.ordinal=ge,wa.preparse=Ca,wa.postformat=Ca,wa.relativeTime=ve,wa.pastFuture=ye,wa.set=k,wa.eras=Vi,wa.erasParse=Hi,wa.erasConvertYear=Ui,wa.erasAbbrRegex=Yi,wa.erasNameRegex=Ji,wa.erasNarrowRegex=Xi,wa.months=Et,wa.monthsShort=Dt,wa.monthsParse=kt,wa.monthsRegex=I,wa.monthsShortRegex=Nt,wa.week=Vt,wa.firstDayOfYear=Wt,wa.firstDayOfWeek=Ut,wa.weekdays=en,wa.weekdaysMin=nn,wa.weekdaysShort=tn,wa.weekdaysParse=an,wa.weekdaysRegex=ln,wa.weekdaysShortRegex=un,wa.weekdaysMinRegex=dn,wa.isPM=_n,wa.meridiem=z;function Ta(e,t,n,r){var i=Mn(),a=p().set(r,t);return i[n](a,e)}function Ea(e,t,n){if(l(e)&&(t=e,e=void 0),e=e||``,t!=null)return Ta(e,t,n,`month`);var r,i=[];for(r=0;r<12;r++)i[r]=Ta(e,r,n,`month`);return i}function Da(e,t,n,r){typeof e==`boolean`?(l(t)&&(n=t,t=void 0),t=t||``):(t=e,n=t,e=!1,l(t)&&(n=t,t=void 0),t=t||``);var i=Mn(),a=e?i._week.dow:0,o,s=[];if(n!=null)return Ta(t,(n+a)%7,r,`day`);for(o=0;o<7;o++)s[o]=Ta(t,(o+a)%7,r,`day`);return s}function Oa(e,t){return Ea(e,t,`months`)}function ka(e,t){return Ea(e,t,`monthsShort`)}function Aa(e,t,n){return Da(e,t,n,`weekdays`)}function ja(e,t,n){return Da(e,t,n,`weekdaysShort`)}function Ma(e,t,n){return Da(e,t,n,`weekdaysMin`)}kn(`en`,{eras:[{since:`0001-01-01`,until:1/0,offset:1,name:`Anno Domini`,narrow:`AD`,abbr:`AD`},{since:`0000-12-31`,until:-1/0,offset:1,name:`Before Christ`,narrow:`BC`,abbr:`BC`}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10;return e+(Ye(e%100/10)===1?`th`:t===1?`st`:t===2?`nd`:t===3?`rd`:`th`)}}),n.lang=T(`moment.lang is deprecated. Use moment.locale instead.`,kn),n.langData=T(`moment.langData is deprecated. Use moment.localeData instead.`,Mn);var Na=Math.abs;function Pa(){var e=this._data;return this._milliseconds=Na(this._milliseconds),this._days=Na(this._days),this._months=Na(this._months),e.milliseconds=Na(e.milliseconds),e.seconds=Na(e.seconds),e.minutes=Na(e.minutes),e.hours=Na(e.hours),e.months=Na(e.months),e.years=Na(e.years),this}function Fa(e,t,n,r){var i=Vr(t,n);return e._milliseconds+=r*i._milliseconds,e._days+=r*i._days,e._months+=r*i._months,e._bubble()}function Ia(e,t){return Fa(this,e,t,1)}function La(e,t){return Fa(this,e,t,-1)}function Ra(e){return e<0?Math.floor(e):Math.ceil(e)}function za(){var e=this._milliseconds,t=this._days,n=this._months,r=this._data,i,a,o,s,c;return e>=0&&t>=0&&n>=0||e<=0&&t<=0&&n<=0||(e+=Ra(Va(n)+t)*864e5,t=0,n=0),r.milliseconds=e%1e3,i=Je(e/1e3),r.seconds=i%60,a=Je(i/60),r.minutes=a%60,o=Je(a/60),r.hours=o%24,t+=Je(o/24),c=Je(Ba(t)),n+=c,t-=Ra(Va(c)),s=Je(n/12),n%=12,r.days=t,r.months=n,r.years=s,this}function Ba(e){return e*4800/146097}function Va(e){return e*146097/4800}function Ha(e){if(!this.isValid())return NaN;var t,n,r=this._milliseconds;if(e=xe(e),e===`month`||e===`quarter`||e===`year`)switch(t=this._days+r/864e5,n=this._months+Ba(t),e){case`month`:return n;case`quarter`:return n/3;case`year`:return n/12}else switch(t=this._days+Math.round(Va(this._months)),e){case`week`:return t/7+r/6048e5;case`day`:return t+r/864e5;case`hour`:return t*24+r/36e5;case`minute`:return t*1440+r/6e4;case`second`:return t*86400+r/1e3;case`millisecond`:return Math.floor(t*864e5)+r;default:throw Error(`Unknown unit `+e)}}function Ua(e){return function(){return this.as(e)}}var Wa=Ua(`ms`),Ga=Ua(`s`),Ka=Ua(`m`),qa=Ua(`h`),Ja=Ua(`d`),Ya=Ua(`w`),Xa=Ua(`M`),Za=Ua(`Q`),Qa=Ua(`y`),$a=Wa;function eo(){return Vr(this)}function to(e){return e=xe(e),this.isValid()?this[e+`s`]():NaN}function no(e){return function(){return this.isValid()?this._data[e]:NaN}}var ro=no(`milliseconds`),io=no(`seconds`),ao=no(`minutes`),oo=no(`hours`),so=no(`days`),co=no(`months`),lo=no(`years`);function uo(){return Je(this.days()/7)}var fo=Math.round,po={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function mo(e,t,n,r,i){return i.relativeTime(t||1,!!n,e,r)}function ho(e,t,n,r){var i=Vr(e).abs(),a=fo(i.as(`s`)),o=fo(i.as(`m`)),s=fo(i.as(`h`)),c=fo(i.as(`d`)),l=fo(i.as(`M`)),u=fo(i.as(`w`)),d=fo(i.as(`y`)),f=a<=n.ss&&[`s`,a]||a<n.s&&[`ss`,a]||o<=1&&[`m`]||o<n.m&&[`mm`,o]||s<=1&&[`h`]||s<n.h&&[`hh`,s]||c<=1&&[`d`]||c<n.d&&[`dd`,c];return n.w!=null&&(f=f||u<=1&&[`w`]||u<n.w&&[`ww`,u]),f=f||l<=1&&[`M`]||l<n.M&&[`MM`,l]||d<=1&&[`y`]||[`yy`,d],f[2]=t,f[3]=+e>0,f[4]=r,mo.apply(null,f)}function go(e){return e===void 0?fo:typeof e==`function`?(fo=e,!0):!1}function _o(e,t){return po[e]===void 0?!1:t===void 0?po[e]:(po[e]=t,e===`s`&&(po.ss=t-1),!0)}function vo(e,t){if(!this.isValid())return this.localeData().invalidDate();var n=!1,r=po,i,a;return typeof e==`object`&&(t=e,e=!1),typeof e==`boolean`&&(n=e),typeof t==`object`&&(r=Object.assign({},po,t),t.s!=null&&t.ss==null&&(r.ss=t.s-1)),i=this.localeData(),a=ho(this,!n,r,i),n&&(a=i.pastFuture(+this,a)),i.postformat(a)}var yo=Math.abs;function bo(e){return(e>0)-(e<0)||+e}function xo(){if(!this.isValid())return this.localeData().invalidDate();var e=yo(this._milliseconds)/1e3,t=yo(this._days),n=yo(this._months),r,i,a,o,s=this.asSeconds(),c,l,u,d;return s?(r=Je(e/60),i=Je(r/60),e%=60,r%=60,a=Je(n/12),n%=12,o=e?e.toFixed(3).replace(/\.?0+$/,``):``,c=s<0?`-`:``,l=bo(this._months)===bo(s)?``:`-`,u=bo(this._days)===bo(s)?``:`-`,d=bo(this._milliseconds)===bo(s)?``:`-`,c+`P`+(a?l+a+`Y`:``)+(n?l+n+`M`:``)+(t?u+t+`D`:``)+(i||r||e?`T`:``)+(i?d+i+`H`:``)+(r?d+r+`M`:``)+(e?d+o+`S`:``)):`P0D`}var So=br.prototype;return So.isValid=vr,So.abs=Pa,So.add=Ia,So.subtract=La,So.as=Ha,So.asMilliseconds=Wa,So.asSeconds=Ga,So.asMinutes=Ka,So.asHours=qa,So.asDays=Ja,So.asWeeks=Ya,So.asMonths=Xa,So.asQuarters=Za,So.asYears=Qa,So.valueOf=$a,So._bubble=za,So.clone=eo,So.get=to,So.milliseconds=ro,So.seconds=io,So.minutes=ao,So.hours=oo,So.days=so,So.weeks=uo,So.months=co,So.years=lo,So.humanize=vo,So.toISOString=xo,So.toString=xo,So.toJSON=xo,So.locale=yi,So.localeData=xi,So.toIsoString=T(`toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)`,xo),So.lang=bi,P(`X`,0,0,`unix`),P(`x`,0,0,`valueOf`),F(`x`,Le),F(`X`,Be),Ze(`X`,function(e,t,n){n._d=new Date(parseFloat(e)*1e3)}),Ze(`x`,function(e,t,n){n._d=new Date(Ye(e))}),n.version=`2.30.1`,r(lr),n.fn=V,n.min=pr,n.max=mr,n.now=hr,n.utc=p,n.unix=xa,n.months=Oa,n.isDate=u,n.locale=kn,n.invalid=v,n.duration=Vr,n.isMoment=C,n.weekdays=Aa,n.parseZone=Sa,n.localeData=Mn,n.isDuration=xr,n.monthsShort=ka,n.weekdaysMin=Ma,n.defineLocale=An,n.updateLocale=jn,n.locales=Nn,n.weekdaysShort=ja,n.normalizeUnits=xe,n.relativeTimeRounding=go,n.relativeTimeThreshold=_o,n.calendarFormat=ei,n.prototype=V,n.HTML5_FMT={DATETIME_LOCAL:`YYYY-MM-DDTHH:mm`,DATETIME_LOCAL_SECONDS:`YYYY-MM-DDTHH:mm:ss`,DATETIME_LOCAL_MS:`YYYY-MM-DDTHH:mm:ss.SSS`,DATE:`YYYY-MM-DD`,TIME:`HH:mm`,TIME_SECONDS:`HH:mm:ss`,TIME_MS:`HH:mm:ss.SSS`,WEEK:`GGGG-[W]WW`,MONTH:`YYYY-MM`},n}))}))(),1);function GP({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)(Dr,{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)(B,{variant:`outline-primary`,size:`sm`,onClick:()=>u(e=>!e),"aria-label":`Toggle Details`,children:l?`Hide Details`:`Show Details`}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{o((0,p.jsx)(UP,{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)(LP,{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:(0,WP.default)(e.date_created).format(`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:(0,WP.default)(e.date_closed).format(`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:(0,WP.default)(e.forecast_up).format(`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===pt.DEFAULT&&`Issue`,e.issue_type===pt.ESCALATION&&`Escalation`,e.issue_type===pt.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:(0,WP.default)(e.last_update).format(`DD MMMM YYYY`)})]})]})]}),s&&a]})}function KP({reservations:e}){if(!e||e.length<1)return(0,p.jsx)(p.Fragment,{});let t=e[0];return(0,p.jsx)(xl,{placement:`top`,overlay:(0,p.jsxs)(hl,{id:`tooltip-${t.id}`,children:[(0,p.jsx)(`h5`,{children:t.title}),(0,p.jsx)(`p`,{children:e[0].active?`Currently active`:`Upcoming in: ${J(e[0].start).format(`DD MMMM YYYY`)}`}),(0,p.jsx)(`p`,{children:e[1]?`Next upcoming reservation in: ${J(e[1].start).format(`DD MMMM YYYY`)}`:`No next upcoming reservations`})]}),children:(0,p.jsxs)(Dr,{bg:e[0].active?`info`:`dark`,children:[`Reserved by: `,e[0].user.full_name]})})}function qP({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)(KP,{reservations:c.filter(e=>e.modules.some(e=>e.id===x.id))})]}),(0,p.jsxs)(_s,{as:Or,title:`Action`,id:`bg-nested-dropdown`,children:[(0,p.jsx)(hs.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)(hs.Item,{eventKey:`1`,onClick:()=>{u((0,p.jsx)(UP,{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)(Pl,{children:[x&&(0,p.jsx)(Zr,{xs:12,md:y.length>0?6:12,children:(0,p.jsx)(Hr,{className:`mb-3`,children:(0,p.jsxs)(Hr.Body,{children:[(0,p.jsxs)(Hr.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)(HP,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},t.id)),s!==1&&A(x.id).map(t=>(0,p.jsx)(GP,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},t.id))]})]})})}),y.length>0&&(0,p.jsx)(Zr,{xs:12,md:x?6:12,children:y.map(t=>(0,p.jsx)(Hr,{className:`mb-3`,children:(0,p.jsxs)(Hr.Body,{children:[(0,p.jsx)(Hr.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)(KP,{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)(HP,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},t.id)),s!==1&&A(t.id).map(t=>(0,p.jsx)(GP,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},t.id))]})]})},t.id))})]})}),_&&h,f&&l]})}var JP=({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)(``),_=()=>document.documentElement.getAttribute(`data-bs-theme`)===`dark`,v={control:e=>({...e,backgroundColor:_()?`#212529`:e.backgroundColor,borderColor:_()?`#495057`:e.borderColor,color:_()?`#fff`:e.color}),menu:e=>({...e,backgroundColor:_()?`#212529`:e.backgroundColor}),option:(e,t)=>({...e,backgroundColor:_()?t.isSelected?`#0d6efd`:t.isFocused?`#343a40`:`#212529`:e.backgroundColor,color:_()?`#fff`:e.color}),singleValue:e=>({...e,color:_()?`#fff`:e.color}),multiValue:e=>({...e,backgroundColor:_()?`#343a40`:e.backgroundColor}),multiValueLabel:e=>({...e,color:_()?`#fff`:e.color}),input:e=>({...e,color:_()?`#fff`:e.color})},{statusMail:y}=(0,d.useContext)(dy);(0,d.useEffect)(()=>{f.default.get(`/list/room`).then(e=>{l((e.data._embedded.items||[]).map(e=>({value:e,label:e.name})))}).catch(e=>{console.error(`Error fetching rooms:`,e),g(`Error fetching rooms:`+e)}),f.default.get(`/list/location/message/type`).then(e=>{let t=y.filter.messageType,r=(e.data._embedded.items||[]).filter(e=>t.includes(e.id.toString())).map(e=>({value:e,label:e.type}));m(r),a(`type`,n?.type||r[0].value)}).catch(e=>{console.error(`Error fetching message types:`,e),g(`Error fetching message types:`+e)})},[]);let b=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)(U,{show:e,size:`lg`,centered:!0,onHide:()=>t(n),children:(0,p.jsxs)(H,{onSubmit:i(async e=>{let r=b(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)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Edit status mail message`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Title`}),(0,p.jsx)(H.Control,{type:`text`,placeholder:`Enter the title`,...r(`title`)})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Message`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,placeholder:`Give the message`,...r(`description`)})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:s,...r(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Rooms`}),(0,p.jsx)(Eu,{name:`rooms`,control:s,render:({field:e})=>(0,p.jsx)(_v,{isMulti:!0,options:c,classNamePrefix:`react-select`,placeholder:`Select one or more rooms`,value:c.filter(t=>e.value?.some(e=>e.id===t.value.id)),onChange:t=>e.onChange(t.map(e=>e.value)),styles:v})})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Type`}),(0,p.jsx)(Eu,{name:`type`,control:s,render:({field:e})=>(0,p.jsx)(_v,{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:v})})]})]}),(0,p.jsxs)(U.Footer,{children:[h!=``&&(0,p.jsx)(`span`,{className:`text-danger`,children:h}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>t(n),children:`Cancel`}),(0,p.jsx)(B,{variant:`primary`,type:`submit`,children:n?`Update Message`:`Create Message`})]})]})})};function YP({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)(Dr,{bg:`dark`,children:a.type.type}),(0,p.jsx)(`h5`,{className:`mb-0`,children:a.title})]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{n((0,p.jsx)(JP,{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)(LP,{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: `,J(a.date_created).format(`DD MMM YYYY`)]}),a.last_update&&(0,p.jsxs)(`span`,{children:[`Updated: `,J(a.last_update).format(`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 XP({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)(B,{variant:`secondary`,onClick:()=>{r((0,p.jsx)(JP,{showModal:!0,onClose:e=>{a(!1),t()}})),a(!0)},children:`New message`})})]}),e.map((e,t)=>(0,p.jsx)(`div`,{children:(0,p.jsx)(YP,{message:e})},e.id)),i&&n]})}function ZP({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)(LP,{children:e.description})}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:J(e.forecast_up).format(`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)(UP,{equipment:r,showModal:!0,onClose:e=>{c(!1),e&&l(e)},issue:e,attachments:u()}))},children:`Edit`})})]},e.id),s&&a]})}function QP({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)(ZP,{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 $P({statusMail:e}){let[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(!1);return(0,p.jsx)(B,{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 eF(){let{statusMail:e}=(0,d.useContext)(dy),[t,n]=(0,d.useState)([]),r=(0,m.useQueryClient)(),i=(0,m.useQueries)({queries:[{queryKey:[`equipment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ee({statusMail:e})},{queryKey:[`module`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>oe({statusMail:e})},{queryKey:[`ecn`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ie({statusMail:e})},{queryKey:[`issue`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>P({statusMail:e})},{queryKey:[`messages`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ce({statusMail:e})},{queryKey:[`ecn`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>N({statusMail:e})},{queryKey:[`issue`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>re({statusMail:e})},{queryKey:[`reservation`,`active`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>se({which:`active`})},{queryKey:[`reservation`,`upcoming`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>se({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)($P,{statusMail:e})})]}),(0,p.jsx)(`p`,{children:e.subject}),v&&(0,p.jsx)(Er,{variant:`info`,children:`Loading status mail`}),y&&(0,p.jsx)(Er,{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)(QP,{issues:e,modules:s.data.items,issueAttachments:h.data.items,reloadQueryFn:a})]})})(),b&&u.data&&(0,p.jsx)(XP,{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===ht.ROOM?t.room.name.localeCompare(n.room.name):t.area&&n.area&&e.classification===ht.AREA?t.area.title.localeCompare(n.area.title):t.area&&n.area&&e.classification===ht.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===ht.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===ht.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===ht.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)(qP,{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 tF(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 nF(e,t){let n=tF(e);if(!n)return``;let r=e=>e.toString().padStart(2,`0`),i={YYYY:n.getFullYear().toString(),YY:n.getFullYear().toString().slice(-2),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=t;return Object.keys(i).sort((e,t)=>t.length-e.length).forEach(e=>{a=a.replace(new RegExp(e,`g`),i[e])}),a}function rF(e,t=`DD-MM-YY HH:mm`){return nF(e,t)}function iF({monitor:e}){let{environment:t}=(0,g.useParams)(),[n]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,e],queryFn:()=>me({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)(Hr,{className:`mb-2 me-2`,children:(0,p.jsxs)(Hr.Body,{className:r,children:[(0,p.jsx)(Hr.Title,{children:(0,p.jsx)(g.Link,{to:`/${t}/operator/monitor/`+e.id,children:e.name})}),(0,p.jsxs)(Hr.Text,{children:[n.title,n.latest_result&&(0,p.jsxs)(p.Fragment,{children:[`Latest measurement: `,rF(n.latest_result.date_created,`DD-MM-YY HH:mm`)]})]})]})},n.id)})}var aF=({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)};function u(){return(0,p.jsx)(Gl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Ul,{onClose:()=>a(!1),show:i,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Ul.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Assist logged`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Ul.Body,{children:`Assist was logged successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,size:t,onClick:()=>r(!0),children:`Log assist`}),(0,p.jsxs)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Log assist`})}),(0,p.jsx)(U.Body,{children:(0,p.jsx)(H,{children:(0,p.jsxs)(H.Group,{className:`mb-3`,controlId:`modal.ControlTextarea1`,children:[(0,p.jsx)(H.Label,{children:`Describe the assist`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,value:o,onChange:e=>l(e)})]})})}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:()=>c(),children:`Log assist`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{r(!1)},children:`Close`})]})]}),(0,p.jsx)(u,{})]})},oF=(0,d.createContext)({equipment:{},reloadEquipment:()=>{}});function sF({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)(Hr,{className:`my-2`,children:[(0,p.jsxs)(Hr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(Hr.Title,{children:[(0,p.jsx)(Dr,{bg:`dark`,children:`Issue`}),` `,c.issue]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(UP,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},issue:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(Hr.Text,{children:(0,p.jsx)(LP,{children:c.description})})]}),(0,p.jsxs)(ac,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(ac.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:rF(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(ac.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)(ac.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:[`(`,rF(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},c.module_id),o&&i]})}function cF({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)(Hr,{className:`my-2`,children:[(0,p.jsxs)(Hr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(Hr.Title,{children:[(0,p.jsx)(Dr,{bg:`dark`,children:`ECN`}),` `,e.ecn]}),(0,p.jsx)(B,{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)(Hr.Text,{children:(0,p.jsx)(LP,{children:e.description})})]}),(0,p.jsxs)(ac,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(ac.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:rF(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(ac.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)(ac.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:[`(`,rF(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},e.module_id),o&&i]})}function lF(){let{id:e}=(0,g.useParams)(),[t,n]=(0,d.useState)([]),r=(0,m.useQueries)({queries:[{queryKey:[`service`,`equipment`,e],queryFn:()=>Xe({equipmentId:Number(e)})}]}),[i]=r,a=r.some(e=>e.isLoading),o=r.some(e=>e.isError),s=r.every(e=>e.isSuccess);if((0,d.useEffect)(()=>{s&&n(i.data.items)},[s,i.data]),a)return(0,p.jsx)(`div`,{children:`Loading...`});if(o)return(0,p.jsx)(`div`,{children:`Error loading services.`});let c=e=>{if(e<60)return`${e} min`;let t=Math.floor(e/60),n=e%60;return`${t}h ${n>0?`${n}min`:``}`.trim()};return i.data.items.length===0?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsx)(Er,{variant:`info`,children:`No services found`})]}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsxs)(Il,{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:c(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 uF(){let{environment:e}=(0,g.useParams)(),{equipment:t}=(0,d.useContext)(oF),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:()=>Fe({firstUnfinishedStepEquipment:t,environment:e})},{queryKey:[`monitors`,t.name],queryFn:()=>he({equipment:t})},{queryKey:[`ecn`,t.name],queryFn:()=>ie({equipment:t})},{queryKey:[`issue`,t.name],queryFn:()=>P({equipment:t})},{queryKey:[`module`,t.name],queryFn:()=>oe({equipment:t})},{queryKey:[`ecn`,`attachment`,t.name],queryFn:()=>N({equipment:t})},{queryKey:[`issue`,`attachment`,t.name],queryFn:()=>re({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)(UP,{equipment:t,showModal:!0,onClose:()=>{o(!1),setTimeout(()=>{S([`issue`,t.name]),S([`issue`,`attachment`,t.name])},100)}})),o(!0)};return(0,p.jsxs)(Qr,{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)(iF,{monitor:e},e.id))}),(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{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)(Er,{variant:`info`,children:`No runs found`}),f.isFetched&&f.data&&f.data?.items.length>0&&(0,p.jsxs)(Il,{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)(lF,{})]}),(0,p.jsxs)(Zr,{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)(B,{variant:`primary`,size:`sm`,onClick:E,children:`New Issue`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:T,children:`New ECN`})}),(0,p.jsx)(`div`,{children:e.id===t.main_tool_module_id&&(0,p.jsx)(aF,{size:`sm`,moduleId:e.id})})]})}),C(e.id)?.map(e=>(0,p.jsx)(cF,{ecn:e,equipment:t,ecnAttachments:b.data?.items??[],reloadQueryFn:S},e.id)),w(e.id)?.map(e=>(0,p.jsx)(sF,{issue:e,equipment:t,issueAttachments:x.data?.items??[],reloadQueryFn:S},e.id))]})]},e.id))]})]}),l&&s,a&&r]})}var dF=()=>{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 fF({children:e}){let{equipment:t,reloadEquipment:n}=dF();return t===null?(0,p.jsx)(jt,{children:(0,p.jsx)(Et,{message:`Loading equipment...`})}):(0,p.jsx)(jt,{children:(0,p.jsx)(oF.Provider,{value:{equipment:t,reloadEquipment:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}function pF(){let{equipment:e}=(0,d.useContext)(oF),t=(0,m.useQueries)({queries:[{queryKey:[`activeReservationQuery`,e],queryFn:()=>se({equipment:e,which:`active`})},{queryKey:[`upcomingReservationQuery`,e],queryFn:()=>se({equipment:e,which:`upcoming`})},{queryKey:[`modules`,e],queryFn:()=>oe({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 `,rF(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`,{}),rF(e.start,`DD-MM-YY HH:mm`),(0,p.jsx)(`br`,{}),e.user.full_name]},e.id))]})]})}function mF(){return(0,p.jsxs)(fF,{children:[(0,p.jsx)(pF,{}),(0,p.jsx)(g.Outlet,{})]})}function hF({children:e}){let{id:t}=(0,g.useParams)(),n=(0,m.useQuery)({queryKey:[`statusMail`,t],queryFn:()=>j({id:parseInt(t)}),enabled:!!t});return n.isLoading||n.isFetching?(0,p.jsx)(jt,{children:(0,p.jsx)(Et,{message:`Loading status mail...`})}):(0,p.jsx)(jt,{children:(0,p.jsx)(dy.Provider,{value:{statusMail:n.data},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}var gF=()=>St(),_F,vF;function yF(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){i(Error(`[ScriptLoadingError] document not defined when attempting to load ${e}`));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),i(Error(`[ScriptLoadingError] Failed to load script: ${e}`))}),t||document.head.append(n)},[]),{isLoading:t,error:r,isSuccess:a}}var bF=e=>e&&e.charts,xF=(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)},SF=e=>window.google;function CF(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}=yF(e.chartLoaderScriptUrl||`https://www.gstatic.com/charts/loader.js`);return(0,d.useEffect)(()=>{if(!m)return;let a=SF();if(!bF(a)){c(Error(`[ScriptInitializationError] Script loaded but Google not attached to window.`));return}if(xF(e,a)){o(a);return}a.charts.load(t,{packages:n,language:r,mapsApiKey:i}),a.charts.setOnLoadCallback(()=>{if(!xF(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 wF={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:`https://www.gstatic.com/charts/loader.js`},TF=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}):!0}).map(e=>{let{control:t}=e;return d.default.createElement(`div`,{key:t.getContainerId(),id:t.getContainerId()})}))},EF=0,DF=()=>(EF+=1,`reactgooglegraph-${EF}`),OF=class{};_F=OF,At(OF,`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)}}),At(OF,`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})})})})}),At(OF,`createControlId`,e=>{let t;return t=e===void 0?`googlechart-control-${DF()}`:e,t}),At(OF,`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=_F.createControlId(r);return{controlProp:e,control:new n.visualization.ControlWrapper({containerId:s,controlType:i,options:a,...o})}}):null}),At(OF,`addControls`,e=>{let{chartWrapper:t,chartDashboard:n}=e,r=_F.createChartControls(e);return!r||!n||!t?null:(n.bind(r.map(e=>{let{control:t}=e;return t}),t),_F.initializeControls(r),r)});var kF=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]},AF=(e,t)=>{d.useEffect(()=>{let n=OF.listenToControlEvents(e??[],t);return()=>{n.forEach(e=>{t.google.visualization.events.removeListener(e)})}},[e,t])},jF=e=>{let[t,n]=kF(e.controls);return AF(t??[],e),{addControls:e=>{n(OF.addControls(e)?.map(e=>e.control)??null)},renderControl:n=>{let{chartWrapper:r,chartDashboard:i}=e;return d.createElement(TF,{...e,isReady:!!(r&&i),chartControls:t,filter:n})}}},MF=e=>{let t=d.useRef(null);return{chartId:(()=>{let{graphID:n,graph_id:r}=e,i=n||r,a;return a=i||t.current||DF(),t.current=a,t.current})()}},NF=[`#3366CC`,`#DC3912`,`#FF9900`,`#109618`,`#990099`,`#3B3EAC`,`#0099C6`,`#DD4477`,`#66AA00`,`#B82E2E`,`#316395`,`#994499`,`#22AA99`,`#AAAA11`,`#6633CC`,`#E67300`,`#8B0707`,`#329262`,`#5574A6`,`#3B3EAC`],PF=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())})})},FF=`#CCCCCC`,IF=class{};vF=IF,At(IF,`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=vF.getColumnId(i,n+1);return t.includes(a)?FF:r&&r.colors?r.colors[n]:NF[n]});n.setOptions({...r,colors:o}),n.draw()}),At(IF,`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=vF.getColumnId(t,i);n?.includes(o)?r(e=>[...e.filter(e=>e!==o)]):r(e=>[...e,o])})}),At(IF,`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 PF(f,c,l):f.visualization.arrayToDataTable([]);let v=g.getNumberOfColumns(),y=Array(v).fill(0).map((e,t)=>{let n=vF.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&&(vF.applyFormatters({dataTable:g,formatters:s,google:f}),d.setDataTable(g),d.draw()),(m===!0||h===!0)&&vF.grayOutHiddenColumnsLabel(e,p)}),At(IF,`getColumnId`,(e,t)=>e.getColumnId(t)||e.getColumnLabel(t)),At(IF,`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 LF=e=>{let{google:t,googleChartWrapper:n,googleChartDashboard:r}=e,[i,a]=d.useState([]);d.useEffect(()=>{n&&IF.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(IF.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t}),window.addEventListener(`resize`,o),l||c){let t=IF.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])},RF=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})})})}},zF=e=>{(0,d.useEffect)(()=>{if(!e.googleChartWrapper)return;let t=RF(e);return()=>{t?.forEach(t=>{e.google.visualization.events.removeListener(t)})}},[e])},BF=e=>{let[t,n]=d.useState(null),[r,i]=d.useState(null),{addControls:a,renderControl:o}=jF({...e,chartDashboard:r,chartWrapper:t});zF({...e,googleChartWrapper:t});let{chartId:s}=MF(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:_})},[]),LF({...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())},VF=d.createContext(wF),HF=e=>{let{children:t,value:n}=e;return d.createElement(VF.Provider,{value:n},t)},UF=e=>{let{google:t,isLoading:n,error:r}=CF(e);return n?e.loader??null:r?e.errorElement??null:t?d.default.createElement(BF,{google:t,...e}):null},WF=e=>{let t={...wF,...e};return d.default.createElement(HF,{value:t},d.default.createElement(UF,t))},GF;(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`})(GF||(GF={}));function KF({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=>{t.values.filter(t=>t.logging_parameter.id===e.logging_parameter.id).filter(e=>e.float_value!==0).forEach(n=>{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)(WF,{chartType:`ScatterChart`,width:`100%`,height:`400px`,data:r,options:n})}var qF=({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)(Al.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)(B,{size:`sm`,onClick:()=>t(e=>Math.max(e-1,0)),disabled:e.currentPage===1,children:`Previous Page`})}),(0,p.jsx)(Al,{size:`sm`,children:a.map((e,t)=>(0,p.jsx)(`div`,{children:e},t))}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{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)(H.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`})]})})]})},JF=new Date().toISOString().split(`T`)[0],YF=({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:JF}}),{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()}function C(){return(0,p.jsx)(Gl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Ul,{onClose:()=>o(!1),show:a,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Ul.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Ul.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,onClick:()=>i(!0),children:`Add manual result`}),(0,p.jsx)(U,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(H,{onSubmit:m(e=>S(e)),validated:s,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add manual result`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`date`,placeholder:`Date`,required:!0,...u(`date`,{required:`This field is required`})},`date`),_.date&&(0,p.jsx)(H.Control.Feedback,{children:_.date.message})]}),y.map((e,t)=>(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:e.label}),(0,p.jsxs)(Hs,{hasValidation:!0,children:[(0,p.jsx)(H.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)(H.Control.Feedback,{children:_.results[t].value.message})]})]},e.id))]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{h(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(C,{})]})},XF=({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=await _e({result:t}),r=await be({requirement:e}),i=await ae({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(),_()}function S(){return(0,p.jsx)(Gl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Ul,{onClose:()=>o(!1),show:a,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Ul.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Ul.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:()=>i(!0),children:`+`}),(0,p.jsx)(U,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(H,{onSubmit:g(e=>x(e)),validated:s,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add process parameter`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`text`,value:t.date_created,readOnly:!0})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module Step Parameter`}),(0,p.jsxs)(H.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)(H.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)(Hs,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,required:!0,...h(`value`,{required:`This field is required`})}),y?.value&&(0,p.jsx)(H.Control.Feedback,{children:y.value.message})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{_(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(S,{})]})},ZF=({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()}function b(){return(0,p.jsx)(Gl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Ul,{onClose:()=>a(!1),show:i,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Ul.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Ul.Body,{children:`Measurement results were saved successfully`})]})})}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)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:(0,p.jsxs)(H,{onSubmit:u(e=>v(e)),validated:o,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add process parameter`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`text`,value:e.date_created,readOnly:!0})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module Step Parameter`}),(0,p.jsx)(H.Control,{type:`text`,value:e.step_parameter.parameter.name,readOnly:!0})]}),(0,p.jsxs)(Hs,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,required:!0,...l(`value`,{required:`This field is required`})}),g?.value&&(0,p.jsx)(H.Control.Feedback,{children:g.value.message})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Update value`}),(0,p.jsx)(B,{className:`float-end`,variant:`danger`,onClick:()=>y(),children:`Delete value`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{m(),r(!1)},children:`Close`})]})]})}),(0,p.jsx)(b,{})]})};function QF({requirement:e}){let[t,n]=(0,d.useState)([]),[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(1),[s,c]=(0,d.useState)(15),[l,u]=(0,d.useState)([]),[h,g,_,v]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`files`,e.step,11],queryFn:()=>ye({step:e.step,pageSize:11,order:`date-created`,direction:`desc`})},{queryKey:[`requirement`,`target`,e],queryFn:()=>ve({requirement:e})},{queryKey:[`requirement`,`results`,e,a,s],queryFn:()=>ge({requirement:e,pageSize:s,order:`date-created`,direction:`desc`,page:a}),placeholderData:m.keepPreviousData},{queryKey:[`requirement`,`monitor_step_parameters`,e,a,s],queryFn:()=>_e({requirement:e,pageSize:s,order:`date-created`,direction:`desc`,page:a}),placeholderData:m.keepPreviousData}]});(0,d.useEffect)(()=>{n([]),!h.isLoading&&h.data.items.forEach(e=>{n(t=>[...t,e])})},[h.isLoading]),(0,d.useEffect)(()=>{v.data&&u(Array.from(new Map(v.data.items.map(e=>[e.step_parameter.id,e.step_parameter])).values()))},[v.isLoading,v.data]);let{getRootProps:y,getInputProps:b,isDragActive:x,isDragAccept:S,isDragReject:C}=Ub({onDrop:(0,d.useCallback)(t=>{t.forEach(t=>{let n=new FileReader;n.onload=async()=>{let r=n.result;try{await f.default.create().post(`update/monitor/requirement/upload-file/`+e.id,{content:r,filename:t.name,type:t.type})}catch(e){i(`Upload failed due to: `+e.response.data.detail)}await h.refetch(),await _.refetch()},n.readAsDataURL(t)})},[e.id,h,_])}),w=(0,d.useMemo)(()=>({...x?{borderColor:`#83afee`}:{},...S?{borderColor:`#00e676`}:{},...C?{borderColor:`#ff1744`}:{}}),[S,C,x]);return g.isLoading||g.isFetching?(0,p.jsx)(Er,{variant:`info`,children:`Loading targets...`}):_.isLoading||_.isFetching?(0,p.jsx)(Er,{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)(Pl,{className:`my-3`,children:(0,p.jsxs)(Zr,{children:[(0,p.jsx)(`h2`,{children:`Charts`}),(0,p.jsx)(`div`,{className:`d-flex`,children:g.data?.items.map(e=>(0,p.jsx)(KF,{target:e,results:_.data.items},e.id))})]})}),(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{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})]}),g.data?.items.length===0&&(0,p.jsx)(Er,{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)(YF,{requirement:e,targets:g.data.items,refetchResults:_.refetch})})]}),(0,p.jsxs)(Il,{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`}),g.data?.items.map(e=>(0,p.jsx)(`th`,{children:e.logging_parameter.name},e.id)),l.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}),g.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)),l.map(e=>(0,p.jsx)(`th`,{className:`table-secondary`},e.id)),(0,p.jsx)(`th`,{})]})]}),(0,p.jsx)(`tbody`,{children:_.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:rF(t.date_created,`DD-MM-YY HH:mm`)}),g.data?.items.map(e=>(0,p.jsx)(`td`,{children:t.values.filter(t=>t.logging_parameter.id===e.logging_parameter.id).map(e=>(0,p.jsx)(`span`,{className:e.value_is_valid?`text-success`:`text-danger`,children:e.float_value},`${e.logging_parameter.id}-${e.float_value}`))},e.id)),l.map(e=>(0,p.jsx)(`td`,{className:`table-secondary`,children:v.data?.items.filter(n=>n.step_parameter.id===e.id&&n.result.id===t.id).map(e=>(0,p.jsx)(ZF,{monitorResultStepParameterValue:e,refetchMonitorStepParameterValues:v.refetch},e.id))},e.id)),(0,p.jsx)(`td`,{children:(0,p.jsx)(XF,{result:t,requirement:e,refetchMonitorStepParameterValues:v.refetch})})]},t.id))})]}),(0,p.jsx)(qF,{data:_.data,setPage:o,setPageSize:c,pageSize:s,isPlaceholderData:_.isPlaceholderData})]}),(0,p.jsxs)(Zr,{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`,{...y({style:w,className:`dropzone`}),children:[(0,p.jsx)(`input`,{...b()}),x?(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:r})]}),t.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:t.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:gF()+e.url,children:e.name}),e.has_monitor_step_loggings&&(0,p.jsx)(Dr,{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:rF(e.date_created,`DD-MM-YY HH:mm`)})]},e.url))})]})]})]})]})}function $F(){let{id:e}=(0,g.useParams)(),[t,n]=(0,m.useQueries)({queries:[{queryKey:[`monitor`,e],queryFn:()=>pe({id:parseInt(e)})},{queryKey:[`requirements`,e],queryFn:()=>me({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)(QF,{requirement:e})},t))]})}function eI(){return(0,p.jsx)(Qr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}var tI=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&pe({id:parseInt(n)}).then(t)},[n,e]);function r(){pe({id:parseInt(n)}).then(t)}return{monitor:e,setMonitor:t,reloadMonitor:r}},nI=(0,d.createContext)({monitor:{},reloadMonitor:()=>{}});function rI({children:e}){let{monitor:t,reloadMonitor:n}=tI();return t===null?(0,p.jsx)(jt,{children:(0,p.jsx)(Et,{message:`Loading monitor...`})}):(0,p.jsx)(jt,{children:(0,p.jsx)(nI.Provider,{value:{monitor:t,reloadMonitor:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}var iI=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||n!==e.id.toString())&&Oe({id:parseInt(n)}).then(t)},[n,e]);function r(){Oe({id:parseInt(n)}).then(t)}return{run:e,reloadRun:r}},aI=(0,d.createContext)({run:{},reloadRun:()=>{}});function oI({children:e}){let{run:t,reloadRun:n}=iI();return t===null?(0,p.jsx)(Et,{message:`Loading run...`}):(0,p.jsx)(jt,{children:(0,p.jsx)(aI.Provider,{value:{run:t,reloadRun:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading rest of run...`}),children:e})})})}function sI({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 cI=({children:e,format:t=`d-M-Y`})=>(0,p.jsx)(p.Fragment,{children:J(Date.parse(e)).format(t)}),lI=({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),n((await f.default.get(`view/run/`+e.id)).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)(H,{onSubmit:o(m),className:`mb-3`,children:[(0,p.jsxs)(Hs,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:6,...a(`content`,{required:!0}),isInvalid:u.content!==void 0}),u.content&&(0,p.jsx)(H.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)(B,{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)(B,{variant:`secondary`,onClick:()=>i(!1),children:`Cancel`})]}),t&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`outline-danger`,className:`text-nowrap`,onClick:h,children:`Delete batch card`})})]})]}):t?t&&(0,p.jsxs)(Hr,{className:`rounded my-4 shadow-sm border-0`,children:[(0,p.jsxs)(Hr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-start justify-content-between gap-3`,children:[(0,p.jsx)(Hr.Title,{className:`text-danger mb-0`,children:`Batch card`}),(0,p.jsx)(B,{variant:`outline-primary`,size:`sm`,className:`text-nowrap`,onClick:()=>i(!0),children:`Update batch card`})]}),(0,p.jsx)(Hr.Text,{className:`mt-3 mb-2 fs-5 text-body`,children:t&&(0,p.jsx)(sI,{text:t.content})})]}),(0,p.jsx)(Hr.Footer,{className:`bg-transparent border-0 pt-0 pb-3`,children:(0,p.jsxs)(`div`,{className:`text-muted small`,children:[`Created `,(0,p.jsx)(cI,{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)(cI,{format:`DD-MM-YY H:m`,children:t.last_update}),`)`]})]})})]}):(0,p.jsx)(B,{variant:`outline-primary`,className:`mb-4`,onClick:()=>i(!0),children:`Create Batch Card`})};function uI(){let{run:e}=(0,d.useContext)(aI);return(0,p.jsxs)(p.Fragment,{children:[e.run_type===gt.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),e.run_type===gt.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)(lI,{run:e})]})}function dI(e){let{run:t,reloadRun:n}=(0,d.useContext)(aI),{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)(nl,{variant:`tabs`,className:e.className,defaultActiveKey:`/home`,activeKey:i,children:a.map(e=>(0,p.jsx)(nl.Item,{children:(0,p.jsx)(g.Link,{to:e.link,className:`nav-link `+(e.link===i?`active`:``),children:e.title})},e.link))})}function fI(){return(0,p.jsx)(oI,{children:(0,p.jsxs)(Qr,{fluid:!0,children:[(0,p.jsx)(uI,{}),(0,p.jsx)(dI,{className:`mb-4`}),(0,p.jsx)(g.Outlet,{})]})})}var pI=(0,d.createContext)({showOnlyEmphasizedParameters:!1,setShowOnlyEmphasizedParameters:()=>{}}),mI=({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`})})]})]})},hI=({runStep:e,showOnlyEmphasizedParameters:t,editableParameters:n=!0,refetchFn:r})=>{let{data:i,isLoading:a}=(0,m.useQuery)({queryKey:[`runStepParameters`,e.id],queryFn:()=>Ve({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)(Il,{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)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:3})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:7})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:4})})})]},t))})]}):c.length===0?(0,p.jsx)(Er,{variant:`info`,children:`No parameters found`}):(0,p.jsxs)(Il,{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)(mI,{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.`})})})]})},gI=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 _I({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:()=>Be({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}=Ub({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)(Il,{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:`${gF()}${e.url}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(Dr,{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))}}),` `,gI(e.size)]}),(0,p.jsx)(`td`,{children:rF(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)(ac,{className:`mt-3`,children:n.map(e=>(0,p.jsx)(ac.Item,{children:e.name},e.name))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(B,{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 vI=({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)(H,{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)(H.Group,{className:`mb-3`,controlId:`formBasicEmail`,children:(0,p.jsx)(H.Control,{as:`textarea`,...s(`comment`)})}),(0,p.jsx)(B,{size:`sm`,type:`submit`,disabled:m,children:`Save`}),(0,p.jsx)(B,{variant:`warning`,size:`sm`,className:`ms-2`,onClick:()=>i(!1),children:`Cancel`})]}):a===null?(0,p.jsx)(B,{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)(B,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Edit`})]}):(0,p.jsx)(`div`,{children:a})},yI=({runStepPart:e,setRunStepPartAction:t,createRunStepPart:n})=>(0,p.jsxs)(hs,{align:`end`,children:[(0,p.jsx)(hs.Toggle,{size:`sm`,variant:`outline-secondary`,children:`Actions`}),(0,p.jsxs)(hs.Menu,{children:[e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(hs.Item,{onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n)),(0,p.jsx)(hs.Item,{onClick:()=>n(),children:`Init`})]})]}),bI={[Ge.START]:`btn-start`,[Ge.FINISH]:`btn-success`,[Ge.FAIL]:`btn-failed`,[Ge.REWORK]:`btn-rework`,[Ge.SET_REPAIR]:`btn-repair`,[Ge.CLEAR_REPAIR]:`btn-secondary`,[Ge.SET_TESTING]:`btn-test`,[Ge.CLEAR_TESTING]:`btn-secondary`},xI=({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 ${bI[n]}`,onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n))}),SI=(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}},CI=(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),wI=e=>e?Array.isArray(e.pages)?e.pages.flatMap(e=>Array.isArray(e?.items)?e.items:[]):Array.isArray(e.items)?e.items:[]:[],TI=(e,t)=>{let{runStepPart:n,latestAction:r}=t;return CI(e,e=>e.map(e=>e.id===n.id?SI(e,r):e))},EI=(e,t)=>CI(e,e=>e.map(e=>t.get(e.id)??e)),DI=e=>Array.isArray(e)?e:Array.isArray(e.items)?e.items:[],OI=(e,t)=>{let n=DI(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 CI(e,e=>e.map(e=>{let t=r.get(e.id)??i.get(e.part_id);return t?SI(e,t):e}))},kI=(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},AI=(e,t,n,r={},i=new Map)=>{if(!e)return e;let a=e=>e.id===n.id?n:r.updateSubsequent&&kI(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 CI(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},jI=e=>{let t=new Map;return e.getQueriesData({queryKey:[`runSteps`]}).forEach(([,e])=>{wI(e).forEach(e=>{t.set(e.id,e)})}),t},MI=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 He({runPart:n}),i=new Map(r.items.map(e=>[e.id,e]));i.size!==0&&e.setQueriesData({queryKey:[`runStepParts`]},e=>EI(e,i))},NI=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=>ke({id:e}))),i=new Map(r.map(e=>[e.id,e]));e.setQueriesData({queryKey:[`runSteps`]},e=>CI(e,e=>e.map(e=>i.get(e.id)??e)))},PI=(e,t)=>{e.setQueriesData({queryKey:[`runStepParts`]},e=>TI(e,t)),MI(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step part cache from run part.`,e)}),NI(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step cache from run step part.`,e)})},FI=(e,t)=>{PI(e,t)},II=(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=>OI(e,n.latestActions)),MI(e,DI(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)}),NI(e,[{step_id:t.id}]).catch(e=>{console.error(`Failed to refresh run step cache from run step.`,e)});return}PI(e,n)},LI=(e,t,n,r={})=>{let i=r.updateSubsequent?jI(e):new Map;e.setQueriesData({queryKey:[`runStepParts`]},e=>AI(e,t,n,r,i))};function RI(e){return!0}var zI=e=>!!e.closest(`button, a, input, textarea, select, option, label`),BI=({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)(()=>{c(r.find(t=>t.part_id===e.id))},[r,e.id]);let u=t=>{if(!n)return;let r=t.target;if(zI(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),LI(l,a,t)})},g=async({runStepPart:e,runStepPartAction:t})=>{let n=await We({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}}),II(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&&RI(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})]})}),RI(a)&&(0,p.jsx)(`td`,{children:o?(0,p.jsx)(yI,{runStepPart:s,setRunStepPartAction:g,createRunStepPart:h}):(0,p.jsx)(xI,{runStepPart:s,setRunStepPartAction:g})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(vI,{runStepPart:s,setRunStepPart:c})})]}):null},VI=(0,d.createContext)(null),HI=()=>{let e=(0,d.useContext)(VI);if(e===null)throw Error(`useScannerContext must be used within a ScannerProvider`);return e},UI=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 WI(e){return e.startsWith(`_qr`)?1:e.toUpperCase().includes(`RESET-FORM`)?2:0}function GI({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}=HI(),s=(0,d.useId)(),c=(0,d.useRef)(new Set),l=(0,d.useCallback)(t=>{if(WI(t)!=UI.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(UI.WILD_CARD,s),l(i),a(UI.WILD_CARD,s,l),()=>{o(UI.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 KI=null;function qI(e){if(!KI){console.warn(`notification() called before NotificationProvider is mounted`);return}KI(e)}function JI({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)(()=>(KI=i,()=>{KI=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)(Gl,{containerPosition:`fixed`,position:`top-end`,children:t.map(({id:e,notificationHeader:t,notificationBody:n,notificationType:r})=>(0,p.jsxs)(Ul,{show:!0,delay:3e3+(r==`danger`?150:0),autohide:!0,bg:r,onClose:()=>a(e),className:`m-5`,children:[(0,p.jsx)(Ul.Header,{children:(0,p.jsx)(`span`,{className:`me-auto`,children:t})}),(0,p.jsx)(Ul.Body,{children:n})]},e))})]})}var YI=e=>`step_id`in e&&`part_id`in e;function XI({runStep:e,parts:t,selectedParts:n,getRunPart:r,getRunStepPart:i,actionsFromScanner:a=!0}){let o=(0,m.useQueryClient)(),{addCallbackFn:s,removeCallbackFn:c}=HI(),l=(0,d.useId)(),u=(0,d.useCallback)(()=>t.length===0?[]:YI(t[0])?t.filter(e=>{let t=r?r(e):e.part_id;return n.get(t)}):t.filter(e=>n.get(e.id)).map(e=>i?i(e):void 0).filter(e=>e!==void 0),[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){if(r.length===1){let e=r[0];FI(o,{runStepPart:e,latestAction:await We({runStepPart:e,runStepPartAction:t})});return}II(o,e,{latestActions:await F({runStepPartActions:r.map(e=>({runStepPart:e,runStepPartAction:t}))})})}},[u,o,e]),p=(0,d.useCallback)(e=>{if(!e||!ZI(e))return;let t=qe(e.split(`/`)[1]);if(!t){qI({notificationHeader:`Part scanner`,notificationBody:`Non valid action found in the scanned text`,notificationType:`danger`});return}qI({notificationHeader:`Part scanner`,notificationBody:`Performing action ${Ke(t)} on selected parts`,notificationType:`success`}),f(t)},[f]);return(0,d.useEffect)(()=>{if(a)return c(UI.PERFORM_RUN_ACTION,l),s(UI.PERFORM_RUN_ACTION,l,p),()=>{c(UI.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 ZI(e){return RegExp(`^_qr/.+`).test(e)}var QI=({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]})},$I=({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 ${bI[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))})},eL=({run:e,runStep:t})=>{let n=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Ne({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>He({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}=GI({parts:l});rL({runStepParts:c,runParts:l});let _=(0,d.useMemo)(()=>l.filter(e=>h.get(e.id)&&(u||!tL(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)(Il,{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)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`div`,animation:`glow`,children:(0,p.jsx)(W,{xs:7})})})]},`placeholder-${t}`)),!a&&_.map((e,n)=>(0,p.jsx)(BI,{runStep:t,runPart:e,runStepParts:c,canInit:!1,partIsSelected:h.get(e.id)??!1,dropdown:!1},`${e.parsed_label}${n}`))]})]}),(0,p.jsx)(nL,{runStepParts:c,selectedPartsLength:_.length,totalParts:l.length,onSelectAll:g,toggleShowCompletedParts:()=>{f(!u)}})]})},tL=(e,t)=>{let n=e.find(e=>e.part_id==t.id);return n==null?!1:n.processed},nL=({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 rL({runStepParts:e,runParts:t}){let{addCallbackFn:n,removeCallbackFn:r}=HI(),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(tL(e,i)){qI({notificationHeader:`Run parts table`,notificationBody:`Part ${i.parsed_label??i.scanner_label} is already completed`,notificationType:`danger`});return}qI({notificationHeader:`Part scanner`,notificationBody:`Found part: ${i.scanner_label}`,notificationType:`success`})}},[t,e]);(0,d.useEffect)(()=>(r(UI.WILD_CARD,i),n(UI.WILD_CARD,i,a),()=>{r(UI.WILD_CARD,i)}),[t,e])}var iL=!1,aL=({run:e,runStep:t})=>{let n=(0,m.useQueryClient)(),r=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Ne({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>He({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}=GI({parts:c});rL({runStepParts:l,runParts:c}),(0,d.useEffect)(()=>{let e=Array.from(u.entries()).filter(([,e])=>e).map(([e])=>e);n.setQueryData([`runPartSelection`,t.id],e)},[n,t.id,u]);let{performActionToSelectedParts:y,getAvailableActionsForSelection:b}=XI({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;if(l.forEach(e=>{let n=c.find(t=>t.id===e.part_id)?.tray;if(!n)return;let r=t.get(n.id)??{id:n.id,label:n.name??n.label??`Tray ${n.id}`,partIds:[]};r.partIds.push(e.part_id),t.set(n.id,r)}),t.size===0)return[];let n=[...e.run_trays??[]].sort((e,t)=>e.sequence-t.sequence);return(n.length>0?n.filter(e=>t.has(e.id)).map(e=>{let n=t.get(e.id);return{...n,label:e.name??e.label??n.label}}):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,l]);if(o)return(0,p.jsx)(Et,{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)(Er,{variant:`warning`,children:`No parts found for this run step.`});if(l.length===0)return(0,p.jsx)(Er,{variant:`warning`,children:`No step parts found for this run step.`});let C=RI(t),w=()=>(0,p.jsx)(p.Fragment,{children:C&&(0,p.jsx)(QI,{onSelectAll:g,onSelectNone:_,hasSelectedParts:v,traySelections:S,onToggleTray:(e,t)=>h(e,t),actionsDropdown:(0,p.jsx)($I,{availableActions:x,onActionSelected:y})})});return(0,p.jsxs)(d.Fragment,{children:[w(),c&&c.length>0&&(0,p.jsxs)(p.Fragment,{children:[!C&&(0,p.jsxs)(Er,{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)(Il,{size:`sm`,striped:!0,hover:!0,className:C?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`}),C&&(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)(BI,{runStep:t,runPart:n,runStepParts:l,canInit:e.run_type===gt.PRODUCTION,partIsSelected:i,setPartAsSelected:C?f:void 0,dropdown:iL},`key-${r}-${n.id}`)})})]})]}),l.length>=25&&w()]})};function oL({run:e,step:t,refetchFn:n=()=>null}){let{run:r}=(0,d.useContext)(aI),{showOnlyEmphasizedParameters:i}=(0,d.useContext)(pI),a=e??r;return a?(0,p.jsx)(Hr,{className:`p-4 my-3`,children:(0,p.jsx)(Hr.Body,{children:(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Experimental split`}),(0,p.jsx)(aL,{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)(Zr,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(hI,{runStep:t,showOnlyEmphasizedParameters:i,refetchFn:()=>{n([JSON.stringify(t),`parameters`])}}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(_I,{runStep:t,refetchFn:()=>{n([`runSteps`])}})]})]})})}):null}var sL=(e,t)=>e==null&&t==null?0:e==null?1:t==null?-1:e-t,cL=(e,t)=>sL(e.left,t.left)||e.id-t.id,lL=e=>e.parent?.id??e.root_id??e.id,uL=(e,t)=>{let n=e[0],r=t[0];return sL(n?.parent?.left,r?.parent?.left)||sL(n?.parent?.id,r?.parent?.id)||cL(n,r)},dL=({parts:e,slotCount:t,getSlotIndex:n})=>{let r=Array.from({length:t},()=>[]),i=new Map;return e.forEach(e=>{let t=lL(e),n=i.get(t)??[];n.push(e),i.set(t,n)}),Array.from(i.values()).map(e=>[...e].sort(cL)).forEach(e=>{let i=n(e[0]),a=i!==null&&i>=0&&i<t?i:r.reduce((e,t,n)=>e===-1||t.length<r[e].length?n:e,-1);a!==-1&&r[a].push(e)}),r.map(e=>e.sort(uL).flat())},fL=({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:sL(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},pL=({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=>{LI(s,o,{...e.data})})},x=async({runStepPart:e,runStepPartAction:t})=>{let n=await We({runStepPart:e,runStepPartAction:t});o&&II(s,o,{runStepPart:e,latestAction:n})},S=!c||!e?null:i&&!c?(0,p.jsxs)(B,{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)(vl,{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)(xI,{runStepPart:t,setRunStepPartAction:x})})})]}):S},mL=(e,t)=>t.get(e.id)?.status.class??`step-part-inactive`,hL=({runPart:e,context:t})=>{let{step:n,stepPartsById:r,allowCreate:i,selectedPartIds:a}=t;return(0,p.jsx)(pL,{runPart:e,statusClass:mL(e,r),allowCreate:i,stepPart:r.get(e.id),isSelected:a.includes(e.id),runStep:n})},gL=({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)(hL,{runPart:e,context:t},e.id))}),_L=({runPart:e,context:t})=>{let{step:n,stepPartsById:r,allowCreate:i,selectedPartIds:a}=t;return(0,p.jsx)(pL,{runPart:e,statusClass:e?mL(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})},vL=12,yL=({leveledParts:e,allNonTrayParts:t,isSplitLevel:n,context:r})=>{let i=fL({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/vL)),s=vL,c={"--tray-columns":s,"--tray-rows":o},l=n?dL({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)(gL,{runParts:e,context:r},`slot-no-tray-${t}`):(0,p.jsx)(_L,{runPart:e[0]??null,context:r},`slot-no-tray-${t}`))})},bL=({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));r.length!==0&&II(i,n,{latestActions:await F({runStepPartActions:r.map(t=>({runStepPart:t,runStepPartAction:e}))})})};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)(vl,{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)($I,{availableActions:f,onActionSelected:h})})})]})},xL=(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),SL=(e,t)=>e.map(e=>t.get(e.id)).filter(e=>e!==void 0),CL=e=>e?.tray_id!=null&&!e?.failed?1:e?.tray_id==null?3:2,wL=({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=SL(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)(bL,{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)(hL,{runPart:e,context:a},e.id))})});let f=c.rows*c.columns,m=c.orientation===`ttb`?`ttb`:`ltr`,h={"--tray-columns":c.columns,"--tray-rows":c.rows},g=fL({parts:n,slotCount:f,getOverrideSlotIndex:e=>{let t=d.get(e.id);return!t||t.tray_row==null&&t.tray_column==null?null:xL(c,t.tray_row??e.tray_row,t.tray_column??e.tray_column)},getDirectSlotIndex:e=>xL(c,e.tray_row,e.tray_column)}),_=i?dL({parts:t,slotCount:f,getSlotIndex:e=>g.get(e.id)??null}):Array.from({length:f},()=>[]);return i||t.forEach(e=>{let t=d.get(e.id),n=xL(c,t?.tray_row??e.tray_row,t?.tray_column??e.tray_column);if(n===null)return;let r=CL(t),i=_[n][0],a=i?CL(d.get(i.id)):null;a!==null&&a<r||(_[n]=[e])}),(0,p.jsx)(bL,{label:l,trayStepParts:u,runStep:o,children:(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":m,style:h,children:_.map((t,n)=>i?(0,p.jsx)(gL,{runParts:t,context:a},`slot-${e.id}-${n}`):(0,p.jsx)(_L,{runPart:t[0]??null,context:a},`slot-${e.id}-${n}`))})})},TL=(e,t)=>!t||!t.tray_id?e.tray?.id??0:t.tray_id,EL=(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=TL(t,n.get(t.id)),i=e.get(r)??[];return i.push(t),e.set(r,i),e},new Map)},DL=({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)(()=>new Map(n.filter(t=>t.step_id===e.id).map(e=>[e.part_id,e])),[n,e]),o=(0,d.useMemo)(()=>[...r.run_trays??[]].sort((e,t)=>e.sequence-t.sequence),[r]),s=(0,d.useMemo)(()=>EL(i,n),[i,n]),c=(0,d.useMemo)(()=>t.filter(e=>!e.tray),[t]),l=(0,d.useMemo)(()=>EL(t,n),[t,n]),u=r.run_type===gt.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)(yL,{leveledParts:i,allNonTrayParts:c,isSplitLevel:f,context:g}):(0,p.jsx)(`div`,{className:`tray-grid-group`,children:o.map(e=>(0,p.jsx)(wL,{tray:e,trayParts:s.get(e.id)??[],trayAllParts:l.get(e.id)??[],stepParts:n,isSplitLevel:f,context:g},`tray-${e.id}`))})};function OL({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:()=>He({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)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(DL,{step:t,parts:n,stepParts:h,run:e})}),(0,p.jsxs)(`td`,{children:[r&&(0,p.jsx)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{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)(oL,{step:t,refetchFn:i})})})]})}var kL=({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);(0,d.useEffect)(()=>{if(Object.keys(s).length>0)return;let n={};for(let r of e.targets){let e=``;t!==void 0&&(e=t.values.find(e=>e.logging_parameter.id==r.logging_parameter.id)?.string_value??``),n[r.logging_parameter.id]=e}c(n)},[e]),(0,d.useEffect)(()=>{_(!1),h(null),u(!1)},[n]);let v=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)}},y=async()=>{try{h(null),_(!1),u(!0);let n=Object.entries(s).map(async([e,n])=>{let r=Number.parseInt(e),i={value:n},a=t?.values.find(e=>e.logging_parameter.id===r)?.id;await f.default.patch(`/update/run/measurement/result/value/${a??0}`,i)});await Promise.all(n),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},b=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)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:t?(0,p.jsx)(p.Fragment,{children:`Update results`}):(0,p.jsx)(p.Fragment,{children:`Create result`})})}),(0,p.jsxs)(H,{onSubmit:e=>{e.preventDefault(),t?y():b()},children:[(0,p.jsxs)(U.Body,{children:[m&&(0,p.jsx)(Er,{variant:`danger`,children:m}),g&&(0,p.jsx)(Er,{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)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:e.logging_parameter.name}),(0,p.jsx)(H.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)(U.Footer,{children:[(0,p.jsx)(B,{variant:`warning`,onClick:()=>r(!1),children:`Close`}),l?(0,p.jsxs)(B,{type:`submit`,variant:`info`,disabled:l,children:[(0,p.jsx)(Fl,{animation:`border`,size:`sm`,className:`me-2`}),` Updating results...`]}):t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`danger`,disabled:l,onClick:v,children:`Delete result`}),(0,p.jsx)(B,{type:`submit`,variant:`info`,disabled:l,children:`Update result`})]}):(0,p.jsx)(B,{type:`submit`,variant:`info`,disabled:l,children:`Create result`})]})]})]})},AL=(0,d.createContext)({runStep:{},setRunStep:e=>{},reloadRunStep:()=>{},run:{},modalProperties:{},setModalProperties:e=>{}});function jL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a,editOnly:o=!1}){let{run:s}=(0,d.useContext)(AL),[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 Ne({run:s}),enabled:!r||r.length===0,retry:1},{queryKey:[`runStepParts`,`${t?.run_id??`unknown`}`,`${t?.id??`unknown`}`],queryFn:async()=>await He({step:e.requirement_for_step??e.step}),enabled:!n||n.length===0,retry:1},{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Le({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)(Fl,{animation:`border`,size:`sm`}),` `,(0,p.jsx)(`span`,{children:`Loading data…`})]});if(j&&E.length===0)return(0,p.jsxs)(Er,{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)(B,{size:`sm`,variant:`outline-light`,onClick:()=>b.refetch(),children:`Retry parts`}),` `,O&&x?.isError&&(0,p.jsx)(B,{size:`sm`,variant:`outline-light`,onClick:()=>x.refetch(),children:`Retry step parts`}),` `,k&&S?.isError&&(0,p.jsx)(B,{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)(Il,{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)(B,{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)(kL,{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)(Er,{variant:`secondary`,className:`mb-0`,children:`No selected parts`})})}function ML({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 Le({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.filter(e=>e.isError).forEach((e,t)=>{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)(B,{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)(kL,{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)(B,{size:`sm`,onClick:()=>g(!h),children:[(0,p.jsx)(`i`,{className:`fa fa-plus`}),` Add results`]})}),(0,p.jsx)(kL,{requirement:e,show:h,setShow:e=>{e||g(!1)},refetchFn:n??c})]})}function NL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}){let{environment:o}=(0,g.useParams)();return(0,p.jsx)(Hr,{className:`p-4 my-3`,children:(0,p.jsx)(Hr.Body,{children:(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{md:`7`,children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(jL,{requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(ML,{requirement:e,measurementResults:i,refetchFn:a})]}),(0,p.jsxs)(Zr,{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)(Il,{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)(_I,{runStep:t,refetchFn:()=>{a([`requirements`])}})]})]})})})}var PL=({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=t=>{let r=i.find(e=>e.part_id===t.id);if(!r)return`badge-inactive`;let a=n.find(e=>e.values.some(e=>e.step_part_id===r.id));if(!a)return``;for(let t of a.values){let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id==t.logging_parameter.id);if(r){if(r.inclusive){if(!(r.min_value<=n&&r.max_value>=n))return`badge-failed`}else if(!(r.min_value<n&&r.max_value>n))return`badge-failed`}}return`badge-processed`},c=e=>(0,p.jsx)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{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} ${s(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=>c(e))]},e)):a.map(e=>c(e)),(0,p.jsx)(`span`,{children:`(measurements)`})]})};function FL({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:()=>Le({measurement:e.measurement})},{queryKey:[`runStepParts`,e.requirement_for_step?.id??e.step.id],queryFn:()=>He({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]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:(t=>{if(t.length==0)return y?``:`table-info`;let n=!1;for(let r of t)if(r.values.some(t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return!1;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):!1})){n=!0;break}return n?`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)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(PL,{requirement:e,step:t,measurementResults:x,parts:n,stepParts:b})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(Dr,{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)(NL,{requirement:e,step:t,stepParts:b,parts:n,measurementResults:x,refetchFn:h})})})]})}function IL(){let{run:e}=(0,d.useContext)(aI),{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n}=(0,d.useContext)(pI),[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:()=>Pe({run:e,page:r,pageSize:a}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>Ne({run:e})},{queryKey:[`requirements`,JSON.stringify(e)],queryFn:()=>je({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.filter(e=>e.isError).forEach((t,n)=>{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)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`2rem`,height:`1rem`,borderRadius:`0.5rem`}})}),(0,p.jsx)(W,{animation:`glow`,as:`span`,className:`ms-2`,children:(0,p.jsx)(W,{style:{width:`15rem`}})})]})}),(0,p.jsxs)(Il,{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)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`0.75rem`}})})}),(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`10rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{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=>(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})})}),E=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)(Il,{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&&E(t),(!t.has_label||o.get(t.label?.id??-1))&&(0,p.jsxs)(p.Fragment,{children:[t.has_step_group&&C.includes(t)&&T(t),t.has_requirement?(0,p.jsx)(FL,{requirement:x.find(e=>e.step.id===t.id),step:t,parts:b,refetchFn:u}):(0,p.jsx)(OL,{run:e,step:t,parts:b,monitoredBy:w[t.id],refetchFn:u})]})]},n)})})]}),(0,p.jsx)(qF,{data:f.data,setPage:i,isPlaceholderData:f.isPlaceholderData})]})}var LL=[],RL=new Set,zL=(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},BL=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n};function VL(){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=>zL(t,e,[])),a(t=>BL(t,e)),s(t=>BL(t,e))},[]),getSelectedPartIds:(0,d.useCallback)(e=>n[e]??LL,[n]),isPartSelected:(0,d.useCallback)((e,t)=>(c[e]??RL).has(t),[c]),setRunPartIds:(0,d.useCallback)((e,t)=>{r(n=>zL(n,e,t))},[]),togglePart:(0,d.useCallback)((e,t)=>{r(n=>{let r=n[e]??[];return zL(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 zL(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 HL(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 UL=(e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left,WL=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(UL)}))},GL=e=>e.parsed_label||e.scanner_label||e.label||e.short_label;function KL({runId:e,part:t,selection:n}){let r=n.isPartSelected(e,t.id),i=GL(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)(H.Label,{htmlFor:a,className:`small text-secondary mb-0`,children:`Split`}),(0,p.jsx)(H.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)(H.Check,{id:o,type:`checkbox`,checked:r,onChange:()=>n.togglePart(e,t.id),"aria-label":`Select ${i}`,className:`ms-sm-auto`})]})}function qL({runId:e,part:t,selection:n}){let r=n.isPartSelected(e,t.id);return(0,p.jsx)(Dr,{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:GL(t)})}function JL({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)(Dr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:t.parts.length}),(0,p.jsx)(B,{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)(KL,{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)(qL,{runId:e,part:t,selection:n},t.id))})]})}function YL({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)(H.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)(B,{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)(B,{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)(Fl,{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)(JL,{runId:e.id,group:n,selection:t,experimentalEdit:i},n.level))]})}function XL({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)(Dr,{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)(B,{variant:`outline-danger`,size:`sm`,onClick:()=>t(e.id),children:`Deselect`})})]},e.id))})]})}var ZL=e=>WL(e.items??[]),QL=e=>({value:e.id,label:`${e.label} — ${e.name}`,run:e}),$L=Xb;function eR({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:()=>Fe({environment:n,availableAsParentForRun:t})}),u=(0,m.useQueries)({queries:s.map(e=>({queryKey:[e.id],queryFn:()=>Ne({run:e}),select:ZL}))}),f=(0,d.useMemo)(()=>c?.items??[],[c]),h=(0,d.useMemo)(()=>f.map(QL),[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();return f.filter(e=>!t||e.label.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)).map(QL)},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)(Jb,{isSearchable:!0,isClearable:!0,defaultOptions:h,placeholder:`— Select a run, or start typing`,loadOptions:b,isLoading:l,value:null,styles:$L,onChange:e=>{e&&x(e.run)}})]}),(0,p.jsx)(XL,{selectedRuns:s,onDeselect:e.deselectRun}),s.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(nl,{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)(nl.Item,{children:(0,p.jsx)(nl.Link,{eventKey:`run-${e.id}`,children:e.label})},e.id))}),(0,p.jsx)(`div`,{className:`ms-2 ps-2`,children:v&&(0,p.jsx)(YL,{run:v,selection:e,partGroups:y?.data??[],isLoadingParts:y?.isFetching??!1,experimentalEdit:a,onToggleExperimentalEdit:()=>o(e=>!e)},v.id)})]})]})}function tR({title:e,children:t}){return(0,p.jsxs)(`fieldset`,{children:[(0,p.jsx)(`legend`,{className:`fs-5 mb-0`,children:e}),t]})}var nR=e=>{if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null};function rR({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)(H.Group,{as:Pl,className:`mb-3`,controlId:e,children:[(0,p.jsxs)(H.Label,{column:!0,sm:3,children:[t,` `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(Zr,{sm:9,children:[(0,p.jsxs)(H.Select,{value:i??``,onChange:e=>a(nR(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)(H.Control.Feedback,{type:`invalid`,children:r?`${t}s are still loading.`:`— Select a ${l}.`}),(0,p.jsx)(H.Text,{muted:!0,children:c})]})]})}function iR({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 aR({selectedRuns:e,selectedSubstrates:t,partIdsByRunId:n}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(iR,{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)(Dr,{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)(iR,{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)(Dr,{bg:`secondary`,pill:!0,className:`fw-normal`,children:[`Amount: `,t]})]},e.id))})]})}function oR({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)(gt.RESEARCH),[w,T]=(0,d.useState)(1),[E,D]=(0,d.useState)(``),[O,k]=(0,d.useState)(!1),A=(0,m.useQuery)({queryKey:[`organisation-groups`,s],queryFn:()=>xe({environment:s})}),j=(0,m.useQuery)({queryKey:[`organisation-teams`,s,vt.Run],queryFn:()=>Ce({environment:s,purpose:vt.Run})}),M=(0,m.useQuery)({queryKey:[`organisation-projects`,s,_t.Run],queryFn:()=>Se({environment:s,purpose:_t.Run})}),ee=c.trim(),te=u.trim(),N=A.isLoading||j.isLoading||M.isLoading,ne=A.isError||j.isError||M.isError,re=A.data?.items??[],ie=j.data?.items??[],ae=M.data?.items??[],P=h!==null&&re.some(e=>e.id===h),oe=v!==null&&ie.some(e=>e.id===v),se=b!==null&&ae.some(e=>e.id===b),ce=ee===``,le=te===``,ue=O&&ce,de=O&&le,fe=!ce&&!le&&P&&oe&&se&&!N&&!ne&&!e;return(0,p.jsxs)(H,{noValidate:!0,onSubmit:e=>{e.preventDefault(),k(!0),fe&&o({name:ee,motivation:te,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)(tR,{title:`Details`,children:[(0,p.jsxs)(H.Group,{as:Pl,className:`mb-3`,controlId:`create-run-name`,children:[(0,p.jsxs)(H.Label,{column:!0,sm:3,children:[`Run name `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(Zr,{sm:9,children:[(0,p.jsx)(H.Control,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Give a run name`,required:!0,disabled:e,isInvalid:ue}),ue&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:`Run name is required.`}),(0,p.jsx)(H.Text,{muted:!0,children:`Give a short and descriptive name for the run`})]})]}),(0,p.jsxs)(H.Group,{as:Pl,className:`mb-3`,controlId:`create-run-location`,children:[(0,p.jsx)(H.Label,{column:!0,sm:3,children:`Sample location`}),(0,p.jsxs)(Zr,{sm:9,children:[(0,p.jsx)(H.Control,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`Location of the samples`,disabled:e}),(0,p.jsx)(H.Text,{muted:!0,children:`Give here the location where the run samples are stored`})]})]}),(0,p.jsxs)(H.Group,{as:Pl,className:`mb-3`,controlId:`create-run-motivation`,children:[(0,p.jsxs)(H.Label,{column:!0,sm:3,children:[`Motivation `,(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsxs)(Zr,{sm:9,children:[(0,p.jsx)(H.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:de}),de&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:`Motivation is required.`}),(0,p.jsx)(H.Text,{muted:!0,children:`Explain here the motivation for this run`})]})]})]}),(0,p.jsxs)(tR,{title:`Organisation`,children:[O&&ne&&(0,p.jsx)(Er,{variant:`warning`,children:`Could not load organisation values.`}),(0,p.jsx)(rR,{controlId:`create-run-group`,label:`Group`,options:re,isLoading:A.isLoading,value:h,onChange:_,showError:O&&!P,disabled:e,helpText:`Select the group to which this run belongs`}),(0,p.jsx)(rR,{controlId:`create-run-team`,label:`Team`,options:ie,isLoading:j.isLoading,value:v,onChange:y,showError:O&&!oe,disabled:e,helpText:`Select the team to which this run belongs`}),(0,p.jsx)(rR,{controlId:`create-run-project`,label:`Project`,options:ae,isLoading:M.isLoading,value:b,onChange:x,showError:O&&!se,disabled:e,helpText:`Select the project to which this run belongs`})]}),(0,p.jsx)(tR,{title:`Parts`,children:(0,p.jsxs)(H.Group,{as:Pl,className:`mb-3`,controlId:`create-run-parts`,children:[(0,p.jsx)(H.Label,{column:!0,sm:3,children:`Experimental split`}),(0,p.jsxs)(Zr,{sm:9,children:[(0,p.jsx)(H.Control,{type:`number`,min:1,step:1,value:w,onChange:e=>T(Number(e.target.value)),disabled:e}),(0,p.jsx)(H.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)(tR,{title:`Type`,children:(0,p.jsxs)(H.Group,{as:Pl,className:`mb-3`,controlId:`create-run-type`,children:[(0,p.jsx)(H.Label,{column:!0,sm:3,children:`Run type`}),(0,p.jsx)(Zr,{sm:9,children:(0,p.jsxs)(H.Select,{value:S,onChange:e=>C(e.target.value),disabled:e,children:[(0,p.jsx)(`option`,{value:gt.RESEARCH,children:`Research`}),(0,p.jsx)(`option`,{value:gt.PRODUCTION,children:`Production`})]})})]})}),(0,p.jsx)(Pl,{className:`my-3`,children:(0,p.jsx)(Zr,{sm:9,className:`offset-sm-3`,children:(0,p.jsx)(aR,{selectedRuns:n,selectedSubstrates:r,partIdsByRunId:i})})}),t&&(0,p.jsx)(Er,{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)(B,{variant:`outline-secondary`,type:`button`,onClick:a,disabled:e,children:`Back`}),(0,p.jsx)(B,{variant:`primary`,type:`submit`,disabled:e,children:e?`Creating...`:`Create Run`})]})]})}var sR=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.`},cR=e=>({value:e.id,label:`${e.label} — ${e.short_label}`,substrate:e}),lR=async e=>(await $e({query:e||void 0})).items.map(cR),uR=Xb;function dR({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)(Jb,{isSearchable:!0,isClearable:!0,defaultOptions:!0,placeholder:`— Select a substrate, or start typing`,loadOptions:lR,value:null,styles:uR,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)(B,{variant:`outline-danger`,size:`sm`,onClick:()=>i(e.id),"aria-label":`Deselect ${e.label}`,children:`Deselect`}),(0,p.jsx)(H.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 fR(){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=VL(),c=(0,m.useMutation)({mutationFn:async({runValues:e,parentRuns:t,substrates:n})=>{let r=await we({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=HL(r.id,t).map(e=>Te(e)),a=n.map(({substrate:e,amount:t})=>Ee({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)(nl,{variant:`tabs`,activeKey:r,onSelect:e=>{(e===`parts`||e===`substrate`)&&i(e)},className:`mb-4`,children:[(0,p.jsx)(nl.Item,{children:(0,p.jsx)(nl.Link,{eventKey:`parts`,children:`Parent run and parts`})}),(0,p.jsx)(nl.Item,{children:(0,p.jsx)(nl.Link,{eventKey:`substrate`,children:`Select Substrate`})})]}),(0,p.jsxs)(`div`,{className:`m-3`,children:[r===`parts`&&(0,p.jsx)(eR,{selection:s}),r===`substrate`&&(0,p.jsx)(dR,{selectedSubstrates:a,setSelectedSubstrates:o}),r===`details`&&(0,p.jsx)(oR,{isSubmitting:c.isPending,errorMessage:c.isError?sR(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)(B,{variant:`primary`,disabled:c.isPending,onClick:()=>{i(`details`)},children:`Continue`})})]})]})}function pR(){let{environment:e}=(0,g.useParams)(),{run:t,reloadRun:n}=(0,d.useContext)(aI),r=(0,m.useQueryClient)(),i=VL(),a=(0,m.useMutation)({mutationFn:async e=>{let n=[];for(let r of HL(t.id,e))n.push(await Te(r));return n},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)(eR,{selection:i,run:t}),(0,p.jsx)(`div`,{className:`d-flex justify-content-end mt-4`,children:(0,p.jsx)(B,{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)(Er,{variant:`success`,className:`mt-3`,children:[`Parent runs added to `,t.label??`#${t.id}`,`.`]})]})})}function mR(){let{run:e}=(0,d.useContext)(aI),{environment:t}=(0,g.useParams)(),n=e.run_type===gt.RESEARCH,r=e.run_type===gt.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:`${Ct()}${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:`${Ct()}${t}/organisation/group/details/${e.group.id}/responsible-users.html`,children:e.group?.name??`—`})})]})]})})]})}var hR=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 gR(){let{run:e}=(0,d.useContext)(aI),[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:()=>Ae({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}=Ub({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 Ie({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 De({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)(Il,{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)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:8})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:6})})}),(0,p.jsx)(`td`,{className:`text-end`,children:(0,p.jsx)(W,{as:`span`,animation:`glow`,children:(0,p.jsx)(W,{xs:10})})})]})})]}):f.length>0?(0,p.jsxs)(Il,{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:`${Ct()}/${c}/file/download/${e.id}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(Dr,{className:`ms-2 bg-primary`,children:`Logging`})]}),(0,p.jsx)(`td`,{children:hR(e.size)}),(0,p.jsx)(`td`,{children:rF(e.date_created,`DD-MM-YY HH:mm`)}),(0,p.jsxs)(`td`,{className:`text-end`,children:[(0,p.jsx)(B,{size:`sm`,variant:`outline-primary`,className:`me-2`,onClick:()=>{window.location.href=`${Ct()}/${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)(B,{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)(ac,{className:`mt-3`,children:t.map(e=>(0,p.jsxs)(ac.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:hR(e.size)})]},`${e.name}-${e.lastModified}`))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(B,{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 _R(){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run information`}),(0,p.jsx)(mR,{}),(0,p.jsx)(gR,{})]})}function vR({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=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t.id))},u=e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},f=async(t,n,a,o)=>{t.preventDefault();let s=Number(t.dataTransfer.getData(`text/plain`)),l=c.get(s);if(!l){console.error(`Unable to update run step part tray: stepPart not found`);return}if(!(l.tray_id===n.id&&l.tray_column===o&&l.tray_row===a)){if(r.find(t=>t.id!==l.id&&t.step_id===e.id&&t.tray_id===n.id&&t.tray_row===a&&t.tray_column===o&&!(t.has_failed_in_previouse_state||t.failed))){qI({notificationHeader:`Tray part change`,notificationBody:`Two PartTrays can not be in the same tray position`,notificationType:`danger`});return}LI(i,e,{...l,tray_id:n.id,tray_row:a,tray_column:o});try{LI(i,e,(await Ue(l,n,a,o,!0)).data,{updateSubsequent:!0}),qI({notificationHeader:`Tray part change`,notificationBody:`Part moved successfully`,notificationType:`success`})}catch(t){LI(i,e,l),qI({notificationHeader:`Tray part change`,notificationBody:xR(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 h=a.rows*a.columns,g={"--tray-rows":a.rows,"--tray-columns":a.columns},_=Array.from({length:h},()=>null);return r.forEach(e=>{let t=s.get(e.part_id);if(!t)return;let n=yR(a,e.tray_row??t.tray_row,e.tray_column??t.tray_column);if(n===null||e.has_failed_in_previouse_state)return;let r=SR(e),i=_[n],o=i?SR(i):null;o!==null&&o<r||(_[n]=e)}),(0,p.jsxs)(`section`,{className:`tray-visual my-2`,style:g,"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:_.map((e,n)=>{let r=n+1,{row:i,column:o}=bR(a,n),c=e?s.get(e.part_id):null,d=CR(e),m=wR(e);return(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:u,onDrop:e=>f(e,t,i,o),children:c&&e?(0,p.jsx)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{id:`tooltip-tray-slot-part-${e.id}`,children:m}),children:(0,p.jsx)(`span`,{className:`tray-visual__part badge ${d} badge-level-${c.part_level}`,"data-part-id":c.id,"data-step-part-id":e.id,draggable:!0,onDragStart:t=>l(t,e),children:c.scanner_label})},e.id):(0,p.jsx)(`span`,{className:`tray-visual__index`,children:r})})},`${t.id}-${r}`)})})})]})}var yR=(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),bR=(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},xR=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.`},SR=e=>e.tray_id!=null&&!e.failed?1:e.tray_id==null?3:2,CR=e=>e?.failed?`bg-danger`:e?.tray_id?`bg-primary`:`bg-grey`,wR=e=>e?.failed?`Part failed`:e==null?`In default postion`:e.tray_id==null?`In default position`:`Not in default postion`,TR=({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)(()=>EL(o,a),[o,a]);return i.length===0||o[0]?.part_level>0?(0,p.jsx)(DL,{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)(vR,{step:e,tray:t,parts:s.get(t.id)??[],stepParts:a},t.id))})};function ER({step:e,parts:t,run:n}){let{environment:r}=(0,g.useParams)(),[i]=(0,m.useQueries)({queries:[{queryKey:[`runStepParts`,e.id],queryFn:()=>He({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)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(TR,{step:e,parts:o,stepParts:a,run:n})})]})}function DR(){let{run:e}=(0,d.useContext)(aI),[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:()=>Pe({run:e,page:t,pageSize:r}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>Ne({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.filter(e=>e.isError).forEach((t,n)=>{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]})})})},b=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})})});return l?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run layout edit`}),(0,p.jsxs)(Il,{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)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`span`,children:(0,p.jsx)(W,{style:{width:`4rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(W,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(W,{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)(Il,{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)&&b(t),(0,p.jsx)(ER,{step:t,parts:h,run:e},`step-${t.id}`)]})]},`step-${t.id}`))})]}),(0,p.jsx)(qF,{data:s.data,setPage:n,isPlaceholderData:s.isPlaceholderData})]})}var OR=()=>{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())&&ke({id:parseInt(i)}).then(e=>(Oe({id:e.run_id}).then(r),e)).then(t)},[i,e]);function a(){ke({id:parseInt(i)}).then(e=>(Oe({id:e.run_id}).then(r),e)).then(t)}return{run:n,runStep:e,setRunStep:t,reloadRunStep:a}};function kR({children:e}){let{runStep:t,setRunStep:n,run:r,reloadRunStep:i}=OR(),[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)(jt,{children:(0,p.jsx)(Et,{message:e})})}return(0,p.jsx)(jt,{children:(0,p.jsx)(AL.Provider,{value:{runStep:t,setRunStep:n,reloadRunStep:i,run:r,modalProperties:a,setModalProperties:o},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}function AR(){return(0,p.jsx)(kR,{children:(0,p.jsx)(Qr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})})}var jR=({label:e})=>(0,p.jsx)(`div`,{className:`p-2 h4 mb-1 bg-info text-white`,children:e.label}),MR=({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,`)`]})]})},NR=({checklistItem:e,show:t,setModalShow:n,mutation:r})=>(0,p.jsxs)(U,{show:t,size:`lg`,onHide:()=>n(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Checklist item`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsx)(`h2`,{children:e.task}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.description}})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:()=>{r.mutate()},children:`Done`}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>n(!1),children:`Close`})]})]});function PR({checklistItem:e,onOpenModal:t,onMarkDone:n}){return e.can_finish?e.description===``?(0,p.jsx)(B,{className:`float-end`,size:`sm`,variant:`success`,onClick:n,children:`Done checklist step`}):(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:t,children:`Execute checklist step`}):null}var FR=({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)(ac.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)(cI,{format:`DD-MM-YYYY`,children:e.date_executed})]})]}),(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(PR,{checklistItem:e,onOpenModal:()=>r(!0),onMarkDone:()=>i.mutate()})}),(0,p.jsx)(NR,{checklistItem:e,show:n,setModalShow:r,mutation:i})]})},IR={movingOut:`Moving out...`,skipping:`Skipping...`,unskipping:`Unskipping...`,operationFinished:`Operation finished`,operationSkipped:`Operation skipped`,operationUnskipped:`Operation unskipped`};function LR({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)(AL);(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:()=>Re({runStep:v}),enabled:!!v}),w=(0,d.useCallback)(async e=>{o(IR.movingOut),c(!0);try{let t=await ze(e);o(IR.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(IR.skipping),c(!0);try{await f.default.create().patch(`update/run/step/skip/${e.id}`,{}),o(IR.operationSkipped),y()}finally{c(!1)}},[y]),E=(0,d.useCallback)(async e=>{o(IR.unskipping),c(!0);try{await f.default.create().patch(`update/run/step/un-skip/${e.id}`,{}),o(IR.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)(Et,{message:`Loading...`}):x?(0,p.jsx)(Er,{variant:`danger`,children:`Failed to load checklist.`}):(0,p.jsxs)(p.Fragment,{children:[D.length===0&&(0,p.jsx)(Er,{variant:`info`,children:`No checklist found`}),D.length>0&&(0,p.jsx)(ac,{children:D.map(e=>(0,p.jsx)(FR,{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)(B,{variant:`success`,onClick:()=>w(v),disabled:s,children:a===IR.operationFinished||a===IR.movingOut?a:`Move out`})}),_.access.edit&&!v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,onClick:()=>T(v),disabled:s,children:a===IR.operationSkipped||a===IR.skipping?a:`Skip operation`})}),_.access.edit&&v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`warning`,onClick:()=>E(v),disabled:s,children:a===IR.operationUnskipped||a===IR.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 RR=()=>void 0;function zR({runStep:e,reloadRunStep:t,title:n=`Remark`,titleClassName:r=`mb-2 text-start`}){let{runStep:i,setRunStep:a}=(0,d.useContext)(AL),o=e??i,s=t?()=>t():e?RR:a??RR,[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)(B,{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)(B,{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)(H,{onSubmit:g(b),children:[(0,p.jsx)(H.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)(B,{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)(B,{variant:`secondary`,className:`ms-2`,onClick:()=>l(!1),children:`Cancel`})]})]}):(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext for StepRemark`})}var BR=({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,_=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)}},v=(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})))})};return(0,p.jsx)(U,{show:t,size:`lg`,onHide:()=>n(!1),children:(0,p.jsxs)(H,{onSubmit:u(_),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:a?`Reset hold code`:`Update hold code`})}),(0,p.jsxs)(U.Body,{children:[!a&&(0,p.jsxs)(Hs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(H.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)(Eu,{name:`holdCode`,control:c,rules:{validate:{required:e=>e.value!==void 0||a||`A hold code is required`}},render:({field:e})=>(0,p.jsx)(Jb,{isSearchable:!1,defaultOptions:!0,placeholder:`— Select a hold code`,loadOptions:v,value:e.value,onChange:t=>{e.onChange(t)}})}),h.holdCode&&(0,p.jsx)(`span`,{className:`text-danger`,children:h.holdCode.message})]})]}),(0,p.jsxs)(Hs,{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)(H.Control,{as:`textarea`,rows:3,id:`holdCodeDescription`,...s(`description`,{required:`A message is required`}),isInvalid:h.description!==void 0}),h.description&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:h.description.message})]})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsxs)(B,{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)(B,{variant:`outline-danger`,onClick:()=>{l(`description`,a?r.description:``),o(!a)},children:a?`Update hold Code`:`Reset hold code`})]})]})})},VR=()=>{let{run:e}=(0,d.useContext)(AL),[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)(Dr,{bg:`secondary`,className:`handle`,onClick:()=>a(),style:{fontSize:`1.5rem`,cursor:`pointer`},children:`No hold code`}),(0,p.jsx)(BR,{run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})]})},HR=()=>{let{run:e}=(0,d.useContext)(AL),[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`})]})},UR=({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)(aL,{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)(hI,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:n})]})]})}),WR=({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)(AL);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)(DL,{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)(Dr,{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)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{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)(cI,{format:`DD-MM-YYYY`,children:n.finish_date}):``})]})]}),c&&(0,p.jsx)(UR,{run:e,runStep:n,showOnlyEmphasizedParameters:!1})]})};function GR({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)(jL,{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)(Il,{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 KR({requirement:e,runParts:t,runStepParts:n,hideLabel:r,firstInGroup:i}){let a=e.step,{environment:o}=(0,g.useParams)(),{runStep:s}=(0,d.useContext)(AL),[c,l]=(0,d.useState)(!1),[u]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Le({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=!1;for(let r of n){let n=u.data?.items.find(e=>e.values.some(e=>e.step_part_id===r.id))?.values.find(e=>e.step_part_id===r.id);if(!(n&&!isNaN(parseFloat(n.string_value))))return a.id===s.id?`bg-success-subtle`:``;let i=parseFloat(n.string_value);if(e.targets.some(e=>e.inclusive?!(e.min_value<=i&&e.max_value>=i):!(e.min_value<i&&e.max_value>i))){t=!0;break}}return t?`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)(PL,{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)(Dr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(Dr,{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)(cI,{format:`DD-MM-YYYY`,children:a.finish_date}):``})]})]}),c&&(0,p.jsx)(GR,{requirement:e,step:a,stepParts:n,parts:t,measurementResults:u.data?.items??[]})]})}var qR=({pageSize:e=25,hideLabel:t=!1})=>{let{runStep:n,run:r}=(0,d.useContext)(AL),[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,s=(0,m.useQuery)({queryKey:[`runParts`,`${o}`],queryFn:()=>Ne({run:r}),enabled:!!o}),c=(0,m.useQuery)({queryKey:[`runStepParts`,`${o}`],queryFn:()=>He({run:r}),enabled:!!o}),l=(0,m.useQuery)({queryKey:[`runSteps`,o,i,e],queryFn:()=>Pe({run:r,page:i,pageSize:e}),enabled:!!o,placeholderData:m.keepPreviousData}),u=(0,m.useQuery)({queryKey:[`requirements`,o],queryFn:()=>je({run:r}),enabled:!!o,placeholderData:m.keepPreviousData}),f=s.isLoading||c.isLoading||l.isLoading||u.isLoading,h=s.isError||c.isError||l.isError||u.isError,g=s.error||c.error||l.error||u.error,_=s.data?.items??[],v=c.data?.items??[],y=l.data?.items??[],b=u.data?.items??[],x=new Set,S=y.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||x.has(String(e.step_group.id))?!1:(x.add(String(e.step_group.id)),!0)),C={};for(let e of b)e.requirement_for_step!=null&&(C[String(e.requirement_for_step.id)]=e);return d.default.useEffect(()=>{h&&console.error(`RunStepSimpleList query error`,{runId:o,errors:[s.error,c.error,l.error,u.error]})},[h,o,s.error,c.error,l.error,u.error]),(0,p.jsxs)(`div`,{children:[f?(0,p.jsx)(`div`,{children:`Loading...`}):h?(0,p.jsxs)(`div`,{children:[`Error: `,String(g?.message??g)]}):(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:y.map((e,n)=>(0,p.jsx)(d.default.Fragment,{children:e.has_requirement?(0,p.jsx)(KR,{requirement:b.find(t=>t.step.id===e.id),runParts:_,runStepParts:v,firstInGroup:S.includes(e)},e.id??e.sequence??n):(0,p.jsx)(WR,{run:r,monitoredBy:C[e.id],runParts:_,runStepParts:v,hideLabel:t,firstInGroup:S.includes(e),runStep:e},e.id??e.sequence??n)},n))}),(0,p.jsx)(qF,{data:l.data,setPage:a,isPlaceholderData:l.isPlaceholderData}),l.isFetching?(0,p.jsx)(`span`,{children:` Loading...`}):null]})},JR=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)(AL),[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:()=>Me({run:n,page:r}),placeholderData:m.keepPreviousData});return(0,p.jsxs)(U,{show:e,size:`lg`,onHide:()=>t(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsxs)(U.Title,{children:[`History of Run `,n.label]})}),(0,p.jsx)(U.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)(Il,{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)(cI,{format:`DD-MM-YYYY`,children:e.date_created})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.message}})}),(0,p.jsxs)(`td`,{children:[e.user.first_name,` `,e.user.last_name]})]},e.id))})}),(0,p.jsx)(qF,{data:l,setPage:i,isPlaceholderData:f}),u?(0,p.jsx)(`span`,{children:` Loading...`}):null]})}),(0,p.jsx)(U.Footer,{children:(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},YR=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{size:e,variant:`primary`,onClick:()=>n(!t),children:`Run history`}),t&&(0,p.jsx)(JR,{show:t,setModalShow:n})]})},XR=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)(AL);return(0,p.jsxs)(U,{show:e,size:`xl`,onHide:()=>t(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsxs)(U.Title,{children:[`All steps of run `,n.label]})}),(0,p.jsx)(U.Body,{children:(0,p.jsx)(qR,{hideLabel:!1})}),(0,p.jsx)(U.Footer,{children:(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},ZR=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(B,{size:e,variant:`primary`,onClick:()=>n(!0),children:`All run steps`}),t&&(0,p.jsx)(XR,{show:t,setModalShow:n})]})},QR=()=>{let{runStep:e,run:t}=(0,d.useContext)(AL),[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:()=>Qe({reworkRecipes:g}),enabled:n&&g.length>0},{queryKey:[`run_steps`,e.id],queryFn:()=>Pe({run:t,page:1,pageSize:1e3}),enabled:n},{queryKey:[`template_steps`,`rework`,o,e.id],queryFn:()=>Ze({template:o,pageSize:1e3}),enabled:o!==null}]});if((0,d.useEffect)(()=>{C.isSuccess&&c.length>0&&_([...C.data.items.filter(e=>c.includes(e.id)).map(e=>e.recipe_version.recipe)])},[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)(H,{method:`post`,onSubmit:()=>E(),children:[(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.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)(Er,{variant:`info`,children:`— Select a rework step`}),g.length>0&&(0,p.jsxs)(H.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)(H.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)(H.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)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Comment`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsxs)(H.Group,{controlId:`runStep.remark`,children:[(0,p.jsx)(H.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)(B,{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)(B,{variant:`warning`,onClick:()=>r(!1),children:`Cancel`})]})})]}),!n&&(0,p.jsx)(B,{variant:`primary`,className:`mt-3`,onClick:()=>r(!0),children:`Set Rework`})]})},$R={items:[],amountOfPages:0,currentPage:0,totalItems:0,hasMore:!1},ez=()=>{let{environment:e}=(0,g.useParams)(),{runStep:t,run:n}=(0,d.useContext)(AL),r=(0,m.useQueries)({queries:[{queryKey:[`monitors`,t.process_module.module.equipment],queryFn:()=>t.process_module.module.equipment?he({equipment:t.process_module.module.equipment}):$R},{queryKey:[`ecn`,t.process_module.module],queryFn:()=>ie({module:t.process_module.module})},{queryKey:[`equipmentModule`,t.process_module.module],queryFn:()=>ne({id:t.process_module.module.id})},{queryKey:[`requirement`,t.id],queryFn:()=>je({run:n,step:t})}]}),[i,a,o,s]=r,[c,l]=(0,d.useState)(!0),{addReadingCallbackFn:u,removeReadingCallbackFn:f}=HI(),[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.filter(e=>e.isError).forEach((e,r)=>{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)(Qr,{fluid:!0,children:(0,p.jsxs)(Pl,{children:[(0,p.jsxs)(Zr,{className:`col-9`,children:[n.run_type===gt.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),n.run_type===gt.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)(HR,{}),(0,p.jsx)(VR,{}),t.is_skipped&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`badge bg-info`,children:`SKIPPED`})]})]}),(0,p.jsx)(lI,{run:n}),t.label&&(0,p.jsx)(jR,{label:t.label}),(0,p.jsx)(MR,{runStep:t}),t.is_finished&&(0,p.jsxs)(Er,{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)(Hr,{className:`rounded my-4`,children:(0,p.jsxs)(Hr.Body,{children:[(0,p.jsx)(Hr.Title,{className:`text-muted`,children:`Recipe`}),(0,p.jsxs)(Hr.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)(jL,{requirement:s.data.items[0],step:t,editOnly:!1}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(ML,{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)(aL,{run:n,runStep:t})]}),(0,p.jsxs)(`p`,{className:`pt-3`,children:[`Reading from scanner: `,h]}),(0,p.jsxs)(Pl,{className:`pm-3`,children:[(0,p.jsxs)(Zr,{children:[(0,p.jsx)(`h3`,{children:`Checklist`}),(0,p.jsx)(LR,{}),(0,p.jsx)(`h2`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(_I,{runStep:t})]}),(0,p.jsxs)(Zr,{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)(hI,{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)(zR,{}),(0,p.jsx)(`h3`,{className:`pt-3`,children:`Rework`}),(0,p.jsx)(QR,{})]})]}),(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)(ZR,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(YR,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(aF,{size:void 0,moduleId:t.process_module.module.id})})]})]}),(0,p.jsx)(qR,{pageSize:n.run_type===gt.RESEARCH?5:1e3,hideLabel:!0})]}),(0,p.jsx)(Zr,{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)(iF,{monitor:e},e.id)),a.data?.items.map(function(e){return(0,p.jsxs)(Hr,{className:`my-2`,children:[(0,p.jsxs)(Hr.Header,{children:[`ECN: `,e.ecn]}),(0,p.jsx)(Hr.Body,{children:(0,p.jsx)(Hr.Text,{children:(0,p.jsx)(LP,{children:e.description})})}),(0,p.jsxs)(Hr.Footer,{children:[e.date_created&&(0,p.jsxs)(p.Fragment,{children:[`Created by `,rF(e.date_created,`DD-MM-YY H:m`),` by `,e.owner.full_name]}),e.last_update&&(0,p.jsxs)(p.Fragment,{children:[` `,`· Updated by `,rF(e.last_update,`DD-MM-YY H:m`),` by `,e.owner.full_name]})]})]},e.id)})]})})]})})},tz=()=>{let[e,t]=(0,d.useState)(!1),{modalProperties:n}=(0,d.useContext)(AL),r=()=>{t(!1),n.show=!1};return(0,d.useEffect)(()=>{t(n.show)},[n]),(0,p.jsxs)(U,{show:e,size:`xl`,onHide:r,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:n.modalTitle})}),(0,p.jsx)(U.Body,{children:n.modalContent}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{variant:`secondary`,onClick:r,children:`Save`}),n.modalSaveButton]})]})};function nz(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ez,{}),(0,p.jsx)(tz,{})]})}function rz({run:e,runStep:t,showOnlyEmphasizedParameters:n,reloadRunStepFn:r}){let{data:i,refetch:a}=(0,m.useQuery)({queryKey:[`checklist`,t?.id],queryFn:()=>Re({runStep:t})}),o=(0,d.useMemo)(()=>i?.items,[i]),[s,c]=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Ne({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>He({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?!1: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)(xl,{placement:`top`,overlay:(0,p.jsx)(hl,{id:`tooltip-move-out`,children:l?`Finish step`:`Finish all parts before moving out`}),children:(0,p.jsx)(`span`,{children:(0,p.jsx)(B,{variant:l?`success`:`light`,onClick:()=>{f(!0),ze(t).finally(()=>{f(!1),r()})},disabled:u||!l,children:u?`Moving out...`:`Move out`})})})]}),(0,p.jsx)(eL,{run:e,runStep:t}),(0,p.jsx)(`h3`,{className:`mt-2`,children:`Parameters`}),(0,p.jsx)(hI,{runStep:t,showOnlyEmphasizedParameters:n}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsx)(`div`,{className:`col`,children:(0,p.jsx)(zR,{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)(ac,{children:Array.from({length:1}).map((e,t)=>(0,p.jsx)(ac.Item,{children:(0,p.jsxs)(W,{as:`div`,animation:`glow`,children:[(0,p.jsx)(W,{xs:17}),` `,(0,p.jsx)(W,{xs:4}),` `,(0,p.jsx)(W,{xs:6})]})},t))}),o&&(0,p.jsxs)(p.Fragment,{children:[o.length===0&&(0,p.jsx)(Er,{variant:`info`,children:`No checklist found`}),o.length>0&&(0,p.jsx)(ac,{children:o.map(e=>(0,p.jsx)(FR,{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)(_I,{runStep:t})]})]})]})}function iz({children:e}){let[t,n]=(0,d.useState)(!1);return(0,p.jsx)(jt,{children:(0,p.jsx)(pI.Provider,{value:{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(Et,{message:`Loading...`}),children:e})})})}function az(){return(0,p.jsx)(Qr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}function oz({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{i((await fe({environment:n,withLocations:!0})).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)(H.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:(0,p.jsx)(Eu,{name:t,render:({field:{onChange:e,value:t}})=>(0,p.jsxs)(H.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 sz=Object.defineProperty,cz=Object.getOwnPropertySymbols,lz=Object.prototype.hasOwnProperty,uz=Object.prototype.propertyIsEnumerable,dz=(e,t,n)=>t in e?sz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fz=(e,t)=>{for(var n in t||(t={}))lz.call(t,n)&&dz(e,n,t[n]);if(cz)for(var n of cz(t))uz.call(t,n)&&dz(e,n,t[n]);return e},pz=(e,t)=>{var n={};for(var r in e)lz.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&cz)for(var r of cz(e))t.indexOf(r)<0&&uz.call(e,r)&&(n[r]=e[r]);return n},mz;(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})(mz||(mz={})),(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={}))})(mz||(mz={})),(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={}))})(mz||(mz={}));var hz=mz,gz={L:hz.QrCode.Ecc.LOW,M:hz.QrCode.Ecc.MEDIUM,Q:hz.QrCode.Ecc.QUARTILE,H:hz.QrCode.Ecc.HIGH},_z=128,vz=`L`,yz=`#FFFFFF`,bz=`#000000`,xz=!1,Sz=1,Cz=4,wz=0,Tz=.1;function Ez(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 Dz(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 Oz(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*Tz),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 kz(e,t){return t==null?e?Cz:wz:Math.max(Math.floor(t),0)}function Az({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(...hz.QrSegment.makeSegments(t)),e),[]);return hz.QrCode.encodeSegments(r,gz[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=kz(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:Oz(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:l,numCells:f,calculatedImageSettings:p}}var jz=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Mz=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=_z,level:a=vz,bgColor:o=yz,fgColor:s=bz,includeMargin:c=xz,minVersion:l=Sz,boostLevel:d,marginSize:f,imageSettings:p}=n,m=pz(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=pz(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}=Az({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=Dz(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,jz?t.fill(new Path2D(Ez(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=fz({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`,fz({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});Mz.displayName=`QRCodeCanvas`;var Nz=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=_z,level:a=vz,bgColor:o=yz,fgColor:s=bz,includeMargin:c=xz,minVersion:l=Sz,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=pz(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=Az({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=Dz(_,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=Ez(b,g);return u.default.createElement(`svg`,fz({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)});Nz.displayName=`QRCodeSVG`;function Pz({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{i((await de({room:n,pageSize:1e3})).items),o(!1)}catch(e){console.error(`Error fetching locations:`,e)}}e()},[n]),a?(0,p.jsx)(`p`,{children:`Loading locations...`}):(0,p.jsxs)(H.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:[(0,p.jsx)(H.Label,{children:`Select a storage location`}),(0,p.jsx)(Eu,{name:t,control:e,defaultValue:``,render:({field:{onChange:e,value:t}})=>(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(Pl,{children:r.map(n=>(0,p.jsx)(Zr,{xs:4,md:3,className:`mb-3`,children:(0,p.jsx)(Hr,{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)(Hr.Body,{children:[(0,p.jsx)(Hr.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)(Nz,{value:`/l/`+n.id.toString(),size:128}),` `]})]})})},n.id))})})})]})}var Fz=({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)(U,{show:e,size:`lg`,onHide:()=>t(!1),children:(0,p.jsxs)(H,{onSubmit:o(l),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Create new chemical`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(Hs,{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)(H.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)(H.Control.Feedback,{type:`invalid`,children:s.cas_number.message})]})]}),(0,p.jsxs)(Hs,{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)(H.Control,{as:`input`,id:`name`,...r(`name`,{required:`A name is required`}),isInvalid:s.name!==void 0}),s.name&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.name.message})]})]}),(0,p.jsxs)(Hs,{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)(H.Control,{as:`textarea`,rows:3,id:`description`,...r(`description`)}),s.description&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.description.message})]})]}),(0,p.jsxs)(Hs,{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)(H.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:ut.NON_STANDARD_PRODUCT,children:`Non standard product`}),(0,p.jsx)(`option`,{value:ut.STANDARD_PRODUCT,children:`Standard product`})]}),s.standard_product&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.standard_product.message})]})]}),(0,p.jsxs)(Hs,{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)(H.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:dt.SOLID,children:`Solid`}),(0,p.jsx)(`option`,{value:dt.LIQUID,children:`Liquid`}),(0,p.jsx)(`option`,{value:dt.GAS,children:`Gas`}),(0,p.jsx)(`option`,{value:dt.OTHER,children:`Other`})]}),s.physical_state&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.physical_state.message})]})]})]}),(0,p.jsx)(U.Footer,{children:(0,p.jsxs)(B,{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 Iz({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)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Search Existing Chemicals`}),(0,p.jsxs)(Pl,{children:[(0,p.jsx)(Eu,{name:t,control:e,render:({field:e})=>(0,p.jsx)(Jb,{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)(H.Control.Feedback,{type:`invalid`,children:r.chemical.message}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,className:`mt-2`,onClick:()=>s(!0),children:`Create New Chemical`})})]})]}),(0,p.jsx)(Fz,{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 Lz(e){return/\/l\/\d+$/.test(e)}function Rz(e){let t=e.match(/\/l\/(\d+)$/);return t?parseInt(t[1],10):null}var zz=[{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 Bz(){let e=new Date;return e.setFullYear(e.getFullYear()+5),e.toISOString().split(`T`)[0]}function Vz({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}=HI(),[l,u]=(0,d.useState)(null),{register:m,control:h,handleSubmit:_,watch:y,setValue:b,formState:{errors:x,isSubmitting:S}}=Id({defaultValues:{expire_date:Bz(),owner:{value:a?.id,label:a?.full_name}}}),C=y(`location`);(0,d.useEffect)(()=>{C&&le({id:C}).then(e=>i(e))},[C]);let w=(0,d.useId)(),T=(0,d.useCallback)(e=>{if(Lz(e)){let t=Rz(e);t!==null&&(le({id:t}).then(e=>i(e)),b(`location`,t))}e.startsWith(`reset-scan-location`)&&O()},[b]);(0,d.useEffect)(()=>(c(UI.WILD_CARD,w),s(UI.WILD_CARD,w,T),()=>c(UI.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)(H,{onSubmit:_(D),children:[!r&&(0,p.jsx)(Pz,{room:e,control:h,name:`location`}),r&&(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Scanned location`}),(0,p.jsx)(Zr,{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)(Nz,{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)(Iz,{control:h,errors:x,setValue:b,...m(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:h,...m(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Concentration`}),(0,p.jsxs)(Hs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...m(`concentration`,{required:`A concentration is required`}),isInvalid:x.concentration!==void 0}),x.concentration&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.concentration.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Amount`}),(0,p.jsxs)(Hs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...m(`amount`,{required:`An amount is required`}),isInvalid:x.amount!==void 0}),(0,p.jsx)(Eu,{name:`amount_unit`,control:h,render:({field:e})=>(0,p.jsxs)(_s,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(hs.Item,{eventKey:``,children:`(no unit)`},0),zz.map(e=>(0,p.jsxs)(hs.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),x.amount&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.amount.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Expire date`}),(0,p.jsx)(H.Control,{type:`date`,...m(`expire_date`,{required:`An expire date is required`}),isInvalid:x.expire_date!==void 0}),x.expire_date&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.expire_date.message})]}),(0,p.jsxs)(B,{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)(Er,{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)(Nz,{value:`reset-form`,size:100,className:`float-end`,onClick:n})]})]})]})}function Hz({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)(Eu,{name:`container_type`,control:e,render:({field:e})=>(0,p.jsx)(Jb,{isSearchable:!0,defaultOptions:!0,placeholder:`— Select a container type`,loadOptions:i,value:a(e.value),onChange:t=>{e.onChange(t?.value)},styles:Xb})})}function Uz({room:e,resetForm:t,location:n,setLocation:r}){let{user:i}=(0,d.useContext)(v),{environment:a}=(0,g.useParams)(),{addCallbackFn:o,removeCallbackFn:s}=HI(),[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&&le({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(Lz(e)){let t=Rz(e);t!==null&&(r(await le({id:t})),b(`location`,t));return}e.startsWith(`reset-scan-location`)&&w()},[r,b,w]);return(0,d.useEffect)(()=>(s(UI.WILD_CARD,T),o(UI.WILD_CARD,T,E),()=>s(UI.WILD_CARD,T)),[E]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(H,{onSubmit:_(async e=>{e.user=e.owner.value,l((await f.default.post(`create/chemical/container`,e)).data)}),children:[!n&&(0,p.jsx)(Pz,{room:e,control:h,name:`location`}),n&&(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Scanned location`}),(0,p.jsx)(Zr,{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)(Nz,{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)(Iz,{control:h,errors:x,setValue:b,...m(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Zb,{control:h,...m(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Concentration`}),(0,p.jsxs)(Hs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...m(`concentration`,{required:`An concentration is required`}),isInvalid:x.concentration!==void 0}),x.concentration&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.concentration.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Amount`}),(0,p.jsxs)(Hs,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...m(`amount`,{required:`An amount is required`}),isInvalid:x.amount!==void 0}),(0,p.jsx)(Eu,{name:`amount_unit`,control:h,render:({field:e})=>(0,p.jsxs)(_s,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(hs.Item,{eventKey:``,children:`(no unit)`},0),zz.map(e=>(0,p.jsxs)(hs.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),x.amount&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.amount.message})]})]}),(0,p.jsxs)(Hs,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(H.Label,{children:`Container type`}),(0,p.jsx)(Hz,{control:h,...m(`container_type`,{required:`Container type is required`}),errors:x}),x.container_type&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.container_type.message})]}),(0,p.jsxs)(H.Group,{className:`mb-3 w-50 w-25-sm`,children:[(0,p.jsx)(H.Label,{children:`Expire date`}),(0,p.jsx)(H.Control,{type:`date`,...m(`expire_date`,{required:`An expire date is required`}),isInvalid:x.expire_date!==void 0}),x.expire_date&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:x.expire_date.message})]}),(0,p.jsxs)(B,{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)(Er,{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)(Nz,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>t()})]})]})]})}function Wz(){let{environment:e}=(0,g.useParams)(),{addReadingCallbackFn:t,removeReadingCallbackFn:n,addCallbackFn:r,removeCallbackFn:i}=HI(),[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`);(0,d.useEffect)(()=>{A&&(x(A),_(A.building.site.has_external_chemical_labelling))},[A]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`);e&&ue({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&&le({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 j=(0,d.useCallback)(()=>{O({room:b}),y(null),C(null),u(null),c([]),m(!1)},[O,b]),M=(0,d.useId)();(0,d.useEffect)(()=>(t(M,o),()=>{n(M)}),[]);let ee=(0,d.useCallback)(async e=>{if(!e.includes(`/l/`)){if(y(e),e.includes(`/cc/`)){let t=e.split(`/cc/`)[1];u(await T({id:parseInt(t)}))}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)}}},[]);(0,d.useEffect)(()=>(i(UI.WILD_CARD,M),r(UI.WILD_CARD,M,ee),()=>i(UI.WILD_CARD,M)),[ee]);let te=(0,d.useId)();return(0,d.useEffect)(()=>(i(UI.RESET_FORM,te),r(UI.RESET_FORM,te,j),()=>i(UI.RESET_FORM,te)),[j]),(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)(oz,{control:w,name:`room`})}),(0,p.jsxs)(`p`,{className:`pt-3`,children:[`Reading from scanner: `,a]})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(Nz,{value:`reset-form`,size:100,className:`float-end`,onClick:j}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset form`})]})]}),b&&(0,p.jsx)(p.Fragment,{children:h?(0,p.jsxs)(Er,{children:[`Lab `,b.name,` has external labels, each chemical material should have a material from the internal supplier/warehouse`]}):(0,p.jsxs)(Er,{children:[`Lab `,b.name,` has no external labels, labels can be printed via the intake form`]})}),l&&(0,p.jsxs)(Er,{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&&(0,p.jsxs)(Il,{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)(Vz,{room:b,barcode:v,location:S,setLocation:C,resetForm:j}),!l&&b&&!h&&(0,p.jsx)(Uz,{room:b,location:S,setLocation:C,resetForm:j})]})}function Gz({badge_uuid:e}){return(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Card read: `,e]})}function Kz({user_id:e}){let[t,n]=(0,d.useState)(``);return(0,d.useEffect)(()=>{let t=`https://`+Yz+`/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()}`);n((await e.json()).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 qz(){return(0,p.jsx)(`div`,{})}var Jz=[`all`,`equipment`,`not_set`],Yz=document.getElementById(`root`)?.dataset.goldsteinEndpoint??``,Xz=`mock-token`,Zz=10,Qz=15;async function $z(e){let t=`https://`+Yz+`/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(!Jz.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 eB(){let e=(0,d.useRef)(null),[t,n]=(0,d.useState)(new Map);async function r(e){n(Rv(e.notifications_list,new Date,Zz,Qz))}function i(){let t=`
|
|
37
37
|
SELECT * FROM notifications
|
|
38
38
|
${s===`all`?``:`WHERE association_item = "${s}"`}
|
|
39
39
|
`.trim(),n={listening_association:`${s}:*`,sql_statement:t},r={package_type:Mv.UPDATE_LISTENING_DATA,payload:JSON.stringify(n)};Pv(e.current,r),r={package_type:Mv.GET_DATA,payload:``},Pv(e.current,r)}let a=()=>{setTimeout(()=>{(e.current===null||e.current.readyState===WebSocket.CLOSED||e.current.readyState===WebSocket.CLOSING)&&o()},1e3)},o=()=>{Iv(`wss://`+Yz+`/ws`,Xz).then(t=>{e.current!==null&&e.current.close(),t.onmessage=e=>{Fv(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(),Pv(t,{package_type:Mv.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)(Jz[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:Jz.map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))})]}),(0,p.jsxs)(Il,{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===Lv.CLIENT_CONNECTED&&(0,p.jsx)(qz,{}),t.status===Lv.CARD_READED&&(0,p.jsx)(Gz,{badge_uuid:t.message.badgeUUID}),t.status===Lv.USER_AUTHENTICATED&&(0,p.jsx)(Kz,{user_id:t.message.userID})]}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>$z(e),children:`Edit association`})})]},e))})]})]})}function tB({result:e,status:t,onAutoSave:n,onDirty:r}){let{control:i,formState:a}=Ou(),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!==``?!0:`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=e=>typeof e==`string`?e:``,g=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)(Eu,{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:h(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:h(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:h(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:h(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:h(t.value),onChange:i=>{t.onChange(i.target.value),r(e.id),n(e)},children:[(0,p.jsx)(`option`,{value:``,children:`-- select --`}),Object.entries(g).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(g).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(g).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 nB({categoryId:e,label:t,results:n}){let r=(0,d.useRef)({}),i=(0,d.useRef)({}),[a,o]=(0,d.useState)({}),s=(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},[]),c=Id({defaultValues:(0,d.useMemo)(()=>s(n),[s,n]),mode:`onBlur`}),{control:l,getValues:u,reset:m,trigger:h}=c;(0,d.useEffect)(()=>{let t=String(e),i=r.current[t];if(i)m(i);else{let e=s(n);r.current[t]=e,m(e)}o({})},[s,e,m,n]);let g=wu({control:l});(0,d.useEffect)(()=>{let t=String(e);if(!g)return;let n=Object.entries(g);r.current[t]=n.reduce((e,[t,n])=>(e[t]=n??null,e),{})},[g,e]);let _=(0,d.useCallback)(async e=>{let t=String(e.id);if(!await h(t))return;let n=u(t),r=(i.current[e.id]??0)+1;i.current[e.id]=r,o(t=>({...t,[e.id]:{state:`saving`}}));let a=n??``;Array.isArray(n)?a=n.join(`, `):typeof n==`boolean`&&(a=n?`true`:`false`);try{await f.default.patch(`/update/service/event/report/result/${e.id}`,{value:a}),i.current[e.id]===r&&o(t=>({...t,[e.id]:{state:`saved`,savedAt:Date.now()}}))}catch(t){console.error(`Failed to save:`,t),i.current[e.id]===r&&o(t=>({...t,[e.id]:{state:`error`,message:`Save failed. Try again.`}}))}},[u,h]),v=(0,d.useCallback)(e=>{o(t=>({...t,[e]:{state:`dirty`}}))},[]),y=(0,d.useMemo)(()=>Object.values(a).some(e=>e.state===`dirty`||e.state===`saving`||e.state===`error`),[a]);return(0,d.useEffect)(()=>{let e=e=>{y&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[y]),(0,p.jsxs)(ku,{...c,children:[(0,p.jsx)(`legend`,{children:t}),n.map(e=>(0,p.jsx)(tB,{result:e,status:a[e.id],onAutoSave:_,onDirty:v},e.id))]})}function rB(){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&&(Je({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)}),Ye({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)(nB,{categoryId:h[l],label:a[h[l]],results:r[h[l]]})]}):(0,p.jsx)(`div`,{children:`Loading…`})}var iB={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 aB(e){let t=e.trim().toLowerCase();return t in iB?iB[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 oB(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 sB={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.`}},cB={awaiting_approval:[`approve`,`reject`,`fail`],started:[`reject`,`fail`],syncing:[`fail`],uploading:[`finish`,`reject`,`fail`]};function lB(e){return(cB[e]??[]).map(e=>sB[e])}function uB(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 dB({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?lB(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 ct(i):t===`fail`?await ot(i):t===`finish`?await st(i):await lt(i);let o=u.find(e=>e.action===t);r(a),l(o?.successMessage??`Action completed.`)}catch(e){s(uB(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 ${aB(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:rF(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 fB({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 ${aB(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: `,rF(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 pB({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=it({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 mB(){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=wt();(0,d.useEffect)(()=>{n&&at({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}=pB({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?oB(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)(fB,{activeContext:n,events:i,selectedEventUid:g?.uid||``,onSelectEvent:s})}),(0,p.jsx)(`div`,{className:`col-xl-7`,children:(0,p.jsx)(dB,{event:g,contentEntries:_,irisEndpoint:u,onEventUpdated:f},g?.uid||``)})]},`${n}${i.length>0?i[0].uid:``}`)]})})})}function hB(e){switch(e){case`Shift`:return!0;case`Alt`:return!0;case`Control`:return!0;case`Meta`:return!0}return!1}function gB(e){switch(e){case`Enter`:return!0;default:return!1}}function _B(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(!hB(a)){if(a===`Escape`){r();return}if(gB(a)){e(n),r();return}n+=a,t&&t(n)}}}var vB=({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=WI(e);(0,d.startTransition)(()=>{r.current.get(t)?.forEach(t=>t(e))})};return(0,d.useEffect)(()=>{let e=_B(o,a);return document.addEventListener(`keyup`,e),()=>{document.removeEventListener(`keyup`,e)}},[o,a]),(0,p.jsx)(VI.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 yB({runsList:e,onFail:t=e=>null}){let[n,r]=(0,d.useState)(null),{lastlyReadedKeys:i}=HI();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}qI({notificationHeader:`Run scanner`,notificationBody:`Run ${a.label} found`,notificationType:`success`}),r(a)},[i]),{selectedRun:n}}exports.AuthContext=v,exports.AuthProvider=Mt,exports.BatchCardElement=lI,exports.ChemicalHeaderElement=az,exports.ChemicalIntakeElement=Wz,exports.DateFormat=cI,exports.EditRunParents=pR,exports.EmphasizedParametersContext=pI,exports.EmphasizedParametersProvider=iz,exports.EquipmentContext=oF,exports.EquipmentDashboard=uF,exports.EquipmentHeaderElement=mF,exports.EquipmentProvider=fF,exports.GoldsteinClientsDashboard=eB,exports.GoldsteinEquipmentDashboard=uy,exports.InputModal=tz,exports.IrisOperatorDashboard=mB,exports.ModuleStatusElement=Ld,exports.MonitorCard=iF,exports.MonitorContext=nI,exports.MonitorHeaderElement=eI,exports.MonitorPage=$F,exports.MonitorProvider=rI,exports.NewRunWizard=fR,exports.NotificationProvider=JI,exports.PaginationLinks=qF,exports.ReportResults=rB,exports.RunContext=aI,exports.RunHeaderElement=fI,exports.RunInformationElement=_R,exports.RunLayoutElement=DR,exports.RunProvider=oI,exports.RunStepChecklist=LR,exports.RunStepContext=AL,exports.RunStepExecuteElement=nz,exports.RunStepExecuteMinimal=rz,exports.RunStepHeaderElement=AR,exports.RunStepProvider=kR,exports.RunStepsElement=IL,exports.ScannerContext=VI,exports.ScannerProvider=vB,exports.SetupUpdateEquipment=Ov,exports.StatusMailComponent=eF,exports.StatusMailContext=dy,exports.StatusMailProvider=hF,exports.StepDetails=oL,exports.initSolodbComponents=xt,exports.notification=qI,exports.useAuth=Tt,exports.useScannerContext=HI,exports.useSelectRunWithScanner=yB;
|