@esrf/daiquiri-lib 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js DELETED
@@ -1,40 +0,0 @@
1
- "use strict";var fs=Object.defineProperty;var ps=(n,t,o)=>t in n?fs(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o;var ne=(n,t,o)=>(ps(n,typeof t!="symbol"?t+"":t,o),o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react-bootstrap"),h=require("react"),P=require("lodash"),ms=require("classnames"),hs=require("lodash/debounce"),gs=require("semver");require("react-bootstrap-typeahead/css/Typeahead.css");require("react-bootstrap-typeahead/css/Typeahead.bs5.css");const Q=require("react-bootstrap-typeahead"),xs=require("@react-hookz/web"),k=require("@vallsv/rc-knob"),L=require("@h5web/lib");require("@h5web/lib/styles.css");const ws=require("js-quantities"),js=require("debug"),pe=require("react-svgmt"),ue=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},ys=ue(h),V=ue(ms),vs=ue(hs),Ns=ue(gs),dt=ue(ws),Ge=ue(js);function De(n){var l;const{hardware:t}=n,{online:o,locked:s=null}=t,r=o?(s!==null?"LOCKED":(l=t.properties)==null?void 0:l.state)||"UNKNOWN":"OFFLINE",c={READY:"success",OFFLINE:"secondary",MOVING:"transient",DISABLED:"secondary",UNKNOWN:"danger",ERROR:"danger",FAILED:"danger",LOCKED:"warning"}[r]||"success";return e.jsx(i.Badge,{bg:c,children:r})}function ut(n){const{hardware:t}=n;return e.jsx(De,{hardware:t})}function ft(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 a(){if(o.overrideName!==void 0)return`Real name: ${s()}`;if(t.alias)return`Real name: ${t.name}`}const c=r(),l=a();return e.jsx("span",{title:l,children:c})}function pt(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 a=t;for(const c of r.split("/"))if(a=a[c],a===void 0)return`property '${r}' not found`;return`${a}`}return e.jsx(e.Fragment,{children:s()})}function bs(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 N(n){const{name:t,icon:o}=n;return e.jsxs("div",{className:"icon",title:t,children:[e.jsx("i",{className:`fa ${o}`}),e.jsx(bs,{...n})]})}function S(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(i.Form.Label,{htmlFor:o.id,children:r})}),n.widgetState,n.hardware.errors&&n.hardware.errors.length>0&&e.jsx(i.OverlayTrigger,{trigger:"click",placement:"bottom",rootClose:!0,overlay:e.jsxs(i.Popover,{id:n.hardware.id,style:{maxWidth:500},children:[e.jsx(i.Popover.Header,{children:"Device Errors"}),e.jsxs(i.Popover.Body,{children:["There were errors with properties on this device:",e.jsx("ul",{children:n.hardware.errors.map(a=>e.jsxs("li",{children:[a.property,":",e.jsxs("span",{className:"stack-trace",children:[a.traceback,e.jsx("br",{}),a.exception]})]}))})]})]}),children:e.jsx(i.Button,{variant:"danger",size:"sm",children:e.jsx("i",{className:"fa fa-exclamation-triangle"})})})]}),e.jsx("div",{className:"hw-content",children:n.widgetContent})]})}}function B(n){const{value:t,variant:o,style:s,className:r,title:a}=n,c=o?`badge-${o} bg-${o} text-bg-${o} border-${o}`:"border-light";return e.jsx(i.Form.Control,{className:`${c} ${r} bg-secondary`,style:s,value:t,title:a,readOnly:!0})}function _s(n){const t=n.online?"READY":"OFFLINE";return e.jsx(i.Badge,{bg:t==="READY"?"success":"warning",children:t})}function mt(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Optic",icon:"fa-cog",online:t.online}),r=e.jsx(_s,{...t});function a(){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(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(B,{value:a()}),l&&e.jsx(i.InputGroup.Text,{children:l})]}),u=n.options.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:f,headerMode:u})}const ee=h.forwardRef(({className:n="",style:t,children:o,...s},r)=>e.jsx(i.Col,{ref:r,...s,className:`monitor-panel-item ${n}`,style:t,children:o}));function ht(n){const{hardware:t,options:o={}}=n,s=o.name??t.alias??t.name??t.id;return e.jsxs(ee,{children:[e.jsx("h1",{children:s}),e.jsx(De,{hardware:t})]})}const Ss={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"},Cs={$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},$s={response:Ss,schema:Cs},gt={default:$s},Os={state:ut,name:ft,info:pt,property:mt,monitor:ht},xt={variants:Os,mocks:gt,monitor:ht};function D(n){const t={display:"inline-block",minWidth:""};return n.minWidth&&(t.minWidth=`${n.minWidth}em`),e.jsx("div",{style:t,children:e.jsx(i.Badge,{bg:n.variant,title:n.description,children:n.state})})}function wt(n){const{states:t,variants:o={},descriptions:s={},minWidth:r}=n,a=t[0]??"";if(t.length===0)return e.jsx(D,{state:"NO_STATE",variant:"fatal",description:"The device no not expose any state",minWidth:r});if(t.length===1)return e.jsx(D,{state:a,variant:o[a]??"fatal",description:s[a],minWidth:r});const c={display:"inline-block",minWidth:r?`${r}em`:""};function l(f){return e.jsx(i.Tooltip,{id:"device-state",...f,children:t.map((u,d)=>{const p=s[u],m=u.startsWith("_")?u.slice(1):u;return e.jsxs(i.Row,{className:"gx-0",children:[e.jsx(i.Col,{sm:"3",className:"text-end",children:e.jsx(i.Badge,{className:"text-right",bg:o[u]??"fatal",children:m})}),e.jsx(i.Col,{sm:"9",className:"text-start lh-1 my-auto ps-1",children:p})]})})})}return e.jsx("div",{style:c,children:e.jsx(i.OverlayTrigger,{placement:"top",delay:{show:250,hide:400},overlay:l,children:e.jsxs("span",{className:"text-nowrap",children:[e.jsx(i.Badge,{className:"rounded-end-0",bg:o[a]??"fatal",children:a}),e.jsxs(i.Badge,{className:"rounded-start-0",bg:"secondary",children:["+",t.length-1]})]})})})}function Te(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={ON:"success",OFF:"danger",MOVING_ON:"transient",MOVING_OFF:"transient",UNKNOWN:"fatal",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(D,{state:o,minWidth:6,variant:r})}function Is(n){const{hardware:t}=n;return e.jsx(Te,{hardware:t})}function Ms(n){var l;const{hardware:t,options:o,disabled:s}=n,r=((l=t.properties)==null?void 0:l.state)??"OFFLINE",a=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(i.ButtonGroup,{className:"mx-auto",style:{width:"12em"},children:[e.jsx(i.Button,{onClick:()=>{t.actions.call("on")},disabled:a||s,style:{width:"5em"},children:e.jsx("span",{className:"text-nowrap",children:"On"})}),e.jsx(i.Button,{onClick:()=>{t.actions.call("off")},disabled:c||s,style:{width:"5em"},children:e.jsx("span",{className:"text-nowrap",children:"Off"})})]})})}function jt(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Air bearing",icon:"fa-hand-point-right",online:t.online}),r=e.jsx(Te,{hardware:t});function a(){return e.jsx(Ms,{...n})}const c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a(),headerMode:c})}function Ze(n){return e.jsx(i.Button,{variant:n.isActive?"primary":n.wasActivated?"warning":"secondary",onClick:n.onClick,disabled:n.disabled||n.wasActivated,title:n.title,children:e.jsxs(i.Row,{className:"gx-0",children:[e.jsx("i",{className:`col-sm-4 justify-content-center align-self-center ${n.icon}`}),e.jsx(i.Col,{sm:"8",children:n.children})]})})}function Ds(n){var d;const{hardware:t,options:o={},disabled:s}=n;function r(){t.actions.call("on")}function a(){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(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary",disabled:s||l}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Actions"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsxs(i.ButtonGroup,{children:[e.jsxs(Ze,{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(Ze,{icon:"fa fa-arrow-down",wasActivated:u,onClick:()=>{a()},disabled:s||l,title:"Turn off the air bearing",children:["Turn",e.jsx("br",{}),"off"]})]})})})]})})]})}function Ts(n){const{hardware:t,options:o,disabled:s}=n,{state:r}=t.properties??"OFFLINE",c={ON:"success",OFF:"danger",MOVING_ON:"transient",MOVING_OFF:"transient",UNKNOWN:"fatal",OFFLINE:"warning"}[r]??"fatal";return e.jsxs(i.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(B,{variant:c,className:"text-center",style:{minWidth:"10em"},value:r}),e.jsx(Ds,{...n})]})}function yt(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Air bearing",icon:"fa-hand-point-right",online:t.online}),r=e.jsx(Te,{hardware:t});function a(){return e.jsx(Ts,{...n})}const c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a(),headerMode:c})}const Fs=["on","off","sync_hard"],Rs="airbearing",As="airbearing",ks=!0,Es={state:"ON"},Ps="bliss",Bs=!1,Gs="airbearing",Hs={callables:Fs,id:Rs,name:As,online:ks,properties:Es,protocol:Ps,require_staff:Bs,type:Gs},vt={default:Hs};async function H(n){await new Promise(t=>{setTimeout(t,n)})}function W(n){const{name:t,alias:o=null,type:s,setProperty:r,call:a,properties:c,useHardwareContext:l=()=>null}=n,f=l(),u=h.useMemo(()=>{var g,j;const m={setProperty:r,call:a};return(j=f==null?void 0:(g=f.actions).updateHardwareChangeActions)==null||j.call(g,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||!P.isEqual(p.current,d))&&(p.current=d,f==null||f.actions.updateHardware(t,d))},[t,d]),e.jsx(e.Fragment,{})}function Nt(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("ON");async function c(u,d){if(u==="on"){a("MOVING_ON"),await H(2e3),a("ON");return}if(u==="off"){a("MOVING_OFF"),await H(2e3),a("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(W,{name:t,alias:o,type:"tomoflatmotion",call:c,setProperty:l,properties:f,useHardwareContext:s})}const Ls={default:jt,protected:yt,state:Is},bt={variants:Ls,mocks:vt,simulator:Nt};function Us(n){const[t,o]=h.useState(),[s,r]=h.useState(),{hardware:a,options:c={}}=n;function l(){const u=a.actions.call("read");return u!==void 0&&(console.log("pending"),u.then(d=>{o(d),r(void 0)}).catch(d=>{r(`${d}`)})),u}function f(u){return a.actions.setProperty("diode_range",u)}return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[a.name," Details"]}),e.jsx(i.Popover.Body,{children:e.jsxs(i.Container,{children:[e.jsxs(i.Row,{children:[e.jsx(i.Col,{sm:6,className:"text-nowrap",children:"Diode Range:"}),e.jsx(i.Col,{children:e.jsx(i.Form.Control,{size:"sm",as:"select",disabled:n.disabled,onChange:u=>{f(u.target.value)},defaultValue:a.properties.diode_range,children:P.map(a.properties.diode_ranges,u=>e.jsx("option",{value:u,children:u},u))})})]}),e.jsxs(i.Row,{children:[e.jsx(i.Col,{sm:6,children:"Current:"}),e.jsxs(i.Col,{children:[s&&e.jsx("i",{className:"fa-solid fa-triangle-exclamation me-1",title:s}),!s&&e.jsx(e.Fragment,{children:t}),e.jsx(i.Button,{size:"sm",disabled:n.disabled,onClick:()=>{l()},children:"Read"})]})]})]})})]}),children:e.jsx(i.Button,{title:"Beamviewer Details",className:"float-end",size:"sm",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function _t(n){const{hardware:t,options:o={}}=n,s=[{name:"Screen",prop:"screen",success:"OUT",toggle:t.properties.screen==="IN",button:t.properties.screen==="IN"?"Out":"In"},{name:"Led",prop:"led",success:"OFF",toggle:t.properties.led==="ON",button:t.properties.led==="ON"?"Off":"On"},{name:"Foil",prop:"foil",success:"OUT",toggle:t.properties.foil==="IN",button:t.properties.foil==="IN"?"Out":"In",test:t.properties.foil!=="NONE"}];function r(a,c){t.actions.call(a,c)}return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(N,{name:"Beamviewer",icon:"fam-hardware-beamviewer",online:t.online}),e.jsx("div",{className:"name me-auto",children:t.name}),e.jsx(Us,{...n})]}),e.jsx("div",{className:"hw-content",children:e.jsx(i.Container,{style:{minWidth:"150px"},children:P.map(s,a=>e.jsx(h.Fragment,{children:(a.test===!0||a.test===void 0)&&e.jsxs(i.Row,{className:"align-items-center mb-1",children:[e.jsx(i.Col,{sm:4,children:a.name}),e.jsx(i.Col,{sm:4,children:e.jsx(i.Badge,{className:"ms-1",bg:t.properties[a.prop]===a.success?"success":"danger",children:t.properties[a.prop]})}),e.jsx(i.Col,{sm:4,children:e.jsx(i.Button,{size:"sm",className:"ms-1",disabled:n.disabled,onClick:c=>r(a.prop,!a.toggle),children:a.button})})]})},a.name))})})]})}const Vs=["foil","current","screen","led"],qs="bv1",Ws="bv1",zs=!0,Ys={diode_range:"1uA",diode_ranges:["1mA","100uA","10uA","1uA","100nA","10nA"],foil:"NONE",led:"OFF",screen:"OUT",state:"ON"},Ks="bliss",Qs=!0,Xs="beamviewer",Zs={callables:Vs,id:qs,name:Ws,online:zs,properties:Ys,protocol:Ks,require_staff:Qs,type:Xs},St={default:Zs},Js=["1mA","100uA","10uA","1uA","100nA","10nA"];function Ct(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("OFF"),[c,l]=h.useState("OUT"),[f,u]=h.useState("NONE"),[d,p]=h.useState("1uA");async function m(x,w){if(x==="read"){const y=Math.random();if(y<.1)throw new Error("Dummy error");return y}return x==="led"?(a(w?"ON":"OFF"),null):x==="screen"?(l(w?"IN":"OUT"),null):x==="foil"?(u(w?"IN":"OUT"),null):(console.log("BeamviewerSimulator: Unsupported call",x,w),null)}async function g(x,w){if(x==="diode_range"){p(w);return}console.log("BeamviewerSimulator: Unsupported setProperty",x,w)}const j={state:"ON",led:r,screen:c,foil:f,diode_range:d,diode_ranges:Js};return console.log(j),e.jsx(W,{name:t,alias:o,type:"optic",call:m,setProperty:g,properties:j,useHardwareContext:s})}const er={default:_t},$t={variants:er,mocks:St,simulator:Ct};function He(n){const{hardware:t}=n,{energy:o=null}=t.properties??{},s=o!==null||Number.isFinite(o)?"VALID":"INVALID",r=t.online?s:"OFFLINE",a={VALID:"success",INVALID:"danger",OFFLINE:"warning"},c=a[r]||a.UNKNOWN;return e.jsx(D,{state:r,minWidth:7,variant:c})}function tr(n){const{hardware:t,disabled:o=!1}=n,{properties:s}=t,{source:r=null,available_source_names:a=[]}=s,c=r==null?void 0:r.slice(9);function l(u){t.actions.setProperty("source",`hardware:${u}`)}function f(u){const p=c===u?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(i.Dropdown.Item,{disabled:o,onClick:()=>{l(u)},title:`Select the source ${u}`,children:[e.jsx("i",{className:p}),"  ",u]},u)}return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:o,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{align:"end",popperConfig:{strategy:"fixed"},children:a.map(u=>f(u))})]})}function Ot(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r={}}=t,{energy:a,unit:c,source:l}=r,f=e.jsx(N,{name:"Energymanager",icon:"fam-hardware-multiposition",online:t.online}),u=e.jsx(He,{hardware:t});function d(j){return j===void 0?"Unknown":j===null?"∅":Number.isFinite(j)?j.toFixed(2):"∅"}const p=h.useMemo(()=>{if(l===void 0)return"Unknown";const j=l.slice(9);return j===""?"No source":j},[l]);function m(){return e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(i.InputGroup.Text,{children:p}),e.jsx(B,{value:d(a)}),!s&&e.jsx(tr,{...n}),c&&e.jsx(i.InputGroup.Text,{children:c})]})}const g=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:f,widgetState:u,widgetContent:m(),headerMode:g})}function It(n){const{hardware:t,options:o={}}=n,{properties:s={}}=t,{source:r,energy:a,unit:c}=s;function l(p,m){return p===void 0||m===void 0?"Unknown":p===null?"∅":Number.isFinite(p)?`${p.toFixed(2)} ${m}`:"∅"}const f=h.useMemo(()=>{if(r===void 0)return"Unknown";const p=r.slice(9);return p===""?"No source":p},[r]),u=l(a,c),d=u!=="∅"?"success":"danger";return e.jsxs(ee,{children:[e.jsx("h1",{children:o.name??f}),e.jsx(i.Badge,{bg:d,children:u})]})}const nr=[],or="energymanager",sr="energymanager",rr=!0,ir={energy:15.2,unit:"keV",available_source_names:["hardware:pink_beam","hardware:dcm"],source:"hardware:pink_beam"},ar="bliss",cr=!1,lr="energymanager",dr={callables:nr,id:or,name:sr,online:rr,properties:ir,protocol:ar,require_staff:cr,type:lr},Mt={default:dr},Je={pink_beam:1.2,dcm:15.6,dcm_off:null};function Dt(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("pink_beam");async function c(d,p){console.log("MultipositionSimulator: Unsupported call",d,p)}async function l(d,p){if(d==="source"){const m=p.slice(9);a(m);return}console.log("EnergyManagerSimulator: Unsupported setProperty",d,p)}const f=h.useMemo(()=>Object.keys(Je).map(d=>d),[]),u={energy:Je[r]??null,unit:"keV",source:`hardware:${r}`,available_source_names:f};return e.jsx(W,{name:t,alias:o,type:"energymanager",call:c,setProperty:l,properties:u,useHardwareContext:s})}const ur={default:Ot,state:He,monitor:It},Tt={variants:ur,mocks:Mt,simulator:Dt,monitor:It};function fr(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)),a=r===0?"":t[r];return{scalar:n*10**-r,prefix:a,multiplier:10**-r}}function pr(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Ft(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 mr(n){return n>0?(662607004e-42*299792458/(n*1e-10)/160218e-24*.001).toFixed(4):0}function hr(n,t){return Number.parseFloat(n.toFixed(t))}const gr=Object.freeze(Object.defineProperty({__proto__:null,formatEng:fr,round:hr,toEnergy:mr,toHoursMins:Ft,ucfirst:pr},Symbol.toStringTag,{value:"Module"}));function xr(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:Ft(t.properties.refill),Message:e.jsx("pre",{children:t.properties.message})};function a(c){if(!(c in t.properties))return"UNKNOWN";const l=t.properties[c];return!l||typeof l!="string"?"UNKNOWN":l}return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("h6",{children:"Interlocks"}),e.jsx(i.Container,{children:P.map(s,(c,l)=>e.jsxs(i.Row,{children:[e.jsxs(i.Col,{children:[l,":"]}),e.jsx(i.Col,{children:e.jsx(i.Badge,{bg:a(c)==="ON"?"success":"danger",children:a(c)})})]},l))}),e.jsx("h6",{children:"Ring Status"}),e.jsx(i.Container,{children:P.map(r,(c,l)=>e.jsxs(i.Row,{children:[e.jsxs(i.Col,{children:[l,":"]}),e.jsx(i.Col,{children:c})]},l))}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(i.Button,{disabled:n.disabled,onClick:o,children:"Reset"})})]})]}),children:e.jsx(i.Button,{className:"flex-grow-0",title:"Shutter Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Rt(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(N,{name:"Frontend",icon:"fam-hardware-frontend",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(i.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(i.ButtonGroup,{className:"d-flex",children:[e.jsx(i.Button,{variant:t.properties.frontend==="FE open"?"danger":"success",onClick:s,disabled:n.disabled,children:t.properties.frontend==="FE open"?"Close":"Open"}),e.jsx(xr,{...n})]})})]})}function wr(n){switch(n){case"OPEN":case"RUNNING":return"success"}return"danger"}function At(n){const{hardware:t,options:o={}}=n,{properties:s={}}=t,{state:r="OFFLINE",status:a}=s,c=o.name??t.alias??t.name,l=wr(r),f=e.jsxs(ee,{children:[e.jsx("h1",{children:c}),e.jsx(i.Badge,{bg:l,children:`${r}`})]});if(a){const u=`${a}`;return e.jsx(i.OverlayTrigger,{placement:"bottom",overlay:e.jsx(i.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:u.includes(`
2
- `)?e.jsx("pre",{children:u}):u}),children:f})}return f}const jr=["open","close","reset"],yr="fe",vr="fe",Nr=!0,br={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
3
- Mode : Beam Delivery
4
- Automatic : Automatic opening active
5
- Type : UHV
6
-
7
- Module 1 Gate Valve 1: Open
8
- Module 1 Gate Valve 2: Open
9
- Module 2 Gate Valve 1: Open
10
-
11
- `},_r="tango",Sr=!0,Cr="frontend",$r={callables:jr,id:yr,name:vr,online:Nr,properties:br,protocol:_r,require_staff:Sr,type:Cr},kt={default:$r},Or={default:Rt,monitor:At},Et={variants:Or,mocks:kt,monitor:At};function Ir(n){const{hardware:t}=n,o=()=>{t.actions.call(t.properties.state==="ON"?"off":"on")};return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.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(i.Button,{disabled:n.disabled,onClick:o,children:t.properties.state==="ON"?"Off":"On"})})]})]}),children:e.jsx(i.Button,{title:"Gauge Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Pt(n){const{hardware:t,options:o={}}=n;return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(N,{name:"Gauge",icon:"fam-hardware-gauge",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(i.Badge,{bg:t.properties.state==="ON"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(i.InputGroup,{children:[e.jsx(i.Form.Control,{value:t.properties.pressure.toExponential(o.precision||3),disabled:!0}),(t.properties.unit||o.unit)&&e.jsx(i.InputGroup.Text,{children:t.properties.unit||o.unit}),e.jsx(Ir,{...n})]})})]})}const Mr=["off","on"],Dr="pir121",Tr="pir121",Fr=!0,Rr={pressure:.0007999999797903001,state:"ON",status:`
12
- Gauge is underrange - Channel B2 (4)
13
- Rel. | Lower | Upper | SA | State
14
- 1 | 1.0e-6| 3.0e-6| 1 | ON
15
- 2 | 4.0e-3| 6.0e-3| 2 | ON
16
- 3 | 1.0e-6| 3.0e-6| 3 | ON
17
- 4 | 4.0e-3| 6.0e-3| 4 | ON
18
- A | 4.0e-3| 1.0e-5| 6 | ON
19
- B | 4.0e-3| 1.0e-5| 8 | ON
20
-
21
- HDB Storage OK`},Ar="tango",kr=!0,Er="gauge",Pr={callables:Mr,id:Dr,name:Tr,online:Fr,properties:Rr,protocol:Ar,require_staff:kr,type:Er},Br=["off","on"],Gr="pen121",Hr="pen121",Lr=!0,Ur={pressure:13999999737279722e-23,state:"ON",status:`Gauge is ON - Channel B1 (3)
22
- Rel. | Lower | Upper | SA | State
23
- 1 | 1.0e-6| 3.0e-6| 1 | ON
24
- 2 | 4.0e-3| 6.0e-3| 2 | ON
25
- 3 | 1.0e-6| 3.0e-6| 3 | ON
26
- 4 | 4.0e-3| 6.0e-3| 4 | ON
27
- A | 4.0e-3| 1.0e-5| 6 | ON
28
- B | 4.0e-3| 1.0e-5| 8 | ON
29
- `},Vr="tango",qr=!0,Wr="gauge",zr={callables:Br,id:Gr,name:Hr,online:Lr,properties:Ur,protocol:Vr,require_staff:qr,type:Wr},Bt={default:Pr,default2:zr},Yr={default:Pt},Gt={variants:Yr,mocks:Bt},Kr=h.forwardRef((n,t)=>{const o=h.useRef(null),s=h.useRef(),[r,a]=h.useState(n.step),[c,l]=h.useState(!1),f=O=>{const Y=t;if(o.current===null)return;let te=Number.parseFloat(Y.current.value);if(o.current.value.startsWith("*")){const K=Number.parseFloat(o.current.value.replace("*",""));te=O?te*K:te/K}else{const K=Number.parseFloat(o.current.value);te+=O?K:-K}Y.current.value=`${te}`,n.onStep&&n.onStep({target:Y.current})},{onStep:u,step:d,overlay:p,incIcon:m,decIcon:g,swapIncDec:j,onKeyDown:x,onBlur:w,horizontalArrows:y,largeArrows:_,disabled:$,stepOnly:b,...v}=n,C=O=>{O.key==="ArrowUp"?(O.preventDefault(),l(!0),f(!0)):O.key==="ArrowDown"?(O.preventDefault(),l(!0),f(!1)):x&&x(O)};c&&(s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{var O;(O=t==null?void 0:t.current)==null||O.focus()},100)),h.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const I=()=>{s.current&&clearTimeout(s.current),l(!1),w&&w()};if(!n.step)return e.jsx(i.Form.Control,{ref:t,type:"number",step:"any",onKeyDown:C,onBlur:I,disabled:$,onClick:O=>{O.stopPropagation()},...v});const M=P.map(n.steps||[n.step],O=>e.jsx("option",{value:O,children:O},O)),E=m||g;return e.jsx("div",{className:V.default("numeric-step",{"numeric-step-large":_,"numeric-step-horizontal":y}),children:e.jsxs(i.InputGroup,{children:[e.jsx(i.Form.Control,{onKeyDown:C,onBlur:I,ref:t,type:"number",step:"any",disabled:$||b,...v}),e.jsxs(e.Fragment,{children:[p,!p&&e.jsxs(i.InputGroup.Text,{className:`d-flex flex-column ${E?"inc-dec":""}`,children:[e.jsx(i.Form.Control,{ref:o,as:"select",className:"step-size",defaultValue:r,disabled:$,onChange:O=>a(Number.parseFloat(O.target.value)),children:M}),n.unit&&e.jsx("div",{children:n.unit}),!m&&!g&&e.jsxs(e.Fragment,{children:[e.jsx(i.Button,{className:"step step-up",disabled:n.disabled,onClick:O=>f(!0)}),e.jsx(i.Button,{className:"step step-down",disabled:n.disabled,onClick:O=>f(!1)})]})]}),g&&j&&e.jsx(i.Button,{disabled:n.disabled,onClick:O=>f(!1),children:e.jsx("i",{className:`fa fa-fw fa-${g}`})}),m&&e.jsx(i.Button,{disabled:n.disabled,onClick:O=>f(!0),children:e.jsx("i",{className:`fa fa-fw fa-${m}`})}),g&&!j&&e.jsx(i.Button,{disabled:n.disabled,onClick:O=>f(!1),children:e.jsx("i",{className:`fa fa-fw fa-${g}`})})]})]})})}),Ht=Kr;function ge(n){const t=h.useRef(null),[o,s]=h.useState(!1),[r,a]=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(()=>{a(!0),setTimeout(()=>{c(n.hardwareValue),a(!1)},2e3)})}function d(p){switch(p.key){case"Enter":{s(!1);const m=Number.parseFloat(p.target.value),g=n.onMoveRequested(m);g&&g.catch(()=>{a(!0),setTimeout(()=>{c(n.hardwareValue),a(!1)},2e3)})}p.preventDefault(),p.stopPropagation();break;case"Esc":case"Escape":o&&(a(!1),s(!1),c(n.hardwareValue)),p.target.blur(),p.preventDefault(),p.stopPropagation();break}}return e.jsx(Ht,{id:n.id,className:V.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(i.Button,{variant:"danger",onClick:n.onAbortRequested,children:e.jsx("i",{className:"fa fa-times"})}):null})}function Lt(n){const{hardware:t,options:o={},disabled:s}=n;function r(u){return t.actions.setProperty("power",u)}function a(u){return t.actions.call(u?"on":"off")}const c=t.properties.state,l=e.jsx(N,{name:"Laser",icon:"fam-hardware-laser",online:t.online}),f=e.jsx(D,{state:c,minWidth:6,variant:c==="ON"?"success":"warning"});return e.jsx(S,{hardware:t,widgetIcon:l,widgetState:f,widgetContent:e.jsxs(i.InputGroup,{children:[e.jsx(ge,{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(i.Button,{size:"sm",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>{a(t.properties.state!=="ON")},children:e.jsx("i",{className:t.properties.state==="ON"?"fa fa-toggle-on":"fa fa-toggle-off"})})]})})}const Qr=[],Xr="yag1",Zr="yag1",Jr=!0,ei={power:5,state:"ON"},ti="bliss",ni=!1,oi="laser",si={callables:Qr,id:Xr,name:Zr,online:Jr,properties:ei,protocol:ti,require_staff:ni,type:oi},Ut={default:si},ri={default:Lt},Vt={variants:ri,mocks:Ut};function ii(n){var o;const{hardware:t}=n;return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"laserheating_overlay",children:[e.jsxs(i.Popover.Header,{children:[t.name," details"]}),e.jsx(i.Popover.Body,{children:e.jsxs(i.Container,{children:[e.jsxs(i.Row,{children:[e.jsx(i.Col,{children:"Background Mode"}),e.jsx(i.Col,{children:t.properties.background_mode})]}),e.jsxs(i.Row,{children:[e.jsx(i.Col,{children:"Calibration"}),e.jsx(i.Col,{children:t.properties.current_calibration})]}),e.jsxs(i.Row,{children:[e.jsx(i.Col,{children:"Fit Wavelength"}),e.jsxs(i.Col,{children:[(o=t.properties.fit_wavelength)==null?void 0:o.join(" - ")," ",e.jsx("span",{children:"nm"})]})]})]})})]}),children:e.jsx(i.Button,{children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function qt(n){const{hardware:t,options:o={},disabled:s}=n,[r,a]=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(){a(!0);const p=t.actions.call("measure");return p!==void 0&&(console.log("pending"),p.then(()=>{a(!1)}).catch(m=>{a(!1)})),p}const f=t.properties.state,u=e.jsx(N,{name:"Laser Heating",icon:"fa-fire",online:t.online}),d=e.jsx(D,{state:f,minWidth:6,variant:f==="READY"?"success":"warning"});return e.jsx(S,{hardware:t,widgetIcon:u,widgetState:d,widgetContent:e.jsxs(i.InputGroup,{children:[e.jsx(ge,{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(i.InputGroup.Text,{children:"s"}),e.jsx(i.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(ii,{hardware:t,disabled:n.disabled})]})})}const ai=[],ci="laserheating",li="laserheating",di=!0,ui={exposure_time:.5,state:"ON",background_mode:"READY",fit_wavelength:[500,650],current_calibration:"/path/to/file"},fi="bliss",pi=!1,mi="laserheating",hi={callables:ai,id:ci,name:li,online:di,properties:ui,protocol:fi,require_staff:pi,type:mi},Wt={default:hi},gi={default:qt},zt={variants:gi,mocks:Wt};function Yt(n){const t=h.useRef(null),{hardware:o,options:s={}}=n;function r(c){o.actions.setProperty("intensity",c)}const a=h.useCallback(vs.default(r,100),[]);return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(N,{name:"Light",icon:"fa-lightbulb-o",online:o.online}),e.jsx("div",{className:"name",children:o.name}),e.jsx(i.Badge,{bg:o.properties.state==="ON"?"success":"danger",children:o.properties.state})]}),e.jsxs("div",{className:"hw-content",children:[e.jsx(i.Form.Control,{ref:t,disabled:n.disabled,type:"range",min:"0",max:"100",onChange:c=>a(Number.parseFloat(c.target.value)),defaultValue:o.properties.intensity}),e.jsxs("div",{children:[e.jsx(i.Button,{disabled:o.properties.intensity===0,size:"sm",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>a(0),children:e.jsx("i",{className:"fa fa-power-off"})}),e.jsxs("span",{className:"float-end",children:[o.properties.intensity," %"]})]})]})]})}const xi=[],wi="light_vlm",ji="light_vlm",yi=!0,vi={intensity:0,state:"ON",temperature:23.2},Ni="bliss",bi=!1,_i="light",Si={callables:xi,id:wi,name:ji,online:yi,properties:vi,protocol:Ni,require_staff:bi,type:_i},Kt={default:Si},Ci={default:Yt},Qt={variants:Ci,mocks:Kt};function X(n){const{hardware:t}=n,{online:o,locked:s=null}=t,r=t.properties.state??"UNKNOWN",a=o?(r==="ACQUIRING"?r:s!==null?"LOCKED":r)||"UNKNOWN":"OFFLINE",c={UNKNOWN:"critical",ACQUIRING:"transient",READY:"success",OFFLINE:"secondary",LOCKED:"warning"},l=c[a]??c.UNKNOWN;return e.jsx(D,{state:a,minWidth:6,variant:l})}function $i(n){const{hardware:t}=n;return e.jsx(X,{hardware:t})}function et(n){const{hardware:t,options:o={}}=n;return e.jsx(i.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:e.jsx("div",{children:t.name})})}function Xt(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(X,{hardware:t}),a=o.header||"top";return a==="none"?e.jsx(et,{...n}):e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:e.jsx(et,{...n}),headerMode:a})}function tt(n){const{hardware:t,options:o={}}=n,[s,r]=t.properties.size??["?","?"];return e.jsxs(i.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 Zt(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(X,{hardware:t}),a=o.header??"top";return a==="none"?e.jsx(tt,{...n}):e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:e.jsx(tt,{...n}),headerMode:a})}function Z(n){const[t,o]=h.useState(!1);return e.jsxs(i.Button,{variant:n.isActive?"primary":t?"warning":"secondary",onClick:()=>{o(!0),n.onAction().finally(()=>{o(!1)})},disabled:n.disabled||t,title:n.title,className:"text-nowrap",children:[n.icon&&e.jsx("i",{className:`col-sm-4 justify-content-center align-self-center ${n.icon}`}),n.children]})}function Oi(n){const{hardware:t,options:o={},disabled:s}=n,{actions:r,properties:a}=t,{rotation:c,flip:[l,f]}=a;return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary",disabled:s}),e.jsx(i.Dropdown.Menu,{align:"end",popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Rotation"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsxs(i.ButtonGroup,{children:[e.jsx(Z,{isActive:c===0,onAction:()=>r.setProperty("rotation",0),disabled:s,title:"Disable rotation transformation",children:"None"}),e.jsxs(Z,{isActive:c===90,onAction:()=>r.setProperty("rotation",90),disabled:s,title:"Disable rotation transformation",children:["90 ",e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]}),e.jsxs(Z,{isActive:c===180,onAction:()=>r.setProperty("rotation",180),disabled:s,title:"Disable rotation transformation",children:["180 ",e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]}),e.jsxs(Z,{isActive:c===270,onAction:()=>r.setProperty("rotation",270),disabled:s,title:"Disable rotation transformation",children:["270 ",e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]})]})})}),e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Flip"})}),e.jsxs(i.Row,{className:"gx-0",children:[e.jsx(i.Col,{xs:6,children:e.jsxs(i.ButtonGroup,{children:[e.jsxs(Z,{isActive:l,onAction:()=>r.setProperty("flip",[!0,f]),disabled:s,title:"Enable horizontal flip transformation",children:["Horiz ",e.jsx("i",{className:"fa fa-fw fa-left-right"})]}),e.jsx(Z,{isActive:!l,onAction:()=>r.setProperty("flip",[!1,f]),disabled:s,title:"Disable horizontal flip transformation",children:"No"})]})}),e.jsx(i.Col,{xs:6,children:e.jsxs(i.ButtonGroup,{children:[e.jsxs(Z,{isActive:f,onAction:()=>r.setProperty("flip",[l,!0]),disabled:s,title:"Enable vertical flip transformation",children:["Vert ",e.jsx("i",{className:"fa fa-fw fa-up-down"})]}),e.jsx(Z,{isActive:!f,onAction:()=>r.setProperty("flip",[l,!1]),disabled:s,title:"Disable vertical flip transformation",children:"No"})]})})]})]})})]})}function Ii(n){const{hardware:t,options:o={}}=n,{properties:s}=t,[r,a]=s.flip,c=s.rotation??0,l=!r&&!a&&c===0;return e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsxs(i.InputGroup.Text,{children:[r&&e.jsxs(i.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Flip",e.jsx("i",{className:"fa fa-fw fa-left-right"})]}),a&&e.jsxs(i.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Flip",e.jsx("i",{className:"fa fa-fw fa-up-down"})]}),c!==0&&e.jsxs(i.Badge,{style:{fontSize:"130%"},className:"me-1",children:["Rot ",c.toFixed(0),e.jsx("i",{className:"fa fa-fw fa-arrow-rotate-right"})]}),l&&e.jsx(i.Badge,{bg:"secondary",style:{fontSize:"130%"},title:"No transformation",children:"None"})]}),!o.readonly&&e.jsx(Oi,{...n})]})}function Jt(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(X,{hardware:t}),a=e.jsx(e.Fragment,{children:e.jsx(Ii,{...n})}),c=o.header??"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const en="4.2em";function Mi(n){const{hardware:t}=n,{properties:o}=t,s=o.state==="READY",r=n.disabled||!t.online||!s,a=o.binning_mode??"SUM";function c(l){const{binningMode:f,selectedMode:u,title:d}=l,m=f===u?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(i.Dropdown.Item,{disabled:r,onClick:()=>{t.actions.setProperty("binning_mode",f)},title:d,children:[e.jsx("i",{className:m})," "," ",e.jsx(i.Badge,{style:{minWidth:en},children:f})]},f)}return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:r,variant:"secondary"}),e.jsxs(i.Dropdown.Menu,{align:"end",popperConfig:{strategy:"fixed"},children:[e.jsx(c,{binningMode:"SUM",selectedMode:a,title:"Merge binned pixel with SUM operation"}),e.jsx(c,{binningMode:"MEAN",selectedMode:a,title:"Merge binned pixel with MEAN operation"})]})]})}function Di(n){const{hardware:t,options:o,disabled:s}=n,{properties:r={}}=t,{binning:a,binning_mode:c="SUM"}=r;function l(g){t.actions.setProperty("binning",[g,g])}const f=Oa(t),u=o.readonly??!1;if(a===void 0)return e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(i.InputGroup.Text,{title:"Binning applied to the detector",children:e.jsx("i",{className:"fa fa-fw fam-binning-2d fa-2x"})}),e.jsx(B,{value:"? × ?"})]});const[d,p]=a??[0,0],m=d===p?d:0;return e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(i.InputGroup.Text,{title:"Binning applied to the detector",children:e.jsx("i",{className:"fa fa-fw fam-binning-2d fa-2x"})}),e.jsx(B,{value:`${a[0]} × ${a[1]}`}),!u&&e.jsxs(e.Fragment,{children:[e.jsx(i.Button,{variant:m===1?"primary":"secondary",onClick:()=>{l(1)},disabled:s,children:"1"}),e.jsx(i.Button,{variant:m===2?"primary":"secondary",onClick:()=>{l(2)},disabled:s,children:"2"}),e.jsx(i.Button,{variant:m===3?"primary":"secondary",onClick:()=>{l(3)},disabled:s,children:"3"}),e.jsx(i.Button,{variant:m===4?"primary":"secondary",onClick:()=>{l(4)},disabled:s,children:"4"})]}),e.jsx(i.InputGroup.Text,{title:"Binning applied to the detector",children:e.jsx(i.Badge,{style:{fontSize:"130%",minWidth:en},title:`Detector setup with binning ${c}`,children:c})}),!u&&f&&e.jsx(Mi,{...n})]})}function tn(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(X,{hardware:t}),a=e.jsx(e.Fragment,{children:e.jsx(Di,{...n})}),c=o.header??"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Ti(n){const{hardware:t}=n,{properties:o}=t;return e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(i.InputGroup.Text,{title:"Rotation applied to the detector",children:e.jsx("i",{className:"fa fa-fw fa-crop-simple fa-2x"})}),e.jsx(i.Form.Control,{value:`${o.roi[0]}`,readOnly:!0}),e.jsx(i.Form.Control,{value:`${o.roi[1]}`,readOnly:!0}),e.jsx(i.Form.Control,{value:`${o.roi[2]}`,readOnly:!0}),e.jsx(i.Form.Control,{value:`${o.roi[3]}`,readOnly:!0}),e.jsx(i.InputGroup.Text,{children:"px"})]})}function nn(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(X,{hardware:t}),a=e.jsx(e.Fragment,{children:e.jsx(Ti,{hardware:t})}),c=o.header??"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Fi(n){const{hardware:t}=n,{properties:o}=t,s=o.static,[r,a]=(s==null?void 0:s.image_max_dim)??["?","?"];return e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{title:"Max size of the detector",children:"Max size"}),e.jsx(i.Form.Control,{value:`${r} × ${a}`,readOnly:!0}),e.jsx(i.InputGroup.Text,{children:"px"})]})}function Ri(n){const{hardware:t}=n,{properties:o}=t,s=o.static;return e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{title:"Version of the Lima server (lima-core)",children:"Lima version"}),e.jsx(i.Form.Control,{value:`${s==null?void 0:s.lima_version}`,readOnly:!0})]})}function Ai(n){const{hardware:t}=n,{properties:o}=t,s=o.static;return e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{title:"Model of the detector",children:"Type/model"}),e.jsx(i.Form.Control,{value:`${s==null?void 0:s.camera_type}`,readOnly:!0}),e.jsx(i.Form.Control,{value:`${s==null?void 0:s.camera_model}`,readOnly:!0})]})}function on(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(X,{hardware:t}),a=e.jsxs(e.Fragment,{children:[e.jsx(Ai,{hardware:t}),e.jsx(Fi,{hardware:t}),e.jsx(Ri,{hardware:t})]}),c=o.header??"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function ki(n){var v;const{hardware:t,disabled:o}=n,{properties:s}=t,r=((v=s.static)==null?void 0:v.image_max_dim)??[0,0],a=s.roi,c=s.binning??[1,1],l=r[0]/c[0],f=r[1]/c[1];function u(){return f>l?1/f:1/l}const d=u(),[p,m]=[100*l*d,100*f*d];function g(){const[C,I,M,E]=a;return[100*C/l,100*I/f,100*M/l,100*E/f]}function j(){const[C,I,M,E]=a;return[100*(C+M*.5)/l,100*(I+E*.5)/f]}const[x,w,y,_]=g(),[$,b]=j();return e.jsx("div",{style:{backgroundColor:"#AAAAAA",width:"10em",height:"10em"},children:e.jsxs("div",{className:"position-relative",title:`Detector ${t.id}`,style:{backgroundColor:"#FFFFFF",border:"2px solid black",width:`${p}%`,height:`${m}%`},children:[e.jsx("div",{title:"ROI location",className:"position-absolute",style:{backgroundColor:"#FFFFFF",border:"2px dotted black",left:`${x}%`,top:`${w}%`,width:`${y}%`,height:`${_}%`}}),e.jsxs("span",{className:"position-absolute",style:{left:`${$}%`,top:`${b}%`,transform:"translate(-50%, -50%)"},children:[a[2],"×",a[3]]})]})})}function sn(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Lima",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(X,{hardware:t}),a=e.jsx(e.Fragment,{children:e.jsx(ki,{...n})}),c=o.header??"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const F={};function Ei(n){n.useHardware&&(F.useHardware&&console.warn("useHardware hook was already registered"),F.useHardware=n.useHardware),n.useHardwareChangeActions&&(F.useHardwareChangeActions&&console.warn("useHardwareChangeActions hook was already registered"),F.useHardwareChangeActions=n.useHardwareChangeActions),n.useHardwareSchema&&(F.useHardwareSchema&&console.warn("useHardwareSchema hook was already registered"),F.useHardwareSchema=n.useHardwareSchema),n.useOperator&&(F.useOperator&&console.warn("useOperator hook was already registered"),F.useOperator=n.useOperator),n.useScanRunning&&(F.useScanRunning&&console.warn("useScanRunning hook was already registered"),F.useScanRunning=n.useScanRunning)}function G(n){if(!F.useHardware)throw new Error("No `useHardware` hook registered");return F.useHardware(n)}function oe(n){if(!F.useHardwareChangeActions)throw new Error("No `useHardwareChangeActions` hook registered");return F.useHardwareChangeActions(n)}function Pi(n){if(!F.useHardwareSchema)throw new Error("No `useHardwareSchema` hook registered");return F.useHardwareSchema(n)}function Bi(){if(!F.useOperator)throw new Error("No `useOperator` hook registered");return F.useOperator()}function Gi(){if(!F.useScanRunning)throw new Error("No `useScanRunning` hook registered");return F.useScanRunning()}const Hi="lima_cam",Li="lima_cam",Ui="bliss",Vi="lima",qi=!0,Wi=!1,zi={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],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:0,size:[128,128],state:"READY"},Yi={id:Hi,name:Li,protocol:Ui,type:Vi,online:qi,require_staff:Wi,properties:zi},Ki="lima_cam",Qi="lima_cam",Xi="bliss",Zi="lima",Ji=!0,ea=!1,ta={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],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:0,size:[128,128],state:"READY"},na={id:Ki,name:Qi,protocol:Xi,type:Zi,online:Ji,require_staff:ea,properties:ta},oa="lima_cam",sa="lima_cam",ra="bliss",ia="lima",aa=!0,ca=!1,la={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],pixel_size:[1e3,1e3],raw_roi:[0,0,128,128],roi:[0,0,128,128],rotation:180,size:[128,128],state:"READY"},da={id:oa,name:sa,protocol:ra,type:ia,online:aa,require_staff:ca,properties:la},ua="lima_cam",fa="lima_cam",pa="bliss",ma="lima",ha=!0,ga=!1,xa={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],pixel_size:[1e3,1e3],raw_roi:[0,710,1920,500],roi:[0,710,1920,500],rotation:0,size:[1920,1920],state:"READY"},wa={id:ua,name:fa,protocol:pa,type:ma,online:ha,require_staff:ga,properties:xa},ja="lima_cam",ya="lima_cam",va="bliss",Na="lima",ba=!0,_a=!1,Sa={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:[5e3,2e3]},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],pixel_size:[1e3,1e3],raw_roi:[0,0,5e3,2e3],roi:[0,0,5e3,2e3],rotation:0,size:[5e3,2e3],state:"READY"},Ca={id:ja,name:ya,protocol:va,type:Na,online:ba,require_staff:_a,properties:Sa},rn={default:Yi,flip:na,rot:da,roicenter:wa,squaredetector:Ca};function an(n){const{name:t,alias:o,useHardwareContext:s}=n,r=[1920,1920],a=[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:a,image_max_dim:r},acc_max_expo_time:1,binning:[1,1],flip:[!1,!1],pixel_size:a,raw_roi:[0,0,...r],roi:[0,0,...r],rotation:0,size:r,state:"READY"});async function f(x,w){console.log("LimaSimulator: Unsupported call",x,w)}function u(x,w){const y=[Math.round(a[0]*w[0]),Math.round(a[1]*w[1])],_=[Math.round(r[0]/w[0]),Math.round(r[1]/w[1])];return{...x,binning:w,pixel_size:y,roi:[0,0,..._],size:_}}function d(x,w){return{...x,binning_mode:w}}function p(x,w){return{...x,rotation:w}}function m(x,w){return{...x,flip:[w,x.flip[1]]}}function g(x,w){return{...x,flip:[x.flip[0],w]}}async function j(x,w){if(x==="binning"){l(y=>u(y,w));return}if(x==="binning_mode"){l(y=>d(y,w));return}if(x==="rotation"){l(y=>p(y,w));return}if(x==="flip_x"){l(y=>m(y,w));return}if(x==="flip_y"){l(y=>g(y,w));return}console.log("LimaSimulator: Unsupported setProperty",x,w)}return e.jsx(W,{name:t,alias:o,type:"lima",call:f,setProperty:j,properties:c,useHardwareContext:s})}function xe(n){return n.type==="lima"}function cn(n){const t=G(n);return t===null||!xe(t)?null:t}function ln(n,t){const o=Math.ceil(n/t),s=n/o;return[o,s]}const $a={default:Xt,size:Zt,transformation:Jt,binning:tn,imageroi:nn,description:on,shape:sn,state:$i},dn={variants:$a,mocks:rn,simulator:an};function Oa(n){var t;return n.properties.binning_mode!==void 0&&Ns.default.gte(((t=n.properties.static)==null?void 0:t.lima_version)??"0.0.0","1.10.4")}function Ia(n,t){const{inputRef:o,referenceElementRef:s,onAddSelection:r,onRemoveSelection:a,...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];a&&a(p).then(()=>{f()})};return e.jsxs(i.InputGroup,{children:[e.jsx(Q.Hint,{children:e.jsx(i.Form.Control,{style:{width:"100%"},...c,ref:p=>{l.current=p,o(p),s(p)},placeholder:`${t.selected.length} enabled`})}),e.jsx(i.Button,{disabled:n.disabled||t.results.length===0,onClick:u,children:e.jsx("i",{className:"fa fa-plus"})}),e.jsx(i.Button,{disabled:n.disabled,onClick:d,children:e.jsx("i",{className:"fa fa-minus"})})]})}function Ma(n){return function(t){function o(s,r,a){return t(s,r,a,n)}return o.displayName=`WithExtraProps(${t.displayName||t.name||"Component"})`,o}}function Da(n,t,o,s){const a=[...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(Q.Highlighter,{search:o.text,children:f})},f)),l=[...o.results].sort().map((f,u)=>e.jsx(Q.MenuItem,{option:f,position:u,children:e.jsx(Q.Highlighter,{search:o.text,children:f})},f));return e.jsxs(Q.Menu,{...t,style:{...t.style,width:350},children:[s.pending&&e.jsx(Q.Menu.Header,{children:"Loading..."}),!s.pending&&e.jsxs(e.Fragment,{children:[e.jsx(Q.Menu.Header,{children:"Enabled"}),a,a.length===0&&e.jsx("span",{className:"dropdown-item disabled",children:"No items enabled"}),e.jsx(Q.Menu.Header,{children:"Available"}),l,l.length===0&&e.jsx("span",{className:"dropdown-item disabled",children:"No items available"})]})]})}function Ta(n){const{hardware:t,disabled:o=!1}=n,{online:s}=t;if(!s)return e.jsx(i.Alert,{children:"Offline"});const r=t.properties.available.filter(f=>!t.properties.disabled.includes(f));function a(f){const u=f.filter(p=>!r.includes(p)),d=r.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 c(f){const u=[];return f.forEach(d=>{const p=t.actions.call("enable",d);u.push(p)}),Promise.all(u)}function l(f){const u=[];return f.forEach(d=>{const p=t.actions.call("disable",d);u.push(p)}),Promise.all(u)}return e.jsx(Q.Typeahead,{disabled:o,id:`typeahead_mg_${t.name}`,multiple:!0,flip:!0,positionFixed:!0,renderInput:Ia,renderMenu:Ma({name:t.id})(Da),onChange:a,inputProps:{onAddSelection:c,onRemoveSelection:l},selected:r,options:t.properties.available,selectHint:(f,u)=>u.key==="Enter"||f})}function un(n){const{hardware:t,options:o={},disabled:s=!1}=n;function r(){return t.actions.call("set_active")}const a=o.header??"top",c=e.jsx(N,{name:"Measurement Group",icon:"fa-list-ol",online:!0}),l=e.jsx(e.Fragment,{children:e.jsx(i.OverlayTrigger,{placement:"top",overlay:e.jsx(i.Tooltip,{id:"active",children:"Activate this measurement group"}),children:e.jsx(i.Button,{size:"sm",disabled:s,onClick:()=>void r(),className:"float-right ml-1",children:e.jsx("i",{className:"fa fa-power-off"})})})}),f=e.jsx(Ta,{...n});return e.jsx(S,{hardware:t,widgetIcon:c,widgetState:l,widgetContent:f,headerMode:a})}const Fa=[],Ra="mg",Aa="mg",ka=!0,Ea={available:["lima:image","diode1","diode2","machinfo:current","machinfo:srcurrent"],disabled:["machinfo:current"]},Pa="bliss",Ba=!1,Ga="measurementgroup",Ha={callables:Fa,id:Ra,name:Aa,online:ka,properties:Ea,protocol:Pa,require_staff:Ba,type:Ga},fn={default:Ha};function pn(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState({available:["lima:image","diode1","diode2","machinfo:current","machinfo:srcurrent"],disabled:["machinfo:current"]});async function c(d){a(p=>{const{disabled:m}=p;return{...p,disabled:m.filter(g=>g!==d)}})}async function l(d){a(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(W,{name:t,alias:o,type:"measurementgroup",call:f,setProperty:u,properties:r,useHardwareContext:s})}const La={default:un},mn={variants:La,mocks:fn,simulator:pn},ke={description:"Unknown state is exposed",variant:"fatal",priority:100},_e={OFFLINE:{description:"Axis is offline",variant:"secondary",priority:0},MOVING:{description:"Axis is moving",variant:"transient",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:ke};function we(n){const{hardware:t}=n,{locked:o=null}=t,{state:s=["UNKNOWN"]}=t.properties,[r,a]=h.useMemo(()=>{if(!t.online)return[["OFFLINE"],void 0];function c(p,m){const g=_e[p]??ke,j=_e[m]??ke;return g.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==null?void 0:o.reason)??" an object"}`:u[p]=_e[p].description??"",p}),u]},[s,t.online,o]);return e.jsx(wt,{states:r,descriptions:a,minWidth:6,variants:Object.fromEntries(Object.entries(_e).map(([c,l])=>[c,l.variant]))})}function Ua(n){const{hardware:t}=n;return e.jsx(we,{hardware:t})}function me(n){const t=h.useRef(null),[o,s]=h.useState(!1),[r,a]=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(()=>{a(!0),setTimeout(()=>{l(n.hardwareValue),a(!1)},2e3)}),d.preventDefault(),d.stopPropagation();break}case"Esc":case"Escape":o&&(a(!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(i.Form.Control,{className:V.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 Va(n){const{states:t,hardware:o}=n,{properties:s}=o;function r(c){return o.actions.setProperty("velocity",c)}function a(c){return o.actions.setProperty("acceleration",c)}return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[o.name," details"]}),e.jsxs(i.Popover.Body,{children:[e.jsxs(i.Form.Group,{children:[e.jsx(i.Form.Label,{children:"Velocity"}),e.jsx(me,{hardwareValue:(s==null?void 0:s.velocity)??0,onMoveRequested:r,hardwareIsDisabled:n.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:n.readOnly})]}),e.jsxs(i.Form.Group,{children:[e.jsx(i.Form.Label,{children:"Acceleration"}),e.jsx(me,{hardwareValue:(s==null?void 0:s.acceleration)??0,onMoveRequested:a,hardwareIsDisabled:n.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:n.readOnly})]})]})]}),children:e.jsx(i.Button,{children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function ce(n){const{hardware:t,options:o={}}=n,{properties:s,user_tags:r}=t;function a(){t.actions.call("stop")}function c(p){return t.actions.call("move",p)}const l=je(s.state,r),f=e.jsx(N,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),u=e.jsx(we,{hardware:t}),d=n.options?n.options.header:"top";return e.jsx(S,{hardware:t,widgetIcon:f,widgetState:u,widgetContent:e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(ge,{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:a,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(i.InputGroup.Text,{children:s.unit}),!l.MOVING&&o.extended&&e.jsx(Va,{hardware:t,disabled:n.disabled,readOnly:o.readOnly,states:l}),l.MOVING&&!n.disabled&&!o.step&&e.jsx(i.Button,{variant:"danger",onClick:a,children:e.jsx("i",{className:"fa fa-times"})})]}),headerMode:d})}function nt(n){const{hardware:t,options:o={}}=n,s=je(t.properties.state,t.user_tags);function r(a){if(a===null)return"∅";const c=o.precision??t.properties.display_digits??void 0;return c!==void 0?a.toFixed(c):`${a}`}return e.jsxs(i.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"horizontal",children:[e.jsx("div",{className:V.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 hn(n){const{hardware:t}=n,o=e.jsx(N,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),s=e.jsx(we,{hardware:t}),r=n.options?n.options.header:"top";return r==="none"?e.jsx(nt,{...n}):e.jsx(S,{hardware:t,widgetIcon:o,widgetState:s,widgetContent:e.jsx(nt,{...n}),headerMode:r})}const A={background:"hsl(0 0% 98%)",backgroundD10:"hsl(0 0% 88%)",disabled0:"hsl(0, 0%, 93%)",disabledD10:"hsl(0, 0%, 83%)",danger:"rgb(220, 53, 69)",edited:"hsl(45, 100%, 71.4%)",transient:"#4285eb",text:"black",textD10:"black"},qa={up:0,right:-90,down:180,left:90};function gn(n){const{size:t,value:o=null,target:s=null,min:r=null,max:a=null,disabled:c=!1,readOnly:l=!1,origin:f="up",direction:u="clockwise",onChange:d=z=>{},onInteractiveChange:p=null,className:m}=n,[g,j]=h.useState(null);function x(){j(null)}function w(z){j(z),p&&p(z)}const y=8,_=5,$=12,b=t*.5,v=b-_-y,C=4,I=v-$-C/2,M=!c&&!l,E=5,O=g!==null?g:s;function Y(z){return z.mouseRadius<v/3?{readOnly:!0}:z.ctrlKey?{steps:8}:b-y-_<=z.mouseRadius&&z.mouseRadius<=b+_?{steps:8}:{}}function te(){if(o===null||r===null||a===null)return null;const z=a-r;return z>=360?null:[(a-360)/360,(a-360+360-z)/360]}const K=te(),ds=u==="clockwise"?360:-360,us=qa[f]+(u==="clockwise"?0:360);return e.jsxs(k.Knob,{size:t,value:o,angleOffset:us,angleRange:ds,min:0,max:360,multiRotation:!0,onChange:d,onInteractiveChange:w,interactiveHook:Y,onEnd:x,readOnly:!M,tracking:!1,useMouseWheel:!1,className:m,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"knob-shadow",cx:t/2,cy:t/2,fx:t*.75,fy:t*.75,r:v+E,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:v/(v+E),stopColor:A.backgroundD10,stopOpacity:"0.1"}),e.jsx("stop",{offset:1,stopColor:A.backgroundD10,stopOpacity:"0"})]}),e.jsxs("linearGradient",{id:"knob-enabled",x1:0,y1:t/2-v,x2:0,y2:t/2+v,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0%",stopColor:A.backgroundD10}),e.jsx("stop",{offset:"30%",stopColor:A.background}),e.jsx("stop",{offset:"70%",stopColor:A.background}),e.jsx("stop",{offset:"100%",stopColor:A.backgroundD10})]}),e.jsxs("linearGradient",{id:"knob-disabled",x1:0,y1:t/2-v,x2:0,y2:t/2+v,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0%",stopColor:A.disabledD10}),e.jsx("stop",{offset:"30%",stopColor:A.disabled0}),e.jsx("stop",{offset:"70%",stopColor:A.disabled0}),e.jsx("stop",{offset:"100%",stopColor:A.disabledD10})]})]}),e.jsx("circle",{r:v+E,cx:t/2,cy:t/2,fill:"url(#knob-shadow)"}),e.jsx("circle",{r:v,cx:t/2,cy:t/2,fill:M?"url(#knob-enabled)":"url(#knob-disabled)"}),K&&e.jsx(k.Range,{percentageFrom:K[0],percentageTo:K[1],radius:b,color:A.danger,arcWidth:y}),e.jsx(k.Scale,{steps:8,tickWidth:2,tickHeight:y,radius:b,color:A.textD10}),e.jsx(k.Scale,{steps:32,tickWidth:1,tickHeight:y/2,radius:b,color:A.textD10}),e.jsx(k.Label,{percentage:.1,radius:b+6,label:"+",style:{fontSize:"80%",fontWeight:"bold"}}),e.jsx(k.Label,{percentage:-.1,radius:b+6,label:"-",style:{fontSize:"80%",fontWeight:"bold"}}),O!==null&&o!==null&&e.jsx(k.Range,{percentageFrom:o/360,percentageTo:O/360,radius:I+C*1.5,color:g!==null?A.edited:A.transient,arcWidth:C}),O!==null&&e.jsx(k.Pointer,{percentage:O/360,width:C,height:C,radius:I,type:"circle",color:g!==null?A.edited:A.transient}),e.jsx(k.Pointer,{percentage:0,width:2.5,height:y,radius:b-y*1.5,type:"circle",color:A.text}),o!==null&&e.jsx(k.Pointer,{percentage:o/360,width:C,height:C,radius:I,type:"circle",color:A.text}),e.jsx(k.Value,{value:g!==null?g:o,decimalPlace:1,marginBottom:t/2,className:"knob-text"})]})}function xn(n){const{hardware:t,options:o={}}=n,s=xs.useDebouncedCallback(m=>{t.actions.call("move",m)},[t.actions],100),r=je(t.properties.state,t.user_tags),a=r.MOVING?t.properties.target:void 0,c=Nn(t,o),l=e.jsx(N,{name:"Motor",icon:"fam-hardware-motor-r",online:t.online}),f=bn(t),u=e.jsx(we,{hardware:t}),d=e.jsx(gn,{className:"mx-auto my-auto",size:100,value:t.properties.position,min:f[0],max:f[1],target:a,onChange:s,disabled:n.disabled,readOnly:o.readOnly||!r.READY,origin:"down",direction:c?"clockwise":"anticlockwise"}),p=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:l,widgetState:u,widgetContent:d,headerMode:p})}function Wa(n,t){return n?t.FAULT?"danger":t.MOVING?"transient":"secondary":"secondary"}function wn(n){const{hardware:t,options:o={}}=n,{online:s=!1,properties:r={}}=t,{state:a,position:c,unit:l=null,display_digits:f}=r,u=je(a,[]),d=o.name??t.alias??t.name??t.id,p=Wa(s,u);function m(){let j="";return c!==void 0&&(c===null?j="null":Number.isFinite(c)?j+=c.toFixed(f??2):j=`${c}`),l!==null&&l!==""&&(j=`${j} ${l}`),j}const g=m();return e.jsxs(ee,{children:[e.jsx("h1",{children:d}),e.jsx(i.Badge,{bg:p,children:g})]})}const za=["move","stop","wait","rmove"],Ya="omega",Ka="omega 123",Qa=!0,Xa={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},Za="bliss",Ja=!1,ec="motor",tc=[],nc={callables:za,id:Ya,name:Ka,online:Qa,properties:Xa,protocol:Za,require_staff:Ja,type:ec,user_tags:tc},oc=["move","stop","wait","rmove"],sc="omega",rc="omega 123",ic=!0,ac={offset:0,sign:1,acceleration:300,limits:[-10,190],position:100,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3},cc="bliss",lc=!1,dc="motor",uc=[],fc={callables:oc,id:sc,name:rc,online:ic,properties:ac,protocol:cc,require_staff:lc,type:dc,user_tags:uc},pc=["move","wait","stop","rmove"],mc="omega",hc="omega 123",gc=!0,xc={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:["UNKNOWN"],target:null,tolerance:1e-4,unit:"deg",velocity:null},wc="bliss",jc=!1,yc="motor",vc=[],Nc={callables:pc,id:mc,name:hc,online:gc,properties:xc,protocol:wc,require_staff:jc,type:yc,user_tags:vc},bc=["move","wait","stop","rmove"],_c="omega",Sc="omega 123",Cc=!0,$c={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:[],target:null,tolerance:1e-4,unit:"deg",velocity:null},Oc="bliss",Ic=!1,Mc="motor",Dc=[],Tc={callables:bc,id:_c,name:Sc,online:Cc,properties:$c,protocol:Oc,require_staff:Ic,type:Mc,user_tags:Dc},Fc=["move","wait","stop","rmove"],Rc="omega",Ac="omega 123",kc=!1,Ec={},Pc="bliss",Bc=!1,Gc="motor",Hc=[],Lc={callables:Fc,id:Rc,name:Ac,online:kc,properties:Ec,protocol:Pc,require_staff:Bc,type:Gc,user_tags:Hc},Uc=["move","wait","stop","rmove"],Vc="omega",qc="omega 123",Wc=!0,zc={acceleration:null,limits:[null,null],offset:null,position:235.1654,sign:null,state:["OFF"],target:null,tolerance:1e-4,unit:"deg",velocity:null},Yc="bliss",Kc=!1,Qc="motor",Xc=[],Zc={callables:Uc,id:Vc,name:qc,online:Wc,properties:zc,protocol:Yc,require_staff:Kc,type:Qc,user_tags:Xc},jn={default:nc,halfMotor:fc,unknownMotor:Nc,notReadyMotor:Tc,disconnectedMotor:Lc,powerOffMotor:Zc};function yn(n){const{name:t="omega",minLimit:o=-999999999,maxLimit:s=999999999,initialPosition:r=0,initialVelocity:a=1e3,useHardwareContext:c=()=>null}=n,[l,f]=h.useState(r),[u,d]=h.useState(["READY"]),[p,m]=h.useState(null),g=h.useRef(Date.now()),j=c(),x=()=>{const v=Date.now(),C=(v-g.current)/1e3;let I;if(g.current=v,p!==null&&p!==l){let M,E;const O=C*a;if(O>Math.abs(l-p))I=p,M=["READY"],E=null;else{const Y=p>l?1:-1;I=l+Y*O,M=["MOVING"],E=p}f(I),d(M),m(E)}},w=h.useCallback((v,C)=>{if(v==="stop")return m(null),d(["READY"]),Promise.resolve();if(v==="move"){const I=Number.parseFloat(C);return m(Number.isNaN(I)?null:I),Promise.resolve()}return console.log("MotorSimulator: Unsupported call",v,C),Promise.resolve()},[]),y=h.useCallback((v,C)=>(console.log("MotorSimulator: Unsupported setProperty",v,C),Promise.resolve()),[]);h.useEffect(()=>{const v=setInterval(()=>{x()},500);return()=>clearInterval(v)});const _=h.useMemo(()=>{var C,I;const v={setProperty:y,call:w};return(I=j==null?void 0:(C=j.actions).updateHardwareChangeActions)==null||I.call(C,t,v),v},[]),$={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:a,target:p,display_digits:3},type:"motor",actions:_,user_tags:[],locked:null},b=h.useRef(null);return h.useEffect(()=>{b.current!==null&&P.isEqual(b.current,$)||(b.current=$,j==null||j.actions.updateHardware(t,$))},[t,$]),e.jsx(e.Fragment,{})}function je(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((a,c)=>(a[c]=!0,a),{});return r.READY===void 0&&s&&r.OFF&&(r.READY=!0),r},[n,t])}function vn(n){return n.type==="motor"}function U(n){const t=G(n);return t===null||!vn(t)?null:t}const Jc={default:ce,text:hn,rotation:xn,state:Ua,monitor:wn};function Nn(n,t){if((t==null?void 0:t.clockwise)!==void 0)return t.clockwise;const o=n.properties.sign<0,s=n.user_tags.includes("dial.anticlockwise"),r=n.user_tags.includes("dial.clockwise");return r&&s&&console.error("Both tags 'dial.clockwise' and 'dial.anticlockwise' are defined"),(r||!s)!==o}function bn(n){var r;const t=(r=n.properties)==null?void 0:r.limits;if(t==null)return[void 0,void 0];const[o,s]=t;return[Number.isFinite(o)?o:void 0,Number.isFinite(s)?s:void 0]}const _n={variants:Jc,mocks:jn,simulator:yn,monitor:wn};function el(n,t){return{id:n,name:n,type:"motor",properties:{position:t,unit:"mm",limits:[-100,100]},online:!0}}function Le(n){var l;const{hardware:t}=n,{online:o,locked:s=null}=t,r=o?(s!==null?"LOCKED":(l=t.properties)==null?void 0:l.state)||"UNKNOWN":"OFFLINE",c={OFFLINE:"secondary",READY:"success",MOVING:"transient",ERROR:"danger",UNKNOWN:"fatal",LOCKED:"warning"}[r]||"success";return e.jsx(i.Badge,{bg:c,children:r})}function Sn(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 a(l){t.actions.call("stop")}const c=P.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(N,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(Le,{hardware:t})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsxs(i.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(i.Button,{onClick:r,disabled:n.disabled,children:"Move"}),t.properties.state==="MOVING"&&!n.disabled&&e.jsx(i.Button,{variant:"danger",onClick:a,children:e.jsx("i",{className:"fa fa-times"})})]})})]})}const Cn=h.forwardRef(({title:n,children:t,bsPrefix:o,rootCloseEvent:s,variant:r,size:a,menuRole:c,renderMenuOnMount:l,disabled:f,href:u,id:d,menuVariant:p,flip:m,style:g,className:j,popperConfig:x,...w},y)=>e.jsxs(i.Dropdown,{ref:y,...w,children:[e.jsx(i.DropdownToggle,{id:d,href:u,size:a,variant:r,disabled:f,childBsPrefix:o,style:g,className:j,children:n}),e.jsx(i.DropdownMenu,{popperConfig:x,role:c,renderOnMount:l,rootCloseEvent:s,variant:p,flip:m,children:t})]}));Cn.displayName="DropdownButton2";const tl=Cn;function nl(n){const{currentPositionId:t,position:o,disabled:s,onSelect:r,filter:a}=n,c=o.position,l=c===t,f=l?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return h.useMemo(()=>{var p,m;if(a==="")return!0;const d=a.toLowerCase();return((p=o.position)==null?void 0:p.toLowerCase().includes(d))||((m=o.description)==null?void 0:m.toLowerCase().includes(d))},[a,o])?e.jsxs(i.Dropdown.Item,{disabled:s,onClick:()=>{r(c)},title:o.description,children:[e.jsxs(i.Row,{className:"gx-0 nowrap",children:[e.jsx(i.Col,{sm:"1",children:e.jsx("i",{className:f})}),e.jsx(i.Col,{sm:"2",children:e.jsx(i.Badge,{className:"small w-100",bg:l?"primary":"secondary",children:e.jsx("span",{className:"secondary",children:e.jsx("span",{className:"text-truncate w-50",children:c})})})})]}),e.jsxs(i.Row,{className:"gx-0 nowrap",children:[e.jsx(i.Col,{sm:"1"}),e.jsx(i.Col,{sm:"11",children:e.jsx(i.Row,{className:"gx-0",children:e.jsx(i.Col,{sm:"12",className:"text-truncate text-start",children:o.description})})})]})]},o.position):e.jsx(e.Fragment,{})}function ol(n,t){if(n===null)return null;for(const o of t)if(n===o.position)return o;return null}function sl(n){const{positionId:t,targetPositionId:o,hardware:s}=n,{properties:r={}}=s,{positions:a=[]}=r;function c(){return o?e.jsx(i.Badge,{bg:"transient",children:o}):t?e.jsx(i.Badge,{children:t}):e.jsx(i.Badge,{bg:"warning",children:"unknown"})}const l=c(),f=h.useMemo(()=>{if(o)return"Moving...";const u=ol(t,a);return u===null?"Position not described":u.description??""},[o,t,a]);return e.jsxs(e.Fragment,{children:[l,e.jsx("div",{className:"text-truncate text-start ms-2 flex-grow-1 flex-shrink-1",title:f,style:{flex:"1 1 0",minWidth:0},children:f})]})}function $n(n){const{hardware:t,options:o={}}=n,{properties:s={}}=t,r=s.state==="READY",a=(s==null?void 0:s.state)==="MOVING",c=n.disabled||!t.online||!r;function l(_){t.actions.call("move",_)}function f(_){t.actions.call("stop")}const u=e.jsx(N,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),d=e.jsx(Le,{hardware:t}),p=a?"moving":null;function m(){var $;const _=(($=t.properties)==null?void 0:$.position)??null;return _==="unknown"?null:_}const g=m(),[j,x]=h.useState("");function w(){return e.jsxs(i.InputGroup,{className:"flex-nowrap",style:{alignItems:"stretch"},children:[e.jsxs(tl,{variant:"secondary",title:e.jsx(sl,{positionId:g,targetPositionId:p,hardware:t}),disabled:c,popperConfig:{strategy:"fixed"},className:"flex-grow-1 d-flex flex-nowrap align-items-center",style:{flex:"1 1 0",minWidth:0},children:[o.search&&e.jsxs(i.Container,{className:"d-flex justify-content-center align-items-center",children:[e.jsx("i",{className:"fa fa-search fa-fw flex-shrink"}),e.jsx(i.Form.Control,{autoFocus:!0,className:"mx-1 my-2 w-50",style:{marginLeft:"auto",marginRight:"auto"},placeholder:"Type to filter...",onChange:_=>x(_.target.value),value:j}),e.jsx(i.CloseButton,{disabled:j==="",onClick:()=>{x("")}})]}),s.positions.map(_=>e.jsx(nl,{currentPositionId:g,position:_,onSelect:$=>{l($)},disabled:c,filter:j})),o.search&&j!==""&&e.jsxs(e.Fragment,{children:[e.jsx(i.Dropdown.Divider,{}),e.jsx(i.Dropdown.Item,{onClick:_=>{x(""),_.stopPropagation()},children:"Display all the positions..."})]})]}),a&&!n.disabled&&e.jsx(i.Button,{variant:"danger",onClick:f,children:e.jsx("i",{className:"fa fa-fw fa-times"})})]})}const y=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:u,widgetState:d,widgetContent:w(),headerMode:y})}const rl=["move","stop"],il="beamstop",al="beamstop",cl=!0,ll={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"},dl="bliss",ul=!1,fl="multiposition",pl={callables:rl,id:il,name:al,online:cl,properties:ll,protocol:dl,require_staff:ul,type:fl},On={default:pl};function In(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("empty"),[c,l]=h.useState("READY");async function f(p,m){if(p==="move"){l("MOVING"),a("unknown"),await H(2e3),l("READY"),a(m);return}if(p==="stop"){a("unknown"),await H(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(W,{name:t,alias:o,type:"multiposition",call:f,setProperty:u,properties:d,useHardwareContext:s})}const ml={state:Le,default:Sn,default2:$n},Mn={variants:ml,mocks:On,simulator:In};function Ue(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOVING:"transient",INVALID:"danger",UNKNOWN:"danger",DISABLED:"secondary",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(D,{state:o,minWidth:6,variant:r})}function hl(n){const{hardware:t}=n;return e.jsx(Ue,{hardware:t})}function gl(n){const{hardware:t,options:o={}}=n,{properties:s}=t,{state:r}=s,a=r==="MOVING",c=r==="READY",l=a?s.target_magnification||0:s.magnification||0,u=[...s.available_magnifications??[]];u.sort((j,x)=>j>x?1:x>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 g(j,x){const y=l===x?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(i.Dropdown.Item,{disabled:d,onClick:()=>{m(x)},children:[e.jsx("i",{className:y}),"  × ",x]},`id${j}`)}return e.jsxs(e.Fragment,{children:[e.jsx(B,{value:l.toFixed(p),className:V.default({"hw-moving":a})}),e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:!c,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:u.map((j,x)=>g(x,j))})]})]})}function xl(n){const{hardware:t,options:o={}}=n,s=t.properties.magnification||0,r=o.digits||2,a=!!o.allowtuning;return e.jsxs(e.Fragment,{children:[e.jsx(B,{value:s.toFixed(r)}),a&&e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{children:"×"}),e.jsx(Dn,{...n})]})})]})]})}function Dn(n){const{hardware:t,options:o={}}=n,s=t.properties.magnification||0,{state:r}=t.properties,a=r==="READY",c=n.disabled||!t.online||!a,[l,f]=t.properties.magnification_range||[null,null],u=h.useRef(null),d=h.useRef(null),[p,m]=h.useState(!1),g=o.digits||2;function j(b){t.actions?n.mode==="move"?t.actions.call("move",b):t.actions.setProperty("magnification",b):console.error("Change request was triggered with:",b)}function x(b){if(!u||!u.current){console.log("formRef not yet defined");return}if(b.key==="Enter"){m(!1);const{value:v}=u.current,C=Number.parseFloat(v);if(l!==null&&C<l||f!==null&&C>f)return;j(C)}else b.key==="Escape"?(u.current.value=s.toFixed(g),d.current&&(d.current.value=s.toString()),m(!1)):console.log(b.key)}function w(b){b!==s&&!p&&m(!0),b===s&&p&&m(!1)}function y(b){if(!u||!u.current){console.error("formRef is not set");return}const v=Number.parseFloat(u.current.value);w(v),d.current&&(d.current.value=v.toString())}function _(b){if(!u||!u.current){console.error("formRef is not set");return}if(!d||!d.current){console.error("rangeRef is not set");return}const v=Number.parseFloat(d.current.value);w(v),u.current.value=v.toFixed(g)}function $(){if(!d||!d.current){console.error("rangeRef is not set");return}const b=Number.parseFloat(d.current.value);j(b)}return h.useEffect(()=>{if(!u||!u.current){console.error("formRef is not set");return}p||(u.current.value=s.toFixed(g)),d.current&&(d.current.value=s.toString())},[g,p,s]),e.jsxs(e.Fragment,{children:[e.jsx(i.Form.Control,{className:p?"form-control-edited":"",type:"number",ref:u,defaultValue:s.toFixed(g),onChange:y,disabled:c,step:10**-g,onKeyDown:x}),l!==null&&f!==null&&e.jsx(i.Form.Control,{ref:d,disabled:c,type:"range",min:l,max:f,step:10**-g,onChange:_,onMouseUp:$,defaultValue:s})]})}function wl(n){const{hardware:t,options:o={}}=n,{properties:s}=t,r=s.state==="MOVING",a=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(B,{value:c.toFixed(l),className:V.default({"hw-moving":r})}),e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:!a,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{children:"×"}),e.jsx(Dn,{...n,mode:"move"})]})})]})]})}function jl(n){return e.jsx(i.Form.Control,{className:"border-light",type:"text",disabled:!0,defaultValue:"Missing"})}function Tn(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Optic",icon:"fam-hardware-optic",online:t.online}),r=e.jsx(Ue,{hardware:t});function a(){function l(){return t.online?t.properties.available_magnifications?gl:t.properties.magnification_range?wl:xl:jl}const f=l();return e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{className:"border-light",children:"×"}),e.jsx(f,{...n})]})}const c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a(),headerMode:c})}const yl=["magnification","reset","open"],vl="optic",Nl="optic",bl=!0,_l={state:"READY",magnification:10,target_magnification:null,available_magnifications:[5,7.5,10],magnification_range:null},Sl="bliss",Cl=!1,$l="optic",Se={callables:yl,id:vl,name:Nl,online:bl,properties:_l,protocol:Sl,require_staff:Cl,type:$l},Fn={default:Se,fixed:Se,off:Se,range:Se};function Rn(n){const{name:t,alias:o,kind:s,useHardwareContext:r}=n;function a(){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,...a()});async function f(p){let m=c.magnification;l(x=>({...x,state:"MOVING",target_magnification:p})),await H(100);const g=.2*(m<p?1:-1);function j(x){l(w=>({...w,magnification:x}))}for(;Math.abs(p-m)>=Math.abs(g)*1.01;)m+=g,j(m),await H(100);l(x=>({...x,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(g=>({...g,magnifications:m}));return}console.log("OpticSimulator: Unsupported setProperty",p,m)}return e.jsx(W,{name:t,alias:o,type:"optic",call:u,setProperty:d,properties:c,useHardwareContext:r})}function Ol(n){return n.type==="optic"}const Il={default:Tn,state:hl},An={variants:Il,mocks:Fn,simulator:Rn};function ye(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={STANDBY:"success",DISABLED:"secondary",OFFLINE:"secondary",RUNNING:"transient",ABORTING:"warning",AWAITING_USER_INPUT:"warning",UNKNOWN:"fatal"},r=s[o]||s.UNKNOWN;return e.jsx(D,{state:o,minWidth:6,variant:r})}function Ml(n){const{hardware:t}=n;return e.jsx(ye,{hardware:t})}function Dl(n){const{hardware:t,options:o}=n,s=n.disabled||!t.online,r=t.properties.state==="AWAITING_USER_INPUT",a=t.properties.state==="ABORTING",c=t.properties.state==="RUNNING"||r||a;function l(u){o.foreground?t.actions.call("run_foreground"):t.actions.call("start")}function f(u){t.actions.call("abort")}return e.jsxs(i.ButtonGroup,{size:"lg",className:"w-100",children:[e.jsx(i.Button,{onClick:l,disabled:s||c,variant:"primary",children:"Start"}),e.jsx(i.Button,{onClick:f,disabled:s||!c,variant:"primary",children:"Abort"})]})}function Ee(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Procedure",icon:"fa-cog",online:t.online}),r=e.jsx(ye,{hardware:t}),a=e.jsx(i.Container,{children:e.jsx(Dl,{hardware:t,disabled:!n.operator,options:o})}),c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Tl(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(i.Badge,{bg:"warning",children:[e.jsx("i",{className:"fa-solid fa-heart-crack fa-beat"})," ABORTING"]}):r?e.jsxs(i.Badge,{bg:"info",children:[e.jsx("i",{className:"fa-solid fa-heart fa-beat"})," RUNNING"]}):o?e.jsxs(i.Badge,{bg:"warning",title:"A user input is expected",children:[e.jsx("i",{className:"fa-solid fa-user fa-beat"})," AWAITING INPUT"]}):e.jsx(Fl,{hardware:t})}function Fl(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]},a=r[o]||r.UNKNOWN,[c,l]=a;return e.jsxs(i.Badge,{bg:c,title:s??void 0,children:[l&&e.jsxs(e.Fragment,{children:[e.jsx("i",{className:`fa-solid ${l}`})," "]}),o]})}function kn(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Procedure",icon:"fa-cog",online:t.online}),r=e.jsx(ye,{hardware:t}),a=e.jsx(i.Container,{children:e.jsx("div",{children:e.jsx("h3",{children:e.jsx(Tl,{hardware:t})})})}),c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Rl(n){const{hardware:t}=n,o=n.disabled||!t.online,s=t.properties.state==="AWAITING_USER_INPUT";function r(a){t.actions.call("validate")}return e.jsx(i.ButtonGroup,{size:"lg",className:"w-100",children:e.jsx(i.Button,{onClick:r,disabled:o||!s,variant:"primary",children:"Validate"})})}function En(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Procedure",icon:"fa-cog",online:t.online}),r=e.jsx(ye,{hardware:t}),a=e.jsx(i.Container,{children:e.jsx(Rl,{hardware:t,disabled:!n.operator})}),c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const Al=["start","abort","clear","validate"],kl="procedure",El="procedure",Pl="procedure",Bl="bliss",Gl=!1,Hl=!0,Ll={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"}}},Ul={callables:Al,type:kl,id:El,name:Pl,protocol:Bl,require_staff:Gl,online:Hl,properties:Ll},Pn={standby:Ul},Vl={default:Ee,manage:Ee,execution:kn,validate:En,state:Ml},Bn={variants:Vl,mocks:Pn};function Gn(n){return n.type==="procedure"}function ql(n){const t=G(n);return t===null||!Gn(t)?null:t}function Hn(n){return n==="OFF"?"danger":n==="READY"?"success":n==="MOVING"?"transient":"warning"}function ot({tooltip:n,children:t}){return e.jsx(i.OverlayTrigger,{placement:"top",overlay:e.jsx(i.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:n}),children:t})}function Ln(n){var p,m;const{hardware:t,options:o={}}=n,{showOutput:s=!0,step:r,steps:a}=o;function c(g){return t.actions.call(g)}function l(g){return t.actions.setProperty("setpoint",g)}const f=t.properties.state,u=e.jsx(N,{name:"RegulationLoop",icon:"fa-repeat",online:t.online}),d=e.jsxs(e.Fragment,{children:[e.jsx(D,{state:f,minWidth:6,variant:Hn(f)}),!t.properties.is_softloop&&e.jsx(ot,{tooltip:"Start/Stop Monitor",children:e.jsx(i.Button,{size:"sm",variant:t.properties.is_monitoring?"success":"warning",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>{c(t.properties.is_monitoring?"stop_monitor":"start_monitor")},children:e.jsx("i",{className:t.properties.is_monitoring?"fa fa-toggle-on":"fa fa-toggle-off"})})}),e.jsx(ot,{tooltip:"Stop Ramping",children:e.jsx(i.Button,{disabled:t.properties.state==="OFF",size:"sm",variant:"danger",className:"ms-1",style:{fontSize:"0.6rem",padding:"0.05rem 0.6rem",marginTop:"0.1rem"},onClick:()=>{c("stop_ramping")},children:e.jsx("i",{className:"fa fa-circle-exclamation"})})})]});return e.jsx(S,{hardware:t,widgetIcon:u,widgetState:d,widgetContent:e.jsxs(e.Fragment,{children:[e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(ge,{id:t.id,hardwareValue:t.properties.setpoint??null,hardwareIsDisabled:!1,hardwareIsMoving:!1,hardwareIsReady:!0,onMoveRequested:l,onAbortRequested:()=>null,precision:1,readOnly:!1,step:r,steps:a,incIcon:void 0,decIcon:void 0,swapIncDec:void 0}),t.properties.input_unit&&e.jsx(i.InputGroup.Text,{children:t.properties.input_unit})]}),e.jsxs(i.InputGroup,{children:[e.jsx(i.InputGroup.Text,{children:"I"}),e.jsx(i.Form.Control,{type:"number",disabled:!0,value:(p=t.properties.input_value)==null?void 0:p.toFixed(2)}),t.properties.input_unit&&e.jsx(i.InputGroup.Text,{children:n.hardware.properties.input_unit}),s&&e.jsxs(e.Fragment,{children:[e.jsx(i.InputGroup.Text,{children:"O"}),e.jsx(i.Form.Control,{type:"number",disabled:!0,value:(m=t.properties.output_value)==null?void 0:m.toFixed(2)}),t.properties.output_unit&&e.jsx(i.InputGroup.Text,{children:n.hardware.properties.output_unit})]})]})]})})}function Un(n){const{hardware:t,options:o={}}=n,{properties:s={}}=t,{state:r}=s,a=o.name??t.alias??t.name,c=Hn(r);let l=t.properties.input_value;return Number.isFinite(l)&&(l=l.toFixed(2)),e.jsxs(ee,{children:[e.jsx("h1",{children:a}),e.jsxs(i.Badge,{bg:c,children:[l," ",t.properties.input_unit]})]})}function Wl({curves:n}){const t=n[0].x??[],o=L.useValueToIndexScale(t,!0),{abscissaConfig:s}=L.useVisCanvasContext();return e.jsx(L.TooltipMesh,{guides:"both",renderTooltip:r=>{const a=o(r);return e.jsxs("div",{className:"h5web-tooltip",children:[s.label||"x","=",t[a],n.map(c=>e.jsxs("div",{children:[e.jsx("span",{style:{content:"",display:"inline-block",width:"0.75em",height:"0.375rem",marginRight:"0.375rem",paddingBottom:"0.125rem",backgroundColor:c.color,transform:"translateY(-1px)"},"data-keep-colors":!0}),e.jsxs("strong",{children:[c.name,":"]})," ",c.y[a].toFixed(2)]},c.name))]})}})}const st=["#1f77b4","#ff7f0e","#d62728","#2ca02c"],rt=[.1,1],it=6;function at(n){const{data:t,xAxisTitle:o,yAxisTitle:s,title:r}=n,a=t.flatMap((f,u)=>{const d=f.x;let p=f.y;return d.length<p.length&&(p=p.slice(0,d.length)),[{color:f.color??st[u%st.length],name:f.name,x:[...L.getAxisValues(d,p.length)],y:p}]}),c=L.useCombinedDomain(L.useDomains(a.map(f=>f.x)))||rt,l=L.useCombinedDomain(L.useDomains(a.map(f=>f.y)))||rt;return e.jsxs(L.VisCanvas,{title:r,abscissaConfig:{visDomain:c,showGrid:!0,label:o},ordinateConfig:{visDomain:l,showGrid:!0,label:s},raycasterThreshold:it,children:[a.map(f=>e.jsx(L.DataCurve,{abscissas:f.x,ordinates:f.y,color:f.color,glyphSize:it,glyphType:L.GlyphType.Circle},f.name)),e.jsx(L.Zoom,{}),e.jsx(L.Pan,{}),e.jsx(Wl,{curves:a})]})}const Ce=100;function $e(n,t){const[o,s]=h.useState(new Array(n).fill(null)),r=h.useRef(0);function a(l){s(f=>{const u=[...f];return r.current===n-1?(u.shift(),u.push(l)):(u[r.current]=l,r.current=(r.current+1)%n),u})}function c(){return o.filter(l=>l!==null)}return{read:c,write:a,name:t}}function Ve(n){const{hardware:t,options:o}=n,{showOutput:s=!0,plotHeight:r,plotWidth:a}=o,c=$e(Ce,"Time"),l=$e(Ce,"Input"),f=$e(Ce,"Output"),u=$e(Ce,"Setpoint");h.useEffect(()=>{c.write(Date.now()),l.write(t.properties.input_value),f.write(t.properties.output_value),u.write(t.properties.setpoint)},[t.properties]);const d=Date.now(),p=c.read().map(w=>-(d-w)/1e3),m=[l,u].map(w=>({name:w.name,x:p,y:w.read()})),g=[f].map(w=>({name:w.name,x:p,y:w.read()})),j={x:p,y:p.map(()=>t.properties.setpoint+(t.properties.deadband??0)),name:"Deadband+",color:"green"},x={x:p,y:p.map(()=>t.properties.setpoint-(t.properties.deadband??0)),name:"Deadband-",color:"green"};return e.jsx(i.Stack,{className:"bg-light rounded-2 ps-2 p-1",direction:"vertical",children:e.jsxs("div",{className:"h5web-plot",style:{display:"flex",height:r??"20rem",width:a},children:[e.jsx(at,{data:[...m,j,x],title:"Input",xAxisTitle:"Time (s)",yAxisTitle:t.properties.input_unit}),s&&e.jsx(at,{data:g,title:"Output",xAxisTitle:"Time (s)",yAxisTitle:t.properties.output_unit})]})})}function zl(n){const{hardware:t,options:o}=n,{showOutput:s=!0,popupPlacement:r="right",plotWidth:a}=o,c=e.jsxs(i.Popover,{id:`regulation-plot-${t.name}`,style:{maxWidth:a??s?300*2:276},children:[e.jsxs(i.Popover.Header,{as:"h3",children:["Regulation Plot for `",n.hardware.name,"`"]}),e.jsx(i.Popover.Body,{children:e.jsx(Ve,{...n})})]});return e.jsx(i.OverlayTrigger,{trigger:"click",placement:r,overlay:c,children:e.jsx(i.Button,{children:o.buttonTitle??"Plot"})})}const Yl=null,Kl=[],Ql=null,Xl="regulation",Zl=!0,Jl={deadband:.05,input_unit:"degC",input_value:10.029739616019928,is_monitoring:!1,output_unit:"Volt",output_value:8.556047391201504,setpoint:10,state:"READY"},ed="regulation",td=[],nd={alias:Yl,errors:Kl,locked:Ql,name:Xl,online:Zl,properties:Jl,type:ed,user_tags:td},Vn={default:nd};function qn(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("READY"),[c,l]=h.useState(0),[f,u]=h.useState(0),[d,p]=h.useState(10),m=h.useRef(Date.now()),g=()=>{const y=Date.now(),_=(y-m.current)/1e3;let $,b;if(m.current=y,d!==null&&d!==c){let v;const C=_*2,I=Math.random()*.1-.05;if(C>Math.abs(c-d)+.05)$=d+I,v="READY",b=-I*5;else{const M=d>c?1:-1;$=c+M*C,b=10*M,v="MOVING"}l($),u(b),a(v)}};async function j(y,_){console.log("RegulationSimulator: Unsupported call",y,_)}async function x(y,_){y==="setpoint"&&p(_),console.log("RegulationSimulator: Unsupported setProperty",y,_)}h.useEffect(()=>{const y=setInterval(()=>{g()},500);return()=>clearInterval(y)});const w={state:r,deadband:.05,input_unit:"degC",input_value:c,is_monitoring:!0,output_unit:"Volt",output_value:f,setpoint:d};return e.jsx(W,{name:t,alias:o,type:"regulation",call:j,setProperty:x,properties:w,useHardwareContext:s})}const od={default:Ln,plot:Ve,popupplot:zl,monitor:Un},Wn={variants:od,mocks:Vn,simulator:qn,monitor:Un};function ve(n){const{hardware:t}=n;function o(){if(!t.online)return"OFFLINE";const a=t.properties.state;return n.useReadyState&&(a==="OPEN"||a==="CLOSED")?"READY":a}const s=o();function r(){switch(s){case"READY":return"success";case"OPEN":return"success";case"CLOSED":return"danger";case"OFFLINE":case"DISABLED":return"secondary";case"MOVING":return"transient";case"STANDBY":return"warning";case"FAULT":return"fatal";default:return"fatal"}}return e.jsx(D,{state:s,minWidth:6,variant:r()})}function sd(n){const{hardware:t}=n;return e.jsx(ve,{hardware:t,useReadyState:!0})}function rd(n){const{hardware:t}=n;function o(){t.actions.call("reset")}return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.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(i.Button,{onClick:o,disabled:n.disabled,children:"Reset"})})]})]}),children:e.jsx(i.Button,{className:"flex-grow-0",title:"Shutter Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function zn(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),r=e.jsx(ve,{hardware:t});function a(){return t.properties?t.properties.state:"UNKNOWN"}function c(x){return x==="OPEN"?["Close","close"]:x==="CLOSED"?["Open","open"]:x==="DISABLED"||x==="STANDBY"||x==="FAULT"?["Closed",""]:x==="MOVING"?["...",""]:["Unknown",""]}const l=a(),[f,u]=c(l),p={OPEN:"danger",CLOSED:"success",MOVING:"transient",DISABLED:"secondary",STANDBY:"danger",FAULT:"fatal",UNKNOWN:"warning"}[l]||"danger";function m(){t.actions.call(u)}const g=e.jsxs(i.ButtonGroup,{className:"d-flex flex-nowrap",children:[e.jsx(i.Button,{variant:p,onClick:m,disabled:n.disabled||u==="",children:f}),o.extended&&e.jsx(rd,{...n})]}),j=n.options.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:g,headerMode:j})}function id(n){var f;const{hardware:t,options:o={}}=n;function s(){t.actions.call("open")}function r(){t.actions.call("close")}const a=((f=t.properties)==null?void 0:f.state)??"UNKNOWN",c=a==="MOVING",l=a==="DISABLED"||c;return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary",disabled:n.disabled||l}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Actions"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsxs(i.ButtonGroup,{children:[e.jsx(i.Button,{variant:c?"warning":"secondary",onClick:()=>{s()},disabled:n.disabled||l,title:"Open the shutter",children:"Open"}),e.jsx(i.Button,{variant:c?"warning":"secondary",onClick:()=>{r()},disabled:n.disabled||l,title:"Close the shutter",children:"Close"})]})})})]})})]})}function Yn(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),r=e.jsx(ve,{hardware:t,useReadyState:!0});function a(){return t.properties?t.properties.state:"UNKNOWN"}function c(x){return x==="OPEN"||x==="CLOSED"?x:x==="DISABLED"||x==="STANDBY"||x==="FAULT"?"CLOSED":x==="MOVING"?"...":"UNKNOWN"}function l(x){return x.charAt(0).toUpperCase()+x.slice(1).toLowerCase()}const f=a(),u=c(f),p={OPEN:"success",CLOSED:"danger",MOVING:"transient",DISABLED:"secondary",STANDBY:"success",FAULT:"fatal",UNKNOWN:"fatal"}[f],m=l(u),g=e.jsxs(i.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(B,{variant:p,className:"text-center",style:{minWidth:"10em"},value:m}),e.jsx(id,{...n})]}),j=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:g,headerMode:j})}function Kn(n){const{hardware:t,options:o={}}=n,{properties:s={}}=t,{state:r="OFFLINE",status:a}=s,c=o.name??t.alias??t.name,l=e.jsxs(ee,{children:[e.jsx("h1",{children:c}),e.jsx(ve,{hardware:t})]});if(a){const f=`${a}`;return e.jsx(i.OverlayTrigger,{placement:"bottom",overlay:e.jsx(i.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:f.includes(`
30
- `)?e.jsx("pre",{children:f}):f}),children:l})}return l}const ad=["reset","open","close","toggle"],cd="abs1",ld="abs1",dd=!0,ud={closed_text:"",open_text:"",state:"OPEN",status:`Pneumatic Beam Shutter is open
31
- `,valid:!0},fd="tango",pd=!0,md="shutter",hd={callables:ad,id:cd,name:ld,online:dd,properties:ud,protocol:fd,require_staff:pd,type:md},gd=["reset","open","close","toggle"],xd="abs1",wd="abs1",jd=!0,yd={closed_text:"",open_text:"",state:"CLOSED",status:`Pneumatic Beam Shutter is closed
32
- `,valid:!0},vd="tango",Nd=!0,bd="shutter",_d={callables:gd,id:xd,name:wd,online:jd,properties:yd,protocol:vd,require_staff:Nd,type:bd},Qn={default:hd,closed:_d};function Xn(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("OPEN");async function c(u,d){if(u==="open"){a("MOVING"),await H(2e3),a("OPEN");return}if(u==="close"){a("MOVING"),await H(2e3),a("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(W,{name:t,alias:o,type:"shutter",call:c,setProperty:l,properties:f,useHardwareContext:s})}const Sd={default:zn,protected:Yn,state:sd,monitor:Kn},Zn={variants:Sd,mocks:Qn,simulator:Xn,monitor:Kn};function Cd(n){var d,p,m,g;const{properties:t}=n,o=(d=t.vgap)==null?void 0:d.slice(9),s=U(o),r=(p=t.hgap)==null?void 0:p.slice(9),a=U(r),c=(m=t.voffset)==null?void 0:m.slice(9),l=U(c),f=(g=t.hoffset)==null?void 0:g.slice(9),u=U(f);return h.useMemo(()=>{var j,x,w,y;return{vgap:((j=s==null?void 0:s.properties)==null?void 0:j.state)??null,hgap:((x=a==null?void 0:a.properties)==null?void 0:x.state)??null,voffset:((w=l==null?void 0:l.properties)==null?void 0:w.state)??null,hoffset:((y=u==null?void 0:u.properties)==null?void 0:y.state)??null}},[s,a,l,u])}function qe(n){const{hardware:t}=n,o=Cd(t),[s,r,a]=h.useMemo(()=>{if(!t.online)return["OFFLINE","secondary","No motor online"];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","transient","A motor is moving"]:c.has("OFF")?["OFF","secondary","A motor is off"]:["READY","success","The slit is ready"]},[t.online,o]);return e.jsx(D,{state:s,description:a,variant:r,minWidth:6})}function $d(n){const{hardware:t}=n;return e.jsx(qe,{hardware:t})}function Od(n){var x,w,y,_;const{properties:t}=n,o=(x=t.vgap)==null?void 0:x.slice(9),s=U(o),r=oe(o),a=(w=t.hgap)==null?void 0:w.slice(9),c=U(a),l=oe(a),f=(y=t.voffset)==null?void 0:y.slice(9),u=U(f),d=oe(f),p=(_=t.hoffset)==null?void 0:_.slice(9),m=U(p),g=oe(p);function j($,b){return $===null?null:{...$,actions:b}}return{vgap:j(s,r),hgap:j(c,l),voffset:j(u,d),hoffset:j(m,g)}}function Id(n){const{hardware:t,operator:o,disabled:s,resolved:r}=n;return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{variant:"secondary"}),e.jsx(i.Dropdown.Menu,{align:"end",popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsxs(i.Row,{className:"flex-nowrap",children:[e.jsx(i.Col,{sm:1,className:"d-flex",children:e.jsx("i",{className:"fa fa-fw fa-square",title:"Gap",style:{alignSelf:"center"}})}),e.jsx(i.Col,{sm:5,children:r.hgap&&e.jsx(ce,{hardware:r.hgap,options:{header:"none"},disabled:s,operator:o})}),e.jsx(i.Col,{sm:1,className:"d-flex",children:e.jsx("span",{style:{alignSelf:"center"},children:"×"})}),e.jsx(i.Col,{sm:5,children:r.vgap&&e.jsx(ce,{hardware:r.vgap,options:{header:"none"},disabled:s,operator:o})})]}),e.jsxs(i.Row,{className:"flex-nowrap",children:[e.jsx(i.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(i.Col,{sm:5,children:r.hoffset&&e.jsx(ce,{hardware:r.hoffset,options:{header:"none"},disabled:s,operator:o})}),e.jsx(i.Col,{sm:1,className:"d-flex",children:e.jsx("span",{style:{alignSelf:"center"},children:";"})}),e.jsx(i.Col,{sm:5,children:r.voffset&&e.jsx(ce,{hardware:r.voffset,options:{header:"none"},disabled:s,operator:o})})]})]})})]})}function Md(n){const{hardware:t,options:o={}}=n,s=Od(t),{readonly:r=!1}=o;function a(m){var x,w;const g=((x=m==null?void 0:m.properties)==null?void 0:x.position)??null;if(g===null)return"∅";const j=o.precision??((w=m==null?void 0:m.properties)==null?void 0:w.display_digits)??void 0;return j!==void 0?g.toFixed(j):`${g}`}const[c,l,f,u,d,p]=h.useMemo(()=>{var b,v,C,I,M,E,O,Y;const m=`${a(s.hgap)} × ${a(s.vgap)}`,g=((b=s.hgap)==null?void 0:b.properties.unit)??((v=s.vgap)==null?void 0:v.properties.unit)??"?",x=new Set([...((C=s.hgap)==null?void 0:C.properties.state)??[],...((I=s.vgap)==null?void 0:I.properties.state)??[]]).has("MOVING"),w=`${a(s.hoffset)} ; ${a(s.voffset)}`,y=((M=s.hoffset)==null?void 0:M.properties.unit)??((E=s.voffset)==null?void 0:E.properties.unit)??"?",$=new Set([...((O=s.hoffset)==null?void 0:O.properties.state)??[],...((Y=s.voffset)==null?void 0:Y.properties.state)??[]]).has("MOVING");return[m,g,x,w,y,$]},[s.hgap,s.hoffset,s.vgap,s.voffset]);return e.jsxs(i.InputGroup,{className:"w-100 flex-nowrap",children:[e.jsx(i.InputGroup.Text,{title:"Gap (horizontal and vertical)",children:e.jsx("i",{className:"fa fa-fw fa-square fa-2x"})}),e.jsx(B,{value:c,title:"Gap",className:V.default({"hw-moving":f})}),e.jsx(i.InputGroup.Text,{children:l}),e.jsx(i.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(B,{value:u,title:"Offset",className:V.default({"hw-moving":p})}),e.jsx(i.InputGroup.Text,{children:d}),!r&&e.jsx(Id,{...n,resolved:s})]})}function Jn(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Slit",icon:"fam-hardware-motor",online:t.online}),r=e.jsx(qe,{hardware:t}),a=e.jsx(Md,{...n}),c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const Dd="s1",Td="s1",Fd=!0,Rd={vgap:"hardware:s1vg",voffset:"hardware:s1vo",hgap:"hardware:s1hg",hoffset:"hardware:s1ho"},Ad="slit",kd={id:Dd,name:Td,online:Fd,properties:Rd,type:Ad},Ed="s1",Pd="s1",Bd=!0,Gd={vgap:"hardware:",voffset:"hardware:",hgap:"hardware:s1hg",hoffset:"hardware:s1ho"},Hd="slit",Ld={id:Ed,name:Pd,online:Bd,properties:Gd,type:Hd},Ud="s1",Vd="s1",qd=!0,Wd={vgap:"hardware:s1vg",voffset:"hardware:s1vo",hgap:"hardware:",hoffset:"hardware:"},zd="slit",Yd={id:Ud,name:Vd,online:qd,properties:Wd,type:zd},eo={default:kd,horizontal:Ld,vertical:Yd},Kd={default:Jn,state:$d},to={variants:Kd,mocks:eo};function Qd(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(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popid",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.Popover.Body,{children:[e.jsx("h6",{children:"Status"}),e.jsx("pre",{children:t.properties.status}),e.jsx("h6",{children:"Properties"}),e.jsx(i.Container,{children:P.map(s,(r,a)=>e.jsxs(i.Row,{children:[e.jsxs(i.Col,{children:[a,":"]}),e.jsx(i.Col,{children:r})]},a))}),e.jsx("div",{className:"d-grid gap-2",children:e.jsx(i.Button,{disabled:n.disabled,onClick:o,variant:t.properties.state==="ON"?"danger":"success",children:t.properties.state==="ON"?"Off":"On"})})]})]}),children:e.jsx(i.Button,{title:"Pump Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function no(n){const{hardware:t,options:o={}}=n;return e.jsxs("div",{className:"hw-component",children:[e.jsxs("div",{className:"hw-head",children:[e.jsx(N,{name:"Pump",icon:"fam-hardware-pump",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(i.Badge,{bg:t.properties.state==="ON"?"success":"danger",children:t.properties.state})]}),e.jsx("div",{className:"hw-content",children:e.jsxs(i.InputGroup,{children:[e.jsx(i.Form.Control,{value:t.properties.pressure.toExponential(o.precision||3),disabled:!0}),(t.properties.unit||o.unit)&&e.jsx(i.InputGroup.Text,{children:t.properties.unit||o.unit}),e.jsx(Qd,{...n})]})})]})}const Xd=["off","on"],Zd="ip121",Jd="ip121",eu=!0,tu={current:.0003000000142492354,pressure:26000000730164174e-23,state:"ON",status:`Pump is ON
33
- Modes: Step/Protect
34
- ID21/v-var-ctrl/121 - Serial line OK
35
- Pump size: 75-55-40 SC/T
36
- `,voltage:6998},nu="tango",ou=!0,su="pump",ru={callables:Xd,id:Zd,name:Jd,online:eu,properties:tu,protocol:nu,require_staff:ou,type:su},oo={default:ru},iu={default:no},so={variants:iu,mocks:oo};function We(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={RETRACTED:"success",IN_TOUCH:"warning",LOST:"warning",MOVING_IN:"transient",MOVING_OUT:"transient",UNKNOWN:"danger",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(D,{state:o,minWidth:6,variant:r})}function au(n){const{hardware:t}=n;return e.jsx(We,{hardware:t})}function Oe(n){const{text:t,icon:o,leftIcon:s=o,rightIcon:r=o,iconLocation:a="left",onAction:c,onActionChange:l,disabled:f=!1,variant:u,style:d={},className:p=""}=n,[m,g]=h.useState(!1),j=r&&a==="right",x=s&&a==="left";return e.jsx(i.Button,{variant:u,style:d,className:p,onClick:()=>{l==null||l(!0),g(!0),c().finally(()=>{g(!1),l==null||l(!1)})},disabled:f,children:e.jsxs("span",{className:"text-nowrap",children:[x&&e.jsxs(e.Fragment,{children:[e.jsx("i",{className:m?"fa-solid fa-fw fa-cog fa-spin":s})," "]}),t,j&&e.jsxs(e.Fragment,{children:[" ",e.jsx("i",{className:m?"fa-solid fa-fw fa-cog fa-spin":r})]})]})})}function cu(n){const{className:t,hardware:o,options:s={},style:r={},leftToRight:a}=n,{state:c}=o.properties??"OFFLINE",f=!(c==="IN_TOUCH")||n.disabled;function u(d){const{distance:p,style:m}=d;return e.jsx(Oe,{text:`${p}`,style:m,variant:"secondary",onAction:()=>o.actions.call("push",p),disabled:f,leftIcon:"fa fa-fw fa-arrow-left",rightIcon:"fa fa-fw fa-arrow-right",iconLocation:a?"right":"left"})}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",...r},children:[e.jsx(u,{distance:5,style:{gridColumn:a?3:1,gridRow:1}}),e.jsx(u,{distance:.5,style:{gridColumn:2,gridRow:1}}),e.jsx(u,{distance:.05,style:{gridColumn:a?1:3,gridRow:1}}),e.jsx(u,{distance:2,style:{gridColumn:a?3:1,gridRow:2}}),e.jsx(u,{distance:.2,style:{gridColumn:2,gridRow:2}}),e.jsx(u,{distance:.02,style:{gridColumn:a?1:3,gridRow:2}}),e.jsx(u,{distance:1,style:{gridColumn:a?3:1,gridRow:3}}),e.jsx(u,{distance:.1,style:{gridColumn:2,gridRow:3}}),e.jsx(u,{distance:.01,style:{gridColumn:a?1:3,gridRow:3}})]})}function lu(n){const{hardware:t,options:o,disabled:s,leftToRight:r}=n,{state:a}=t.properties??"OFFLINE",c=a==="RETRACTED",l=a==="IN_TOUCH",f=a==="LOST",[u,d]=h.useState(!1);function p(){return c?r?"ms-0":"ms-auto":l?r?"ms-auto":"ms-0":"mx-auto"}const m=p();return e.jsxs("div",{style:{display:"grid",gridTemplateRows:"min-content min-content",gridTemplateColumns:r?"auto min-content":"min-content auto",gridGap:"1px"},children:[e.jsx("i",{className:`${l||f?"fas fa-dizzy":"fa fa-smile"} fa-3x my-auto`,style:{gridColumn:r?2:1,gridRow:1}}),e.jsx(cu,{className:m,...n,style:{gridColumn:r?1:2,gridRow:1}}),e.jsxs(i.ButtonGroup,{className:"mx-auto",style:{width:"12em",gridColumn:r?1:2,gridRow:2},children:[!r&&e.jsx(Oe,{text:"In",onAction:()=>t.actions.call("move_in"),onActionChange:g=>{d(g)},disabled:l||s||u,style:{width:"5em"},iconLocation:"left",icon:"fa fa-fw fa-arrow-left"}),e.jsx(Oe,{text:"Out",onAction:()=>t.actions.call("move_out"),onActionChange:g=>{d(g)},disabled:c||s||u,style:{width:"5em"},leftIcon:"fa fa-fw fa-arrow-left",rightIcon:"fa fa-fw fa-arrow-right"}),r&&e.jsx(Oe,{text:"In",onAction:()=>t.actions.call("move_in"),onActionChange:g=>{d(g)},disabled:l||s||u,style:{width:"5em"},iconLocation:"right",icon:"fa fa-fw fa-arrow-right"})]})]})}function ro(n){const{hardware:t,options:o={}}=n,s=(o.orientation??"left-right")==="left-right",r=e.jsx(N,{name:"Pusher",icon:"fa-hand-point-right",online:t.online}),a=e.jsx(We,{hardware:t});function c(){return e.jsx(lu,{...n,leftToRight:s})}const l=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:c(),headerMode:l})}const du=["move_in","move_out","push","sync_hard"],uu="pusher",fu="pusher",pu=!0,mu={state:"RETRACTED"},hu="bliss",gu=!1,xu="pusher",wu={callables:du,id:uu,name:fu,online:pu,properties:mu,protocol:hu,require_staff:gu,type:xu},io={default:wu};function ao(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState("RETRACTED");async function c(u,d){if(u==="move_in"){a("MOVING_IN"),await H(2e3),a("IN_TOUCH");return}if(u==="move_out"){a("MOVING_OUT"),await H(2e3),a("RETRACTED");return}if(u==="push"){await H(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(W,{name:t,alias:o,type:"pusher",call:c,setProperty:l,properties:f,useHardwareContext:s})}const ju={default:ro,state:au},co={variants:ju,mocks:io,simulator:ao};function Fe(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={STOPPED:"danger",STARTING:"transient",RUNNING:"success",BACKOFF:"warning",STOPPING:"transient",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"fatal",OFFLINE:"secondary"},r=s[o]||s.UNKNOWN;return e.jsx(D,{state:o,minWidth:6,variant:r})}function yu(n){const{hardware:t}=n;return e.jsx(Fe,{hardware:t})}function lo(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Shutter",icon:"fa-cog",online:t.online}),r=e.jsx(Fe,{hardware:t});function a(){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(b){return b.charAt(0).toUpperCase()+b.slice(1).toLowerCase()}const d=f(),p=u(d),g={STOPPED:"danger",STARTING:"transient",RUNNING:"success",BACKOFF:"warning",STOPPING:"transient",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"secondary",OFFLINE:"secondary"}[d]||"danger";function j(){const b=d==="RUNNING"||d==="STARTING";return{icon:b?"fa fa-refresh fa-wp":"fa fa-play fa-wp",variant:n.disabled?"":"success",callback:d==="RUNNING"?c:a,disabled:n.disabled,title:n.operator?b?"Restart the service":"Start the serStaticTextInputvice":"You dont have the control to the session"}}function x(){const b=d==="RUNNING"||d==="STARTING";return{icon:"fa fa-stop fa-wp",variant:n.disabled?"":b?"danger":"secondary",callback:l,disabled:n.disabled,title:n.operator?"Stop the service":"You dont have the control to the session"}}const w=j(),y=x(),_=e.jsxs(i.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(B,{variant:g,className:"text-center",style:{minWidth:"8em"},value:p}),e.jsx(i.Button,{style:{width:"2.5em"},variant:"light",className:`px-0 text-${w.variant}`,onClick:w.callback,disabled:w.disabled,title:w.title,children:e.jsx("i",{className:`${w.icon}`})}),e.jsx(i.Button,{style:{width:"2.5em"},variant:"light",className:`px-0 text-${y.variant}`,onClick:y.callback,disabled:y.disabled,title:y.title,children:e.jsx("i",{className:`${y.icon}`})})]}),$=n.options.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:_,headerMode:$})}function vu(n){var f;const{hardware:t,options:o={}}=n;function s(){t.actions.call("start")}function r(){t.actions.call("restart")}function a(){t.actions.call("stop")}const c=((f=t.properties)==null?void 0:f.state)??"UNKNOWN",l=c==="STOPPING"||c==="STARTING";return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,placement:o.dropDirection==="up"?"top":"bottom",overlay:e.jsx(i.Popover,{id:"service-protected-overlay",children:e.jsxs(i.Popover.Body,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Actions"})}),e.jsx(i.Row,{children:e.jsxs(i.Col,{children:[c==="RUNNING"&&e.jsxs(i.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(i.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(i.Button,{className:`text-${c!=="STOPPED"?"danger":"primary"} border-secondary`,variant:"light",onClick:()=>{a()},disabled:n.disabled,title:"Stop the service",children:[e.jsx("i",{className:"fa fa-stop fa-wp me-1"}),"Stop"]})]})})]})}),children:e.jsx(i.Button,{disabled:n.disabled||l,children:e.jsx("i",{className:`fa fa-caret-${o.dropDirection==="up"?"up":"down"}`})})})}function uo(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Shutter",icon:"fa-cog",online:t.online}),r=e.jsx(Fe,{hardware:t});function a(){return t.properties?t.properties.state:"UNKNOWN"}function c(g){return g.charAt(0).toUpperCase()+g.slice(1).toLowerCase()}const l=a(),u={STOPPED:"danger",STARTING:"transient",RUNNING:"success",BACKOFF:"warning",STOPPING:"transient",EXITED:"secondary",FATAL:"fatal",UNKNOWN:"fatal",OFFLINE:"secondary"}[l],d=c(l),p=e.jsxs(i.InputGroup,{className:"d-flex flex-nowrap",children:[e.jsx(B,{variant:u,style:{minWidth:"10em"},value:d,className:"text-center"}),e.jsx(vu,{...n})]}),m=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:p,headerMode:m})}const Nu=["start","stop","restart"],bu="service1",_u="service1",Su=!0,Cu={state:"RUNNING"},$u="multivisor",Ou=!0,Iu="service",Mu={callables:Nu,id:bu,name:_u,online:Su,properties:Cu,protocol:$u,require_staff:Ou,type:Iu},fo={default:Mu},Du={default:lo,protected:uo,state:yu},po={variants:Du,mocks:fo};function Ne(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:["success","Ready to be used"],IN:["success","The sample is in the beam"],OUT:["danger","The sample is out of the beam"],MOVING_IN:["transient","The sample moving in the beam"],MOVING_OUT:["transient","The sample moving out of the beam"],LOST:["warning","The motion was interrupted between IN and OUT positions"],UNKNOWN:["fatal","The device have an unknown state"]},[r,a]=s[o]||s.UNKNOWN;return e.jsx(D,{state:o,minWidth:6,variant:r,description:a})}function Tu(n){const{hardware:t}=n;return e.jsx(Ne,{hardware:t})}function Fu(n){const{motion:t}=n,s=t.axisRef.slice(9),r=U(s),a=(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:a})}function Ru(n){const{motion:t,actions:o,disabled:s}=n,r=t.axisRef;function a(){o.call("update_axis",{axis_ref:r})}return e.jsx(i.Button,{variant:"danger",onClick:a,disabled:s,children:e.jsx("i",{className:"fa fa-trash"})})}function Au(n){const{motion:t,actions:o,axisRef:s,disabled:r}=n,a=h.useMemo(()=>{for(const d of t)if(d.axisRef===s)return!0;return!1},[t,s]),c=s.slice(9),l=U(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(i.Button,{className:"ms-1",variant:a?"primary":"secondary",onClick:()=>{a||u()},title:a?"This axis is already part of the motion":"Use this axis in the motion",disabled:r,children:f})}function ku(n){var x;const{motion:t,actions:o}=n,s=t.axisRef,r=t.absolute_position??t.relative_position??0,a=s.slice(9),c=U(a),l=n.disabled||!(c!=null&&c.online),f=h.useRef(null),[u,d]=h.useState(!1),p=3,m=((x=c==null?void 0:c.properties)==null?void 0:x.unit)??"";function g(w){if(!f||!f.current)console.log("formRef not yet defined");else if(w.key==="Enter"){d(!1);const y=Number.parseFloat(f.current.value);o.call("update_axis",{axis_ref:s,absolute_position:t.absolute_position!==null?y:null,relative_position:t.relative_position!==null?y:null})}else w.key==="Escape"?(f.current.value=r.toFixed(p),d(!1)):console.log(w.key)}function j(w){const{value:y}=w.target;if(y===void 0)return;const _=Number.parseFloat(y);_!==r&&!u&&d(!0),_===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(i.InputGroup,{className:"w-100",children:[e.jsx(i.Form.Control,{className:u?"form-control-edited":"",type:"number",ref:f,defaultValue:r.toFixed(p),onChange:j,disabled:l,onKeyDown:g}),e.jsx(i.InputGroup.Text,{children:m})]})}function Eu(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 a(){t.call("update_axis",{axis_ref:o.axisRef,relative_position:o.absolute_position??o.relative_position})}return e.jsxs(i.ButtonGroup,{children:[e.jsx(i.Button,{onClick:r,variant:o.absolute_position!==null?"primary":"secondary",disabled:s,children:"Abs"}),e.jsx(i.Button,{onClick:a,variant:o.relative_position!==null?"primary":"secondary",disabled:s,children:"Rel"})]})}function mo(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r={}}=t,a=yo(t),c=e.jsx(N,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),l=e.jsx(Ne,{hardware:t}),f=e.jsxs(i.Container,{children:[e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Move in parallel"}),e.jsx(i.Col,{xs:9,children:r.move_in_parallel?"true":"false"})]}),e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Switch power on/off"}),e.jsx(i.Col,{xs:9,children:r.power_onoff?"true":"false"})]}),e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Settle time"}),e.jsxs(i.Col,{xs:9,children:[r.settle_time.toFixed(2)," ",e.jsx("span",{title:"seconds",children:"s"})]})]}),e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Available axes"}),e.jsx(i.Col,{xs:9,children:r.available_axes.map(d=>e.jsx(Au,{axisRef:d,motion:r.motion,actions:t.actions,disabled:s||!a},d))})]}),e.jsxs(i.Row,{className:"mt-1",children:[e.jsx(i.Col,{xs:3,children:"Actual motion"}),e.jsx(i.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((d,p)=>e.jsxs(h.Fragment,{children:[e.jsx(Fu,{motion:d}),e.jsx(Eu,{motion:d,actions:t.actions,disabled:s||!a}),e.jsx(ku,{motion:d,actions:t.actions,disabled:s||!a}),e.jsx(Ru,{motion:d,actions:t.actions,disabled:s||!a})]},`motion${p}`))]})})]})]}),u=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:c,widgetState:l,widgetContent:f,headerMode:u})}function Pu(n){var b;const{motion:t,actions:o}=n,s=t.axisRef,r=t.absolute_position??t.relative_position??0,a=s.slice(9),c=U(a),l=n.disabled||!(c!=null&&c.online),f=h.useRef(null),[u,d]=h.useState(!1),p=3,m=((b=c==null?void 0:c.properties)==null?void 0:b.unit)??"",g=(c==null?void 0:c.alias)??(c==null?void 0:c.name)??(c==null?void 0:c.id)??"none";function j(v){if(!f||!f.current)console.log("formRef not yet defined");else if(v.key==="Enter"){d(!1);const C=Number.parseFloat(f.current.value);o.call("update_axis",{axis_ref:s,absolute_position:t.absolute_position!==null?C:null,relative_position:t.relative_position!==null?C:null})}else v.key==="Escape"?(f.current.value=r.toFixed(p),d(!1)):console.log(v.key)}function x(v){const{value:C}=v.target;if(C===void 0)return;const I=Number.parseFloat(C);I!==r&&!u&&d(!0),I===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 w(){return t.absolute_position!==null?["ABS","warning","Absolute displacement"]:t.relative_position!==null?["REL","none","Relative displacement"]:["ERR","danger","Unknown motion kind"]}const[y,_,$]=w();return e.jsxs(i.InputGroup,{className:"w-100 flex-nowrap",children:[e.jsx(i.InputGroup.Text,{title:"Displacement to apply on this axis to take a flat",style:{width:"5em"},children:g}),e.jsx(i.InputGroup.Text,{className:`bg-${_}`,title:$,style:{width:"3em"},children:y}),e.jsx(i.Form.Control,{className:u?"form-control-edited":"",type:"number",ref:f,defaultValue:r.toFixed(p),onChange:x,disabled:l,onKeyDown:j}),e.jsx(i.InputGroup.Text,{children:m})]})}function ho(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r={}}=t,a=yo(t),c=e.jsx(N,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),l=e.jsx(Ne,{hardware:t}),f=e.jsxs(e.Fragment,{children:[r.motion.length===0&&e.jsx(i.Alert,{variant:"danger",className:"mb-0",children:"No flat motion defined"}),r.motion.length>0&&e.jsx(i.Stack,{direction:"vertical",children:r.motion.map((d,p)=>e.jsx(Pu,{actions:t.actions,motion:d,disabled:s||!a},d.axisRef))})]}),u=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:c,widgetState:l,widgetContent:f,headerMode:u})}function Bu(n){const{hardware:t,options:o={},disabled:s}=n,{properties:r}=t,{state:a="UNKNOWN"}=r,c=e.jsx(N,{name:"TomoFlatMotion",icon:"fam-hardware-camera",online:t.online}),l=e.jsx(Ne,{hardware:t}),f=a==="IN",u=a==="OUT";function d(){return f?"1 / 3":u?"3 / 5":"2 / 4"}const p=d(),m=f?"fa-face-grin-beam-sweat":"fa-smile",g=f?"The sample is in front of the beam":u?"The sample is out of the beam":"",j=e.jsx("div",{style:{display:"grid",gridGap:0,gridTemplateColumns:"1fr 1fr 1fr 1fr 1fr 1fr",gridTemplateRows:"1fr"},children:e.jsx("i",{className:`fa ${m} fa-3x my-auto mx-auto`,style:{gridColumn:p,gridRow:1},title:g})}),x=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:c,widgetState:l,widgetContent:j,headerMode:x})}const Gu="tomoflatmotion",Hu="tomoflatmotion",Lu=!0,Uu={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}]},Vu="bliss",qu=!1,Wu="tomoflatmotion",zu={id:Gu,name:Hu,online:Lu,properties:Uu,protocol:Vu,require_staff:qu,type:Wu},Yu=["move","stop","wait","rmove"],Ku="sy",Qu="sy",Xu=!0,Zu={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},Ju="bliss",ef=!1,tf="motor",nf=[],of={callables:Yu,id:Ku,name:Qu,online:Xu,properties:Zu,protocol:Ju,require_staff:ef,type:tf,user_tags:nf},sf=["move","stop","wait","rmove"],rf="sy2",af="sy2",cf=!0,lf={offset:0,sign:1,acceleration:300,limits:[-999999999,999999999],position:235.165400001,state:["READY"],tolerance:1e-4,unit:"um",velocity:1e3,display_digits:4},df="bliss",uf=!1,ff="motor",pf=[],mf={callables:sf,id:rf,name:af,online:cf,properties:lf,protocol:df,require_staff:uf,type:ff,user_tags:pf},go={default:zu,sy:of,sy2:mf};function xo(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=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(g=>{if(g.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(g)}),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"){a(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(W,{name:t,alias:o,type:"tomoflatmotion",call:l,setProperty:f,properties:r,useHardwareContext:s})}const hf={default:mo,small:ho,state:Tu,sample_location:Bu},wo={variants:hf,mocks:go,simulator:xo};function jo(n){return n.type==="tomoflatmotion"}function gf(n){const t=G(n);return t===null||!jo(t)?null:t}function yo(n){const{properties:t={}}=n,{state:o="UNKNOWN"}=t;return["IN","READY"].includes(o)}function vo(n){const{hardware:t,options:o={},disabled:s}=n,{actions:r}=t,{label:a}=o,[c,l]=h.useState(void 0),[f,u]=h.useState(!1),d=e.jsx(N,{name:"TomoReferencePositionSchema",icon:"fam-hardware-motor",online:t.online});function p(x){l(void 0),u(!0),r.call("move_to_reference").catch(w=>{l(`${w}`)}).finally(()=>{u(!1)})}const m=e.jsx(e.Fragment,{}),g=e.jsxs(i.Button,{onClick:p,variant:c===void 0?"secondary":"danger",disabled:s||f,className:"w-100",children:[c&&e.jsx("i",{className:"fa-solid fa-triangle-exclamation me-1",title:c}),!c&&f&&e.jsx("i",{className:"fa-solid fa-cog fa-spin me-1"}),a??"Back to reference position"]}),j=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:d,widgetState:m,widgetContent:g,headerMode:j})}function xf(n){return n.type==="tomoreferenceposition"}const wf={default:vo},No={variants:wf};function be(n){const{hardware:t}=n,{online:o,locked:s=null}=t,r=o?(s!==null?"LOCKED":t.properties.state)||"UNKNOWN":"OFFLINE",a={UNKNOWN:"danger",READY:"success",OFFLINE:"secondary",INVALID:"danger",MOUNTING:"transient",UNMOUNTING:"transient",LOCKED:"warning"},c=a[r]||a.UNKNOWN;return e.jsx(D,{state:r,minWidth:6,variant:c})}function jf(n){const{hardware:t}=n;return e.jsx(be,{hardware:t})}function yf(n){const{hardware:t,options:o={}}=n;function s(a){return t.actions?t.actions.setProperty("sample_pixel_size_mode",a):console.error("Change request was triggered with:",a),null}const r=t.properties.sample_pixel_size_mode;return e.jsx(i.Dropdown,{style:n.style,children:e.jsxs(i.ButtonGroup,{children:[e.jsx(i.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(i.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 vf(n){const{hardware:t,options:o={}}=n,s=t.properties.user_sample_pixel_size||0,{state:r}=t.properties,a=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(me,{hardwareValue:s,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:a,hardwareIsMoving:!1,readOnly:t.properties.sample_pixel_size_mode!=="USER"})}function Nf(n){const{hardware:t,options:o={}}=n;return t.properties.state,e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:n.disabled,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Mode"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsx(yf,{...n,style:{width:"100%"}})})}),e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center mt-1",children:"User pixel size"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsxs(i.InputGroup,{children:[e.jsx(vf,{...n}),e.jsx(i.InputGroup.Text,{children:"um"})]})})})]})})]})}function bf(n,t,o){return h.useMemo(()=>{function s(c){return c==="um"?"μm":c}function r(c){return c.toFixed(3).replace(/\.?0+$/,"")}if(n==null)return["∅",""];if(t===o)return[r(n),s(o)];const a=dt.default(n,t);return[r(a.to(o).scalar),s(o)]},[n,t,o])}function bo(n){const{hardware:t,options:o={}}=n,s=o.display_unit??"um",r=e.jsx(N,{name:"TomoDetector",icon:"fa-cog",online:t.online}),a=e.jsx(be,{hardware:t}),[c,l]=bf(t.properties.sample_pixel_size,"um",s),f=e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(i.InputGroup.Text,{className:"justify-content-center",style:{minWidth:"4em"},children:t.properties.sample_pixel_size_mode}),e.jsx(B,{value:c,title:`${t.properties.sample_pixel_size} um`}),e.jsx(i.InputGroup.Text,{children:l}),e.jsx(Nf,{...n})]}),u=n.options?n.options.header:"top";return e.jsx(S,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:f,headerMode:u})}function de(n,t,o,s){if(t===o)return n;if(t==="rad"&&o==="deg")return 180*n/Math.PI;if(t==="deg"&&o==="rad")return Math.PI*n/180;if(t==="px"){if(s!==void 0){const r=s.to("mm").scalar;return de(n*r,"mm",o,void 0)}return Number.NaN}if(o==="px"){if(s!==void 0){const r=de(n,t,"mm",void 0),a=s.to("mm").scalar;return r/a}return Number.NaN}try{return dt.default(n,t).to(o).scalar}catch{return console.error(`Convertion ${t}->${o} is not provided`),Number.NaN}}function _o(n){return n.startsWith("u")?`μ${n.slice(1)}`:n}function le(n){return!n||!n.startsWith("hardware:")?null:n.slice(9)}function _f(n){const{hardware:t,options:o={}}=n,{properties:s={}}=t,{sample_pixel_size:r,detector:a=null}=s,c=cn(le(a)),{properties:l={}}=c??{},{size:f}=l,u=o.display_unit??"mm",d=o.digits??3,p=e.jsx(N,{name:"TomoDetector",icon:"fa-eye",online:t.online}),m=e.jsx(be,{hardware:t}),g=h.useMemo(()=>{if(r==null||f===null||f===void 0)return"∅";const w=de(f[0]*r,"um",u),y=de(f[1]*r,"um",u);return`${w.toFixed(d)} × ${y.toFixed(d)}`},[r,f,u,d]),j=e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(B,{value:g}),e.jsx(i.InputGroup.Text,{children:_o(u)})]}),x=n.options?n.options.header:"top";return e.jsx(S,{hardware:t,widgetIcon:p,widgetState:m,widgetContent:j,headerMode:x})}function Sf(n){const{hardware:t,options:o={}}=n;function s(a){return t.actions?t.actions.setProperty("acq_mode",a):console.error("Change request was triggered with:",a),null}const r=t.properties.acq_mode;return e.jsx(i.Dropdown,{style:n.style,children:e.jsxs(i.ButtonGroup,{children:[e.jsx(i.Button,{variant:r==="SINGLE"?"primary":"secondary",onClick:()=>{s("SINGLE")},disabled:n.disabled,title:"Do acquisition in a single shot",children:"SINGLE"}),e.jsx(i.Button,{variant:r==="ACCUMULATION"?"primary":"secondary",onClick:()=>{s("ACCUMULATION")},disabled:n.disabled,title:"Do acqisition in multiple sub frame with accumulation",children:"ACCU"})]})})}function Cf(n){const{hardware:t,actions:o}=n,s=t.properties.acc_max_expo_time||0,{state:r}=t.properties,a=r==="READY";function c(l){return o.setProperty("acc_max_expo_time",l),null}return e.jsx(me,{hardwareValue:s,onMoveRequested:c,hardwareIsDisabled:!1,hardwareIsReady:a,hardwareIsMoving:!1,readOnly:t.properties.state!=="READY"})}function $f(n){const t=G(n);return t!==null&&xe(t)?t:null}function Of(n){var c;const{hardware:t}=n,{properties:o}=t,s=((c=o.detector)==null?void 0:c.slice(9))??"",r=$f(s),a=oe(s);return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:n.disabled,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:e.jsxs(i.Container,{children:[e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center",children:"Acquisition mode"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:e.jsx(Sf,{...n,style:{width:"100%"}})})}),e.jsx(i.Row,{children:e.jsx(i.Col,{className:"text-center mt-1",children:"Max sub frame exposition"})}),e.jsx(i.Row,{children:e.jsx(i.Col,{children:r&&e.jsxs(i.InputGroup,{children:[e.jsx(Cf,{hardware:r,actions:a}),e.jsx(i.InputGroup.Text,{children:"um"})]})})})]})})]})}function So(n){const{hardware:t}=n,o=e.jsx(N,{name:"TomoDetector",icon:"fa-cog",online:t.online}),s=e.jsx(be,{hardware:t}),r=e.jsxs(i.InputGroup,{className:"flex-nowrap",children:[e.jsx(B,{value:t.properties.acq_mode}),e.jsx(Of,{...n})]}),a=n.options?n.options.header:"top";return e.jsx(S,{hardware:t,widgetIcon:o,widgetState:s,widgetContent:r,headerMode:a})}const If="tomodet1",Mf="tomodet1",Df=!0,Tf={state:"READY",sample_pixel_size_mode:"AUTO",user_sample_pixel_size:50,sample_pixel_size:48,detector:"hardware:det1",optic:"hardware:opt1",source_distance:10,acq_mode:"SINGLE"},Ff="bliss",Rf=!1,Af="tomodetector",kf={id:If,name:Mf,online:Df,properties:Tf,protocol:Ff,require_staff:Rf,type:Af},Co={default:kf},Ef={samplepixelsize:bo,acquisitionmode:So,fieldofview:_f,state:jf},$o={variants:Ef,mocks:Co};function ze(n){return n.type==="tomodetector"}function Pf(n){const t=G(n);return t===null||!ze(t)?null:t}function Ye(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOUNTING:"transient",UNMOUNTING:"transient",UNKNOWN:"fatal",OFFLINE:"warning"},r=s[o]||s.UNKNOWN;return e.jsx(D,{state:o,minWidth:6,variant:r})}function Bf(n){const{hardware:t}=n;return e.jsx(Ye,{hardware:t})}function Gf(n){const{hardware:t}=n,{properties:o}=t,{detectors:s}=o,r=le(o.active_detector),a=le(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=le(d),g=p===(a||r)?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o";return e.jsxs(i.Dropdown.Item,{disabled:l,onClick:()=>{f(p)},children:[e.jsx("i",{className:g}),"  ",p]},d)}return e.jsxs(i.Dropdown,{children:[e.jsx(i.Dropdown.Toggle,{disabled:l,variant:"secondary"}),e.jsx(i.Dropdown.Menu,{popperConfig:{strategy:"fixed"},children:s.map(d=>u(d))})]})}function Oo(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"Optic",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(Ye,{hardware:t}),{properties:a}=t,c=a.state==="MOUNTING",l=le(a.active_detector),f=le(a.target_detector);function u(){return e.jsxs(i.InputGroup,{children:[e.jsx(B,{className:V.default({"hw-moving":c}),value:f||l||"No detector"}),e.jsx(Gf,{...n})]})}const d=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:u(),headerMode:d})}const Hf="tomodetectors",Lf="tomodetectors",Uf=!0,Vf={state:"READY",active_detector:"hardware:limadetector1",detectors:["hardware:limadetector1","hardware:limadetector2","hardware:limadetector3"]},qf="bliss",Wf=!1,zf="optic",Yf={id:Hf,name:Lf,online:Uf,properties:Vf,protocol:qf,require_staff:Wf,type:zf},Io={default:Yf},Kf={default:Oo,state:Bf},Mo={variants:Kf,mocks:Io};function Do(n){return n.type==="tomodetectors"}function Qf(n){const t=G(n);return t===null||!Do(t)?null:t}function ae(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",BLOCKED:"secondary",ACQUIRING:"transient",UNKNOWN:"fatal"},r=s[o]||s.UNKNOWN;return e.jsx(D,{state:o,minWidth:6,variant:r})}function Xf(n){const{hardware:t}=n;return e.jsx(ae,{hardware:t})}function Zf(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 a(c){t.actions.setProperty("update_on_move",!0)}return e.jsxs(i.ButtonGroup,{className:"me-2",children:[e.jsx(i.InputGroup.Text,{children:"Update mode"}),e.jsx(i.Button,{onClick:a,disabled:s,variant:o?"primary":"secondary",children:"Auto"}),e.jsx(i.Button,{onClick:r,disabled:s,variant:o?"secondary":"primary",children:"Off"})]})}function Jf(n){const{hardware:t}=n,o=t.properties.exposure_time??0,s=n.disabled||!t.online,r=h.useRef(null),[a,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&&!a&&c(!0),m===o&&a&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):a||(r.current.value=o.toFixed(l))},[a,o]),e.jsxs(i.InputGroup,{className:"me-2",children:[e.jsx(i.InputGroup.Text,{children:"Exposure time"}),e.jsx(i.Form.Control,{className:a?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:u,disabled:s,onKeyDown:f}),e.jsx(i.InputGroup.Text,{children:"s"})]})}function ep(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 a(c){t.actions.call("take_flat")}return e.jsxs(i.ButtonGroup,{size:"lg",className:"me-2",children:[e.jsx(i.InputGroup.Text,{children:"Take"}),e.jsx(i.Button,{onClick:s,disabled:o,variant:"primary",children:"Proj"}),e.jsx(i.Button,{onClick:a,disabled:o,variant:"primary",children:"Flat"}),e.jsx(i.Button,{onClick:r,disabled:o,variant:"primary",children:"Dark"})]})}function To(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(ae,{hardware:t}),a=e.jsxs(i.Container,{children:[e.jsx(i.Row,{className:"mt-1",children:e.jsx(i.Col,{children:e.jsx(Zf,{hardware:t,disabled:n.disabled})})}),e.jsx(i.Row,{className:"mt-1",children:e.jsx(i.Col,{children:e.jsx(Jf,{hardware:t,disabled:n.disabled})})}),e.jsx(i.Row,{className:"mt-1",children:e.jsx(i.Col,{children:e.jsx(ep,{hardware:t,disabled:n.disabled})})})]}),c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function tp(n){const{style:t,className:o,value:s,decimals:r=2,allowNullAsEmpty:a=!1,disabled:c=!1}=n,[l,f]=h.useState(void 0),u=l!==void 0,d=h.useMemo(()=>n.preferedDisplayUnit!==void 0&&(n.pixelSize===void 0||n.unit==="px"||n.preferedDisplayUnit==="px")?n.preferedDisplayUnit:n.displayUnit??n.unit,[n.displayUnit,n.unit,n.preferedDisplayUnit,n.pixelSize]),p=h.useCallback(y=>y===null||d===void 0?null:de(y,d,n.unit,n.pixelSize),[n.unit,d,n.pixelSize]),m=h.useCallback(y=>y===null||d===void 0?null:de(y,n.unit,d,n.pixelSize),[n.unit,d,n.pixelSize]);function g(y){return(y??"")===""?null:Number.parseFloat(y)}function j(){var $;if(l===void 0||!a&&l==="")return;let y;try{y=g(l)}catch{return}const _=p(y);($=n.onAccepted)==null||$.call(n,_),f(void 0)}function x(){var y;l!==void 0&&((y=n.onAborted)==null||y.call(n),f(void 0))}const w=h.useMemo(()=>{const y=m(s);return y===null?"":y.toFixed(r)},[s]);return e.jsx(i.Form.Control,{value:l??w??void 0,className:o,step:n.step,type:"number",style:{...t,backgroundColor:u?"#FFFF80":void 0},disabled:c,onChange:y=>{f(y.target.value)},onBlur:()=>{x()},onKeyDown:y=>/^[ a-z]$/i.test(y.key)?(y.preventDefault(),!1):(y.stopPropagation(),y.key==="Enter"?j():y.key==="Escape"&&x(),!0)})}function np(n){const{onAccepted:t,...o}=n;return e.jsx(tp,{...o,allowNullAsEmpty:!1,onAccepted:t})}function op(n){const{hardware:t,options:o}=n,s=t.properties.exposure_time??0,r=n.disabled||!t.online,a=o.unit??"s",c=o.digits??3;return e.jsxs(i.InputGroup,{className:"w-100",children:[e.jsx(np,{value:s,unit:"s",displayUnit:o.unit??"s",onAccepted:l=>{t.actions.setProperty("exposure_time",l)},decimals:c,disabled:r}),e.jsx(i.InputGroup.Text,{children:_o(a)})]})}function sp(n){const{exposureTime:t}=n,o=G("ACTIVE_TOMOCONFIG.ref.detectors.active_detector.detector"),s=G("ACTIVE_TOMOCONFIG.ref.detectors.active_detector");if(o===null||s===null)return e.jsx(e.Fragment,{});if(!xe(o)||!ze(s))return e.jsx(e.Fragment,{});const r=o.properties.acc_max_expo_time,a=s.properties.acq_mode;if(!r||a!=="ACCUMULATION")return e.jsx(e.Fragment,{});const[c,l]=ln(t,r);return e.jsxs("div",{className:"text-center",title:"Decompisiton of the accumulation",children:[c," × ",l.toFixed(3)]})}function Fo(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(ae,{hardware:t}),a=e.jsxs(e.Fragment,{children:[e.jsx(op,{hardware:t,disabled:n.disabled,options:o}),e.jsx(sp,{exposureTime:t.properties.exposure_time})]}),c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function rp(n){const{hardware:t}=n,o=t.properties.settle_time||0,s=n.disabled||!t.online,r=h.useRef(null),[a,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&&!a&&c(!0),m===o&&a&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):a||(r.current.value=o.toFixed(l))},[a,o]),e.jsxs(i.InputGroup,{className:"w-100",children:[e.jsx(i.Form.Control,{className:a?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:u,disabled:s,onKeyDown:f}),e.jsx(i.InputGroup.Text,{children:"s"})]})}function Ro(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(ae,{hardware:t}),a=e.jsx(rp,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function Ae(n){const[t,o]=h.useState(!1),[s,r]=h.useState(void 0),{text:a,disabled:c,onAction:l,onStarted:f,onTerminated:u,title:d}=n;function p(m){f==null||f(),r(void 0),o(!0),l().catch(g=>{r(`${g}`)}).finally(()=>{o(!1),u==null||u()})}return e.jsxs(i.Button,{onClick:p,disabled:c||t,variant:s===void 0?"primary":"danger",className:V.default({"ps-4":!t,"pe-4":!t}),title:d,children:[s&&e.jsx("i",{className:"fa-solid fa-triangle-exclamation me-1",title:s}),!s&&t&&e.jsx("i",{className:"fa-solid fa-cog fa-spin me-1"}),a]})}function ip(){const n=G("ACTIVE_TOMOCONFIG.ref.detectors.active_detector.detector");return n===null||!xe(n)?null:n}function ap(n){const{hardware:t,restoreSample:o}=n,[s,r]=h.useState(!1),a=n.disabled||!t.online||s,c=ip(),l=(c==null?void 0:c.properties.state)==="OFFLINE";function f(){r(!0)}function u(){r(!1)}function d(){return t.actions.call("take_proj")}function p(){return t.actions.call("take_dark")}function m(){return t.actions.call(o?"take_flat":"take_flat_and_stay")}return e.jsxs(i.ButtonGroup,{size:"lg",className:"w-100",title:l?`The detector '${c==null?void 0:c.name}' is offline`:void 0,children:[e.jsx(Ae,{onAction:d,onStarted:f,onTerminated:u,disabled:a||l,text:"Proj",title:"Take a projection"}),e.jsx(Ae,{onAction:m,onStarted:f,onTerminated:u,disabled:a||l,text:"Flat",title:"Take a flat"}),e.jsx(Ae,{onAction:p,onStarted:f,onTerminated:u,disabled:a||l,text:"Dark",title:"Take a dark"})]})}function Ao(n){const{hardware:t,options:o={}}=n,{restore_sample:s=!0}=o,r=e.jsx(N,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),a=e.jsx(ae,{hardware:t}),c=e.jsx(ap,{hardware:t,disabled:n.disabled,restoreSample:s}),l=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:r,widgetState:a,widgetContent:c,headerMode:l})}function cp(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 a(c){t.actions.setProperty("update_on_move",!0)}return e.jsxs(i.ButtonGroup,{className:"w-100",children:[e.jsx(i.Button,{onClick:a,disabled:s,variant:o?"primary":"secondary",children:"Auto"}),e.jsx(i.Button,{onClick:r,disabled:s,variant:o?"secondary":"primary",children:"Off"})]})}function ko(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(ae,{hardware:t}),a=e.jsx(cp,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const lp="tomoimaging",dp="tomoimaging",up=!0,fp={state:"READY",update_on_move:!1,exposure_time:1},pp="bliss",mp=!1,hp="optic",gp={id:lp,name:dp,online:up,properties:fp,protocol:pp,require_staff:mp,type:hp},Eo={default:gp};function Po(n){const{name:t,alias:o,useHardwareContext:s}=n,[r,a]=h.useState({state:"READY",update_on_move:!0,exposure_time:1,settle_time:0});function c(u){a(d=>({...d,state:u}))}async function l(u,d){if(u==="take_dark"){c("ACQUIRING"),await H(2e3),c("READY");return}if(u==="take_flat"){c("ACQUIRING"),await H(2e3),c("READY");return}if(u==="take_proj"){c("ACQUIRING"),await H(2e3),c("READY");return}console.log("TomoImagingSimulator: Unsupported call",u,d)}async function f(u,d){a(p=>({...p,[u]:d}))}return e.jsx(W,{name:t,alias:o,type:"tomoimaging",call:l,setProperty:f,properties:r,useHardwareContext:s})}const xp={default:To,exposuretime:Fo,settletime:Ro,actions:Ao,updatemode:ko,state:Xf},Bo={variants:xp,mocks:Eo,simulator:Po},wp={},Go={variants:wp};function Ho(n){return n.type==="tomosamplestage"}function jp(n){const t=G(n);return t===null||!Ho(t)?null:t}function yp(n){const{hardware:t}=n,o=t.properties.latency_time||0,s=n.disabled||!t.online,r=h.useRef(null),[a,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&&!a&&c(!0),m===o&&a&&c(!1)}return h.useEffect(()=>{!r||!r.current?console.log("formRef not yet defined"):a||(r.current.value=o.toFixed(l))},[a,o]),e.jsxs(i.InputGroup,{className:"w-100",children:[e.jsx(i.Form.Control,{className:a?"form-control-edited":"",type:"number",ref:r,defaultValue:o.toFixed(l),onChange:u,disabled:s,onKeyDown:f}),e.jsx(i.InputGroup.Text,{children:"s"})]})}function Lo(n){const{hardware:t,options:o={}}=n,s=e.jsx(N,{name:"TomoImaging",icon:"fam-hardware-camera",online:t.online}),r=e.jsx(e.Fragment,{}),a=e.jsx(yp,{hardware:t,disabled:n.disabled}),c=o.header||"top";return e.jsx(S,{hardware:t,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const vp={latencytime:Lo},Uo={variants:vp};function Vo(n){return n.type==="tomoconfig"}function Np(n){const t=G(n);return t===null||!Vo(t)?null:t}function qo(n){const{hardware:t}=n,o=t.online?t.properties.state:"OFFLINE",s={READY:"success",MOVING:"transient",STABILIZING:"transient",INVALID:"danger",INVALID_DETECTOR_BINNING_CHANGED:"danger",INVALID_DETECTOR_DISTANCE_CHANGED:"danger",INVALID_DETECTOR_CHANGED:"danger"},r=s[o]||s.UNKNOWN;return e.jsx(D,{state:o,minWidth:6,variant:r})}function bp(n){const{hardware:t}=n;return e.jsx(qo,{hardware:t})}const _p={state:bp},Wo={variants:_p};function zo(n){return n.type==="tomoholo"}function Sp(n){const t=G(n);return t===null||!zo(t)?null:t}function Cp(n){const{hardware:t}=n,o=()=>{t.actions.call("reset")};return e.jsx(i.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"popover",children:[e.jsxs(i.Popover.Header,{children:[t.name," Details"]}),e.jsxs(i.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(i.Button,{disabled:n.disabled,onClick:o,children:"Reset"})})]})]}),children:e.jsx(i.Button,{className:"flex-grow-0",title:"Valve Details",children:e.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Yo(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(N,{name:"Valve",icon:"fam-hardware-valve",online:t.online}),e.jsx("div",{className:"name",children:t.name}),e.jsx(i.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(i.ButtonGroup,{className:"d-flex",children:[e.jsx(i.Button,{variant:t.properties.state==="OPEN"?"danger":"success",onClick:s,disabled:n.disabled,children:t.properties.state==="OPEN"?"Close":"Open"}),e.jsx(Cp,{...n})]})})]})}const $p=["close","reset","open"],Op="rv12",Ip="rv12",Mp=!0,Dp={state:"CLOSED",status:`Pneumatic is closed
37
- `},Tp="tango",Fp=!1,Rp="valve",Ap={callables:$p,id:Op,name:Ip,online:Mp,properties:Dp,protocol:Tp,require_staff:Fp,type:Rp},Ko={default:Ap},kp={default:Yo},Qo={variants:kp,mocks:Ko},Ep=Ge.default("daiquiri.components.hardware.NoObject");function Pp(n){if(n.options.emptyifnone)return Ep('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const t=e.jsx(N,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),s=e.jsx("span",{title:`Object '${n.name}' is missing`,children:"Missing"}),r=n.options?n.options.header:"top",a={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(S,{hardware:a,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}function Bp(n){const t=e.jsx(N,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),s=e.jsx("span",{title:`Object '${n.name}' is loading`,children:e.jsx("i",{className:"fa-solid fa-spinner fa-spin-pulse"})}),r=n.options?n.options.header:"top",a={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(S,{hardware:a,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}const Gp=Ge.default("daiquiri.components.hardware.MissingObject");function Hp(n){if(n.options.emptyifnone)return Gp('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const t=e.jsx(N,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),s=e.jsx("span",{title:`Object '${n.name}' is missing`,children:"Missing"}),r=n.options?n.options.header:"top",a={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(S,{hardware:a,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}function Lp(n){const{properties:t={}}=n,{message:o="Unknown error"}=t,s=e.jsx(N,{name:"NoObject",icon:"fam-hardware-any",online:!1}),r=e.jsx(e.Fragment,{}),a=e.jsx(i.OverlayTrigger,{trigger:["focus","hover"],placement:"bottom",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"error",style:{maxWidth:500},children:[e.jsx(i.Popover.Header,{children:"Error"}),e.jsx(i.Popover.Body,{children:e.jsx("ul",{children:e.jsx("li",{children:o})})})]}),children:e.jsxs(i.Button,{variant:"danger",size:"sm",className:"w-100",children:[e.jsx("i",{className:"fa fa-exclamation-triangle"})," Error"]})}),c=n.options?n.options.header:"top",l={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(S,{hardware:l,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}const Up=Ge.default("daiquiri.components.hardware.MissingComponentObject");function Vp(n){const{options:t}=n,{variant:o="default"}=t;if(t.emptyifnone)return Up('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',n.id,n.name),e.jsx(e.Fragment,{});const s=e.jsx(N,{name:"NoObject",icon:"fam-hardware-any",online:!1}),r=e.jsx(e.Fragment,{}),a=e.jsx(i.OverlayTrigger,{trigger:["focus","hover"],placement:"bottom",rootClose:!0,overlay:e.jsxs(i.Popover,{id:"error",style:{maxWidth:500},children:[e.jsx(i.Popover.Header,{children:"Error"}),e.jsx(i.Popover.Body,{children:e.jsx("ul",{children:e.jsxs("li",{children:["No component available for object id '",n.name,"' (type '",n.type,"' and/or variant '",o,"' are not registred)"]})})})]}),children:e.jsxs(i.Button,{variant:"danger",size:"sm",className:"w-100",children:[e.jsx("i",{className:"fa fa-exclamation-triangle"})," Error"]})}),c=t?t.header:"top",l={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(S,{hardware:l,widgetIcon:s,widgetState:r,widgetContent:a,headerMode:c})}function qp(n){if(n.options.emptyifnone)return e.jsx(e.Fragment,{});const t=e.jsx(N,{name:"NoObject",icon:"fam-hardware-any",online:!1}),o=e.jsx(e.Fragment,{}),s=e.jsx(e.Fragment,{children:"No object"}),r=n.options?n.options.header:"top",a={id:n.id,name:n.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return e.jsx(S,{hardware:a,widgetIcon:t,widgetState:o,widgetContent:s,headerMode:r})}function Xo(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 Wp(n){const{size:t,value:o,min:s,max:r,lowWarning:a,hiWarning:c,lowDanger:l,hiDanger:f}=n;function u(w){return w===null?null:(w-s)/(r-s)}const d=h.useMemo(()=>{const w=l===void 0?void 0:u(l),y=f===void 0?void 0:u(f),_=a===void 0?void 0:u(a),$=c===void 0?void 0:u(c);return{lowPercentDanger:w,hiPercentDanger:y,lowPercentWarning:_,hiPercentWarning:$}},[s,r,a,c,l,f]),p=h.useMemo(()=>o===null?"value":l!==void 0&&o<=l||f!==void 0&&o>=f?"value value-danger":a!==void 0&&o<=a||c!==void 0&&o>=c?"value value-warning":"value",[o,l,f,a,c]),m=t/2-15,g=t/10,j=t/10*3;function x(w){return g+(j-g)*w}return e.jsxs(k.Knob,{size:t,angleOffset:240,angleRange:240,min:s,max:r,value:o,readOnly:!0,className:"gauge",children:[d.lowPercentDanger&&e.jsx(k.Power,{radiusFrom:m,radiusTo:m,className:"range range-danger",percentageFrom:0,percentageTo:d.lowPercentDanger,widthFrom:x(0),widthTo:x(d.lowPercentDanger)}),d.lowPercentWarning&&e.jsx(k.Power,{radiusFrom:m,radiusTo:m,className:"range range-warning",percentageFrom:d.lowPercentDanger??0,percentageTo:d.lowPercentWarning,widthFrom:x(d.lowPercentDanger??0),widthTo:x(d.lowPercentWarning)}),e.jsx(k.Power,{radiusFrom:m,radiusTo:m,className:"range",percentageFrom:d.lowPercentWarning??d.lowPercentDanger??0,percentageTo:d.hiPercentWarning??d.hiPercentDanger??1,widthFrom:x(d.lowPercentWarning??d.lowPercentDanger??0),widthTo:x(d.hiPercentWarning??d.hiPercentDanger??1)}),d.hiPercentWarning&&e.jsx(k.Power,{radiusFrom:m,radiusTo:m,className:"range range-warning",percentageFrom:d.hiPercentWarning,percentageTo:d.hiPercentDanger??1,widthFrom:x(d.hiPercentWarning),widthTo:x(d.hiPercentDanger??1)}),d.hiPercentDanger&&e.jsx(k.Power,{radiusFrom:m,radiusTo:m,className:"range range-danger",percentageFrom:d.hiPercentDanger,percentageTo:1,widthFrom:x(d.hiPercentDanger),widthTo:x(1)}),e.jsx("circle",{r:t/20,cx:t/2,cy:t/2,fill:"black"}),e.jsx(k.Pointer,{percentage:u(o),width:10,height:t/2-15,radius:2,type:"triangle",color:"black"}),e.jsx(k.Value,{className:p,value:o})]})}function zp(n){return e.jsx("div",{className:"panel-header",style:n.style,children:n.children})}function Yp(n){return e.jsx("div",{className:`panel-contents ${n.className}`,style:n.style,children:n.children})}function R(n){const t=n.scroll?Xo:h.Fragment;return e.jsx("div",{className:`panel ${n.className??""}`,style:n.style,children:e.jsx(t,{children:n.children})})}R.Header=zp;R.Contents=Yp;function Zo(n){return e.jsx(e.Fragment,{})}function Kp(n){const{providers:t={},yamlNode:o,label:s,...r}=n;return ts(o,"label",s),fe(o,r),e.jsx("div",{children:s})}function Qp({yamlNode:n,panel:t}){const{type:o,style:s,children:r,...a}=n;return fe(n,a),e.jsx(i.Row,{className:"ymllayout-row gx-0",style:s,children:P.map(r,(c,l)=>q(c,l,t))})}function Xp({yamlNode:n,panel:t}){const{type:o,style:s,xs:r,children:a,...c}=n;return fe(n,c),ns(n,"xs",r),e.jsx(i.Col,{className:V.default("yamymllayout-col",{col:!!r}),style:s,xs:r,children:P.map(n.children,(l,f)=>q(l,f,t))})}function Zp({yamlNode:n,panel:t}){const o=n.options||{},s=n.style;return e.jsx(i.Container,{className:"ymllayout-container",...o,style:s,children:P.map(n.children,(r,a)=>q(r,a,t))})}function Jp(n){const{yamlNode:t}=n,o=t.options||{},s={};return t.centerContent&&(s.margin="auto"),e.jsxs(R,{className:"ymllayout-panel",...o,style:t.style,children:[t.title&&e.jsx(R.Header,{children:t.title}),e.jsx(R.Contents,{style:s,children:P.map(t.children,(r,a)=>q(r,a,!1))})]})}const em=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15);function tm({yamlNode:n,panel:t}){const o=[];return P.each(n.children,(s,r)=>{o.push(e.jsx(i.Tab,{eventKey:em(),title:s.title,style:s.style,children:q(s,0,!1)},r))}),t?e.jsxs(R,{className:"ymllayout-tabs",style:n.style,children:[n.title&&e.jsx(R.Header,{children:n.title}),e.jsx(R.Contents,{children:e.jsx(i.Tabs,{mountOnEnter:!0,children:o})})]}):e.jsx(i.Tabs,{children:o})}function nm(n){const{node:t,state:o,row:s}=n,{title:r}=t;function a(){if(t.id)return t.id}function c(){if(r!==void 0)return r;if(t.type==="hardware"){const f=a(),u={_parentNode:t._parentNode,_indexFromParent:t._indexFromParent,type:"hardware",id:f,variant:"name",emptyifnone:!0};return q(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 om(n){const{node:t,row:o}=n,{titlealign:s,title:r,stateinheader:a=!1,variant:c,id:l,...f}=t;let u,d;if(f.type==="hardware")if(u={...f,id:l,variant:c},a){const p={...f,id:l,variant:"state",emptyifnone:!0};d=q(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(nm,{node:t,state:d,row:o})}),e.jsx("div",{style:{gridColumn:2,alignSelf:"center",overflow:"auto"},children:q(u,"k",!1)})]})}function sm(n){const{yamlNode:t,panel:o}=n,{type:s,children:r,options:a={},title:c,style:l,...f}=t;return fm(t,f),e.jsxs(R,{className:"ymllayout-form",...a,children:[t.title&&e.jsx(R.Header,{children:t.title}),e.jsx(R.Contents,{className:"full-sizer",style:{overflow:"auto"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"min-content auto",...l},children:P.map(r,(u,d)=>u.type==="formheader"?q(u,d,o):u.type==="none"?e.jsx(ys.default.Fragment,{},d):e.jsx(om,{node:u,row:d},d))})})]})}function rm({yamlNode:n}){const{type:t,title:o,style:s={},...r}=n;return Ke(n,"title",o),fe(n,r),e.jsx("div",{className:"ymllayout-form-header",style:{gridColumn:"1 / 3",...s},children:e.jsx("h3",{children:o})})}function im(n){const{yamlNode:t,panel:o}=n,s=t.style||{};return e.jsx("div",{className:"ymllayout-grid",style:{gridTemplateColumns:t.columns,gridTemplateRows:t.rows,...s},children:P.map(t.children,(r,a)=>{const{columnSpan:c=1,rowSpan:l=1,...f}=r,u=c>1?`span ${c}`:void 0,d=l>1?`span ${l}`:void 0;return e.jsx("div",{className:"ymllayout-grid-cell",style:{gridColumn:u,gridRow:d},children:q(f,a,o)},a)})})}const re={row:Qp,col:Xp,container:Zp,panel:Jp,tabs:tm,form:sm,formheader:rm,grid:im};function am(n,t){ie[n]&&console.warn(`yaml registration: The type ${n} is already a component. The component will not be reachable anymore.`),re[n]&&console.warn(`yaml registration: The type ${n} is already a container. The previous container will be dropped.`),re[n]=t}const ie={todo:os,none:Zo,label:Kp};function Jo(n,t){ie[n]&&console.warn(`yaml registration: The type ${n} is already a component. The previous component will be dropped.`),re[n]&&console.warn(`yaml registration: The type ${n} is already a container. This component will not be used.`),ie[n]=t}function cm(n){Object.entries(n).forEach(([t,o])=>Jo(t,o))}function lm(){return ie}function dm(){return re}function um(n){const{yamlNode:t,panel:o}=n,{type:s,style:r,scroll:a,title:c,...l}=t;if(!(s in ie))return e.jsx(R,{children:e.jsx(R.Contents,{children:e.jsxs(i.Alert,{variant:"warning",children:['Unknown component "',s,'"']})})});const f=ie[t.type];return o?e.jsx(R,{style:r,scroll:a,children:e.jsxs(h.Suspense,{fallback:e.jsx("p",{children:"Loading..."}),children:[c&&e.jsx(R.Header,{children:c}),e.jsx(R.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 q(n,t,o=!0){if(!n)return e.jsx(e.Fragment,{});const{type:s}=n,r=s&&s in re?re[s]:um;return e.jsx(r,{yamlNode:n,panel:o},t)}function fm(n,t){const{_parentNode:o,_indexFromParent:s,...r}=t;if(n&&Object.keys(r).length>0)throw new he(n,Object.keys(r))}class se extends Error{constructor(o,s){super(o);ne(this,"yamlNode");this.yamlNode=s}}class he extends se{constructor(o,s){super(`Unexpected keys: ${s.join(", ")}`,o);ne(this,"keys");this.keys=s}}class Ie extends se{constructor(o,s){super(`Keys ${s.join(", ")} are missing`,o);ne(this,"keys");this.keys=s}}class T extends se{constructor(o,s,r){super(`Key ${s} error: ${r}`,o);ne(this,"key");ne(this,"keyMessage");this.key=s,this.keyMessage=r}}function pm(n){let t=n;for(;t._parentNode;)t=t._parentNode;return t}function mm(n){const t=[];let o=n;for(;o;)t.push({node:o,indexFromParent:o._indexFromParent}),o=o._parentNode;return t.reverse(),t}function es(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((a,c)=>es(a,s,c))}return Object.freeze(s),s}function hm(n,t,o){if(n&&o===void 0)throw new Ie(n,[t])}function ts(n,t,o){if(typeof o!="string")throw new T(n,t,"A string is expected")}function gm(n,t,o){if(typeof o!="boolean")throw new T(n,t,"A boolean is expected")}function xm(n,t,o){if(typeof o!="number")throw new T(n,t,"A number is expected")}function wm(n,t,o){if(o!==void 0&&typeof o!="boolean")throw new T(n,t,"An optional boolean is expected")}function Ke(n,t,o){if(o!==void 0&&typeof o!="string")throw new T(n,t,"An optional string is expected")}function jm(n,t,o){if(!Array.isArray(o))throw new T(n,t,"A list of string is expected");o.forEach(s=>{if(typeof s!="string")throw new T(n,t,"A list of string is expected")})}function ym(n,t,o){if(o!==void 0&&typeof o!="string"){if(!Array.isArray(o))throw new T(n,t,"An optional string or list of string is expected");o.forEach(s=>{if(typeof s!="string")throw new T(n,t,"An optional string or list of string is expected")})}}function vm(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new T(n,t,"An optional list of string is expected");o.forEach(s=>{if(typeof s!="string")throw new T(n,t,"A optional list of string is expected")})}}function ns(n,t,o){if(o!==void 0&&typeof o!="number")throw new T(n,t,"An optional number is expected")}function Nm(n,t,o){if(o!==void 0){if(!Array.isArray(o))throw new T(n,t,"An optional list of numbers is expected");o.forEach(s=>{if(typeof s!="number")throw new T(n,t,"An optional list of numbers is expected")})}}function bm(n,t,o,s,r){if(o!==void 0){if(!Array.isArray(o))throw new T(n,t,`An optional list of ${r} is expected`);o.forEach(a=>{if(!s(a))throw new T(n,t,`An optional list of type ${r} is expected`)})}}function fe(n,t){const{_parentNode:o,_indexFromParent:s,...r}=t;if(n&&Object.keys(r).length>0)throw new he(n,Object.keys(r))}function _m(n,t,o){if(o!=="last"&&typeof o!="number")throw new T(n,t,'"last" or a number is expected')}function Sm(n,t,o){if(o!==void 0&&o!=="h5web"&&o!=="plotly")throw new T(n,t,'"h5web" or "plotly" string is expected')}function Cm(n,t,o){if(o!==void 0&&!Array.isArray(o))throw new T(n,t,"A list is expected")}function $m(n,t,o){if(o!==void 0&&(o===null||typeof o!="object"))throw new T(n,t,"A list is expected")}function Om(n,t,o,s){const{optional:r,schema:a}=s;if(r&&o===void 0)return;if(!o||typeof o!="object")throw new T(n,t,"A mapping is expected");const c=Object.keys(o).filter(f=>typeof f=="string"&&!(f in a));if(c.length>0)throw new he(n,Object.keys(c.map(f=>`${t}/${f}`)));const l=o;Object.entries(a).forEach(([f,u])=>{typeof f=="string"&&u(n,`${t}/${f}`,l[f])})}const Im=Object.freeze(Object.defineProperty({__proto__:null,assertBoolean:gm,assertDataCollectionId:_m,assertKeyExpected:hm,assertNoUnknownKeys:fe,assertNumber:xm,assertOptionalArgs:Cm,assertOptionalBackend:Sm,assertOptionalBoolean:wm,assertOptionalKwargs:$m,assertOptionalListOfType:bm,assertOptionalNumber:ns,assertOptionalNumberList:Nm,assertOptionalString:Ke,assertOptionalStringList:vm,assertOptionalStringOrStringList:ym,assertString:ts,assertStringList:jm,assertStringMappingRecord:Om},Symbol.toStringTag,{value:"Module"}));function os(n){const{providers:t={},yamlNode:o,message:s,...r}=n;return Ke(o,"message",s),fe(o,r),e.jsx(i.Alert,{variant:"warning",className:"mb-0",children:s??"TODO"})}const J={},ss={},Mm={airbearing:bt,base:xt,beamviewer:$t,energymanager:Tt,frontend:Et,gauge:Gt,laser:Vt,laserheating:zt,light:Qt,lima:dn,measurementgroup:mn,motor:_n,multiposition:Mn,optic:An,procedure:Bn,pump:so,pusher:co,regulation:Wn,service:po,shutter:Zn,slit:to,tomoconfig:Uo,tomodetector:$o,tomodetectors:Mo,tomoflatmotion:wo,tomoholo:Wo,tomoimaging:Bo,tomoreferenceposition:No,tomosamplestage:Go,valve:Qo};Object.entries(Mm).forEach(([n,t])=>{J[n]={...t.variants},ss[n]={...t}});function Dm(n,t,o){n in J||(J[n]={}),t in J[n]&&console.warn(`Hardware variant ${n}/${t} already existes. Overwrite.`),J[n][t]=o}function Qe(n,t){if(n in J){const s=J[n];if(t in s)return s[t]}const o=J.base;return t in o?o[t]:null}function Tm(){return ss}function Fm(n){const{hardware:t,options:o={}}=n,{emptyifnone:s=!1}=o;if(t===null)return s?e.jsx(e.Fragment,{}):e.jsx(D,{state:"NONE",variant:"danger",description:"No hardware"});const{type:r}=t;switch(r){case"missing":return e.jsx(D,{state:"MISSING",variant:"danger",description:"Hardware not available"});case"error":return e.jsx(D,{state:"ERROR",variant:"danger",description:"Error to load the hardware"});case"loading":return e.jsx(D,{state:"LOADING",variant:"warning",description:"The hardware was requested"})}const a=Qe(r,"state");if(!a)return e.jsx(De,{hardware:t});const c={setProperty:(l,f)=>Promise.resolve(),call:(l,...f)=>Promise.resolve()};return e.jsx(a,{hardware:{...t,actions:c},options:{name:t.name},operator:!1,disabled:!1})}function Rm(n){const{title:t,children:o,buttons:s,cancelText:r,footer:a=!0,showClose:c=!0,show:l=!1,actions:f={},otherButtons:u,bodyClassName:d,size:p="lg",fullscreen:m}=n,{onShow:g,onClose:j}=f;return e.jsxs(i.Modal,{fullscreen:m,size:p,"aria-labelledby":"modal-title",centered:!0,onShow:g,onHide:j,show:l,children:[e.jsx(i.Modal.Header,{closeButton:!0,children:e.jsx(i.Modal.Title,{id:"modal-title",children:t})}),e.jsx(i.Modal.Body,{className:d,children:o}),a&&e.jsxs(i.Modal.Footer,{children:[u&&e.jsx("div",{className:"form-other-buttons",children:u}),s,c&&e.jsx(i.Button,{onClick:j,children:r||"Close"})]})]})}function Am(n){return n.condition?n.wrap(n.children):n.children}const km=h.forwardRef((n,t)=>{const[o,s]=h.useState(!1),{showButton:r=!0}=n,a=h.useRef(null);function c(){s(!1),n.onClose&&n.onClose()}function l(){c()}h.useImperativeHandle(t,()=>({showModal:()=>s(!0),close:()=>l()}));const f=n.modalClass||Rm;return e.jsxs(e.Fragment,{children:[r&&e.jsx(Am,{condition:n.tooltip,wrap:u=>e.jsx(i.OverlayTrigger,{placement:n.tooltipPlacement||"top",overlay:e.jsx(i.Tooltip,{id:"tooltip1",children:n.tooltip}),children:u}),children:e.jsx(i.Button,{onClick:()=>{s(!0)},...n.buttonProps,ref:a,children:n.button})}),e.jsx(f,{target:a,show:o,actions:{onClose:l},title:n.title,buttons:n.buttons,children:n.children})]})}),Em=km;function Re(n){return n===void 0||n===null||typeof n!="string"?null:n.startsWith("$")?n.slice(1):n}const Pe={">":(n,t)=>n>t,"<":(n,t)=>n<t,">=":(n,t)=>n>=t,"<=":(n,t)=>n<=t,"==":(n,t)=>n===t,"!=":(n,t)=>n!==t,in:(n,t)=>t.indexOf(n)>-1},Pm=Object.keys(Pe),Me=(n,t,o)=>{if(n in Pe)return Pe[n](t,o)};function rs(n,t,o){const s=n.split(t);return o?[s.slice(0,-o).join(t)].concat(s.slice(-o)):s}function ct(n){const t=n!==void 0?rs(n,".",1):[null,""],o=G(Re(t[0]));if(!o||!o.properties)return;const s=t[1];if(s===null)return;const r=o.properties[s];return Array.isArray(r)?r[0]:r}function Bm(n){const t=n!==void 0&&!n.includes("."),o=n!==void 0?rs(n,".",1):[null,""],s=G(Re(o[0]));if(t)return n;if(s&&s.properties&&o[1]!==null)return`${s.properties[o[1]]}`}function is(n){const{monitor:t}=n;let o=ct(t.value)??"-";const s=Bm(t.unit),r=ct(t.overlay),a=Number.parseFloat(`${o}`);Number.isNaN(a)||String(a).length>5&&(o=a.toPrecision(5));function c(){return t.comparator&&t.comparison?Me(t.comparator,o,t.comparison)?"success":"danger":"secondary"}const l=c();Number.isNaN(a)||s!==void 0&&(o=`${o} ${s}`);const f=e.jsxs(ee,{children:[e.jsx("h1",{children:t.name}),e.jsx(i.Badge,{bg:l,children:`${o}`})]});if(r){const u=`${r}`;return e.jsx(i.OverlayTrigger,{placement:"bottom",overlay:e.jsx(i.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:u.includes(`
38
- `)?e.jsx("pre",{children:u}):u}),children:f})}return f}function Gm({value:n,unit:t,display_digits:o}){let s="";return n!==void 0&&(n===null?s="null":Number.isFinite(n)?s+=n.toFixed(o??2):s=`${n}`),t!==null&&t!==""&&(s=`${s} ${t}`),s}function Hm(n){const t=h.useRef({}),[o,s]=h.useState(void 0),{synoptic:r,fetchSVG:a,getHardwareGroupComponent:c,hardwareObjects:l}=n;h.useEffect(()=>{a(r.synoptic).then(p=>{s(p.data)})},[r]);const f=h.useCallback(p=>{var m,g;p in t.current&&((g=(m=t.current)==null?void 0:m[p].current)==null||g.showModal())},[t]),u=h.useMemo(()=>r.elements.map(p=>{var y,_,$,b;let m=!1,g;const j=p.ids&&((y=p.ids)==null?void 0:y.length)>0;if(j&&(m=!0,(_=p.ids)==null||_.forEach(v=>{v in l&&(l[v].properties.state_ok||(m=!1))})),p.state){const v=p.state.split("."),C=l[v[0]],I=C?C.properties[v[1]]:!1;Array.isArray(p.state_comparison)?(m=void 0,p.state_comparison.forEach(M=>{(Me(M==null?void 0:M.comparator,M==null?void 0:M.comparison,I)??!1)&&(g=M.color)})):p.state_comparison?m=Me(($=p.state_comparison)==null?void 0:$.comparator,(b=p.state_comparison)==null?void 0:b.comparison,I)??!1:m=!!I}let x=null;if(p.value){const v=p.value.split("."),C=l[v[0]];C&&(x=Gm({value:C.properties[v[1]],unit:C.properties.unit,display_digits:p.value_display_digits}))}const w=p.name.toLowerCase();return[e.jsx(pe.SvgProxy,{selector:`.${w} .status`,class:`$ORIGINAL ${m!==void 0?m?"ok":"error":""}`,style:g?`fill: ${g};`:""},`${w}state`),e.jsx(pe.SvgProxy,{selector:`.${w} .value`,children:x},`${w}value`),e.jsx(pe.SvgProxy,{selector:`.${w} > rect`,onClick:()=>f(w)},`${w}handler`),e.jsx(pe.SvgProxy,{class:`$ORIGINAL ${j?"active":""}`,selector:`.${w}`},`${w}comp`)]}),[r,l]),d=h.useMemo(()=>r.elements.filter(p=>{var m;return p.ids&&((m=p.ids)==null?void 0:m.length)>0}).map(p=>{const m=p.name.toLowerCase(),g=h.createRef();return t.current[m]=g,e.jsx(Em,{ref:g,title:p.name,showButton:!1,button:e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"fa fa-plus"}),"show"]}),children:c(p.ids??[])},`${m}pop`)}),[r]);return e.jsxs("div",{children:[e.jsx(pe.SvgLoader,{width:"100%",svgXML:o,className:`synoptic ${r.color_icons?"synoptic-color":""}`,children:u}),d]})}const Lm=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Um=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));function as(n){var t;return e.jsxs(i.Alert,{variant:"danger",children:[n.message,e.jsx("br",{}),e.jsx("pre",{children:(t=n.error)==null?void 0:t.stack})]})}function Vm(n){const{error:t}=n;if(!(t instanceof se))return e.jsx(e.Fragment,{});function o(a,c=3){const l=mm(a.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 a instanceof he?a.keys.forEach(d=>{f.push(`${u}${d}: ... ${" ".repeat(50-u.length-d.length)}<-- unexpected key`)}):a instanceof Ie?a.keys.forEach(d=>{f.push(`${u}???: ${" ".repeat(50-u.length-d.length)}<-- key **${d}** is expected`)}):a instanceof T&&f.push(`${u}${a.key}: ${" ".repeat(50-u.length-a.key.length)}<-- ${a.keyMessage}`),f.join(`
39
- `)}const r=pm(t.yamlNode).name;if(t instanceof he){const a=t.keys.length===1?"key":"keys";return e.jsxs(i.Alert,{variant:"danger",children:["Unexpected ",a," ",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 Ie){const a=t.keys.length===1?"Key":"Keys";return e.jsxs(i.Alert,{variant:"danger",children:["Expected ",a," ",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 T?e.jsxs(i.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(as,{...n})}const lt={hasError:!1,message:"",error:void 0};class cs extends h.Component{constructor(o){super(o);ne(this,"reload",()=>{window.location.reload()});this.state=lt}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(o){var s,r;if(o instanceof se||!this.props.unhandledComponentDidCatch){this.setState({hasError:!0,message:o.message,error:o});return}(r=(s=this.props).unhandledComponentDidCatch)==null||r.call(s,o,a=>{this.setState({hasError:!0,message:o.message,error:o,...a})})}componentDidUpdate(o,s){this.state.hasError&&s.error!==void 0&&o.resetKey!==this.props.resetKey&&this.setState(lt)}render(){if(this.state.hasError){const{UnhandledErrorComponent:o}=this.props,{hasError:s,...r}=this.state;return e.jsxs(i.Container,{className:"mt-2",children:[e.jsx("h4",{children:"Something went wrong"}),this.state.error instanceof se&&e.jsx(Vm,{message:this.state.message,error:this.state.error}),!(this.state.error instanceof se)&&e.jsx(e.Fragment,{children:o?e.jsx(o,{...r}):e.jsx(as,{message:this.state.message,error:this.state.error})}),e.jsxs("p",{children:["This error has been logged. Please"," ",e.jsxs(i.Button,{size:"sm",onClick:this.reload,children:[e.jsx("i",{className:"fa fa-refresh"})," Reload"]})," ","the application"]})]})}return this.props.children}}function qm(n){var o;const t=h.useMemo(()=>es(n.layout),[n.layout]);return t.error?e.jsx("div",{className:`${n.className??""} ymllayout-main`,"data-testid":n.testid,children:e.jsxs(R,{children:[e.jsx(R.Header,{children:"Layout Error"}),e.jsxs(R.Contents,{children:[e.jsxs("p",{children:["File: ",t.name]}),e.jsx(i.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(cs,{resetKey:t,unhandledComponentDidCatch:n.unhandledComponentDidCatch,UnhandledErrorComponent:n.UnhandledErrorComponent,children:(o=t.children)==null?void 0:o.map((s,r)=>q(s,r))})})}const Xe={hardwareproperty:is,hardware:ls};function Wm(n,t){Xe[n]=t}function zm(){return Xe}function Be(n){return e.jsxs(i.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 Ym(n){const t=P.map(n.monitors,(o,s)=>{const r=o.type??"hardwareproperty",a=Xe[r];return a===void 0?e.jsx(Be,{monitor:o,message:`Type ${r} unsupported`},`m${s}`):e.jsx(a,{monitor:o},`m${s}`)});return e.jsx("div",{className:V.default({"ms-auto":n.margin==="start"},"me-auto","monitor-panel",{"monitor-panel-light":n.bg==="light"}),children:e.jsx(i.Container,{fluid:!0,children:e.jsx(i.Row,{className:"flex-nowrap",children:t})})})}function ls(n){const{monitor:t}=n,{id:o}=t,s=Re(o),r=G(s),a=oe(s);if(o===void 0)return e.jsx(Be,{monitor:t,message:"'id' is missing"});if(typeof o!="string")return e.jsx(Be,{monitor:t,message:"'id' is invalid"});if(r===null)return e.jsx(D,{state:"NONE",variant:"danger",description:`hardware '${o}' was not found`});const{type:c="none"}=r,l={...r,actions:a},f=Qe(c,"monitor");return f?e.jsx(f,{hardware:l,options:{name:t.name},operator:!1,disabled:!1}):e.jsx(De,{hardware:l})}exports.AirBearing=jt;exports.AirBearingHardwareDesc=bt;exports.AirBearingMocks=vt;exports.AirBearingProtected=yt;exports.AirBearingSimulator=Nt;exports.AirBearingState=Te;exports.BaseHardwareDesc=xt;exports.BaseInfo=pt;exports.BaseMocks=gt;exports.BaseName=ft;exports.BaseProperty=mt;exports.BaseState=ut;exports.Beamviewer=_t;exports.BeamviewerHardwareDesc=$t;exports.BeamviewerMocks=St;exports.BeamviewerSimulator=Ct;exports.COMPARATORS=Pm;exports.EnergyManagerDefault=Ot;exports.EnergyManagerHardwareDesc=Tt;exports.EnergyManagerMocks=Mt;exports.EnergyManagerSimulator=Dt;exports.EnergyManagerState=He;exports.ErrorObject=Lp;exports.Formatting=gr;exports.Frontend=Rt;exports.FrontendHardwareDesc=Et;exports.FrontendMocks=kt;exports.FullSizer=Xo;exports.Gauge=Pt;exports.GaugeHardwareDesc=Gt;exports.GaugeIndicator=Wp;exports.GaugeMocks=Bt;exports.HardwareInputNumber=me;exports.HardwareNumericStep=ge;exports.HardwareSchema=Um;exports.HardwareState=Fm;exports.HardwareTemplate=S;exports.HardwareTypes=Lm;exports.InfiniteKnob360=gn;exports.KeyError=T;exports.Laser=Lt;exports.LaserHardwareDesc=Vt;exports.LaserHeating=qt;exports.LaserHeatingHardwareDesc=zt;exports.LaserHeatingMocks=Wt;exports.LaserMocks=Ut;exports.Light=Yt;exports.LightHardwareDesc=Qt;exports.LightMocks=Kt;exports.LimaBinning=tn;exports.LimaDefault=Xt;exports.LimaDescription=on;exports.LimaHardwareDesc=dn;exports.LimaImageRoi=nn;exports.LimaMocks=rn;exports.LimaShape=sn;exports.LimaSimulator=an;exports.LimaSize=Zt;exports.LimaState=X;exports.LimaTransformation=Jt;exports.LoadingObject=Bp;exports.MeasurementGroupDefault=un;exports.MeasurementGroupHardwareDesc=mn;exports.MeasurementGroupMocks=fn;exports.MeasurementGroupSimulator=pn;exports.MissingComponentObject=Vp;exports.MissingKeysError=Ie;exports.MissingObject=Hp;exports.MonitorHardware=ls;exports.MonitorHardwareProperty=is;exports.MonitorPanel=Ym;exports.MonitorPanelItem=ee;exports.MotorDefault=ce;exports.MotorHardwareDesc=_n;exports.MotorMocks=jn;exports.MotorRotation=xn;exports.MotorSimulator=yn;exports.MotorState=we;exports.MotorText=hn;exports.MultiState=wt;exports.Multiposition=Sn;exports.MultipositionDefault2=$n;exports.MultipositionHardwareDesc=Mn;exports.MultipositionMocks=On;exports.MultipositionSimulator=In;exports.NoObject=Pp;exports.None=Zo;exports.NullObject=qp;exports.NumericStep=Ht;exports.OpticDefault=Tn;exports.OpticHardwareDesc=An;exports.OpticMocks=Fn;exports.OpticSimulator=Rn;exports.OpticState=Ue;exports.Panel=R;exports.ProcedureExecution=kn;exports.ProcedureHardwareDesc=Bn;exports.ProcedureManage=Ee;exports.ProcedureMocks=Pn;exports.ProcedureState=ye;exports.ProcedureValidate=En;exports.PumpDefault=no;exports.PumpHardwareDesc=so;exports.PumpMocks=oo;exports.PusherDefault=ro;exports.PusherHardwareDesc=co;exports.PusherMocks=io;exports.PusherSimulator=ao;exports.PusherState=We;exports.RegulationDefault=Ln;exports.RegulationHardwareDesc=Wn;exports.RegulationMocks=Vn;exports.RegulationPlot=Ve;exports.RegulationSimulator=qn;exports.ServiceDefault=lo;exports.ServiceHardwareDesc=po;exports.ServiceMocks=fo;exports.ServiceProtected=uo;exports.ServiceState=Fe;exports.ShutterDefault=zn;exports.ShutterHardwareDesc=Zn;exports.ShutterMocks=Qn;exports.ShutterProtected=Yn;exports.ShutterSimulator=Xn;exports.ShutterState=ve;exports.SlitDefault=Jn;exports.SlitHardwareDesc=to;exports.SlitMocks=eo;exports.SlitState=qe;exports.State=D;exports.Synoptic=Hm;exports.Todo=os;exports.TomoConfigHardwareDesc=Uo;exports.TomoConfigLatencyTime=Lo;exports.TomoDetectorAcquisitionMode=So;exports.TomoDetectorHardwareDesc=$o;exports.TomoDetectorMocks=Co;exports.TomoDetectorSamplePixelSize=bo;exports.TomoDetectorState=be;exports.TomoDetectorsDefault=Oo;exports.TomoDetectorsHardwareDesc=Mo;exports.TomoDetectorsMocks=Io;exports.TomoDetectorsState=Ye;exports.TomoFlatMotionDefault=mo;exports.TomoFlatMotionHardwareDesc=wo;exports.TomoFlatMotionMocks=go;exports.TomoFlatMotionSimulator=xo;exports.TomoFlatMotionSmall=ho;exports.TomoFlatMotionState=Ne;exports.TomoHoloHardwareDesc=Wo;exports.TomoHoloState=qo;exports.TomoImagingActions=Ao;exports.TomoImagingDefault=To;exports.TomoImagingExposureTime=Fo;exports.TomoImagingHardwareDesc=Bo;exports.TomoImagingMocks=Eo;exports.TomoImagingSettleTime=Ro;exports.TomoImagingSimulator=Po;exports.TomoImagingState=ae;exports.TomoImagingUpdateMode=ko;exports.TomoReferencePositionDefault=vo;exports.TomoReferencePositionHardwareDesc=No;exports.TomoSampleStageHardwareDesc=Go;exports.TypeIcon=N;exports.ValveDefault=Yo;exports.ValveHardwareDesc=Qo;exports.ValveMocks=Ko;exports.YAMLErrorBoundary=cs;exports.YAMLLayout=qm;exports.YamlAsserts=Im;exports.createMotorMock=el;exports.dynamicOp=Me;exports.getAllHardwareDesc=Tm;exports.getAllMonitors=zm;exports.getHardwareVariantComponent=Qe;exports.getYamlComponents=lm;exports.getYamlContainers=dm;exports.isLimaHardware=xe;exports.isMotorClockWise=Nn;exports.isMotorHardware=vn;exports.isOpticHardware=Ol;exports.isProcedureHardware=Gn;exports.isTomoConfigHardware=Vo;exports.isTomoDetectorHardware=ze;exports.isTomoDetectorsHardware=Do;exports.isTomoFlatMotionHardware=jo;exports.isTomoHoloHardware=zo;exports.isTomoReferencePositionHardware=xf;exports.isTomoSampleStageHardware=Ho;exports.limaGuessSubframes=ln;exports.motorLimits=bn;exports.normalizeId=Re;exports.registerHardwareVariant=Dm;exports.registerMonitorComponent=Wm;exports.registerRuntimeHook=Ei;exports.registerYamlComponent=Jo;exports.registerYamlComponents=cm;exports.registerYamlContainer=am;exports.renderYamlNode=q;exports.useHardware=G;exports.useHardwareChangeActions=oe;exports.useHardwareSchema=Pi;exports.useLimaHardware=cn;exports.useMotorHardware=U;exports.useMotorStates=je;exports.useOperator=Bi;exports.useProcedureHardware=ql;exports.useScanRunning=Gi;exports.useTomoConfigHardware=Np;exports.useTomoDetectorHardware=Pf;exports.useTomoDetectorsHardware=Qf;exports.useTomoFlatMotionHardware=gf;exports.useTomoHoloHardware=Sp;exports.useTomoSampleStageHardware=jp;exports.yamlComponents=ie;exports.yamlContainers=re;
40
- //# sourceMappingURL=index.js.map