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