@esrf/daiquiri-lib 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -38,23 +38,25 @@ interface Hardware {
38
38
  id: string;
39
39
  /** An optional object alias */
40
40
  alias: string | null;
41
+ /** A list of user tags */
42
+ user_tags: string[];
41
43
  /** The object properties as defined in the relevant schema */
42
44
  properties: {
43
45
  [name: string]: any;
44
46
  };
45
47
  /** Whether the device is available */
46
48
  online: boolean;
49
+ /** The reason why the hardware is locked, else null */
50
+ locked: string | null;
47
51
  /** The object type as defined by the REST API */
48
52
  type: string;
49
53
  /** Any potential errors initialising this object */
50
54
  errors?: HardwareError[];
51
55
  }
52
- interface HardwareChangeAction {
53
- property?: string;
54
- function?: string;
55
- value?: any;
56
+ interface HardwareChangeActions {
57
+ setProperty: (name: string, value: any) => Promise<void>;
58
+ call: (name: string, ...args: any[]) => Promise<void>;
56
59
  }
57
- declare type HardwareChangeHandler = (action: HardwareChangeAction) => Promise<void> | null;
58
60
  /**
59
61
  * Common options exposed to user as yaml configuration for hardware widgets
60
62
  */
@@ -66,7 +68,7 @@ interface HardwareWidgetOptions {
66
68
  }
67
69
  declare type EditableHardware<H extends Hardware = Hardware> = H & {
68
70
  /** Call the API to make a change on the hardware object */
69
- requestChange: HardwareChangeHandler;
71
+ actions: HardwareChangeActions;
70
72
  };
71
73
  /**
72
74
  * Properties which are passed to the widgets
@@ -78,12 +80,6 @@ interface HardwareWidgetProps<H extends Hardware = Hardware, O extends HardwareW
78
80
  schema: HardwareSchemaDescription;
79
81
  /** Options passed to the widget by the yaml configuration */
80
82
  options: O;
81
- /** Add temporary message on the Daiquiri top level interface */
82
- addToast: (props: {
83
- type: string;
84
- title: string;
85
- text: string;
86
- }) => void;
87
83
  /** Global state of the widget (aggregating scan/operator/hardware states) */
88
84
  disabled: boolean;
89
85
  /** True if the session have the control */
@@ -92,58 +88,14 @@ interface HardwareWidgetProps<H extends Hardware = Hardware, O extends HardwareW
92
88
 
93
89
  type types_d_EditableHardware<H extends Hardware = Hardware> = EditableHardware<H>;
94
90
  type types_d_Hardware = Hardware;
95
- type types_d_HardwareChangeAction = HardwareChangeAction;
96
- type types_d_HardwareChangeHandler = HardwareChangeHandler;
91
+ type types_d_HardwareChangeActions = HardwareChangeActions;
97
92
  type types_d_HardwareSchemaDescription = HardwareSchemaDescription;
98
93
  type types_d_HardwareWidgetOptions = HardwareWidgetOptions;
99
94
  type types_d_HardwareWidgetProps<H extends Hardware = Hardware, O extends HardwareWidgetOptions = HardwareWidgetOptions> = HardwareWidgetProps<H, O>;
100
95
  declare namespace types_d {
101
- export type { types_d_EditableHardware as EditableHardware, types_d_Hardware as Hardware, types_d_HardwareChangeAction as HardwareChangeAction, types_d_HardwareChangeHandler as HardwareChangeHandler, types_d_HardwareSchemaDescription as HardwareSchemaDescription, types_d_HardwareWidgetOptions as HardwareWidgetOptions, types_d_HardwareWidgetProps as HardwareWidgetProps };
96
+ export type { types_d_EditableHardware as EditableHardware, types_d_Hardware as Hardware, types_d_HardwareChangeActions as HardwareChangeActions, types_d_HardwareSchemaDescription as HardwareSchemaDescription, types_d_HardwareWidgetOptions as HardwareWidgetOptions, types_d_HardwareWidgetProps as HardwareWidgetProps };
102
97
  }
103
98
 
104
- interface GenericSchema extends Hardware {
105
- properties: {
106
- state: string;
107
- };
108
- }
109
- interface MotorSchema extends Hardware {
110
- properties: {
111
- position: number;
112
- target: number;
113
- tolerance: number;
114
- acceleration: number;
115
- velocity: number;
116
- limits: number[];
117
- state: string[];
118
- unit: string;
119
- offset: number;
120
- sign: number;
121
- };
122
- }
123
- interface MultipositionSchema extends Hardware {
124
- properties: {
125
- position: string;
126
- positions: {
127
- position: string;
128
- description: string;
129
- target: {
130
- axis: string;
131
- destination: number;
132
- tolerance: number;
133
- }[];
134
- }[];
135
- state: string;
136
- };
137
- }
138
- interface ShutterSchema extends Hardware {
139
- properties: {
140
- state: string;
141
- status: string;
142
- valid: boolean;
143
- open_text: string;
144
- closed_text: string;
145
- };
146
- }
147
99
  interface FrontendSchema extends Hardware {
148
100
  properties: {
149
101
  state: string;
@@ -160,15 +112,6 @@ interface FrontendSchema extends Hardware {
160
112
  };
161
113
  }
162
114
 
163
- type schema_d_FrontendSchema = FrontendSchema;
164
- type schema_d_GenericSchema = GenericSchema;
165
- type schema_d_MotorSchema = MotorSchema;
166
- type schema_d_MultipositionSchema = MultipositionSchema;
167
- type schema_d_ShutterSchema = ShutterSchema;
168
- declare namespace schema_d {
169
- export type { schema_d_FrontendSchema as FrontendSchema, schema_d_GenericSchema as GenericSchema, schema_d_MotorSchema as MotorSchema, schema_d_MultipositionSchema as MultipositionSchema, schema_d_ShutterSchema as ShutterSchema };
170
- }
171
-
172
115
  declare function Frontend(props: HardwareWidgetProps<FrontendSchema>): JSX.Element;
173
116
 
174
117
  interface InfoOptions extends HardwareWidgetOptions {
@@ -177,8 +120,25 @@ interface InfoOptions extends HardwareWidgetOptions {
177
120
  /** Unit for the property */
178
121
  unit?: string;
179
122
  }
123
+
180
124
  declare function Info(props: HardwareWidgetProps<Hardware, InfoOptions>): JSX.Element;
181
125
 
126
+ interface MotorSchema extends Hardware {
127
+ properties: {
128
+ position: number | null;
129
+ target: number;
130
+ tolerance: number;
131
+ acceleration: number;
132
+ velocity: number;
133
+ limits: [number, number];
134
+ state: string[];
135
+ unit: string;
136
+ offset: number;
137
+ sign: number;
138
+ display_digits: number | null;
139
+ };
140
+ }
141
+
182
142
  interface MotorDefaultOptions extends HardwareWidgetOptions {
183
143
  /** Default step size to use for up / down arrows */
184
144
  step?: number;
@@ -203,32 +163,79 @@ interface MotorDefaultOptions extends HardwareWidgetOptions {
203
163
  /** Show large step arrows */
204
164
  largearrows?: boolean;
205
165
  }
166
+
206
167
  /**
207
168
  * The default motor widget
208
169
  */
209
170
  declare function MotorDefault(props: HardwareWidgetProps<MotorSchema, MotorDefaultOptions>): JSX.Element;
210
171
 
172
+ /**
173
+ * A motor have a set of flags as state.
174
+ *
175
+ * For example an axis can expose `READY` and `MOVING` at the same time.
176
+ * It means the controller is ready to change it's target, even
177
+ * during a motion.
178
+ *
179
+ * For now we only display a "main" state.
180
+ */
181
+ declare function MotorState(props: {
182
+ hardware: MotorSchema;
183
+ }): JSX.Element;
184
+
185
+ interface MultipositionSchema extends Hardware {
186
+ properties: {
187
+ position: string;
188
+ positions: {
189
+ position: string;
190
+ description: string;
191
+ target: {
192
+ axis: string;
193
+ destination: number;
194
+ tolerance: number;
195
+ }[];
196
+ }[];
197
+ state: string;
198
+ };
199
+ }
200
+
211
201
  declare function Multiposition(props: HardwareWidgetProps<MultipositionSchema>): JSX.Element;
212
202
 
213
- interface NoObjectProps {
214
- id: string;
215
- name?: string;
216
- options: {
217
- header?: string;
218
- emptyifnone?: boolean;
203
+ interface GenericSchema extends Hardware {
204
+ properties: {
205
+ state: string;
219
206
  };
220
207
  }
221
- declare function NoObject(props: NoObjectProps): JSX.Element;
208
+
209
+ type schema_d_GenericSchema = GenericSchema;
210
+ declare namespace schema_d {
211
+ export type { schema_d_GenericSchema as GenericSchema };
212
+ }
222
213
 
223
214
  interface PropertyWidgetOptions extends HardwareWidgetOptions {
224
215
  header?: string;
225
216
  property?: string;
226
217
  unit?: string;
227
218
  }
219
+
228
220
  declare function Property(props: HardwareWidgetProps<GenericSchema, PropertyWidgetOptions>): JSX.Element;
229
221
 
222
+ interface ShutterSchema extends Hardware {
223
+ properties: {
224
+ state: string;
225
+ status: string;
226
+ valid: boolean;
227
+ open_text: string;
228
+ closed_text: string;
229
+ };
230
+ }
231
+
230
232
  declare function ShutterDefault(props: HardwareWidgetProps<ShutterSchema, HardwareWidgetOptions>): JSX.Element;
231
233
 
234
+ declare function ShutterState(props: {
235
+ hardware: ShutterSchema;
236
+ useReadyState?: boolean;
237
+ }): JSX.Element;
238
+
232
239
  interface Props$c {
233
240
  online: boolean;
234
241
  activeMessage?: string;
@@ -286,9 +293,9 @@ declare function HardwareNumericStep(props: {
286
293
  onMoveRequested: (value: number) => Promise<void> | null;
287
294
  onAbortRequested: () => void;
288
295
  /** Default step size to use for up / down arrows */
289
- step?: number;
296
+ step?: number | string;
290
297
  /** Array of selectable step sizes */
291
- steps?: number[];
298
+ steps?: (number | string)[];
292
299
  /** Number of decimals to show */
293
300
  precision?: number;
294
301
  /** Whether this widget is read only */
@@ -317,20 +324,29 @@ declare function HardwareState(props: {
317
324
  state: string;
318
325
  variant: string;
319
326
  minWidth?: number;
327
+ description?: string;
320
328
  }): JSX.Element;
321
- declare function MotorState(props: {
322
- hardware: MotorSchema;
323
- }): JSX.Element;
324
- declare function ShutterState(props: {
325
- hardware: ShutterSchema;
326
- useReadyState?: boolean;
329
+ /**
330
+ * Normalize the way to display an hardware exposing multiple states.
331
+ *
332
+ * - `states` is the states exposed by the hardware.
333
+ * - `variants` contains a variant for each of this states, else `fatal` is used.
334
+ * - `descriptions` can be provided to add a description to the state.
335
+ *
336
+ * If `minWidth` is pecified (in `em`) it ensure the widget width will stay the
337
+ * same when the state change
338
+ */
339
+ declare function HardwareMultiState(props: {
340
+ states: string[];
341
+ variants?: Record<string, string>;
342
+ descriptions?: Record<string, string>;
343
+ minWidth?: number;
327
344
  }): JSX.Element;
328
345
 
346
+ declare const State_d_HardwareMultiState: typeof HardwareMultiState;
329
347
  declare const State_d_HardwareState: typeof HardwareState;
330
- declare const State_d_MotorState: typeof MotorState;
331
- declare const State_d_ShutterState: typeof ShutterState;
332
348
  declare namespace State_d {
333
- export { State_d_HardwareState as HardwareState, State_d_MotorState as MotorState, State_d_ShutterState as ShutterState };
349
+ export { State_d_HardwareMultiState as HardwareMultiState, State_d_HardwareState as HardwareState };
334
350
  }
335
351
 
336
352
  declare function formatEng(scalar: number): {
@@ -367,14 +383,24 @@ declare class HardwareVariant extends Component<HardwareVariantOptions, void> {
367
383
  render(): JSX.Element;
368
384
  }
369
385
 
386
+ interface NoObjectProps {
387
+ id: string;
388
+ name?: string;
389
+ options: {
390
+ header?: string;
391
+ emptyifnone?: boolean;
392
+ };
393
+ }
394
+ declare function NoObject(props: NoObjectProps): JSX.Element;
395
+
370
396
  interface Props$a {
371
397
  className?: string;
372
398
  }
373
399
  declare function FullSizer(props: PropsWithChildren<Props$a>): JSX.Element;
374
400
 
375
401
  interface Props$9 {
376
- step?: number;
377
- steps?: number[];
402
+ step?: number | string;
403
+ steps?: (number | string)[];
378
404
  disabled: boolean;
379
405
  id?: string;
380
406
  unit?: string;
@@ -403,6 +429,7 @@ declare function PanelHeader(props: {
403
429
  declare function PanelContents(props: {
404
430
  children?: ReactChild | ReactChild[];
405
431
  style?: Record<string, any>;
432
+ className?: string;
406
433
  }): JSX.Element;
407
434
  interface Props$8 {
408
435
  style?: Record<string, any>;
@@ -555,7 +582,7 @@ declare const yamlMap: {
555
582
  label: typeof YamlLabel;
556
583
  };
557
584
  interface Props$1 {
558
- id: string;
585
+ testid: string;
559
586
  layout: YamlRoot;
560
587
  className?: string;
561
588
  unhandledComponentDidCatch?: (error: Error, setStateCallback: (data: Record<string, any>) => void) => void;
@@ -642,10 +669,6 @@ declare namespace asserts_d {
642
669
 
643
670
  interface HardwareObjectProps {
644
671
  id: string;
645
- actions: {
646
- requestChange: (data: any) => void;
647
- addToast: (data: any) => void;
648
- };
649
672
  options: {
650
673
  variant?: string;
651
674
  header?: string;
@@ -658,6 +681,7 @@ interface HardwareObjectProps {
658
681
  }
659
682
  interface ResolvedHardwareObjectProps extends HardwareObjectProps {
660
683
  operator?: boolean;
684
+ runningScan?: boolean;
661
685
  obj: Hardware | null;
662
686
  }
663
687
  interface ComponentMapping {
@@ -703,4 +727,4 @@ interface MonitorPanelItemProps {
703
727
  }
704
728
  declare function MonitorPanelItem(props: PropsWithChildren<MonitorPanelItemProps>): JSX.Element;
705
729
 
706
- export { formatting_d as Formatting, Frontend, FullSizer, HardwareObject_d as HWObject, HardwareInputNumber, HardwareNumericStep, schema_d as HardwareSchema, State_d as HardwareState, HardwareTemplate, types_d as HardwareTypes, HardwareVariant, Info, type InfoOptions, KeyError, MissingKeysError, type Monitor, MonitorHardware, MonitorPanel, MonitorPanelItem, type MonitorPanelProps, MotorDefault, type MotorDefaultOptions, Multiposition, NoObject, NumericStep, Panel, Property, ShutterDefault, TypeIcon, type Props$c as TypeIconOptions, ErrorBoundary as YAMLErrorBoundary, Main as YAMLLayout, asserts_d as YamlAsserts, type YamlComponent$1 as YamlComponent, type YamlNode, dynamicOp, registerHardwareComponent, registerMonitorComponent, registerRuntimeHook, registerComponent as registerYamlComponent, registerComponents as registerYamlComponents, registerYamlType, renderYamlNode, yamlMap };
730
+ export { formatting_d as Formatting, Frontend, FullSizer, HardwareObject_d as HWObject, type Hardware, HardwareInputNumber, HardwareNumericStep, schema_d as HardwareSchema, State_d as HardwareState, HardwareTemplate, types_d as HardwareTypes, HardwareVariant, Info, type InfoOptions, KeyError, MissingKeysError, type Monitor, MonitorHardware, MonitorPanel, MonitorPanelItem, type MonitorPanelProps, MotorDefault, type MotorDefaultOptions, type MotorSchema, MotorState, Multiposition, NoObject, NumericStep, Panel, Property, ShutterDefault, type ShutterSchema, ShutterState, TypeIcon, type Props$c as TypeIconOptions, ErrorBoundary as YAMLErrorBoundary, Main as YAMLLayout, asserts_d as YamlAsserts, type YamlComponent$1 as YamlComponent, type YamlNode, dynamicOp, registerHardwareComponent, registerMonitorComponent, registerRuntimeHook, registerComponent as registerYamlComponent, registerComponents as registerYamlComponents, registerYamlType, renderYamlNode, yamlMap };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),w=require("lodash"),a=require("react-bootstrap"),m=require("react"),fe=require("classnames"),me=require("debug"),q=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},O=q(fe),pe=q(me);function xe(e){const{activeMessage:t="Online",inactiveMessage:r="Offline",message:s="This device is"}=e;return n.jsx("div",{className:`dot-indicator small bg-${e.online?"success":"danger"}`,title:`${s} ${e.online?t:r}`})}function N(e){const{name:t,icon:r}=e;return n.jsxs("div",{className:"icon",title:t,children:[n.jsx("i",{className:`fa ${r}`}),n.jsx(xe,{...e})]})}function ge(e){const t={24:"Y",21:"Z",18:"E",15:"P",12:"T",9:"G",6:"M",3:"k","-3":"m","-6":"µ","-9":"n","-12":"p","-15":"f","-18":"a","-21":"z","-24":"y"},r=Math.log(e)/Math.log(1e3),s=!Number.isInteger(r),i=3*Math.ceil(r-(s?1:0)),o=i===0?"":t[i];return{scalar:e*10**-i,prefix:o,multiplier:10**-i}}function je(e){return e.charAt(0).toUpperCase()+e.slice(1)}function G(e){if(e<60)return`${Math.round(e)} sec`;const t=Math.round(e/60),r=t%60,s=Math.floor(t/60);return s?`${s} hr ${r} min`:`${r} min`}function we(e){return e>0?(662607004e-42*299792458/(e*1e-10)/160218e-24*.001).toFixed(4):0}function ye(e,t){return Number.parseFloat(e.toFixed(t))}const ve=Object.freeze(Object.defineProperty({__proto__:null,formatEng:ge,round:ye,toEnergy:we,toHoursMins:G,ucfirst:je},Symbol.toStringTag,{value:"Module"}));function be(e){const{hardware:t}=e;function r(d){t.requestChange({function:"reset"})}const s={"Front End":"feitlk",Experimental:"expitlk",PSS:"pssitlk"},i={Current:`${t.properties.current.toFixed(1)} mA`,Mode:t.properties.mode,Refill:G(t.properties.refill),Message:n.jsx("pre",{children:t.properties.message})};function o(d){if(!(d in t.properties))return"UNKNOWN";const l=t.properties[d];return!l||typeof l!="string"?"UNKNOWN":l}return n.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:n.jsxs(a.Popover,{id:"popid",children:[n.jsxs(a.Popover.Header,{children:[t.name," Details"]}),n.jsxs(a.Popover.Body,{children:[n.jsx("h6",{children:"Status"}),n.jsx("pre",{children:t.properties.status}),n.jsx("h6",{children:"Interlocks"}),n.jsx(a.Container,{children:w.map(s,(d,l)=>n.jsxs(a.Row,{children:[n.jsxs(a.Col,{children:[l,":"]}),n.jsx(a.Col,{children:n.jsx(a.Badge,{bg:o(d)==="ON"?"success":"danger",children:o(d)})})]},l))}),n.jsx("h6",{children:"Ring Status"}),n.jsx(a.Container,{children:w.map(i,(d,l)=>n.jsxs(a.Row,{children:[n.jsxs(a.Col,{children:[l,":"]}),n.jsx(a.Col,{children:d})]},l))}),n.jsx("div",{className:"d-grid gap-2",children:n.jsx(a.Button,{disabled:e.disabled,onClick:r,children:"Reset"})})]})]}),children:n.jsx(a.Button,{className:"flex-grow-0",title:"Shutter Details",children:n.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Ne(e){const{hardware:t,options:r={}}=e;function s(i){t.requestChange({function:t.properties.frontend==="FE open"?"close":"open"})}return n.jsxs("div",{className:"hw-component",children:[n.jsxs("div",{className:"hw-head",children:[n.jsx(N,{name:"Frontend",icon:"fam-hardware-frontend",online:t.online}),n.jsx("div",{className:"name",children:t.name}),n.jsx(a.Badge,{bg:t.properties.state==="OPEN"||t.properties.state==="RUNNING"?"success":"danger",children:t.properties.state})]}),n.jsx("div",{className:"hw-content",children:n.jsxs(a.ButtonGroup,{className:"d-flex",children:[n.jsx(a.Button,{variant:t.properties.frontend==="FE open"?"danger":"success",onClick:s,disabled:e.disabled,children:t.properties.frontend==="FE open"?"Close":"Open"}),n.jsx(be,{...e})]})})]})}function Ce(e){const{hardware:t,options:r={}}=e;function s(){const i=r.property;if(i===void 0)return"property is not set";if(i===null)return"property is null";let o=t;for(const d of i.split("/"))if(o=o[d],o===void 0)return`property '${i}' not found`;return`${o}`}return n.jsx(n.Fragment,{children:s()})}function E(e){const{headerMode:t,hardware:r}=e;function s(){return r.alias?r.alias:r.name?r.name:r.id}const i=s();switch(t){case"front":return n.jsx("div",{className:"hw-component",children:n.jsxs("div",{className:"hw-single",children:[e.widgetIcon,n.jsx("div",{className:"name",children:i}),n.jsx("div",{className:"d-inline-block",children:e.widgetContent})]})});case"none":return n.jsx("div",{className:"hw-component",children:n.jsx("div",{className:"hw-single",children:e.widgetContent})});case"state":return e.widgetState;default:return n.jsxs("div",{className:"hw-component",children:[n.jsxs("div",{className:"hw-head",children:[e.widgetIcon,n.jsx("div",{className:"name",children:n.jsx(a.Form.Label,{htmlFor:r.id,children:i})}),e.widgetState,e.hardware.errors&&e.hardware.errors.length>0&&n.jsx(a.OverlayTrigger,{trigger:"click",placement:"bottom",rootClose:!0,overlay:n.jsxs(a.Popover,{id:e.hardware.id,style:{maxWidth:500},children:[n.jsx(a.Popover.Header,{children:"Device Errors"}),n.jsxs(a.Popover.Body,{children:["There were errors with properties on this device:",n.jsx("ul",{children:e.hardware.errors.map(o=>n.jsxs("li",{children:[o.property,":",n.jsxs("span",{className:"stack-trace",children:[o.traceback,n.jsx("br",{}),o.exception]})]}))})]})]}),children:n.jsx(a.Button,{variant:"danger",size:"sm",children:n.jsx("i",{className:"fa fa-exclamation-triangle"})})})]}),n.jsx("div",{className:"hw-content",children:e.widgetContent})]})}}function H(e){const t={display:"inline-block",minWidth:""};return e.minWidth&&(t.minWidth=`${e.minWidth}em`),n.jsx("div",{style:t,children:n.jsx(a.Badge,{bg:e.variant,children:e.state})})}function K(e){const{hardware:t}=e;function r(){if(!t.online)return"OFFLINE";let i="UNKNOWN";return e.hardware.properties.state&&([i]=e.hardware.properties.state),i}const s=r();return n.jsx(H,{state:s,minWidth:6,variant:s==="READY"?"success":"warning"})}function U(e){const{hardware:t}=e;function r(){if(!t.online)return"OFFLINE";const o=t.properties.state;return e.useReadyState&&(o==="OPEN"||o==="CLOSED")?"READY":o}const s=r();function i(){switch(s){case"READY":return"success";case"OPEN":return"success";case"CLOSED":return"danger";case"DISABLED":return"secondary";case"MOVING":case"STANDBY":case"OFFLINE":return"warning";case"FAULT":return"fatal";default:return"fatal"}}return n.jsx(H,{state:s,minWidth:6,variant:i()})}const Se=Object.freeze(Object.defineProperty({__proto__:null,HardwareState:H,MotorState:K,ShutterState:U},Symbol.toStringTag,{value:"Module"})),Oe=m.forwardRef((e,t)=>{const r=m.useRef(null),[s,i]=m.useState(e.step),o=j=>{const k=t;if(r.current===null)return;let B=Number.parseFloat(k.current.value);const V=Number.parseFloat(r.current.value);B+=j?V:-V,k.current.value=`${B}`,e.onStep&&e.onStep({target:k.current})},{onStep:d,step:l,overlay:h,incIcon:u,decIcon:c,swapIncDec:f,onKeyDown:g,horizontalArrows:C,largeArrows:I,...v}=e,_=j=>{j.key==="ArrowUp"?(j.preventDefault(),o(!0)):j.key==="ArrowDown"?(j.preventDefault(),o(!1)):g&&g(j)};if(!e.step)return n.jsx(a.Form.Control,{ref:t,type:"number",step:"any",onKeyDown:_,...v});const he=w.map(e.steps||[e.step],j=>n.jsx("option",{value:j,children:j},j));return n.jsx("div",{className:O.default("numeric-step",{"numeric-step-large":I,"numeric-step-horizontal":C}),children:n.jsxs(a.InputGroup,{children:[n.jsx(a.Form.Control,{onKeyDown:_,ref:t,type:"number",step:"any",...v}),n.jsxs(n.Fragment,{children:[h,!h&&n.jsxs(a.InputGroup.Text,{className:"d-flex flex-column",children:[n.jsx(a.Form.Control,{ref:r,as:"select",className:"step-size",defaultValue:s,onChange:j=>i(Number.parseFloat(j.target.value)),children:he}),e.unit&&n.jsx("div",{children:e.unit}),!u&&!c&&n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{className:"step step-up",disabled:e.disabled,onClick:j=>o(!0)}),n.jsx(a.Button,{className:"step step-down",disabled:e.disabled,onClick:j=>o(!1)})]})]}),c&&f&&n.jsx(a.Button,{disabled:e.disabled,onClick:j=>o(!1),children:n.jsx("i",{className:`fa fa-fw fa-${c}`})}),u&&n.jsx(a.Button,{disabled:e.disabled,onClick:j=>o(!0),children:n.jsx("i",{className:`fa fa-fw fa-${u}`})}),c&&!f&&n.jsx(a.Button,{disabled:e.disabled,onClick:j=>o(!1),children:n.jsx("i",{className:`fa fa-fw fa-${c}`})})]})]})})}),z=Oe;function W(e){const t=m.useRef(null),[r,s]=m.useState(!1),[i,o]=m.useState(!1);m.useEffect(()=>{t.current&&(e.hardwareValue===null?t.current.value="":t.current.value=e.hardwareValue.toString(),s(!1))},[e.hardwareValue]);function d(f){let g=f;e.precision!==void 0&&(g=Number.parseFloat(g).toFixed(e.precision)),t!=null&&t.current&&(t.current.value=g)}function l(){r&&setTimeout(()=>{d(e.hardwareValue),s(!1)},3e3)}function h(f){e.hardwareValue!==null&&(s(!0),t!=null&&t.current&&(t.current.value=f.target.value),f.target.value===e.hardwareValue.toString()&&s(!1))}function u(f){s(!1),e.onMoveRequested(f.target.value)}function c(f){switch(f.key){case"Enter":{s(!1);const g=Number.parseFloat(f.target.value),C=e.onMoveRequested(g);C&&C.catch(()=>{o(!0),setTimeout(()=>{d(e.hardwareValue),o(!1)},2e3)})}f.preventDefault(),f.stopPropagation();break;case"Esc":case"Escape":r&&(o(!1),s(!1),d(e.hardwareValue)),f.target.blur(),f.preventDefault(),f.stopPropagation();break}}return n.jsx(z,{id:e.id,className:O.default({"form-control-edited":r,"form-control-error":i,"hw-moving":e.hardwareIsMoving}),type:e.readOnly?"text":"number",ref:t,precision:e.precision,onChange:h,onBlur:l,onStep:u,onKeyDown:c,disabled:e.hardwareIsDisabled||e.readOnly||!e.hardwareIsReady,step:e.step,steps:e.steps,incIcon:e.incIcon,decIcon:e.decIcon,swapIncDec:e.swapIncDec,horizontalArrows:e.horizontalArrows,largeArrows:e.largeArrows,overlay:e.hardwareIsMoving&&!e.hardwareIsDisabled?n.jsx(a.Button,{variant:"danger",onClick:e.onAbortRequested,children:n.jsx("i",{className:"fa fa-times"})}):null})}function D(e){const t=m.useRef(null),[r,s]=m.useState(!1),[i,o]=m.useState(!1);function d(c){return e.precision!==void 0?Number.parseFloat(c).toFixed(e.precision):c}m.useEffect(()=>{var c;t.current&&(t.current.value=d((c=e.hardwareValue)==null?void 0:c.toString()),s(!1))},[e.hardwareValue,e.precision]);function l(c){const f=d(c);t!=null&&t.current&&(t.current.value=f)}function h(c){switch(c.key){case"Enter":{s(!1);const f=Number.parseFloat(c.target.value),g=e.onMoveRequested(f);g&&g.catch(()=>{o(!0),setTimeout(()=>{l(e.hardwareValue),o(!1)},2e3)}),c.preventDefault(),c.stopPropagation();break}case"Esc":case"Escape":r&&(o(!1),s(!1),l(e.hardwareValue)),c.target.blur(),c.preventDefault(),c.stopPropagation();break}}function u(c){s(!0),c.target,t!=null&&t.current&&(t.current.value=c.target.value),c.target.value===e.hardwareValue.toString()&&s(!1)}return n.jsx(a.Form.Control,{className:O.default({"form-control-edited":r,"form-control-error":i,"hw-moving":e.hardwareIsMoving}),type:"number",ref:t,onChange:u,onKeyDown:h,disabled:e.readOnly||e.hardwareIsMoving||e.hardwareIsDisabled,step:e.step})}function Ee(e){function t(i){return e.hardware.requestChange({property:"velocity",value:i})}function r(i){return e.hardware.requestChange({property:"acceleration",value:i})}let s="UNKNOWN";return e.hardware.properties.state&&([s]=e.hardware.properties.state),n.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:n.jsxs(a.Popover,{id:"popid",children:[n.jsxs(a.Popover.Header,{children:[e.hardware.name," details"]}),n.jsxs(a.Popover.Body,{children:[n.jsxs(a.Form.Group,{children:[n.jsx(a.Form.Label,{children:"Velocity"}),n.jsx(D,{hardwareValue:e.hardware.properties.velocity,onMoveRequested:t,hardwareIsDisabled:e.disabled,hardwareIsReady:s==="READY",hardwareIsMoving:s==="MOVING",readOnly:e.readOnly})]}),n.jsxs(a.Form.Group,{children:[n.jsx(a.Form.Label,{children:"Acceleration"}),n.jsx(D,{hardwareValue:e.hardware.properties.acceleration,onMoveRequested:r,hardwareIsDisabled:e.disabled,hardwareIsReady:s==="READY",hardwareIsMoving:s==="MOVING",readOnly:e.readOnly})]})]})]}),children:n.jsx(a.Button,{children:n.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Me(e){const{hardware:t,options:r={}}=e;function s(){t.requestChange({function:"stop"})}function i(u){return t.requestChange({property:"position",value:u,function:"move"})}let o="UNKNOWN";e.hardware.properties.state&&([o]=e.hardware.properties.state);const d=n.jsx(N,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),l=n.jsx(K,{hardware:t}),h=e.options?e.options.header:"top";return n.jsx(E,{hardware:t,widgetIcon:d,widgetState:l,widgetContent:n.jsxs(a.InputGroup,{children:[n.jsx(W,{id:t.id,hardwareValue:t.properties.position,hardwareIsDisabled:e.disabled,hardwareIsReady:o==="READY",hardwareIsMoving:o==="MOVING",onMoveRequested:i,onAbortRequested:s,precision:r.precision,readOnly:r.readOnly,step:r.step,steps:r.steps,incIcon:r.incicon,decIcon:r.decicon,swapIncDec:r.swapincdec,horizontalArrows:r.horizontalarrows,largeArrows:r.largearrows}),t.properties.unit&&n.jsx(a.InputGroup.Text,{children:t.properties.unit}),o!=="MOVING"&&r.extended&&n.jsx(Ee,{hardware:t,disabled:e.disabled,readOnly:r.readOnly}),o==="MOVING"&&!e.disabled&&!r.step&&n.jsx(a.Button,{variant:"danger",onClick:s,children:n.jsx("i",{className:"fa fa-times"})})]}),headerMode:h})}function Ae(e){const{hardware:t,options:r={}}=e,s=m.useRef(null);m.useEffect(()=>{if(!s.current){console.error("selectionRef ref is unset");return}s.current.value=t.properties.position},[t.properties.position]);function i(l){if(console.debug("change",l),!s||!s.current){console.error("selection ref is unset");return}t.requestChange({value:s.current.value,function:"move"})}function o(l){t.requestChange({function:"stop"})}const d=w.map(t.properties.positions,l=>n.jsx("option",{title:l.description,children:l.position},l.position));return n.jsxs("div",{className:"hw-component",children:[n.jsxs("div",{className:"hw-head",children:[n.jsx(N,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),n.jsx("div",{className:"name",children:t.name}),n.jsx(a.Badge,{bg:t.properties.state==="READY"?"success":"warning",children:t.properties.state})]}),n.jsx("div",{className:"hw-content",children:n.jsxs(a.InputGroup,{children:[n.jsxs(a.Form.Control,{className:"custom-select",as:"select",ref:s,disabled:e.disabled,defaultValue:t.properties.position,children:[n.jsx("option",{disabled:!0,children:"unknown"}),d]}),t.properties.state!=="MOVING"&&n.jsx(a.Button,{onClick:i,disabled:e.disabled,children:"Move"}),t.properties.state==="MOVING"&&!e.disabled&&n.jsx(a.Button,{variant:"danger",onClick:o,children:n.jsx("i",{className:"fa fa-times"})})]})})]})}const Fe=pe.default("daiquiri.components.hardware.NoObject");function Ie(e){if(e.options.emptyifnone)return Fe('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',e.id,e.name),n.jsx(n.Fragment,{});const t=n.jsx(N,{name:"NoObject",icon:"fam-hardware-any",online:!1}),r=n.jsx(n.Fragment,{}),s=n.jsx(n.Fragment,{children:"Missing"}),i=e.options?e.options.header:"top",o={id:e.id,name:e.name??"",alias:null,online:!1,properties:{},type:""};return n.jsx(E,{hardware:o,widgetIcon:t,widgetState:r,widgetContent:s,headerMode:i})}function ke(e){const t=e.online?"READY":"OFFLINE";return n.jsx(a.Badge,{bg:t==="READY"?"success":"warning",children:t})}function De(e){const{hardware:t,options:r={}}=e,s=n.jsx(N,{name:"Optic",icon:"fa-cog",online:t.online}),i=n.jsx(ke,{...t});function o(){const c=r.property;if(c===void 0)return"property is not set";if(c===null)return"property is null";let f=t;for(const g of c.split("/"))if(f=f[g],f===void 0)return`property '${c}' not found`;return`${f}`}function d(){const c=r.unit;if(!c)return null;if(!c.includes("properties"))return c;let f=e;for(const g of c.split("/"))if(f=f[g],f===void 0)return null;return`${f}`}const l=d(),h=n.jsxs(a.InputGroup,{children:[n.jsx(a.Form.Control,{value:o(),readOnly:!0}),l&&n.jsx(a.InputGroup.Text,{children:l})]}),u=e.options.header||"top";return n.jsx(E,{hardware:t,widgetIcon:s,widgetState:i,widgetContent:h,headerMode:u})}function $e(e){const{hardware:t}=e,r=()=>{t.requestChange({function:"reset"})};return n.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:n.jsxs(a.Popover,{id:"popid",children:[n.jsxs(a.Popover.Header,{children:[t.name," Details"]}),n.jsxs(a.Popover.Body,{children:[n.jsx("h6",{children:"Status"}),n.jsx("pre",{children:t.properties.status}),n.jsx("div",{className:"d-grid gap-2",children:n.jsx(a.Button,{onClick:r,disabled:e.disabled,children:"Reset"})})]})]}),children:n.jsx(a.Button,{className:"flex-grow-0",title:"Shutter Details",children:n.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Pe(e){const{hardware:t,options:r={}}=e,s=n.jsx(N,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),i=n.jsx(U,{hardware:t});function o(){return t.properties?t.properties.state:"UNKNOWN"}function d(v){return v==="OPEN"?["Close","close"]:v==="CLOSED"?["Open","open"]:v==="DISABLED"||v==="STANDBY"||v==="FAULT"?["Closed",""]:v==="MOVING"?["...",""]:["Unknown",""]}const l=o(),[h,u]=d(l),f={OPEN:"danger",CLOSED:"success",MOVING:"warning",DISABLED:"secondary",STANDBY:"danger",FAULT:"fatal",UNKNOWN:"warning"}[l]||"danger";function g(){t.requestChange({function:u})}const C=n.jsxs(a.ButtonGroup,{className:"d-flex flex-nowrap",children:[n.jsx(a.Button,{variant:f,onClick:g,disabled:e.disabled||u==="",children:h}),r.extended&&n.jsx($e,{...e})]}),I=e.options.header||"top";return n.jsx(E,{hardware:t,widgetIcon:s,widgetState:i,widgetContent:C,headerMode:I})}class Re extends m.Component{constructor(){super(...arguments),this.variants={}}render(){let t=this.variants.default;return this.props.options.variant in this.variants&&(t=this.variants[this.props.options.variant]),n.jsx(t,{...this.props})}}function Z(e){const[t,r]=m.useState({}),s=m.useRef(null);return m.useEffect(()=>{if(s.current){const i=s.current;r({width:i.clientWidth,height:i.clientHeight})}},[]),n.jsx("div",{ref:s,style:{width:"100%",height:"100%"},className:e.className,children:t.width>0&&n.jsx("div",{className:"full-sizer",style:{width:`${t.width}px`,height:`${t.height}px`,overflow:"scroll"},children:e.children})})}function Te(e){return n.jsx("div",{className:"panel-header",style:e.style,children:e.children})}function He(e){return n.jsx("div",{className:"panel-contents",style:e.style,children:e.children})}function p(e){const t=e.scroll?Z:m.Fragment;return n.jsx("div",{className:`panel ${e.className??""}`,style:e.style,children:n.jsx(t,{children:e.children})})}p.Header=Te;p.Contents=He;const _e=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Be=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),M={};function J(e,t){M[e]=t}function y(e,t,r=!0){if(!e)return n.jsx(n.Fragment,{});const{type:s}=e,i=s&&s in M?M[s]:M.component;return n.jsx(i,{yamlNode:e,panel:r},t)}function Ve({children:e,key:t,panel:r,options:s}){return r?n.jsx(p,{style:s.style,scroll:s.scroll,children:n.jsx(p.Contents,{children:e})},t):n.jsx(n.Fragment,{children:m.Children.map(e,i=>m.isValidElement(i)?m.cloneElement(i,{key:t,...i.props}):void 0)})}function Q(e,t){const{_parentNode:r,_indexFromParent:s,...i}=t;if(e&&Object.keys(i).length>0)throw new A(e,Object.keys(i))}class b extends Error{constructor(t,r){super(t),this.yamlNode=r}}class A extends b{constructor(t,r){super(`Unexpected keys: ${r.join(", ")}`,t),this.keys=r}}class S extends b{constructor(t,r){super(`Keys ${r.join(", ")} are missing`,t),this.keys=r}}class x extends b{constructor(t,r,s){super(`Key ${r} error: ${s}`,t),this.key=r,this.keyMessage=s}}function Ye(e){let t=e;for(;t._parentNode;)t=t._parentNode;return t}function Le(e){const t=[];let r=e;for(;r;)t.push({node:r,indexFromParent:r._indexFromParent}),r=r._parentNode;return t.reverse(),t}function X(e,t=null,r=null){if(e._parentNode)throw new Error("Attribute _parentNode was already defined by the yml layout.");const s={...e,_parentNode:t,_indexFromParent:r};if(e.children){const i=[...e.children];Object.freeze(i),s.children=i.map((o,d)=>X(o,s,d))}return Object.freeze(s),s}function ee(e){var t;return n.jsxs(a.Alert,{variant:"danger",children:[e.message,n.jsx("br",{}),n.jsx("pre",{children:(t=e.error)==null?void 0:t.stack})]})}function qe(e){const{error:t}=e;if(!(t instanceof b))return n.jsx(n.Fragment,{});function r(o,d=3){const l=Le(o.yamlNode),h=[];let u="";for(let c=1;c<l.length;c++){const{node:f,indexFromParent:g}=l[c];h.push(`${u}children:`),u+=" ".repeat(d),g===1?h.push(`${u}- type: ...`):(g??0>1)&&h.push(`${u}...`,`${u}...`,`${u}# children number ${g??0+1}`),h.push(`${u}- type: ${f.type}`),u+=" ".repeat(2)}return o instanceof A?o.keys.forEach(c=>{h.push(`${u}${c}: ... ${" ".repeat(50-u.length-c.length)}<-- unexpected key`)}):o instanceof S?o.keys.forEach(c=>{h.push(`${u}???: ${" ".repeat(50-u.length-c.length)}<-- key **${c}** is expected`)}):o instanceof x&&h.push(`${u}${o.key}: ${" ".repeat(50-u.length-o.key.length)}<-- ${o.keyMessage}`),h.join(`
2
- `)}const i=Ye(t.yamlNode).name;if(t instanceof A){const o=t.keys.length===1?"key":"keys";return n.jsxs(a.Alert,{variant:"danger",children:["Unexpected ",o," ",t.keys.map((d,l)=>n.jsxs(n.Fragment,{children:[l!==0&&", ",n.jsx("b",{children:d})]}))," ","from the layout name ",n.jsx("b",{children:i}),".",n.jsx("br",{}),n.jsx("pre",{className:"mt-3",children:r(t)}),n.jsx("br",{})]})}if(t instanceof S){const o=t.keys.length===1?"Key":"Keys";return n.jsxs(a.Alert,{variant:"danger",children:["Expected ",o," ",t.keys.map((d,l)=>n.jsxs(n.Fragment,{children:[l!==0&&", ",n.jsx("b",{children:d})]}))," ","from the layout name ",n.jsx("b",{children:i}),".",n.jsx("br",{}),n.jsx("pre",{className:"mt-3",children:r(t)}),n.jsx("br",{})]})}return t instanceof x?n.jsxs(a.Alert,{variant:"danger",children:["Error on key ",n.jsx("b",{children:t.key})," from the layout name ",n.jsx("b",{children:i}),".",n.jsx("br",{}),n.jsx("pre",{className:"mt-3",children:r(t)}),n.jsx("br",{})]}):n.jsx(ee,{...e})}const Y={hasError:!1,message:"",error:void 0};class te extends m.Component{constructor(t){super(t),this.reload=()=>{window.location.reload()},this.state=Y}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){var r,s;if(t instanceof b||!this.props.unhandledComponentDidCatch){this.setState({hasError:!0,message:t.message,error:t});return}(s=(r=this.props).unhandledComponentDidCatch)==null||s.call(r,t,i=>{this.setState({hasError:!0,message:t.message,error:t,...i})})}componentDidUpdate(t,r){this.state.hasError&&r.error!==void 0&&t.resetKey!==this.props.resetKey&&this.setState(Y)}render(){if(this.state.hasError){const{UnhandledErrorComponent:t}=this.props,{hasError:r,...s}=this.state;return n.jsxs(a.Container,{className:"mt-2",children:[n.jsx("h4",{children:"Something went wrong"}),this.state.error instanceof b&&n.jsx(qe,{message:this.state.message,error:this.state.error}),!(this.state.error instanceof b)&&n.jsx(n.Fragment,{children:t?n.jsx(t,{...s}):n.jsx(ee,{message:this.state.message,error:this.state.error})}),n.jsxs("p",{children:["This error has been logged. Please"," ",n.jsxs(a.Button,{size:"sm",onClick:this.reload,children:[n.jsx("i",{className:"fa fa-refresh"})," Reload"]})," ","the application"]})]})}return this.props.children}}function Ge(e,t,r){if(e&&r===void 0)throw new S(e,[t])}function Ke(e,t,r){if(typeof r!="string")throw new x(e,t,"A string is expected")}function Ue(e,t,r){if(typeof r!="boolean")throw new x(e,t,"A boolean is expected")}function ze(e,t,r){if(typeof r!="number")throw new x(e,t,"A number is expected")}function $(e,t,r){if(r!==void 0&&typeof r!="boolean")throw new x(e,t,"An optional boolean is expected")}function ne(e,t,r){if(r!==void 0&&typeof r!="string")throw new x(e,t,"An optional string is expected")}function We(e,t,r){if(!Array.isArray(r))throw new x(e,t,"A list of string is expected");r.forEach(s=>{if(typeof s!="string")throw new x(e,t,"A list of string is expected")})}function Ze(e,t,r){if(r!==void 0&&typeof r!="string"){if(!Array.isArray(r))throw new x(e,t,"An optional string or list of string is expected");r.forEach(s=>{if(typeof s!="string")throw new x(e,t,"An optional string or list of string is expected")})}}function Je(e,t,r){if(r!==void 0){if(!Array.isArray(r))throw new x(e,t,"An optional list of string is expected");r.forEach(s=>{if(typeof s!="string")throw new x(e,t,"A optional list of string is expected")})}}function re(e,t,r){if(r!==void 0&&typeof r!="number")throw new x(e,t,"An optional number is expected")}function Qe(e,t,r){if(r!==void 0){if(!Array.isArray(r))throw new x(e,t,"An optional list of numbers is expected");r.forEach(s=>{if(typeof s!="number")throw new x(e,t,"An optional list of numbers is expected")})}}function F(e,t){const{_parentNode:r,_indexFromParent:s,...i}=t;if(e&&Object.keys(i).length>0)throw new A(e,Object.keys(i))}function Xe(e,t,r){if(r!=="last"&&typeof r!="number")throw new x(e,t,'"last" or a number is expected')}function et(e,t,r){if(r!==void 0&&r!=="h5web"&&r!=="plotly")throw new x(e,t,'"h5web" or "plotly" string is expected')}const tt=Object.freeze(Object.defineProperty({__proto__:null,assertBoolean:Ue,assertDataCollectionId:Xe,assertKeyExpected:Ge,assertNoUnknownKeys:F,assertNumber:ze,assertOptionalBackend:et,assertOptionalBoolean:$,assertOptionalNumber:re,assertOptionalNumberList:Qe,assertOptionalString:ne,assertOptionalStringList:Je,assertOptionalStringOrStringList:Ze,assertString:Ke,assertStringList:We},Symbol.toStringTag,{value:"Module"}));function nt({yamlNode:e,panel:t}){const{type:r,style:s,children:i,...o}=e;return F(e,o),n.jsx(a.Row,{className:"ymllayout-row gx-0",style:s,children:w.map(i,(d,l)=>y(d,l,t))})}function rt({yamlNode:e,panel:t}){const{type:r,style:s,xs:i,children:o,...d}=e;return F(e,d),re(e,"xs",i),n.jsx(a.Col,{className:O.default("yamymllayout-col",{col:!!i}),style:s,xs:i,children:w.map(e.children,(l,h)=>y(l,h,t))})}const P={};function st(e,t){P[e]=t}function it(e,t){if(t===void 0)throw new S(e,["id"]);if(typeof t.id!="string")throw new x(e,"id","A string is expected")}function ot(e,t,r){if(r!==void 0){if(!Array.isArray(r))throw new x(e,"ids","A option list is expected");r.forEach((s,i)=>{try{it(e,s)}catch{throw new x(e,"ids",`The hardware description ${i} is wrong`)}})}}function at(e){const{providers:t={},yamlNode:r,ids:s,groupid:i,even:o,nowrap:d,...l}=e;if(ot(r,"ids",s),ne(r,"groupid",i),$(r,"even",o),$(r,"nowrap",d),F(r,l),!P.HardwareGroup)return n.jsx(a.Alert,{variant:"warning",children:"No `HardwareGroup` component registered"});const h=P.HardwareGroup;return n.jsx(h,{providers:t,ids:s,groupid:i,nowrap:d||!1,even:o||!1})}const R={hardwaregroup:at};function se(e,t){R[e]=t}function lt(e){Object.entries(e).forEach(([t,r])=>se(t,r))}function ct(e){const{yamlNode:t,panel:r}=e,{type:s,style:i,scroll:o,title:d,...l}=t;if(!(s in R))return n.jsx(p,{children:n.jsx(p.Contents,{children:n.jsxs(a.Alert,{variant:"warning",children:['Unknown component "',s,'"']})})});const h=R[t.type];return r?n.jsx(p,{style:i,scroll:o,children:n.jsxs(m.Suspense,{fallback:n.jsx("p",{children:"Loading..."}),children:[d&&n.jsx(p.Header,{children:d}),n.jsx(p.Contents,{children:n.jsx(h,{...l,yamlNode:t})})]})}):n.jsx(m.Suspense,{fallback:n.jsx("p",{children:"Loading..."}),children:n.jsx(h,{...l,yamlNode:t})})}function dt({yamlNode:e,panel:t}){const r=e.options||{};return n.jsx(a.Container,{className:"ymllayout-container",...r,children:w.map(e.children,(s,i)=>y(s,i,t))})}function ut(e){const{yamlNode:t}=e,r=t.options||{},s={};return r.centerContent&&(s.margin="auto"),n.jsxs(p,{className:"ymllayout-panel",...r,children:[t.title&&n.jsx(p.Header,{children:t.title}),n.jsx(p.Contents,{style:s,children:w.map(t.children,(i,o)=>y(i,o,!1))})]})}const ht=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15);function ft({yamlNode:e,panel:t}){const r=[];return w.each(e.children,(s,i)=>{r.push(n.jsx(a.Tab,{eventKey:ht(),title:s.title,children:y(s,0,!1)},i))}),t?n.jsxs(p,{className:"ymllayout-tabs",children:[e.title&&n.jsx(p.Header,{children:e.title}),n.jsx(p.Contents,{children:n.jsx(a.Tabs,{mountOnEnter:!0,children:r})})]}):n.jsx(a.Tabs,{children:r})}function mt(e){const{node:t}=e,{type:r,title:s,...i}=t;return Q(t,i),n.jsx("div",{style:{gridColumn:"1 / 3"},children:n.jsx("h3",{children:s})})}function pt(e){const{node:t,state:r,row:s}=e,{title:i}=t;function o(){if(t.id)return t.id}function d(){if(i!==void 0)return i;if(t.type==="hardware"){const h=o(),u={_parentNode:t._parentNode,_indexFromParent:t._indexFromParent,type:"hardware",id:h,variant:"name",emptyifnone:!0};return y(u,"a",!1)}return""}const l=d();return n.jsxs("div",{style:{textAlign:"center"},children:[n.jsx("h5",{style:{margin:"0px",whiteSpace:"nowrap"},children:l}),r&&n.jsx("div",{style:{position:"relative",top:-5},children:r})]})}function xt(e){const{node:t,row:r}=e,{titlealign:s,title:i,stateinheader:o=!1,variant:d,id:l,...h}=t;let u,c;if(h.type==="hardware")if(u={...h,id:l,variant:d},o){const f={...h,id:l,variant:"state",emptyifnone:!0};c=y(f,"k",!1)}else c=null;else u=h,c=null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{gridColumn:1,alignSelf:s??"center"},children:n.jsx(pt,{node:t,state:c,row:r})}),n.jsx("div",{style:{gridColumn:2},children:y(u,"k",!1)})]})}function gt(e){const{yamlNode:t,panel:r}=e,{type:s,children:i,options:o={},title:d,...l}=t;return Q(t,l),n.jsxs(p,{className:"ymllayout-form",...o,children:[t.title&&n.jsx(p.Header,{children:t.title}),n.jsx(p.Contents,{children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:"min-content auto"},children:w.map(i,(h,u)=>h.type==="formheader"?n.jsx(mt,{node:h,row:u},u):n.jsx(xt,{node:h,row:u},u))})})]})}function jt(e){const{yamlNode:t,panel:r}=e;return n.jsxs("div",{className:"ymllayout-grid",style:{gridTemplateColumns:t.columns,gridTemplateRows:t.rows},children:[w.map(t.children,(s,i)=>{const{columnSpan:o=1,rowSpan:d=1,...l}=s,h=o>1?`span ${o}`:void 0,u=d>1?`span ${d}`:void 0;return n.jsx("div",{className:"ymllayout-grid-cell",style:{gridColumn:h,gridRow:u},children:y(l,i,r)},i)})," "]})}function wt({yamlNode:e,panel:t}){const r=e.options||{};return n.jsx(Ve,{panel:t,options:r,children:n.jsx("div",{children:e.label})})}const ie={row:nt,col:rt,container:dt,component:ct,panel:ut,tabs:ft,form:gt,grid:jt,label:wt};Object.entries(ie).forEach(([e,t])=>{J(e,t)});function yt(e){var r;const t=m.useMemo(()=>X(e.layout),[e.layout]);return t.error?n.jsx("div",{className:`${e.className??""} ymllayout-main`,id:e.id,children:n.jsxs(p,{children:[n.jsx(p.Header,{children:"Layout Error"}),n.jsxs(p.Contents,{children:[n.jsxs("p",{children:["File: ",t.name]}),n.jsx(a.Alert,{variant:"warning",children:n.jsx("pre",{className:"mb-0",children:t.error})})]})]})}):n.jsx("div",{className:`${e.className??""} ymllayout-main`,id:e.id,children:n.jsx(te,{resetKey:t,unhandledComponentDidCatch:e.unhandledComponentDidCatch,UnhandledErrorComponent:e.UnhandledErrorComponent,children:(r=t.children)==null?void 0:r.map((s,i)=>y(s,i))})})}const vt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),oe={hardware:ue};function bt(e,t){oe[e]=t}function Nt(e){return n.jsxs(a.Col,{className:"monitor-panel-item bg-fatal",title:`Error from yaml configuration: ${e.message}`,children:[n.jsx("h1",{children:e.monitor.name}),n.jsx("div",{children:"Parsing error"})]})}function Ct(e){const t=w.map(e.monitors,(r,s)=>{const i=r.type??"hardware",o=oe[i];return o===void 0?n.jsx(Nt,{monitor:r,message:`Type ${i} unsupported`},`m${s}`):n.jsx(o,{monitor:r},`m${s}`)});return n.jsx("div",{className:O.default({"ms-auto":e.margin==="start"},"me-auto","monitor-panel",{"monitor-panel-light":e.bg==="light"}),children:n.jsx(a.Container,{fluid:!0,children:n.jsx(a.Row,{className:"flex-nowrap",children:t})})})}function ae(e){return n.jsx(a.Col,{className:"monitor-panel-item",children:e.children})}const T={};function St(e,t){T[e]=t}function le(e){if(!T.useHardware)throw new Error("No `useHardware` hook registered");return T.useHardware(e)}const ce=(e,t,r)=>{const s={">":(i,o)=>i>o,"<":(i,o)=>i<o,">=":(i,o)=>i>=o,"<=":(i,o)=>i<=o,"==":(i,o)=>i===o,"!=":(i,o)=>i!==o,in:(i,o)=>o.indexOf(i)>-1};if(e in s)return s[e](t,r)};function de(e,t,r){const s=e.split(t);return r?[s.slice(0,-r).join(t)].concat(s.slice(-r)):s}function L(e){const t=e!==void 0?de(e,".",1):[null,""],r=le(t[0]);if(r&&r.properties&&t[1]!==null)return Array.isArray(r.properties[t[1]])?r.properties[t[1]][0]:r.properties[t[1]]}function Ot(e){const t=e!==void 0&&!e.includes("."),r=e!==void 0?de(e,".",1):[null,""],s=le(r[0]);if(t)return e;if(s&&s.properties&&r[1]!==null)return`${s.properties[r[1]]}`}function ue(e){const{monitor:t}=e;let r=L(t.value)??"-";const s=Ot(t.unit),i=L(t.overlay),o=Number.parseFloat(`${r}`);Number.isNaN(o)||String(o).length>5&&(r=o.toPrecision(5));let d;t.comparator&&t.comparison&&(d=ce(t.comparator,r,t.comparison)?"valid":"invalid"),Number.isNaN(o)||s!==void 0&&(r=`${r} ${s}`);let l=m.Fragment;const h={};if(i){const u=`${i}`;let c=m.Fragment;u.includes(`
3
- `)&&(c="pre"),l=a.OverlayTrigger,h.placement="bottom",h.overlay=n.jsx(a.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:n.jsx(c,{children:u})})}return m.createElement(l,{...h,key:t.name},n.jsxs(ae,{children:[n.jsx("h1",{children:t.name}),n.jsx("div",{className:d,children:`${r}`})]}))}exports.Formatting=ve;exports.Frontend=Ne;exports.FullSizer=Z;exports.HWObject=vt;exports.HardwareInputNumber=D;exports.HardwareNumericStep=W;exports.HardwareSchema=Be;exports.HardwareState=Se;exports.HardwareTemplate=E;exports.HardwareTypes=_e;exports.HardwareVariant=Re;exports.Info=Ce;exports.KeyError=x;exports.MissingKeysError=S;exports.MonitorHardware=ue;exports.MonitorPanel=Ct;exports.MonitorPanelItem=ae;exports.MotorDefault=Me;exports.Multiposition=Ae;exports.NoObject=Ie;exports.NumericStep=z;exports.Panel=p;exports.Property=De;exports.ShutterDefault=Pe;exports.TypeIcon=N;exports.YAMLErrorBoundary=te;exports.YAMLLayout=yt;exports.YamlAsserts=tt;exports.dynamicOp=ce;exports.registerHardwareComponent=st;exports.registerMonitorComponent=bt;exports.registerRuntimeHook=St;exports.registerYamlComponent=se;exports.registerYamlComponents=lt;exports.registerYamlType=J;exports.renderYamlNode=y;exports.yamlMap=ie;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),y=require("lodash"),a=require("react-bootstrap"),p=require("react"),ye=require("classnames"),ve=require("debug"),q=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},A=q(ye),Ne=q(ve);function be(e){const{activeMessage:t="Online",inactiveMessage:r="Offline",message:i="This device is"}=e;return n.jsx("div",{className:`dot-indicator small bg-${e.online?"success":"danger"}`,title:`${i} ${e.online?t:r}`})}function C(e){const{name:t,icon:r}=e;return n.jsxs("div",{className:"icon",title:t,children:[n.jsx("i",{className:`fa ${r}`}),n.jsx(be,{...e})]})}function Ce(e){const t={24:"Y",21:"Z",18:"E",15:"P",12:"T",9:"G",6:"M",3:"k","-3":"m","-6":"µ","-9":"n","-12":"p","-15":"f","-18":"a","-21":"z","-24":"y"},r=Math.log(e)/Math.log(1e3),i=!Number.isInteger(r),s=3*Math.ceil(r-(i?1:0)),o=s===0?"":t[s];return{scalar:e*10**-s,prefix:o,multiplier:10**-s}}function Se(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Z(e){if(e<60)return`${Math.round(e)} sec`;const t=Math.round(e/60),r=t%60,i=Math.floor(t/60);return i?`${i} hr ${r} min`:`${r} min`}function Oe(e){return e>0?(662607004e-42*299792458/(e*1e-10)/160218e-24*.001).toFixed(4):0}function Ee(e,t){return Number.parseFloat(e.toFixed(t))}const Me=Object.freeze(Object.defineProperty({__proto__:null,formatEng:Ce,round:Ee,toEnergy:Oe,toHoursMins:Z,ucfirst:Se},Symbol.toStringTag,{value:"Module"}));function Ae(e){const{hardware:t}=e;function r(){t.actions.call("reset")}const i={"Front End":"feitlk",Experimental:"expitlk",PSS:"pssitlk"},s={Current:`${t.properties.current.toFixed(1)} mA`,Mode:t.properties.mode,Refill:Z(t.properties.refill),Message:n.jsx("pre",{children:t.properties.message})};function o(c){if(!(c in t.properties))return"UNKNOWN";const l=t.properties[c];return!l||typeof l!="string"?"UNKNOWN":l}return n.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:n.jsxs(a.Popover,{id:"popid",children:[n.jsxs(a.Popover.Header,{children:[t.name," Details"]}),n.jsxs(a.Popover.Body,{children:[n.jsx("h6",{children:"Status"}),n.jsx("pre",{children:t.properties.status}),n.jsx("h6",{children:"Interlocks"}),n.jsx(a.Container,{children:y.map(i,(c,l)=>n.jsxs(a.Row,{children:[n.jsxs(a.Col,{children:[l,":"]}),n.jsx(a.Col,{children:n.jsx(a.Badge,{bg:o(c)==="ON"?"success":"danger",children:o(c)})})]},l))}),n.jsx("h6",{children:"Ring Status"}),n.jsx(a.Container,{children:y.map(s,(c,l)=>n.jsxs(a.Row,{children:[n.jsxs(a.Col,{children:[l,":"]}),n.jsx(a.Col,{children:c})]},l))}),n.jsx("div",{className:"d-grid gap-2",children:n.jsx(a.Button,{disabled:e.disabled,onClick:r,children:"Reset"})})]})]}),children:n.jsx(a.Button,{className:"flex-grow-0",title:"Shutter Details",children:n.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Fe(e){const{hardware:t,options:r={}}=e;function i(){t.actions.call(t.properties.frontend==="FE open"?"close":"open")}return n.jsxs("div",{className:"hw-component",children:[n.jsxs("div",{className:"hw-head",children:[n.jsx(C,{name:"Frontend",icon:"fam-hardware-frontend",online:t.online}),n.jsx("div",{className:"name",children:t.name}),n.jsx(a.Badge,{bg:t.properties.state==="OPEN"||t.properties.state==="RUNNING"?"success":"danger",children:t.properties.state})]}),n.jsx("div",{className:"hw-content",children:n.jsxs(a.ButtonGroup,{className:"d-flex",children:[n.jsx(a.Button,{variant:t.properties.frontend==="FE open"?"danger":"success",onClick:i,disabled:e.disabled,children:t.properties.frontend==="FE open"?"Close":"Open"}),n.jsx(Ae,{...e})]})})]})}function Ie(e){const{hardware:t,options:r={}}=e;function i(){const s=r.property;if(s===void 0)return"property is not set";if(s===null)return"property is null";let o=t;for(const c of s.split("/"))if(o=o[c],o===void 0)return`property '${s}' not found`;return`${o}`}return n.jsx(n.Fragment,{children:i()})}function F(e){const{headerMode:t,hardware:r}=e;function i(){return r.alias?r.alias:r.name?r.name:r.id}const s=i();switch(t){case"front":return n.jsx("div",{className:"hw-component",children:n.jsxs("div",{className:"hw-single",children:[e.widgetIcon,n.jsx("div",{className:"name",children:s}),n.jsx("div",{className:"d-inline-block",children:e.widgetContent})]})});case"none":return n.jsx("div",{className:"hw-component",children:n.jsx("div",{className:"hw-single",children:e.widgetContent})});case"state":return e.widgetState;default:return n.jsxs("div",{className:"hw-component",children:[n.jsxs("div",{className:"hw-head",children:[e.widgetIcon,n.jsx("div",{className:"name",children:n.jsx(a.Form.Label,{htmlFor:r.id,children:s})}),e.widgetState,e.hardware.errors&&e.hardware.errors.length>0&&n.jsx(a.OverlayTrigger,{trigger:"click",placement:"bottom",rootClose:!0,overlay:n.jsxs(a.Popover,{id:e.hardware.id,style:{maxWidth:500},children:[n.jsx(a.Popover.Header,{children:"Device Errors"}),n.jsxs(a.Popover.Body,{children:["There were errors with properties on this device:",n.jsx("ul",{children:e.hardware.errors.map(o=>n.jsxs("li",{children:[o.property,":",n.jsxs("span",{className:"stack-trace",children:[o.traceback,n.jsx("br",{}),o.exception]})]}))})]})]}),children:n.jsx(a.Button,{variant:"danger",size:"sm",children:n.jsx("i",{className:"fa fa-exclamation-triangle"})})})]}),n.jsx("div",{className:"hw-content",children:e.widgetContent})]})}}function k(e){const t={display:"inline-block",minWidth:""};return e.minWidth&&(t.minWidth=`${e.minWidth}em`),n.jsx("div",{style:t,children:n.jsx(a.Badge,{bg:e.variant,title:e.description,children:e.state})})}function J(e){const{states:t,variants:r={},descriptions:i={},minWidth:s}=e,o=t[0]??"";if(t.length===0)return n.jsx(k,{state:"NoState",variant:"fatal",description:"The device no not expose any state",minWidth:s});if(t.length===1)return n.jsx(k,{state:o,variant:r[o]??"fatal",description:i[o],minWidth:s});const c={display:"inline-block",minWidth:s?`${s}em`:""};function l(u){return n.jsx(a.Tooltip,{id:"device-state",...u,children:t.map((h,f)=>{const d=i[h],m=h.startsWith("_")?h.slice(1):h;return n.jsxs(a.Row,{className:"gx-0",children:[n.jsx(a.Col,{sm:"3",className:"text-end",children:n.jsx(a.Badge,{className:"text-right",bg:r[h]??"fatal",children:m})}),n.jsx(a.Col,{sm:"9",className:"text-start lh-1 my-auto ps-1",children:d})]})})})}return n.jsx("div",{style:c,children:n.jsx(a.OverlayTrigger,{placement:"top",delay:{show:250,hide:400},overlay:l,children:n.jsxs("span",{className:"text-nowrap",children:[n.jsx(a.Badge,{className:"rounded-end-0",bg:r[o]??"fatal",children:o}),n.jsxs(a.Badge,{className:"rounded-start-0",bg:"secondary",children:["+",t.length-1]})]})})})}const De=Object.freeze(Object.defineProperty({__proto__:null,HardwareMultiState:J,HardwareState:k},Symbol.toStringTag,{value:"Module"})),_={description:"Unknown state is exposed",variant:"fatal",priority:100},I={OFFLINE:{description:"Axis is offline",variant:"secondary",priority:0},MOVING:{description:"Axis is moving",variant:"warning",priority:10},FAULT:{description:"Axis is in fault",variant:"danger",priority:20},LOCKED:{description:"Axis is locked",variant:"warning",priority:25},OFF:{description:"Power is off",variant:"secondary",priority:30},DISABLED:{description:"Axis is disabled",variant:"warning",priority:40},LOWLIMIT:{description:"Low limit is reached",variant:"warning",priority:50},HIGHLIMIT:{description:"High limit is reached",variant:"warning",priority:51},HOME:{description:"Home signal active",variant:"info",priority:52},READY:{description:"Ready to handle request",variant:"success",priority:60},NOT_READY:{description:"Not ready",variant:"warning",priority:100},UNKNOWN:_};function Q(e){const{hardware:t}=e,{locked:r=null}=t,{state:i=["UNKNOWN"]}=t.properties,[s,o]=p.useMemo(()=>{if(!t.online)return[["OFFLINE"],void 0];function c(d,m){const w=I[d]??_,S=I[m]??_;return w.priority-S.priority}const l=[...i,...r!==null?["LOCKED"]:[],...i.length===0?["NOT_READY"]:[]];l.sort(c);function u(d){const m=d.split(":",2);return m.length===1?[d,void 0]:m}const h={};return[l.map(d=>{if(d.startsWith("_")){const m=u(d);return m[1]!==void 0&&(h[m[0]]=m[1]),m[0]}return d==="LOCKED"?h[d]=`Locked by ${r}`:h[d]=I[d].description??"",d}),h]},[i,t.online,r]);return n.jsx(J,{states:s,descriptions:o,minWidth:6,variants:Object.fromEntries(Object.entries(I).map(([c,l])=>[c,l.variant]))})}const ke=p.forwardRef((e,t)=>{const r=p.useRef(null),i=p.useRef(),[s,o]=p.useState(e.step),[c,l]=p.useState(!1),u=x=>{const $=t;if(r.current===null)return;let O=Number.parseFloat($.current.value);if(r.current.value.startsWith("*")){const E=Number.parseFloat(r.current.value.replace("*",""));O=x?O*E:O/E}else{const E=Number.parseFloat(r.current.value);O+=x?E:-E}$.current.value=`${O}`,e.onStep&&e.onStep({target:$.current})},{onStep:h,step:f,overlay:d,incIcon:m,decIcon:w,swapIncDec:S,onKeyDown:N,onBlur:Y,horizontalArrows:ge,largeArrows:je,...G}=e,K=x=>{x.key==="ArrowUp"?(x.preventDefault(),l(!0),u(!0)):x.key==="ArrowDown"?(x.preventDefault(),l(!0),u(!1)):N&&N(x)};c&&(i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{var x;(x=t==null?void 0:t.current)==null||x.focus()},100)),p.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const U=()=>{i.current&&clearTimeout(i.current),l(!1),Y&&Y()};if(!e.step)return n.jsx(a.Form.Control,{ref:t,type:"number",step:"any",onKeyDown:K,onBlur:U,...G});const we=y.map(e.steps||[e.step],x=>n.jsx("option",{value:x,children:x},x));return n.jsx("div",{className:A.default("numeric-step",{"numeric-step-large":je,"numeric-step-horizontal":ge}),children:n.jsxs(a.InputGroup,{children:[n.jsx(a.Form.Control,{onKeyDown:K,onBlur:U,ref:t,type:"number",step:"any",...G}),n.jsxs(n.Fragment,{children:[d,!d&&n.jsxs(a.InputGroup.Text,{className:"d-flex flex-column",children:[n.jsx(a.Form.Control,{ref:r,as:"select",className:"step-size",defaultValue:s,onChange:x=>o(Number.parseFloat(x.target.value)),children:we}),e.unit&&n.jsx("div",{children:e.unit}),!m&&!w&&n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{className:"step step-up",disabled:e.disabled,onClick:x=>u(!0)}),n.jsx(a.Button,{className:"step step-down",disabled:e.disabled,onClick:x=>u(!1)})]})]}),w&&S&&n.jsx(a.Button,{disabled:e.disabled,onClick:x=>u(!1),children:n.jsx("i",{className:`fa fa-fw fa-${w}`})}),m&&n.jsx(a.Button,{disabled:e.disabled,onClick:x=>u(!0),children:n.jsx("i",{className:`fa fa-fw fa-${m}`})}),w&&!S&&n.jsx(a.Button,{disabled:e.disabled,onClick:x=>u(!1),children:n.jsx("i",{className:`fa fa-fw fa-${w}`})})]})]})})}),X=ke;function ee(e){const t=p.useRef(null),[r,i]=p.useState(!1),[s,o]=p.useState(!1);p.useEffect(()=>{t.current&&(e.hardwareValue===null?t.current.value="":e.precision!==void 0?t.current.value=e.hardwareValue.toFixed(e.precision):t.current.value=e.hardwareValue.toString(),i(!1))},[e.hardwareValue]);function c(d){let m=d;e.precision!==void 0&&(m=Number.parseFloat(m).toFixed(e.precision)),t!=null&&t.current&&(t.current.value=m)}function l(){r&&setTimeout(()=>{c(e.hardwareValue),i(!1)},3e3)}function u(d){e.hardwareValue!==null&&i(d.target.value!==e.hardwareValue.toString())}function h(d){i(!1);const m=e.onMoveRequested(d.target.value);m&&m.catch(()=>{o(!0),setTimeout(()=>{c(e.hardwareValue),o(!1)},2e3)})}function f(d){switch(d.key){case"Enter":{i(!1);const m=Number.parseFloat(d.target.value),w=e.onMoveRequested(m);w&&w.catch(()=>{o(!0),setTimeout(()=>{c(e.hardwareValue),o(!1)},2e3)})}d.preventDefault(),d.stopPropagation();break;case"Esc":case"Escape":r&&(o(!1),i(!1),c(e.hardwareValue)),d.target.blur(),d.preventDefault(),d.stopPropagation();break}}return n.jsx(X,{id:e.id,className:A.default({"form-control-edited":r,"form-control-error":s,"hw-moving":e.hardwareIsMoving}),type:e.readOnly?"text":"number",ref:t,precision:e.precision,onChange:u,onBlur:l,onStep:h,onKeyDown:f,disabled:e.hardwareIsDisabled||e.readOnly||!e.hardwareIsReady,step:e.step,steps:e.steps,incIcon:e.incIcon,decIcon:e.decIcon,swapIncDec:e.swapIncDec,horizontalArrows:e.horizontalArrows,largeArrows:e.largeArrows,overlay:e.hardwareIsMoving&&!e.hardwareIsDisabled?n.jsx(a.Button,{variant:"danger",onClick:e.onAbortRequested,children:n.jsx("i",{className:"fa fa-times"})}):null})}function P(e){const t=p.useRef(null),[r,i]=p.useState(!1),[s,o]=p.useState(!1);function c(f){return e.precision!==void 0?Number.parseFloat(f).toFixed(e.precision):f}p.useEffect(()=>{var f;t.current&&(t.current.value=c((f=e.hardwareValue)==null?void 0:f.toString()),i(!1))},[e.hardwareValue,e.precision]);function l(f){const d=c(f);t!=null&&t.current&&(t.current.value=d)}function u(f){switch(f.key){case"Enter":{i(!1);const d=Number.parseFloat(f.target.value),m=e.onMoveRequested(d);m&&m.catch(()=>{o(!0),setTimeout(()=>{l(e.hardwareValue),o(!1)},2e3)}),f.preventDefault(),f.stopPropagation();break}case"Esc":case"Escape":r&&(o(!1),i(!1),l(e.hardwareValue)),f.target.blur(),f.preventDefault(),f.stopPropagation();break}}function h(f){i(f.target.value!==e.hardwareValue.toString())}return n.jsx(a.Form.Control,{className:A.default({"form-control-edited":r,"form-control-error":s,"hw-moving":e.hardwareIsMoving}),type:"number",ref:t,onChange:h,onKeyDown:u,disabled:e.readOnly||e.hardwareIsMoving||e.hardwareIsDisabled,step:e.step})}function Re(e,t=[]){return p.useMemo(()=>{const r=t.includes("auto_ready"),i=t.includes("auto_on");if(e===void 0)return{UNKNOWN:!0};if((e==null?void 0:e.length)===0)return r?{READY:!0}:{NOT_READY:!0};const s=e.reduce((o,c)=>(o[c]=!0,o),{});return s.READY===void 0&&i&&s.OFF&&(s.READY=!0),s},[e,t])}function Te(e){var s,o;const{states:t}=e;function r(c){return e.hardware.actions.setProperty("velocity",c)}function i(c){return e.hardware.actions.setProperty("acceleration",c)}return n.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:n.jsxs(a.Popover,{id:"popid",children:[n.jsxs(a.Popover.Header,{children:[e.hardware.name," details"]}),n.jsxs(a.Popover.Body,{children:[n.jsxs(a.Form.Group,{children:[n.jsx(a.Form.Label,{children:"Velocity"}),n.jsx(P,{hardwareValue:((s=e.hardware.properties)==null?void 0:s.velocity)??0,onMoveRequested:r,hardwareIsDisabled:e.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:e.readOnly})]}),n.jsxs(a.Form.Group,{children:[n.jsx(a.Form.Label,{children:"Acceleration"}),n.jsx(P,{hardwareValue:((o=e.hardware.properties)==null?void 0:o.acceleration)??0,onMoveRequested:i,hardwareIsDisabled:e.disabled,hardwareIsReady:t.READY,hardwareIsMoving:t.MOVING,readOnly:e.readOnly})]})]})]}),children:n.jsx(a.Button,{children:n.jsx("i",{className:"fa fa-ellipsis-h"})})})}function $e(e){const{hardware:t,options:r={}}=e,{properties:i,user_tags:s}=t;function o(){t.actions.call("stop")}function c(d){return t.actions.call("move",d)}const l=Re(i.state,s),u=n.jsx(C,{name:"Motor",icon:"fam-hardware-motor",online:t.online}),h=n.jsx(Q,{hardware:t}),f=e.options?e.options.header:"top";return n.jsx(F,{hardware:t,widgetIcon:u,widgetState:h,widgetContent:n.jsxs(a.InputGroup,{children:[n.jsx(ee,{id:t.id,hardwareValue:(i==null?void 0:i.position)??null,hardwareIsDisabled:e.disabled,hardwareIsReady:l.READY??!1,hardwareIsMoving:l.MOVING??!1,onMoveRequested:c,onAbortRequested:o,precision:r.precision??i.display_digits??void 0,readOnly:r.readOnly,step:r.step,steps:r.steps,incIcon:r.incicon,decIcon:r.decicon,swapIncDec:r.swapincdec,horizontalArrows:r.horizontalarrows,largeArrows:r.largearrows}),i.unit&&n.jsx(a.InputGroup.Text,{children:i.unit}),!l.MOVING&&r.extended&&n.jsx(Te,{hardware:t,disabled:e.disabled,readOnly:r.readOnly,states:l}),l.MOVING&&!e.disabled&&!r.step&&n.jsx(a.Button,{variant:"danger",onClick:o,children:n.jsx("i",{className:"fa fa-times"})})]}),headerMode:f})}function _e(e){const{hardware:t,options:r={}}=e,i=p.useRef(null);p.useEffect(()=>{if(!i.current){console.error("selectionRef ref is unset");return}i.current.value=t.properties.position},[t.properties.position]);function s(l){if(console.debug("change",l),!i||!i.current){console.error("selection ref is unset");return}t.actions.call("move",i.current.value)}function o(l){t.actions.call("stop")}const c=y.map(t.properties.positions,l=>n.jsx("option",{title:l.description,children:l.position},l.position));return n.jsxs("div",{className:"hw-component",children:[n.jsxs("div",{className:"hw-head",children:[n.jsx(C,{name:"Multiposition",icon:"fam-hardware-multiposition",online:t.online}),n.jsx("div",{className:"name",children:t.name}),n.jsx(a.Badge,{bg:t.properties.state==="READY"?"success":"warning",children:t.properties.state})]}),n.jsx("div",{className:"hw-content",children:n.jsxs(a.InputGroup,{children:[n.jsxs(a.Form.Control,{className:"custom-select",as:"select",ref:i,disabled:e.disabled,defaultValue:t.properties.position,children:[n.jsx("option",{disabled:!0,children:"unknown"}),c]}),t.properties.state!=="MOVING"&&n.jsx(a.Button,{onClick:s,disabled:e.disabled,children:"Move"}),t.properties.state==="MOVING"&&!e.disabled&&n.jsx(a.Button,{variant:"danger",onClick:o,children:n.jsx("i",{className:"fa fa-times"})})]})})]})}function Pe(e){const t=e.online?"READY":"OFFLINE";return n.jsx(a.Badge,{bg:t==="READY"?"success":"warning",children:t})}function He(e){const{hardware:t,options:r={}}=e,i=n.jsx(C,{name:"Optic",icon:"fa-cog",online:t.online}),s=n.jsx(Pe,{...t});function o(){const f=r.property;if(f===void 0)return"property is not set";if(f===null)return"property is null";let d=t;for(const m of f.split("/"))if(d=d[m],d===void 0)return`property '${f}' not found`;return`${d}`}function c(){const f=r.unit;if(!f)return null;if(!f.includes("properties"))return f;let d=e;for(const m of f.split("/"))if(d=d[m],d===void 0)return null;return`${d}`}const l=c(),u=n.jsxs(a.InputGroup,{children:[n.jsx(a.Form.Control,{value:o(),readOnly:!0}),l&&n.jsx(a.InputGroup.Text,{children:l})]}),h=e.options.header||"top";return n.jsx(F,{hardware:t,widgetIcon:i,widgetState:s,widgetContent:u,headerMode:h})}function te(e){const{hardware:t}=e;function r(){if(!t.online)return"OFFLINE";const o=t.properties.state;return e.useReadyState&&(o==="OPEN"||o==="CLOSED")?"READY":o}const i=r();function s(){switch(i){case"READY":return"success";case"OPEN":return"success";case"CLOSED":return"danger";case"DISABLED":return"secondary";case"MOVING":case"STANDBY":case"OFFLINE":return"warning";case"FAULT":return"fatal";default:return"fatal"}}return n.jsx(k,{state:i,minWidth:6,variant:s()})}function Be(e){const{hardware:t}=e;function r(){t.actions.call("reset")}return n.jsx(a.OverlayTrigger,{trigger:"click",rootClose:!0,overlay:n.jsxs(a.Popover,{id:"popid",children:[n.jsxs(a.Popover.Header,{children:[t.name," Details"]}),n.jsxs(a.Popover.Body,{children:[n.jsx("h6",{children:"Status"}),n.jsx("pre",{children:t.properties.status}),n.jsx("div",{className:"d-grid gap-2",children:n.jsx(a.Button,{onClick:r,disabled:e.disabled,children:"Reset"})})]})]}),children:n.jsx(a.Button,{className:"flex-grow-0",title:"Shutter Details",children:n.jsx("i",{className:"fa fa-ellipsis-h"})})})}function Le(e){const{hardware:t,options:r={}}=e,i=n.jsx(C,{name:"Shutter",icon:"fam-hardware-shutter",online:t.online}),s=n.jsx(te,{hardware:t});function o(){return t.properties?t.properties.state:"UNKNOWN"}function c(N){return N==="OPEN"?["Close","close"]:N==="CLOSED"?["Open","open"]:N==="DISABLED"||N==="STANDBY"||N==="FAULT"?["Closed",""]:N==="MOVING"?["...",""]:["Unknown",""]}const l=o(),[u,h]=c(l),d={OPEN:"danger",CLOSED:"success",MOVING:"warning",DISABLED:"secondary",STANDBY:"danger",FAULT:"fatal",UNKNOWN:"warning"}[l]||"danger";function m(){t.actions.call(h)}const w=n.jsxs(a.ButtonGroup,{className:"d-flex flex-nowrap",children:[n.jsx(a.Button,{variant:d,onClick:m,disabled:e.disabled||h==="",children:u}),r.extended&&n.jsx(Be,{...e})]}),S=e.options.header||"top";return n.jsx(F,{hardware:t,widgetIcon:i,widgetState:s,widgetContent:w,headerMode:S})}class Ve extends p.Component{constructor(){super(...arguments),this.variants={}}render(){let t=this.variants.default;return this.props.options.variant in this.variants&&(t=this.variants[this.props.options.variant]),n.jsx(t,{...this.props})}}const Ye=Ne.default("daiquiri.components.hardware.NoObject");function Ge(e){if(e.options.emptyifnone)return Ye('Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',e.id,e.name),n.jsx(n.Fragment,{});const t=n.jsx(C,{name:"NoObject",icon:"fam-hardware-any",online:!1}),r=n.jsx(n.Fragment,{}),i=n.jsx(n.Fragment,{children:"Missing"}),s=e.options?e.options.header:"top",o={id:e.id,name:e.name??"",alias:null,user_tags:[],online:!1,locked:null,properties:{},type:""};return n.jsx(F,{hardware:o,widgetIcon:t,widgetState:r,widgetContent:i,headerMode:s})}function ne(e){const[t,r]=p.useState({}),i=p.useRef(null);return p.useEffect(()=>{if(i.current){const s=i.current;r({width:s.clientWidth,height:s.clientHeight})}},[]),n.jsx("div",{ref:i,style:{width:"100%",height:"100%"},className:e.className,children:t.width>0&&n.jsx("div",{className:"full-sizer",style:{width:`${t.width}px`,height:`${t.height}px`,overflow:"scroll"},children:e.children})})}function Ke(e){return n.jsx("div",{className:"panel-header",style:e.style,children:e.children})}function Ue(e){return n.jsx("div",{className:`panel-contents ${e.className}`,style:e.style,children:e.children})}function g(e){const t=e.scroll?ne:p.Fragment;return n.jsx("div",{className:`panel ${e.className??""}`,style:e.style,children:n.jsx(t,{children:e.children})})}g.Header=Ke;g.Contents=Ue;const ze=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),We=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),D={};function re(e,t){D[e]=t}function v(e,t,r=!0){if(!e)return n.jsx(n.Fragment,{});const{type:i}=e,s=i&&i in D?D[i]:D.component;return n.jsx(s,{yamlNode:e,panel:r},t)}function qe({children:e,key:t,panel:r,options:i}){return r?n.jsx(g,{style:i.style,scroll:i.scroll,children:n.jsx(g.Contents,{children:e})},t):n.jsx(n.Fragment,{children:p.Children.map(e,s=>p.isValidElement(s)?p.cloneElement(s,{key:t,...s.props}):void 0)})}function ie(e,t){const{_parentNode:r,_indexFromParent:i,...s}=t;if(e&&Object.keys(s).length>0)throw new R(e,Object.keys(s))}class b extends Error{constructor(t,r){super(t),this.yamlNode=r}}class R extends b{constructor(t,r){super(`Unexpected keys: ${r.join(", ")}`,t),this.keys=r}}class M extends b{constructor(t,r){super(`Keys ${r.join(", ")} are missing`,t),this.keys=r}}class j extends b{constructor(t,r,i){super(`Key ${r} error: ${i}`,t),this.key=r,this.keyMessage=i}}function Ze(e){let t=e;for(;t._parentNode;)t=t._parentNode;return t}function Je(e){const t=[];let r=e;for(;r;)t.push({node:r,indexFromParent:r._indexFromParent}),r=r._parentNode;return t.reverse(),t}function se(e,t=null,r=null){if(e._parentNode)throw new Error("Attribute _parentNode was already defined by the yml layout.");const i={...e,_parentNode:t,_indexFromParent:r};if(e.children){const s=[...e.children];Object.freeze(s),i.children=s.map((o,c)=>se(o,i,c))}return Object.freeze(i),i}function oe(e){var t;return n.jsxs(a.Alert,{variant:"danger",children:[e.message,n.jsx("br",{}),n.jsx("pre",{children:(t=e.error)==null?void 0:t.stack})]})}function Qe(e){const{error:t}=e;if(!(t instanceof b))return n.jsx(n.Fragment,{});function r(o,c=3){const l=Je(o.yamlNode),u=[];let h="";for(let f=1;f<l.length;f++){const{node:d,indexFromParent:m}=l[f];u.push(`${h}children:`),h+=" ".repeat(c),m===1?u.push(`${h}- type: ...`):(m??0>1)&&u.push(`${h}...`,`${h}...`,`${h}# children number ${m??0+1}`),u.push(`${h}- type: ${d.type}`),h+=" ".repeat(2)}return o instanceof R?o.keys.forEach(f=>{u.push(`${h}${f}: ... ${" ".repeat(50-h.length-f.length)}<-- unexpected key`)}):o instanceof M?o.keys.forEach(f=>{u.push(`${h}???: ${" ".repeat(50-h.length-f.length)}<-- key **${f}** is expected`)}):o instanceof j&&u.push(`${h}${o.key}: ${" ".repeat(50-h.length-o.key.length)}<-- ${o.keyMessage}`),u.join(`
2
+ `)}const s=Ze(t.yamlNode).name;if(t instanceof R){const o=t.keys.length===1?"key":"keys";return n.jsxs(a.Alert,{variant:"danger",children:["Unexpected ",o," ",t.keys.map((c,l)=>n.jsxs(n.Fragment,{children:[l!==0&&", ",n.jsx("b",{children:c})]}))," ","from the layout name ",n.jsx("b",{children:s}),".",n.jsx("br",{}),n.jsx("pre",{className:"mt-3",children:r(t)}),n.jsx("br",{})]})}if(t instanceof M){const o=t.keys.length===1?"Key":"Keys";return n.jsxs(a.Alert,{variant:"danger",children:["Expected ",o," ",t.keys.map((c,l)=>n.jsxs(n.Fragment,{children:[l!==0&&", ",n.jsx("b",{children:c})]}))," ","from the layout name ",n.jsx("b",{children:s}),".",n.jsx("br",{}),n.jsx("pre",{className:"mt-3",children:r(t)}),n.jsx("br",{})]})}return t instanceof j?n.jsxs(a.Alert,{variant:"danger",children:["Error on key ",n.jsx("b",{children:t.key})," from the layout name ",n.jsx("b",{children:s}),".",n.jsx("br",{}),n.jsx("pre",{className:"mt-3",children:r(t)}),n.jsx("br",{})]}):n.jsx(oe,{...e})}const z={hasError:!1,message:"",error:void 0};class ae extends p.Component{constructor(t){super(t),this.reload=()=>{window.location.reload()},this.state=z}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){var r,i;if(t instanceof b||!this.props.unhandledComponentDidCatch){this.setState({hasError:!0,message:t.message,error:t});return}(i=(r=this.props).unhandledComponentDidCatch)==null||i.call(r,t,s=>{this.setState({hasError:!0,message:t.message,error:t,...s})})}componentDidUpdate(t,r){this.state.hasError&&r.error!==void 0&&t.resetKey!==this.props.resetKey&&this.setState(z)}render(){if(this.state.hasError){const{UnhandledErrorComponent:t}=this.props,{hasError:r,...i}=this.state;return n.jsxs(a.Container,{className:"mt-2",children:[n.jsx("h4",{children:"Something went wrong"}),this.state.error instanceof b&&n.jsx(Qe,{message:this.state.message,error:this.state.error}),!(this.state.error instanceof b)&&n.jsx(n.Fragment,{children:t?n.jsx(t,{...i}):n.jsx(oe,{message:this.state.message,error:this.state.error})}),n.jsxs("p",{children:["This error has been logged. Please"," ",n.jsxs(a.Button,{size:"sm",onClick:this.reload,children:[n.jsx("i",{className:"fa fa-refresh"})," Reload"]})," ","the application"]})]})}return this.props.children}}function Xe(e,t,r){if(e&&r===void 0)throw new M(e,[t])}function et(e,t,r){if(typeof r!="string")throw new j(e,t,"A string is expected")}function tt(e,t,r){if(typeof r!="boolean")throw new j(e,t,"A boolean is expected")}function nt(e,t,r){if(typeof r!="number")throw new j(e,t,"A number is expected")}function H(e,t,r){if(r!==void 0&&typeof r!="boolean")throw new j(e,t,"An optional boolean is expected")}function le(e,t,r){if(r!==void 0&&typeof r!="string")throw new j(e,t,"An optional string is expected")}function rt(e,t,r){if(!Array.isArray(r))throw new j(e,t,"A list of string is expected");r.forEach(i=>{if(typeof i!="string")throw new j(e,t,"A list of string is expected")})}function it(e,t,r){if(r!==void 0&&typeof r!="string"){if(!Array.isArray(r))throw new j(e,t,"An optional string or list of string is expected");r.forEach(i=>{if(typeof i!="string")throw new j(e,t,"An optional string or list of string is expected")})}}function st(e,t,r){if(r!==void 0){if(!Array.isArray(r))throw new j(e,t,"An optional list of string is expected");r.forEach(i=>{if(typeof i!="string")throw new j(e,t,"A optional list of string is expected")})}}function ce(e,t,r){if(r!==void 0&&typeof r!="number")throw new j(e,t,"An optional number is expected")}function ot(e,t,r){if(r!==void 0){if(!Array.isArray(r))throw new j(e,t,"An optional list of numbers is expected");r.forEach(i=>{if(typeof i!="number")throw new j(e,t,"An optional list of numbers is expected")})}}function T(e,t){const{_parentNode:r,_indexFromParent:i,...s}=t;if(e&&Object.keys(s).length>0)throw new R(e,Object.keys(s))}function at(e,t,r){if(r!=="last"&&typeof r!="number")throw new j(e,t,'"last" or a number is expected')}function lt(e,t,r){if(r!==void 0&&r!=="h5web"&&r!=="plotly")throw new j(e,t,'"h5web" or "plotly" string is expected')}const ct=Object.freeze(Object.defineProperty({__proto__:null,assertBoolean:tt,assertDataCollectionId:at,assertKeyExpected:Xe,assertNoUnknownKeys:T,assertNumber:nt,assertOptionalBackend:lt,assertOptionalBoolean:H,assertOptionalNumber:ce,assertOptionalNumberList:ot,assertOptionalString:le,assertOptionalStringList:st,assertOptionalStringOrStringList:it,assertString:et,assertStringList:rt},Symbol.toStringTag,{value:"Module"}));function dt({yamlNode:e,panel:t}){const{type:r,style:i,children:s,...o}=e;return T(e,o),n.jsx(a.Row,{className:"ymllayout-row gx-0",style:i,children:y.map(s,(c,l)=>v(c,l,t))})}function ut({yamlNode:e,panel:t}){const{type:r,style:i,xs:s,children:o,...c}=e;return T(e,c),ce(e,"xs",s),n.jsx(a.Col,{className:A.default("yamymllayout-col",{col:!!s}),style:i,xs:s,children:y.map(e.children,(l,u)=>v(l,u,t))})}const B={};function ht(e,t){B[e]=t}function ft(e,t){if(t===void 0)throw new M(e,["id"]);if(typeof t.id!="string")throw new j(e,"id","A string is expected")}function mt(e,t,r){if(r!==void 0){if(!Array.isArray(r))throw new j(e,t,"A option list is expected");r.forEach((i,s)=>{try{ft(e,i)}catch{throw new j(e,t,`The hardware description ${s} is wrong`)}})}}function pt(e){const{providers:t={},yamlNode:r,ids:i,groupid:s,even:o,nowrap:c,...l}=e;if(mt(r,"ids",i),le(r,"groupid",s),H(r,"even",o),H(r,"nowrap",c),T(r,l),!B.HardwareGroup)return n.jsx(a.Alert,{variant:"warning",children:"No `HardwareGroup` component registered"});const u=B.HardwareGroup;return n.jsx(u,{providers:t,ids:i,groupid:s,nowrap:c||!1,even:o||!1})}const L={hardwaregroup:pt};function de(e,t){L[e]=t}function xt(e){Object.entries(e).forEach(([t,r])=>de(t,r))}function gt(e){const{yamlNode:t,panel:r}=e,{type:i,style:s,scroll:o,title:c,...l}=t;if(!(i in L))return n.jsx(g,{children:n.jsx(g.Contents,{children:n.jsxs(a.Alert,{variant:"warning",children:['Unknown component "',i,'"']})})});const u=L[t.type];return r?n.jsx(g,{style:s,scroll:o,children:n.jsxs(p.Suspense,{fallback:n.jsx("p",{children:"Loading..."}),children:[c&&n.jsx(g.Header,{children:c}),n.jsx(g.Contents,{children:n.jsx(u,{...l,yamlNode:t})})]})}):n.jsx(p.Suspense,{fallback:n.jsx("p",{children:"Loading..."}),children:n.jsx(u,{...l,yamlNode:t})})}function jt({yamlNode:e,panel:t}){const r=e.options||{};return n.jsx(a.Container,{className:"ymllayout-container",...r,children:y.map(e.children,(i,s)=>v(i,s,t))})}function wt(e){const{yamlNode:t}=e,r=t.options||{},i={};return r.centerContent&&(i.margin="auto"),n.jsxs(g,{className:"ymllayout-panel",...r,children:[t.title&&n.jsx(g.Header,{children:t.title}),n.jsx(g.Contents,{style:i,children:y.map(t.children,(s,o)=>v(s,o,!1))})]})}const yt=()=>Math.random().toString(36).slice(2,15)+Math.random().toString(36).slice(2,15);function vt({yamlNode:e,panel:t}){const r=[];return y.each(e.children,(i,s)=>{r.push(n.jsx(a.Tab,{eventKey:yt(),title:i.title,children:v(i,0,!1)},s))}),t?n.jsxs(g,{className:"ymllayout-tabs",children:[e.title&&n.jsx(g.Header,{children:e.title}),n.jsx(g.Contents,{children:n.jsx(a.Tabs,{mountOnEnter:!0,children:r})})]}):n.jsx(a.Tabs,{children:r})}function Nt(e){const{node:t}=e,{type:r,title:i,...s}=t;return ie(t,s),n.jsx("div",{className:"ymllayout-form-header",style:{gridColumn:"1 / 3"},children:n.jsx("h3",{children:i})})}function bt(e){const{node:t,state:r,row:i}=e,{title:s}=t;function o(){if(t.id)return t.id}function c(){if(s!==void 0)return s;if(t.type==="hardware"){const u=o(),h={_parentNode:t._parentNode,_indexFromParent:t._indexFromParent,type:"hardware",id:u,variant:"name",emptyifnone:!0};return v(h,"a",!1)}return""}const l=c();return n.jsxs("div",{style:{textAlign:"center"},children:[n.jsx("h5",{style:{margin:"0px",whiteSpace:"nowrap"},children:l}),r&&n.jsx("div",{style:{position:"relative",top:-5},children:r})]})}function Ct(e){const{node:t,row:r}=e,{titlealign:i,title:s,stateinheader:o=!1,variant:c,id:l,...u}=t;let h,f;if(u.type==="hardware")if(h={...u,id:l,variant:c},o){const d={...u,id:l,variant:"state",emptyifnone:!0};f=v(d,"k",!1)}else f=null;else h=u,f=null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{gridColumn:1,alignSelf:i??"center"},children:n.jsx(bt,{node:t,state:f,row:r})}),n.jsx("div",{style:{gridColumn:2,alignSelf:"center"},children:v(h,"k",!1)})]})}function St(e){const{yamlNode:t,panel:r}=e,{type:i,children:s,options:o={},title:c,...l}=t;return ie(t,l),n.jsxs(g,{className:"ymllayout-form",...o,children:[t.title&&n.jsx(g.Header,{children:t.title}),n.jsx(g.Contents,{className:"full-sizer",style:{overflow:"auto"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:"min-content auto"},children:y.map(s,(u,h)=>u.type==="formheader"?n.jsx(Nt,{node:u,row:h},h):n.jsx(Ct,{node:u,row:h},h))})})]})}function Ot(e){const{yamlNode:t,panel:r}=e;return n.jsxs("div",{className:"ymllayout-grid",style:{gridTemplateColumns:t.columns,gridTemplateRows:t.rows},children:[y.map(t.children,(i,s)=>{const{columnSpan:o=1,rowSpan:c=1,...l}=i,u=o>1?`span ${o}`:void 0,h=c>1?`span ${c}`:void 0;return n.jsx("div",{className:"ymllayout-grid-cell",style:{gridColumn:u,gridRow:h},children:v(l,s,r)},s)})," "]})}function Et({yamlNode:e,panel:t}){const r=e.options||{};return n.jsx(qe,{panel:t,options:r,children:n.jsx("div",{children:e.label})})}const ue={row:dt,col:ut,container:jt,component:gt,panel:wt,tabs:vt,form:St,grid:Ot,label:Et};Object.entries(ue).forEach(([e,t])=>{re(e,t)});function Mt(e){var r;const t=p.useMemo(()=>se(e.layout),[e.layout]);return t.error?n.jsx("div",{className:`${e.className??""} ymllayout-main`,"data-testid":e.testid,children:n.jsxs(g,{children:[n.jsx(g.Header,{children:"Layout Error"}),n.jsxs(g.Contents,{children:[n.jsxs("p",{children:["File: ",t.name]}),n.jsx(a.Alert,{variant:"warning",children:n.jsx("pre",{className:"mb-0",children:t.error})})]})]})}):n.jsx("div",{className:`${e.className??""} ymllayout-main`,"data-testid":e.testid,children:n.jsx(ae,{resetKey:t,unhandledComponentDidCatch:e.unhandledComponentDidCatch,UnhandledErrorComponent:e.UnhandledErrorComponent,children:(r=t.children)==null?void 0:r.map((i,s)=>v(i,s))})})}const At=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),he={hardware:xe};function Ft(e,t){he[e]=t}function It(e){return n.jsxs(a.Col,{className:"monitor-panel-item bg-fatal",title:`Error from yaml configuration: ${e.message}`,children:[n.jsx("h1",{children:e.monitor.name}),n.jsx("div",{children:"Parsing error"})]})}function Dt(e){const t=y.map(e.monitors,(r,i)=>{const s=r.type??"hardware",o=he[s];return o===void 0?n.jsx(It,{monitor:r,message:`Type ${s} unsupported`},`m${i}`):n.jsx(o,{monitor:r},`m${i}`)});return n.jsx("div",{className:A.default({"ms-auto":e.margin==="start"},"me-auto","monitor-panel",{"monitor-panel-light":e.bg==="light"}),children:n.jsx(a.Container,{fluid:!0,children:n.jsx(a.Row,{className:"flex-nowrap",children:t})})})}function kt(e){return n.jsx(a.Col,{className:"monitor-panel-item",children:e.children})}const V={};function Rt(e,t){V[e]=t}function fe(e){if(!V.useHardware)throw new Error("No `useHardware` hook registered");return V.useHardware(e)}const me=(e,t,r)=>{const i={">":(s,o)=>s>o,"<":(s,o)=>s<o,">=":(s,o)=>s>=o,"<=":(s,o)=>s<=o,"==":(s,o)=>s===o,"!=":(s,o)=>s!==o,in:(s,o)=>o.indexOf(s)>-1};if(e in i)return i[e](t,r)};function pe(e,t,r){const i=e.split(t);return r?[i.slice(0,-r).join(t)].concat(i.slice(-r)):i}function W(e){const t=e!==void 0?pe(e,".",1):[null,""],r=fe(t[0]);if(r&&r.properties&&t[1]!==null)return Array.isArray(r.properties[t[1]])?r.properties[t[1]][0]:r.properties[t[1]]}function Tt(e){const t=e!==void 0&&!e.includes("."),r=e!==void 0?pe(e,".",1):[null,""],i=fe(r[0]);if(t)return e;if(i&&i.properties&&r[1]!==null)return`${i.properties[r[1]]}`}function xe(e){const{monitor:t}=e;let r=W(t.value)??"-";const i=Tt(t.unit),s=W(t.overlay),o=Number.parseFloat(`${r}`);Number.isNaN(o)||String(o).length>5&&(r=o.toPrecision(5));let c;if(t.comparator&&t.comparison&&(c=me(t.comparator,r,t.comparison)?"valid":"invalid"),Number.isNaN(o)||i!==void 0&&(r=`${r} ${i}`),s){const l=`${s}`;return n.jsx(a.OverlayTrigger,{placement:"bottom",overlay:n.jsx(a.Tooltip,{id:"tooltipid",className:"monitor-panel-tooltip",children:l.includes(`
3
+ `)?n.jsx("pre",{children:l}):l}),children:n.jsxs(a.Col,{className:"monitor-panel-item",children:[n.jsx("h1",{children:t.name}),n.jsx("div",{className:c,children:`${r}`})]})},t.name)}return n.jsxs(a.Col,{className:"monitor-panel-item",children:[n.jsx("h1",{children:t.name}),n.jsx("div",{className:c,children:`${r}`})]},t.name)}exports.Formatting=Me;exports.Frontend=Fe;exports.FullSizer=ne;exports.HWObject=At;exports.HardwareInputNumber=P;exports.HardwareNumericStep=ee;exports.HardwareSchema=We;exports.HardwareState=De;exports.HardwareTemplate=F;exports.HardwareTypes=ze;exports.HardwareVariant=Ve;exports.Info=Ie;exports.KeyError=j;exports.MissingKeysError=M;exports.MonitorHardware=xe;exports.MonitorPanel=Dt;exports.MonitorPanelItem=kt;exports.MotorDefault=$e;exports.MotorState=Q;exports.Multiposition=_e;exports.NoObject=Ge;exports.NumericStep=X;exports.Panel=g;exports.Property=He;exports.ShutterDefault=Le;exports.ShutterState=te;exports.TypeIcon=C;exports.YAMLErrorBoundary=ae;exports.YAMLLayout=Mt;exports.YamlAsserts=ct;exports.dynamicOp=me;exports.registerHardwareComponent=ht;exports.registerMonitorComponent=Ft;exports.registerRuntimeHook=Rt;exports.registerYamlComponent=de;exports.registerYamlComponents=xt;exports.registerYamlType=re;exports.renderYamlNode=v;exports.yamlMap=ue;
4
4
  //# sourceMappingURL=index.js.map