@esrf/daiquiri-lib 1.0.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,38 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),w=require("lodash"),a=require("react-bootstrap"),m=require("react"),fe=require("classnames"),me=require("debug"),q=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},O=q(fe),pe=q(me);function xe(e){const{activeMessage:t="Online",inactiveMessage:r="Offline",message:s="This device is"}=e;return n.jsx("div",{className:`dot-indicator small bg-${e.online?"success":"danger"}`,title:`${s} ${e.online?t:r}`})}function N(e){const{name:t,icon:r}=e;return n.jsxs("div",{className:"icon",title:t,children:[n.jsx("i",{className:`fa ${r}`}),n.jsx(xe,{...e})]})}function ge(e){const t={24:"Y",21:"Z",18:"E",15:"P",12:"T",9:"G",6:"M",3:"k","-3":"m","-6":"µ","-9":"n","-12":"p","-15":"f","-18":"a","-21":"z","-24":"y"},r=Math.log(e)/Math.log(1e3),s=!Number.isInteger(r),i=3*Math.ceil(r-(s?1:0)),o=i===0?"":t[i];return{scalar:e*10**-i,prefix:o,multiplier:10**-i}}function je(e){return e.charAt(0).toUpperCase()+e.slice(1)}function G(e){if(e<60)return`${Math.round(e)} sec`;const t=Math.round(e/60),r=t%60,s=Math.floor(t/60);return s?`${s} hr ${r} min`:`${r} min`}function we(e){return e>0?(662607004e-42*299792458/(e*1e-10)/160218e-24*.001).toFixed(4):0}function ye(e,t){return Number.parseFloat(e.toFixed(t))}const ve=Object.freeze(Object.defineProperty({__proto__:null,formatEng:ge,round:ye,toEnergy:we,toHoursMins:G,ucfirst:je},Symbol.toStringTag,{value:"Module"}));function be(e){const{hardware:t}=e;function r(d){t.requestChange({function:"reset"})}const s={"Front End":"feitlk",Experimental:"expitlk",PSS:"pssitlk"},i={Current:`${t.properties.current.toFixed(1)} mA`,Mode:t.properties.mode,Refill:G(t.properties.refill),Message:n.jsx("pre",{children:t.properties.message})};function o(d){if(!(d in t.properties))return"UNKNOWN";const l=t.properties[d];return!l||typeof l!="string"?"UNKNOWN":l}return n.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:n.jsxs(a.Popover,{id:"popid",children:[n.jsxs(a.Popover.Header,{children:[t.name," Details"]}),n.jsxs(a.Popover.Body,{children:[n.jsx("h6",{children:"Status"}),n.jsx("pre",{children:t.properties.status}),n.jsx("h6",{children:"Interlocks"}),n.jsx(a.Container,{children:w.map(s,(d,l)=>n.jsxs(a.Row,{children:[n.jsxs(a.Col,{children:[l,":"]}),n.jsx(a.Col,{children:n.jsx(a.Badge,{bg:o(d)==="ON"?"success":"danger",children:o(d)})})]},l))}),n.jsx("h6",{children:"Ring Status"}),n.jsx(a.Container,{children:w.map(i,(d,l)=>n.jsxs(a.Row,{children:[n.jsxs(a.Col,{children:[l,":"]}),n.jsx(a.Col,{children:d})]},l))}),n.jsx("div",{className:"d-grid gap-2",children:n.jsx(a.Button,{disabled:e.disabled,onClick:r,children:"Reset"})})]})]}),children:n.jsx(a.Button,{className:"flex-grow-0",title:"Shutter Details",children:n.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Ne(e){const{hardware:t,options:r={}}=e;function s(i){t.requestChange({function:t.properties.frontend==="FE open"?"close":"open"})}return n.jsxs("div",{className:"hw-component",children:[n.jsxs("div",{className:"hw-head",children:[n.jsx(N,{name:"Frontend",icon:"fam-hardware-frontend",online:t.online}),n.jsx("div",{className:"name",children:t.name}),n.jsx(a.Badge,{bg:t.properties.state==="OPEN"||t.properties.state==="RUNNING"?"success":"danger",children:t.properties.state})]}),n.jsx("div",{className:"hw-content",children:n.jsxs(a.ButtonGroup,{className:"d-flex",children:[n.jsx(a.Button,{variant:t.properties.frontend==="FE open"?"danger":"success",onClick:s,disabled:e.disabled,children:t.properties.frontend==="FE open"?"Close":"Open"}),n.jsx(be,{...e})]})})]})}function Ce(e){const{hardware:t,options:r={}}=e;function s(){const i=r.property;if(i===void 0)return"property is not set";if(i===null)return"property is null";let o=t;for(const d of i.split("/"))if(o=o[d],o===void 0)return`property '${i}' not found`;return`${o}`}return n.jsx(n.Fragment,{children:s()})}function E(e){const{headerMode:t,hardware:r}=e;function s(){return r.alias?r.alias:r.name?r.name:r.id}const i=s();switch(t){case"front":return n.jsx("div",{className:"hw-component",children:n.jsxs("div",{className:"hw-single",children:[e.widgetIcon,n.jsx("div",{className:"name",children:i}),n.jsx("div",{className:"d-inline-block",children:e.widgetContent})]})});case"none":return n.jsx("div",{className:"hw-component",children:n.jsx("div",{className:"hw-single",children:e.widgetContent})});case"state":return e.widgetState;default:return n.jsxs("div",{className:"hw-component",children:[n.jsxs("div",{className:"hw-head",children:[e.widgetIcon,n.jsx("div",{className:"name",children:n.jsx(a.Form.Label,{htmlFor:r.id,children:i})}),e.widgetState,e.hardware.errors&&e.hardware.errors.length>0&&n.jsx(a.OverlayTrigger,{trigger:"click",placement:"bottom",rootClose:!0,overlay:n.jsxs(a.Popover,{id:e.hardware.id,style:{maxWidth:500},children:[n.jsx(a.Popover.Header,{children:"Device Errors"}),n.jsxs(a.Popover.Body,{children:["There were errors with properties on this device:",n.jsx("ul",{children:e.hardware.errors.map(o=>n.jsxs("li",{children:[o.property,":",n.jsxs("span",{className:"stack-trace",children:[o.traceback,n.jsx("br",{}),o.exception]})]}))})]})]}),children:n.jsx(a.Button,{variant:"danger",size:"sm",children:n.jsx("i",{className:"fa fa-exclamation-triangle"})})})]}),n.jsx("div",{className:"hw-content",children:e.widgetContent})]})}}function H(e){const t={display:"inline-block",minWidth:""};return e.minWidth&&(t.minWidth=`${e.minWidth}em`),n.jsx("div",{style:t,children:n.jsx(a.Badge,{bg:e.variant,children:e.state})})}function K(e){const{hardware:t}=e;function r(){if(!t.online)return"OFFLINE";let i="UNKNOWN";return e.hardware.properties.state&&([i]=e.hardware.properties.state),i}const s=r();return n.jsx(H,{state:s,minWidth:6,variant:s==="READY"?"success":"warning"})}function U(e){const{hardware:t}=e;function r(){if(!t.online)return"OFFLINE";const o=t.properties.state;return e.useReadyState&&(o==="OPEN"||o==="CLOSED")?"READY":o}const s=r();function i(){switch(s){case"READY":return"success";case"OPEN":return"success";case"CLOSED":return"danger";case"DISABLED":return"secondary";case"MOVING":case"STANDBY":case"OFFLINE":return"warning";case"FAULT":return"fatal";default:return"fatal"}}return n.jsx(H,{state:s,minWidth:6,variant:i()})}const Se=Object.freeze(Object.defineProperty({__proto__:null,HardwareState:H,MotorState:K,ShutterState:U},Symbol.toStringTag,{value:"Module"})),Oe=m.forwardRef((e,t)=>{const r=m.useRef(null),[s,i]=m.useState(e.step),o=j=>{const k=t;if(r.current===null)return;let B=Number.parseFloat(k.current.value);const V=Number.parseFloat(r.current.value);B+=j?V:-V,k.current.value=`${B}`,e.onStep&&e.onStep({target:k.current})},{onStep:d,step:l,overlay:h,incIcon:u,decIcon:c,swapIncDec:f,onKeyDown:g,horizontalArrows:C,largeArrows:I,...v}=e,_=j=>{j.key==="ArrowUp"?(j.preventDefault(),o(!0)):j.key==="ArrowDown"?(j.preventDefault(),o(!1)):g&&g(j)};if(!e.step)return n.jsx(a.Form.Control,{ref:t,type:"number",step:"any",onKeyDown:_,...v});const he=w.map(e.steps||[e.step],j=>n.jsx("option",{value:j,children:j},j));return n.jsx("div",{className:O.default("numeric-step",{"numeric-step-large":I,"numeric-step-horizontal":C}),children:n.jsxs(a.InputGroup,{children:[n.jsx(a.Form.Control,{onKeyDown:_,ref:t,type:"number",step:"any",...v}),n.jsxs(n.Fragment,{children:[h,!h&&n.jsxs(a.InputGroup.Text,{className:"d-flex flex-column",children:[n.jsx(a.Form.Control,{ref:r,as:"select",className:"step-size",defaultValue:s,onChange:j=>i(Number.parseFloat(j.target.value)),children:he}),e.unit&&n.jsx("div",{children:e.unit}),!u&&!c&&n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{className:"step step-up",disabled:e.disabled,onClick:j=>o(!0)}),n.jsx(a.Button,{className:"step step-down",disabled:e.disabled,onClick:j=>o(!1)})]})]}),c&&f&&n.jsx(a.Button,{disabled:e.disabled,onClick:j=>o(!1),children:n.jsx("i",{className:`fa fa-fw fa-${c}`})}),u&&n.jsx(a.Button,{disabled:e.disabled,onClick:j=>o(!0),children:n.jsx("i",{className:`fa fa-fw fa-${u}`})}),c&&!f&&n.jsx(a.Button,{disabled:e.disabled,onClick:j=>o(!1),children:n.jsx("i",{className:`fa fa-fw fa-${c}`})})]})]})})}),z=Oe;function W(e){const t=m.useRef(null),[r,s]=m.useState(!1),[i,o]=m.useState(!1);m.useEffect(()=>{t.current&&(e.hardwareValue===null?t.current.value="":t.current.value=e.hardwareValue.toString(),s(!1))},[e.hardwareValue]);function d(f){let g=f;e.precision!==void 0&&(g=Number.parseFloat(g).toFixed(e.precision)),t!=null&&t.current&&(t.current.value=g)}function l(){r&&setTimeout(()=>{d(e.hardwareValue),s(!1)},3e3)}function h(f){e.hardwareValue!==null&&(s(!0),t!=null&&t.current&&(t.current.value=f.target.value),f.target.value===e.hardwareValue.toString()&&s(!1))}function u(f){s(!1),e.onMoveRequested(f.target.value)}function c(f){switch(f.key){case"Enter":{s(!1);const g=Number.parseFloat(f.target.value),C=e.onMoveRequested(g);C&&C.catch(()=>{o(!0),setTimeout(()=>{d(e.hardwareValue),o(!1)},2e3)})}f.preventDefault(),f.stopPropagation();break;case"Esc":case"Escape":r&&(o(!1),s(!1),d(e.hardwareValue)),f.target.blur(),f.preventDefault(),f.stopPropagation();break}}return n.jsx(z,{id:e.id,className:O.default({"form-control-edited":r,"form-control-error":i,"hw-moving":e.hardwareIsMoving}),type:e.readOnly?"text":"number",ref:t,precision:e.precision,onChange:h,onBlur:l,onStep:u,onKeyDown:c,disabled:e.hardwareIsDisabled||e.readOnly||!e.hardwareIsReady,step:e.step,steps:e.steps,incIcon:e.incIcon,decIcon:e.decIcon,swapIncDec:e.swapIncDec,horizontalArrows:e.horizontalArrows,largeArrows:e.largeArrows,overlay:e.hardwareIsMoving&&!e.hardwareIsDisabled?n.jsx(a.Button,{variant:"danger",onClick:e.onAbortRequested,children:n.jsx("i",{className:"fa fa-times"})}):null})}function D(e){const t=m.useRef(null),[r,s]=m.useState(!1),[i,o]=m.useState(!1);function d(c){return e.precision!==void 0?Number.parseFloat(c).toFixed(e.precision):c}m.useEffect(()=>{var c;t.current&&(t.current.value=d((c=e.hardwareValue)==null?void 0:c.toString()),s(!1))},[e.hardwareValue,e.precision]);function l(c){const f=d(c);t!=null&&t.current&&(t.current.value=f)}function h(c){switch(c.key){case"Enter":{s(!1);const f=Number.parseFloat(c.target.value),g=e.onMoveRequested(f);g&&g.catch(()=>{o(!0),setTimeout(()=>{l(e.hardwareValue),o(!1)},2e3)}),c.preventDefault(),c.stopPropagation();break}case"Esc":case"Escape":r&&(o(!1),s(!1),l(e.hardwareValue)),c.target.blur(),c.preventDefault(),c.stopPropagation();break}}function u(c){s(!0),c.target,t!=null&&t.current&&(t.current.value=c.target.value),c.target.value===e.hardwareValue.toString()&&s(!1)}return n.jsx(a.Form.Control,{className:O.default({"form-control-edited":r,"form-control-error":i,"hw-moving":e.hardwareIsMoving}),type:"number",ref:t,onChange:u,onKeyDown:h,disabled:e.readOnly||e.hardwareIsMoving||e.hardwareIsDisabled,step:e.step})}function Ee(e){function t(i){return e.hardware.requestChange({property:"velocity",value:i})}function r(i){return e.hardware.requestChange({property:"acceleration",value:i})}let s="UNKNOWN";return e.hardware.properties.state&&([s]=e.hardware.properties.state),n.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:n.jsxs(a.Popover,{id:"popid",children:[n.jsxs(a.Popover.Header,{children:[e.hardware.name," details"]}),n.jsxs(a.Popover.Body,{children:[n.jsxs(a.Form.Group,{children:[n.jsx(a.Form.Label,{children:"Velocity"}),n.jsx(D,{hardwareValue:e.hardware.properties.velocity,onMoveRequested:t,hardwareIsDisabled:e.disabled,hardwareIsReady:s==="READY",hardwareIsMoving:s==="MOVING",readOnly:e.readOnly})]}),n.jsxs(a.Form.Group,{children:[n.jsx(a.Form.Label,{children:"Acceleration"}),n.jsx(D,{hardwareValue:e.hardware.properties.acceleration,onMoveRequested:r,hardwareIsDisabled:e.disabled,hardwareIsReady:s==="READY",hardwareIsMoving:s==="MOVING",readOnly:e.readOnly})]})]})]}),children:n.jsx(a.Button,{children:n.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Me(e){const{hardware:t,options:r={}}=e;function s(){t.requestChange({function:"stop"})}function i(u){return t.requestChange({property:"position",value:u,function:"move"})}let o="UNKNOWN";e.hardware.properties.state&&([o]=e.hardware.properties.state);const d=n.jsx(N,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),l=n.jsx(K,{hardware:t}),h=e.options?e.options.header:"top";return n.jsx(E,{hardware:t,widgetIcon:d,widgetState:l,widgetContent:n.jsxs(a.InputGroup,{children:[n.jsx(W,{id:t.id,hardwareValue:t.properties.position,hardwareIsDisabled:e.disabled,hardwareIsReady:o==="READY",hardwareIsMoving:o==="MOVING",onMoveRequested:i,onAbortRequested:s,precision:r.precision,readOnly:r.readOnly,step:r.step,steps:r.steps,incIcon:r.incicon,decIcon:r.decicon,swapIncDec:r.swapincdec,horizontalArrows:r.horizontalarrows,largeArrows:r.largearrows}),t.properties.unit&&n.jsx(a.InputGroup.Text,{children:t.properties.unit}),o!=="MOVING"&&r.extended&&n.jsx(Ee,{hardware:t,disabled:e.disabled,readOnly:r.readOnly}),o==="MOVING"&&!e.disabled&&!r.step&&n.jsx(a.Button,{variant:"danger",onClick:s,children:n.jsx("i",{className:"fa fa-times"})})]}),headerMode:h})}function Ae(e){const{hardware:t,options:r={}}=e,s=m.useRef(null);m.useEffect(()=>{if(!s.current){console.error("selectionRef ref is unset");return}s.current.value=t.properties.position},[t.properties.position]);function i(l){if(console.debug("change",l),!s||!s.current){console.error("selection ref is unset");return}t.requestChange({value:s.current.value,function:"move"})}function o(l){t.requestChange({function:"stop"})}const d=w.map(t.properties.positions,l=>n.jsx("option",{title:l.description,children:l.position},l.position));return n.jsxs("div",{className:"hw-component",children:[n.jsxs("div",{className:"hw-head",children:[n.jsx(N,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),n.jsx("div",{className:"name",children:t.name}),n.jsx(a.Badge,{bg:t.properties.state==="READY"?"success":"warning",children:t.properties.state})]}),n.jsx("div",{className:"hw-content",children:n.jsxs(a.InputGroup,{children:[n.jsxs(a.Form.Control,{className:"custom-select",as:"select",ref:s,disabled:e.disabled,defaultValue:t.properties.position,children:[n.jsx("option",{disabled:!0,children:"unknown"}),d]}),t.properties.state!=="MOVING"&&n.jsx(a.Button,{onClick:i,disabled:e.disabled,children:"Move"}),t.properties.state==="MOVING"&&!e.disabled&&n.jsx(a.Button,{variant:"danger",onClick:o,children:n.jsx("i",{className:"fa fa-times"})})]})})]})}const Fe=pe.default("daiquiri.components.hardware.NoObject");function Ie(e){if(e.options.emptyifnone)return Fe('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',e.id,e.name),n.jsx(n.Fragment,{});const t=n.jsx(N,{name:"NoObject",icon:"fam-hardware-any",online:!1}),r=n.jsx(n.Fragment,{}),s=n.jsx(n.Fragment,{children:"Missing"}),i=e.options?e.options.header:"top",o={id:e.id,name:e.name??"",alias:null,online:!1,properties:{},type:""};return n.jsx(E,{hardware:o,widgetIcon:t,widgetState:r,widgetContent:s,headerMode:i})}function ke(e){const t=e.online?"READY":"OFFLINE";return n.jsx(a.Badge,{bg:t==="READY"?"success":"warning",children:t})}function De(e){const{hardware:t,options:r={}}=e,s=n.jsx(N,{name:"Optic",icon:"fa-cog",online:t.online}),i=n.jsx(ke,{...t});function o(){const c=r.property;if(c===void 0)return"property is not set";if(c===null)return"property is null";let f=t;for(const g of c.split("/"))if(f=f[g],f===void 0)return`property '${c}' not found`;return`${f}`}function d(){const c=r.unit;if(!c)return null;if(!c.includes("properties"))return c;let f=e;for(const g of c.split("/"))if(f=f[g],f===void 0)return null;return`${f}`}const l=d(),h=n.jsxs(a.InputGroup,{children:[n.jsx(a.Form.Control,{value:o(),readOnly:!0}),l&&n.jsx(a.InputGroup.Text,{children:l})]}),u=e.options.header||"top";return n.jsx(E,{hardware:t,widgetIcon:s,widgetState:i,widgetContent:h,headerMode:u})}function $e(e){const{hardware:t}=e,r=()=>{t.requestChange({function:"reset"})};return n.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:n.jsxs(a.Popover,{id:"popid",children:[n.jsxs(a.Popover.Header,{children:[t.name," Details"]}),n.jsxs(a.Popover.Body,{children:[n.jsx("h6",{children:"Status"}),n.jsx("pre",{children:t.properties.status}),n.jsx("div",{className:"d-grid gap-2",children:n.jsx(a.Button,{onClick:r,disabled:e.disabled,children:"Reset"})})]})]}),children:n.jsx(a.Button,{className:"flex-grow-0",title:"Shutter Details",children:n.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Pe(e){const{hardware:t,options:r={}}=e,s=n.jsx(N,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),i=n.jsx(U,{hardware:t});function o(){return t.properties?t.properties.state:"UNKNOWN"}function d(v){return v==="OPEN"?["Close","close"]:v==="CLOSED"?["Open","open"]:v==="DISABLED"||v==="STANDBY"||v==="FAULT"?["Closed",""]:v==="MOVING"?["...",""]:["Unknown",""]}const l=o(),[h,u]=d(l),f={OPEN:"danger",CLOSED:"success",MOVING:"warning",DISABLED:"secondary",STANDBY:"danger",FAULT:"fatal",UNKNOWN:"warning"}[l]||"danger";function g(){t.requestChange({function:u})}const C=n.jsxs(a.ButtonGroup,{className:"d-flex flex-nowrap",children:[n.jsx(a.Button,{variant:f,onClick:g,disabled:e.disabled||u==="",children:h}),r.extended&&n.jsx($e,{...e})]}),I=e.options.header||"top";return n.jsx(E,{hardware:t,widgetIcon:s,widgetState:i,widgetContent:C,headerMode:I})}class Re extends m.Component{constructor(){super(...arguments),this.variants={}}render(){let t=this.variants.default;return this.props.options.variant in this.variants&&(t=this.variants[this.props.options.variant]),n.jsx(t,{...this.props})}}function Z(e){const[t,r]=m.useState({}),s=m.useRef(null);return m.useEffect(()=>{if(s.current){const i=s.current;r({width:i.clientWidth,height:i.clientHeight})}},[]),n.jsx("div",{ref:s,style:{width:"100%",height:"100%"},className:e.className,children:t.width>0&&n.jsx("div",{className:"full-sizer",style:{width:`${t.width}px`,height:`${t.height}px`,overflow:"scroll"},children:e.children})})}function Te(e){return n.jsx("div",{className:"panel-header",style:e.style,children:e.children})}function He(e){return n.jsx("div",{className:"panel-contents",style:e.style,children:e.children})}function p(e){const t=e.scroll?Z:m.Fragment;return n.jsx("div",{className:`panel ${e.className??""}`,style:e.style,children:n.jsx(t,{children:e.children})})}p.Header=Te;p.Contents=He;const _e=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Be=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),M={};function J(e,t){M[e]=t}function y(e,t,r=!0){if(!e)return n.jsx(n.Fragment,{});const{type:s}=e,i=s&&s in M?M[s]:M.component;return n.jsx(i,{yamlNode:e,panel:r},t)}function Ve({children:e,key:t,panel:r,options:s}){return r?n.jsx(p,{style:s.style,scroll:s.scroll,children:n.jsx(p.Contents,{children:e})},t):n.jsx(n.Fragment,{children:m.Children.map(e,i=>m.isValidElement(i)?m.cloneElement(i,{key:t,...i.props}):void 0)})}function Q(e,t){const{_parentNode:r,_indexFromParent:s,...i}=t;if(e&&Object.keys(i).length>0)throw new A(e,Object.keys(i))}class b extends Error{constructor(t,r){super(t),this.yamlNode=r}}class A extends b{constructor(t,r){super(`Unexpected keys: ${r.join(", ")}`,t),this.keys=r}}class S extends b{constructor(t,r){super(`Keys ${r.join(", ")} are missing`,t),this.keys=r}}class x extends b{constructor(t,r,s){super(`Key ${r} error: ${s}`,t),this.key=r,this.keyMessage=s}}function Ye(e){let t=e;for(;t._parentNode;)t=t._parentNode;return t}function Le(e){const t=[];let r=e;for(;r;)t.push({node:r,indexFromParent:r._indexFromParent}),r=r._parentNode;return t.reverse(),t}function X(e,t=null,r=null){if(e._parentNode)throw new Error("Attribute _parentNode was already defined by the yml layout.");const s={...e,_parentNode:t,_indexFromParent:r};if(e.children){const i=[...e.children];Object.freeze(i),s.children=i.map((o,d)=>X(o,s,d))}return Object.freeze(s),s}function ee(e){var t;return n.jsxs(a.Alert,{variant:"danger",children:[e.message,n.jsx("br",{}),n.jsx("pre",{children:(t=e.error)==null?void 0:t.stack})]})}function qe(e){const{error:t}=e;if(!(t instanceof b))return n.jsx(n.Fragment,{});function r(o,d=3){const l=Le(o.yamlNode),h=[];let u="";for(let c=1;c<l.length;c++){const{node:f,indexFromParent:g}=l[c];h.push(`${u}children:`),u+=" ".repeat(d),g===1?h.push(`${u}- type: ...`):(g??0>1)&&h.push(`${u}...`,`${u}...`,`${u}# children number ${g??0+1}`),h.push(`${u}- type: ${f.type}`),u+=" ".repeat(2)}return o instanceof A?o.keys.forEach(c=>{h.push(`${u}${c}: ... ${" ".repeat(50-u.length-c.length)}<-- unexpected key`)}):o instanceof S?o.keys.forEach(c=>{h.push(`${u}???: ${" ".repeat(50-u.length-c.length)}<-- key **${c}** is expected`)}):o instanceof x&&h.push(`${u}${o.key}: ${" ".repeat(50-u.length-o.key.length)}<-- ${o.keyMessage}`),h.join(`
2
- `)}const i=Ye(t.yamlNode).name;if(t instanceof A){const o=t.keys.length===1?"key":"keys";return n.jsxs(a.Alert,{variant:"danger",children:["Unexpected ",o," ",t.keys.map((d,l)=>n.jsxs(n.Fragment,{children:[l!==0&&", ",n.jsx("b",{children:d})]}))," ","from the layout name ",n.jsx("b",{children:i}),".",n.jsx("br",{}),n.jsx("pre",{className:"mt-3",children:r(t)}),n.jsx("br",{})]})}if(t instanceof S){const o=t.keys.length===1?"Key":"Keys";return n.jsxs(a.Alert,{variant:"danger",children:["Expected ",o," ",t.keys.map((d,l)=>n.jsxs(n.Fragment,{children:[l!==0&&", ",n.jsx("b",{children:d})]}))," ","from the layout name ",n.jsx("b",{children:i}),".",n.jsx("br",{}),n.jsx("pre",{className:"mt-3",children:r(t)}),n.jsx("br",{})]})}return t instanceof x?n.jsxs(a.Alert,{variant:"danger",children:["Error on key ",n.jsx("b",{children:t.key})," from the layout name ",n.jsx("b",{children:i}),".",n.jsx("br",{}),n.jsx("pre",{className:"mt-3",children:r(t)}),n.jsx("br",{})]}):n.jsx(ee,{...e})}const Y={hasError:!1,message:"",error:void 0};class te extends m.Component{constructor(t){super(t),this.reload=()=>{window.location.reload()},this.state=Y}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){var r,s;if(t instanceof b||!this.props.unhandledComponentDidCatch){this.setState({hasError:!0,message:t.message,error:t});return}(s=(r=this.props).unhandledComponentDidCatch)==null||s.call(r,t,i=>{this.setState({hasError:!0,message:t.message,error:t,...i})})}componentDidUpdate(t,r){this.state.hasError&&r.error!==void 0&&t.resetKey!==this.props.resetKey&&this.setState(Y)}render(){if(this.state.hasError){const{UnhandledErrorComponent:t}=this.props,{hasError:r,...s}=this.state;return n.jsxs(a.Container,{className:"mt-2",children:[n.jsx("h4",{children:"Something went wrong"}),this.state.error instanceof b&&n.jsx(qe,{message:this.state.message,error:this.state.error}),!(this.state.error instanceof b)&&n.jsx(n.Fragment,{children:t?n.jsx(t,{...s}):n.jsx(ee,{message:this.state.message,error:this.state.error})}),n.jsxs("p",{children:["This error has been logged. Please"," ",n.jsxs(a.Button,{size:"sm",onClick:this.reload,children:[n.jsx("i",{className:"fa fa-refresh"})," Reload"]})," ","the application"]})]})}return this.props.children}}function Ge(e,t,r){if(e&&r===void 0)throw new S(e,[t])}function Ke(e,t,r){if(typeof r!="string")throw new x(e,t,"A string is expected")}function Ue(e,t,r){if(typeof r!="boolean")throw new x(e,t,"A boolean is expected")}function ze(e,t,r){if(typeof r!="number")throw new x(e,t,"A number is expected")}function $(e,t,r){if(r!==void 0&&typeof r!="boolean")throw new x(e,t,"An optional boolean is expected")}function ne(e,t,r){if(r!==void 0&&typeof r!="string")throw new x(e,t,"An optional string is expected")}function We(e,t,r){if(!Array.isArray(r))throw new x(e,t,"A list of string is expected");r.forEach(s=>{if(typeof s!="string")throw new x(e,t,"A list of string is expected")})}function Ze(e,t,r){if(r!==void 0&&typeof r!="string"){if(!Array.isArray(r))throw new x(e,t,"An optional string or list of string is expected");r.forEach(s=>{if(typeof s!="string")throw new x(e,t,"An optional string or list of string is expected")})}}function Je(e,t,r){if(r!==void 0){if(!Array.isArray(r))throw new x(e,t,"An optional list of string is expected");r.forEach(s=>{if(typeof s!="string")throw new x(e,t,"A optional list of string is expected")})}}function re(e,t,r){if(r!==void 0&&typeof r!="number")throw new x(e,t,"An optional number is expected")}function Qe(e,t,r){if(r!==void 0){if(!Array.isArray(r))throw new x(e,t,"An optional list of numbers is expected");r.forEach(s=>{if(typeof s!="number")throw new x(e,t,"An optional list of numbers is expected")})}}function F(e,t){const{_parentNode:r,_indexFromParent:s,...i}=t;if(e&&Object.keys(i).length>0)throw new A(e,Object.keys(i))}function Xe(e,t,r){if(r!=="last"&&typeof r!="number")throw new x(e,t,'"last" or a number is expected')}function et(e,t,r){if(r!==void 0&&r!=="h5web"&&r!=="plotly")throw new x(e,t,'"h5web" or "plotly" string is expected')}const tt=Object.freeze(Object.defineProperty({__proto__:null,assertBoolean:Ue,assertDataCollectionId:Xe,assertKeyExpected:Ge,assertNoUnknownKeys:F,assertNumber:ze,assertOptionalBackend:et,assertOptionalBoolean:$,assertOptionalNumber:re,assertOptionalNumberList:Qe,assertOptionalString:ne,assertOptionalStringList:Je,assertOptionalStringOrStringList:Ze,assertString:Ke,assertStringList:We},Symbol.toStringTag,{value:"Module"}));function nt({yamlNode:e,panel:t}){const{type:r,style:s,children:i,...o}=e;return F(e,o),n.jsx(a.Row,{className:"ymllayout-row gx-0",style:s,children:w.map(i,(d,l)=>y(d,l,t))})}function rt({yamlNode:e,panel:t}){const{type:r,style:s,xs:i,children:o,...d}=e;return F(e,d),re(e,"xs",i),n.jsx(a.Col,{className:O.default("yamymllayout-col",{col:!!i}),style:s,xs:i,children:w.map(e.children,(l,h)=>y(l,h,t))})}const P={};function st(e,t){P[e]=t}function it(e,t){if(t===void 0)throw new S(e,["id"]);if(typeof t.id!="string")throw new x(e,"id","A string is expected")}function ot(e,t,r){if(r!==void 0){if(!Array.isArray(r))throw new x(e,"ids","A option list is expected");r.forEach((s,i)=>{try{it(e,s)}catch{throw new x(e,"ids",`The hardware description ${i} is wrong`)}})}}function at(e){const{providers:t={},yamlNode:r,ids:s,groupid:i,even:o,nowrap:d,...l}=e;if(ot(r,"ids",s),ne(r,"groupid",i),$(r,"even",o),$(r,"nowrap",d),F(r,l),!P.HardwareGroup)return n.jsx(a.Alert,{variant:"warning",children:"No `HardwareGroup` component registered"});const h=P.HardwareGroup;return n.jsx(h,{providers:t,ids:s,groupid:i,nowrap:d||!1,even:o||!1})}const R={hardwaregroup:at};function se(e,t){R[e]=t}function lt(e){Object.entries(e).forEach(([t,r])=>se(t,r))}function ct(e){const{yamlNode:t,panel:r}=e,{type:s,style:i,scroll:o,title:d,...l}=t;if(!(s in R))return n.jsx(p,{children:n.jsx(p.Contents,{children:n.jsxs(a.Alert,{variant:"warning",children:['Unknown component "',s,'"']})})});const h=R[t.type];return r?n.jsx(p,{style:i,scroll:o,children:n.jsxs(m.Suspense,{fallback:n.jsx("p",{children:"Loading..."}),children:[d&&n.jsx(p.Header,{children:d}),n.jsx(p.Contents,{children:n.jsx(h,{...l,yamlNode:t})})]})}):n.jsx(m.Suspense,{fallback:n.jsx("p",{children:"Loading..."}),children:n.jsx(h,{...l,yamlNode:t})})}function dt({yamlNode:e,panel:t}){const r=e.options||{};return n.jsx(a.Container,{className:"ymllayout-container",...r,children:w.map(e.children,(s,i)=>y(s,i,t))})}function ut(e){const{yamlNode:t}=e,r=t.options||{},s={};return r.centerContent&&(s.margin="auto"),n.jsxs(p,{className:"ymllayout-panel",...r,children:[t.title&&n.jsx(p.Header,{children:t.title}),n.jsx(p.Contents,{style:s,children:w.map(t.children,(i,o)=>y(i,o,!1))})]})}const ht=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15);function ft({yamlNode:e,panel:t}){const r=[];return w.each(e.children,(s,i)=>{r.push(n.jsx(a.Tab,{eventKey:ht(),title:s.title,children:y(s,0,!1)},i))}),t?n.jsxs(p,{className:"ymllayout-tabs",children:[e.title&&n.jsx(p.Header,{children:e.title}),n.jsx(p.Contents,{children:n.jsx(a.Tabs,{mountOnEnter:!0,children:r})})]}):n.jsx(a.Tabs,{children:r})}function mt(e){const{node:t}=e,{type:r,title:s,...i}=t;return Q(t,i),n.jsx("div",{style:{gridColumn:"1 / 3"},children:n.jsx("h3",{children:s})})}function pt(e){const{node:t,state:r,row:s}=e,{title:i}=t;function o(){if(t.id)return t.id}function d(){if(i!==void 0)return i;if(t.type==="hardware"){const h=o(),u={_parentNode:t._parentNode,_indexFromParent:t._indexFromParent,type:"hardware",id:h,variant:"name",emptyifnone:!0};return y(u,"a",!1)}return""}const l=d();return n.jsxs("div",{style:{textAlign:"center"},children:[n.jsx("h5",{style:{margin:"0px",whiteSpace:"nowrap"},children:l}),r&&n.jsx("div",{style:{position:"relative",top:-5},children:r})]})}function xt(e){const{node:t,row:r}=e,{titlealign:s,title:i,stateinheader:o=!1,variant:d,id:l,...h}=t;let u,c;if(h.type==="hardware")if(u={...h,id:l,variant:d},o){const f={...h,id:l,variant:"state",emptyifnone:!0};c=y(f,"k",!1)}else c=null;else u=h,c=null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{gridColumn:1,alignSelf:s??"center"},children:n.jsx(pt,{node:t,state:c,row:r})}),n.jsx("div",{style:{gridColumn:2},children:y(u,"k",!1)})]})}function gt(e){const{yamlNode:t,panel:r}=e,{type:s,children:i,options:o={},title:d,...l}=t;return Q(t,l),n.jsxs(p,{className:"ymllayout-form",...o,children:[t.title&&n.jsx(p.Header,{children:t.title}),n.jsx(p.Contents,{children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:"min-content auto"},children:w.map(i,(h,u)=>h.type==="formheader"?n.jsx(mt,{node:h,row:u},u):n.jsx(xt,{node:h,row:u},u))})})]})}function jt(e){const{yamlNode:t,panel:r}=e;return n.jsxs("div",{className:"ymllayout-grid",style:{gridTemplateColumns:t.columns,gridTemplateRows:t.rows},children:[w.map(t.children,(s,i)=>{const{columnSpan:o=1,rowSpan:d=1,...l}=s,h=o>1?`span ${o}`:void 0,u=d>1?`span ${d}`:void 0;return n.jsx("div",{className:"ymllayout-grid-cell",style:{gridColumn:h,gridRow:u},children:y(l,i,r)},i)})," "]})}function wt({yamlNode:e,panel:t}){const r=e.options||{};return n.jsx(Ve,{panel:t,options:r,children:n.jsx("div",{children:e.label})})}const ie={row:nt,col:rt,container:dt,component:ct,panel:ut,tabs:ft,form:gt,grid:jt,label:wt};Object.entries(ie).forEach(([e,t])=>{J(e,t)});function yt(e){var r;const t=m.useMemo(()=>X(e.layout),[e.layout]);return t.error?n.jsx("div",{className:`${e.className??""} ymllayout-main`,id:e.id,children:n.jsxs(p,{children:[n.jsx(p.Header,{children:"Layout Error"}),n.jsxs(p.Contents,{children:[n.jsxs("p",{children:["File: ",t.name]}),n.jsx(a.Alert,{variant:"warning",children:n.jsx("pre",{className:"mb-0",children:t.error})})]})]})}):n.jsx("div",{className:`${e.className??""} ymllayout-main`,id:e.id,children:n.jsx(te,{resetKey:t,unhandledComponentDidCatch:e.unhandledComponentDidCatch,UnhandledErrorComponent:e.UnhandledErrorComponent,children:(r=t.children)==null?void 0:r.map((s,i)=>y(s,i))})})}const vt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),oe={hardware:ue};function bt(e,t){oe[e]=t}function Nt(e){return n.jsxs(a.Col,{className:"monitor-panel-item bg-fatal",title:`Error from yaml configuration: ${e.message}`,children:[n.jsx("h1",{children:e.monitor.name}),n.jsx("div",{children:"Parsing error"})]})}function Ct(e){const t=w.map(e.monitors,(r,s)=>{const i=r.type??"hardware",o=oe[i];return o===void 0?n.jsx(Nt,{monitor:r,message:`Type ${i} unsupported`},`m${s}`):n.jsx(o,{monitor:r},`m${s}`)});return n.jsx("div",{className:O.default({"ms-auto":e.margin==="start"},"me-auto","monitor-panel",{"monitor-panel-light":e.bg==="light"}),children:n.jsx(a.Container,{fluid:!0,children:n.jsx(a.Row,{className:"flex-nowrap",children:t})})})}function ae(e){return n.jsx(a.Col,{className:"monitor-panel-item",children:e.children})}const T={};function St(e,t){T[e]=t}function le(e){if(!T.useHardware)throw new Error("No `useHardware` hook registered");return T.useHardware(e)}const ce=(e,t,r)=>{const s={">":(i,o)=>i>o,"<":(i,o)=>i<o,">=":(i,o)=>i>=o,"<=":(i,o)=>i<=o,"==":(i,o)=>i===o,"!=":(i,o)=>i!==o,in:(i,o)=>o.indexOf(i)>-1};if(e in s)return s[e](t,r)};function de(e,t,r){const s=e.split(t);return r?[s.slice(0,-r).join(t)].concat(s.slice(-r)):s}function L(e){const t=e!==void 0?de(e,".",1):[null,""],r=le(t[0]);if(r&&r.properties&&t[1]!==null)return Array.isArray(r.properties[t[1]])?r.properties[t[1]][0]:r.properties[t[1]]}function Ot(e){const t=e!==void 0&&!e.includes("."),r=e!==void 0?de(e,".",1):[null,""],s=le(r[0]);if(t)return e;if(s&&s.properties&&r[1]!==null)return`${s.properties[r[1]]}`}function ue(e){const{monitor:t}=e;let r=L(t.value)??"-";const s=Ot(t.unit),i=L(t.overlay),o=Number.parseFloat(`${r}`);Number.isNaN(o)||String(o).length>5&&(r=o.toPrecision(5));let d;t.comparator&&t.comparison&&(d=ce(t.comparator,r,t.comparison)?"valid":"invalid"),Number.isNaN(o)||s!==void 0&&(r=`${r} ${s}`);let l=m.Fragment;const h={};if(i){const u=`${i}`;let c=m.Fragment;u.includes(`
3
- `)&&(c="pre"),l=a.OverlayTrigger,h.placement="bottom",h.overlay=n.jsx(a.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:n.jsx(c,{children:u})})}return m.createElement(l,{...h,key:t.name},n.jsxs(ae,{children:[n.jsx("h1",{children:t.name}),n.jsx("div",{className:d,children:`${r}`})]}))}exports.Formatting=ve;exports.Frontend=Ne;exports.FullSizer=Z;exports.HWObject=vt;exports.HardwareInputNumber=D;exports.HardwareNumericStep=W;exports.HardwareSchema=Be;exports.HardwareState=Se;exports.HardwareTemplate=E;exports.HardwareTypes=_e;exports.HardwareVariant=Re;exports.Info=Ce;exports.KeyError=x;exports.MissingKeysError=S;exports.MonitorHardware=ue;exports.MonitorPanel=Ct;exports.MonitorPanelItem=ae;exports.MotorDefault=Me;exports.Multiposition=Ae;exports.NoObject=Ie;exports.NumericStep=z;exports.Panel=p;exports.Property=De;exports.ShutterDefault=Pe;exports.TypeIcon=N;exports.YAMLErrorBoundary=te;exports.YAMLLayout=yt;exports.YamlAsserts=tt;exports.dynamicOp=ce;exports.registerHardwareComponent=st;exports.registerMonitorComponent=bt;exports.registerRuntimeHook=St;exports.registerYamlComponent=se;exports.registerYamlComponents=lt;exports.registerYamlType=J;exports.renderYamlNode=y;exports.yamlMap=ie;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react-bootstrap"),h=require("react"),F=require("lodash"),Vt=require("lodash/debounce"),Lt=require("classnames"),Ut=require("js-quantities"),qt=require("debug"),Z=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},Ht=Z(Vt),A=Z(Lt),Wt=Z(Ut),zt=Z(qt);function Kt(n){const{hardware:t}=n,{online:o,locked:r=null}=t,a=o?(r!==null?"LOCKED":t.properties.state)||"UNKNOWN":"OFFLINE",c={READY:"success",OFFLINE:"warning",MOVING:"warning",DISABLED:"secondary",UNKNOWN:"danger",ERROR:"danger",FAILED:"danger",LOCKED:"warning"}[a]||"success";return e.jsx(s.Badge,{bg:c,children:a})}function Ce(n){const{hardware:t}=n;return e.jsx(Kt,{hardware:t})}function Oe(n){const{hardware:t,options:o}=n;function r(){return t.name?t.name:t.id}function a(){return o.overrideName!==void 0?o.overrideName:t.alias?t.alias:t.name?t.name:t.id}function i(){if(o.overrideName!==void 0)return`Real name: ${r()}`;if(t.alias)return`Real name: ${t.name}`}const c=a(),l=i();return e.jsx("span",{title:l,children:c})}function Ie(n){const{hardware:t,options:o={}}=n;function r(){const a=o.property;if(a===void 0)return"property is not set";if(a===null)return"property is null";let i=t;for(const c of a.split("/"))if(i=i[c],i===void 0)return`property '${a}' not found`;return`${i}`}return e.jsx(e.Fragment,{children:r()})}function Yt(n){const{activeMessage:t="Online",inactiveMessage:o="Offline",message:r="This device is"}=n;return e.jsx("div",{className:`dot-indicator small bg-${n.online?"success":"danger"}`,title:`${r} ${n.online?t:o}`})}function x(n){const{name:t,icon:o}=n;return e.jsxs("div",{className:"icon",title:t,children:[e.jsx("i",{className:`fa ${o}`}),e.jsx(Yt,{...n})]})}function w(n){const{headerMode:t,hardware:o}=n;function r(){return o.alias?o.alias:o.name?o.name:o.id}const a=r();switch(t){case"front":return e.jsx("div",{className:"hw-component",children:e.jsxs("div",{className:"hw-single",children:[n.widgetIcon,e.jsx("div",{className:"name",children:a}),e.jsx("div",{className:"d-inline-block",children:n.widgetContent})]})});case"none":return e.jsx("div",{className:"hw-component",children:e.jsx("div",{className:"hw-single",children:n.widgetContent})});case"state":return n.widgetState;default:return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[n.widgetIcon,e.jsx("div",{className:"name",children:e.jsx(s.Form.Label,{htmlFor:o.id,children:a})}),n.widgetState,n.hardware.errors&&n.hardware.errors.length>0&&e.jsx(s.OverlayTrigger,{trigger:"click",placement:"bottom",rootClose:!0,overlay:e.jsxs(s.Popover,{id:n.hardware.id,style:{maxWidth:500},children:[e.jsx(s.Popover.Header,{children:"Device Errors"}),e.jsxs(s.Popover.Body,{children:["There were errors with properties on this device:",e.jsx("ul",{children:n.hardware.errors.map(i=>e.jsxs("li",{children:[i.property,":",e.jsxs("span",{className:"stack-trace",children:[i.traceback,e.jsx("br",{}),i.exception]})]}))})]})]}),children:e.jsx(s.Button,{variant:"danger",size:"sm",children:e.jsx("i",{className:"fa fa-exclamation-triangle"})})})]}),e.jsx("div",{className:"hw-content",children:n.widgetContent})]})}}function Qt(n){const t=n.online?"READY":"OFFLINE";return e.jsx(s.Badge,{bg:t==="READY"?"success":"warning",children:t})}function Se(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Optic",icon:"fa-cog",online:t.online}),a=e.jsx(Qt,{...t});function i(){const d=o.property;if(d===void 0)return"property is not set";if(d===null)return"property is null";let m=t;for(const p of d.split("/"))if(m=m[p],m===void 0)return`property '${d}' not found`;return`${m}`}function c(){const d=o.unit;if(!d)return null;if(!d.includes("properties"))return d;let m=n;for(const p of d.split("/"))if(m=m[p],m===void 0)return null;return`${m}`}const l=c(),u=e.jsxs(s.InputGroup,{children:[e.jsx(s.Form.Control,{value:i(),readOnly:!0}),l&&e.jsx(s.InputGroup.Text,{children:l})]}),f=n.options.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:u,headerMode:f})}const Xt={state:Ce,name:Oe,info:Ie,property:Se},Jt=Xt,Zt={callables:[],id:"test_object",name:"test_object",online:!0,properties:{number:345,option:"one",state:"1",string:"asbkjdsah"},protocol:"bliss",require_staff:!1,type:"test"},en={$ref:"#/definitions/HWTestSchema",$schema:"http://json-schema.org/draft-07/schema#",asyncValidate:!1,cache:!0,definitions:{HWTestSchema:{additionalProperties:!1,properties:{callables:{$ref:"#/definitions/HardwareSchema",type:"object"},id:{title:"id",type:"string"},name:{title:"name",type:"string"},online:{title:"online",type:"boolean"},properties:{$ref:"#/definitions/TestPropertiesSchema",type:"object"},protocol:{title:"protocol",type:"string"},require_staff:{title:"require_staff",type:"boolean"},type:{title:"type",type:"string"}},type:"object"},HardwareSchema:{additionalProperties:!1,cache:!0,properties:{},type:"object"},TestPropertiesSchema:{additionalProperties:!1,cache:!0,properties:{number:{format:"integer",title:"number",type:"number"},option:{enum:["one","two","three"],enumNames:[],title:"option",type:"string"},state:{enum:["ON","OFF","UNKNOWN","ERROR"],enumNames:[],readOnly:!0,title:"state",type:"string"},string:{title:"string",type:"string"}},type:"object"}},save_presets:!1},tn={response:Zt,schema:en},nn={default:tn};function on(n){const{showActions:t=!1}=n,[o,r]=h.useState([]);function a(c,l){t?r([{kind:"call",event:{type:"call",name:c,value:l}},...o]):console.log("Request change:","call",c,l)}function i(c,l){const u={type:"setProperty",name:c,value:l};t?r([{kind:"setProperty",event:u},...o]):console.log("Request change:",u)}return e.jsxs(e.Fragment,{children:[h.Children.map(n.children,c=>h.isValidElement(c)?h.cloneElement(c,{...c.props,hardware:{actions:{setProperty:i,call:a},...c.props.hardware}}):void 0),o.length>0&&e.jsxs("div",{children:[e.jsx(s.Button,{onClick:()=>{r([])},children:"Clear"}),e.jsx(s.ListGroup,{variant:"flush",children:o.map((c,l)=>e.jsxs(s.ListGroup.Item,{variant:"secondary",className:"text-monospace",children:[c.kind," ",JSON.stringify(c.event)]},l))})]})]})}function S(n){const t={display:"inline-block",minWidth:""};return n.minWidth&&(t.minWidth=`${n.minWidth}em`),e.jsx("div",{style:t,children:e.jsx(s.Badge,{bg:n.variant,title:n.description,children:n.state})})}function Te(n){const{states:t,variants:o={},descriptions:r={},minWidth:a}=n,i=t[0]??"";if(t.length===0)return e.jsx(S,{state:"NoState",variant:"fatal",description:"The device no not expose any state",minWidth:a});if(t.length===1)return e.jsx(S,{state:i,variant:o[i]??"fatal",description:r[i],minWidth:a});const c={display:"inline-block",minWidth:a?`${a}em`:""};function l(u){return e.jsx(s.Tooltip,{id:"device-state",...u,children:t.map((f,d)=>{const m=r[f],p=f.startsWith("_")?f.slice(1):f;return e.jsxs(s.Row,{className:"gx-0",children:[e.jsx(s.Col,{sm:"3",className:"text-end",children:e.jsx(s.Badge,{className:"text-right",bg:o[f]??"fatal",children:p})}),e.jsx(s.Col,{sm:"9",className:"text-start lh-1 my-auto ps-1",children:m})]})})})}return e.jsx("div",{style:c,children:e.jsx(s.OverlayTrigger,{placement:"top",delay:{show:250,hide:400},overlay:l,children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx(s.Badge,{className:"rounded-end-0",bg:o[i]??"fatal",children:i}),e.jsxs(s.Badge,{className:"rounded-start-0",bg:"secondary",children:["+",t.length-1]})]})})})}const rn=Object.freeze(Object.defineProperty({__proto__:null,HardwareMultiState:Te,HardwareState:S},Symbol.toStringTag,{value:"Module"}));function ee(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",r={ON:"danger",OFF:"success",MOVING_ON:"warning",MOVING_OFF:"warning",UNKNOWN:"fatal",OFFLINE:"warning"},a=r[o]||r.UNKNOWN;return e.jsx(S,{state:o,minWidth:6,variant:a})}function sn(n){const{hardware:t}=n;return e.jsx(ee,{hardware:t})}function an(n){const{hardware:t,options:o,disabled:r}=n,{state:a}=t.properties??"OFFLINE",i=a==="ON",c=a==="OFF";return e.jsx("div",{style:{display:"grid",gridTemplateRows:"min-content min-content",gridTemplateColumns:"min-content auto",gridGap:"1px"},children:e.jsxs(s.ButtonGroup,{className:"mx-auto",style:{width:"12em"},children:[e.jsx(s.Button,{onClick:()=>{t.actions.call("on")},disabled:!i||r,style:{width:"5em"},children:e.jsx("span",{className:"text-nowrap",children:"On"})}),e.jsx(s.Button,{onClick:()=>{t.actions.call("off")},disabled:!c||r,style:{width:"5em"},children:e.jsx("span",{className:"text-nowrap",children:"Off"})})]})})}function Me(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Air bearing",icon:"fa-hand-point-right",online:t.online}),a=e.jsx(ee,{hardware:t});function i(){return e.jsx(an,{...n})}const c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i(),headerMode:c})}function R(n){const{value:t,variant:o,style:r,className:a,title:i}=n,c=o?`badge-${o} bg-${o} text-bg-${o} border-${o}`:"border-light";return e.jsx(s.Form.Control,{className:`${c} ${a} bg-secondary`,style:r,value:t,title:i,readOnly:!0})}function ve(n){return e.jsx(s.Button,{variant:n.isActive?"primary":n.wasActivated?"warning":"secondary",onClick:n.onClick,disabled:n.disabled||n.wasActivated,title:n.title,children:e.jsxs(s.Row,{className:"gx-0",children:[e.jsx("i",{className:`col-sm-4 justify-content-center align-self-center ${n.icon}`}),e.jsx(s.Col,{sm:"8",children:n.children})]})})}function cn(n){var d;const{hardware:t,options:o={},disabled:r}=n;function a(){t.actions.call("on")}function i(){t.actions.call("off")}const c=((d=t.properties)==null?void 0:d.state)??"UNKNOWN",l=c==="MOVING_ON"||c==="MOVING_OFF",u=c==="MOVING_ON",f=c==="MOVING_OFF";return e.jsxs(s.Dropdown,{children:[e.jsx(s.Dropdown.Toggle,{variant:"secondary",disabled:r||l}),e.jsx(s.Dropdown.Menu,{children:e.jsxs(s.Container,{children:[e.jsx(s.Row,{children:e.jsx(s.Col,{className:"text-center",children:"Actions"})}),e.jsx(s.Row,{children:e.jsx(s.Col,{children:e.jsxs(s.ButtonGroup,{children:[e.jsxs(ve,{icon:"fa fa-arrow-up",wasActivated:u,onClick:()=>{a()},disabled:r||l,title:"Turn on the air bearing",children:["Turn",e.jsx("br",{}),"on"]}),e.jsxs(ve,{icon:"fa fa-arrow-down",wasActivated:f,onClick:()=>{i()},disabled:r||l,title:"Turn off the air bearing",children:["Turn",e.jsx("br",{}),"off"]})]})})})]})})]})}function ln(n){const{hardware:t,options:o,disabled:r}=n,{state:a}=t.properties??"OFFLINE",c={ON:"danger",OFF:"success",MOVING_ON:"warning",MOVING_OFF:"warning",UNKNOWN:"fatal",OFFLINE:"warning"}[a]??"fatal";return e.jsxs(s.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(R,{variant:c,className:"text-center",style:{minWidth:"10em"},value:a}),e.jsx(cn,{...n})]})}function Fe(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Air bearing",icon:"fa-hand-point-right",online:t.online}),a=e.jsx(ee,{hardware:t});function i(){return e.jsx(ln,{...n})}const c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i(),headerMode:c})}const dn={default:Me,protected:Fe,state:sn},un=dn,fn=["on","off","sync_hard"],mn="airbearing",pn="airbearing",hn=!0,xn={state:"ON"},gn="bliss",jn=!1,wn="airbearing",vn={callables:fn,id:mn,name:pn,online:hn,properties:xn,protocol:gn,require_staff:jn,type:wn},Nn={default:vn};function yn(n){const t={24:"Y",21:"Z",18:"E",15:"P",12:"T",9:"G",6:"M",3:"k","-3":"m","-6":"µ","-9":"n","-12":"p","-15":"f","-18":"a","-21":"z","-24":"y"},o=Math.log(n)/Math.log(1e3),r=!Number.isInteger(o),a=3*Math.ceil(o-(r?1:0)),i=a===0?"":t[a];return{scalar:n*10**-a,prefix:i,multiplier:10**-a}}function bn(n){return n.charAt(0).toUpperCase()+n.slice(1)}function De(n){if(n<60)return`${Math.round(n)} sec`;const t=Math.round(n/60),o=t%60,r=Math.floor(t/60);return r?`${r} hr ${o} min`:`${o} min`}function _n(n){return n>0?(662607004e-42*299792458/(n*1e-10)/160218e-24*.001).toFixed(4):0}function $n(n,t){return Number.parseFloat(n.toFixed(t))}const Cn=Object.freeze(Object.defineProperty({__proto__:null,formatEng:yn,round:$n,toEnergy:_n,toHoursMins:De,ucfirst:bn},Symbol.toStringTag,{value:"Module"}));function On(n){const{hardware:t}=n;function o(){t.actions.call("reset")}const r={"Front End":"feitlk",Experimental:"expitlk",PSS:"pssitlk"},a={Current:`${t.properties.current.toFixed(1)} mA`,Mode:t.properties.mode,Refill:De(t.properties.refill),Message:e.jsx("pre",{children:t.properties.message})};function i(c){if(!(c in t.properties))return"UNKNOWN";const l=t.properties[c];return!l||typeof l!="string"?"UNKNOWN":l}return e.jsx(s.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(s.Popover,{id:"popid",children:[e.jsxs(s.Popover.Header,{children:[t.name," Details"]}),e.jsxs(s.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("h6",{children:"Interlocks"}),e.jsx(s.Container,{children:F.map(r,(c,l)=>e.jsxs(s.Row,{children:[e.jsxs(s.Col,{children:[l,":"]}),e.jsx(s.Col,{children:e.jsx(s.Badge,{bg:i(c)==="ON"?"success":"danger",children:i(c)})})]},l))}),e.jsx("h6",{children:"Ring Status"}),e.jsx(s.Container,{children:F.map(a,(c,l)=>e.jsxs(s.Row,{children:[e.jsxs(s.Col,{children:[l,":"]}),e.jsx(s.Col,{children:c})]},l))}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(s.Button,{disabled:n.disabled,onClick:o,children:"Reset"})})]})]}),children:e.jsx(s.Button,{className:"flex-grow-0",title:"Shutter Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Ee(n){const{hardware:t,options:o={}}=n;function r(){t.actions.call(t.properties.frontend==="FE open"?"close":"open")}return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(x,{name:"Frontend",icon:"fam-hardware-frontend",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(s.Badge,{bg:t.properties.state==="OPEN"||t.properties.state==="RUNNING"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(s.ButtonGroup,{className:"d-flex",children:[e.jsx(s.Button,{variant:t.properties.frontend==="FE open"?"danger":"success",onClick:r,disabled:n.disabled,children:t.properties.frontend==="FE open"?"Close":"Open"}),e.jsx(On,{...n})]})})]})}const In={default:Ee},Sn=In,Tn=["open","close","reset"],Mn="fe",Fn="fe",Dn=!0,En={current:196.58051532652968,expitlk:"ON",feitlk:"ON",frontend:"FE open",pssitlk:"ON",refill:2287,state:"RUNNING",mode:"USM",message:"USM until 18:00",status:`State : The Front End is open with automatic opening mode on
2
+ Mode : Beam Delivery
3
+ Automatic : Automatic opening active
4
+ Type : UHV
5
+
6
+ Module 1 Gate Valve 1: Open
7
+ Module 1 Gate Valve 2: Open
8
+ Module 2 Gate Valve 1: Open
9
+
10
+ `},Rn="tango",An=!0,kn="frontend",Bn={callables:Tn,id:Mn,name:Fn,online:Dn,properties:En,protocol:Rn,require_staff:An,type:kn},Pn={default:Bn};function Gn(n){const{hardware:t}=n,o=()=>{t.actions.call(t.properties.state==="ON"?"off":"on")};return e.jsx(s.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(s.Popover,{id:"popid",children:[e.jsxs(s.Popover.Header,{children:[t.name," Details"]}),e.jsxs(s.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(s.Button,{disabled:n.disabled,onClick:o,children:t.properties.state==="ON"?"Off":"On"})})]})]}),children:e.jsx(s.Button,{title:"Gauge Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Re(n){const{hardware:t,options:o={}}=n;return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(x,{name:"Gauge",icon:"fam-hardware-gauge",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(s.Badge,{bg:t.properties.state==="ON"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(s.InputGroup,{children:[e.jsx(s.Form.Control,{value:t.properties.pressure.toExponential(o.precision||3),disabled:!0}),(t.properties.unit||o.unit)&&e.jsx(s.InputGroup.Text,{children:t.properties.unit||o.unit}),e.jsx(Gn,{...n})]})})]})}const Vn={default:Re},Ln=Vn,Un=["off","on"],qn="pir121",Hn="pir121",Wn=!0,zn={pressure:.0007999999797903001,state:"ON",status:`
11
+ Gauge is underrange - Channel B2 (4)
12
+ Rel. | Lower | Upper | SA | State
13
+ 1 | 1.0e-6| 3.0e-6| 1 | ON
14
+ 2 | 4.0e-3| 6.0e-3| 2 | ON
15
+ 3 | 1.0e-6| 3.0e-6| 3 | ON
16
+ 4 | 4.0e-3| 6.0e-3| 4 | ON
17
+ A | 4.0e-3| 1.0e-5| 6 | ON
18
+ B | 4.0e-3| 1.0e-5| 8 | ON
19
+
20
+ HDB Storage OK`},Kn="tango",Yn=!0,Qn="gauge",Xn={callables:Un,id:qn,name:Hn,online:Wn,properties:zn,protocol:Kn,require_staff:Yn,type:Qn},Jn=["off","on"],Zn="pen121",eo="pen121",to=!0,no={pressure:13999999737279722e-23,state:"ON",status:`Gauge is ON - Channel B1 (3)
21
+ Rel. | Lower | Upper | SA | State
22
+ 1 | 1.0e-6| 3.0e-6| 1 | ON
23
+ 2 | 4.0e-3| 6.0e-3| 2 | ON
24
+ 3 | 1.0e-6| 3.0e-6| 3 | ON
25
+ 4 | 4.0e-3| 6.0e-3| 4 | ON
26
+ A | 4.0e-3| 1.0e-5| 6 | ON
27
+ B | 4.0e-3| 1.0e-5| 8 | ON
28
+ `},oo="tango",ro=!0,so="gauge",ao={callables:Jn,id:Zn,name:eo,online:to,properties:no,protocol:oo,require_staff:ro,type:so},io={default:Xn,default2:ao},co=h.forwardRef((n,t)=>{const o=h.useRef(null),r=h.useRef(),[a,i]=h.useState(n.step),[c,l]=h.useState(!1),u=_=>{const le=t;if(o.current===null)return;let L=Number.parseFloat(le.current.value);if(o.current.value.startsWith("*")){const U=Number.parseFloat(o.current.value.replace("*",""));L=_?L*U:L/U}else{const U=Number.parseFloat(o.current.value);L+=_?U:-U}le.current.value=`${L}`,n.onStep&&n.onStep({target:le.current})},{onStep:f,step:d,overlay:m,incIcon:p,decIcon:j,swapIncDec:y,onKeyDown:g,onBlur:b,horizontalArrows:v,largeArrows:I,disabled:T,...N}=n,O=_=>{_.key==="ArrowUp"?(_.preventDefault(),l(!0),u(!0)):_.key==="ArrowDown"?(_.preventDefault(),l(!0),u(!1)):g&&g(_)};c&&(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{var _;(_=t==null?void 0:t.current)==null||_.focus()},100)),h.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]);const M=()=>{r.current&&clearTimeout(r.current),l(!1),b&&b()};if(!n.step)return e.jsx(s.Form.Control,{ref:t,type:"number",step:"any",onKeyDown:O,onBlur:M,disabled:T,...N});const V=F.map(n.steps||[n.step],_=>e.jsx("option",{value:_,children:_},_)),Gt=p||j;return e.jsx("div",{className:A.default("numeric-step",{"numeric-step-large":I,"numeric-step-horizontal":v}),children:e.jsxs(s.InputGroup,{children:[e.jsx(s.Form.Control,{onKeyDown:O,onBlur:M,ref:t,type:"number",step:"any",disabled:T||n.stepOnly,...N}),e.jsxs(e.Fragment,{children:[m,!m&&e.jsxs(s.InputGroup.Text,{className:`d-flex flex-column ${Gt?"inc-dec":""}`,children:[e.jsx(s.Form.Control,{ref:o,as:"select",className:"step-size",defaultValue:a,disabled:T,onChange:_=>i(Number.parseFloat(_.target.value)),children:V}),n.unit&&e.jsx("div",{children:n.unit}),!p&&!j&&e.jsxs(e.Fragment,{children:[e.jsx(s.Button,{className:"step step-up",disabled:n.disabled,onClick:_=>u(!0)}),e.jsx(s.Button,{className:"step step-down",disabled:n.disabled,onClick:_=>u(!1)})]})]}),j&&y&&e.jsx(s.Button,{disabled:n.disabled,onClick:_=>u(!1),children:e.jsx("i",{className:`fa fa-fw fa-${j}`})}),p&&e.jsx(s.Button,{disabled:n.disabled,onClick:_=>u(!0),children:e.jsx("i",{className:`fa fa-fw fa-${p}`})}),j&&!y&&e.jsx(s.Button,{disabled:n.disabled,onClick:_=>u(!1),children:e.jsx("i",{className:`fa fa-fw fa-${j}`})})]})]})})}),Ae=co;function te(n){const t=h.useRef(null),[o,r]=h.useState(!1),[a,i]=h.useState(!1);h.useEffect(()=>{t.current&&(n.hardwareValue===null?t.current.value="":n.precision!==void 0?t.current.value=n.hardwareValue.toFixed(n.precision):t.current.value=n.hardwareValue.toString(),r(!1))},[n.hardwareValue]);function c(m){let p=m;n.precision!==void 0&&(p=Number.parseFloat(p).toFixed(n.precision)),t!=null&&t.current&&(t.current.value=p)}function l(){o&&setTimeout(()=>{c(n.hardwareValue),r(!1)},3e3)}function u(m){n.hardwareValue!==null&&r(m.target.value!==n.hardwareValue.toString())}function f(m){r(!1);const p=n.onMoveRequested(m.target.value);p&&p.catch(()=>{i(!0),setTimeout(()=>{c(n.hardwareValue),i(!1)},2e3)})}function d(m){switch(m.key){case"Enter":{r(!1);const p=Number.parseFloat(m.target.value),j=n.onMoveRequested(p);j&&j.catch(()=>{i(!0),setTimeout(()=>{c(n.hardwareValue),i(!1)},2e3)})}m.preventDefault(),m.stopPropagation();break;case"Esc":case"Escape":o&&(i(!1),r(!1),c(n.hardwareValue)),m.target.blur(),m.preventDefault(),m.stopPropagation();break}}return e.jsx(Ae,{id:n.id,className:A.default({"form-control-edited":o,"form-control-error":a,"hw-moving":n.hardwareIsMoving}),type:n.readOnly?"text":"number",ref:t,precision:n.precision,onChange:u,onBlur:l,onStep:f,onKeyDown:d,disabled:n.hardwareIsDisabled||n.readOnly||!n.hardwareIsReady,stepOnly:n.stepOnly,step:n.step,steps:n.steps,incIcon:n.incIcon,decIcon:n.decIcon,swapIncDec:n.swapIncDec,horizontalArrows:n.horizontalArrows,largeArrows:n.largeArrows,overlay:n.hardwareIsMoving&&!n.hardwareIsDisabled?e.jsx(s.Button,{variant:"danger",onClick:n.onAbortRequested,children:e.jsx("i",{className:"fa fa-times"})}):null})}function ke(n){const{hardware:t,options:o={},disabled:r}=n;function a(f){return t.actions.setProperty("power",f)}function i(f){return t.actions.call(f?"on":"off")}const c=t.properties.state,l=e.jsx(x,{name:"Laser",icon:"fam-hardware-laser",online:t.online}),u=e.jsx(S,{state:c,minWidth:6,variant:c==="ON"?"success":"warning"});return e.jsx(w,{hardware:t,widgetIcon:l,widgetState:u,widgetContent:e.jsxs(s.InputGroup,{children:[e.jsx(te,{id:t.id,hardwareValue:t.properties.power,hardwareIsDisabled:!1,hardwareIsReady:!0,hardwareIsMoving:c==="MOVING",onMoveRequested:a,onAbortRequested:()=>null,precision:1,readOnly:!1,step:o.step,steps:o.steps,incIcon:void 0,decIcon:void 0,swapIncDec:void 0}),e.jsx(s.Button,{size:"sm",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>{i(t.properties.state!=="ON")},children:e.jsx("i",{className:t.properties.state==="ON"?"fa fa-toggle-on":"fa fa-toggle-off"})})]})})}const lo={default:ke},uo=lo,fo=[],mo="yag1",po="yag1",ho=!0,xo={power:5,state:"ON"},go="bliss",jo=!1,wo="laser",vo={callables:fo,id:mo,name:po,online:ho,properties:xo,protocol:go,require_staff:jo,type:wo},No={default:vo};function yo(n){var o;const{hardware:t}=n;return e.jsx(s.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(s.Popover,{id:"laserheating_overlay",children:[e.jsxs(s.Popover.Header,{children:[t.name," details"]}),e.jsx(s.Popover.Body,{children:e.jsxs(s.Container,{children:[e.jsxs(s.Row,{children:[e.jsx(s.Col,{children:"Background Mode"}),e.jsx(s.Col,{children:t.properties.background_mode})]}),e.jsxs(s.Row,{children:[e.jsx(s.Col,{children:"Calibration"}),e.jsx(s.Col,{children:t.properties.current_calibration})]}),e.jsxs(s.Row,{children:[e.jsx(s.Col,{children:"Fit Wavelength"}),e.jsxs(s.Col,{children:[(o=t.properties.fit_wavelength)==null?void 0:o.join(" - ")," ",e.jsx("span",{children:"nm"})]})]})]})})]}),children:e.jsx(s.Button,{children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Be(n){const{hardware:t,options:o={},disabled:r}=n,[a,i]=h.useState(!1);function c(m){return m<=0?Promise.reject(new Error("exposure_time must be > 0")):t.actions.setProperty("exposure_time",m)}function l(){i(!0);const m=t.actions.call("measure");return m!==void 0&&(console.log("pending"),m.then(()=>{i(!1)}).catch(p=>{i(!1)})),m}const u=t.properties.state,f=e.jsx(x,{name:"Laser Heating",icon:"fa-fire",online:t.online}),d=e.jsx(S,{state:u,minWidth:6,variant:u==="READY"?"success":"warning"});return e.jsx(w,{hardware:t,widgetIcon:f,widgetState:d,widgetContent:e.jsxs(s.InputGroup,{children:[e.jsx(te,{id:t.id,hardwareValue:t.properties.exposure_time,hardwareIsReady:!0,hardwareIsDisabled:n.disabled,hardwareIsMoving:!1,onMoveRequested:c,onAbortRequested:()=>null,precision:1,readOnly:!1,step:o.exposureStep,steps:o.exposureSteps,incIcon:void 0,decIcon:void 0,swapIncDec:void 0}),e.jsx(s.InputGroup.Text,{children:"s"}),e.jsx(s.Button,{size:"sm",disabled:n.disabled||a,onClick:()=>{l()},children:a?e.jsx("i",{className:"fa fa-spinner fa-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"fa fa-play me-1"}),"Measure"]})}),e.jsx(yo,{hardware:t,disabled:n.disabled})]})})}const bo={default:Be},_o=bo,$o=[],Co="laserheating",Oo="laserheating",Io=!0,So={exposure_time:.5,state:"ON",background_mode:"READY",fit_wavelength:[500,650],current_calibration:"/path/to/file"},To="bliss",Mo=!1,Fo="laserheating",Do={callables:$o,id:Co,name:Oo,online:Io,properties:So,protocol:To,require_staff:Mo,type:Fo},Eo={default:Do};function Pe(n){const t=h.useRef(null),{hardware:o,options:r={}}=n;function a(c){o.actions.setProperty("intensity",c)}const i=h.useCallback(Ht.default(a,100),[]);return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(x,{name:"Light",icon:"fa-lightbulb-o",online:o.online}),e.jsx("div",{className:"name",children:o.name}),e.jsx(s.Badge,{bg:o.properties.state==="ON"?"success":"danger",children:o.properties.state})]}),e.jsxs("div",{className:"hw-content",children:[e.jsx(s.Form.Control,{ref:t,disabled:n.disabled,type:"range",min:"0",max:"100",onChange:c=>i(Number.parseFloat(c.target.value)),defaultValue:o.properties.intensity}),e.jsxs("div",{children:[e.jsx(s.Button,{disabled:o.properties.intensity===0,size:"sm",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>i(0),children:e.jsx("i",{className:"fa fa-power-off"})}),e.jsxs("span",{className:"float-end",children:[o.properties.intensity," %"]})]})]})]})}const Ro={default:Pe},Ao=Ro,ko=[],Bo="light_vlm",Po="light_vlm",Go=!0,Vo={intensity:0,state:"ON",temperature:23.2},Lo="bliss",Uo=!1,qo="light",Ho={callables:ko,id:Bo,name:Po,online:Go,properties:Vo,protocol:Lo,require_staff:Uo,type:qo},Wo={default:Ho};function B(n){const{hardware:t}=n,{online:o,locked:r=null}=t,a=t.properties.state??"UNKNOWN";console.log(a);const i=o?(a==="ACQUIRING"?a:r!==null?"LOCKED":a)||"UNKNOWN":"OFFLINE",c={UNKNOWN:"critical",ACQUIRING:"warning",READY:"success",OFFLINE:"secondary",LOCKED:"warning"},l=c[i]??c.UNKNOWN;return e.jsx(S,{state:i,minWidth:6,variant:l})}function zo(n){const{hardware:t}=n;return e.jsx(B,{hardware:t})}function Ne(n){const{hardware:t,options:o={}}=n;return e.jsx(s.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:e.jsx("div",{children:t.name})})}function Ge(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(B,{hardware:t}),i=o.header||"top";return i==="none"?e.jsx(Ne,{...n}):e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:e.jsx(Ne,{...n}),headerMode:i})}function ye(n){const{hardware:t,options:o={}}=n,[r,a]=t.properties.size??["?","?"];return e.jsxs(s.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:[e.jsxs("div",{children:[r," × ",a]}),e.jsx("div",{className:"ms-auto",children:e.jsx("small",{children:e.jsx("small",{children:"px"})})})]})}function Ve(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(B,{hardware:t}),i=o.header??"top";return i==="none"?e.jsx(ye,{...n}):e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:e.jsx(ye,{...n}),headerMode:i})}function Ko(n){const{hardware:t}=n,{properties:o}=t,[r,a]=o.flip,i=o.rotation??0,c=!r&&!a&&i===0;return e.jsx("div",{children:e.jsxs(s.InputGroup.Text,{children:[r&&e.jsxs(s.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Flip",e.jsx("i",{className:"fa fa-fw fa-left-right"})]}),a&&e.jsxs(s.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Flip",e.jsx("i",{className:"fa fa-fw fa-up-down"})]}),i!==0&&e.jsxs(s.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Rot ",i.toFixed(0),e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]}),c&&e.jsx(s.Badge,{bg:"secondary",style:{fontSize:"130%"},title:"No transformation",children:"None"})]})})}function Le(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(B,{hardware:t}),i=e.jsx(e.Fragment,{children:e.jsx(Ko,{hardware:t})}),c=o.header??"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}function Yo(n){const{hardware:t,disabled:o}=n,{properties:r}=t,[a,i]=r.binning,c=a===i?a:0;function l(u){t.actions.setProperty("binning",[u,u])}return e.jsxs(s.InputGroup,{children:[e.jsx(s.InputGroup.Text,{title:"Binning applied to the detector",children:e.jsx("i",{className:"fa fa-fw fa-ruler-combined fa-2x"})}),e.jsx(s.Form.Control,{value:`${r.binning[0]}`,readOnly:!0}),e.jsx(s.Form.Control,{value:`${r.binning[1]}`,readOnly:!0}),e.jsx(s.Button,{variant:c===1?"primary":"secondary",onClick:()=>{l(1)},disabled:o,children:"1"}),e.jsx(s.Button,{variant:c===2?"primary":"secondary",onClick:()=>{l(2)},disabled:o,children:"2"}),e.jsx(s.Button,{variant:c===3?"primary":"secondary",onClick:()=>{l(3)},disabled:o,children:"3"}),e.jsx(s.Button,{variant:c===4?"primary":"secondary",onClick:()=>{l(4)},disabled:o,children:"4"})]})}function Ue(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(B,{hardware:t}),i=e.jsx(e.Fragment,{children:e.jsx(Yo,{...n})}),c=o.header??"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}function Qo(n){const{hardware:t}=n,{properties:o}=t;return e.jsxs(s.InputGroup,{children:[e.jsx(s.InputGroup.Text,{title:"Rotation applied to the detector",children:e.jsx("i",{className:"fa fa-fw fa-crop-simple fa-2x"})}),e.jsx(s.Form.Control,{value:`${o.roi[0]}`,readOnly:!0}),e.jsx(s.Form.Control,{value:`${o.roi[1]}`,readOnly:!0}),e.jsx(s.Form.Control,{value:`${o.roi[2]}`,readOnly:!0}),e.jsx(s.Form.Control,{value:`${o.roi[3]}`,readOnly:!0}),e.jsx(s.InputGroup.Text,{children:"px"})]})}function qe(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(B,{hardware:t}),i=e.jsx(e.Fragment,{children:e.jsx(Qo,{hardware:t})}),c=o.header??"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}function Xo(n){const{hardware:t}=n,{properties:o}=t,r=o.static,[a,i]=(r==null?void 0:r.image_max_dim)??["?","?"];return e.jsxs(s.InputGroup,{children:[e.jsx(s.InputGroup.Text,{title:"Max size of the detector",children:"Max size"}),e.jsx(s.Form.Control,{value:`${a} × ${i}`,readOnly:!0}),e.jsx(s.InputGroup.Text,{children:"px"})]})}function Jo(n){const{hardware:t}=n,{properties:o}=t,r=o.static;return e.jsxs(s.InputGroup,{children:[e.jsx(s.InputGroup.Text,{title:"Version of the Lima server",children:"Lima version"}),e.jsx(s.Form.Control,{value:`${r==null?void 0:r.lima_version}`,readOnly:!0})]})}function Zo(n){const{hardware:t}=n,{properties:o}=t,r=o.static;return e.jsxs(s.InputGroup,{children:[e.jsx(s.InputGroup.Text,{title:"Model of the detector",children:"Type/model"}),e.jsx(s.Form.Control,{value:`${r==null?void 0:r.camera_type}`,readOnly:!0}),e.jsx(s.Form.Control,{value:`${r==null?void 0:r.camera_model}`,readOnly:!0})]})}function He(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(B,{hardware:t}),i=e.jsxs(e.Fragment,{children:[e.jsx(Zo,{hardware:t}),e.jsx(Xo,{hardware:t}),e.jsx(Jo,{hardware:t})]}),c=o.header??"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}const k={};function er(n){n.useHardware&&(k.useHardware&&console.warn("useHardware hook was already registered"),k.useHardware=n.useHardware),n.useHardwareChangeActions&&(k.useHardwareChangeActions&&console.warn("useHardwareChangeActions hook was already registered"),k.useHardwareChangeActions=n.useHardwareChangeActions)}function D(n){if(!k.useHardware)throw new Error("No `useHardware` hook registered");return k.useHardware(n)}function tr(n){if(!k.useHardwareChangeActions)throw new Error("No `useHardwareChangeActions` hook registered");return k.useHardwareChangeActions(n)}function ne(n){return n.type==="lima"}function nr(n){const t=D(n);return t===null||!ne(t)?null:t}function We(n,t){const o=Math.ceil(n/t),r=n/o;return[o,r]}const or={default:Ge,size:Ve,transformation:Le,binning:Ue,imageroi:qe,description:He,state:zo},rr=or,sr="lima_cam",ar="lima_cam",ir="bliss",cr="lima",lr=!0,dr=!1,ur={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],max_size:[128,128],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:0,size:[128,128],state:"READY"},fr={id:sr,name:ar,protocol:ir,type:cr,online:lr,require_staff:dr,properties:ur},mr="lima_cam",pr="lima_cam",hr="bliss",xr="lima",gr=!0,jr=!1,wr={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!0,!1],max_size:[128,128],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:0,size:[128,128],state:"READY"},vr={id:mr,name:pr,protocol:hr,type:xr,online:gr,require_staff:jr,properties:wr},Nr="lima_cam",yr="lima_cam",br="bliss",_r="lima",$r=!0,Cr=!1,Or={static:{lima_version:"1.9.23",lima_type:"Frelon",camera_type:"Frelon",camera_model:"SPB8x2 CcdFT2k-F16",camera_pixelsize:[16e-6,16e-6],image_max_dim:[1920,1920]},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],max_size:[128,128],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:180,size:[128,128],state:"READY"},Ir={id:Nr,name:yr,protocol:br,type:_r,online:$r,require_staff:Cr,properties:Or},Sr={default:fr,flip:vr,rot:Ir},de={description:"Unknown state is exposed",variant:"fatal",priority:100},Y={OFFLINE:{description:"Axis is offline",variant:"secondary",priority:0},MOVING:{description:"Axis is moving",variant:"warning",priority:10},FAULT:{description:"Axis is in fault",variant:"danger",priority:20},LOCKED:{description:"Axis is locked",variant:"warning",priority:25},OFF:{description:"Power is off",variant:"secondary",priority:30},DISABLED:{description:"Axis is disabled",variant:"warning",priority:40},LOWLIMIT:{description:"Low limit is reached",variant:"warning",priority:50},HIGHLIMIT:{description:"High limit is reached",variant:"warning",priority:51},HOME:{description:"Home signal active",variant:"info",priority:52},READY:{description:"Ready to handle request",variant:"success",priority:60},NOT_READY:{description:"Not ready",variant:"warning",priority:100},UNKNOWN:de};function oe(n){const{hardware:t}=n,{locked:o=null}=t,{state:r=["UNKNOWN"]}=t.properties,[a,i]=h.useMemo(()=>{if(!t.online)return[["OFFLINE"],void 0];function c(m,p){const j=Y[m]??de,y=Y[p]??de;return j.priority-y.priority}const l=[...r,...o!==null?["LOCKED"]:[],...r.length===0?["NOT_READY"]:[]];l.sort(c);function u(m){const p=m.split(":",2);return p.length===1?[m,void 0]:p}const f={};return[l.map(m=>{if(m.startsWith("_")){const p=u(m);return p[1]!==void 0&&(f[p[0]]=p[1]),p[0]}return m==="LOCKED"?f[m]=`Locked by ${o}`:f[m]=Y[m].description??"",m}),f]},[r,t.online,o]);return e.jsx(Te,{states:a,descriptions:i,minWidth:6,variants:Object.fromEntries(Object.entries(Y).map(([c,l])=>[c,l.variant]))})}function Tr(n){const{hardware:t}=n;return e.jsx(oe,{hardware:t})}function H(n){const t=h.useRef(null),[o,r]=h.useState(!1),[a,i]=h.useState(!1);function c(d){return n.precision!==void 0?Number.parseFloat(d).toFixed(n.precision):d}h.useEffect(()=>{var d;t.current&&(t.current.value=c((d=n.hardwareValue)==null?void 0:d.toString()),r(!1))},[n.hardwareValue,n.precision]);function l(d){const m=c(d);t!=null&&t.current&&(t.current.value=m)}function u(d){switch(d.key){case"Enter":{r(!1);const m=Number.parseFloat(d.target.value),p=n.onMoveRequested(m);p&&p.catch(()=>{i(!0),setTimeout(()=>{l(n.hardwareValue),i(!1)},2e3)}),d.preventDefault(),d.stopPropagation();break}case"Esc":case"Escape":o&&(i(!1),r(!1),l(n.hardwareValue)),d.target.blur(),d.preventDefault(),d.stopPropagation();break}}function f(d){r(d.target.value!==n.hardwareValue.toString())}return e.jsx(s.Form.Control,{className:A.default({"form-control-edited":o,"form-control-error":a,"hw-moving":n.hardwareIsMoving}),type:"number",ref:t,onChange:f,onKeyDown:u,disabled:n.readOnly||n.hardwareIsMoving||n.hardwareIsDisabled,step:n.step})}function Mr(n){var a,i;const{states:t}=n;function o(c){return n.hardware.actions.setProperty("velocity",c)}function r(c){return n.hardware.actions.setProperty("acceleration",c)}return e.jsx(s.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(s.Popover,{id:"popid",children:[e.jsxs(s.Popover.Header,{children:[n.hardware.name," details"]}),e.jsxs(s.Popover.Body,{children:[e.jsxs(s.Form.Group,{children:[e.jsx(s.Form.Label,{children:"Velocity"}),e.jsx(H,{hardwareValue:((a=n.hardware.properties)==null?void 0:a.velocity)??0,onMoveRequested:o,hardwareIsDisabled:n.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:n.readOnly})]}),e.jsxs(s.Form.Group,{children:[e.jsx(s.Form.Label,{children:"Acceleration"}),e.jsx(H,{hardwareValue:((i=n.hardware.properties)==null?void 0:i.acceleration)??0,onMoveRequested:r,hardwareIsDisabled:n.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:n.readOnly})]})]})]}),children:e.jsx(s.Button,{children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function ze(n){const{hardware:t,options:o={}}=n,{properties:r,user_tags:a}=t;function i(){t.actions.call("stop")}function c(m){return t.actions.call("move",m)}const l=he(r.state,a),u=e.jsx(x,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),f=e.jsx(oe,{hardware:t}),d=n.options?n.options.header:"top";return e.jsx(w,{hardware:t,widgetIcon:u,widgetState:f,widgetContent:e.jsxs(s.InputGroup,{children:[e.jsx(te,{id:t.id,hardwareValue:(r==null?void 0:r.position)??null,hardwareIsDisabled:n.disabled,hardwareIsReady:l.READY??!1,hardwareIsMoving:l.MOVING??!1,onMoveRequested:c,onAbortRequested:i,precision:o.precision??r.display_digits??void 0,readOnly:o.readOnly,stepOnly:o.stepOnly,step:o.step,steps:o.steps,incIcon:o.incicon,decIcon:o.decicon,swapIncDec:o.swapincdec,horizontalArrows:o.horizontalarrows,largeArrows:o.largearrows}),r.unit&&e.jsx(s.InputGroup.Text,{children:r.unit}),!l.MOVING&&o.extended&&e.jsx(Mr,{hardware:t,disabled:n.disabled,readOnly:o.readOnly,states:l}),l.MOVING&&!n.disabled&&!o.step&&e.jsx(s.Button,{variant:"danger",onClick:i,children:e.jsx("i",{className:"fa fa-times"})})]}),headerMode:d})}function be(n){const{hardware:t,options:o={}}=n,r=he(t.properties.state,t.user_tags);function a(i){if(i===null)return"∅";const c=o.precision??t.properties.display_digits??void 0;return c!==void 0?i.toFixed(c):`${i}`}return e.jsxs(s.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:[e.jsx("div",{className:A.default({"hw-moving":r.MOVING}),children:a(t.properties.position)}),t.properties.unit&&e.jsx("div",{className:"ms-auto",children:e.jsx("small",{children:e.jsx("small",{children:t.properties.unit})})})]})}function Ke(n){const{hardware:t}=n,o=e.jsx(x,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),r=e.jsx(oe,{hardware:t}),a=n.options?n.options.header:"top";return a==="none"?e.jsx(be,{...n}):e.jsx(w,{hardware:t,widgetIcon:o,widgetState:r,widgetContent:e.jsx(be,{...n}),headerMode:a})}function he(n,t=[]){return h.useMemo(()=>{const o=t.includes("auto_ready"),r=t.includes("auto_on");if(n===void 0)return{UNKNOWN:!0};if((n==null?void 0:n.length)===0)return o?{READY:!0}:{NOT_READY:!0};const a=n.reduce((i,c)=>(i[c]=!0,i),{});return a.READY===void 0&&r&&a.OFF&&(a.READY=!0),a},[n,t])}function Ye(n){return n.type==="motor"}function z(n){const t=D(n);return t===null||!Ye(t)?null:t}const Fr={default:ze,text:Ke,state:Tr},Dr=Fr,Er=["move","stop","wait","rmove"],Rr="omega",Ar="omega 123",kr=!0,Br={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},Pr="bliss",Gr=!1,Vr="motor",Lr=[],Ur={callables:Er,id:Rr,name:Ar,online:kr,properties:Br,protocol:Pr,require_staff:Gr,type:Vr,user_tags:Lr},qr=["move","stop","wait","rmove"],Hr="omega",Wr="omega 123",zr=!0,Kr={offset:0,sign:1,acceleration:300,limits:[-10,190],position:100,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3},Yr="bliss",Qr=!1,Xr="motor",Jr=[],Zr={callables:qr,id:Hr,name:Wr,online:zr,properties:Kr,protocol:Yr,require_staff:Qr,type:Xr,user_tags:Jr},es=["move","wait","stop","rmove"],ts="omega",ns="omega 123",os=!0,rs={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:["UNKNOWN"],target:null,tolerance:1e-4,unit:"deg",velocity:null},ss="bliss",as=!1,is="motor",cs=[],ls={callables:es,id:ts,name:ns,online:os,properties:rs,protocol:ss,require_staff:as,type:is,user_tags:cs},ds=["move","wait","stop","rmove"],us="omega",fs="omega 123",ms=!0,ps={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:[],target:null,tolerance:1e-4,unit:"deg",velocity:null},hs="bliss",xs=!1,gs="motor",js=[],ws={callables:ds,id:us,name:fs,online:ms,properties:ps,protocol:hs,require_staff:xs,type:gs,user_tags:js},vs=["move","wait","stop","rmove"],Ns="omega",ys="omega 123",bs=!1,_s={},$s="bliss",Cs=!1,Os="motor",Is=[],Ss={callables:vs,id:Ns,name:ys,online:bs,properties:_s,protocol:$s,require_staff:Cs,type:Os,user_tags:Is},Ts=["move","wait","stop","rmove"],Ms="omega",Fs="omega 123",Ds=!0,Es={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:["OFF"],target:null,tolerance:1e-4,unit:"deg",velocity:null},Rs="bliss",As=!1,ks="motor",Bs=[],Ps={callables:Ts,id:Ms,name:Fs,online:Ds,properties:Es,protocol:Rs,require_staff:As,type:ks,user_tags:Bs},Gs={default:Ur,halfMotor:Zr,unknownMotor:ls,notReadyMotor:ws,disconnectedMotor:Ss,powerOffMotor:Ps};function Vs(n,t){return{id:n,name:n,type:"motor",properties:{position:t,unit:"mm",limits:[-100,100]},online:!0}}function Ls(n){const{minLimit:t=-999999999,maxLimit:o=999999999,initialPosition:r=0,initialVelocity:a=1e3,children:i}=n,[c,l]=h.useState(r),[u,f]=h.useState(["READY"]),[d,m]=h.useState(null),p=h.useRef(Date.now()),j=()=>{const v=Date.now(),I=(v-p.current)/1e3;let T;if(p.current=v,d!==null&&d!==c){let N,O;const M=I*a;if(M>Math.abs(c-d))T=d,N=["READY"],O=null;else{const V=d>c?1:-1;T=c+V*M,N=["MOVING"],O=d}l(T),f(N),m(O)}},y=(v,I)=>{if(v==="stop")return m(null),f(["READY"]),null;if(v==="move"){const T=Number.parseFloat(I);return m(Number.isNaN(T)?null:T),null}return console.log("MockMotor: Unsupported call",v,I),null},g=(v,I)=>(console.log("MockMotor: Unsupported setProperty",v,I),null);h.useEffect(()=>{const v=setInterval(()=>{j()},500);return()=>clearInterval(v)});const b={callables:["move","stop","wait","rmove"],id:"omega",name:"omega 123",online:!0,properties:{acceleration:300,limits:[t,o],position:c,offset:0,sign:1,state:u,tolerance:1e-4,unit:null,velocity:a,target:d},protocol:"bliss",require_staff:!1,type:"motor",actions:{setProperty:g,call:y},user_tags:[],locked:null};return e.jsx("div",{children:h.Children.map(i,v=>h.isValidElement(v)?h.cloneElement(v,{hardware:b,...v.props}):void 0)})}function Qe(n){const{hardware:t,options:o={}}=n,r=h.useRef(null);h.useEffect(()=>{if(!r.current){console.error("selectionRef ref is unset");return}r.current.value=t.properties.position},[t.properties.position]);function a(l){if(console.debug("change",l),!r||!r.current){console.error("selection ref is unset");return}t.actions.call("move",r.current.value)}function i(l){t.actions.call("stop")}const c=F.map(t.properties.positions,l=>e.jsx("option",{title:l.description,children:l.position},l.position));return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(x,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(s.Badge,{bg:t.properties.state==="READY"?"success":"warning",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(s.InputGroup,{children:[e.jsxs(s.Form.Control,{className:"custom-select",as:"select",ref:r,disabled:n.disabled,defaultValue:t.properties.position,children:[e.jsx("option",{disabled:!0,children:"unknown"}),c]}),t.properties.state!=="MOVING"&&e.jsx(s.Button,{onClick:a,disabled:n.disabled,children:"Move"}),t.properties.state==="MOVING"&&!n.disabled&&e.jsx(s.Button,{variant:"danger",onClick:i,children:e.jsx("i",{className:"fa fa-times"})})]})})]})}const Us={default:Qe},qs=Us,Hs=["move","stop"],Ws="beamstop",zs="beamstop",Ks=!0,Ys={position:"OUT",positions:[{description:"Beamstop position IN the beam",position:"IN",target:[{destination:2.5,tolerance:.01},{destination:1,tolerance:.2}]},{description:"Beamstop position OUT of the beam",position:"OUT",target:[{destination:3.5,tolerance:.01},{destination:2,tolerance:.2}]}],state:"READY"},Qs="bliss",Xs=!1,Js="multiposition",Zs={callables:Hs,id:Ws,name:zs,online:Ks,properties:Ys,protocol:Qs,require_staff:Xs,type:Js},ea={default:Zs};function xe(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",r={READY:"success",MOVING:"warning",INVALID:"danger",UNKNOWN:"danger",DISABLED:"secondary",OFFLINE:"warning"},a=r[o]||r.UNKNOWN;return e.jsx(S,{state:o,minWidth:6,variant:a})}function ta(n){const{hardware:t}=n;return e.jsx(xe,{hardware:t})}function na(n){const{hardware:t,options:o={}}=n,{properties:r}=t,{state:a}=r,i=a==="MOVING",c=a==="READY",l=i?r.target_magnification||0:r.magnification||0,f=[...r.available_magnifications];f.sort((y,g)=>y>g?1:g>y?-1:0);const d=n.disabled||!t.online||!c,m=o.digits||2;function p(y){t.actions?t.actions.call("move",y):console.error("Change request was triggered with:",y)}function j(y,g){const v=l===g?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(s.Dropdown.Item,{disabled:d,onClick:()=>{p(g)},children:[e.jsx("i",{className:v}),"  × ",g]},`id${y}`)}return e.jsxs(e.Fragment,{children:[e.jsx(R,{value:l.toFixed(m),className:A.default({"hw-moving":i})}),e.jsxs(s.Dropdown,{children:[e.jsx(s.Dropdown.Toggle,{disabled:!c,variant:"secondary"}),e.jsx(s.Dropdown.Menu,{children:f.map((y,g)=>j(g,y))})]})]})}function oa(n){const{hardware:t,options:o={}}=n,r=t.properties.magnification||0,a=o.digits||2,i=!!o.allowtuning;return e.jsxs(e.Fragment,{children:[e.jsx(R,{value:r.toFixed(a)}),i&&e.jsxs(s.Dropdown,{children:[e.jsx(s.Dropdown.Toggle,{variant:"secondary"}),e.jsx(s.Dropdown.Menu,{children:e.jsxs(s.InputGroup,{children:[e.jsx(s.InputGroup.Text,{children:"×"}),e.jsx(Xe,{...n})]})})]})]})}function Xe(n){const{hardware:t,options:o={}}=n,r=t.properties.magnification||0,{state:a}=t.properties,i=a==="READY",c=n.disabled||!t.online||!i,[l,u]=t.properties.magnification_range||[null,null],f=h.useRef(null),d=h.useRef(null),[m,p]=h.useState(!1),j=o.digits||2;function y(N){t.actions?n.mode==="move"?t.actions.call("move",N):t.actions.setProperty("magnification",N):console.error("Change request was triggered with:",N)}function g(N){if(!f||!f.current){console.log("formRef not yet defined");return}if(N.key==="Enter"){p(!1);const{value:O}=f.current,M=Number.parseFloat(O);if(l!==null&&M<l||u!==null&&M>u)return;y(M)}else N.key==="Escape"?(f.current.value=r.toFixed(j),d.current&&(d.current.value=r.toString()),p(!1)):console.log(N.key)}function b(N){N!==r&&!m&&p(!0),N===r&&m&&p(!1)}function v(N){if(!f||!f.current){console.error("formRef is not set");return}const O=Number.parseFloat(f.current.value);b(O),d.current&&(d.current.value=O.toString())}function I(N){if(!f||!f.current){console.error("formRef is not set");return}if(!d||!d.current){console.error("rangeRef is not set");return}const O=Number.parseFloat(d.current.value);b(O),f.current.value=O.toFixed(j)}function T(){if(!d||!d.current){console.error("rangeRef is not set");return}const N=Number.parseFloat(d.current.value);y(N)}return h.useEffect(()=>{if(!f||!f.current){console.error("formRef is not set");return}m||(f.current.value=r.toFixed(j)),d.current&&(d.current.value=r.toString())},[j,m,r]),e.jsxs(e.Fragment,{children:[e.jsx(s.Form.Control,{className:m?"form-control-edited":"",type:"number",ref:f,defaultValue:r.toFixed(j),onChange:v,disabled:c,step:10**-j,onKeyDown:g}),l!==null&&u!==null&&e.jsx(s.Form.Control,{ref:d,disabled:c,type:"range",min:l,max:u,step:10**-j,onChange:I,onMouseUp:T,defaultValue:r})]})}function ra(n){const{hardware:t,options:o={}}=n,{properties:r}=t,a=r.state==="MOVING",i=r.state==="READY",c=a?r.target_magnification||0:r.magnification||0,l=n.options.digits||2;return e.jsxs(e.Fragment,{children:[e.jsx(R,{value:c.toFixed(l),className:A.default({"hw-moving":a})}),e.jsxs(s.Dropdown,{children:[e.jsx(s.Dropdown.Toggle,{disabled:!i,variant:"secondary"}),e.jsx(s.Dropdown.Menu,{children:e.jsxs(s.InputGroup,{children:[e.jsx(s.InputGroup.Text,{children:"×"}),e.jsx(Xe,{...n,mode:"move"})]})})]})]})}function sa(n){return e.jsx(s.Form.Control,{className:"border-light",type:"text",disabled:!0,defaultValue:"Missing"})}function Je(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Optic",icon:"fam-hardware-optic",online:t.online}),a=e.jsx(xe,{hardware:t});function i(){function l(){return t.online?t.properties.available_magnifications?na:t.properties.magnification_range?ra:oa:sa}const u=l();return e.jsxs(s.InputGroup,{children:[e.jsx(s.InputGroup.Text,{className:"border-light",children:"×"}),e.jsx(u,{...n})]})}const c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i(),headerMode:c})}function aa(n){return n.type==="optic"}const ia={default:Je,state:ta},ca=ia,la=["magnification","reset","open"],da="optic",ua="optic",fa=!0,ma={state:"READY",status:`Optic is ready
29
+ `,magnification:10,target_magnification:null,available_magnifications:[5,7.5,10],magnification_range:null},pa="bliss",ha=!1,xa="optic",Q={callables:la,id:da,name:ua,online:fa,properties:ma,protocol:pa,require_staff:ha,type:xa},ga={default:Q,fixed:Q,off:Q,range:Q};function K(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",r={STANDBY:"success",DISABLED:"secondary",OFFLINE:"secondary",RUNNING:"warning",ABORTING:"warning",AWAITING_USER_INPUT:"warning",UNKNOWN:"fatal"},a=r[o]||r.UNKNOWN;return e.jsx(S,{state:o,minWidth:6,variant:a})}function ja(n){const{hardware:t}=n;return e.jsx(K,{hardware:t})}function wa(n){const{hardware:t}=n,o=n.disabled||!t.online,r=t.properties.state==="AWAITING_USER_INPUT",a=t.properties.state==="ABORTING",i=t.properties.state==="RUNNING"||r||a;function c(u){t.actions.call("start")}function l(u){t.actions.call("abort")}return e.jsxs(s.ButtonGroup,{size:"lg",className:"w-100",children:[e.jsx(s.Button,{onClick:c,disabled:o||i,variant:"primary",children:"Start"}),e.jsx(s.Button,{onClick:l,disabled:o||!i,variant:"primary",children:"Abort"})]})}function ue(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Procedure",icon:"fa-cog",online:t.online}),a=e.jsx(K,{hardware:t}),i=e.jsx(s.Container,{children:e.jsx(wa,{hardware:t,disabled:!n.operator})}),c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}function va(n){const{hardware:t}=n,o=t.properties.state==="AWAITING_USER_INPUT",r=t.properties.state==="ABORTING",a=t.properties.state==="RUNNING";return r?e.jsxs(s.Badge,{bg:"warning",children:[e.jsx("i",{className:"fa-solid fa-heart-crack fa-beat"})," ABORTING"]}):a?e.jsxs(s.Badge,{bg:"info",children:[e.jsx("i",{className:"fa-solid fa-heart fa-beat"})," RUNNING"]}):o?e.jsxs(s.Badge,{bg:"warning",title:"A user input is expected",children:[e.jsx("i",{className:"fa-solid fa-user fa-beat"})," AWAITING INPUT"]}):e.jsx(Na,{hardware:t})}function Na(n){const{hardware:t}=n,{previous_run_state:o,previous_run_exception:r}=t.properties,a={NONE:["secondary",null],ABORTED:["warning","fa-heart-crack"],FAILED:["danger",null],SUCCESSED:["success",null],UNKNOWN:["danger",null]},i=a[o]||a.UNKNOWN,[c,l]=i;return e.jsxs(s.Badge,{bg:c,title:r??void 0,children:[l&&e.jsxs(e.Fragment,{children:[e.jsx("i",{className:`fa-solid ${l}`})," "]}),o]})}function Ze(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Procedure",icon:"fa-cog",online:t.online}),a=e.jsx(K,{hardware:t}),i=e.jsx(s.Container,{children:e.jsx("div",{children:e.jsx("h3",{children:e.jsx(va,{hardware:t})})})}),c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}function ya(n){const{hardware:t}=n,o=n.disabled||!t.online,r=t.properties.state==="AWAITING_USER_INPUT";function a(i){t.actions.call("validate")}return e.jsx(s.ButtonGroup,{size:"lg",className:"w-100",children:e.jsx(s.Button,{onClick:a,disabled:o||!r,variant:"primary",children:"Validate"})})}function et(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Procedure",icon:"fa-cog",online:t.online}),a=e.jsx(K,{hardware:t}),i=e.jsx(s.Container,{children:e.jsx(ya,{hardware:t,disabled:!n.operator})}),c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}const ba={default:ue,manage:ue,execution:Ze,validate:et,state:ja},_a=ba,$a=["start","abort","clear","validate"],Ca="procedure",Oa="procedure",Ia="procedure",Sa="bliss",Ta=!1,Ma=!0,Fa={state:"STANDBY",previous_run_state:"NONE",previous_run_exception:null,parameters:{my_number:10,my_string:"foo",my_null:null,my_boolean:!0,my_dict:{a:10,b:"10",c:!0},my_list:[10,"10",!0],"my_scan_1.11":{__type__:"scan",node:"demo_session:tmp:scans:inhouse:id002405:sample:sample_0002:_1_flat images 1",mmh3:3852826388},"my_scan_2.0":{__type__:"scan",key:"esrf:scan:01J1QDB370S2V8WF7FX2Y9H29V",mmh3:3852826389},my_quantity:{__type__:"quantity",scalar:20,unit:"mm"},my_nan:{__type__:"nan"},my_posinf:{__type__:"posinf"},my_neginf:{__type__:"neginf"},my_obj:{__type__:"hardware",name:"roby"}}},Da={callables:$a,type:Ca,id:Oa,name:Ia,protocol:Sa,require_staff:Ta,online:Ma,properties:Fa},Ea={standby:Da};function re(n){const{hardware:t}=n;function o(){if(!t.online)return"OFFLINE";const i=t.properties.state;return n.useReadyState&&(i==="OPEN"||i==="CLOSED")?"READY":i}const r=o();function a(){switch(r){case"READY":return"success";case"OPEN":return"success";case"CLOSED":return"danger";case"DISABLED":return"secondary";case"MOVING":case"STANDBY":case"OFFLINE":return"warning";case"FAULT":return"fatal";default:return"fatal"}}return e.jsx(S,{state:r,minWidth:6,variant:a()})}function Ra(n){const{hardware:t}=n;return e.jsx(re,{hardware:t,useReadyState:!0})}function Aa(n){const{hardware:t}=n;function o(){t.actions.call("reset")}return e.jsx(s.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(s.Popover,{id:"popid",children:[e.jsxs(s.Popover.Header,{children:[t.name," Details"]}),e.jsxs(s.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(s.Button,{onClick:o,disabled:n.disabled,children:"Reset"})})]})]}),children:e.jsx(s.Button,{className:"flex-grow-0",title:"Shutter Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function tt(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),a=e.jsx(re,{hardware:t});function i(){return t.properties?t.properties.state:"UNKNOWN"}function c(g){return g==="OPEN"?["Close","close"]:g==="CLOSED"?["Open","open"]:g==="DISABLED"||g==="STANDBY"||g==="FAULT"?["Closed",""]:g==="MOVING"?["...",""]:["Unknown",""]}const l=i(),[u,f]=c(l),m={OPEN:"danger",CLOSED:"success",MOVING:"warning",DISABLED:"secondary",STANDBY:"danger",FAULT:"fatal",UNKNOWN:"warning"}[l]||"danger";function p(){t.actions.call(f)}const j=e.jsxs(s.ButtonGroup,{className:"d-flex flex-nowrap",children:[e.jsx(s.Button,{variant:m,onClick:p,disabled:n.disabled||f==="",children:u}),o.extended&&e.jsx(Aa,{...n})]}),y=n.options.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:j,headerMode:y})}function ka(n){var u;const{hardware:t,options:o={}}=n;function r(){t.actions.call("open")}function a(){t.actions.call("close")}const i=((u=t.properties)==null?void 0:u.state)??"UNKNOWN",c=i==="MOVING",l=i==="DISABLED"||c;return e.jsxs(s.Dropdown,{children:[e.jsx(s.Dropdown.Toggle,{variant:"secondary",disabled:n.disabled||l}),e.jsx(s.Dropdown.Menu,{children:e.jsxs(s.Container,{children:[e.jsx(s.Row,{children:e.jsx(s.Col,{className:"text-center",children:"Actions"})}),e.jsx(s.Row,{children:e.jsx(s.Col,{children:e.jsxs(s.ButtonGroup,{children:[e.jsx(s.Button,{variant:c?"warning":"secondary",onClick:()=>{r()},disabled:n.disabled||l,title:"Open the shutter",children:"Open"}),e.jsx(s.Button,{variant:c?"warning":"secondary",onClick:()=>{a()},disabled:n.disabled||l,title:"Close the shutter",children:"Close"})]})})})]})})]})}function nt(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),a=e.jsx(re,{hardware:t,useReadyState:!0});function i(){return t.properties?t.properties.state:"UNKNOWN"}function c(g){return g==="OPEN"||g==="CLOSED"?g:g==="DISABLED"||g==="STANDBY"||g==="FAULT"?"CLOSED":g==="MOVING"?"...":"UNKNOWN"}function l(g){return g.charAt(0).toUpperCase()+g.slice(1).toLowerCase()}const u=i(),f=c(u),m={OPEN:"success",CLOSED:"danger",MOVING:"warning",DISABLED:"secondary",STANDBY:"success",FAULT:"fatal",UNKNOWN:"fatal"}[u],p=l(f),j=e.jsxs(s.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(R,{variant:m,className:"text-center",style:{minWidth:"10em"},value:p}),e.jsx(ka,{...n})]}),y=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:j,headerMode:y})}const Ba={default:tt,protected:nt,state:Ra},Pa=Ba,Ga=["reset","open","close","toggle"],Va="abs1",La="abs1",Ua=!0,qa={closed_text:"",open_text:"",state:"OPEN",status:`Pneumatic Beam Shutter is open
30
+ `,valid:!0},Ha="tango",Wa=!0,za="shutter",Ka={callables:Ga,id:Va,name:La,online:Ua,properties:qa,protocol:Ha,require_staff:Wa,type:za},Ya={default:Ka};function Qa(n){const{hardware:t}=n,o=()=>{t.actions.call(t.properties.state==="ON"?"off":"on")},r={Voltage:`${t.properties.voltage.toFixed(0)} V`,Current:`${(t.properties.current*1e3).toFixed(2)} mA`};return e.jsx(s.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(s.Popover,{id:"popid",children:[e.jsxs(s.Popover.Header,{children:[t.name," Details"]}),e.jsxs(s.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("h6",{children:"Properties"}),e.jsx(s.Container,{children:F.map(r,(a,i)=>e.jsxs(s.Row,{children:[e.jsxs(s.Col,{children:[i,":"]}),e.jsx(s.Col,{children:a})]},i))}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(s.Button,{disabled:n.disabled,onClick:o,variant:t.properties.state==="ON"?"danger":"success",children:t.properties.state==="ON"?"Off":"On"})})]})]}),children:e.jsx(s.Button,{title:"Pump Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function ot(n){const{hardware:t,options:o={}}=n;return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(x,{name:"Pump",icon:"fam-hardware-pump",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(s.Badge,{bg:t.properties.state==="ON"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(s.InputGroup,{children:[e.jsx(s.Form.Control,{value:t.properties.pressure.toExponential(o.precision||3),disabled:!0}),(t.properties.unit||o.unit)&&e.jsx(s.InputGroup.Text,{children:t.properties.unit||o.unit}),e.jsx(Qa,{...n})]})})]})}const Xa={default:ot},Ja=Xa,Za=["off","on"],ei="ip121",ti="ip121",ni=!0,oi={current:.0003000000142492354,pressure:26000000730164174e-23,state:"ON",status:`Pump is ON
31
+ Modes: Step/Protect
32
+ ID21/v-var-ctrl/121 - Serial line OK
33
+ Pump size: 75-55-40 SC/T
34
+ `,voltage:6998},ri="tango",si=!0,ai="pump",ii={callables:Za,id:ei,name:ti,online:ni,properties:oi,protocol:ri,require_staff:si,type:ai},ci={default:ii};function ge(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",r={RETRACTED:"success",IN_TOUCH:"warning",MOVING_IN:"warning",MOVING_OUT:"warning",UNKNOWN:"danger",OFFLINE:"warning"},a=r[o]||r.UNKNOWN;return e.jsx(S,{state:o,minWidth:6,variant:a})}function li(n){const{hardware:t}=n;return e.jsx(ge,{hardware:t})}function di(n){const{className:t,hardware:o,options:r={}}=n,{state:a}=o.properties??"OFFLINE",c=!(a==="IN_TOUCH")||n.disabled;function l(u){const{distance:f}=u;return e.jsx(s.Button,{variant:"secondary",onClick:()=>{o.actions.call("push",f)},disabled:c,children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx("i",{className:"fa fa-arrow-right fa-rotate-180"})," ",f]})})}return e.jsxs("div",{className:t,style:{display:"grid",gridTemplateRows:"min-content min-content min-content",gridTemplateColumns:"min-content min-content min-content",gridGap:"1px"},children:[e.jsx(l,{distance:5}),e.jsx(l,{distance:2}),e.jsx(l,{distance:1}),e.jsx(l,{distance:.5}),e.jsx(l,{distance:.2}),e.jsx(l,{distance:.1}),e.jsx(l,{distance:.05}),e.jsx(l,{distance:.02}),e.jsx(l,{distance:.01})]})}function ui(n){const{hardware:t,options:o,disabled:r}=n,{state:a}=t.properties??"OFFLINE",i=a==="RETRACTED",c=a==="IN_TOUCH",l=i?"ms-auto":c?"ms-0":"mx-auto";return e.jsxs("div",{style:{display:"grid",gridTemplateRows:"min-content min-content",gridTemplateColumns:"min-content auto",gridGap:"1px"},children:[e.jsx("i",{className:`${c?"fas fa-dizzy":"fa fa-smile"} fa-3x my-auto`}),e.jsx(di,{className:l,...n}),e.jsx("span",{}),e.jsxs(s.ButtonGroup,{className:"mx-auto",style:{width:"12em"},children:[e.jsx(s.Button,{onClick:()=>{t.actions.call("move_in")},disabled:c||r,style:{width:"5em"},children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx("i",{className:"fa fa-arrow-right fa-rotate-180"})," In"]})}),e.jsx(s.Button,{onClick:()=>{t.actions.call("move_out")},disabled:i||r,style:{width:"5em"},children:e.jsxs("span",{className:"text-nowrap",children:["Out ",e.jsx("i",{className:"fa fa-arrow-right"})]})})]})]})}function rt(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Pusher",icon:"fa-hand-point-right",online:t.online}),a=e.jsx(ge,{hardware:t});function i(){return e.jsx(ui,{...n})}const c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i(),headerMode:c})}const fi={default:rt,state:li},mi=fi,pi=["move_in","move_out","push","sync_hard"],hi="pusher",xi="pusher",gi=!0,ji={state:"RETRACTED"},wi="bliss",vi=!1,Ni="pusher",yi={callables:pi,id:hi,name:xi,online:gi,properties:ji,protocol:wi,require_staff:vi,type:Ni},bi={default:yi};function se(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",r={STOPPED:"danger",STARTING:"warning",RUNNING:"success",BACKOFF:"warning",STOPPING:"warning",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"fatal",OFFLINE:"secondary"},a=r[o]||r.UNKNOWN;return e.jsx(S,{state:o,minWidth:6,variant:a})}function _i(n){const{hardware:t}=n;return e.jsx(se,{hardware:t})}function st(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Shutter",icon:"fa-cog",online:t.online}),a=e.jsx(se,{hardware:t});function i(){t.actions.call("start")}function c(){t.actions.call("restart")}function l(){t.actions.call("stop")}function u(){return t.properties?t.properties.state:"UNKNOWN"}function f(N){return N.charAt(0).toUpperCase()+N.slice(1).toLowerCase()}const d=u(),m=f(d),j={STOPPED:"danger",STARTING:"warning",RUNNING:"success",BACKOFF:"warning",STOPPING:"warning",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"secondary",OFFLINE:"secondary"}[d]||"danger";function y(){const N=d==="RUNNING"||d==="STARTING";return{icon:N?"fa fa-refresh fa-wp":"fa fa-play fa-wp",variant:n.disabled?"":"success",callback:d==="RUNNING"?c:i,disabled:n.disabled,title:n.operator?N?"Restart the service":"Start the serStaticTextInputvice":"You dont have the control to the session"}}function g(){const N=d==="RUNNING"||d==="STARTING";return{icon:"fa fa-stop fa-wp",variant:n.disabled?"":N?"danger":"secondary",callback:l,disabled:n.disabled,title:n.operator?"Stop the service":"You dont have the control to the session"}}const b=y(),v=g(),I=e.jsxs(s.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(R,{variant:j,className:"text-center",style:{minWidth:"8em"},value:m}),e.jsx(s.Button,{style:{width:"2.5em"},variant:"light",className:`px-0 text-${b.variant}`,onClick:b.callback,disabled:b.disabled,title:b.title,children:e.jsx("i",{className:`${b.icon}`})}),e.jsx(s.Button,{style:{width:"2.5em"},variant:"light",className:`px-0 text-${v.variant}`,onClick:v.callback,disabled:v.disabled,title:v.title,children:e.jsx("i",{className:`${v.icon}`})})]}),T=n.options.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:I,headerMode:T})}function $i(n){var u;const{hardware:t,options:o={}}=n;function r(){t.actions.call("start")}function a(){t.actions.call("restart")}function i(){t.actions.call("stop")}const c=((u=t.properties)==null?void 0:u.state)??"UNKNOWN",l=c==="STOPPING"||c==="STARTING";return e.jsx(s.OverlayTrigger,{trigger:"click",rootClose:!0,placement:o.dropDirection==="up"?"top":"bottom",overlay:e.jsx(s.Popover,{id:"service-protected-overlay",children:e.jsxs(s.Popover.Body,{children:[e.jsx(s.Row,{children:e.jsx(s.Col,{className:"text-center",children:"Actions"})}),e.jsx(s.Row,{children:e.jsxs(s.Col,{children:[c==="RUNNING"&&e.jsxs(s.Button,{className:"me-1 text-success border-secondary",variant:"light",onClick:()=>{a()},disabled:n.disabled,title:"Restart the service",children:[e.jsx("i",{className:"fa fa-refresh fa-wp me-1"}),"Restart"]}),c!=="RUNNING"&&e.jsxs(s.Button,{className:"me-1 text-success border-secondary",variant:"light",onClick:()=>{r()},disabled:n.disabled,title:"Start the service",children:[e.jsx("i",{className:"fa fa-play fa-wp me-1"}),"Start"]}),e.jsxs(s.Button,{className:`text-${c!=="STOPPED"?"danger":"primary"} border-secondary`,variant:"light",onClick:()=>{i()},disabled:n.disabled,title:"Stop the service",children:[e.jsx("i",{className:"fa fa-stop fa-wp me-1"}),"Stop"]})]})})]})}),children:e.jsx(s.Button,{disabled:n.disabled||l,children:e.jsx("i",{className:`fa fa-caret-${o.dropDirection==="up"?"up":"down"}`})})})}function at(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Shutter",icon:"fa-cog",online:t.online}),a=e.jsx(se,{hardware:t});function i(){return t.properties?t.properties.state:"UNKNOWN"}function c(j){return j.charAt(0).toUpperCase()+j.slice(1).toLowerCase()}const l=i(),f={STOPPED:"danger",STARTING:"warning",RUNNING:"success",BACKOFF:"warning",STOPPING:"warning",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"fatal",OFFLINE:"secondary"}[l],d=c(l),m=e.jsxs(s.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(R,{variant:f,style:{minWidth:"10em"},value:d,className:"text-center"}),e.jsx($i,{...n})]}),p=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:m,headerMode:p})}const Ci={default:st,protected:at,state:_i},Oi=Ci,Ii=["start","stop","restart"],Si="service1",Ti="service1",Mi=!0,Fi={state:"RUNNING"},Di="multivisor",Ei=!0,Ri="service",Ai={callables:Ii,id:Si,name:Ti,online:Mi,properties:Fi,protocol:Di,require_staff:Ei,type:Ri},ki={default:Ai};function ae(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",r={UNKNOWN:"danger",READY:"success"},a=r[o]||r.UNKNOWN;return e.jsx(S,{state:o,minWidth:6,variant:a})}function Bi(n){const{hardware:t}=n;return e.jsx(ae,{hardware:t})}function Pi(n){const{motion:t}=n,r=t.axisRef.slice(9),a=z(r),i=(a==null?void 0:a.alias)??(a==null?void 0:a.name)??(a==null?void 0:a.id)??"none";return e.jsx("div",{className:"my-auto",children:i})}function Gi(n){const{motion:t,actions:o,disabled:r}=n,a=t.axisRef;function i(){o.call("update_axis",{axis_ref:a})}return e.jsx(s.Button,{variant:"danger",onClick:i,disabled:r,children:e.jsx("i",{className:"fa fa-trash"})})}function Vi(n){const{motion:t,actions:o,axisRef:r,disabled:a}=n,i=h.useMemo(()=>{for(const d of t)if(d.axisRef===r)return!0;return!1},[t,r]),c=r.slice(9),l=z(c),u=(l==null?void 0:l.alias)??(l==null?void 0:l.name)??(l==null?void 0:l.id)??"none";function f(){o.call("update_axis",{axis_ref:r,relative_position:0})}return e.jsx(s.Button,{className:"ms-1",variant:i?"primary":"secondary",onClick:()=>{i||f()},title:i?"This axis is already part of the motion":"Use this axis in the motion",disabled:a,children:u})}function Li(n){var g;const{motion:t,actions:o}=n,r=t.axisRef,a=t.absolute_position??t.relative_position??0,i=r.slice(9),c=z(i),l=n.disabled||!(c!=null&&c.online),u=h.useRef(null),[f,d]=h.useState(!1),m=3,p=((g=c==null?void 0:c.properties)==null?void 0:g.unit)??"";function j(b){if(!u||!u.current)console.log("formRef not yet defined");else if(b.key==="Enter"){d(!1);const v=Number.parseFloat(u.current.value);o.call("update_axis",{axis_ref:r,absolute_position:t.absolute_position!==null?v:null,relative_position:t.relative_position!==null?v:null})}else b.key==="Escape"?(u.current.value=a.toFixed(m),d(!1)):console.log(b.key)}function y(b){const{value:v}=b.target;if(v===void 0)return;const I=Number.parseFloat(v);I!==a&&!f&&d(!0),I===a&&f&&d(!1)}return h.useEffect(()=>{!u||!u.current?console.log("formRef not yet defined"):f||(u.current.value=a.toFixed(m))},[f,a]),e.jsxs(s.InputGroup,{className:"w-100",children:[e.jsx(s.Form.Control,{className:f?"form-control-edited":"",type:"number",ref:u,defaultValue:a.toFixed(m),onChange:y,disabled:l,onKeyDown:j}),e.jsx(s.InputGroup.Text,{children:p})]})}function Ui(n){const{actions:t,motion:o,disabled:r}=n;function a(){t.call("update_axis",{axis_ref:o.axisRef,absolute_position:o.absolute_position??o.relative_position})}function i(){t.call("update_axis",{axis_ref:o.axisRef,relative_position:o.absolute_position??o.relative_position})}return e.jsxs(s.ButtonGroup,{children:[e.jsx(s.Button,{onClick:a,variant:o.absolute_position!==null?"primary":"secondary",disabled:r,children:"Abs"}),e.jsx(s.Button,{onClick:i,variant:o.relative_position!==null?"primary":"secondary",disabled:r,children:"Rel"})]})}function it(n){const{hardware:t,options:o={},disabled:r}=n,{properties:a}=t,i=e.jsx(x,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),c=e.jsx(ae,{hardware:t}),l=e.jsxs(s.Container,{children:[e.jsxs(s.Row,{className:"mt-1",children:[e.jsx(s.Col,{xs:3,children:"Move in parallel"}),e.jsx(s.Col,{xs:9,children:a.move_in_parallel?"true":"false"})]}),e.jsxs(s.Row,{className:"mt-1",children:[e.jsx(s.Col,{xs:3,children:"Switch power on/off"}),e.jsx(s.Col,{xs:9,children:a.power_onoff?"true":"false"})]}),e.jsxs(s.Row,{className:"mt-1",children:[e.jsx(s.Col,{xs:3,children:"Settle time"}),e.jsxs(s.Col,{xs:9,children:[a.settle_time.toFixed(2)," ",e.jsx("span",{title:"seconds",children:"s"})]})]}),e.jsxs(s.Row,{className:"mt-1",children:[e.jsx(s.Col,{xs:3,children:"Available axes"}),e.jsx(s.Col,{xs:9,children:a.available_axes.map(f=>e.jsx(Vi,{axisRef:f,motion:a.motion,actions:t.actions,disabled:r},f))})]}),e.jsxs(s.Row,{className:"mt-1",children:[e.jsx(s.Col,{xs:3,children:"Actual motion"}),e.jsx(s.Col,{xs:9,children:e.jsxs("div",{style:{display:"grid",gridGap:5,gridTemplateColumns:"min-content min-content auto min-content"},children:[e.jsx("div",{children:"Axis"}),e.jsx("div",{children:"Kind"}),e.jsx("div",{children:"Displacement"}),e.jsx("div",{}),a.motion.map((f,d)=>e.jsxs(e.Fragment,{children:[e.jsx(Pi,{motion:f},`motion${d}-0`),e.jsx(Ui,{motion:f,actions:t.actions,disabled:r},`motion${d}-1`),e.jsx(Li,{motion:f,actions:t.actions,disabled:r},`motion${d}-2`),e.jsx(Gi,{motion:f,actions:t.actions,disabled:r},`motion${d}-3`)]}))]})})]})]}),u=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:i,widgetState:c,widgetContent:l,headerMode:u})}function qi(n){var N;const{motion:t,actions:o}=n,r=t.axisRef,a=t.absolute_position??t.relative_position??0,i=r.slice(9),c=z(i),l=n.disabled||!(c!=null&&c.online),u=h.useRef(null),[f,d]=h.useState(!1),m=3,p=((N=c==null?void 0:c.properties)==null?void 0:N.unit)??"",j=(c==null?void 0:c.alias)??(c==null?void 0:c.name)??(c==null?void 0:c.id)??"none";function y(O){if(!u||!u.current)console.log("formRef not yet defined");else if(O.key==="Enter"){d(!1);const M=Number.parseFloat(u.current.value);o.call("update_axis",{axis_ref:r,absolute_position:t.absolute_position!==null?M:null,relative_position:t.relative_position!==null?M:null})}else O.key==="Escape"?(u.current.value=a.toFixed(m),d(!1)):console.log(O.key)}function g(O){const{value:M}=O.target;if(M===void 0)return;const V=Number.parseFloat(M);V!==a&&!f&&d(!0),V===a&&f&&d(!1)}h.useEffect(()=>{!u||!u.current?console.log("formRef not yet defined"):f||(u.current.value=a.toFixed(m))},[f,a]);function b(){return t.absolute_position!==null?["ABS","warning","Absolute displacement"]:t.relative_position!==null?["REL","none","Relative displacement"]:["ERR","danger","Unknown motion kind"]}const[v,I,T]=b();return e.jsxs(s.InputGroup,{className:"w-100",children:[e.jsx(s.InputGroup.Text,{title:"Displacement to apply on this axis to take a flat",style:{width:"5em"},children:j}),e.jsx(s.InputGroup.Text,{className:`bg-${I}`,title:T,style:{width:"3em"},children:v}),e.jsx(s.Form.Control,{className:f?"form-control-edited":"",type:"number",ref:u,defaultValue:a.toFixed(m),onChange:g,disabled:l,onKeyDown:y}),e.jsx(s.InputGroup.Text,{children:p})]})}function ct(n){const{hardware:t,options:o={},disabled:r}=n,{properties:a}=t,i=e.jsx(x,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),c=e.jsx(ae,{hardware:t}),l=e.jsxs(e.Fragment,{children:[a.motion.length===0&&e.jsx(s.Alert,{variant:"danger",className:"mb-0",children:"No flat motion defined"}),a.motion.length>0&&e.jsx(s.Stack,{direction:"vertical",children:a.motion.map((f,d)=>e.jsx(qi,{actions:t.actions,motion:f,disabled:r},f.axisRef))})]}),u=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:i,widgetState:c,widgetContent:l,headerMode:u})}const Hi={default:it,small:ct,state:Bi},Wi=Hi;function lt(n){return n.type==="tomoflatmotion"}function zi(n){const t=D(n);return t===null||!lt(t)?null:t}const Ki="tomoflatmotion",Yi="tomoflatmotion",Qi=!0,Xi={state:"READY",settle_time:2,power_onoff:!1,move_in_parallel:!0,available_axes:["hardware:sy","hardware:sy2"],motion:[{axis:"hardware:sy",absolute_position:null,relative_position:1}]},Ji="bliss",Zi=!1,ec="flatmotion",tc={id:Ki,name:Yi,online:Qi,properties:Xi,protocol:Ji,require_staff:Zi,type:ec},nc={default:tc};function dt(n){const{hardware:t,options:o={},disabled:r}=n,{actions:a}=t,i=e.jsx(x,{name:"TomoReferencePositionSchema",icon:"fam-hardware-motor",online:t.online});function c(){a.call("move_to_reference")}const l=e.jsx(e.Fragment,{}),u=e.jsx(s.Button,{className:"w-100",onClick:()=>{c()},disabled:r,children:"Back to parking position"}),f=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:i,widgetState:l,widgetContent:u,headerMode:f})}function oc(n){return n.type==="tomoreferenceposition"}const rc={default:dt},sc=rc;function ie(n){const{hardware:t}=n,{online:o,locked:r=null}=t,a=o?(r!==null?"LOCKED":t.properties.state)||"UNKNOWN":"OFFLINE",i={UNKNOWN:"danger",READY:"success",OFFLINE:"secondary",INVALID:"danger",MOUNTING:"warning",UNMOUNTING:"warning",LOCKED:"warning"},c=i[a]||i.UNKNOWN;return e.jsx(S,{state:a,minWidth:6,variant:c})}function ac(n){const{hardware:t}=n;return e.jsx(ie,{hardware:t})}function ic(n){const{hardware:t,options:o={}}=n;function r(i){return t.actions?t.actions.setProperty("sample_pixel_size_mode",i):console.error("Change request was triggered with:",i),null}const a=t.properties.sample_pixel_size_mode;return e.jsx(s.Dropdown,{style:n.style,children:e.jsxs(s.ButtonGroup,{children:[e.jsx(s.Button,{variant:a==="USER"?"primary":"secondary",onClick:()=>{r("USER")},disabled:n.disabled,title:"Use a fixed pixel size defined by the user",children:"USER"}),e.jsx(s.Button,{variant:a==="AUTO"?"primary":"secondary",onClick:()=>{r("AUTO")},disabled:n.disabled,title:"Compute the pixel size automatically based on the beamline geometry",children:"AUTO"})]})})}function cc(n){const{hardware:t,options:o={}}=n,r=t.properties.user_sample_pixel_size||0,{state:a}=t.properties,i=a==="READY";function c(l){return t.actions?t.actions.setProperty("user_sample_pixel_size",l):console.error("Change request was triggered with:",l),null}return e.jsx(H,{hardwareValue:r,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:i,hardwareIsMoving:!1,readOnly:t.properties.sample_pixel_size_mode!=="USER"})}function lc(n){const{hardware:t,options:o={}}=n;return t.properties.state,e.jsxs(s.Dropdown,{children:[e.jsx(s.Dropdown.Toggle,{disabled:n.disabled,variant:"secondary"}),e.jsx(s.Dropdown.Menu,{children:e.jsxs(s.Container,{children:[e.jsx(s.Row,{children:e.jsx(s.Col,{className:"text-center",children:"Mode"})}),e.jsx(s.Row,{children:e.jsx(s.Col,{children:e.jsx(ic,{...n,style:{width:"100%"}})})}),e.jsx(s.Row,{children:e.jsx(s.Col,{className:"text-center mt-1",children:"User pixel size"})}),e.jsx(s.Row,{children:e.jsx(s.Col,{children:e.jsxs(s.InputGroup,{children:[e.jsx(cc,{...n}),e.jsx(s.InputGroup.Text,{children:"um"})]})})})]})})]})}function dc(n,t,o){return h.useMemo(()=>{function r(c){return c==="um"?"μm":c}function a(c){return c.toFixed(2).replace(/\.?0+$/,"")}if(n===null)return["∅",""];if(t===o)return[a(n),r(o)];const i=Wt.default(n,t);return[a(i.to(o).scalar),r(o)]},[n,t,o])}function ut(n){const{hardware:t,options:o={}}=n,r=o.display_unit??"um",a=e.jsx(x,{name:"TomoDetector",icon:"fa-cog",online:t.online}),i=e.jsx(ie,{hardware:t}),[c,l]=dc(t.properties.sample_pixel_size,"um",r),u=e.jsxs(s.InputGroup,{className:"flex-nowrap",children:[e.jsx(s.InputGroup.Text,{className:"justify-content-center",style:{minWidth:"4em"},children:t.properties.sample_pixel_size_mode}),e.jsx(R,{value:c,title:`${t.properties.sample_pixel_size} um`}),e.jsx(s.InputGroup.Text,{children:l}),e.jsx(lc,{...n})]}),f=n.options?n.options.header:"top";return e.jsx(w,{hardware:t,widgetIcon:a,widgetState:i,widgetContent:u,headerMode:f})}function uc(n){const{hardware:t,options:o={}}=n;function r(i){return t.actions?t.actions.setProperty("acq_mode",i):console.error("Change request was triggered with:",i),null}const a=t.properties.acq_mode;return e.jsx(s.Dropdown,{style:n.style,children:e.jsxs(s.ButtonGroup,{children:[e.jsx(s.Button,{variant:a==="SINGLE"?"primary":"secondary",onClick:()=>{r("SINGLE")},disabled:n.disabled,title:"Do acquisition in a single shot",children:"SINGLE"}),e.jsx(s.Button,{variant:a==="ACCUMULATION"?"primary":"secondary",onClick:()=>{r("ACCUMULATION")},disabled:n.disabled,title:"Do acqisition in multiple sub frame with accumulation",children:"ACCU"})]})})}function fc(n){const{hardware:t,actions:o}=n,r=t.properties.acc_max_expo_time||0,{state:a}=t.properties,i=a==="READY";function c(l){return o.setProperty("acc_max_expo_time",l),null}return e.jsx(H,{hardwareValue:r,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:i,hardwareIsMoving:!1,readOnly:t.properties.state!=="READY"})}function mc(n){const t=D(n);return t!==null&&ne(t)?t:null}function pc(n){const{hardware:t}=n,{properties:o}=t,r=o.detector.slice(9),a=mc(r),i=tr(r);return e.jsxs(s.Dropdown,{children:[e.jsx(s.Dropdown.Toggle,{disabled:n.disabled,variant:"secondary"}),e.jsx(s.Dropdown.Menu,{children:e.jsxs(s.Container,{children:[e.jsx(s.Row,{children:e.jsx(s.Col,{className:"text-center",children:"Acquisition mode"})}),e.jsx(s.Row,{children:e.jsx(s.Col,{children:e.jsx(uc,{...n,style:{width:"100%"}})})}),e.jsx(s.Row,{children:e.jsx(s.Col,{className:"text-center mt-1",children:"Max sub frame exposition"})}),e.jsx(s.Row,{children:e.jsx(s.Col,{children:a&&e.jsxs(s.InputGroup,{children:[e.jsx(fc,{hardware:a,actions:i}),e.jsx(s.InputGroup.Text,{children:"um"})]})})})]})})]})}function ft(n){const{hardware:t}=n,o=e.jsx(x,{name:"TomoDetector",icon:"fa-cog",online:t.online}),r=e.jsx(ie,{hardware:t}),a=e.jsxs(s.InputGroup,{className:"flex-nowrap",children:[e.jsx(R,{value:t.properties.acq_mode}),e.jsx(pc,{...n})]}),i=n.options?n.options.header:"top";return e.jsx(w,{hardware:t,widgetIcon:o,widgetState:r,widgetContent:a,headerMode:i})}const hc={samplepixelsize:ut,acquisitionmode:ft,state:ac},xc=hc;function je(n){return n.type==="tomodetector"}function gc(n){const t=D(n);return t===null||!je(t)?null:t}const jc="tomodetector",wc="tomodetector",vc=!0,Nc={state:"READY",actual_size:[1024,1024],sample_pixel_size_mode:"AUTO",user_sample_pixel_size:50,sample_pixel_size:48},yc="bliss",bc=!1,_c="tomodetector",$c={id:jc,name:wc,online:vc,properties:Nc,protocol:yc,require_staff:bc,type:_c},Cc={default:$c};function we(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",r={READY:"success",MOUNTING:"warning",UNMOUNTING:"warning",UNKNOWN:"fatal",OFFLINE:"warning"},a=r[o]||r.UNKNOWN;return e.jsx(S,{state:o,minWidth:6,variant:a})}function Oc(n){const{hardware:t}=n;return e.jsx(we,{hardware:t})}function q(n){return!n||!n.startsWith("hardware:")?null:n.slice(9)}function Ic(n){const{hardware:t}=n,{properties:o}=t,{detectors:r}=o,a=q(o.active_detector),i=q(o.target_detector),c=o.state==="READY",l=n.disabled||!t.online||!c;function u(d){t.actions?t.actions.call("mount",d):console.error("Change request was triggered with:",d)}function f(d){const m=q(d),j=m===(i||a)?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(s.Dropdown.Item,{disabled:l,onClick:()=>{u(m)},children:[e.jsx("i",{className:j}),"  ",m]},d)}return e.jsxs(s.Dropdown,{children:[e.jsx(s.Dropdown.Toggle,{disabled:l,variant:"secondary"}),e.jsx(s.Dropdown.Menu,{children:r.map(d=>f(d))})]})}function mt(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"Optic",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(we,{hardware:t}),{properties:i}=t,c=i.state==="MOUNTING",l=q(i.active_detector),u=q(i.target_detector);function f(){return e.jsxs(s.InputGroup,{children:[e.jsx(R,{className:A.default({"hw-moving":c}),value:u||l||"No detector"}),e.jsx(Ic,{...n})]})}const d=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:f(),headerMode:d})}const Sc={default:mt,state:Oc},Tc=Sc;function pt(n){return n.type==="tomodetectors"}function Mc(n){const t=D(n);return t===null||!pt(t)?null:t}const Fc="tomodetectors",Dc="tomodetectors",Ec=!0,Rc={state:"READY",active_detector:"hardware:limadetector1",detectors:["hardware:limadetector1","hardware:limadetector2","hardware:limadetector3"]},Ac="bliss",kc=!1,Bc="optic",Pc={id:Fc,name:Dc,online:Ec,properties:Rc,protocol:Ac,require_staff:kc,type:Bc},Gc={default:Pc};function G(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",r={READY:"success",BLOCKED:"secondary",ACQUIRING:"warning",UNKNOWN:"fatal"},a=r[o]||r.UNKNOWN;return e.jsx(S,{state:o,minWidth:6,variant:a})}function Vc(n){const{hardware:t}=n;return e.jsx(G,{hardware:t})}function Lc(n){const{hardware:t}=n,o=t.properties.update_on_move,r=n.disabled||!t.online;function a(c){t.actions.setProperty("update_on_move",!1)}function i(c){t.actions.setProperty("update_on_move",!0)}return e.jsxs(s.ButtonGroup,{className:"me-2",children:[e.jsx(s.InputGroup.Text,{children:"Update mode"}),e.jsx(s.Button,{onClick:i,disabled:r,variant:o?"primary":"secondary",children:"Auto"}),e.jsx(s.Button,{onClick:a,disabled:r,variant:o?"secondary":"primary",children:"Off"})]})}function Uc(n){const{hardware:t}=n,o=t.properties.exposure_time||0,r=n.disabled||!t.online,a=h.useRef(null),[i,c]=h.useState(!1),l=2;function u(d){!a||!a.current?console.log("formRef not yet defined"):d.key==="Enter"?(c(!1),t.actions.setProperty("exposure_time",a.current.value)):d.key==="Escape"?(a.current.value=o.toFixed(l),c(!1)):console.log(d.key)}function f(d){const{value:m}=d.target;if(m===void 0)return;const p=Number.parseFloat(m);p!==o&&!i&&c(!0),p===o&&i&&c(!1)}return h.useEffect(()=>{!a||!a.current?console.log("formRef not yet defined"):i||(a.current.value=o.toFixed(l))},[i,o]),e.jsxs(s.InputGroup,{className:"me-2",children:[e.jsx(s.InputGroup.Text,{children:"Exposure time"}),e.jsx(s.Form.Control,{className:i?"form-control-edited":"",type:"number",ref:a,defaultValue:o.toFixed(l),onChange:f,disabled:r,onKeyDown:u}),e.jsx(s.InputGroup.Text,{children:"s"})]})}function qc(n){const{hardware:t}=n,o=n.disabled||!t.online;function r(c){t.actions.call("take_proj")}function a(c){t.actions.call("take_dark")}function i(c){t.actions.call("take_flat")}return e.jsxs(s.ButtonGroup,{size:"lg",className:"me-2",children:[e.jsx(s.InputGroup.Text,{children:"Take"}),e.jsx(s.Button,{onClick:r,disabled:o,variant:"primary",children:"Proj"}),e.jsx(s.Button,{onClick:i,disabled:o,variant:"primary",children:"Flat"}),e.jsx(s.Button,{onClick:a,disabled:o,variant:"primary",children:"Dark"})]})}function ht(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(G,{hardware:t}),i=e.jsxs(s.Container,{children:[e.jsx(s.Row,{className:"mt-1",children:e.jsx(s.Col,{children:e.jsx(Lc,{hardware:t,disabled:n.disabled})})}),e.jsx(s.Row,{className:"mt-1",children:e.jsx(s.Col,{children:e.jsx(Uc,{hardware:t,disabled:n.disabled})})}),e.jsx(s.Row,{className:"mt-1",children:e.jsx(s.Col,{children:e.jsx(qc,{hardware:t,disabled:n.disabled})})})]}),c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}function Hc(n){const{hardware:t}=n,o=t.properties.exposure_time||0,r=n.disabled||!t.online,a=h.useRef(null),[i,c]=h.useState(!1),l=3;function u(d){!a||!a.current?console.log("formRef not yet defined"):d.key==="Enter"?(c(!1),t.actions.setProperty("exposure_time",a.current.value)):d.key==="Escape"?(a.current.value=o.toFixed(l),c(!1)):console.log(d.key)}function f(d){const{value:m}=d.target;if(m===void 0)return;const p=Number.parseFloat(m);p!==o&&!i&&c(!0),p===o&&i&&c(!1)}return h.useEffect(()=>{!a||!a.current?console.log("formRef not yet defined"):i||(a.current.value=o.toFixed(l))},[i,o]),e.jsxs(s.InputGroup,{className:"w-100",children:[e.jsx(s.Form.Control,{className:i?"form-control-edited":"",type:"number",ref:a,defaultValue:o.toFixed(l),onChange:f,disabled:r,onKeyDown:u}),e.jsx(s.InputGroup.Text,{children:"s"})]})}function Wc(n){const{exposureTime:t}=n,o=D("ACTIVE_TOMOCONFIG.ref.detectors.active_detector.detector"),r=D("ACTIVE_TOMOCONFIG.ref.detectors.active_detector");if(o===null||r===null)return e.jsx(e.Fragment,{});if(!ne(o)||!je(r))return e.jsx(e.Fragment,{});const a=o.properties.acc_max_expo_time,i=r.properties.acq_mode;if(!a||i!=="ACCUMULATION")return e.jsx(e.Fragment,{});const[c,l]=We(t,a);return e.jsxs("div",{className:"text-center",title:"Decompisiton of the accumulation",children:[c," × ",l.toFixed(3)]})}function xt(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(G,{hardware:t}),i=e.jsxs(e.Fragment,{children:[e.jsx(Hc,{hardware:t,disabled:n.disabled}),e.jsx(Wc,{exposureTime:t.properties.exposure_time})]}),c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}function zc(n){const{hardware:t}=n,o=t.properties.settle_time||0,r=n.disabled||!t.online,a=h.useRef(null),[i,c]=h.useState(!1),l=3;function u(d){!a||!a.current?console.log("formRef not yet defined"):d.key==="Enter"?(c(!1),t.actions.setProperty("settle_time",a.current.value)):d.key==="Escape"?(a.current.value=o.toFixed(l),c(!1)):console.log(d.key)}function f(d){const{value:m}=d.target;if(m===void 0)return;const p=Number.parseFloat(m);p!==o&&!i&&c(!0),p===o&&i&&c(!1)}return h.useEffect(()=>{!a||!a.current?console.log("formRef not yet defined"):i||(a.current.value=o.toFixed(l))},[i,o]),e.jsxs(s.InputGroup,{className:"w-100",children:[e.jsx(s.Form.Control,{className:i?"form-control-edited":"",type:"number",ref:a,defaultValue:o.toFixed(l),onChange:f,disabled:r,onKeyDown:u}),e.jsx(s.InputGroup.Text,{children:"s"})]})}function gt(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(G,{hardware:t}),i=e.jsx(zc,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}function Kc(n){const{hardware:t}=n,o=n.disabled||!t.online;function r(c){t.actions.call("take_proj")}function a(c){t.actions.call("take_dark")}function i(c){t.actions.call("take_flat")}return e.jsxs(s.ButtonGroup,{size:"lg",className:"w-100",children:[e.jsx(s.Button,{onClick:r,disabled:o,variant:"primary",children:"Proj"}),e.jsx(s.Button,{onClick:i,disabled:o,variant:"primary",children:"Flat"}),e.jsx(s.Button,{onClick:a,disabled:o,variant:"primary",children:"Dark"})]})}function jt(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(G,{hardware:t}),i=e.jsx(Kc,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}function Yc(n){const{hardware:t}=n,o=t.properties.update_on_move,r=n.disabled||!t.online;function a(c){t.actions.setProperty("update_on_move",!1)}function i(c){t.actions.setProperty("update_on_move",!0)}return e.jsxs(s.ButtonGroup,{className:"w-100",children:[e.jsx(s.Button,{onClick:i,disabled:r,variant:o?"primary":"secondary",children:"Auto"}),e.jsx(s.Button,{onClick:a,disabled:r,variant:o?"secondary":"primary",children:"Off"})]})}function wt(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(G,{hardware:t}),i=e.jsx(Yc,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}const Qc={default:ht,exposuretime:xt,settletime:gt,actions:jt,updatemode:wt,state:Vc},Xc=Qc,Jc="tomoimaging",Zc="tomoimaging",el=!0,tl={state:"READY",update_on_move:!1,exposure_time:1},nl="bliss",ol=!1,rl="optic",sl={id:Jc,name:Zc,online:el,properties:tl,protocol:nl,require_staff:ol,type:rl},al={default:sl},il={},cl=il;function vt(n){return n.type==="tomosamplestage"}function ll(n){const t=D(n);return t===null||!vt(t)?null:t}function dl(n){const{hardware:t}=n,o=t.properties.latency_time||0,r=n.disabled||!t.online,a=h.useRef(null),[i,c]=h.useState(!1),l=3;function u(d){!a||!a.current?console.log("formRef not yet defined"):d.key==="Enter"?(c(!1),t.actions.setProperty("latency_time",a.current.value)):d.key==="Escape"?(a.current.value=o.toFixed(l),c(!1)):console.log(d.key)}function f(d){const{value:m}=d.target;if(m===void 0)return;const p=Number.parseFloat(m);p!==o&&!i&&c(!0),p===o&&i&&c(!1)}return h.useEffect(()=>{!a||!a.current?console.log("formRef not yet defined"):i||(a.current.value=o.toFixed(l))},[i,o]),e.jsxs(s.InputGroup,{className:"w-100",children:[e.jsx(s.Form.Control,{className:i?"form-control-edited":"",type:"number",ref:a,defaultValue:o.toFixed(l),onChange:f,disabled:r,onKeyDown:u}),e.jsx(s.InputGroup.Text,{children:"s"})]})}function Nt(n){const{hardware:t,options:o={}}=n,r=e.jsx(x,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(e.Fragment,{}),i=e.jsx(dl,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(w,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:i,headerMode:c})}const ul={latencytime:Nt},fl=ul;function yt(n){return n.type==="tomoconfig"}function ml(n){const t=D(n);return t===null||!yt(t)?null:t}function bt(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",r={READY:"success",MOVING:"warning",STABILIZING:"warning",INVALID:"danger",INVALID_DETECTOR_BINNING_CHANGED:"danger",INVALID_DETECTOR_DISTANCE_CHANGED:"danger",INVALID_DETECTOR_CHANGED:"danger"},a=r[o]||r.UNKNOWN;return e.jsx(S,{state:o,minWidth:6,variant:a})}function pl(n){const{hardware:t}=n;return e.jsx(bt,{hardware:t})}const hl={state:pl},xl=hl;function _t(n){return n.type==="tomoholo"}function gl(n){const t=D(n);return t===null||!_t(t)?null:t}function jl(n){const{hardware:t}=n,o=()=>{t.actions.call("reset")};return e.jsx(s.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(s.Popover,{id:"popover",children:[e.jsxs(s.Popover.Header,{children:[t.name," Details"]}),e.jsxs(s.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(s.Button,{disabled:n.disabled,onClick:o,children:"Reset"})})]})]}),children:e.jsx(s.Button,{className:"flex-grow-0",title:"Valve Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function $t(n){const{hardware:t,options:o={}}=n,r=()=>{t.actions.call(t.properties.state==="OPEN"?"close":"open")};return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(x,{name:"Valve",icon:"fam-hardware-valve",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(s.Badge,{bg:t.properties.state==="OPEN"||t.properties.state==="RUNNING"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(s.ButtonGroup,{className:"d-flex",children:[e.jsx(s.Button,{variant:t.properties.state==="OPEN"?"danger":"success",onClick:r,disabled:n.disabled,children:t.properties.state==="OPEN"?"Close":"Open"}),e.jsx(jl,{...n})]})})]})}const wl={default:$t},vl=wl,Nl=["close","reset","open"],yl="rv12",bl="rv12",_l=!0,$l={state:"CLOSED",status:`Pneumatic is closed
35
+ `},Cl="tango",Ol=!1,Il="valve",Sl={callables:Nl,id:yl,name:bl,online:_l,properties:$l,protocol:Cl,require_staff:Ol,type:Il},Tl={default:Sl},Ml=zt.default("daiquiri.components.hardware.NoObject");function Fl(n){if(n.options.emptyifnone)return Ml('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const t=e.jsx(x,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),r=e.jsx(e.Fragment,{children:"Missing"}),a=n.options?n.options.header:"top",i={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(w,{hardware:i,widgetIcon:t,widgetState:o,widgetContent:r,headerMode:a})}function Ct(n){const[t,o]=h.useState({}),r=h.useRef(null);return h.useEffect(()=>{if(r.current){const a=r.current;o({width:a.clientWidth,height:a.clientHeight})}},[]),e.jsx("div",{ref:r,style:{width:"100%",height:"100%"},className:n.className,children:t.width>0&&e.jsx("div",{className:"full-sizer",style:{width:`${t.width}px`,height:`${t.height}px`,overflow:"scroll"},children:n.children})})}function Dl(n){return e.jsx("div",{className:"panel-header",style:n.style,children:n.children})}function El(n){return e.jsx("div",{className:`panel-contents ${n.className}`,style:n.style,children:n.children})}function $(n){const t=n.scroll?Ct:h.Fragment;return e.jsx("div",{className:`panel ${n.className??""}`,style:n.style,children:e.jsx(t,{children:n.children})})}$.Header=Dl;$.Contents=El;const Rl=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Al=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),X={};function Ot(n,t){X[n]=t}function E(n,t,o=!0){if(!n)return e.jsx(e.Fragment,{});const{type:r}=n,a=r&&r in X?X[r]:X.component;return e.jsx(a,{yamlNode:n,panel:o},t)}function kl({children:n,key:t,panel:o,options:r}){return o?e.jsx($,{style:r.style,scroll:r.scroll,children:e.jsx($.Contents,{children:n})},t):e.jsx(e.Fragment,{children:h.Children.map(n,a=>h.isValidElement(a)?h.cloneElement(a,{key:t,...a.props}):void 0)})}function It(n,t){const{_parentNode:o,_indexFromParent:r,...a}=t;if(n&&Object.keys(a).length>0)throw new J(n,Object.keys(a))}class P extends Error{constructor(t,o){super(t),this.yamlNode=o}}class J extends P{constructor(t,o){super(`Unexpected keys: ${o.join(", ")}`,t),this.keys=o}}class W extends P{constructor(t,o){super(`Keys ${o.join(", ")} are missing`,t),this.keys=o}}class C extends P{constructor(t,o,r){super(`Key ${o} error: ${r}`,t),this.key=o,this.keyMessage=r}}function Bl(n){let t=n;for(;t._parentNode;)t=t._parentNode;return t}function Pl(n){const t=[];let o=n;for(;o;)t.push({node:o,indexFromParent:o._indexFromParent}),o=o._parentNode;return t.reverse(),t}function St(n,t=null,o=null){if(n._parentNode)throw new Error("Attribute _parentNode was already defined by the yml layout.");const r={...n,_parentNode:t,_indexFromParent:o};if(n.children){const a=[...n.children];Object.freeze(a),r.children=a.map((i,c)=>St(i,r,c))}return Object.freeze(r),r}function Tt(n){var t;return e.jsxs(s.Alert,{variant:"danger",children:[n.message,e.jsx("br",{}),e.jsx("pre",{children:(t=n.error)==null?void 0:t.stack})]})}function Gl(n){const{error:t}=n;if(!(t instanceof P))return e.jsx(e.Fragment,{});function o(i,c=3){const l=Pl(i.yamlNode),u=[];let f="";for(let d=1;d<l.length;d++){const{node:m,indexFromParent:p}=l[d];u.push(`${f}children:`),f+=" ".repeat(c),p===1?u.push(`${f}- type: ...`):(p??0>1)&&u.push(`${f}...`,`${f}...`,`${f}# children number ${p??0+1}`),u.push(`${f}- type: ${m.type}`),f+=" ".repeat(2)}return i instanceof J?i.keys.forEach(d=>{u.push(`${f}${d}: ... ${" ".repeat(50-f.length-d.length)}<-- unexpected key`)}):i instanceof W?i.keys.forEach(d=>{u.push(`${f}???: ${" ".repeat(50-f.length-d.length)}<-- key **${d}** is expected`)}):i instanceof C&&u.push(`${f}${i.key}: ${" ".repeat(50-f.length-i.key.length)}<-- ${i.keyMessage}`),u.join(`
36
+ `)}const a=Bl(t.yamlNode).name;if(t instanceof J){const i=t.keys.length===1?"key":"keys";return e.jsxs(s.Alert,{variant:"danger",children:["Unexpected ",i," ",t.keys.map((c,l)=>e.jsxs(e.Fragment,{children:[l!==0&&", ",e.jsx("b",{children:c})]}))," ","from the layout name ",e.jsx("b",{children:a}),".",e.jsx("br",{}),e.jsx("pre",{className:"mt-3",children:o(t)}),e.jsx("br",{})]})}if(t instanceof W){const i=t.keys.length===1?"Key":"Keys";return e.jsxs(s.Alert,{variant:"danger",children:["Expected ",i," ",t.keys.map((c,l)=>e.jsxs(e.Fragment,{children:[l!==0&&", ",e.jsx("b",{children:c})]}))," ","from the layout name ",e.jsx("b",{children:a}),".",e.jsx("br",{}),e.jsx("pre",{className:"mt-3",children:o(t)}),e.jsx("br",{})]})}return t instanceof C?e.jsxs(s.Alert,{variant:"danger",children:["Error on key ",e.jsx("b",{children:t.key})," from the layout name ",e.jsx("b",{children:a}),".",e.jsx("br",{}),e.jsx("pre",{className:"mt-3",children:o(t)}),e.jsx("br",{})]}):e.jsx(Tt,{...n})}const _e={hasError:!1,message:"",error:void 0};class Mt extends h.Component{constructor(t){super(t),this.reload=()=>{window.location.reload()},this.state=_e}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){var o,r;if(t instanceof P||!this.props.unhandledComponentDidCatch){this.setState({hasError:!0,message:t.message,error:t});return}(r=(o=this.props).unhandledComponentDidCatch)==null||r.call(o,t,a=>{this.setState({hasError:!0,message:t.message,error:t,...a})})}componentDidUpdate(t,o){this.state.hasError&&o.error!==void 0&&t.resetKey!==this.props.resetKey&&this.setState(_e)}render(){if(this.state.hasError){const{UnhandledErrorComponent:t}=this.props,{hasError:o,...r}=this.state;return e.jsxs(s.Container,{className:"mt-2",children:[e.jsx("h4",{children:"Something went wrong"}),this.state.error instanceof P&&e.jsx(Gl,{message:this.state.message,error:this.state.error}),!(this.state.error instanceof P)&&e.jsx(e.Fragment,{children:t?e.jsx(t,{...r}):e.jsx(Tt,{message:this.state.message,error:this.state.error})}),e.jsxs("p",{children:["This error has been logged. Please"," ",e.jsxs(s.Button,{size:"sm",onClick:this.reload,children:[e.jsx("i",{className:"fa fa-refresh"})," Reload"]})," ","the application"]})]})}return this.props.children}}function Vl(n,t,o){if(n&&o===void 0)throw new W(n,[t])}function Ll(n,t,o){if(typeof o!="string")throw new C(n,t,"A string is expected")}function Ul(n,t,o){if(typeof o!="boolean")throw new C(n,t,"A boolean is expected")}function ql(n,t,o){if(typeof o!="number")throw new C(n,t,"A number is expected")}function fe(n,t,o){if(o!==void 0&&typeof o!="boolean")throw new C(n,t,"An optional boolean is expected")}function Ft(n,t,o){if(o!==void 0&&typeof o!="string")throw new C(n,t,"An optional string is expected")}function Hl(n,t,o){if(!Array.isArray(o))throw new C(n,t,"A list of string is expected");o.forEach(r=>{if(typeof r!="string")throw new C(n,t,"A list of string is expected")})}function Wl(n,t,o){if(o!==void 0&&typeof o!="string"){if(!Array.isArray(o))throw new C(n,t,"An optional string or list of string is expected");o.forEach(r=>{if(typeof r!="string")throw new C(n,t,"An optional string or list of string is expected")})}}function zl(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new C(n,t,"An optional list of string is expected");o.forEach(r=>{if(typeof r!="string")throw new C(n,t,"A optional list of string is expected")})}}function Dt(n,t,o){if(o!==void 0&&typeof o!="number")throw new C(n,t,"An optional number is expected")}function Kl(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new C(n,t,"An optional list of numbers is expected");o.forEach(r=>{if(typeof r!="number")throw new C(n,t,"An optional list of numbers is expected")})}}function ce(n,t){const{_parentNode:o,_indexFromParent:r,...a}=t;if(n&&Object.keys(a).length>0)throw new J(n,Object.keys(a))}function Yl(n,t,o){if(o!=="last"&&typeof o!="number")throw new C(n,t,'"last" or a number is expected')}function Ql(n,t,o){if(o!==void 0&&o!=="h5web"&&o!=="plotly")throw new C(n,t,'"h5web" or "plotly" string is expected')}const Xl=Object.freeze(Object.defineProperty({__proto__:null,assertBoolean:Ul,assertDataCollectionId:Yl,assertKeyExpected:Vl,assertNoUnknownKeys:ce,assertNumber:ql,assertOptionalBackend:Ql,assertOptionalBoolean:fe,assertOptionalNumber:Dt,assertOptionalNumberList:Kl,assertOptionalString:Ft,assertOptionalStringList:zl,assertOptionalStringOrStringList:Wl,assertString:Ll,assertStringList:Hl},Symbol.toStringTag,{value:"Module"}));function Jl({yamlNode:n,panel:t}){const{type:o,style:r,children:a,...i}=n;return ce(n,i),e.jsx(s.Row,{className:"ymllayout-row gx-0",style:r,children:F.map(a,(c,l)=>E(c,l,t))})}function Zl({yamlNode:n,panel:t}){const{type:o,style:r,xs:a,children:i,...c}=n;return ce(n,c),Dt(n,"xs",a),e.jsx(s.Col,{className:A.default("yamymllayout-col",{col:!!a}),style:r,xs:a,children:F.map(n.children,(l,u)=>E(l,u,t))})}const me={};function ed(n,t){me[n]=t}function td(n,t){if(t===void 0)throw new W(n,["id"]);if(typeof t.id!="string")throw new C(n,"id","A string is expected")}function nd(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new C(n,t,"A option list is expected");o.forEach((r,a)=>{try{td(n,r)}catch{throw new C(n,t,`The hardware description ${a} is wrong`)}})}}function od(n){const{providers:t={},yamlNode:o,ids:r,groupid:a,even:i,nowrap:c,...l}=n;if(nd(o,"ids",r),Ft(o,"groupid",a),fe(o,"even",i),fe(o,"nowrap",c),ce(o,l),!me.HardwareGroup)return e.jsx(s.Alert,{variant:"warning",children:"No `HardwareGroup` component registered"});const u=me.HardwareGroup;return e.jsx(u,{providers:t,ids:r,groupid:a,nowrap:c||!1,even:i||!1})}const pe={hardwaregroup:od};function Et(n,t){pe[n]=t}function rd(n){Object.entries(n).forEach(([t,o])=>Et(t,o))}function sd(n){const{yamlNode:t,panel:o}=n,{type:r,style:a,scroll:i,title:c,...l}=t;if(!(r in pe))return e.jsx($,{children:e.jsx($.Contents,{children:e.jsxs(s.Alert,{variant:"warning",children:['Unknown component "',r,'"']})})});const u=pe[t.type];return o?e.jsx($,{style:a,scroll:i,children:e.jsxs(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:[c&&e.jsx($.Header,{children:c}),e.jsx($.Contents,{children:e.jsx(u,{...l,yamlNode:t})})]})}):e.jsx(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:e.jsx(u,{...l,yamlNode:t})})}function ad({yamlNode:n,panel:t}){const o=n.options||{};return e.jsx(s.Container,{className:"ymllayout-container",...o,children:F.map(n.children,(r,a)=>E(r,a,t))})}function id(n){const{yamlNode:t}=n,o=t.options||{},r={};return o.centerContent&&(r.margin="auto"),e.jsxs($,{className:"ymllayout-panel",...o,children:[t.title&&e.jsx($.Header,{children:t.title}),e.jsx($.Contents,{style:r,children:F.map(t.children,(a,i)=>E(a,i,!1))})]})}const cd=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15);function ld({yamlNode:n,panel:t}){const o=[];return F.each(n.children,(r,a)=>{o.push(e.jsx(s.Tab,{eventKey:cd(),title:r.title,children:E(r,0,!1)},a))}),t?e.jsxs($,{className:"ymllayout-tabs",children:[n.title&&e.jsx($.Header,{children:n.title}),e.jsx($.Contents,{children:e.jsx(s.Tabs,{mountOnEnter:!0,children:o})})]}):e.jsx(s.Tabs,{children:o})}function dd(n){const{node:t}=n,{type:o,title:r,...a}=t;return It(t,a),e.jsx("div",{className:"ymllayout-form-header",style:{gridColumn:"1 / 3"},children:e.jsx("h3",{children:r})})}function ud(n){const{node:t,state:o,row:r}=n,{title:a}=t;function i(){if(t.id)return t.id}function c(){if(a!==void 0)return a;if(t.type==="hardware"){const u=i(),f={_parentNode:t._parentNode,_indexFromParent:t._indexFromParent,type:"hardware",id:u,variant:"name",emptyifnone:!0};return E(f,"a",!1)}return""}const l=c();return e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("h5",{style:{margin:"0px",whiteSpace:"nowrap"},children:l}),o&&e.jsx("div",{style:{position:"relative",top:-5},children:o})]})}function fd(n){const{node:t,row:o}=n,{titlealign:r,title:a,stateinheader:i=!1,variant:c,id:l,...u}=t;let f,d;if(u.type==="hardware")if(f={...u,id:l,variant:c},i){const m={...u,id:l,variant:"state",emptyifnone:!0};d=E(m,"k",!1)}else d=null;else f=u,d=null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{gridColumn:1,alignSelf:r??"center"},children:e.jsx(ud,{node:t,state:d,row:o})}),e.jsx("div",{style:{gridColumn:2,alignSelf:"center"},children:E(f,"k",!1)})]})}function md(n){const{yamlNode:t,panel:o}=n,{type:r,children:a,options:i={},title:c,...l}=t;return It(t,l),e.jsxs($,{className:"ymllayout-form",...i,children:[t.title&&e.jsx($.Header,{children:t.title}),e.jsx($.Contents,{className:"full-sizer",style:{overflow:"auto"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"min-content auto"},children:F.map(a,(u,f)=>u.type==="formheader"?e.jsx(dd,{node:u,row:f},f):e.jsx(fd,{node:u,row:f},f))})})]})}function pd(n){const{yamlNode:t,panel:o}=n;return e.jsxs("div",{className:"ymllayout-grid",style:{gridTemplateColumns:t.columns,gridTemplateRows:t.rows},children:[F.map(t.children,(r,a)=>{const{columnSpan:i=1,rowSpan:c=1,...l}=r,u=i>1?`span ${i}`:void 0,f=c>1?`span ${c}`:void 0;return e.jsx("div",{className:"ymllayout-grid-cell",style:{gridColumn:u,gridRow:f},children:E(l,a,o)},a)})," "]})}function hd({yamlNode:n,panel:t}){const o=n.options||{};return e.jsx(kl,{panel:t,options:o,children:e.jsx("div",{children:n.label})})}const Rt={row:Jl,col:Zl,container:ad,component:sd,panel:id,tabs:ld,form:md,grid:pd,label:hd};Object.entries(Rt).forEach(([n,t])=>{Ot(n,t)});function xd(n){var o;const t=h.useMemo(()=>St(n.layout),[n.layout]);return t.error?e.jsx("div",{className:`${n.className??""} ymllayout-main`,"data-testid":n.testid,children:e.jsxs($,{children:[e.jsx($.Header,{children:"Layout Error"}),e.jsxs($.Contents,{children:[e.jsxs("p",{children:["File: ",t.name]}),e.jsx(s.Alert,{variant:"warning",children:e.jsx("pre",{className:"mb-0",children:t.error})})]})]})}):e.jsx("div",{className:`${n.className??""} ymllayout-main`,"data-testid":n.testid,children:e.jsx(Mt,{resetKey:t,unhandledComponentDidCatch:n.unhandledComponentDidCatch,UnhandledErrorComponent:n.UnhandledErrorComponent,children:(o=t.children)==null?void 0:o.map((r,a)=>E(r,a))})})}const gd=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),At=(n,t,o)=>{const r={">":(a,i)=>a>i,"<":(a,i)=>a<i,">=":(a,i)=>a>=i,"<=":(a,i)=>a<=i,"==":(a,i)=>a===i,"!=":(a,i)=>a!==i,in:(a,i)=>i.indexOf(a)>-1};if(n in r)return r[n](t,o)};function kt(n,t,o){const r=n.split(t);return o?[r.slice(0,-o).join(t)].concat(r.slice(-o)):r}function $e(n){const t=n!==void 0?kt(n,".",1):[null,""],o=D(t[0]);if(o&&o.properties&&t[1]!==null)return Array.isArray(o.properties[t[1]])?o.properties[t[1]][0]:o.properties[t[1]]}function jd(n){const t=n!==void 0&&!n.includes("."),o=n!==void 0?kt(n,".",1):[null,""],r=D(o[0]);if(t)return n;if(r&&r.properties&&o[1]!==null)return`${r.properties[o[1]]}`}function Bt(n){const{monitor:t}=n;let o=$e(t.value)??"-";const r=jd(t.unit),a=$e(t.overlay),i=Number.parseFloat(`${o}`);Number.isNaN(i)||String(i).length>5&&(o=i.toPrecision(5));let c;if(t.comparator&&t.comparison&&(c=At(t.comparator,o,t.comparison)?"valid":"invalid"),Number.isNaN(i)||r!==void 0&&(o=`${o} ${r}`),a){const l=`${a}`;return e.jsx(s.OverlayTrigger,{placement:"bottom",overlay:e.jsx(s.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:l.includes(`
37
+ `)?e.jsx("pre",{children:l}):l}),children:e.jsxs(s.Col,{className:"monitor-panel-item",children:[e.jsx("h1",{children:t.name}),e.jsx("div",{className:c,children:`${o}`})]})},t.name)}return e.jsxs(s.Col,{className:"monitor-panel-item",children:[e.jsx("h1",{children:t.name}),e.jsx("div",{className:c,children:`${o}`})]},t.name)}const Pt={hardware:Bt};function wd(n,t){Pt[n]=t}function vd(n){return e.jsxs(s.Col,{className:"monitor-panel-item bg-fatal",title:`Error from yaml configuration: ${n.message}`,children:[e.jsx("h1",{children:n.monitor.name}),e.jsx("div",{children:"Parsing error"})]})}function Nd(n){const t=F.map(n.monitors,(o,r)=>{const a=o.type??"hardware",i=Pt[a];return i===void 0?e.jsx(vd,{monitor:o,message:`Type ${a} unsupported`},`m${r}`):e.jsx(i,{monitor:o},`m${r}`)});return e.jsx("div",{className:A.default({"ms-auto":n.margin==="start"},"me-auto","monitor-panel",{"monitor-panel-light":n.bg==="light"}),children:e.jsx(s.Container,{fluid:!0,children:e.jsx(s.Row,{className:"flex-nowrap",children:t})})})}function yd(n){return e.jsx(s.Col,{className:"monitor-panel-item",children:n.children})}exports.AirBearing=Me;exports.AirBearingMocks=Nn;exports.AirBearingProtected=Fe;exports.AirBearingState=ee;exports.AirBearingVariants=un;exports.BaseInfo=Ie;exports.BaseMocks=nn;exports.BaseName=Oe;exports.BaseProperty=Se;exports.BaseState=Ce;exports.BaseVariants=Jt;exports.Formatting=Cn;exports.Frontend=Ee;exports.FrontendMocks=Pn;exports.FrontendVariants=Sn;exports.FullSizer=Ct;exports.Gauge=Re;exports.GaugeMocks=io;exports.GaugeVariants=Ln;exports.HWObject=gd;exports.HardwareInputNumber=H;exports.HardwareNumericStep=te;exports.HardwareSchema=Al;exports.HardwareState=rn;exports.HardwareTemplate=w;exports.HardwareTypes=Rl;exports.KeyError=C;exports.Laser=ke;exports.LaserHeating=Be;exports.LaserHeatingMocks=Eo;exports.LaserHeatingVariants=_o;exports.LaserMocks=No;exports.LaserVariants=uo;exports.Light=Pe;exports.LightMocks=Wo;exports.LightVariants=Ao;exports.LimaBinning=Ue;exports.LimaDefault=Ge;exports.LimaDescription=He;exports.LimaImageRoi=qe;exports.LimaMocks=Sr;exports.LimaSize=Ve;exports.LimaState=B;exports.LimaTransformation=Le;exports.LimaVariants=rr;exports.MissingKeysError=W;exports.MockMotor=Ls;exports.MonitorHardware=Bt;exports.MonitorPanel=Nd;exports.MonitorPanelItem=yd;exports.MotorDefault=ze;exports.MotorMocks=Gs;exports.MotorState=oe;exports.MotorText=Ke;exports.MotorVariants=Dr;exports.Multiposition=Qe;exports.MultipositionMocks=ea;exports.MultipositionVariants=qs;exports.NoObject=Fl;exports.NumericStep=Ae;exports.OpticDefault=Je;exports.OpticMocks=ga;exports.OpticState=xe;exports.OpticVariants=ca;exports.Panel=$;exports.ProcedureExecution=Ze;exports.ProcedureManage=ue;exports.ProcedureMocks=Ea;exports.ProcedureState=K;exports.ProcedureValidate=et;exports.ProcedureVariants=_a;exports.PumpDefault=ot;exports.PumpMocks=ci;exports.PumpVariants=Ja;exports.PusherDefault=rt;exports.PusherMocks=bi;exports.PusherState=ge;exports.PusherVariants=mi;exports.ServiceDefault=st;exports.ServiceMocks=ki;exports.ServiceProtected=at;exports.ServiceState=se;exports.ServiceVariants=Oi;exports.ShutterDefault=tt;exports.ShutterMocks=Ya;exports.ShutterProtected=nt;exports.ShutterState=re;exports.ShutterVariants=Pa;exports.TomoConfigLatencyTime=Nt;exports.TomoConfigVariants=fl;exports.TomoDetectorAcquisitionMode=ft;exports.TomoDetectorMocks=Cc;exports.TomoDetectorSamplePixelSize=ut;exports.TomoDetectorState=ie;exports.TomoDetectorVariants=xc;exports.TomoDetectorsDefault=mt;exports.TomoDetectorsMocks=Gc;exports.TomoDetectorsState=we;exports.TomoDetectorsVariants=Tc;exports.TomoFlatMotionDefault=it;exports.TomoFlatMotionMocks=nc;exports.TomoFlatMotionSmall=ct;exports.TomoFlatMotionState=ae;exports.TomoFlatMotionVariants=Wi;exports.TomoHoloState=bt;exports.TomoHoloVariants=xl;exports.TomoImagingActions=jt;exports.TomoImagingDefault=ht;exports.TomoImagingExposureTime=xt;exports.TomoImagingMocks=al;exports.TomoImagingSettleTime=gt;exports.TomoImagingState=G;exports.TomoImagingUpdateMode=wt;exports.TomoImagingVariants=Xc;exports.TomoReferencePositionDefault=dt;exports.TomoReferencePositionVariants=sc;exports.TomoSampleStageVariants=cl;exports.TypeIcon=x;exports.ValveDefault=$t;exports.ValveMocks=Tl;exports.ValveVariants=vl;exports.Wrapper=on;exports.YAMLErrorBoundary=Mt;exports.YAMLLayout=xd;exports.YamlAsserts=Xl;exports.createMotorMock=Vs;exports.dynamicOp=At;exports.isLimaHardware=ne;exports.isMotorHardware=Ye;exports.isOpticHardware=aa;exports.isTomoConfigHardware=yt;exports.isTomoDetectorHardware=je;exports.isTomoDetectorsHardware=pt;exports.isTomoFlatMotionHardware=lt;exports.isTomoHoloHardware=_t;exports.isTomoReferencePositionHardware=oc;exports.isTomoSampleStageHardware=vt;exports.limaGuessSubframes=We;exports.registerHardwareComponent=ed;exports.registerMonitorComponent=wd;exports.registerRuntimeHook=er;exports.registerYamlComponent=Et;exports.registerYamlComponents=rd;exports.registerYamlType=Ot;exports.renderYamlNode=E;exports.useLimaHardware=nr;exports.useMotorHardware=z;exports.useMotorStates=he;exports.useTomoConfigHardware=ml;exports.useTomoDetectorHardware=gc;exports.useTomoDetectorsHardware=Mc;exports.useTomoFlatMotionHardware=zi;exports.useTomoHoloHardware=gl;exports.useTomoSampleStageHardware=ll;exports.yamlMap=Rt;
4
38
  //# sourceMappingURL=index.js.map